Random refactoring to make EvA2Problems work again.
This commit is contained in:
parent
3ac628e85f
commit
c8de290e4c
@ -13,6 +13,7 @@ public class GeneralOptimizationEditorProperty {
|
|||||||
public PropertyEditor editor;
|
public PropertyEditor editor;
|
||||||
public Object value;
|
public Object value;
|
||||||
public JComponent view;
|
public JComponent view;
|
||||||
|
public JComponent viewWrapper;
|
||||||
public JLabel label;
|
public JLabel label;
|
||||||
public Class propertyType;
|
public Class propertyType;
|
||||||
public String name;
|
public String name;
|
||||||
|
@ -52,7 +52,7 @@ public class ImpactOfDimensionOnMOEAs {
|
|||||||
mean = 0;
|
mean = 0;
|
||||||
for (int j = 0; j < multiRuns; j++) {
|
for (int j = 0; j < multiRuns; j++) {
|
||||||
pop = new Population();
|
pop = new Population();
|
||||||
ikel.initPopulation(pop, popSize, numberofVariables);
|
ikel.initializePopulation(pop, popSize, numberofVariables);
|
||||||
ikel.evaluatePopulation(pop, i);
|
ikel.evaluatePopulation(pop, i);
|
||||||
mean += ikel.numberOfParetoOptimalSolutions(pop) / (double) pop.size();
|
mean += ikel.numberOfParetoOptimalSolutions(pop) / (double) pop.size();
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ public class ImpactOfDimensionOnMOEAs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initPopulation(Population pop, int popSize, int numberOfVariables) {
|
public void initializePopulation(Population pop, int popSize, int numberOfVariables) {
|
||||||
AbstractEAIndividual tmpIndy, template;
|
AbstractEAIndividual tmpIndy, template;
|
||||||
pop.clear();
|
pop.clear();
|
||||||
template = new ESIndividualDoubleData();
|
template = new ESIndividualDoubleData();
|
||||||
|
@ -129,7 +129,7 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initPopulationAt(Population population, double time) {
|
public void initializePopulationAt(Population population, double time) {
|
||||||
getProblem().initializePopulation(population);
|
getProblem().initializePopulation(population);
|
||||||
for (Object individuum : population) {
|
for (Object individuum : population) {
|
||||||
((AbstractEAIndividual) individuum).setAge(0);
|
((AbstractEAIndividual) individuum).setAge(0);
|
||||||
|
@ -101,7 +101,7 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initializePopulation(Population population) {
|
public void initializePopulation(Population population) {
|
||||||
this.initPopulationAt(population, getCurrentProblemTime());
|
this.initializePopulationAt(population, getCurrentProblemTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,7 +110,7 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz
|
|||||||
* @param population The populations that is to be inited
|
* @param population The populations that is to be inited
|
||||||
* @param time current time stamp to be used
|
* @param time current time stamp to be used
|
||||||
*/
|
*/
|
||||||
public abstract void initPopulationAt(Population population, double time);
|
public abstract void initializePopulationAt(Population population, double time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the startTime
|
* @return the startTime
|
||||||
|
@ -96,7 +96,7 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
|
|||||||
this.template = new ESIndividualDoubleData();
|
this.template = new ESIndividualDoubleData();
|
||||||
makeBorder();
|
makeBorder();
|
||||||
if (this.show) {
|
if (this.show) {
|
||||||
this.initProblemFrame();
|
this.initializeProblemFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
|
|||||||
public void setShowParetoFront(boolean b) {
|
public void setShowParetoFront(boolean b) {
|
||||||
this.show = b;
|
this.show = b;
|
||||||
if (this.show) {
|
if (this.show) {
|
||||||
this.initProblemFrame();
|
this.initializeProblemFrame();
|
||||||
} else if (this.plot != null) {
|
} else if (this.plot != null) {
|
||||||
this.plot.dispose();
|
this.plot.dispose();
|
||||||
this.plot = null;
|
this.plot = null;
|
||||||
@ -146,7 +146,7 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
|
|||||||
makeBorder();
|
makeBorder();
|
||||||
this.paretoFront = new Population();
|
this.paretoFront = new Population();
|
||||||
if (this.show) {
|
if (this.show) {
|
||||||
this.initProblemFrame();
|
this.initializeProblemFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
|
|||||||
public void evaluatePopulationStart(Population population) {
|
public void evaluatePopulationStart(Population population) {
|
||||||
super.evaluatePopulationStart(population);
|
super.evaluatePopulationStart(population);
|
||||||
if (this.show && (this.plot == null)) {
|
if (this.show && (this.plot == null)) {
|
||||||
this.initProblemFrame();
|
this.initializeProblemFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
|
|||||||
/**
|
/**
|
||||||
* This method will initialize the problem specific visualisation of the problem
|
* This method will initialize the problem specific visualisation of the problem
|
||||||
*/
|
*/
|
||||||
public void initProblemFrame() {
|
public void initializeProblemFrame() {
|
||||||
double[] tmpD = new double[2];
|
double[] tmpD = new double[2];
|
||||||
tmpD[0] = 0;
|
tmpD[0] = 0;
|
||||||
tmpD[1] = 0;
|
tmpD[1] = 0;
|
||||||
|
@ -188,7 +188,7 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
|
|||||||
* @param template
|
* @param template
|
||||||
* @param prob
|
* @param prob
|
||||||
*/
|
*/
|
||||||
public static void defaultInitPopulation(Population population, AbstractEAIndividual template, InterfaceOptimizationProblem prob) {
|
public static void defaultInitializePopulation(Population population, AbstractEAIndividual template, InterfaceOptimizationProblem prob) {
|
||||||
AbstractEAIndividual tmpIndy;
|
AbstractEAIndividual tmpIndy;
|
||||||
population.clear();
|
population.clear();
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
|
|||||||
|
|
||||||
tmpBitSet = ((InterfaceDataTypeBinary) individual).getBinaryData();
|
tmpBitSet = ((InterfaceDataTypeBinary) individual).getBinaryData();
|
||||||
// evaluate the fitness
|
// evaluate the fitness
|
||||||
result = eval(tmpBitSet);
|
result = evaluate(tmpBitSet);
|
||||||
// set the fitness
|
// set the fitness
|
||||||
individual.setFitness(result);
|
individual.setFitness(result);
|
||||||
}
|
}
|
||||||
@ -52,12 +52,12 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
|
|||||||
* @param x a BitSet representing a possible
|
* @param x a BitSet representing a possible
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract double[] eval(BitSet bs);
|
public abstract double[] evaluate(BitSet bs);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializePopulation(Population population) {
|
public void initializePopulation(Population population) {
|
||||||
((InterfaceDataTypeBinary) this.template).setBinaryDataLength(this.getProblemDimension());
|
((InterfaceDataTypeBinary) this.template).setBinaryDataLength(this.getProblemDimension());
|
||||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -205,7 +205,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
@Override
|
@Override
|
||||||
public void initializePopulation(Population population) {
|
public void initializePopulation(Population population) {
|
||||||
initTemplate();
|
initTemplate();
|
||||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ public abstract class AbstractProblemInteger extends AbstractOptimizationProblem
|
|||||||
public void initializePopulation(Population population) {
|
public void initializePopulation(Population population) {
|
||||||
this.bestIndividuum = null;
|
this.bestIndividuum = null;
|
||||||
((InterfaceDataTypeInteger) this.template).setIntegerDataLength(this.problemDimension);
|
((InterfaceDataTypeInteger) this.template).setIntegerDataLength(this.problemDimension);
|
||||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,7 +48,7 @@ public class B1Problem extends AbstractProblemBinary implements java.io.Serializ
|
|||||||
* @return Double[]
|
* @return Double[]
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(BitSet b) {
|
public double[] evaluate(BitSet b) {
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
int fitness = 0;
|
int fitness = 0;
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
|||||||
BitSet tmpSet = new BitSet();
|
BitSet tmpSet = new BitSet();
|
||||||
tmpSet.clear();
|
tmpSet.clear();
|
||||||
|
|
||||||
while (eval(tmpSet)[1] > 0) {
|
while (evaluate(tmpSet)[1] > 0) {
|
||||||
tmpSet.set(RNG.randomInt(0, items.length - 1));
|
tmpSet.set(RNG.randomInt(0, items.length - 1));
|
||||||
}
|
}
|
||||||
((InterfaceDataTypeBinary) indy).setBinaryGenotype(tmpSet);
|
((InterfaceDataTypeBinary) indy).setBinaryGenotype(tmpSet);
|
||||||
@ -183,7 +183,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
|||||||
double[] result;
|
double[] result;
|
||||||
|
|
||||||
tmpBitSet = ((InterfaceDataTypeBinary) individual).getBinaryData();
|
tmpBitSet = ((InterfaceDataTypeBinary) individual).getBinaryData();
|
||||||
result = this.eval(tmpBitSet);
|
result = this.evaluate(tmpBitSet);
|
||||||
if (RNG.flipCoin(this.localSearch)) {
|
if (RNG.flipCoin(this.localSearch)) {
|
||||||
// first remove surplus assets
|
// first remove surplus assets
|
||||||
while (result[1] > 0) {
|
while (result[1] > 0) {
|
||||||
@ -203,7 +203,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
|||||||
}
|
}
|
||||||
// remove the weakest
|
// remove the weakest
|
||||||
tmpBitSet.clear(weakest);
|
tmpBitSet.clear(weakest);
|
||||||
result = this.eval(tmpBitSet);
|
result = this.evaluate(tmpBitSet);
|
||||||
}
|
}
|
||||||
// now lets see if we can replace some guy with a more efficient one
|
// now lets see if we can replace some guy with a more efficient one
|
||||||
int weakest = tmpBitSet.nextSetBit(0);
|
int weakest = tmpBitSet.nextSetBit(0);
|
||||||
@ -223,7 +223,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpBitSet.clear(weakest);
|
tmpBitSet.clear(weakest);
|
||||||
result = this.eval(tmpBitSet);
|
result = this.evaluate(tmpBitSet);
|
||||||
int weight = 0;
|
int weight = 0;
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
if (tmpBitSet.get(i)) {
|
if (tmpBitSet.get(i)) {
|
||||||
@ -246,7 +246,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
|||||||
if (stronger >= 0) {
|
if (stronger >= 0) {
|
||||||
tmpBitSet.set(stronger);
|
tmpBitSet.set(stronger);
|
||||||
}
|
}
|
||||||
result = this.eval(tmpBitSet);
|
result = this.evaluate(tmpBitSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lamarckism) {
|
if (this.lamarckism) {
|
||||||
@ -266,7 +266,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
|||||||
* @return Double[]
|
* @return Double[]
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(BitSet b) {
|
public double[] evaluate(BitSet b) {
|
||||||
double[] result = new double[3];
|
double[] result = new double[3];
|
||||||
|
|
||||||
int l = items.length;
|
int l = items.length;
|
||||||
@ -306,7 +306,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
|||||||
|
|
||||||
tmpIndy = (InterfaceDataTypeBinary) individual;
|
tmpIndy = (InterfaceDataTypeBinary) individual;
|
||||||
tmpBitSet = tmpIndy.getBinaryData();
|
tmpBitSet = tmpIndy.getBinaryData();
|
||||||
report = this.eval(tmpBitSet);
|
report = this.evaluate(tmpBitSet);
|
||||||
result += individual.getStringRepresentation() + "\n";
|
result += individual.getStringRepresentation() + "\n";
|
||||||
result += "Is worth: " + Math.abs(report[2]) + " and ";
|
result += "Is worth: " + Math.abs(report[2]) + " and ";
|
||||||
if (report[1] == 0) {
|
if (report[1] == 0) {
|
||||||
|
@ -149,7 +149,7 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
|
|||||||
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.problemDimension);
|
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.problemDimension);
|
||||||
((InterfaceDataTypeDouble) this.template).setDoubleRange(makeRange());
|
((InterfaceDataTypeDouble) this.template).setDoubleRange(makeRange());
|
||||||
|
|
||||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -285,7 +285,7 @@ public class FLensProblem extends AbstractOptimizationProblem
|
|||||||
}
|
}
|
||||||
((InterfaceDataTypeDouble) this.template).setDoubleRange(range);
|
((InterfaceDataTypeDouble) this.template).setDoubleRange(range);
|
||||||
|
|
||||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||||
if (this.show) {
|
if (this.show) {
|
||||||
this.initProblemFrame();
|
this.initProblemFrame();
|
||||||
}
|
}
|
||||||
|
@ -561,7 +561,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
|||||||
@Override
|
@Override
|
||||||
public void initializePopulation(Population population) {
|
public void initializePopulation(Population population) {
|
||||||
initTemplate();
|
initTemplate();
|
||||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -144,7 +144,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initializePopulation(Population population) {
|
public void initializePopulation(Population population) {
|
||||||
initPopulation(population, this, useInnerConst, numberOfConstants);
|
initializePopulation(population, this, useInnerConst, numberOfConstants);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -155,7 +155,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
|
|||||||
* @param useInnerConsts
|
* @param useInnerConsts
|
||||||
* @param numConsts
|
* @param numConsts
|
||||||
*/
|
*/
|
||||||
public static void initPopulation(Population pop, InterfaceProgramProblem prob, boolean useInnerConsts, int numConsts) {
|
public static void initializePopulation(Population pop, InterfaceProgramProblem prob, boolean useInnerConsts, int numConsts) {
|
||||||
AbstractEAIndividual template;
|
AbstractEAIndividual template;
|
||||||
|
|
||||||
template = ((AbstractOptimizationProblem) prob).getIndividualTemplate();
|
template = ((AbstractOptimizationProblem) prob).getIndividualTemplate();
|
||||||
@ -166,7 +166,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
|
|||||||
if ((template instanceof GAPIndividualProgramData) && useInnerConsts) {
|
if ((template instanceof GAPIndividualProgramData) && useInnerConsts) {
|
||||||
((GAPIndividualProgramData) template).setDoubleDataLength(numConsts);
|
((GAPIndividualProgramData) template).setDoubleDataLength(numConsts);
|
||||||
}
|
}
|
||||||
AbstractOptimizationProblem.defaultInitPopulation(pop, template, prob);
|
AbstractOptimizationProblem.defaultInitializePopulation(pop, template, prob);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
|||||||
@Override
|
@Override
|
||||||
public void initializePopulation(Population population) {
|
public void initializePopulation(Population population) {
|
||||||
initTemplate();
|
initTemplate();
|
||||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,7 +95,7 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
|
|||||||
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.problemDimension);
|
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.problemDimension);
|
||||||
((InterfaceDataTypeDouble) this.template).setDoubleRange(newRange);
|
((InterfaceDataTypeDouble) this.template).setDoubleRange(newRange);
|
||||||
|
|
||||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double[][] makeRange() {
|
protected double[][] makeRange() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user