Rename more init() methods to initialize()

This commit is contained in:
Fabian Becker 2014-11-02 14:53:27 +01:00
parent 97d79612c2
commit 8104c9baf7
31 changed files with 44 additions and 52 deletions

View File

@ -113,7 +113,7 @@ public class TestESCrossover implements java.io.Serializable {
tmpIndyEA.initialize(optimizationProblem); tmpIndyEA.initialize(optimizationProblem);
partners.add(tmpIndyEA); partners.add(tmpIndyEA);
} }
partners.init(); partners.initialize();
daddy = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone(); daddy = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
daddy.initialize(optimizationProblem); daddy.initialize(optimizationProblem);
plot.clearAll(); plot.clearAll();

View File

@ -40,7 +40,7 @@ public class PBILPopulation extends Population implements Cloneable, java.io.Ser
* have been inited by a problem. * have been inited by a problem.
*/ */
@Override @Override
public void init() { public void initialize() {
this.generationCount = 0; this.generationCount = 0;
this.functionCallCount = 0; this.functionCallCount = 0;
if (!(this.get(0) instanceof InterfaceGAIndividual)) { if (!(this.get(0) instanceof InterfaceGAIndividual)) {

View File

@ -363,19 +363,17 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
} }
/** /**
* This method inits the state of the population AFTER the individuals have * This method initializes the state of the population AFTER the individuals have
* been inited by a problem * been initialized by a problem
*/ */
public void init() { public void initialize() {
this.historyList = new LinkedList<>(); this.historyList = new LinkedList<>();
this.generationCount = 0; this.generationCount = 0;
this.functionCallCount = 0; this.functionCallCount = 0;
double[] popSeed = null; double[] popSeed = null;
// evaluationTimeHashes = null;
// evaluationTimeModCount = -1;
if (this.populationArchive != null) { if (this.populationArchive != null) {
this.populationArchive.clear(); this.populationArchive.clear();
this.populationArchive.init(); this.populationArchive.initialize();
} }
switch (initMethod) { switch (initMethod) {
case individualDefault: case individualDefault:
@ -433,14 +431,12 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
return seedPos; return seedPos;
} }
@Parameter(description = "Position around which the population will be (randomly) initialized. Be aware that the vector length must match (or exceed) problem dimension!")
public void setInitPos(double[] si) { public void setInitPos(double[] si) {
seedPos = si; seedPos = si;
} }
public String initPosTipText() { @Parameter(description = "Length of hypercube within which individuals are initialized around the initial position.")
return "Position around which the population will be (randomly) initialized. Be aware that the vector length must match (or exceed) problem dimension!";
}
public void setInitAround(double d) { public void setInitAround(double d) {
aroundDist = d; aroundDist = d;
} }
@ -449,10 +445,6 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
return aroundDist; return aroundDist;
} }
public String initAroundTipText() {
return "Lenght of hypercube within which individuals are initialized around the initial position.";
}
/** /**
* This method inits the population. Function and generation counters are * This method inits the population. Function and generation counters are
* reset and size default Individuals are created and initialized by the * reset and size default Individuals are created and initialized by the

View File

@ -65,7 +65,7 @@ public class AdaptiveDifferentialEvolution extends AbstractOptimizer {
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.evaluatePopulation(this.population); this.evaluatePopulation(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -64,7 +64,7 @@ public class ArtificialBeeColony extends AbstractOptimizer implements Serializab
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.evaluatePopulation(this.population); this.evaluatePopulation(this.population);
this.bestIndividual = this.population.getBestEAIndividual(); this.bestIndividual = this.population.getBestEAIndividual();
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);

View File

@ -78,7 +78,7 @@ public class CHCAdaptiveSearchAlgorithm extends AbstractOptimizer implements jav
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
} }
AbstractEAIndividual tmpIndy = ((AbstractEAIndividual) (this.population.get(0))); AbstractEAIndividual tmpIndy = ((AbstractEAIndividual) (this.population.get(0)));
if (tmpIndy instanceof InterfaceGAIndividual) { if (tmpIndy instanceof InterfaceGAIndividual) {

View File

@ -216,7 +216,7 @@ public class ClusterBasedNichingEA extends AbstractOptimizer implements Interfac
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.undifferentiatedPopulation = (Population) pop.clone(); this.undifferentiatedPopulation = (Population) pop.clone();
if (reset) { if (reset) {
this.undifferentiatedPopulation.init(); this.undifferentiatedPopulation.initialize();
} }
initDefaults(reset); initDefaults(reset);
} }

View File

@ -114,7 +114,7 @@ public class ClusteringHillClimbing extends AbstractOptimizer implements Interfa
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
population.addPopulationChangedEventListener(null); population.addPopulationChangedEventListener(null);
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.optimizationProblem.evaluate(this.population); this.optimizationProblem.evaluate(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -117,7 +117,7 @@ public class DifferentialEvolution extends AbstractOptimizer implements java.io.
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.evaluatePopulation(this.population); this.evaluatePopulation(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -908,7 +908,7 @@ public class EsDpiNiching extends AbstractOptimizer implements Serializable, Int
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.optimizationProblem.evaluate(population); this.optimizationProblem.evaluate(population);
population.incrGeneration(); population.incrGeneration();
} }

View File

@ -101,7 +101,7 @@ public class EvolutionStrategies extends AbstractOptimizer implements java.io.Se
origPopSize = pop.getTargetSize(); origPopSize = pop.getTargetSize();
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.evaluatePopulation(this.population); this.evaluatePopulation(this.population);
} }
} }

View File

@ -59,7 +59,7 @@ public class EvolutionaryProgramming extends AbstractOptimizer implements java.i
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.evaluatePopulation(this.population); this.evaluatePopulation(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -65,7 +65,7 @@ public class FloodAlgorithm extends AbstractOptimizer implements java.io.Seriali
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.optimizationProblem.evaluate(this.population); this.optimizationProblem.evaluate(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -61,7 +61,7 @@ public class GeneticAlgorithm extends AbstractOptimizer implements java.io.Seria
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.optimizationProblem.initializePopulation(population); this.optimizationProblem.initializePopulation(population);
this.population.init(); this.population.initialize();
this.evaluatePopulation(this.population); this.evaluatePopulation(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -52,7 +52,7 @@ public class GradientDescentAlgorithm extends AbstractOptimizer implements java.
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.setPopulation((Population) pop.clone()); this.setPopulation((Population) pop.clone());
if (reset) { if (reset) {
this.getPopulation().init(); this.getPopulation().initialize();
this.optimizationProblem.evaluate(this.getPopulation()); this.optimizationProblem.evaluate(this.getPopulation());
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -50,7 +50,7 @@ public class HillClimbing extends AbstractOptimizer implements java.io.Serializa
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.optimizationProblem.evaluate(this.population); this.optimizationProblem.evaluate(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -83,7 +83,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
// this.population = new Population(); // this.population = new Population();
this.population.clear(); this.population.clear();
this.population.init(); this.population.initialize();
this.optimizer.initialize(); this.optimizer.initialize();
this.optimizer.setProblem(this.optimizationProblem); this.optimizer.setProblem(this.optimizationProblem);
this.optimizer.setPopulation((Population) population.clone()); this.optimizer.setPopulation((Population) population.clone());
@ -151,7 +151,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
this.population = (Population) tpop.clone(); this.population = (Population) tpop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.population.incrGeneration(); this.population.incrGeneration();
} }
this.optimizer.initialize(); this.optimizer.initialize();

View File

@ -64,7 +64,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer, java.io.Serializabl
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.setPopulation((Population) pop.clone()); this.setPopulation((Population) pop.clone());
if (reset) { if (reset) {
this.getPopulation().init(); this.getPopulation().initialize();
this.optimizationProblem.evaluate(this.getPopulation()); this.optimizationProblem.evaluate(this.getPopulation());
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -57,7 +57,7 @@ public class MonteCarloSearch extends AbstractOptimizer implements java.io.Seria
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.optimizationProblem.evaluate(this.population); this.optimizationProblem.evaluate(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -97,7 +97,7 @@ public class ParticleFilterOptimization extends AbstractOptimizer implements jav
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.evaluatePopulation(this.population); this.evaluatePopulation(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -484,7 +484,7 @@ public class ParticleSubSwarmOptimization extends ParticleSwarmOptimizationGCPSO
tmpIndy.initialize(prob); tmpIndy.initialize(prob);
tmp.add(tmpIndy); tmp.add(tmpIndy);
} }
tmp.init(); tmp.initialize();
/////////// ///////////
ParticleSubSwarmOptimization tmpopt = new ParticleSubSwarmOptimization(); ParticleSubSwarmOptimization tmpopt = new ParticleSubSwarmOptimization();

View File

@ -424,7 +424,7 @@ public class ParticleSwarmOptimization extends AbstractOptimizer implements java
externalInitialPop = true; externalInitialPop = true;
} }
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
} }
AbstractEAIndividual indy; AbstractEAIndividual indy;

View File

@ -91,7 +91,7 @@ public class PopulationBasedIncrementalLearning extends AbstractOptimizer implem
this.population = new PBILPopulation(); this.population = new PBILPopulation();
this.population.addPopulation((Population) pop.clone()); this.population.addPopulation((Population) pop.clone());
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.evaluatePopulation(this.population); this.evaluatePopulation(this.population);
} }
((PBILPopulation) this.population).buildProbabilityVector(); ((PBILPopulation) this.population).buildProbabilityVector();

View File

@ -844,7 +844,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
} }
Population pop = new Population(); Population pop = new Population();
pop.setTargetSize(refSetSize); pop.setTargetSize(refSetSize);
pop.init(); pop.initialize();
problem.initializePopulation(pop); problem.initializePopulation(pop);
ss.initializeByPopulation(pop, true); ss.initializeByPopulation(pop, true);

View File

@ -64,7 +64,7 @@ public class SimulatedAnnealing extends AbstractOptimizer implements java.io.Ser
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
this.currentTemperature = this.initialTemperature; this.currentTemperature = this.initialTemperature;
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.optimizationProblem.evaluate(this.population); this.optimizationProblem.evaluate(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -60,7 +60,7 @@ public class SteadyStateGA extends AbstractOptimizer implements java.io.Serializ
public void initializeByPopulation(Population pop, boolean reset) { public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.evaluatePopulation(this.population); this.evaluatePopulation(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -61,7 +61,7 @@ public class ThresholdAlgorithm extends AbstractOptimizer implements java.io.Ser
this.population = (Population) pop.clone(); this.population = (Population) pop.clone();
this.currentT = this.initialT; this.currentT = this.initialT;
if (reset) { if (reset) {
this.population.init(); this.population.initialize();
this.optimizationProblem.evaluate(this.population); this.optimizationProblem.evaluate(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED); this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
} }

View File

@ -229,7 +229,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
population.clear(); population.clear();
population.addAll(swarm.toPopulation()); population.addAll(swarm.toPopulation());
population.init(); // necessary to allow for multi-runs population.initialize(); // necessary to allow for multi-runs
if (show) { if (show) {
show(); show();

View File

@ -62,7 +62,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
} }
// population initialize must be last // population initialize must be last
// it set's fitcalls and generation to zero // it set's fitcalls and generation to zero
population.init(); population.initialize();
if (listOfOptima == null) { if (listOfOptima == null) {
this.globalOptimum = Double.NEGATIVE_INFINITY; this.globalOptimum = Double.NEGATIVE_INFINITY;
listOfOptima = new Population(); listOfOptima = new Population();

View File

@ -194,7 +194,7 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
} }
// population initialize must be last // population initialize must be last
// it set's fitcalls and generation to zero // it set's fitcalls and generation to zero
population.init(); population.initialize();
} }
/** /**

View File

@ -62,14 +62,14 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
public static String rawFitKey = "UnconstrainedFitnessValue"; public static String rawFitKey = "UnconstrainedFitnessValue";
public AbstractProblemDouble() { public AbstractProblemDouble() {
initTemplate(); initializeTemplate();
} }
public AbstractProblemDouble(AbstractProblemDouble o) { public AbstractProblemDouble(AbstractProblemDouble o) {
cloneObjects(o); cloneObjects(o);
} }
protected void initTemplate() { protected void initializeTemplate() {
if (template == null) { if (template == null) {
template = new ESIndividualDoubleData(); template = new ESIndividualDoubleData();
} }
@ -174,9 +174,9 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
* @param indyPos may contain the decoded individual position * @param indyPos may contain the decoded individual position
*/ */
protected void addConstraints(AbstractEAIndividual individual, double[] indyPos) { protected void addConstraints(AbstractEAIndividual individual, double[] indyPos) {
AbstractConstraint[] contraints = getConstraints(); AbstractConstraint[] constraints = getConstraints();
for (AbstractConstraint contraint : contraints) { for (AbstractConstraint constraint : constraints) {
contraint.addViolation(individual, indyPos); constraint.addViolation(individual, indyPos);
} }
} }
@ -205,7 +205,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
@Override @Override
public void initializePopulation(Population population) { public void initializePopulation(Population population) {
initTemplate(); initializeTemplate();
AbstractOptimizationProblem.defaultInitializePopulation(population, template, this); AbstractOptimizationProblem.defaultInitializePopulation(population, template, this);
} }
@ -257,7 +257,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
@Override @Override
public void initializeProblem() { public void initializeProblem() {
initTemplate(); initializeTemplate();
if (isDoRotation()) { if (isDoRotation()) {
rotation = initializeDefaultRotationMatrix(rotAngle, getProblemDimension()); rotation = initializeDefaultRotationMatrix(rotAngle, getProblemDimension());
} else { } else {
@ -339,7 +339,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
*/ */
public void setDefaultRange(double defaultRange) { public void setDefaultRange(double defaultRange) {
this.defaultRange = defaultRange; this.defaultRange = defaultRange;
initTemplate(); initializeTemplate();
} }
public String defaultRangeTipText() { public String defaultRangeTipText() {