Fix globalInfo/annotations.
This commit is contained in:
parent
0202692844
commit
079715bb24
@ -39,8 +39,10 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* <p> The OptimizerFactory allows quickly creating some optimizers without
|
* <p> The OptimizerFactory allows quickly creating some optimizers without
|
||||||
* thinking much about parameters. You can access a runnable Optimization thread
|
* thinking much about parameters. You can access a runnable Optimization thread
|
||||||
* and directly start it, or access its fully prepared GOParameter instance,
|
* and directly start it, or access its fully prepared OptimizationParameter instance,
|
||||||
* change some parameters, and start it then. </p> <p> On the other hand this
|
* change some parameters, and start it then.
|
||||||
|
* </p> <p>
|
||||||
|
* On the other hand this
|
||||||
* class provides an almost complete list of all currently available
|
* class provides an almost complete list of all currently available
|
||||||
* optimization procedures in EvA2. The arguments passed to the methods
|
* optimization procedures in EvA2. The arguments passed to the methods
|
||||||
* initialize the respective optimization procedure. To perform an optimization
|
* initialize the respective optimization procedure. To perform an optimization
|
||||||
@ -50,12 +52,6 @@ import java.util.List;
|
|||||||
* EvaluationTerminator terminator = new EvaluationTerminator(numOfFitnessCalls);
|
* EvaluationTerminator terminator = new EvaluationTerminator(numOfFitnessCalls);
|
||||||
* while (!terminator.isTerminated(optimizer.getPopulation())) optimizer.optimize();
|
* while (!terminator.isTerminated(optimizer.getPopulation())) optimizer.optimize();
|
||||||
* </code> </p>
|
* </code> </p>
|
||||||
*
|
|
||||||
* @author mkron
|
|
||||||
* @author Andreas Dräger
|
|
||||||
* @version 0.1
|
|
||||||
* @date 17.04.2007
|
|
||||||
* @since 2.0
|
|
||||||
*/
|
*/
|
||||||
public class OptimizerFactory {
|
public class OptimizerFactory {
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import eva2.util.annotation.Description;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Description(value = "Boolean combination of two terminators.")
|
@Description("Boolean combination of two terminators.")
|
||||||
public class CombinedTerminator implements InterfaceTerminator, Serializable {
|
public class CombinedTerminator implements InterfaceTerminator, Serializable {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -4,6 +4,7 @@ import eva2.optimization.operator.distancemetric.InterfaceDistanceMetric;
|
|||||||
import eva2.optimization.operator.distancemetric.PhenotypeMetric;
|
import eva2.optimization.operator.distancemetric.PhenotypeMetric;
|
||||||
import eva2.optimization.population.Population;
|
import eva2.optimization.population.Population;
|
||||||
import eva2.optimization.population.PopulationInterface;
|
import eva2.optimization.population.PopulationInterface;
|
||||||
|
import eva2.util.annotation.Description;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ -14,9 +15,10 @@ import java.io.Serializable;
|
|||||||
* May be computationally expensive.
|
* May be computationally expensive.
|
||||||
*
|
*
|
||||||
* @author mkron
|
* @author mkron
|
||||||
* @see Population.getPopulationMeasures()
|
* @see Population#getPopulationMeasures()
|
||||||
* @see PhenotypeMetric
|
* @see PhenotypeMetric
|
||||||
*/
|
*/
|
||||||
|
@Description("The diversity terminator uses the distance of individuals in the population as a termination criterion.")
|
||||||
public class DiversityTerminator extends PopulationMeasureTerminator implements InterfaceTerminator, Serializable {
|
public class DiversityTerminator extends PopulationMeasureTerminator implements InterfaceTerminator, Serializable {
|
||||||
public enum DiversityCriterion {averageDistance, minimumDistance, maximumDistance}
|
public enum DiversityCriterion {averageDistance, minimumDistance, maximumDistance}
|
||||||
|
|
||||||
@ -35,10 +37,6 @@ public class DiversityTerminator extends PopulationMeasureTerminator implements
|
|||||||
this.criterion = divCrit;
|
this.criterion = divCrit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String globalInfo() {
|
|
||||||
return "The diversity terminator uses the distance of individuals in the population as a termination criterion.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the metric
|
* @return the metric
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +35,7 @@ public class EvaluationTerminator implements InterfaceTerminator,
|
|||||||
/**
|
/**
|
||||||
* Construct Terminator with a maximum number of fitness calls.
|
* Construct Terminator with a maximum number of fitness calls.
|
||||||
*
|
*
|
||||||
* @param maximum number of fitness calls
|
* @param x number of fitness calls
|
||||||
*/
|
*/
|
||||||
public EvaluationTerminator(int x) {
|
public EvaluationTerminator(int x) {
|
||||||
maxFitnessCalls = x;
|
maxFitnessCalls = x;
|
||||||
@ -68,12 +68,10 @@ public class EvaluationTerminator implements InterfaceTerminator,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFitnessCalls(int x) {
|
public void setFitnessCalls(int x) {
|
||||||
//System.out.println("setFitnessCalls"+x);
|
|
||||||
maxFitnessCalls = x;
|
maxFitnessCalls = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFitnessCalls() {
|
public int getFitnessCalls() {
|
||||||
//System.out.println("getFitnessCalls"+maxFitnessCalls);
|
|
||||||
return maxFitnessCalls;
|
return maxFitnessCalls;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ package eva2.optimization.operator.terminators;
|
|||||||
|
|
||||||
import eva2.optimization.population.PopulationInterface;
|
import eva2.optimization.population.PopulationInterface;
|
||||||
import eva2.tools.math.Mathematics;
|
import eva2.tools.math.Mathematics;
|
||||||
|
import eva2.util.annotation.Description;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ import java.io.Serializable;
|
|||||||
*
|
*
|
||||||
* @see PopulationMeasureTerminator
|
* @see PopulationMeasureTerminator
|
||||||
*/
|
*/
|
||||||
|
@Description("Stop if a fitness convergence criterion has been met.")
|
||||||
public class FitnessConvergenceTerminator extends PopulationMeasureTerminator
|
public class FitnessConvergenceTerminator extends PopulationMeasureTerminator
|
||||||
implements InterfaceTerminator, Serializable {
|
implements InterfaceTerminator, Serializable {
|
||||||
|
|
||||||
@ -27,10 +29,6 @@ public class FitnessConvergenceTerminator extends PopulationMeasureTerminator
|
|||||||
super(other);
|
super(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String globalInfo() {
|
|
||||||
return "Stop if a fitness convergence criterion has been met.";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected double calcInitialMeasure(PopulationInterface pop) {
|
protected double calcInitialMeasure(PopulationInterface pop) {
|
||||||
return Mathematics.norm(pop.getBestFitness());
|
return Mathematics.norm(pop.getBestFitness());
|
||||||
|
@ -4,12 +4,14 @@ import eva2.gui.BeanInspector;
|
|||||||
import eva2.optimization.population.InterfaceSolutionSet;
|
import eva2.optimization.population.InterfaceSolutionSet;
|
||||||
import eva2.optimization.population.PopulationInterface;
|
import eva2.optimization.population.PopulationInterface;
|
||||||
import eva2.problems.InterfaceOptimizationProblem;
|
import eva2.problems.InterfaceOptimizationProblem;
|
||||||
|
import eva2.util.annotation.Description;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Description("Terminate if a certain fitness value has been reached.")
|
||||||
public class FitnessValueTerminator implements InterfaceTerminator,
|
public class FitnessValueTerminator implements InterfaceTerminator,
|
||||||
Serializable {
|
Serializable {
|
||||||
protected double[] fitnessValue;
|
protected double[] fitnessValue;
|
||||||
@ -27,13 +29,6 @@ public class FitnessValueTerminator implements InterfaceTerminator,
|
|||||||
msg = "Not terminated.";
|
msg = "Not terminated.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static String globalInfo() {
|
|
||||||
return "Terminate if a certain fitness value has been reached.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -6,6 +6,7 @@ import eva2.optimization.population.PopulationInterface;
|
|||||||
import eva2.problems.InterfaceMultimodalProblemKnown;
|
import eva2.problems.InterfaceMultimodalProblemKnown;
|
||||||
import eva2.problems.InterfaceOptimizationProblem;
|
import eva2.problems.InterfaceOptimizationProblem;
|
||||||
import eva2.tools.EVAERROR;
|
import eva2.tools.EVAERROR;
|
||||||
|
import eva2.util.annotation.Description;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -16,9 +17,8 @@ import java.util.logging.Logger;
|
|||||||
* implements InterfaceMultimodalProblemKnown. A population is regarded as terminated
|
* implements InterfaceMultimodalProblemKnown. A population is regarded as terminated
|
||||||
* if the preset number of optima is identified.
|
* if the preset number of optima is identified.
|
||||||
* For any other problem types, this terminator will not make sense, so take care.
|
* For any other problem types, this terminator will not make sense, so take care.
|
||||||
*
|
|
||||||
* @author mkron
|
|
||||||
*/
|
*/
|
||||||
|
@Description("Terminate if a given number of optima has been found. Works for problems implementing InterfaceMultimodalProblemKnown, e.g. FM0.")
|
||||||
public class KnownOptimaFoundTerminator implements InterfaceTerminator, Serializable {
|
public class KnownOptimaFoundTerminator implements InterfaceTerminator, Serializable {
|
||||||
private Logger LOGGER = Logger.getLogger(KnownOptimaFoundTerminator.class.getName());
|
private Logger LOGGER = Logger.getLogger(KnownOptimaFoundTerminator.class.getName());
|
||||||
private InterfaceMultimodalProblemKnown mProblem = null;
|
private InterfaceMultimodalProblemKnown mProblem = null;
|
||||||
@ -90,8 +90,4 @@ public class KnownOptimaFoundTerminator implements InterfaceTerminator, Serializ
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "KnownOptimaFoundTerminator requiring " + reqOptima + " optima.";
|
return "KnownOptimaFoundTerminator requiring " + reqOptima + " optima.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String globalInfo() {
|
|
||||||
return "Terminate if a given number of optima has been found. Works for problems implementing InterfaceMultimodalProblemKnown, e.g. FM0.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import eva2.optimization.population.PopulationInterface;
|
|||||||
import eva2.problems.AbstractMultiObjectiveOptimizationProblem;
|
import eva2.problems.AbstractMultiObjectiveOptimizationProblem;
|
||||||
import eva2.problems.InterfaceOptimizationProblem;
|
import eva2.problems.InterfaceOptimizationProblem;
|
||||||
import eva2.tools.EVAERROR;
|
import eva2.tools.EVAERROR;
|
||||||
|
import eva2.util.annotation.Description;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ -17,9 +18,10 @@ import java.io.Serializable;
|
|||||||
* on the fitness range.
|
* on the fitness range.
|
||||||
* The metric may be employed on the current population or the current pareto front
|
* The metric may be employed on the current population or the current pareto front
|
||||||
* maintained by the problem instance.
|
* maintained by the problem instance.
|
||||||
*
|
|
||||||
* @author mkron
|
|
||||||
*/
|
*/
|
||||||
|
@Description("Terminate if the pareto front of a multi-objective optimization process converges " +
|
||||||
|
"with respect to a certain measure. Note that this only works with " +
|
||||||
|
"AbstractMultiObjectiveOptimizationProblem instances.")
|
||||||
public class ParetoMetricTerminator extends PopulationMeasureTerminator implements Serializable {
|
public class ParetoMetricTerminator extends PopulationMeasureTerminator implements Serializable {
|
||||||
private InterfaceParetoFrontMetric pMetric = new MetricS();
|
private InterfaceParetoFrontMetric pMetric = new MetricS();
|
||||||
AbstractMultiObjectiveOptimizationProblem moProb = null;
|
AbstractMultiObjectiveOptimizationProblem moProb = null;
|
||||||
@ -87,12 +89,6 @@ public class ParetoMetricTerminator extends PopulationMeasureTerminator implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String globalInfo() {
|
|
||||||
return "Terminate if the pareto front of a multi-objective optimization process converges " +
|
|
||||||
"with respect to a certain measure. Note that this only works with " +
|
|
||||||
"AbstractMultiObjectiveOptimizationProblem instances.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParetoMetric(InterfaceParetoFrontMetric pMetric) {
|
public void setParetoMetric(InterfaceParetoFrontMetric pMetric) {
|
||||||
this.pMetric = pMetric;
|
this.pMetric = pMetric;
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,12 @@ import eva2.optimization.individuals.AbstractEAIndividual;
|
|||||||
import eva2.optimization.operator.distancemetric.PhenotypeMetric;
|
import eva2.optimization.operator.distancemetric.PhenotypeMetric;
|
||||||
import eva2.optimization.population.PopulationInterface;
|
import eva2.optimization.population.PopulationInterface;
|
||||||
import eva2.problems.InterfaceOptimizationProblem;
|
import eva2.problems.InterfaceOptimizationProblem;
|
||||||
|
import eva2.util.annotation.Description;
|
||||||
|
|
||||||
|
@Description("Terminate if the best individual of the current population moved less than a threshold within phenotypic space.")
|
||||||
public class PhenotypeConvergenceTerminator extends PopulationMeasureTerminator implements InterfaceTerminator {
|
public class PhenotypeConvergenceTerminator extends PopulationMeasureTerminator implements InterfaceTerminator {
|
||||||
AbstractEAIndividual oldIndy = null;
|
AbstractEAIndividual oldIndy = null;
|
||||||
private PhenotypeMetric pMetric = null;
|
private PhenotypeMetric pMetric = null;
|
||||||
// double oldPhenNorm = 0;
|
|
||||||
|
|
||||||
public PhenotypeConvergenceTerminator() {
|
public PhenotypeConvergenceTerminator() {
|
||||||
super();
|
super();
|
||||||
@ -24,20 +25,17 @@ public class PhenotypeConvergenceTerminator extends PopulationMeasureTerminator
|
|||||||
super(o);
|
super(o);
|
||||||
oldIndy = (AbstractEAIndividual) o.oldIndy.clone();
|
oldIndy = (AbstractEAIndividual) o.oldIndy.clone();
|
||||||
pMetric = (PhenotypeMetric) o.pMetric.clone();
|
pMetric = (PhenotypeMetric) o.pMetric.clone();
|
||||||
// oldPhenNorm = o.oldPhenNorm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(InterfaceOptimizationProblem prob) {
|
public void initialize(InterfaceOptimizationProblem prob) {
|
||||||
super.initialize(prob);
|
super.initialize(prob);
|
||||||
// oldPhenNorm = 0;
|
|
||||||
oldIndy = null;
|
oldIndy = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected double calcInitialMeasure(PopulationInterface pop) {
|
protected double calcInitialMeasure(PopulationInterface pop) {
|
||||||
oldIndy = (AbstractEAIndividual) ((AbstractEAIndividual) pop.getBestIndividual()).clone();
|
oldIndy = (AbstractEAIndividual) ((AbstractEAIndividual) pop.getBestIndividual()).clone();
|
||||||
// oldPhenNorm = PhenotypeMetric.norm(oldIndy);
|
|
||||||
return Double.MAX_VALUE;
|
return Double.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,15 +48,10 @@ public class PhenotypeConvergenceTerminator extends PopulationMeasureTerminator
|
|||||||
protected void saveState(PopulationInterface Pop) {
|
protected void saveState(PopulationInterface Pop) {
|
||||||
super.saveState(Pop);
|
super.saveState(Pop);
|
||||||
oldIndy = (AbstractEAIndividual) ((AbstractEAIndividual) Pop.getBestIndividual()).clone();
|
oldIndy = (AbstractEAIndividual) ((AbstractEAIndividual) Pop.getBestIndividual()).clone();
|
||||||
// oldPhenNorm = PhenotypeMetric.norm(oldIndy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getMeasureName() {
|
protected String getMeasureName() {
|
||||||
return "Phenotype";
|
return "Phenotype";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String globalInfo() {
|
|
||||||
return "Terminate if the best individual of the current population moved less than a threshold within phenotypic space.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,16 @@ package eva2.optimization.operator.terminators;
|
|||||||
import eva2.optimization.individuals.IndividualWeightedFitnessComparator;
|
import eva2.optimization.individuals.IndividualWeightedFitnessComparator;
|
||||||
import eva2.optimization.population.Population;
|
import eva2.optimization.population.Population;
|
||||||
import eva2.optimization.population.PopulationInterface;
|
import eva2.optimization.population.PopulationInterface;
|
||||||
|
import eva2.util.annotation.Description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminate if a score based on the archive of the population converges.
|
* Terminate if a score based on the archive of the population converges.
|
||||||
* Note that this only works if the archive is filled with sensible data.
|
* Note that this only works if the archive is filled with sensible data.
|
||||||
*
|
|
||||||
* @author mkron
|
|
||||||
*/
|
*/
|
||||||
|
@Description("Stop if a linear recombination of the best fitness stagnates for a certain period.")
|
||||||
public class PopulationArchiveTerminator extends PopulationMeasureTerminator {
|
public class PopulationArchiveTerminator extends PopulationMeasureTerminator {
|
||||||
IndividualWeightedFitnessComparator wfComp = new IndividualWeightedFitnessComparator(new double[]{1.});
|
IndividualWeightedFitnessComparator wfComp = new IndividualWeightedFitnessComparator(new double[]{1.});
|
||||||
|
|
||||||
public static String globalInfo() {
|
|
||||||
return "Stop if a linear recombination of the best fitness stagnates for a certain period.";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected double calcInitialMeasure(PopulationInterface pop) {
|
protected double calcInitialMeasure(PopulationInterface pop) {
|
||||||
Population archive = ((Population) pop).getArchive();
|
Population archive = ((Population) pop).getArchive();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user