Fixing lots of smaller bugs and code inconsitencies.
Added several annotations and removed globalInfo/TipText methods.
This commit is contained in:
parent
531bbe50ed
commit
63fe74d2e0
@ -324,6 +324,10 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
||||
|
||||
break;
|
||||
case "EvolutionStrategies":
|
||||
//double cm, cr;
|
||||
//int mu, lambda;
|
||||
boolean plusStrategy;
|
||||
//this.optimizer = OptimizerFactory.createEvolutionStrategy()
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unsupported Optimizer");
|
||||
@ -349,7 +353,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
||||
OptimizerFactory.setEvaluationTerminator(50000);
|
||||
OptimizerFactory.addTerminator(new FitnessValueTerminator(new double[]{0.00001}), CombinedTerminator.OR);
|
||||
|
||||
LOGGER.log(Level.INFO, "Running {0}", "Differential Evolution");
|
||||
LOGGER.log(Level.INFO, "Running {0}", optimizer.getName());
|
||||
|
||||
OptimizationParameters params = OptimizerFactory.makeParams(optimizer, this.populationSize, this.problem);
|
||||
double[] result = OptimizerFactory.optimizeToDouble(params);
|
||||
|
@ -7,35 +7,29 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 11.05.2003
|
||||
* Time: 13:14:06
|
||||
* To change this template use Options | File Templates.
|
||||
*
|
||||
*/
|
||||
public interface InterfaceOptimizationParameters {
|
||||
/**
|
||||
* This method allows you to serialize the current parameters into a *.ser file
|
||||
*/
|
||||
public void saveInstance();
|
||||
void saveInstance();
|
||||
|
||||
/**
|
||||
* This method returns the name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public String getName();
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* This methods allow you to set and get the Seed for the Random Number Generator.
|
||||
*
|
||||
* @param x Long seed.
|
||||
*/
|
||||
public void setSeed(long x);
|
||||
void setSeed(long x);
|
||||
|
||||
public long getSeed();
|
||||
|
||||
public String seedTipText();
|
||||
long getSeed();
|
||||
|
||||
/**
|
||||
* This method allows you to choose a termination criteria for the
|
||||
@ -43,48 +37,33 @@ public interface InterfaceOptimizationParameters {
|
||||
*
|
||||
* @param term The new terminator
|
||||
*/
|
||||
public void setTerminator(InterfaceTerminator term);
|
||||
void setTerminator(InterfaceTerminator term);
|
||||
|
||||
public InterfaceTerminator getTerminator();
|
||||
|
||||
public String terminatorTipText();
|
||||
InterfaceTerminator getTerminator();
|
||||
|
||||
/**
|
||||
* This method allows you to set the current optimizing algorithm
|
||||
*
|
||||
* @param optimizer The new optimizing algorithm
|
||||
*/
|
||||
public void setOptimizer(InterfaceOptimizer optimizer);
|
||||
void setOptimizer(InterfaceOptimizer optimizer);
|
||||
|
||||
public InterfaceOptimizer getOptimizer();
|
||||
// public String optimizerTipText();
|
||||
InterfaceOptimizer getOptimizer();
|
||||
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
public void setProblem(InterfaceOptimizationProblem problem);
|
||||
void setProblem(InterfaceOptimizationProblem problem);
|
||||
|
||||
public InterfaceOptimizationProblem getProblem();
|
||||
InterfaceOptimizationProblem getProblem();
|
||||
|
||||
public String problemTipText();
|
||||
InterfacePostProcessParams getPostProcessParams();
|
||||
|
||||
/**
|
||||
* This method will set the output filename
|
||||
*
|
||||
* @param name TODO invalidate these!
|
||||
*/
|
||||
// public void setOutputFileName (String name);
|
||||
// public String getOutputFileName ();
|
||||
// public String outputFileNameTipText();
|
||||
public InterfacePostProcessParams getPostProcessParams();
|
||||
void setPostProcessParams(InterfacePostProcessParams ppp);
|
||||
|
||||
public void setPostProcessParams(InterfacePostProcessParams ppp);
|
||||
|
||||
public String postProcessParamsTipText();
|
||||
|
||||
public void setDoPostProcessing(boolean doPP);
|
||||
void setDoPostProcessing(boolean doPP);
|
||||
|
||||
/**
|
||||
* Give an instance which should be informed about elements which are additional informers.
|
||||
@ -92,7 +71,7 @@ public interface InterfaceOptimizationParameters {
|
||||
* @param o
|
||||
* @see InterfaceAdditionalPopulationInformer
|
||||
*/
|
||||
public void addInformableInstance(InterfaceNotifyOnInformers o);
|
||||
void addInformableInstance(InterfaceNotifyOnInformers o);
|
||||
|
||||
public boolean removeInformableInstance(InterfaceNotifyOnInformers o);
|
||||
boolean removeInformableInstance(InterfaceNotifyOnInformers o);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
import eva2.tools.Serializer;
|
||||
import eva2.util.annotation.Parameter;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@ -23,13 +24,39 @@ import java.util.logging.Logger;
|
||||
|
||||
public abstract class AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable {
|
||||
protected static final Logger LOGGER = Logger.getLogger(AbstractOptimizationParameters.class.getName());
|
||||
|
||||
@Parameter(name = "Random Seed", description = "Random number seed, set to zero to use current system time.")
|
||||
protected long randomSeed = (long) 0.0;
|
||||
|
||||
// Opt. Algorithms and Parameters
|
||||
/**
|
||||
* The optimizer to be executed.
|
||||
*/
|
||||
@Parameter(name = "Optimizer", description = "Choose an optimization strategy.")
|
||||
protected InterfaceOptimizer optimizer;
|
||||
|
||||
/**
|
||||
* The optimization problem to be optimized.
|
||||
* When changed it is automatically applied to the
|
||||
* selected optimizer.
|
||||
*/
|
||||
@Parameter(name = "Problem", description = "Choose the problem that is to optimize and the EA individual parameters.")
|
||||
protected InterfaceOptimizationProblem problem;
|
||||
|
||||
/**
|
||||
* The termination criteria that terminated an
|
||||
* optimization run.
|
||||
*/
|
||||
@Parameter(name = "Terminator", description = "Choose a termination criterion.")
|
||||
protected InterfaceTerminator terminator;
|
||||
|
||||
/**
|
||||
* Post processing parameters.
|
||||
* This can be enabled in the UI and will perform additional
|
||||
* optimization e.g. with Hill Climbing.
|
||||
*/
|
||||
@Parameter(name = "Post Processing", description = "Parameters for the post processing step.")
|
||||
protected InterfacePostProcessParams postProcessing = new PostProcessParams(false);
|
||||
|
||||
transient protected InterfacePopulationChangedEventListener populationChangedEventListener;
|
||||
transient private List<InterfaceNotifyOnInformers> toInformAboutInformers = null;
|
||||
|
||||
@ -181,10 +208,6 @@ public abstract class AbstractOptimizationParameters implements InterfaceOptimiz
|
||||
return this.optimizer;
|
||||
}
|
||||
|
||||
public String optimizerTipText() {
|
||||
return "Choose an optimization strategy.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Optimization parameters";
|
||||
@ -207,11 +230,6 @@ public abstract class AbstractOptimizationParameters implements InterfaceOptimiz
|
||||
return this.problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String problemTipText() {
|
||||
return "Choose the problem that is to optimize and the EA individual parameters.";
|
||||
}
|
||||
|
||||
/**
|
||||
* This methods allow you to set and get the Seed for the Random Number Generator.
|
||||
*
|
||||
@ -232,11 +250,6 @@ public abstract class AbstractOptimizationParameters implements InterfaceOptimiz
|
||||
return randomSeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String seedTipText() {
|
||||
return "Random number seed, set to zero to use current system time.";
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to choose a termination criteria for the
|
||||
* evolutionary algorithm.
|
||||
@ -253,11 +266,6 @@ public abstract class AbstractOptimizationParameters implements InterfaceOptimiz
|
||||
return this.terminator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String terminatorTipText() {
|
||||
return "Choose a termination criterion.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfacePostProcessParams getPostProcessParams() {
|
||||
return postProcessing;
|
||||
@ -268,11 +276,6 @@ public abstract class AbstractOptimizationParameters implements InterfaceOptimiz
|
||||
postProcessing = ppp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String postProcessParamsTipText() {
|
||||
return "Parameters for the post processing step";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoPostProcessing(boolean doPP) {
|
||||
postProcessing.setDoPostProcessing(doPP);
|
||||
|
@ -102,7 +102,6 @@ public class MOEAParameters extends AbstractOptimizationParameters implements In
|
||||
((MultiObjectiveEA) this.optimizer).setOptimizer(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String optimizerTipText() {
|
||||
return "Choose a population based optimizing technique to use.";
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.optimization.strategies.GeneticAlgorithm;
|
||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
import eva2.tools.Serializer;
|
||||
import eva2.util.annotation.Description;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -16,16 +17,24 @@ import java.util.logging.Level;
|
||||
|
||||
|
||||
/**
|
||||
* OptimizationParamers for configuration of an
|
||||
* OptimizationParameters for configuration of an
|
||||
* optimization run.
|
||||
* <p/>
|
||||
* This class is used to generate the default GUI
|
||||
* configuration panel for optimizations.
|
||||
*/
|
||||
@Description("Select the optimization parameters.")
|
||||
public class OptimizationParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable {
|
||||
|
||||
/**
|
||||
* Should be removed and replaced by a more solid
|
||||
* serialization. (EvAScript?)
|
||||
*
|
||||
* @deprecated
|
||||
* @return
|
||||
*/
|
||||
public static OptimizationParameters getInstance() {
|
||||
return getInstance("OptimizationParameters.ser", true);
|
||||
return getInstance("OptimizationParameters.set", true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,13 +89,4 @@ public class OptimizationParameters extends AbstractOptimizationParameters imple
|
||||
public Object clone() {
|
||||
return new OptimizationParameters(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a global info string.
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "Select the optimization parameters.";
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,14 @@ import java.util.BitSet;
|
||||
*/
|
||||
public class CM2 implements InterfaceCrossover, java.io.Serializable {
|
||||
|
||||
private InterfaceOptimizationProblem m_OptimizationProblem;
|
||||
private InterfaceOptimizationProblem optimizationProblem;
|
||||
|
||||
public CM2() {
|
||||
|
||||
}
|
||||
|
||||
public CM2(CM2 c) {
|
||||
this.m_OptimizationProblem = c.m_OptimizationProblem;
|
||||
this.optimizationProblem = c.optimizationProblem;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,7 +58,7 @@ public class CM2 implements InterfaceCrossover, java.io.Serializable {
|
||||
@Override
|
||||
public void init(AbstractEAIndividual individual,
|
||||
InterfaceOptimizationProblem opt) {
|
||||
this.m_OptimizationProblem = opt;
|
||||
this.optimizationProblem = opt;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,11 +10,7 @@ import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Dante Alighieri
|
||||
* Date: 21.05.2005
|
||||
* Time: 11:36:38
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluatingCrossoverOperator, java.io.Serializable {
|
||||
public static final String CROSSOVER_EA_MIXER_OPERATOR_KEY = "CrossoverEAMixerOperatorKey";
|
||||
@ -60,7 +56,7 @@ public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluating
|
||||
this.m_Crossers.setSelectedCrossers(tmpList);
|
||||
this.m_Crossers.normalizeWeights();
|
||||
this.m_Crossers.setDescriptiveString("Combining alternative mutation operators, please norm the weights!");
|
||||
this.m_Crossers.setWeightsLabel("Weigths");
|
||||
this.m_Crossers.setWeightsLabel("Weights");
|
||||
}
|
||||
|
||||
public CrossoverEAMixer(CrossoverEAMixer mutator) {
|
||||
|
@ -86,7 +86,8 @@ public class TestESCrossover implements java.io.Serializable {
|
||||
double[] tmpD = new double[2];
|
||||
tmpD[0] = 0;
|
||||
tmpD[1] = 0;
|
||||
this.m_Plot = new Plot("ES Crossover Testert", "x", "y", tmpD, tmpD);
|
||||
// ToDo: Fix plot (it's internal and not showing)
|
||||
this.m_Plot = new Plot("ES Crossover Tester", "x", "y", tmpD, tmpD);
|
||||
// validate and show
|
||||
this.m_Frame.validate();
|
||||
this.m_Frame.setVisible(true);
|
||||
|
@ -6,7 +6,7 @@ import eva2.optimization.population.Population;
|
||||
/**
|
||||
* Simple method to selecet all.
|
||||
* In case of multiple fitness values the selection
|
||||
* critria is selected randomly for each selection event. pff
|
||||
* criteria is selected randomly for each selection event. pff
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 31.03.2004
|
||||
|
@ -211,6 +211,6 @@ public class SelectBestIndividuals implements InterfaceSelection, java.io.Serial
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
return "Toggle the use of Deb's coonstraint violation principle.";
|
||||
return "Toggle the use of Deb's constraint violation principle.";
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import eva2.tools.math.RNG;
|
||||
*/
|
||||
public class SelectTournament implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private int m_TournamentSize = 4;
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private int tournamentSize = 4;
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectTournament() {
|
||||
}
|
||||
@ -29,8 +29,8 @@ public class SelectTournament implements InterfaceSelection, java.io.Serializabl
|
||||
}
|
||||
|
||||
public SelectTournament(SelectTournament a) {
|
||||
this.m_TournamentSize = a.m_TournamentSize;
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.tournamentSize = a.tournamentSize;
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,9 +82,9 @@ public class SelectTournament implements InterfaceSelection, java.io.Serializabl
|
||||
try {
|
||||
critSize = ((AbstractEAIndividual) population.get(0)).getFitness().length;
|
||||
currentCriteria = RNG.randomInt(0, critSize - 1);
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
if (this.obeyDebsConstViolationPrinciple) {
|
||||
Population tournamentGroup = new Population();
|
||||
for (int i = 0; i < this.m_TournamentSize; i++) {
|
||||
for (int i = 0; i < this.tournamentSize; i++) {
|
||||
tournamentGroup.add(population.get(RNG.randomInt(0, population.size() - 1)));
|
||||
}
|
||||
SelectBestIndividuals best = new SelectBestIndividuals();
|
||||
@ -92,7 +92,7 @@ public class SelectTournament implements InterfaceSelection, java.io.Serializabl
|
||||
result = (AbstractEAIndividual) best.selectFrom(tournamentGroup, 1).get(0);
|
||||
} else {
|
||||
result = (AbstractEAIndividual) population.get(RNG.randomInt(0, population.size() - 1));
|
||||
for (int i = 1; i < this.m_TournamentSize; i++) {
|
||||
for (int i = 1; i < this.tournamentSize; i++) {
|
||||
tmpIndy = (AbstractEAIndividual) population.get(RNG.randomInt(0, population.size() - 1));
|
||||
if (tmpIndy.getFitness(currentCriteria) < result.getFitness(currentCriteria)) {
|
||||
result = tmpIndy;
|
||||
@ -152,11 +152,11 @@ public class SelectTournament implements InterfaceSelection, java.io.Serializabl
|
||||
}
|
||||
|
||||
public int getTournamentSize() {
|
||||
return m_TournamentSize;
|
||||
return tournamentSize;
|
||||
}
|
||||
|
||||
public void setTournamentSize(int g) {
|
||||
m_TournamentSize = g;
|
||||
tournamentSize = g;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,11 +167,11 @@ public class SelectTournament implements InterfaceSelection, java.io.Serializabl
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -6,81 +6,28 @@ import eva2.optimization.operator.selection.probability.SelProbStandard;
|
||||
import eva2.optimization.population.Population;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
|
||||
class treeElement implements java.io.Serializable {
|
||||
public double separator = 0;
|
||||
public int m_Index = -1;
|
||||
public treeElement m_Left = null, m_Right = null;
|
||||
|
||||
public treeElement(double[][] d, int list, int low, int high) {
|
||||
//System.out.println("Calling Low/high: "+low+"/"+high);
|
||||
if (low == high) {
|
||||
// end reached
|
||||
//System.out.println("This: "+low);
|
||||
this.m_Index = low;
|
||||
} else {
|
||||
if (low == high - 1) {
|
||||
//System.out.println("This: "+high);
|
||||
this.m_Index = high;
|
||||
} else {
|
||||
int midPoint = (int) ((high + low) / 2);
|
||||
this.separator = d[midPoint - 1][list];
|
||||
//System.out.println("Branching: "+midPoint + " : " + this.separator);
|
||||
this.m_Left = new treeElement(d, list, low, midPoint);
|
||||
this.m_Right = new treeElement(d, list, midPoint, high);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getIndexFor(double d) {
|
||||
if (this.m_Index >= 0) {
|
||||
return this.m_Index - 1;
|
||||
} else {
|
||||
if (d < this.separator) {
|
||||
return this.m_Left.getIndexFor(d);
|
||||
} else {
|
||||
return this.m_Right.getIndexFor(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.m_Index >= 0) {
|
||||
return "Ind:" + this.m_Index;
|
||||
} else {
|
||||
return "{" + this.m_Left.toString() + "} X<" + this.separator + " {" + this.m_Right.toString() + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The RoulettWheel selection requires a selection probability calculator.
|
||||
* The RouletteWheel selection requires a selection probability calculator.
|
||||
* In case of multiple fitness values the selection
|
||||
* critria is selected randomly for each selection event.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 18.03.2003
|
||||
* Time: 16:36:11
|
||||
* To change this template use Options | File Templates.
|
||||
* criteria is selected randomly for each selection event.
|
||||
*/
|
||||
public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private transient treeElement[] m_TreeRoot = null;
|
||||
private InterfaceSelectionProbability m_SelProbCalculator = new SelProbStandard();
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private transient TreeElement[] treeRoot = null;
|
||||
private InterfaceSelectionProbability selectionProbability = new SelProbStandard();
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectXProbRouletteWheel() {
|
||||
}
|
||||
|
||||
public SelectXProbRouletteWheel(SelectXProbRouletteWheel a) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.m_SelProbCalculator = (InterfaceSelectionProbability) a.m_SelProbCalculator.clone();
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
this.selectionProbability = (InterfaceSelectionProbability) a.selectionProbability.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return (Object) new SelectXProbRouletteWheel(this);
|
||||
return new SelectXProbRouletteWheel(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,8 +40,8 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser
|
||||
*/
|
||||
@Override
|
||||
public void prepareSelection(Population population) {
|
||||
this.m_SelProbCalculator.computeSelectionProbability(population, "Fitness", this.m_ObeyDebsConstViolationPrinciple);
|
||||
this.m_TreeRoot = this.buildSelectionTree(population);
|
||||
this.selectionProbability.computeSelectionProbability(population, "Fitness", this.obeyDebsConstViolationPrinciple);
|
||||
this.treeRoot = this.buildSelectionTree(population);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,8 +70,8 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser
|
||||
*
|
||||
* @param p The population
|
||||
*/
|
||||
private treeElement[] buildSelectionTree(Population p) {
|
||||
treeElement result[];
|
||||
private TreeElement[] buildSelectionTree(Population p) {
|
||||
TreeElement result[];
|
||||
double[][] tmpList = new double[p.size()][];
|
||||
|
||||
for (int i = 0; i < p.size(); i++) {
|
||||
@ -137,12 +84,12 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser
|
||||
}
|
||||
}
|
||||
|
||||
result = new treeElement[tmpList[0].length];
|
||||
result = new TreeElement[tmpList[0].length];
|
||||
for (int i = 0; i < tmpList[0].length; i++) {
|
||||
//String s = "Input: {";
|
||||
//for (int j = 0; j < tmpList.length; j++) s += tmpList[j][i] +"; ";
|
||||
//System.out.println(s+"}");
|
||||
result[i] = new treeElement(tmpList, i, 0, tmpList.length);
|
||||
result[i] = new TreeElement(tmpList, i, 0, tmpList.length);
|
||||
//System.out.println("Resulting Tree: " + result[i].toString());
|
||||
}
|
||||
|
||||
@ -160,7 +107,7 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser
|
||||
critSize = ((AbstractEAIndividual) population.get(0)).getSelectionProbability().length;
|
||||
currentCriteria = RNG.randomInt(0, critSize - 1);
|
||||
double d = RNG.randomDouble();
|
||||
int index = this.m_TreeRoot[currentCriteria].getIndexFor(d);
|
||||
int index = this.treeRoot[currentCriteria].getIndexFor(d);
|
||||
//System.out.println("Looking for: " + d + " found " +index);
|
||||
return ((AbstractEAIndividual) (population.get(index)));
|
||||
}
|
||||
@ -234,11 +181,11 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser
|
||||
* @param normation
|
||||
*/
|
||||
public void setSelProbCalculator(InterfaceSelectionProbability normation) {
|
||||
this.m_SelProbCalculator = normation;
|
||||
this.selectionProbability = normation;
|
||||
}
|
||||
|
||||
public InterfaceSelectionProbability getSelProbCalculator() {
|
||||
return this.m_SelProbCalculator;
|
||||
return this.selectionProbability;
|
||||
}
|
||||
|
||||
public String selProbCalculatorTipText() {
|
||||
@ -253,14 +200,62 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
return "Toggle the use of Deb's coonstraint violation principle.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TreeElement implements java.io.Serializable {
|
||||
public double separator = 0;
|
||||
public int m_Index = -1;
|
||||
public TreeElement m_Left = null, m_Right = null;
|
||||
|
||||
public TreeElement(double[][] d, int list, int low, int high) {
|
||||
//System.out.println("Calling Low/high: "+low+"/"+high);
|
||||
if (low == high) {
|
||||
// end reached
|
||||
//System.out.println("This: "+low);
|
||||
this.m_Index = low;
|
||||
} else {
|
||||
if (low == high - 1) {
|
||||
//System.out.println("This: "+high);
|
||||
this.m_Index = high;
|
||||
} else {
|
||||
int midPoint = (int) ((high + low) / 2);
|
||||
this.separator = d[midPoint - 1][list];
|
||||
//System.out.println("Branching: "+midPoint + " : " + this.separator);
|
||||
this.m_Left = new TreeElement(d, list, low, midPoint);
|
||||
this.m_Right = new TreeElement(d, list, midPoint, high);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getIndexFor(double d) {
|
||||
if (this.m_Index >= 0) {
|
||||
return this.m_Index - 1;
|
||||
} else {
|
||||
if (d < this.separator) {
|
||||
return this.m_Left.getIndexFor(d);
|
||||
} else {
|
||||
return this.m_Right.getIndexFor(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.m_Index >= 0) {
|
||||
return "Ind:" + this.m_Index;
|
||||
} else {
|
||||
return "{" + this.m_Left.toString() + "} X<" + this.separator + " {" + this.m_Right.toString() + "}";
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import eva2.optimization.population.SolutionSet;
|
||||
import eva2.optimization.problems.B1Problem;
|
||||
import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Parameter;
|
||||
|
||||
/**
|
||||
* Evolution strategies by Rechenberg and Schwefel, but please remember that
|
||||
@ -26,8 +27,13 @@ import eva2.util.annotation.Description;
|
||||
@Description(value = "This is an Evolution Strategy. Note that the population size depends on mu (number of parents) and lambda (number of offspring)")
|
||||
public class EvolutionStrategies implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
@Parameter(description = "Mu", name = "mu")
|
||||
protected int mu = 5;
|
||||
|
||||
@Parameter(description = "Lambda", name = "lambda")
|
||||
protected int lambda = 20;
|
||||
|
||||
@Parameter(description = "Determines whether the +-Strategy should be used.", name = "usePlus")
|
||||
protected boolean usePlusStrategy = false;
|
||||
protected Population population = new Population();
|
||||
protected InterfaceOptimizationProblem optimizationProblem = new B1Problem();
|
||||
|
Loading…
x
Reference in New Issue
Block a user