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 Object value;
|
||||
public JComponent view;
|
||||
public JComponent viewWrapper;
|
||||
public JLabel label;
|
||||
public Class propertyType;
|
||||
public String name;
|
||||
|
@ -52,7 +52,7 @@ public class ImpactOfDimensionOnMOEAs {
|
||||
mean = 0;
|
||||
for (int j = 0; j < multiRuns; j++) {
|
||||
pop = new Population();
|
||||
ikel.initPopulation(pop, popSize, numberofVariables);
|
||||
ikel.initializePopulation(pop, popSize, numberofVariables);
|
||||
ikel.evaluatePopulation(pop, i);
|
||||
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;
|
||||
pop.clear();
|
||||
template = new ESIndividualDoubleData();
|
||||
|
@ -129,7 +129,7 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void initPopulationAt(Population population, double time) {
|
||||
public void initializePopulationAt(Population population, double time) {
|
||||
getProblem().initializePopulation(population);
|
||||
for (Object individuum : population) {
|
||||
((AbstractEAIndividual) individuum).setAge(0);
|
||||
|
@ -101,7 +101,7 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz
|
||||
*/
|
||||
@Override
|
||||
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 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
|
||||
|
@ -96,7 +96,7 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
|
||||
this.template = new ESIndividualDoubleData();
|
||||
makeBorder();
|
||||
if (this.show) {
|
||||
this.initProblemFrame();
|
||||
this.initializeProblemFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
|
||||
public void setShowParetoFront(boolean b) {
|
||||
this.show = b;
|
||||
if (this.show) {
|
||||
this.initProblemFrame();
|
||||
this.initializeProblemFrame();
|
||||
} else if (this.plot != null) {
|
||||
this.plot.dispose();
|
||||
this.plot = null;
|
||||
@ -146,7 +146,7 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
|
||||
makeBorder();
|
||||
this.paretoFront = new Population();
|
||||
if (this.show) {
|
||||
this.initProblemFrame();
|
||||
this.initializeProblemFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
|
||||
public void evaluatePopulationStart(Population population) {
|
||||
super.evaluatePopulationStart(population);
|
||||
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
|
||||
*/
|
||||
public void initProblemFrame() {
|
||||
public void initializeProblemFrame() {
|
||||
double[] tmpD = new double[2];
|
||||
tmpD[0] = 0;
|
||||
tmpD[1] = 0;
|
||||
|
@ -188,7 +188,7 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
|
||||
* @param template
|
||||
* @param prob
|
||||
*/
|
||||
public static void defaultInitPopulation(Population population, AbstractEAIndividual template, InterfaceOptimizationProblem prob) {
|
||||
public static void defaultInitializePopulation(Population population, AbstractEAIndividual template, InterfaceOptimizationProblem prob) {
|
||||
AbstractEAIndividual tmpIndy;
|
||||
population.clear();
|
||||
|
||||
|
@ -40,7 +40,7 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
|
||||
|
||||
tmpBitSet = ((InterfaceDataTypeBinary) individual).getBinaryData();
|
||||
// evaluate the fitness
|
||||
result = eval(tmpBitSet);
|
||||
result = evaluate(tmpBitSet);
|
||||
// set the fitness
|
||||
individual.setFitness(result);
|
||||
}
|
||||
@ -52,12 +52,12 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
|
||||
* @param x a BitSet representing a possible
|
||||
* @return
|
||||
*/
|
||||
public abstract double[] eval(BitSet bs);
|
||||
public abstract double[] evaluate(BitSet bs);
|
||||
|
||||
@Override
|
||||
public void initializePopulation(Population population) {
|
||||
((InterfaceDataTypeBinary) this.template).setBinaryDataLength(this.getProblemDimension());
|
||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
||||
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -205,7 +205,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
||||
@Override
|
||||
public void initializePopulation(Population population) {
|
||||
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) {
|
||||
this.bestIndividuum = null;
|
||||
((InterfaceDataTypeInteger) this.template).setIntegerDataLength(this.problemDimension);
|
||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
||||
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,7 +48,7 @@ public class B1Problem extends AbstractProblemBinary implements java.io.Serializ
|
||||
* @return Double[]
|
||||
*/
|
||||
@Override
|
||||
public double[] eval(BitSet b) {
|
||||
public double[] evaluate(BitSet b) {
|
||||
double[] result = new double[1];
|
||||
int fitness = 0;
|
||||
|
||||
|
@ -165,7 +165,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
||||
BitSet tmpSet = new BitSet();
|
||||
tmpSet.clear();
|
||||
|
||||
while (eval(tmpSet)[1] > 0) {
|
||||
while (evaluate(tmpSet)[1] > 0) {
|
||||
tmpSet.set(RNG.randomInt(0, items.length - 1));
|
||||
}
|
||||
((InterfaceDataTypeBinary) indy).setBinaryGenotype(tmpSet);
|
||||
@ -183,7 +183,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
||||
double[] result;
|
||||
|
||||
tmpBitSet = ((InterfaceDataTypeBinary) individual).getBinaryData();
|
||||
result = this.eval(tmpBitSet);
|
||||
result = this.evaluate(tmpBitSet);
|
||||
if (RNG.flipCoin(this.localSearch)) {
|
||||
// first remove surplus assets
|
||||
while (result[1] > 0) {
|
||||
@ -203,7 +203,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
||||
}
|
||||
// remove the 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
|
||||
int weakest = tmpBitSet.nextSetBit(0);
|
||||
@ -223,7 +223,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
||||
}
|
||||
|
||||
tmpBitSet.clear(weakest);
|
||||
result = this.eval(tmpBitSet);
|
||||
result = this.evaluate(tmpBitSet);
|
||||
int weight = 0;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (tmpBitSet.get(i)) {
|
||||
@ -246,7 +246,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
||||
if (stronger >= 0) {
|
||||
tmpBitSet.set(stronger);
|
||||
}
|
||||
result = this.eval(tmpBitSet);
|
||||
result = this.evaluate(tmpBitSet);
|
||||
}
|
||||
|
||||
if (this.lamarckism) {
|
||||
@ -266,7 +266,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
||||
* @return Double[]
|
||||
*/
|
||||
@Override
|
||||
public double[] eval(BitSet b) {
|
||||
public double[] evaluate(BitSet b) {
|
||||
double[] result = new double[3];
|
||||
|
||||
int l = items.length;
|
||||
@ -306,7 +306,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
||||
|
||||
tmpIndy = (InterfaceDataTypeBinary) individual;
|
||||
tmpBitSet = tmpIndy.getBinaryData();
|
||||
report = this.eval(tmpBitSet);
|
||||
report = this.evaluate(tmpBitSet);
|
||||
result += individual.getStringRepresentation() + "\n";
|
||||
result += "Is worth: " + Math.abs(report[2]) + " and ";
|
||||
if (report[1] == 0) {
|
||||
|
@ -149,7 +149,7 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
|
||||
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.problemDimension);
|
||||
((InterfaceDataTypeDouble) this.template).setDoubleRange(makeRange());
|
||||
|
||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
||||
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -285,7 +285,7 @@ public class FLensProblem extends AbstractOptimizationProblem
|
||||
}
|
||||
((InterfaceDataTypeDouble) this.template).setDoubleRange(range);
|
||||
|
||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
||||
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||
if (this.show) {
|
||||
this.initProblemFrame();
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
||||
@Override
|
||||
public void initializePopulation(Population population) {
|
||||
initTemplate();
|
||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
||||
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,7 +144,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
|
||||
*/
|
||||
@Override
|
||||
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 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;
|
||||
|
||||
template = ((AbstractOptimizationProblem) prob).getIndividualTemplate();
|
||||
@ -166,7 +166,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
|
||||
if ((template instanceof GAPIndividualProgramData) && useInnerConsts) {
|
||||
((GAPIndividualProgramData) template).setDoubleDataLength(numConsts);
|
||||
}
|
||||
AbstractOptimizationProblem.defaultInitPopulation(pop, template, prob);
|
||||
AbstractOptimizationProblem.defaultInitializePopulation(pop, template, prob);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,7 +104,7 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
||||
@Override
|
||||
public void initializePopulation(Population population) {
|
||||
initTemplate();
|
||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
||||
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,7 +95,7 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
|
||||
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.problemDimension);
|
||||
((InterfaceDataTypeDouble) this.template).setDoubleRange(newRange);
|
||||
|
||||
AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
|
||||
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
|
||||
}
|
||||
|
||||
protected double[][] makeRange() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user