diff --git a/src/eva2/OptimizerFactory.java b/src/eva2/OptimizerFactory.java index c6af76eb..053e8604 100644 --- a/src/eva2/OptimizerFactory.java +++ b/src/eva2/OptimizerFactory.java @@ -124,7 +124,7 @@ public class OptimizerFactory { double lambda, double CR, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); setTemplateOperators(problem, new NoMutation(), 0, new NoCrossover(), 0); @@ -205,7 +205,7 @@ public class OptimizerFactory { InterfaceSelection selection, AbstractOptimizationProblem problem, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); AbstractEAIndividual tmpIndi = problem.getIndividualTemplate(); AbstractEAIndividual.setOperators(tmpIndi, mutationoperator, pm, crossoveroperator, pc); @@ -243,7 +243,7 @@ public class OptimizerFactory { AbstractOptimizationProblem problem, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); setTemplateOperators(problem, mut, pm, cross, pc); @@ -317,7 +317,7 @@ public class OptimizerFactory { AbstractOptimizationProblem problem, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); subOpt.setProblem(problem); return new MultiObjectiveEA(subOpt, archiving, archiveSize, @@ -335,7 +335,7 @@ public class OptimizerFactory { System.err.println("Currently not implemented!"); - problem.initProblem(); + problem.initializeProblem(); AbstractEAIndividual tmpIndi = problem.getIndividualTemplate(); tmpIndi.setCrossoverOperator(new NoCrossover()); @@ -375,7 +375,7 @@ public class OptimizerFactory { AbstractOptimizationProblem problem, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); setTemplateOperators(problem, mutator, 1., new NoCrossover(), 0); @@ -406,7 +406,7 @@ public class OptimizerFactory { AbstractOptimizationProblem problem, int popsize, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); setTemplateOperators(problem, new NoMutation(), 0, new NoCrossover(), 0); MonteCarloSearch mc = new MonteCarloSearch(); @@ -443,7 +443,7 @@ public class OptimizerFactory { double phi2, double speedLim, PSOTopologyEnum selectedTopology, int topologyRange, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); setTemplateOperators(problem, new NoMutation(), 0, new NoCrossover(), 0); @@ -484,7 +484,7 @@ public class OptimizerFactory { double temperature, InterfaceMutation mut, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); setTemplateOperators(problem, mut, 1, new NoCrossover(), 0); @@ -520,7 +520,7 @@ public class OptimizerFactory { double learningRate, double mutateSigma, double mutationRate, int positiveSamples, InterfaceSelection selection, int popsize, AbstractOptimizationProblem problem, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); PopulationBasedIncrementalLearning pbil = new PopulationBasedIncrementalLearning(); pbil.setLearningRate(learningRate); @@ -771,7 +771,7 @@ public class OptimizerFactory { InterfaceTerminator term) { Population pop = new Population(popSize); RNG.setRandomSeed(seed); - problem.initPopulation(pop); + problem.initializePopulation(pop); return makeParams(opt, pop, problem, seed, term); } diff --git a/src/eva2/optimization/go/GOStandaloneVersion.java b/src/eva2/optimization/go/GOStandaloneVersion.java index 69b53141..79aa927f 100644 --- a/src/eva2/optimization/go/GOStandaloneVersion.java +++ b/src/eva2/optimization/go/GOStandaloneVersion.java @@ -55,9 +55,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu transient private boolean show = false; // transient private InterfaceTest test = new Test1(); // Opt. Algorithms and Parameters - //transient private InterfaceOptimizer m_Optimizer = new EvolutionaryMultiObjectiveOptimization(); - //transient private InterfaceOptimizationProblem m_Problem = new TF1Problem(); - //transient private int m_FunctionCalls = 1000; + //transient private InterfaceOptimizer optimizer = new EvolutionaryMultiObjectiveOptimization(); + //transient private InterfaceOptimizationProblem problem = new TF1Problem(); + //transient private int functionCalls = 1000; private GOParameters m_GO; transient private int m_MultiRuns = 1; transient private int m_RecentFC; @@ -324,7 +324,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu ((GAIndividualDoubleData) tmpIndy).setCrossoverProbability(1.0); ((GAIndividualDoubleData) tmpIndy).setMutationProbability(1.0); ((F1Problem) problem).setEAIndividual(tmpIndy); - //((FGRNInferringProblem)this.m_Problem).setStructreSkelInterval(1); + //((FGRNInferringProblem)this.problem).setStructreSkelInterval(1); this.m_GO.getOptimizer().setProblem(problem); this.m_GO.getOptimizer().addPopulationChangedEventListener(this); this.doWork(); @@ -340,8 +340,8 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu tmpIndy = new ESIndividualDoubleData(); ((AbstractEAIndividual) tmpIndy).setMutationOperator(new MutateESLocal()); ((F1Problem) problem).setEAIndividual(tmpIndy); - //((FGRNInferringProblem)this.m_Problem).setUseHEigenMatrix(true); - //((FGRNInferringProblem)this.m_Problem).setUseOnlyPositiveNumbers(true); + //((FGRNInferringProblem)this.problem).setUseHEigenMatrix(true); + //((FGRNInferringProblem)this.problem).setUseOnlyPositiveNumbers(true); this.m_GO.getOptimizer().setProblem(problem); this.m_GO.getOptimizer().addPopulationChangedEventListener(this); this.doWork(); @@ -388,7 +388,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu } // init problem - this.m_GO.getProblem().initProblem(); + this.m_GO.getProblem().initializeProblem(); this.m_GO.getOptimizer().setProblem(this.m_GO.getProblem()); // int optimizer and population //this.m_GO.getOptimizer().init(); @@ -402,7 +402,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu //this.writeToFile("Here i'll write something characterizing the algorithm."); for (int j = 0; j < this.m_MultiRuns; j++) { - this.m_GO.getProblem().initProblem(); // in the loop as well, dynamic probs may need that (MK) + this.m_GO.getProblem().initializeProblem(); // in the loop as well, dynamic probs may need that (MK) this.m_TmpData = new ArrayList(); this.currentRun = j; if (this.show) { @@ -415,7 +415,7 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu this.writeToFile(" FitnessCalls\t Best\t Mean\t Worst \t" + BeanInspector.toString(this.m_GO.getProblem().getAdditionalDataHeader(), '\t', false, "")); if ((this.m_ContinueFlag) && (this.m_Backup != null)) { this.m_RecentFC += this.m_Backup.getFunctionCalls(); - this.m_GO.getOptimizer().getProblem().initProblem(); + this.m_GO.getOptimizer().getProblem().initializeProblem(); this.m_GO.getOptimizer().addPopulationChangedEventListener(null); this.m_GO.getOptimizer().setPopulation(this.m_Backup); this.m_GO.getOptimizer().getProblem().evaluate(this.m_GO.getOptimizer().getPopulation()); @@ -427,9 +427,9 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu this.m_RecentFC = 0; this.m_GO.getOptimizer().init(); } - //while (this.m_GO.getOptimizer().getPopulation().getFunctionCalls() < this.m_FunctionCalls) { + //while (this.m_GO.getOptimizer().getPopulation().getFunctionCalls() < this.functionCalls) { while (!this.m_GO.getTerminator().isTerminated(this.m_GO.getOptimizer().getPopulation())) { - //System.out.println("Simulated Function calls "+ this.m_Optimizer.getPopulation().getFunctionCalls()); + //System.out.println("Simulated Function calls "+ this.optimizer.getPopulation().getFunctionCalls()); if (Thread.interrupted()) { throw new InterruptedException(); } @@ -751,10 +751,10 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu // * @param functionCalls The maximal number of Function calls // */ // public void setFunctionCalls(int functionCalls) { -// this.m_FunctionCalls = functionCalls; +// this.functionCalls = functionCalls; // } // public int getFunctionCalls() { -// return this.m_FunctionCalls; +// return this.functionCalls; // } // public String functionCallsTipText() { // return "The maxiaml number of function(fitness) evaluations that are performed. Mote: Generational algorihtms may be delayed!"; @@ -764,13 +764,13 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu // * @param optimizer The new optimizing algorithm // */ // public void setOptimizer(InterfaceOptimizer optimizer) { -// this.m_Optimizer = optimizer; -// this.m_Optimizer.addPopulationChangedEventListener(this); -// this.m_ExperimentName = this.m_Optimizer.getName()+"-"+this.m_PerformedRuns.size(); -// this.m_Optimizer.SetProblem(this.m_Problem); +// this.optimizer = optimizer; +// this.optimizer.addPopulationChangedEventListener(this); +// this.m_ExperimentName = this.optimizer.getName()+"-"+this.m_PerformedRuns.size(); +// this.optimizer.SetProblem(this.problem); // } // public InterfaceOptimizer getOptimizer() { -// return this.m_Optimizer; +// return this.optimizer; // } // public String optimizerTipText() { // return "Choose a optimizing strategies."; @@ -779,11 +779,11 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu // * @param problem // */ // public void SetProblem (InterfaceOptimizationProblem problem) { -// this.m_Problem = problem; -// this.m_Optimizer.SetProblem(this.m_Problem); +// this.problem = problem; +// this.optimizer.SetProblem(this.problem); // } // public InterfaceOptimizationProblem getProblem () { -// return this.m_Problem; +// return this.problem; // } // public String problemTipText() { // return "Choose the problem that is to optimize and the EA individual parameters."; diff --git a/src/eva2/optimization/go/MOCCOStandalone.java b/src/eva2/optimization/go/MOCCOStandalone.java index 21b2794b..828117c3 100644 --- a/src/eva2/optimization/go/MOCCOStandalone.java +++ b/src/eva2/optimization/go/MOCCOStandalone.java @@ -129,7 +129,7 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati Population pop = new Population(); pop.setTargetSize(this.m_State.m_InitialPopulationSize); this.m_State.m_CurrentProblem = (InterfaceOptimizationProblem) this.m_State.m_OriginalProblem.clone(); - this.m_State.m_CurrentProblem.initPopulation(pop); + this.m_State.m_CurrentProblem.initializePopulation(pop); this.m_State.m_CurrentProblem.evaluate(pop); this.m_State.addPopulation2History(pop); this.m_View.problemChanged(true); @@ -140,7 +140,7 @@ public class MOCCOStandalone implements InterfaceGOStandalone, InterfacePopulati tmpP.initProcessElementParametrization(); while (!tmpP.isFinished()) { try { Thread.sleep(1000); } catch (java.lang.InterruptedException e) { } } this.m_State.makeFitnessCache(true); - this.m_State.m_CurrentProblem.initProblem(); + this.m_State.m_CurrentProblem.initializeProblem(); this.m_State.makeBackup(); this.m_View.problemChanged(true); if (this.m_State.m_CurrentProblem.isMultiObjective()) { diff --git a/src/eva2/optimization/individuals/AbstractEAIndividual.java b/src/eva2/optimization/individuals/AbstractEAIndividual.java index caa97a60..4908e812 100644 --- a/src/eva2/optimization/individuals/AbstractEAIndividual.java +++ b/src/eva2/optimization/individuals/AbstractEAIndividual.java @@ -32,40 +32,38 @@ import java.util.*; */ public abstract class AbstractEAIndividual implements IndividualInterface, java.io.Serializable { - public int m_FunctionCalls = 0; // TODO ist irgendwie eine Kruecke - protected int m_Age = 0; - private long m_ID = 0; - private static long m_IDcounter = 0; + public int functionCalls = 0; // TODO ist irgendwie eine Kruecke + protected int age = 0; + private long id = 0; + private static long idCounter = 0; private boolean logParents = false; // heritage is to contain a list of all parents of the individual private Long[] parentIDs = null; transient private AbstractEAIndividual[] parentTree = null; - protected double[] m_Fitness = new double[1]; - private double m_ConstraintViolation = 0; - public boolean m_AreaConst4ParallelViolated = false; // no idea what felix used this for... - public boolean m_Marked = false; // is for GUI only! - public boolean m_isPenalized = false; // may be set true for penalty based constraints - protected double[] m_SelectionProbability = new double[1]; - ; - protected double m_CrossoverProbability = 1.0; - protected double m_MutationProbability = 0.2; - protected InterfaceMutation m_MutationOperator = new NoMutation(); - protected InterfaceCrossover m_CrossoverOperator = new NoCrossover(); - protected InterfaceInitialization m_InitOperator = new DefaultInitialization(); - // protected String[] m_Identifiers = new String[m_ObjectIncrement]; -// protected Object[] m_Objects = new Object[m_ObjectIncrement]; - protected HashMap m_dataHash = new HashMap(); + protected double[] fitness = new double[1]; + private double constraintViolation = 0; + public boolean areaConst4ParallelViolated = false; // no idea what felix used this for... + public boolean isMarked = false; // is for GUI only! + public boolean isPenalized = false; // may be set true for penalty based constraints + protected double[] selectionProbability = new double[1]; + + protected double crossoverProbability = 1.0; + protected double mutationProbability = 0.2; + protected InterfaceMutation mutationOperator = new NoMutation(); + protected InterfaceCrossover crossoverOperator = new NoCrossover(); + protected InterfaceInitialization initializationOperator = new DefaultInitialization(); + protected HashMap dataHash = new HashMap(); // introduced for the nichingPSO/ANPSO (M.Aschoff) private int individualIndex = -1; public AbstractEAIndividual() { - m_IDcounter++; - m_ID = m_IDcounter; -// System.out.println("my id is " + m_ID); + idCounter++; + id = idCounter; +// System.out.println("my id is " + id); } public long getIndyID() { - return m_ID; + return id; } public int getIndividualIndex() { @@ -95,11 +93,11 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param pCross */ public void setOperators(InterfaceInitialization initOp, InterfaceMutation mutOp, double pMut, InterfaceCrossover coOp, double pCross) { - m_InitOperator = initOp; - m_MutationProbability = pMut; - m_MutationOperator = mutOp; - m_CrossoverProbability = pCross; - m_CrossoverOperator = coOp; + initializationOperator = initOp; + mutationProbability = pMut; + mutationOperator = mutOp; + crossoverProbability = pCross; + crossoverOperator = coOp; } /** @@ -125,12 +123,12 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param pCross */ public void initCloneOperators(InterfaceMutation mutOp, double pMut, InterfaceCrossover coOp, double pCross, InterfaceOptimizationProblem problem) { - m_MutationProbability = pMut; - m_MutationOperator = (InterfaceMutation) mutOp.clone(); - m_MutationOperator.init(this, problem); - m_CrossoverProbability = pCross; - m_CrossoverOperator = (InterfaceCrossover) coOp.clone(); - m_CrossoverOperator.init(this, problem); + mutationProbability = pMut; + mutationOperator = (InterfaceMutation) mutOp.clone(); + mutationOperator.init(this, problem); + crossoverProbability = pCross; + crossoverOperator = (InterfaceCrossover) coOp.clone(); + crossoverOperator.init(this, problem); } /** @@ -156,13 +154,13 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. */ public void cloneAEAObjects(AbstractEAIndividual individual) { // m_Name = new String(individual.m_Name); - m_dataHash = (HashMap) (individual.m_dataHash.clone()); - m_ConstraintViolation = individual.m_ConstraintViolation; -// m_AreaConst4ParallelViolated = individual.m_AreaConst4ParallelViolated; - m_Marked = individual.m_Marked; - m_isPenalized = individual.m_isPenalized; + dataHash = (HashMap) (individual.dataHash.clone()); + constraintViolation = individual.constraintViolation; +// areaConst4ParallelViolated = individual.areaConst4ParallelViolated; + isMarked = individual.isMarked; + isPenalized = individual.isPenalized; individualIndex = individual.individualIndex; - m_InitOperator = individual.m_InitOperator.clone(); + initializationOperator = individual.initializationOperator.clone(); if (individual.parentIDs != null) { parentIDs = new Long[individual.parentIDs.length]; System.arraycopy(individual.parentIDs, 0, parentIDs, 0, parentIDs.length); @@ -191,7 +189,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. if (!this.equalFitness(indy)) { return false; } - this.m_ConstraintViolation = indy.m_ConstraintViolation; + this.constraintViolation = indy.constraintViolation; // check the genotypes if (!this.equalGenotypes(indy)) { @@ -199,21 +197,21 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. } // Age will not be used - //if (this.m_Age != indy.m_Age) return false; + //if (this.age != indy.age) return false; // checking on mutation/crossover probabilities - if (this.m_MutationProbability != indy.m_MutationProbability) { + if (this.mutationProbability != indy.mutationProbability) { return false; } - if (this.m_CrossoverProbability != indy.m_CrossoverProbability) { + if (this.crossoverProbability != indy.crossoverProbability) { return false; } // checking in mutation/crossover operators - if (!this.m_MutationOperator.equals(indy.m_MutationOperator)) { + if (!this.mutationOperator.equals(indy.mutationOperator)) { return false; } - if (!this.m_CrossoverOperator.equals(indy.m_CrossoverOperator)) { + if (!this.crossoverOperator.equals(indy.crossoverOperator)) { return false; } // System.err.println("Check whether this is semantically meant by equality!!! (AbstractEAIndividual.equals())"); @@ -297,12 +295,12 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. // public boolean equals(Object obj) { // if (obj instanceof AbstractEAIndividual) { // AbstractEAIndividual indy = (AbstractEAIndividual)obj; -// if (this.m_Fitness.length != indy.m_Fitness.length) return false; -//// for (int i = 0; i < this.m_Fitness.length; i++) if (this.m_Fitness[i] != indy.m_Fitness[i]) return false; -//// for (int i = 0; i < this.m_Fitness.length; i++) -//// if (new Double(this.m_Fitness[i]).compareTo(new Double(indy.m_Fitness[i])) != 0) return false; -// for (int i = 0; i < this.m_Fitness.length; i++) { -// if (Math.abs(this.m_Fitness[i]- indy.m_Fitness[i]) > 0.00000001) return false; +// if (this.fitness.length != indy.fitness.length) return false; +//// for (int i = 0; i < this.fitness.length; i++) if (this.fitness[i] != indy.fitness[i]) return false; +//// for (int i = 0; i < this.fitness.length; i++) +//// if (new Double(this.fitness[i]).compareTo(new Double(indy.fitness[i])) != 0) return false; +// for (int i = 0; i < this.fitness.length; i++) { +// if (Math.abs(this.fitness[i]- indy.fitness[i]) > 0.00000001) return false; // } // return true; // } else { @@ -315,10 +313,10 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param opt The optimization problem that is to be solved. */ public void init(InterfaceOptimizationProblem opt) { - m_InitOperator.initialize(this, opt); + initializationOperator.initialize(this, opt); // this.defaultInit(opt); - this.m_MutationOperator.init(this, opt); - this.m_CrossoverOperator.init(this, opt); + this.mutationOperator.init(this, opt); + this.crossoverOperator.init(this, opt); } /** @@ -334,8 +332,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * This method will mutate the individual randomly */ public void mutate() { - if (RNG.flipCoin(this.m_MutationProbability)) { - this.m_MutationOperator.mutate(this); + if (RNG.flipCoin(this.mutationProbability)) { + this.mutationOperator.mutate(this); } } @@ -350,8 +348,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. */ public AbstractEAIndividual[] mateWith(Population partners) { AbstractEAIndividual[] result; - if (RNG.flipCoin(this.m_CrossoverProbability)) { - result = this.m_CrossoverOperator.mate(this, partners); + if (RNG.flipCoin(this.crossoverProbability)) { + result = this.crossoverOperator.mate(this, partners); if (logParents) { for (int i = 0; i < result.length; i++) { result[i].setParents(this, partners); @@ -477,7 +475,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return The current age. */ public int getAge() { - return this.m_Age; + return this.age; } /** @@ -487,21 +485,21 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param age The new age. */ public void SetAge(int age) { - this.m_Age = age; + this.age = age; } /** * This method will incr the current age by one. */ public void incrAge() { - this.m_Age++; + this.age++; } /** * This method allows you to reset the user data */ public void resetUserData() { - m_dataHash.clear(); + dataHash.clear(); } /** @@ -509,8 +507,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * individual */ public void resetConstraintViolation() { - m_isPenalized = false; - this.m_ConstraintViolation = 0; + isPenalized = false; + this.constraintViolation = 0; } /** @@ -520,7 +518,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param c The constraint violation. */ public void addConstraintViolation(double c) { - this.m_ConstraintViolation += Math.abs(c); + this.constraintViolation += Math.abs(c); } /** @@ -529,7 +527,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return The current level of constraint violation */ public double getConstraintViolation() { - return this.m_ConstraintViolation; + return this.constraintViolation; } /** @@ -538,7 +536,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return True if constraints are violated */ public boolean violatesConstraint() { - if (this.m_ConstraintViolation > 0) { + if (this.constraintViolation > 0) { return true; } else { return false; @@ -552,23 +550,23 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return true if marked false if not */ public boolean getMarked() { - return this.m_Marked; + return this.isMarked; } public void SetMarked(boolean t) { - this.m_Marked = t; + this.isMarked = t; } public boolean isMarked() { - return this.m_Marked; + return this.isMarked; } public void unmark() { - this.m_Marked = false; + this.isMarked = false; } public void mark() { - this.m_Marked = true; + this.isMarked = true; } /** @@ -577,7 +575,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return */ public boolean isMarkedPenalized() { - return m_isPenalized; + return isPenalized; } /** @@ -586,7 +584,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return */ public void SetMarkPenalized(boolean p) { - m_isPenalized = p; + isPenalized = p; } /** @@ -598,7 +596,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. */ @Override public double[] getFitness() { - return this.m_Fitness; + return this.fitness; } /** @@ -609,8 +607,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return The fitness value at index */ public double getFitness(int index) { - if (this.m_Fitness.length > index) { - return this.m_Fitness[index]; + if (this.fitness.length > index) { + return this.fitness[index]; } else { return 0; } @@ -620,11 +618,10 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * This method will set the complete Fitness of the individual * * @param fitness The new fitness array - * @deprecated */ @Override public void setFitness(double[] fitness) { - this.m_Fitness = fitness; + this.fitness = fitness; } /** @@ -634,15 +631,15 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param fitness The new fitness value. */ public void SetFitness(int index, double fitness) { - if (this.m_Fitness.length > index) { - this.m_Fitness[index] = fitness; + if (this.fitness.length > index) { + this.fitness[index] = fitness; } else { double[] tmpD = new double[index + 1]; - for (int i = 0; i < this.m_Fitness.length; i++) { - tmpD[i] = this.m_Fitness[i]; + for (int i = 0; i < this.fitness.length; i++) { + tmpD[i] = this.fitness[i]; } - this.m_Fitness = tmpD; - this.m_Fitness[index] = fitness; + this.fitness = tmpD; + this.fitness[index] = fitness; } } @@ -653,9 +650,9 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param resetVal The new fitness array */ public void resetFitness(double resetVal) { - if (m_Fitness != null) { - for (int i = 0; i < m_Fitness.length; i++) { - m_Fitness[i] = resetVal; + if (fitness != null) { + for (int i = 0; i < fitness.length; i++) { + fitness[i] = resetVal; } } } @@ -665,11 +662,11 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * for parallelizing MOEAs */ public void checkAreaConst4Parallelization(ArrayList Constraints) { - this.m_AreaConst4ParallelViolated = false; + this.areaConst4ParallelViolated = false; if (Constraints != null) { for (int i = 0; i < Constraints.size(); i++) { if (!((InterfaceConstraint) Constraints.get(i)).isValid(this)) { - this.m_AreaConst4ParallelViolated = true; + this.areaConst4ParallelViolated = true; } } } @@ -684,15 +681,15 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return True if better false else */ public boolean isDominating(AbstractEAIndividual indy) { - if (this.m_AreaConst4ParallelViolated) { + if (this.areaConst4ParallelViolated) { return false; } - if (indy.m_AreaConst4ParallelViolated) { + if (indy.areaConst4ParallelViolated) { return true; } return isDominatingFitness(getFitness(), indy.getFitness()); -// for (int i = 0; (i < this.m_Fitness.length) && (i < tmpFitness.length); i++) { -// if (this.m_Fitness[i] <= tmpFitness[i]) result &= true; +// for (int i = 0; (i < this.fitness.length) && (i < tmpFitness.length); i++) { +// if (this.fitness[i] <= tmpFitness[i]) result &= true; // else result &= false; // } // return result; @@ -770,15 +767,15 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * is worse, 0 if they are equal in that respect. */ public int compareConstraintViolation(AbstractEAIndividual indy) { - if ((this.m_ConstraintViolation > 0) && (indy.m_ConstraintViolation <= 0)) { + if ((this.constraintViolation > 0) && (indy.constraintViolation <= 0)) { return -1; } - if ((this.m_ConstraintViolation <= 0) && (indy.m_ConstraintViolation > 0)) { + if ((this.constraintViolation <= 0) && (indy.constraintViolation > 0)) { return 1; - } else { // both violate: ((this.m_ConstraintViolation > 0) && (indy.m_ConstraintViolation > 0)) { - if (this.m_ConstraintViolation < indy.m_ConstraintViolation) { + } else { // both violate: ((this.constraintViolation > 0) && (indy.constraintViolation > 0)) { + if (this.constraintViolation < indy.constraintViolation) { return 1; - } else if (this.m_ConstraintViolation > indy.m_ConstraintViolation) { + } else if (this.constraintViolation > indy.constraintViolation) { return -1; } else { return 0; @@ -801,8 +798,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. } else { return (constrViolComp > 0); } -// for (int i = 0; (i < this.m_Fitness.length) && (i < tmpFitness.length); i++) { -// if (this.m_Fitness[i] <= tmpFitness[i]) result &= true; +// for (int i = 0; (i < this.fitness.length) && (i < tmpFitness.length); i++) { +// if (this.fitness[i] <= tmpFitness[i]) result &= true; // else result &= false; // } // return result; @@ -818,10 +815,10 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. */ public boolean isDominatingEqual(AbstractEAIndividual indy) { // TODO: should this method really be called "..Equal"? - if (this.m_AreaConst4ParallelViolated) { + if (this.areaConst4ParallelViolated) { return false; } - if (indy.m_AreaConst4ParallelViolated) { + if (indy.areaConst4ParallelViolated) { return true; } return isDominatingFitnessNotEqual(getFitness(), indy.getFitness()); @@ -854,7 +851,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return The complete selection probability array */ public double[] getSelectionProbability() { - return this.m_SelectionProbability; + return this.selectionProbability; } /** @@ -866,8 +863,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return The selection probability value at index */ public double getSelectionProbability(int index) { - if (this.m_SelectionProbability.length > index) { - return this.m_SelectionProbability[index]; + if (this.selectionProbability.length > index) { + return this.selectionProbability[index]; } else { return 0; } @@ -879,7 +876,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param sel The new selection probability array */ public void SetSelectionProbability(double[] sel) { - this.m_SelectionProbability = sel; + this.selectionProbability = sel; } /** @@ -889,15 +886,15 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param sel The new selection probability value. */ public void SetSelectionProbability(int index, double sel) { - if (this.m_SelectionProbability.length > index) { - this.m_SelectionProbability[index] = sel; + if (this.selectionProbability.length > index) { + this.selectionProbability[index] = sel; } else { double[] tmpD = new double[index + 1]; - for (int i = 0; i < this.m_SelectionProbability.length; i++) { - tmpD[i] = this.m_SelectionProbability[i]; + for (int i = 0; i < this.selectionProbability.length; i++) { + tmpD[i] = this.selectionProbability[i]; } - this.m_SelectionProbability = tmpD; - this.m_SelectionProbability[index] = sel; + this.selectionProbability = tmpD; + this.selectionProbability[index] = sel; } } @@ -908,11 +905,11 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param mutator The mutation operator. */ public void setMutationOperator(InterfaceMutation mutator) { - this.m_MutationOperator = mutator; + this.mutationOperator = mutator; } public InterfaceMutation getMutationOperator() { - return this.m_MutationOperator; + return this.mutationOperator; } public String mutationOperatorTipText() { @@ -932,11 +929,11 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. if (mutprob > 1) { mutprob = 1; } - m_MutationProbability = mutprob; + mutationProbability = mutprob; } public double getMutationProbability() { - return m_MutationProbability; + return mutationProbability; } public String mutationProbabilityTipText() { @@ -950,11 +947,11 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param crossover The crossover operator. */ public void setCrossoverOperator(InterfaceCrossover crossover) { - this.m_CrossoverOperator = crossover; + this.crossoverOperator = crossover; } public InterfaceCrossover getCrossoverOperator() { - return this.m_CrossoverOperator; + return this.crossoverOperator; } public String crossoverOperatorTipText() { @@ -967,17 +964,17 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param prob */ public void setCrossoverProbability(double prob) { - this.m_CrossoverProbability = prob; - if (this.m_CrossoverProbability > 1) { - this.m_CrossoverProbability = 1; + this.crossoverProbability = prob; + if (this.crossoverProbability > 1) { + this.crossoverProbability = 1; } - if (this.m_CrossoverProbability < 0) { - this.m_CrossoverProbability = 0; + if (this.crossoverProbability < 0) { + this.crossoverProbability = 0; } } public double getCrossoverProbability() { - return this.m_CrossoverProbability; + return this.crossoverProbability; } public String crossoverProbabilityTipText() { @@ -985,11 +982,11 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. } public InterfaceInitialization getInitOperator() { - return m_InitOperator; + return initializationOperator; } public void setInitOperator(InterfaceInitialization mInitOperator) { - m_InitOperator = mInitOperator; + initializationOperator = mInitOperator; } public String initOperatorTipText() { @@ -1004,7 +1001,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @param obj The object that is to be stored. */ public void putData(String name, Object obj) { - m_dataHash.put(name, obj); + dataHash.put(name, obj); } /** @@ -1020,7 +1017,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. // if (name.equalsIgnoreCase("SelectionProbabilityArray")) return this.getSelectionProbability(); // if (name.equalsIgnoreCase("Fitness")) return this.getFitness(); // if (name.equalsIgnoreCase("FitnessArray")) return this.getFitness(); - Object data = m_dataHash.get(name); + Object data = dataHash.get(name); if (data == null) { // Fitness is actually in use... so lets have a minor special treatment // try { if (name.compareToIgnoreCase("Fitness") == 0) { @@ -1045,7 +1042,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. * @return true if data is associated with the key, else false */ public boolean hasData(String key) { - if (m_dataHash.get(key) == null) { + if (dataHash.get(key) == null) { return (key.compareToIgnoreCase("Fitness") == 0); } else { return true; @@ -1323,7 +1320,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. // else return this.getFitness(); // } public boolean isDominantNotEqual(double[] otherFitness) { - return isDominatingFitnessNotEqual(m_Fitness, otherFitness); + return isDominatingFitnessNotEqual(fitness, otherFitness); } /** @@ -1332,7 +1329,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. */ @Override public boolean isDominant(double[] otherFitness) { - return isDominatingFitness(m_Fitness, otherFitness); + return isDominatingFitness(fitness, otherFitness); } /** diff --git a/src/eva2/optimization/individuals/ESIndividualBinaryData.java b/src/eva2/optimization/individuals/ESIndividualBinaryData.java index 4428ad8b..489b5696 100644 --- a/src/eva2/optimization/individuals/ESIndividualBinaryData.java +++ b/src/eva2/optimization/individuals/ESIndividualBinaryData.java @@ -25,10 +25,10 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte private double[][] m_Range; public ESIndividualBinaryData() { - this.m_MutationProbability = 1.0; - this.m_MutationOperator = new MutateESGlobal(); - this.m_CrossoverProbability = 0.5; - this.m_CrossoverOperator = new CrossoverESDefault(); + this.mutationProbability = 1.0; + this.mutationOperator = new MutateESGlobal(); + this.crossoverProbability = 0.5; + this.crossoverOperator = new CrossoverESDefault(); this.m_Genotype = new double[1]; this.m_Range = new double[1][2]; this.m_Range[0][0] = 0; @@ -49,18 +49,18 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte this.m_UseHardSwitch = individual.m_UseHardSwitch; // cloning the members of AbstractEAIndividual - this.m_Age = individual.m_Age; - this.m_CrossoverOperator = individual.m_CrossoverOperator; - this.m_CrossoverProbability = individual.m_CrossoverProbability; - this.m_MutationOperator = (InterfaceMutation)individual.m_MutationOperator.clone(); - this.m_MutationProbability = individual.m_MutationProbability; - this.m_SelectionProbability = new double[individual.m_SelectionProbability.length]; - for (int i = 0; i < this.m_SelectionProbability.length; i++) { - this.m_SelectionProbability[i] = individual.m_SelectionProbability[i]; + this.age = individual.age; + this.crossoverOperator = individual.crossoverOperator; + this.crossoverProbability = individual.crossoverProbability; + this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); + this.mutationProbability = individual.mutationProbability; + this.selectionProbability = new double[individual.selectionProbability.length]; + for (int i = 0; i < this.selectionProbability.length; i++) { + this.selectionProbability[i] = individual.selectionProbability[i]; } - this.m_Fitness = new double[individual.m_Fitness.length]; - for (int i = 0; i < this.m_Fitness.length; i++) { - this.m_Fitness[i] = individual.m_Fitness[i]; + this.fitness = new double[individual.fitness.length]; + for (int i = 0; i < this.fitness.length; i++) { + this.fitness[i] = individual.fitness[i]; } cloneAEAObjects((AbstractEAIndividual) individual); } @@ -211,8 +211,8 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte this.defaultInit(opt); System.out.println("Initial value for ESIndividualBinaryData is no BitSet!"); } - this.m_MutationOperator.init(this, opt); - this.m_CrossoverOperator.init(this, opt); + this.mutationOperator.init(this, opt); + this.crossoverOperator.init(this, opt); } /** This method will return a string description of the GAIndividal @@ -224,12 +224,12 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte String result = ""; result += "ESIndividual coding double: ("; result += "Fitness {"; - for (int i = 0; i < this.m_Fitness.length; i++) { - result += this.m_Fitness[i] + ";"; + for (int i = 0; i < this.fitness.length; i++) { + result += this.fitness[i] + ";"; } result += "}/SelProb{"; - for (int i = 0; i < this.m_SelectionProbability.length; i++) { - result += this.m_SelectionProbability[i] + ";"; + for (int i = 0; i < this.selectionProbability.length; i++) { + result += this.selectionProbability[i] + ";"; } result += "})\n Value: "; result += "["; diff --git a/src/eva2/optimization/individuals/ESIndividualDoubleData.java b/src/eva2/optimization/individuals/ESIndividualDoubleData.java index 1ae59f5b..733dd1ee 100644 --- a/src/eva2/optimization/individuals/ESIndividualDoubleData.java +++ b/src/eva2/optimization/individuals/ESIndividualDoubleData.java @@ -25,10 +25,10 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte private double[][] m_Range; public ESIndividualDoubleData() { - this.m_MutationProbability = 1.0; - this.m_MutationOperator = new MutateESGlobal(0.2, MutateESCrossoverTypeEnum.intermediate); - this.m_CrossoverProbability = 0.5; - this.m_CrossoverOperator = new CrossoverESDefault(); + this.mutationProbability = 1.0; + this.mutationOperator = new MutateESGlobal(0.2, MutateESCrossoverTypeEnum.intermediate); + this.crossoverProbability = 0.5; + this.crossoverOperator = new CrossoverESDefault(); this.m_Genotype = new double[1]; this.m_Phenotype = null; this.m_Range = new double[1][2]; @@ -50,18 +50,18 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte } // cloning the members of AbstractEAIndividual - this.m_Age = individual.m_Age; - this.m_CrossoverOperator = individual.m_CrossoverOperator; - this.m_CrossoverProbability = individual.m_CrossoverProbability; - this.m_MutationOperator = (InterfaceMutation)individual.m_MutationOperator.clone(); - this.m_MutationProbability = individual.m_MutationProbability; - this.m_SelectionProbability = new double[individual.m_SelectionProbability.length]; - for (int i = 0; i < this.m_SelectionProbability.length; i++) { - this.m_SelectionProbability[i] = individual.m_SelectionProbability[i]; + this.age = individual.age; + this.crossoverOperator = individual.crossoverOperator; + this.crossoverProbability = individual.crossoverProbability; + this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); + this.mutationProbability = individual.mutationProbability; + this.selectionProbability = new double[individual.selectionProbability.length]; + for (int i = 0; i < this.selectionProbability.length; i++) { + this.selectionProbability[i] = individual.selectionProbability[i]; } - this.m_Fitness = new double[individual.m_Fitness.length]; - for (int i = 0; i < this.m_Fitness.length; i++) { - this.m_Fitness[i] = individual.m_Fitness[i]; + this.fitness = new double[individual.fitness.length]; + for (int i = 0; i < this.fitness.length; i++) { + this.fitness[i] = individual.fitness[i]; } cloneAEAObjects((AbstractEAIndividual) individual); } @@ -264,8 +264,8 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte this.defaultInit(opt); System.out.println("Initial value for ESIndividualDoubleData is not double[]!"); } - this.m_MutationOperator.init(this, opt); - this.m_CrossoverOperator.init(this, opt); + this.mutationOperator.init(this, opt); + this.crossoverOperator.init(this, opt); } /** This method will return a string description of the GAIndividal @@ -276,14 +276,14 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte public String getStringRepresentation() { StringBuilder strB = new StringBuilder(200); strB.append("ESIndividual coding double: (Fitness {"); - for (int i = 0; i < this.m_Fitness.length; i++) { - strB.append(this.m_Fitness[i]); + for (int i = 0; i < this.fitness.length; i++) { + strB.append(this.fitness[i]); strB.append(";"); } strB.append("}/SelProb{"); - for (int i = 0; i < this.m_SelectionProbability.length; i++) { - strB.append(this.m_SelectionProbability[i]); + for (int i = 0; i < this.selectionProbability.length; i++) { + strB.append(this.selectionProbability[i]); strB.append(";"); } strB.append("}) Value: ["); @@ -404,8 +404,8 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte // public String toString() { // String str = "Ind " + m_Genotype[0]; // for (int i=1; i, // public static void main(String[] args) { // TF1Problem prob = new TF1Problem(); // Population pop = new Population(10); -// prob.initPopulation(pop); +// prob.initializePopulation(pop); // prob.evaluate(pop); // System.out.println(pop.getStringRepresentation()); // System.out.println("***"); diff --git a/src/eva2/optimization/individuals/OBGAIndividualPermutationData.java b/src/eva2/optimization/individuals/OBGAIndividualPermutationData.java index c393e1e2..44d9bee1 100644 --- a/src/eva2/optimization/individuals/OBGAIndividualPermutationData.java +++ b/src/eva2/optimization/individuals/OBGAIndividualPermutationData.java @@ -25,10 +25,10 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen int[] firstindex; public OBGAIndividualPermutationData() { - this.m_MutationProbability = 0.2; - this.m_MutationOperator = new MutateOBGAFlip(); - this.m_CrossoverProbability = 1.0; - this.m_CrossoverOperator = new CrossoverOBGAPMX(); + this.mutationProbability = 0.2; + this.mutationOperator = new MutateOBGAFlip(); + this.crossoverProbability = 1.0; + this.crossoverOperator = new CrossoverOBGAPMX(); this.setPermutationDataLength(new int[]{20}); firstindex = new int[]{0}; } @@ -49,17 +49,17 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen System.arraycopy(individual.m_Genotype, 0, this.m_Genotype, 0, this.m_Genotype.length); this.firstindex = individual.firstindex; - this.m_Age = individual.m_Age; - this.m_CrossoverOperator = individual.m_CrossoverOperator; - this.m_CrossoverProbability = individual.m_CrossoverProbability; - this.m_MutationOperator = (InterfaceMutation)individual.m_MutationOperator.clone(); - this.m_MutationProbability = individual.m_MutationProbability; - this.m_SelectionProbability = new double[individual.m_SelectionProbability.length]; - for (int i = 0; i < this.m_SelectionProbability.length; i++) { - this.m_SelectionProbability[i] = individual.m_SelectionProbability[i]; } - this.m_Fitness = new double[individual.m_Fitness.length]; - for (int i = 0; i < this.m_Fitness.length; i++) { - this.m_Fitness[i] = individual.m_Fitness[i]; + this.age = individual.age; + this.crossoverOperator = individual.crossoverOperator; + this.crossoverProbability = individual.crossoverProbability; + this.mutationOperator = (InterfaceMutation)individual.mutationOperator.clone(); + this.mutationProbability = individual.mutationProbability; + this.selectionProbability = new double[individual.selectionProbability.length]; + for (int i = 0; i < this.selectionProbability.length; i++) { + this.selectionProbability[i] = individual.selectionProbability[i]; } + this.fitness = new double[individual.fitness.length]; + for (int i = 0; i < this.fitness.length; i++) { + this.fitness[i] = individual.fitness[i]; } this.cloneAEAObjects(individual); } @@ -111,8 +111,8 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen this.defaultInit(opt); System.out.println("Initial value for OBGAIndividualBinaryData is no Permutation!"); } - this.m_MutationOperator.init(this, opt); - this.m_CrossoverOperator.init(this, opt); + this.mutationOperator.init(this, opt); + this.crossoverOperator.init(this, opt); } /** This method can be used to read the current fitness of the individual. @@ -122,7 +122,7 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen */ @Override public double[] getFitness() { - return this.m_Fitness; + return this.fitness; } /** This method will return a string description of the GAIndividal @@ -134,12 +134,12 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen String result = ""; result += "OBGAIndividual: ("; result += "Fitness {"; - for (int i = 0; i < this.m_Fitness.length; i++) { - result += this.m_Fitness[i] + ";"; + for (int i = 0; i < this.fitness.length; i++) { + result += this.fitness[i] + ";"; } result += "}/SelProb{"; - for (int i = 0; i < this.m_SelectionProbability.length; i++) { - result += this.m_SelectionProbability[i] + ";"; + for (int i = 0; i < this.selectionProbability.length; i++) { + result += this.selectionProbability[i] + ";"; } result += "})\n Value: "; result += "{"; @@ -153,7 +153,7 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen result += "\n"; } result += "}"; - result += "\n Mutation ("+this.m_MutationProbability+"):" + this.m_MutationOperator.getStringRepresentation(); + result += "\n Mutation ("+this.mutationProbability +"):" + this.mutationOperator.getStringRepresentation(); return result; } diff --git a/src/eva2/optimization/mocco/MOCCOParameterizeMO.java b/src/eva2/optimization/mocco/MOCCOParameterizeMO.java index 3af6739d..66b41b67 100644 --- a/src/eva2/optimization/mocco/MOCCOParameterizeMO.java +++ b/src/eva2/optimization/mocco/MOCCOParameterizeMO.java @@ -27,11 +27,11 @@ import javax.swing.*; public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessElement { // private JComboBox m_OptimizerChooser; -// private InterfaceOptimizer m_Optimizer; +// private InterfaceOptimizer optimizer; public MOCCOParameterizeMO(MOCCOStandalone mocco) { this.m_Mocco = mocco; -// this.m_Optimizer = (InterfaceOptimizer)this.m_Mocco.m_State.m_Optimizer.clone(); +// this.optimizer = (InterfaceOptimizer)this.m_Mocco.m_State.optimizer.clone(); } /** This method will call the init method and will go to stall @@ -67,11 +67,11 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE "Warning", JOptionPane.WARNING_MESSAGE); } // JOptionPane.showMessageDialog(this.m_Mocco.m_JFrame, -// "The current "+this.m_Mocco.m_State.m_Optimizer.getName() + +// "The current "+this.m_Mocco.m_State.optimizer.getName() + // " is typically a single-objective optimizer. I'm defaulting to a " + // "multi-objective EA instead, please parameterize accordingly.", // "Warning", JOptionPane.WARNING_MESSAGE); -// this.m_Mocco.m_State.m_Optimizer = new MultiObjectiveEA(); +// this.m_Mocco.m_State.optimizer = new MultiObjectiveEA(); } this.m_Mocco.m_JPanelParameters.removeAll(); this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); @@ -145,7 +145,7 @@ public class MOCCOParameterizeMO extends MOCCOPhase implements InterfaceProcessE ActionListener continue2 = new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - //m_Mocco.m_State.m_Optimizer = (InterfaceOptimizer)m_Optimizer.clone(); + //m_Mocco.m_State.optimizer = (InterfaceOptimizer)optimizer.clone(); m_Mocco.m_JPanelControl.removeAll(); m_Mocco.m_JPanelParameters.removeAll(); m_Mocco.m_State.m_Optimizer.setProblem(m_Mocco.m_State.m_CurrentProblem); diff --git a/src/eva2/optimization/modules/AbstractGOParameters.java b/src/eva2/optimization/modules/AbstractGOParameters.java index 7f3d5c45..16c72bd4 100644 --- a/src/eva2/optimization/modules/AbstractGOParameters.java +++ b/src/eva2/optimization/modules/AbstractGOParameters.java @@ -25,11 +25,11 @@ public abstract class AbstractGOParameters implements InterfaceGOParameters, Ser protected long randomSeed = (long)0.0; // Opt. Algorithms and Parameters - protected InterfaceOptimizer m_Optimizer; - protected InterfaceOptimizationProblem m_Problem ; - protected InterfaceTerminator m_Terminator; - protected InterfacePostProcessParams m_PostProc = new PostProcessParams(false); - transient protected InterfacePopulationChangedEventListener m_Listener; + protected InterfaceOptimizer optimizer; + protected InterfaceOptimizationProblem problem; + protected InterfaceTerminator terminator; + protected InterfacePostProcessParams postProcessing = new PostProcessParams(false); + transient protected InterfacePopulationChangedEventListener populationChangedEventListener; transient private List toInformAboutInformers = null; protected AbstractGOParameters() { @@ -37,20 +37,20 @@ public abstract class AbstractGOParameters implements InterfaceGOParameters, Ser protected AbstractGOParameters(AbstractGOParameters goParameters) { this(); - this.m_Optimizer = goParameters.m_Optimizer; - this.m_Problem = goParameters.m_Problem; - this.m_Terminator = goParameters.m_Terminator; - this.m_Optimizer.setProblem(this.m_Problem); - this.randomSeed = goParameters.randomSeed; - this.m_PostProc = goParameters.m_PostProc; + this.optimizer = goParameters.optimizer; + this.problem = goParameters.problem; + this.terminator = goParameters.terminator; + this.optimizer.setProblem(this.problem); + this.randomSeed = goParameters.randomSeed; + this.postProcessing = goParameters.postProcessing; } public AbstractGOParameters(InterfaceOptimizer opt, InterfaceOptimizationProblem prob, InterfaceTerminator term) { this(); - m_Optimizer = opt; - m_Problem = prob; - m_Terminator = term; - m_PostProc = new PostProcessParams(false); + optimizer = opt; + problem = prob; + terminator = term; + postProcessing = new PostProcessParams(false); opt.setProblem(prob); } @@ -60,12 +60,12 @@ public abstract class AbstractGOParameters implements InterfaceGOParameters, Ser * @param src */ public void setSameParams(AbstractGOParameters src) { - setOptimizer(src.m_Optimizer); - setProblem(src.m_Problem); - setTerminator(src.m_Terminator); - this.m_Optimizer.setProblem(this.m_Problem); + setOptimizer(src.optimizer); + setProblem(src.problem); + setTerminator(src.terminator); + this.optimizer.setProblem(this.problem); setSeed(src.randomSeed); - setPostProcessParams(src.m_PostProc); + setPostProcessParams(src.postProcessing); } /** @@ -74,22 +74,22 @@ public abstract class AbstractGOParameters implements InterfaceGOParameters, Ser * @param ea */ public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) { - this.m_Listener = ea; - if (this.m_Optimizer != null) { - this.m_Optimizer.addPopulationChangedEventListener(this.m_Listener); + this.populationChangedEventListener = ea; + if (this.optimizer != null) { + this.optimizer.addPopulationChangedEventListener(this.populationChangedEventListener); + } + } + + public boolean removePopulationChangedEventListener(InterfacePopulationChangedEventListener ea) { + if (populationChangedEventListener ==ea) { + populationChangedEventListener =null; + if (this.optimizer !=null) { + this.optimizer.removePopulationChangedEventListener(ea); } - } - public boolean removePopulationChangedEventListener( - InterfacePopulationChangedEventListener ea) { - if (m_Listener==ea) { - m_Listener=null; - if (this.m_Optimizer!=null) { - this.m_Optimizer.removePopulationChangedEventListener(ea); - } - return true; - } else { - return false; - } + return true; + } else { + return false; + } } /** @@ -117,11 +117,11 @@ public abstract class AbstractGOParameters implements InterfaceGOParameters, Ser sBuilder.append("seed="); sBuilder.append(randomSeed); sBuilder.append("\nProblem: "); - sBuilder.append(BeanInspector.toString(m_Problem)); + sBuilder.append(BeanInspector.toString(problem)); sBuilder.append("\nOptimizer: "); - sBuilder.append(BeanInspector.toString(m_Optimizer)); + sBuilder.append(BeanInspector.toString(optimizer)); sBuilder.append("\nTerminator: "); - sBuilder.append(BeanInspector.toString(m_Terminator)); + sBuilder.append(BeanInspector.toString(terminator)); sBuilder.append("\n"); return sBuilder.toString(); } @@ -156,28 +156,28 @@ listener.setInformers(getInformerList()); @Override public void setOptimizer(InterfaceOptimizer optimizer) { - this.m_Optimizer = optimizer; - this.m_Optimizer.setProblem(this.m_Problem); - if (this.m_Listener != null) { - this.m_Optimizer.addPopulationChangedEventListener(this.m_Listener); + this.optimizer = optimizer; + this.optimizer.setProblem(this.problem); + if (this.populationChangedEventListener != null) { + this.optimizer.addPopulationChangedEventListener(this.populationChangedEventListener); } fireNotifyOnInformers(); } private List getInformerList() { LinkedList ret = new LinkedList(); - if (m_Problem instanceof InterfaceAdditionalPopulationInformer) { - ret.add(m_Problem); + if (problem instanceof InterfaceAdditionalPopulationInformer) { + ret.add(problem); } - if (m_Optimizer instanceof InterfaceAdditionalPopulationInformer) { - ret.add((InterfaceAdditionalPopulationInformer)m_Optimizer); + if (optimizer instanceof InterfaceAdditionalPopulationInformer) { + ret.add((InterfaceAdditionalPopulationInformer) optimizer); } return ret; } @Override public InterfaceOptimizer getOptimizer() { - return this.m_Optimizer; + return this.optimizer; } public String optimizerTipText() { return "Choose an optimization strategy."; @@ -194,14 +194,14 @@ listener.setInformers(getInformerList()); */ @Override public void setProblem (InterfaceOptimizationProblem problem) { - this.m_Problem = problem; - this.m_Optimizer.setProblem(this.m_Problem); + this.problem = problem; + this.optimizer.setProblem(this.problem); fireNotifyOnInformers(); } @Override public InterfaceOptimizationProblem getProblem() { - return this.m_Problem; + return this.problem; } @Override public String problemTipText() { @@ -237,11 +237,11 @@ listener.setInformers(getInformerList()); */ @Override public void setTerminator(InterfaceTerminator term) { - this.m_Terminator = term; + this.terminator = term; } @Override public InterfaceTerminator getTerminator() { - return this.m_Terminator; + return this.terminator; } @Override public String terminatorTipText() { @@ -250,11 +250,11 @@ listener.setInformers(getInformerList()); @Override public InterfacePostProcessParams getPostProcessParams() { - return m_PostProc; + return postProcessing; } @Override public void setPostProcessParams(InterfacePostProcessParams ppp) { - m_PostProc = ppp; + postProcessing = ppp; } @Override public String postProcessParamsTipText() { @@ -262,6 +262,6 @@ listener.setInformers(getInformerList()); } @Override public void setDoPostProcessing(boolean doPP){ - m_PostProc.setDoPostProcessing(doPP); + postProcessing.setDoPostProcessing(doPP); } } diff --git a/src/eva2/optimization/modules/DEParameters.java b/src/eva2/optimization/modules/DEParameters.java index 3d0a326b..12874152 100644 --- a/src/eva2/optimization/modules/DEParameters.java +++ b/src/eva2/optimization/modules/DEParameters.java @@ -82,11 +82,11 @@ public class DEParameters extends AbstractGOParameters implements InterfaceGOPar * @return The population of current solutions to a given problem. */ public Population getPopulation() { - return ((DifferentialEvolution) this.m_Optimizer).getPopulation(); + return ((DifferentialEvolution) this.optimizer).getPopulation(); } public void setPopulation(Population pop){ - ((DifferentialEvolution) this.m_Optimizer).setPopulation(pop); + ((DifferentialEvolution) this.optimizer).setPopulation(pop); } public String populationTipText() { @@ -97,10 +97,10 @@ public class DEParameters extends AbstractGOParameters implements InterfaceGOPar * @param f */ public void setF (double f) { - ((DifferentialEvolution) this.m_Optimizer).setF(f); + ((DifferentialEvolution) this.optimizer).setF(f); } public double getF() { - return ((DifferentialEvolution) this.m_Optimizer).getF(); + return ((DifferentialEvolution) this.optimizer).getF(); } public String fTipText() { return "F is a real and constant factor which controlls the ampllification of the differential variation."; @@ -110,10 +110,10 @@ public class DEParameters extends AbstractGOParameters implements InterfaceGOPar * @param k */ public void setK(double k) { - ((DifferentialEvolution) this.m_Optimizer).setK(k); + ((DifferentialEvolution) this.optimizer).setK(k); } public double getK() { - return ((DifferentialEvolution) this.m_Optimizer).getK(); + return ((DifferentialEvolution) this.optimizer).getK(); } public String kTipText() { return "Probability of alteration through DE1."; @@ -123,10 +123,10 @@ public class DEParameters extends AbstractGOParameters implements InterfaceGOPar * @param l */ public void setLambda (double l) { - ((DifferentialEvolution) this.m_Optimizer).setLambda(l); + ((DifferentialEvolution) this.optimizer).setLambda(l); } public double getLambda() { - return ((DifferentialEvolution) this.m_Optimizer).getLambda(); + return ((DifferentialEvolution) this.optimizer).getLambda(); } public String lambdaTipText() { return "Enhance greediness through amplification of the differential vector to the best individual for DE2."; @@ -136,10 +136,10 @@ public class DEParameters extends AbstractGOParameters implements InterfaceGOPar * @param s The type. */ public void setDEType(DETypeEnum s) { - ((DifferentialEvolution) this.m_Optimizer).setDEType(s); + ((DifferentialEvolution) this.optimizer).setDEType(s); } public DETypeEnum getDEType() { - return ((DifferentialEvolution) this.m_Optimizer).getDEType(); + return ((DifferentialEvolution) this.optimizer).getDEType(); } public String dETypeTipText() { return "Choose the type of Differential Evolution."; diff --git a/src/eva2/optimization/modules/EPParameters.java b/src/eva2/optimization/modules/EPParameters.java index 745e3b68..0a163c12 100644 --- a/src/eva2/optimization/modules/EPParameters.java +++ b/src/eva2/optimization/modules/EPParameters.java @@ -89,10 +89,10 @@ public class EPParameters extends AbstractGOParameters implements InterfaceGOPar * @return The population of current solutions to a given problem. */ public Population getPopulation() { - return ((EvolutionaryProgramming)this.m_Optimizer).getPopulation(); + return ((EvolutionaryProgramming)this.optimizer).getPopulation(); } public void setPopulation(Population pop){ - ((EvolutionaryProgramming)this.m_Optimizer).setPopulation(pop); + ((EvolutionaryProgramming)this.optimizer).setPopulation(pop); } public String populationTipText() { return "Edit the properties of the population used."; @@ -102,10 +102,10 @@ public class EPParameters extends AbstractGOParameters implements InterfaceGOPar * @param selection */ public void setEnvironmentSelection(InterfaceSelection selection) { - ((EvolutionaryProgramming)this.m_Optimizer).setEnvironmentSelection(selection); + ((EvolutionaryProgramming)this.optimizer).setEnvironmentSelection(selection); } public InterfaceSelection getEnvironmentSelection() { - return ((EvolutionaryProgramming)this.m_Optimizer).getEnvironmentSelection(); + return ((EvolutionaryProgramming)this.optimizer).getEnvironmentSelection(); } public String environmentSelectionTipText() { return "Choose a method for selecting the reduced population."; diff --git a/src/eva2/optimization/modules/GAParameters.java b/src/eva2/optimization/modules/GAParameters.java index f69c4d74..7e070c0b 100644 --- a/src/eva2/optimization/modules/GAParameters.java +++ b/src/eva2/optimization/modules/GAParameters.java @@ -86,10 +86,10 @@ public class GAParameters extends AbstractGOParameters implements InterfaceGOPar * @return The population of current solutions to a given problem. */ public Population getPopulation() { - return ((GeneticAlgorithm)this.m_Optimizer).getPopulation(); + return ((GeneticAlgorithm)this.optimizer).getPopulation(); } public void setPopulation(Population pop){ - ((GeneticAlgorithm)this.m_Optimizer).setPopulation(pop); + ((GeneticAlgorithm)this.optimizer).setPopulation(pop); } public String populationTipText() { return "Edit the properties of the population used."; @@ -112,10 +112,10 @@ public class GAParameters extends AbstractGOParameters implements InterfaceGOPar * @param selection */ public void setParentSelection(InterfaceSelection selection) { - ((GeneticAlgorithm)this.m_Optimizer).setParentSelection(selection); + ((GeneticAlgorithm)this.optimizer).setParentSelection(selection); } public InterfaceSelection getParentSelection() { - return ((GeneticAlgorithm)this.m_Optimizer).getParentSelection(); + return ((GeneticAlgorithm)this.optimizer).getParentSelection(); } public String parentSelectionTipText() { return "Choose a parent selection method."; @@ -125,10 +125,10 @@ public class GAParameters extends AbstractGOParameters implements InterfaceGOPar * @param elitism */ public void setElitism (boolean elitism) { - ((GeneticAlgorithm)this.m_Optimizer).setElitism(elitism); + ((GeneticAlgorithm)this.optimizer).setElitism(elitism); } public boolean getElitism() { - return ((GeneticAlgorithm)this.m_Optimizer).getElitism(); + return ((GeneticAlgorithm)this.optimizer).getElitism(); } public String elitismTipText() { return "Enable/disable elitism."; @@ -141,10 +141,10 @@ public class GAParameters extends AbstractGOParameters implements InterfaceGOPar if (partners < 0) { partners = 0; } - ((GeneticAlgorithm)this.m_Optimizer).setNumberOfPartners(partners); + ((GeneticAlgorithm)this.optimizer).setNumberOfPartners(partners); } public int getNumberOfPartners() { - return ((GeneticAlgorithm)this.m_Optimizer).getNumberOfPartners(); + return ((GeneticAlgorithm)this.optimizer).getNumberOfPartners(); } public String numberOfPartnersTipText() { return "The number of mating partners needed to create offsprings."; @@ -154,10 +154,10 @@ public class GAParameters extends AbstractGOParameters implements InterfaceGOPar * @param selection */ public void setPartnerSelection(InterfaceSelection selection) { - ((GeneticAlgorithm)this.m_Optimizer).setPartnerSelection(selection); + ((GeneticAlgorithm)this.optimizer).setPartnerSelection(selection); } public InterfaceSelection getPartnerSelection() { - return ((GeneticAlgorithm)this.m_Optimizer).getPartnerSelection(); + return ((GeneticAlgorithm)this.optimizer).getPartnerSelection(); } public String partnerSelectionTipText() { return "Choose a selection method for selecting recombination partners for given parents."; diff --git a/src/eva2/optimization/modules/HCParameters.java b/src/eva2/optimization/modules/HCParameters.java index bf81d549..df0410ea 100644 --- a/src/eva2/optimization/modules/HCParameters.java +++ b/src/eva2/optimization/modules/HCParameters.java @@ -82,10 +82,10 @@ public class HCParameters extends AbstractGOParameters implements InterfaceGOPar * @return The population of current solutions to a given problem. */ public Population getPopulation() { - return ((HillClimbing) this.m_Optimizer).getPopulation(); + return ((HillClimbing) this.optimizer).getPopulation(); } public void setPopulation(Population pop){ - ((HillClimbing) this.m_Optimizer).setPopulation(pop); + ((HillClimbing) this.optimizer).setPopulation(pop); } public String populationTipText() { return "Edit the properties of the population used."; diff --git a/src/eva2/optimization/modules/MCParameters.java b/src/eva2/optimization/modules/MCParameters.java index 453e63a0..03e1ed8f 100644 --- a/src/eva2/optimization/modules/MCParameters.java +++ b/src/eva2/optimization/modules/MCParameters.java @@ -80,10 +80,10 @@ public class MCParameters extends AbstractGOParameters implements InterfaceGOPar * @return The population of current solutions to a given problem. */ public Population getPopulation() { - return ((MonteCarloSearch)this.m_Optimizer).getPopulation(); + return ((MonteCarloSearch)this.optimizer).getPopulation(); } public void setPopulation(Population pop){ - ((MonteCarloSearch)this.m_Optimizer).setPopulation(pop); + ((MonteCarloSearch)this.optimizer).setPopulation(pop); } public String populationTipText() { return "Edit the properties of the population used."; diff --git a/src/eva2/optimization/modules/MOEAParameters.java b/src/eva2/optimization/modules/MOEAParameters.java index 0ab0cace..b3edba20 100644 --- a/src/eva2/optimization/modules/MOEAParameters.java +++ b/src/eva2/optimization/modules/MOEAParameters.java @@ -70,10 +70,10 @@ public class MOEAParameters extends AbstractGOParameters implements InterfaceGOP * @return The population of current solutions to a given problem. */ public Population getPopulation() { - return ((MultiObjectiveEA)this.m_Optimizer).getPopulation(); + return ((MultiObjectiveEA)this.optimizer).getPopulation(); } public void setPopulation(Population pop){ - ((MultiObjectiveEA)this.m_Optimizer).setPopulation(pop); + ((MultiObjectiveEA)this.optimizer).setPopulation(pop); } public String populationTipText() { return "Edit the properties of the Population used."; @@ -84,11 +84,11 @@ public class MOEAParameters extends AbstractGOParameters implements InterfaceGOP */ @Override public InterfaceOptimizer getOptimizer() { - return ((MultiObjectiveEA)this.m_Optimizer).getOptimizer(); + return ((MultiObjectiveEA)this.optimizer).getOptimizer(); } @Override public void setOptimizer(InterfaceOptimizer b){ - ((MultiObjectiveEA)this.m_Optimizer).setOptimizer(b); + ((MultiObjectiveEA)this.optimizer).setOptimizer(b); } @Override public String optimizerTipText() { @@ -99,10 +99,10 @@ public class MOEAParameters extends AbstractGOParameters implements InterfaceGOP * @return The current optimizing method */ public InterfaceArchiving getArchivingStrategy() { - return ((MultiObjectiveEA)this.m_Optimizer).getArchivingStrategy(); + return ((MultiObjectiveEA)this.optimizer).getArchivingStrategy(); } public void setArchivingStrategy(InterfaceArchiving b){ - ((MultiObjectiveEA)this.m_Optimizer).setArchivingStrategy(b); + ((MultiObjectiveEA)this.optimizer).setArchivingStrategy(b); } public String archivingStrategyTipText() { return "Choose the archiving strategy."; @@ -112,10 +112,10 @@ public class MOEAParameters extends AbstractGOParameters implements InterfaceGOP * @return The current optimizing method */ public InterfaceInformationRetrieval getInformationRetrieval() { - return ((MultiObjectiveEA)this.m_Optimizer).getInformationRetrieval(); + return ((MultiObjectiveEA)this.optimizer).getInformationRetrieval(); } public void setInformationRetrieval(InterfaceInformationRetrieval b){ - ((MultiObjectiveEA)this.m_Optimizer).setInformationRetrieval(b); + ((MultiObjectiveEA)this.optimizer).setInformationRetrieval(b); } public String informationRetrievalTipText() { return "Choose the Information Retrieval strategy."; @@ -125,20 +125,20 @@ public class MOEAParameters extends AbstractGOParameters implements InterfaceGOP * @return The current optimizing method */ public int getArchiveSize() { - Population archive = ((MultiObjectiveEA)this.m_Optimizer).getPopulation().getArchive(); + Population archive = ((MultiObjectiveEA)this.optimizer).getPopulation().getArchive(); if (archive == null) { archive = new Population(); - ((MultiObjectiveEA)this.m_Optimizer).getPopulation().SetArchive(archive); + ((MultiObjectiveEA)this.optimizer).getPopulation().SetArchive(archive); } - return ((MultiObjectiveEA)this.m_Optimizer).getArchiveSize(); + return ((MultiObjectiveEA)this.optimizer).getArchiveSize(); } public void setArchiveSize(int b){ - Population archive = ((MultiObjectiveEA)this.m_Optimizer).getPopulation().getArchive(); + Population archive = ((MultiObjectiveEA)this.optimizer).getPopulation().getArchive(); if (archive == null) { archive = new Population(); - ((MultiObjectiveEA)this.m_Optimizer).getPopulation().SetArchive(archive); + ((MultiObjectiveEA)this.optimizer).getPopulation().SetArchive(archive); } - ((MultiObjectiveEA)this.m_Optimizer).getPopulation().getArchive().setTargetSize(b); + ((MultiObjectiveEA)this.optimizer).getPopulation().getArchive().setTargetSize(b); } public String archiveSizeTipText() { return "Choose the size of the archive."; diff --git a/src/eva2/optimization/modules/PBILParameters.java b/src/eva2/optimization/modules/PBILParameters.java index b5f7d5b7..2e67d084 100644 --- a/src/eva2/optimization/modules/PBILParameters.java +++ b/src/eva2/optimization/modules/PBILParameters.java @@ -60,7 +60,7 @@ public class PBILParameters extends AbstractGOParameters implements InterfaceGOP * @return description */ // public static String globalInfo() { -// return ((PopulationBasedIncrementalLearning)this.m_Optimizer).globalInfo(); +// return ((PopulationBasedIncrementalLearning)this.optimizer).globalInfo(); // } @Override @@ -75,10 +75,10 @@ public class PBILParameters extends AbstractGOParameters implements InterfaceGOP * @return The population of current solutions to a given problem. */ public Population getPopulation() { - return ((PopulationBasedIncrementalLearning)this.m_Optimizer).getPopulation(); + return ((PopulationBasedIncrementalLearning)this.optimizer).getPopulation(); } public void setPopulation(Population pop){ - ((PopulationBasedIncrementalLearning)this.m_Optimizer).setPopulation(pop); + ((PopulationBasedIncrementalLearning)this.optimizer).setPopulation(pop); } public String populationTipText() { return "Edit the properties of the population used."; @@ -88,10 +88,10 @@ public class PBILParameters extends AbstractGOParameters implements InterfaceGOP * @param selection */ public void setSelectionMethod(InterfaceSelection selection) { - ((PopulationBasedIncrementalLearning)this.m_Optimizer).setSelectionMethod(selection); + ((PopulationBasedIncrementalLearning)this.optimizer).setSelectionMethod(selection); } public InterfaceSelection getSelectionMethod() { - return ((PopulationBasedIncrementalLearning)this.m_Optimizer).getSelectionMethod(); + return ((PopulationBasedIncrementalLearning)this.optimizer).getSelectionMethod(); } public String selectionMethodTipText() { return "Choose a selection method."; @@ -101,10 +101,10 @@ public class PBILParameters extends AbstractGOParameters implements InterfaceGOP * @param elitism */ public void setElitism (boolean elitism) { - ((PopulationBasedIncrementalLearning)this.m_Optimizer).setElitism(elitism); + ((PopulationBasedIncrementalLearning)this.optimizer).setElitism(elitism); } public boolean getElitism() { - return ((PopulationBasedIncrementalLearning)this.m_Optimizer).getElitism(); + return ((PopulationBasedIncrementalLearning)this.optimizer).getElitism(); } public String elitismTipText() { return "Enable/disable elitism."; @@ -117,10 +117,10 @@ public class PBILParameters extends AbstractGOParameters implements InterfaceGOP if (LearningRate < 0) { LearningRate = 0; } - ((PopulationBasedIncrementalLearning)this.m_Optimizer).setLearningRate(LearningRate); + ((PopulationBasedIncrementalLearning)this.optimizer).setLearningRate(LearningRate); } public double getLearningRate() { - return ((PopulationBasedIncrementalLearning)this.m_Optimizer).getLearningRate(); + return ((PopulationBasedIncrementalLearning)this.optimizer).getLearningRate(); } public String learningRateTipText() { return "The learing rate of PBIL."; @@ -136,11 +136,11 @@ public class PBILParameters extends AbstractGOParameters implements InterfaceGOP if (m > 1) { m = 1; } - ((PopulationBasedIncrementalLearning)this.m_Optimizer).setMutationRate(m); + ((PopulationBasedIncrementalLearning)this.optimizer).setMutationRate(m); } public double getMutationRate() { - return ((PopulationBasedIncrementalLearning)this.m_Optimizer).getMutationRate(); + return ((PopulationBasedIncrementalLearning)this.optimizer).getMutationRate(); } public String mutationRateTipText() { return "The mutation rate of PBIL."; @@ -153,10 +153,10 @@ public class PBILParameters extends AbstractGOParameters implements InterfaceGOP if (m < 0) { m = 0; } - ((PopulationBasedIncrementalLearning)this.m_Optimizer).setMutateSigma(m); + ((PopulationBasedIncrementalLearning)this.optimizer).setMutateSigma(m); } public double getMutateSigma() { - return ((PopulationBasedIncrementalLearning)this.m_Optimizer).getMutateSigma(); + return ((PopulationBasedIncrementalLearning)this.optimizer).getMutateSigma(); } public String mutateSigmaTipText() { return "Set the sigma for the mutation of the probability vector."; @@ -169,10 +169,10 @@ public class PBILParameters extends AbstractGOParameters implements InterfaceGOP if (PositiveSamples < 1) { PositiveSamples = 1; } - ((PopulationBasedIncrementalLearning)this.m_Optimizer).setPositiveSamples(PositiveSamples); + ((PopulationBasedIncrementalLearning)this.optimizer).setPositiveSamples(PositiveSamples); } public int getPositiveSamples() { - return ((PopulationBasedIncrementalLearning)this.m_Optimizer).getPositiveSamples(); + return ((PopulationBasedIncrementalLearning)this.optimizer).getPositiveSamples(); } public String positiveSamplesTipText() { return "The number of positive samples that update the PBIL vector."; diff --git a/src/eva2/optimization/modules/PSOParameters.java b/src/eva2/optimization/modules/PSOParameters.java index 346b6be4..9ec3a730 100644 --- a/src/eva2/optimization/modules/PSOParameters.java +++ b/src/eva2/optimization/modules/PSOParameters.java @@ -89,10 +89,10 @@ public class PSOParameters extends AbstractGOParameters implements InterfaceGOPa * @return The population of current solutions to a given problem. */ public Population getPopulation() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getPopulation(); + return ((ParticleSwarmOptimization)this.optimizer).getPopulation(); } public void setPopulation(Population pop){ - ((ParticleSwarmOptimization)this.m_Optimizer).setPopulation(pop); + ((ParticleSwarmOptimization)this.optimizer).setPopulation(pop); } public String populationTipText() { return "Edit the properties of the population used."; @@ -102,26 +102,26 @@ public class PSOParameters extends AbstractGOParameters implements InterfaceGOPa * @param f */ public void setInitialVelocity (double f) { - ((ParticleSwarmOptimization)this.m_Optimizer).setInitialVelocity(f); + ((ParticleSwarmOptimization)this.optimizer).setInitialVelocity(f); } public double getInitialVelocity() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getInitialVelocity(); + return ((ParticleSwarmOptimization)this.optimizer).getInitialVelocity(); } public String initialVelocityTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).initialVelocityTipText(); + return ((ParticleSwarmOptimization)this.optimizer).initialVelocityTipText(); } /** This method will set the speed limit * @param k */ public void setSpeedLimit (double k) { - ((ParticleSwarmOptimization)this.m_Optimizer).setSpeedLimit(k); + ((ParticleSwarmOptimization)this.optimizer).setSpeedLimit(k); } public double getSpeedLimit() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getSpeedLimit(); + return ((ParticleSwarmOptimization)this.optimizer).getSpeedLimit(); } public String speedLimitTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).speedLimitTipText(); + return ((ParticleSwarmOptimization)this.optimizer).speedLimitTipText(); } /** This method will set the inertness @@ -130,15 +130,15 @@ public class PSOParameters extends AbstractGOParameters implements InterfaceGOPa public void setInertnessOrChi(double k) { // if (k < 0) k = 0; // if (k > 1) k = 1; - ((ParticleSwarmOptimization)this.m_Optimizer).setInertnessOrChi(k); + ((ParticleSwarmOptimization)this.optimizer).setInertnessOrChi(k); } public double getInertnessOrChi() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getInertnessOrChi(); + return ((ParticleSwarmOptimization)this.optimizer).getInertnessOrChi(); } public String inertnessOrChiTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).inertnessOrChiTipText(); + return ((ParticleSwarmOptimization)this.optimizer).inertnessOrChiTipText(); } /** This method will set greediness to move towards the best solution @@ -146,13 +146,13 @@ public class PSOParameters extends AbstractGOParameters implements InterfaceGOPa * @param l */ public void setPhi1 (double l) { - ((ParticleSwarmOptimization)this.m_Optimizer).setPhi1(l); + ((ParticleSwarmOptimization)this.optimizer).setPhi1(l); } public double getPhi1() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getPhi1(); + return ((ParticleSwarmOptimization)this.optimizer).getPhi1(); } public String phi1TipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).phi1TipText(); + return ((ParticleSwarmOptimization)this.optimizer).phi1TipText(); } /** This method will set greediness to move towards the best solution @@ -160,13 +160,13 @@ public class PSOParameters extends AbstractGOParameters implements InterfaceGOPa * @param l */ public void setPhi2 (double l) { - ((ParticleSwarmOptimization)this.m_Optimizer).setPhi2(l); + ((ParticleSwarmOptimization)this.optimizer).setPhi2(l); } public double getPhi2() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getPhi2(); + return ((ParticleSwarmOptimization)this.optimizer).getPhi2(); } public String phi2TipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).phi2TipText(); + return ((ParticleSwarmOptimization)this.optimizer).phi2TipText(); } @@ -174,129 +174,129 @@ public class PSOParameters extends AbstractGOParameters implements InterfaceGOPa * @param s Check Constraints. */ public void setCheckRange(boolean s) { - ((ParticleSwarmOptimization)this.m_Optimizer).setCheckRange(s); + ((ParticleSwarmOptimization)this.optimizer).setCheckRange(s); } public boolean isCheckRange() { - return ((ParticleSwarmOptimization)this.m_Optimizer).isCheckRange(); + return ((ParticleSwarmOptimization)this.optimizer).isCheckRange(); } public String checkConstraintsTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).checkRangeTipText(); + return ((ParticleSwarmOptimization)this.optimizer).checkRangeTipText(); } /** This method allows you to choose the topology type. * @param t The type. */ public void setTopology(PSOTopologyEnum t) { - ((ParticleSwarmOptimization)this.m_Optimizer).setTopology(t); - ((ParticleSwarmOptimization)this.m_Optimizer).setGOEShowProperties(getClass()); + ((ParticleSwarmOptimization)this.optimizer).setTopology(t); + ((ParticleSwarmOptimization)this.optimizer).setGOEShowProperties(getClass()); } public PSOTopologyEnum getTopology() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getTopology(); + return ((ParticleSwarmOptimization)this.optimizer).getTopology(); } public String topologyTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).topologyTipText(); + return ((ParticleSwarmOptimization)this.optimizer).topologyTipText(); } /** The range of the local neighbourhood. * @param s The range. */ public void setTopologyRange(int s) { - ((ParticleSwarmOptimization)this.m_Optimizer).setTopologyRange(s); + ((ParticleSwarmOptimization)this.optimizer).setTopologyRange(s); } public int getTopologyRange() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getTopologyRange(); + return ((ParticleSwarmOptimization)this.optimizer).getTopologyRange(); } public String topologyRangeTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).topologyRangeTipText(); + return ((ParticleSwarmOptimization)this.optimizer).topologyRangeTipText(); } public double getSubSwarmRadius() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getSubSwarmRadius(); + return ((ParticleSwarmOptimization)this.optimizer).getSubSwarmRadius(); } public void setSubSwarmRadius(double radius) { - ((ParticleSwarmOptimization)this.m_Optimizer).setSubSwarmRadius(radius); + ((ParticleSwarmOptimization)this.optimizer).setSubSwarmRadius(radius); } public String subSwarmRadiusTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).subSwarmRadiusTipText(); + return ((ParticleSwarmOptimization)this.optimizer).subSwarmRadiusTipText(); } public int getMaxSubSwarmSize() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getMaxSubSwarmSize(); + return ((ParticleSwarmOptimization)this.optimizer).getMaxSubSwarmSize(); } public void setMaxSubSwarmSize(int subSize) { - ((ParticleSwarmOptimization)this.m_Optimizer).setMaxSubSwarmSize(subSize); + ((ParticleSwarmOptimization)this.optimizer).setMaxSubSwarmSize(subSize); } public String maxSubSwarmSizeTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).maxSubSwarmSizeTipText(); + return ((ParticleSwarmOptimization)this.optimizer).maxSubSwarmSizeTipText(); } /** * @return the checkSpeedLimit **/ public boolean isCheckSpeedLimit() { - return ((ParticleSwarmOptimization)this.m_Optimizer).isCheckSpeedLimit(); + return ((ParticleSwarmOptimization)this.optimizer).isCheckSpeedLimit(); } /** * @param checkSpeedLimit the checkSpeedLimit to set **/ public void setCheckSpeedLimit(boolean checkSpeedLimit) { - ((ParticleSwarmOptimization)this.m_Optimizer).setCheckSpeedLimit(checkSpeedLimit); + ((ParticleSwarmOptimization)this.optimizer).setCheckSpeedLimit(checkSpeedLimit); GenericObjectEditor.setHideProperty(getClass(), "speedLimit", !checkSpeedLimit); } public String checkSpeedLimitTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).checkSpeedLimitTipText(); + return ((ParticleSwarmOptimization)this.optimizer).checkSpeedLimitTipText(); } /** This method allows you to choose the algorithm type. * @param s The type. */ public void setAlgoType(SelectedTag s) { - ((ParticleSwarmOptimization)this.m_Optimizer).setAlgoType(s); + ((ParticleSwarmOptimization)this.optimizer).setAlgoType(s); } public SelectedTag getAlgoType() { - return ((ParticleSwarmOptimization)this.m_Optimizer).getAlgoType(); + return ((ParticleSwarmOptimization)this.optimizer).getAlgoType(); } public String algoTypeTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).algoTypeTipText(); + return ((ParticleSwarmOptimization)this.optimizer).algoTypeTipText(); } // /** // * @return the treeBranchDeg // */ // public int getTreeBranchDegree() { -// return ((ParticleSwarmOptimization)this.m_Optimizer).getTreeBranchDegree(); +// return ((ParticleSwarmOptimization)this.optimizer).getTreeBranchDegree(); // } // // /** // * @param treeBranchDeg the treeBranchDeg to set // */ // public void setTreeBranchDegree(int treeBranchDeg) { -// ((ParticleSwarmOptimization)this.m_Optimizer).setTreeBranchDegree(treeBranchDeg); +// ((ParticleSwarmOptimization)this.optimizer).setTreeBranchDegree(treeBranchDeg); // } // // public String treeBranchDegreeTipText() { -// return ((ParticleSwarmOptimization)this.m_Optimizer).treeBranchDegreeTipText(); +// return ((ParticleSwarmOptimization)this.optimizer).treeBranchDegreeTipText(); // } /** * @return the wrapTopology */ public boolean isWrapTopology() { - return ((ParticleSwarmOptimization)this.m_Optimizer).isWrapTopology(); + return ((ParticleSwarmOptimization)this.optimizer).isWrapTopology(); } /** * @param wrapTopology the wrapTopology to set */ public void setWrapTopology(boolean wrapTopology) { - ((ParticleSwarmOptimization)this.m_Optimizer).setWrapTopology(wrapTopology); + ((ParticleSwarmOptimization)this.optimizer).setWrapTopology(wrapTopology); } public String wrapTopologyTipText() { - return ((ParticleSwarmOptimization)this.m_Optimizer).wrapTopologyTipText(); + return ((ParticleSwarmOptimization)this.optimizer).wrapTopologyTipText(); } } \ No newline at end of file diff --git a/src/eva2/optimization/modules/Processor.java b/src/eva2/optimization/modules/Processor.java index 1cef3672..dd88edb5 100644 --- a/src/eva2/optimization/modules/Processor.java +++ b/src/eva2/optimization/modules/Processor.java @@ -239,7 +239,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo while (isOptRunning() && (runCounter < m_Statistics.getStatisticsParameter().getMultiRuns())) { m_Statistics.startOptPerformed(getInfoString(), runCounter, goParams, getInformerList()); - this.goParams.getProblem().initProblem(); + this.goParams.getProblem().initializeProblem(); this.goParams.getOptimizer().setProblem(this.goParams.getProblem()); this.goParams.getTerminator().init(this.goParams.getProblem()); maybeInitParamCtrl(goParams); diff --git a/src/eva2/optimization/modules/SAParameters.java b/src/eva2/optimization/modules/SAParameters.java index ce1fd5e0..d76461c5 100644 --- a/src/eva2/optimization/modules/SAParameters.java +++ b/src/eva2/optimization/modules/SAParameters.java @@ -27,7 +27,7 @@ public class SAParameters extends AbstractGOParameters implements InterfaceGOPar // Opt. Algorithms and Parameters private InterfaceOptimizer m_Optimizer = new SimulatedAnnealing(); private InterfaceOptimizationProblem m_Problem = new B1Problem(); - //private int m_FunctionCalls = 1000; + //private int functionCalls = 1000; private InterfaceTerminator m_Terminator = new EvaluationTerminator(); // private String m_OutputFileName = "none"; transient private InterfacePopulationChangedEventListener m_Listener; diff --git a/src/eva2/optimization/modules/SSGAParameters.java b/src/eva2/optimization/modules/SSGAParameters.java index cd2167d6..0126b801 100644 --- a/src/eva2/optimization/modules/SSGAParameters.java +++ b/src/eva2/optimization/modules/SSGAParameters.java @@ -79,11 +79,11 @@ public class SSGAParameters extends AbstractGOParameters implements InterfaceGOP * @return The population of current solutions to a given problem. */ public Population getPopulation() { - return ((SteadyStateGA) this.m_Optimizer).getPopulation(); + return ((SteadyStateGA) this.optimizer).getPopulation(); } public void setPopulation(Population pop){ - ((SteadyStateGA) this.m_Optimizer).setPopulation(pop); + ((SteadyStateGA) this.optimizer).setPopulation(pop); } public String populationTipText() { @@ -107,11 +107,11 @@ public class SSGAParameters extends AbstractGOParameters implements InterfaceGOP * @param selection */ public void setParentSelection(InterfaceSelection selection) { - ((SteadyStateGA) this.m_Optimizer).setParentSelection(selection); + ((SteadyStateGA) this.optimizer).setParentSelection(selection); } public InterfaceSelection getParentSelection() { - return ((SteadyStateGA) this.m_Optimizer).getParentSelection(); + return ((SteadyStateGA) this.optimizer).getParentSelection(); } public String parentSelectionTipText() { @@ -128,11 +128,11 @@ public class SSGAParameters extends AbstractGOParameters implements InterfaceGOP if (partners < 0) { partners = 0; } - ((SteadyStateGA) this.m_Optimizer).setNumberOfPartners(partners); + ((SteadyStateGA) this.optimizer).setNumberOfPartners(partners); } public int getNumberOfPartners() { - return ((SteadyStateGA) this.m_Optimizer).getNumberOfPartners(); + return ((SteadyStateGA) this.optimizer).getNumberOfPartners(); } public String numberOfPartnersTipText() { return "The number of mating partners needed to create offsprings."; @@ -142,10 +142,10 @@ public class SSGAParameters extends AbstractGOParameters implements InterfaceGOP * @param selection */ public void setPartnerSelection(InterfaceSelection selection) { - ((SteadyStateGA)this.m_Optimizer).setPartnerSelection(selection); + ((SteadyStateGA)this.optimizer).setPartnerSelection(selection); } public InterfaceSelection getPartnerSelection() { - return ((SteadyStateGA)this.m_Optimizer).getPartnerSelection(); + return ((SteadyStateGA)this.optimizer).getPartnerSelection(); } public String partnerSelectionTipText() { return "Choose a selection method for selecting recombination partners for given parents."; @@ -155,10 +155,10 @@ public class SSGAParameters extends AbstractGOParameters implements InterfaceGOP * @param s A InterfaceReplacement strategy. */ public void setReplacementSelection(InterfaceReplacement s) { - ((SteadyStateGA)this.m_Optimizer).setReplacementSelection(s); + ((SteadyStateGA)this.optimizer).setReplacementSelection(s); } public InterfaceReplacement getReplacementSelection() { - return ((SteadyStateGA)this.m_Optimizer).getReplacementSelection(); + return ((SteadyStateGA)this.optimizer).getReplacementSelection(); } public String replacementSelectionTipText() { return "Choose a replacement strategy."; diff --git a/src/eva2/optimization/operators/cluster/ClusteringKMeans.java b/src/eva2/optimization/operators/cluster/ClusteringKMeans.java index f114e8ef..dd1661ff 100644 --- a/src/eva2/optimization/operators/cluster/ClusteringKMeans.java +++ b/src/eva2/optimization/operators/cluster/ClusteringKMeans.java @@ -395,7 +395,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab F1Problem f1 = new F1Problem(); f1.setProblemDimension(2); f1.setEAIndividual(new ESIndividualDoubleData()); - f1.initPopulation(pop); + f1.initializePopulation(pop); ckm.cluster(pop, (Population)null); } diff --git a/src/eva2/optimization/operators/cluster/ClusteringXMeans.java b/src/eva2/optimization/operators/cluster/ClusteringXMeans.java index 691c5139..abdb0da1 100644 --- a/src/eva2/optimization/operators/cluster/ClusteringXMeans.java +++ b/src/eva2/optimization/operators/cluster/ClusteringXMeans.java @@ -303,7 +303,7 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab if (true) { int k = 3; double[] x; - f1.initPopulation(pop); + f1.initializePopulation(pop); for (int i = 0; i < pop.size(); i++) { x = ((InterfaceDataTypeDouble)pop.get(i)).getDoubleData(); switch (i%k) { @@ -343,7 +343,7 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab ((InterfaceDataTypeDouble)pop.get(i)).SetDoubleGenotype(x); } } else { - f1.initPopulation(pop); + f1.initializePopulation(pop); } ckm.cluster(pop, (Population)null); diff --git a/src/eva2/optimization/operators/migration/MOConeSeparation.java b/src/eva2/optimization/operators/migration/MOConeSeparation.java index 33d53a9e..0b8dc0a0 100644 --- a/src/eva2/optimization/operators/migration/MOConeSeparation.java +++ b/src/eva2/optimization/operators/migration/MOConeSeparation.java @@ -149,7 +149,7 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl // indy = (AbstractEAIndividual)oldIPOP[i].get(j); // myPoint = new DPoint(indy.getFitness()[0], indy.getFitness()[1]); // tmp = new Chart2DDPointIconText(""+i); -// if (indy.m_AreaConst4ParallelViolated) tmp.setIcon(new Chart2DDPointIconCircle()); +// if (indy.areaConst4ParallelViolated) tmp.setIcon(new Chart2DDPointIconCircle()); // myPoint.setIcon(tmp); // mySet.addDPoint(myPoint); // } @@ -382,7 +382,7 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl // prob.evaluate(newIPOP[i]); // System.out.println("Invalid Individual in Island "+i+" ("+newIPOP[i].size()+"): "); // for (int j = 0; j < newIPOP[i].size(); j++) { -// if(((AbstractEAIndividual)newIPOP[i].get(j)).m_AreaConst4ParallelViolated) { +// if(((AbstractEAIndividual)newIPOP[i].get(j)).areaConst4ParallelViolated) { // System.out.print(j+", "); // ((AbstractEAIndividual)newIPOP[i].get(j)).checkAreaConst4Parallelization(((AbstractMultiObjectiveOptimizationProblem)prob).m_AreaConst4Parallelization); // } diff --git a/src/eva2/optimization/operators/mutation/MutateESCorrVector.java b/src/eva2/optimization/operators/mutation/MutateESCorrVector.java index 342c68bd..e7db8f88 100644 --- a/src/eva2/optimization/operators/mutation/MutateESCorrVector.java +++ b/src/eva2/optimization/operators/mutation/MutateESCorrVector.java @@ -132,7 +132,7 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab // mutate the velocity vector and write it back if ((m_scalingDev > 0) || (m_rotationDev > 0)) { // for (int i = 0; i < vel.length; i++) { -// vel[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.m_MutationStepSize); +// vel[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.mutationStepSize); // } double rotateRad = m_rotationDev*(Math.PI/360.)*RNG.gaussianDouble(1.); // rotate with a gaussian distribution of deviation rotationDeg diff --git a/src/eva2/optimization/operators/mutation/MutateESCorrolated.java b/src/eva2/optimization/operators/mutation/MutateESCorrolated.java index 4e43b516..a0434ed0 100644 --- a/src/eva2/optimization/operators/mutation/MutateESCorrolated.java +++ b/src/eva2/optimization/operators/mutation/MutateESCorrolated.java @@ -14,39 +14,39 @@ import eva2.tools.math.RNG; * To change this template use Options | File Templates. */ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializable { - protected double m_MutationStepSize = 0.2; - protected double m_Tau1 = 0.15; - protected double m_LowerLimitStepSize = 0.0000005; + protected double mutationStepSize = 0.2; + protected double tau1 = 0.15; + protected double lowerLimitStepSize = 0.0000005; private static final long serialVersionUID = 1L; - private double[] m_Sigmas = null; - private double[] m_Alphas = null; - protected double m_Tau2 = 0.15; + private double[] sigmas = null; + private double[] alphas = null; + protected double tau2 = 0.15; public MutateESCorrolated() { - this.m_Sigmas = null; - this.m_Alphas = null; + this.sigmas = null; + this.alphas = null; } public MutateESCorrolated(MutateESCorrolated mutator) { - if ((mutator.m_Sigmas != null)) { - this.m_Sigmas = new double[mutator.m_Sigmas.length]; - for (int i = 0; i < this.m_Sigmas.length; i++) { - this.m_Sigmas[i] = mutator.m_Sigmas[i]; + if ((mutator.sigmas != null)) { + this.sigmas = new double[mutator.sigmas.length]; + for (int i = 0; i < this.sigmas.length; i++) { + this.sigmas[i] = mutator.sigmas[i]; } } - if (mutator.m_Alphas != null) { - this.m_Alphas = new double[mutator.m_Alphas.length]; - for (int i = 0; i < this.m_Alphas.length; i++) { - this.m_Alphas[i] = mutator.m_Alphas[i]; + if (mutator.alphas != null) { + this.alphas = new double[mutator.alphas.length]; + for (int i = 0; i < this.alphas.length; i++) { + this.alphas[i] = mutator.alphas[i]; } } - this.m_MutationStepSize = mutator.m_MutationStepSize; - this.m_Tau1 = mutator.m_Tau1; - this.m_Tau2 = mutator.m_Tau2; - this.m_LowerLimitStepSize = mutator.m_LowerLimitStepSize; + this.mutationStepSize = mutator.mutationStepSize; + this.tau1 = mutator.tau1; + this.tau2 = mutator.tau2; + this.lowerLimitStepSize = mutator.lowerLimitStepSize; } /** This method will enable you to clone a given mutation operator @@ -68,27 +68,27 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab } if (mutator instanceof MutateESCorrolated) { MutateESCorrolated mut = (MutateESCorrolated)mutator; - if (this.m_Tau1 != mut.m_Tau1) { + if (this.tau1 != mut.tau1) { return false; } - if (this.m_Tau2 != mut.m_Tau2) { + if (this.tau2 != mut.tau2) { return false; } - if (this.m_LowerLimitStepSize != mut.m_LowerLimitStepSize) { + if (this.lowerLimitStepSize != mut.lowerLimitStepSize) { return false; } - if (this.m_Sigmas != null) { - for (int i = 0; i < this.m_Sigmas.length; i++) { - if (this.m_Sigmas[i] != mut.m_Sigmas[i]) { + if (this.sigmas != null) { + for (int i = 0; i < this.sigmas.length; i++) { + if (this.sigmas[i] != mut.sigmas[i]) { return false; } } } else { return false; } - if (this.m_Alphas != null) { - for (int i = 0; i < this.m_Alphas.length; i++) { - if (this.m_Alphas[i] != mut.m_Alphas[i]) { + if (this.alphas != null) { + for (int i = 0; i < this.alphas.length; i++) { + if (this.alphas[i] != mut.alphas[i]) { return false; } } @@ -109,18 +109,18 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) { if (individual instanceof InterfaceESIndividual) { double[] x = ((InterfaceESIndividual)individual).getDGenotype(); - if (this.m_Sigmas == null) { + if (this.sigmas == null) { // init the Sigmas - this.m_Sigmas = new double[x.length]; - for (int i = 0; i < this.m_Sigmas.length; i++) { - this.m_Sigmas[i] = this.m_MutationStepSize; + this.sigmas = new double[x.length]; + for (int i = 0; i < this.sigmas.length; i++) { + this.sigmas[i] = this.mutationStepSize; } } - if (this.m_Alphas == null) { + if (this.alphas == null) { // init the Alphas - this.m_Alphas = new double[(x.length*(x.length-1))/2]; - for (int i = 0; i < this.m_Alphas.length; i++) { - this.m_Alphas[i] = 0.0; + this.alphas = new double[(x.length*(x.length-1))/2]; + for (int i = 0; i < this.alphas.length; i++) { + this.alphas[i] = 0.0; } } } @@ -136,34 +136,34 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab // double[] xCopy = ((InterfaceESIndividual)individual).getDGenotype(); // double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); // double tmpR = RNG.gaussianDouble(1); -// if (this.m_Sigmas == null) { +// if (this.sigmas == null) { // // init the Sigmas -// this.m_Sigmas = new double[x.length]; -// for (int i = 0; i < this.m_Sigmas.length; i++) this.m_Sigmas[i] = this.m_MutationStepSize; +// this.sigmas = new double[x.length]; +// for (int i = 0; i < this.sigmas.length; i++) this.sigmas[i] = this.mutationStepSize; // } // // //Mutate Sigmas // for (int i = 0; i < x.length; i++) { -// this.m_Sigmas[i] = this.m_Sigmas[i] * Math.exp(this.m_Tau1 * tmpR + this.m_Tau2 * RNG.gaussianDouble(1)); -// if (this.m_Sigmas[i] < this.m_LowerLimitStepSize) this.m_Sigmas[i] = this.m_LowerLimitStepSize; +// this.sigmas[i] = this.sigmas[i] * Math.exp(this.tau1 * tmpR + this.tau2 * RNG.gaussianDouble(1)); +// if (this.sigmas[i] < this.lowerLimitStepSize) this.sigmas[i] = this.lowerLimitStepSize; // } // -//// if (this.m_Alphas == null) { +//// if (this.alphas == null) { //// // init the Alphas -//// this.m_Alphas = new double[(x.length*(x.length-1))/2]; -//// for (int i = 0; i < this.m_Alphas.length; i++) this.m_Alphas[i] = 0.0; +//// this.alphas = new double[(x.length*(x.length-1))/2]; +//// for (int i = 0; i < this.alphas.length; i++) this.alphas[i] = 0.0; //// } // //// //Mutate Alphas -//// for (int i = 0; i < this.m_Alphas.length; i++) { -//// this.m_Alphas[i] = this.m_Alphas[i] + RNG.gaussianDouble(0.01); -//// if (this.m_Alphas[i] < -m_PI/2) this.m_Alphas[i] = -m_PI/2; -//// if (this.m_Alphas[i] > m_PI/2) this.m_Alphas[i] = m_PI/2; +//// for (int i = 0; i < this.alphas.length; i++) { +//// this.alphas[i] = this.alphas[i] + RNG.gaussianDouble(0.01); +//// if (this.alphas[i] < -m_PI/2) this.alphas[i] = -m_PI/2; +//// if (this.alphas[i] > m_PI/2) this.alphas[i] = m_PI/2; //// } // // //Generate mutationvector in unitspace modified by sigmas // for (int i = 0; i < x.length; i++) { -// xCopy[i] = RNG.gaussianDouble(this.m_Sigmas[i]); +// xCopy[i] = RNG.gaussianDouble(this.sigmas[i]); // } // // //modify genotype @@ -199,26 +199,26 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab //Mutate Sigmas for (int i = 0; i < x.length; i++) { - this.m_Sigmas[i] *= Math.exp(this.m_Tau1 * tmpR + this.m_Tau2 * RNG.gaussianDouble(1)); - if (this.m_Sigmas[i] < this.m_LowerLimitStepSize) { - this.m_Sigmas[i] = this.m_LowerLimitStepSize; + this.sigmas[i] *= Math.exp(this.tau1 * tmpR + this.tau2 * RNG.gaussianDouble(1)); + if (this.sigmas[i] < this.lowerLimitStepSize) { + this.sigmas[i] = this.lowerLimitStepSize; } } //Mutate Alphas - for (int i = 0; i < this.m_Alphas.length; i++) { - this.m_Alphas[i] += RNG.gaussianDouble(0.2); - if (this.m_Alphas[i] < -Math.PI/2) { - this.m_Alphas[i] = -Math.PI/2; + for (int i = 0; i < this.alphas.length; i++) { + this.alphas[i] += RNG.gaussianDouble(0.2); + if (this.alphas[i] < -Math.PI/2) { + this.alphas[i] = -Math.PI/2; } - if (this.m_Alphas[i] > Math.PI/2) { - this.m_Alphas[i] = Math.PI/2; + if (this.alphas[i] > Math.PI/2) { + this.alphas[i] = Math.PI/2; } } //Generate mutationvector in unitspace modified by sigmas for (int i = 0; i < x.length; i++) { - xCopy[i] = RNG.gaussianDouble(this.m_Sigmas[i]); + xCopy[i] = RNG.gaussianDouble(this.sigmas[i]); } //turn mutationvector with alphas @@ -268,7 +268,7 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab sum+=n-count-1; } sum+=j-i; sum--; - return this.m_Alphas[sum]; + return this.alphas[sum]; }else{ System.err.println("Falscher Zugriff auf Alphaliste!"); return 0.0; @@ -308,10 +308,10 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab if (d < 0) { d = 0; } - this.m_Tau2 = d; + this.tau2 = d; } public double getTau2() { - return this.m_Tau2; + return this.tau2; } public String tau2TipText() { return "Set the value for tau2."; @@ -322,12 +322,12 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab */ public void setMutationStepSize(double d) { if (d < 0) { - d = this.m_LowerLimitStepSize; + d = this.lowerLimitStepSize; } - this.m_MutationStepSize = d; + this.mutationStepSize = d; } public double getMutationStepSize() { - return this.m_MutationStepSize; + return this.mutationStepSize; } public String mutationStepSizeTipText() { return "Choose the initial mutation step size."; @@ -340,10 +340,10 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab if (d < 0) { d = 0; } - this.m_LowerLimitStepSize = d; + this.lowerLimitStepSize = d; } public double getLowerLimitStepSize() { - return this.m_LowerLimitStepSize; + return this.lowerLimitStepSize; } public String lowerLimitStepSizeTipText() { return "Set the lower limit for the mutation step size."; @@ -356,10 +356,10 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab if (d < 0) { d = 0; } - this.m_Tau1 = d; + this.tau1 = d; } public double getTau1() { - return this.m_Tau1; + return this.tau1; } public String tau1TipText() { return "Set the value for tau1."; diff --git a/src/eva2/optimization/operators/mutation/MutateESMutativeStepSizeControl.java b/src/eva2/optimization/operators/mutation/MutateESMutativeStepSizeControl.java index 8bd33bd5..ebe8c300 100644 --- a/src/eva2/optimization/operators/mutation/MutateESMutativeStepSizeControl.java +++ b/src/eva2/optimization/operators/mutation/MutateESMutativeStepSizeControl.java @@ -120,7 +120,7 @@ public class MutateESMutativeStepSizeControl implements InterfaceMutation, java. } } ((InterfaceESIndividual)individual).SetDGenotype(x); - // System.out.println("new step size: " + m_MutationStepSize); + // System.out.println("new step size: " + mutationStepSize); } //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); } diff --git a/src/eva2/optimization/operators/mutation/MutateESStandard.java b/src/eva2/optimization/operators/mutation/MutateESStandard.java index dac9c564..f859998d 100644 --- a/src/eva2/optimization/operators/mutation/MutateESStandard.java +++ b/src/eva2/optimization/operators/mutation/MutateESStandard.java @@ -17,12 +17,12 @@ package eva2.optimization.operators.mutation; // * To change this template use Options | File Templates. // */ //public class MutateESStandard implements InterfaceMutation, java.io.Serializable { -// protected double m_MutationStepSize = 0.1; +// protected double mutationStepSize = 0.1; // public MutateESStandard() { // } // // public MutateESStandard(MutateESStandard d) { -// this.m_MutationStepSize = d.m_MutationStepSize; +// this.mutationStepSize = d.mutationStepSize; // } // // /** This method will enable you to clone a given mutation operator @@ -39,7 +39,7 @@ package eva2.optimization.operators.mutation; // public boolean equals(Object mutator) { // if (mutator instanceof MutateESStandard) { // MutateESStandard mut = (MutateESStandard)mutator; -// if (this.m_MutationStepSize != mut.m_MutationStepSize) return false; +// if (this.mutationStepSize != mut.mutationStepSize) return false; // return true; // } else return false; // } @@ -62,7 +62,7 @@ package eva2.optimization.operators.mutation; // double[] x = ((InterfaceESIndividual)individual).getDGenotype(); // double[][] range = ((InterfaceESIndividual)individual).getDoubleRange(); // for (int i = 0; i < x.length; i++) { -// x[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.m_MutationStepSize); +// x[i] += ((range[i][1] -range[i][0])/2)*RNG.gaussianDouble(this.mutationStepSize); // if (range[i][0] > x[i]) x[i] = range[i][0]; // if (range[i][1] < x[i]) x[i] = range[i][1]; // } @@ -111,10 +111,10 @@ package eva2.optimization.operators.mutation; // */ // public void setMutationStepSize(double step) { // if (step < 0) step = 0.0000001; -// this.m_MutationStepSize = step; +// this.mutationStepSize = step; // } // public double getMutationStepSize() { -// return this.m_MutationStepSize; +// return this.mutationStepSize; // } // public String mutationStepSizeTipText() { // return "Set the value for the fixed mutation step size."; diff --git a/src/eva2/optimization/operators/mutation/MutateESSuccessRule.java b/src/eva2/optimization/operators/mutation/MutateESSuccessRule.java index dae18a4e..d3bc537a 100644 --- a/src/eva2/optimization/operators/mutation/MutateESSuccessRule.java +++ b/src/eva2/optimization/operators/mutation/MutateESSuccessRule.java @@ -14,8 +14,8 @@ import eva2.optimization.populations.Population; public class MutateESSuccessRule extends MutateESFixedStepSize implements InterfaceMutation, InterfaceAdaptOperatorGenerational, java.io.Serializable { // it would be quite nice to make this variable static, but in that case // no one could runs n independent ES runs in parallel anymore *sigh* - // protected static double m_MutationStepSize = 0.2; -// protected double m_MutationStepSize = 0.2; // now in base class + // protected static double mutationStepSize = 0.2; +// protected double mutationStepSize = 0.2; // now in base class protected double m_SuccessRate = 0.2; protected double m_Alpha = 1.2; diff --git a/src/eva2/optimization/operators/postprocess/PostProcess.java b/src/eva2/optimization/operators/postprocess/PostProcess.java index 974c7754..78f05a28 100644 --- a/src/eva2/optimization/operators/postprocess/PostProcess.java +++ b/src/eva2/optimization/operators/postprocess/PostProcess.java @@ -1410,7 +1410,7 @@ listener.println("found " + getFoundOptima(solutions, mmkProb.getRealOptima(), e double[] avgFit = null; Population pop = new Population(portion); IndividualInterface indy; - prob.initProblem(); + prob.initializeProblem(); while (cnt < steps) { pop.clear(); for (int i=0; i 0) { this.functionCallCount += d; // add up the rest diff --git a/src/eva2/optimization/problems/AbstractDynTransProblem.java b/src/eva2/optimization/problems/AbstractDynTransProblem.java index 23a2c4ad..35e48269 100644 --- a/src/eva2/optimization/problems/AbstractDynTransProblem.java +++ b/src/eva2/optimization/problems/AbstractDynTransProblem.java @@ -110,10 +110,10 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz * Initializes the underlying problem in the problem class */ @Override - public void initProblem() { - super.initProblem(); + public void initializeProblem() { + super.initializeProblem(); bestIndividual = null; - getProblem().initProblem(); + getProblem().initializeProblem(); } @@ -138,7 +138,7 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz if (TRACE) { System.out.println("DynTransProblem at " + this + " initPop, problem is " + getProblem()); } - getProblem().initPopulation(population); + getProblem().initializePopulation(population); for (int i = 0; i < population.size(); i++) { ((AbstractEAIndividual)population.get(i)).SetAge(0); } @@ -172,7 +172,7 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz /* to get the right values for problemDimension and Range */ Population pop = new Population(); pop.setTargetSize(1); - prob.initPopulation(pop); + prob.initializePopulation(pop); AbstractEAIndividual indy = (AbstractEAIndividual)pop.get(0); if (indy instanceof InterfaceDataTypeDouble) { problemDimension = ((InterfaceDataTypeDouble)indy).getDoubleRange().length; diff --git a/src/eva2/optimization/problems/AbstractDynamicOptimizationProblem.java b/src/eva2/optimization/problems/AbstractDynamicOptimizationProblem.java index c4a29b80..f6261ab7 100644 --- a/src/eva2/optimization/problems/AbstractDynamicOptimizationProblem.java +++ b/src/eva2/optimization/problems/AbstractDynamicOptimizationProblem.java @@ -84,7 +84,7 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz } @Override - public void initProblem() { + public void initializeProblem() { setCurrentProblemTime(getStartTime()); if (myplot != null) { try { @@ -108,8 +108,8 @@ makePlot(); * @param population The populations that is to be inited */ @Override - public void initPopulation(Population population) { - //initProblem(); // this shouldnt be necessary + public void initializePopulation(Population population) { + //initializeProblem(); // this shouldnt be necessary this.initPopulationAt(population, getCurrentProblemTime()); } diff --git a/src/eva2/optimization/problems/AbstractMultiModalProblemKnown.java b/src/eva2/optimization/problems/AbstractMultiModalProblemKnown.java index d0e9fdb5..6f55caf8 100644 --- a/src/eva2/optimization/problems/AbstractMultiModalProblemKnown.java +++ b/src/eva2/optimization/problems/AbstractMultiModalProblemKnown.java @@ -16,94 +16,65 @@ import java.util.List; public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDouble implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown { protected static InterfaceDistanceMetric m_Metric = new PhenotypeMetric(); - private double m_GlobalOpt = 0; - protected Population m_ListOfOptima; - protected double m_Epsilon = 0.05; -// protected double[][] m_Range; -// protected double[] m_Extrema; - protected int m_ProblemDimension = 2; + private double globalOptimum = 0; + protected Population listOfOptima; + protected double epsilon = 0.05; + protected int problemDimension = 2; // if the global optimum is zero and we want to see logarithmic plots, the offset must be a little lower. see addOptimum() - protected boolean makeGlobalOptUnreachable = false; + protected boolean makeGlobalOptUnreachable = false; public AbstractMultiModalProblemKnown() { - this.m_ProblemDimension = 2; - this.m_Template = new ESIndividualDoubleData(); -// this.m_Extrema = new double[2]; -// this.m_Range = makeRange(); -// this.m_Extrema[0] = -2; -// this.m_Extrema[1] = 6; + this.problemDimension = 2; + this.template = new ESIndividualDoubleData(); } protected void cloneObjects(AbstractMultiModalProblemKnown b) { super.cloneObjects(b); - if (b.m_ListOfOptima != null) { - this.m_ListOfOptima = (Population)((Population)b.m_ListOfOptima).clone(); - } -// if (b.m_Range != null) { -// this.m_Range = new double[b.m_Range.length][b.m_Range[0].length]; -// for (int i = 0; i < this.m_Range.length; i++) { -// for (int j = 0; j < this.m_Range[i].length; j++) { -// this.m_Range[i][j] = b.m_Range[i][j]; -// } -// } -// } - this.m_ProblemDimension = b.m_ProblemDimension; - this.m_GlobalOpt = b.m_GlobalOpt; - this.m_Epsilon = b.m_Epsilon; -// if (b.m_Extrema != null) { -// this.m_Extrema = new double[b.m_Extrema.length]; -// for (int i = 0; i < this.m_Extrema.length; i++) { -// this.m_Extrema[i] = b.m_Extrema[i]; -// } -// } + if (b.listOfOptima != null) { + this.listOfOptima = (Population)((Population)b.listOfOptima).clone(); + }; + this.globalOptimum = b.globalOptimum; + this.epsilon = b.epsilon; } public AbstractMultiModalProblemKnown(AbstractMultiModalProblemKnown b) { cloneObjects(b); } -// /** This method returns a deep clone of the problem. -// * @return the clone -// */ -// public Object clone() { -// return (Object) new AbstractMultiModalProblem(this); -// } - /** This method inits a given population * @param population The populations that is to be inited */ @Override - public void initPopulation(Population population) { + public void initializePopulation(Population population) { AbstractEAIndividual tmpIndy; population.clear(); -// this.m_ProblemDimension = 2; - ((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(this.m_ProblemDimension); - ((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(makeRange()); + ((InterfaceDataTypeDouble)this.template).setDoubleDataLength(this.problemDimension); + ((InterfaceDataTypeDouble)this.template).SetDoubleRange(makeRange()); for (int i = 0; i < population.getTargetSize(); i++) { - tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.m_Template).clone(); + tmpIndy = (AbstractEAIndividual)((AbstractEAIndividual)this.template).clone(); tmpIndy.init(this); population.add(tmpIndy); } // population init must be last // it set's fitcalls and generation to zero population.init(); - if (m_ListOfOptima == null) { - this.m_GlobalOpt = Double.NEGATIVE_INFINITY; - m_ListOfOptima = new Population(); + if (listOfOptima == null) { + this.globalOptimum = Double.NEGATIVE_INFINITY; + listOfOptima = new Population(); this.initListOfOptima(); } } @Override - public void initProblem() { - super.initProblem(); - this.m_GlobalOpt = Double.NEGATIVE_INFINITY; - m_ListOfOptima = new Population(); + public void initializeProblem() { + super.initializeProblem(); + this.globalOptimum = Double.NEGATIVE_INFINITY; + listOfOptima = new Population(); this.initListOfOptima(); - if (!fullListAvailable() && (Double.isInfinite(m_GlobalOpt))) { - m_GlobalOpt=0; + if (!fullListAvailable() && (Double.isInfinite(globalOptimum))) { + globalOptimum =0; } } @@ -115,7 +86,7 @@ implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown { public double[] eval(double[] x) { x = rotateMaybe(x); double[] result = new double[1]; - result[0] = this.m_GlobalOpt - evalUnnormalized(x)[0]; + result[0] = this.globalOptimum - evalUnnormalized(x)[0]; return result; } @@ -140,27 +111,11 @@ implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown { @Override public Object[] getAdditionalDataValue(PopulationInterface pop) { Object[] result = new Object[2]; -// result += AbstractEAIndividual.getDefaultDataString(pop.getBestIndividual()) +"\t"; result[0] = this.getNumberOfFoundOptima((Population)pop); result[1] = this.getMaximumPeakRatio((Population)pop); return ToolBox.appendArrays(result, super.getAdditionalDataValue(pop)); } -// -// /** This method returns a string describing the optimization problem. -// * @return The description. -// */ -// public String getStringRepresentation() { -// String result = ""; -// -// result += "M0 function:\n"; -// result += "This problem has one global and one local optimum.\n"; -// result += "Parameters:\n"; -// result += "Dimension : " + this.m_ProblemDimension +"\n"; -// result += "Noise level : " + this.getNoise() + "\n"; -// result += "Solution representation:\n"; -// //result += this.m_Template.getSolutionRepresentationFor(); -// return result; -// } + /********************************************************************************************************************** * Implementation of InterfaceMultimodalProblemKnown @@ -178,33 +133,32 @@ implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown { } /** This method allows you to add a 2d optima to the list of optima - * @param x - * @param y + * @param point */ protected void addOptimum(double[] point) { InterfaceDataTypeDouble tmpIndy; - tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.m_Template).clone(); + tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.template).clone(); tmpIndy.SetDoubleGenotype(point); ((AbstractEAIndividual)tmpIndy).setFitness(evalUnnormalized(point)); - if (((AbstractEAIndividual)tmpIndy).getFitness(0)>=m_GlobalOpt) { - m_GlobalOpt = ((AbstractEAIndividual)tmpIndy).getFitness(0); + if (((AbstractEAIndividual)tmpIndy).getFitness(0)>= globalOptimum) { + globalOptimum = ((AbstractEAIndividual)tmpIndy).getFitness(0); if (makeGlobalOptUnreachable) { - double tmp=m_GlobalOpt; + double tmp= globalOptimum; double dx = 1e-30; - while (tmp==m_GlobalOpt) { + while (tmp== globalOptimum) { // this increases the optimum until there is a real difference. // tries to avoid zero y-values which break the logarithmic plot tmp+=dx; dx *= 10; } - m_GlobalOpt = tmp; + globalOptimum = tmp; } } if (isDoRotation()) { point = inverseRotateMaybe(point); // theres an inverse rotation required tmpIndy.SetDoubleGenotype(point); } - this.m_ListOfOptima.add(tmpIndy); + this.listOfOptima.add(tmpIndy); } /** @@ -222,7 +176,7 @@ implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown { */ @Override public Population getRealOptima() { - return this.m_ListOfOptima; + return this.listOfOptima; } /** @@ -265,7 +219,7 @@ implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown { return -1; } else { - return getMaximumPeakRatio(this.getRealOptima(), pop, m_Epsilon); + return getMaximumPeakRatio(this.getRealOptima(), pop, epsilon); } } @@ -273,7 +227,7 @@ implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown { * Returns -1 if the full list is not available. Otherwise calculates the maximum peak ratio * based on the full list of known optima. * This assumes that the realOpts have fitness values assigned as for maximization and the - * pop has fitness values assigned for minimization (mirrored by maximum fitness within realOpts). + * population has fitness values assigned for minimization (mirrored by maximum fitness within realOpts). * * This is in analogy to the original implementation by F.Streichert. * @@ -287,8 +241,6 @@ implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown { if (realOpts==null || (realOpts.size()==0)) { return -1; } -// if (!mmProb.fullListAvailable()) return -1; -// Population realOpts = mmProb.getRealOptima(); double tmp, maxOpt = realOpts.getEAIndividual(0).getFitness(0); sumRealMaxima = maxOpt; for (int i=1; i resultrep; - Population pop; - Semaphore m_Semaphore; + Population population; + Semaphore semaphore; public EvalThread(AbstractOptimizationProblem prob, AbstractEAIndividual ind, Population pop,Semaphore sema) { this.ind = ind; this.prob = prob; -// this.resultrep = resultrep; - this.pop = pop; - this.m_Semaphore=sema; + this.population = pop; + this.semaphore =sema; } @Override public void run() { -// System.out.println("Running ET " + this); -// long time=System.nanoTime(); prob.evaluate(ind); -// resultrep.add(ind); - pop.incrFunctionCalls(); - m_Semaphore.release(); -// long duration=System.nanoTime()-time; -// System.out.println("Finished ET" + this + ", time was " + duration); + population.incrFunctionCalls(); + semaphore.release(); } } @@ -82,9 +74,9 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial */ public static final String OLD_FITNESS_KEY = "oldFitness"; - int parallelthreads = 1; + private int parallelthreads = 1; - protected AbstractEAIndividual m_Template = null; + protected AbstractEAIndividual template = null; // private transient ArrayList changeListeners = null; private double defaultAccuracy = 0.001; // default accuracy for identifying optima. @@ -112,7 +104,7 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial * If you override it, make sure to call the super method! */ @Override - public abstract void initProblem(); + public abstract void initializeProblem(); /******************** The most important methods ****************************************/ @@ -120,7 +112,7 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial * @param population The populations that is to be inited */ @Override - public abstract void initPopulation(Population population); + public abstract void initializePopulation(Population population); /** This method evaluates a given population and set the fitness values * accordingly @@ -133,27 +125,6 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial if (this.parallelthreads > 1) { Vector queue = new Vector(population.size()); -// Vector finished = new Vector(population.size()); - /* queue.addAll(population); - Semaphore sema=new Semaphore(parallelthreads); - while (finished.size() < population.size()) { - try { - sema.acquire(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if ((population.size()-(queue.size() + finished.size())) < parallelthreads) { - if (queue.size() > 0) { - AbstractEAIndividual tmpindy = queue.get(0); - queue.remove(0); - tmpindy.resetConstraintViolation(); - EvalThread evalthread = new EvalThread(this,tmpindy,finished,population,sema); - evalthread.start(); - - } - } - }*/ Semaphore sema=new Semaphore(0); ExecutorService pool = Executors.newFixedThreadPool(parallelthreads); int cntIndies=0; @@ -338,7 +309,6 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial Population maybeFiltered = (Population)pop; if (pop.size()>100) { // for efficiency reasons... maybeFiltered = maybeFiltered.filterByFitness(hist.getUpperBound(), fitCrit); -// System.out.println("Reduced " + pop.size() + " to " + maybeFiltered.size()); } Population sols = PostProcess.clusterBestUpdateHistogram((Population)maybeFiltered, this, hist, fitCrit, getDefaultAccuracy()); } @@ -429,7 +399,7 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial * @return the problem's individual template */ public AbstractEAIndividual getIndividualTemplate() { - return m_Template; + return template; } public String individualTemplateTipText() { @@ -451,7 +421,7 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial double epsilonPhenoSpace, double epsilonFitConv, double clusterSigma, int maxEvalsPerIndy) { Population potOptima = new Population(); for (int i = 0; i < pop.size(); ++i){ - //System.out.println("Refining " + i + " of " + pop.size()); + //System.out.println("Refining " + i + " of " + population.size()); AbstractEAIndividual indy = pop.getEAIndividual(i); // System.out.println("bef: " + indy.toString()); boolean isConverged = AbstractOptimizationProblem.isPotentialOptimumNMS(prob, indy, epsilonPhenoSpace, epsilonFitConv, maxEvalsPerIndy); @@ -496,7 +466,7 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial mutationStepSize = 0.0001; } if (numOfFailures<0) { - numOfFailures = 100*AbstractEAIndividual.getDoublePositionShallow(this.m_Template).length; + numOfFailures = 100*AbstractEAIndividual.getDoublePositionShallow(this.template).length; } // scales the effort with the number of problem dimensions AbstractEAIndividual indy = (AbstractEAIndividual)orig.clone(); @@ -564,11 +534,10 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial double initRelPerturb = -1; int dim = -1; if (orig instanceof InterfaceDataTypeDouble) { -// initPerturb = epsilonPhenoSpace/(2*(Mathematics.getAvgRange(((InterfaceDataTypeDouble)orig).getDoubleRange()))); initRelPerturb = epsilonPhenoSpace*0.5; dim=((InterfaceDataTypeDouble)orig).getDoubleRange().length; if (maxEvaluations<0) { - maxEvaluations = 500*AbstractEAIndividual.getDoublePositionShallow(prob.m_Template).length; + maxEvaluations = 500*AbstractEAIndividual.getDoublePositionShallow(prob.template).length; } // scales the effort with the number of problem dimensions } else { System.err.println("Cannot initialize NMS on non-double valued individuals!"); @@ -584,19 +553,19 @@ implements InterfaceOptimizationProblem /*, InterfaceParamControllable*/, Serial int evalsPerf = PostProcess.processSingleCandidatesNMCMA(PostProcessMethod.nelderMead, pop, term, initRelPerturb, prob); overallDist = metric.distance(indy, pop.getBestEAIndividual()); //System.out.println(System.currentTimeMillis() + " in " + evalsPerf + " evals moved by "+ overallDist); -// System.out.println("aft: " + pop.getBestEAIndividual().toString() + ", evals performed: " + evalsPerf + ", opt moved by " + overallDist); +// System.out.println("aft: " + population.getBestEAIndividual().toString() + ", evals performed: " + evalsPerf + ", opt moved by " + overallDist); // System.out.println("terminated because: " + term.lastTerminationMessage()); orig.putData(PostProcess.movedDistanceKey, overallDist); orig.putData(PostProcess.movedToPositionKey, pop.getBestEAIndividual().getDoublePosition()); // if (overallDist==0) { -// PostProcess.processSingleCandidatesNMCMA(PostProcessMethod.nelderMead, pop, term, initPerturb, this); +// PostProcess.processSingleCandidatesNMCMA(PostProcessMethod.nelderMead, population, term, initPerturb, this); // } // System.out.println("Checked "+ indy.getStringRepresentation()); // String msg = "----discarding "; // if (overallDist <= epsilonPhenoSpace) msg= "++++keeping "; // System.out.println(msg + BeanInspector.toString(indy.getDoublePosition())); -// System.out.println("which moved to " + BeanInspector.toString(pop.getBestEAIndividual().getDoublePosition())); +// System.out.println("which moved to " + BeanInspector.toString(population.getBestEAIndividual().getDoublePosition())); // System.out.println(" by " + overallDist + " > " + epsilonPhenoSpace); return (overallDist < epsilonPhenoSpace); diff --git a/src/eva2/optimization/problems/AbstractParallelOptimizationProblem.java b/src/eva2/optimization/problems/AbstractParallelOptimizationProblem.java index 9e3cfcd1..ea5b7c5a 100644 --- a/src/eva2/optimization/problems/AbstractParallelOptimizationProblem.java +++ b/src/eva2/optimization/problems/AbstractParallelOptimizationProblem.java @@ -17,7 +17,7 @@ public abstract class AbstractParallelOptimizationProblem extends AbstractOptimi private AbstractOptimizationProblem[] m_Slaves; @Override - public void initProblem() { + public void initializeProblem() { /* if (this.m_Parallelize) { // this is running on remote maschines String[] nodesList = this.m_Servers.getCheckedServerNodes(); diff --git a/src/eva2/optimization/problems/AbstractProblemBinary.java b/src/eva2/optimization/problems/AbstractProblemBinary.java index c7e7f246..e0735416 100644 --- a/src/eva2/optimization/problems/AbstractProblemBinary.java +++ b/src/eva2/optimization/problems/AbstractProblemBinary.java @@ -21,17 +21,17 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem } protected void initTemplate() { - if (m_Template == null) { - this.m_Template = new GAIndividualBinaryData(); + if (template == null) { + this.template = new GAIndividualBinaryData(); } - if (((InterfaceGAIndividual)this.m_Template).getGenotypeLength()!=this.getProblemDimension()) { - ((InterfaceDataTypeBinary)this.m_Template).setBinaryDataLength(this.getProblemDimension()); + if (((InterfaceGAIndividual)this.template).getGenotypeLength()!=this.getProblemDimension()) { + ((InterfaceDataTypeBinary)this.template).setBinaryDataLength(this.getProblemDimension()); } } public void cloneObjects(AbstractProblemBinary o) { - if (o.m_Template != null) { - m_Template = (AbstractEAIndividual)o.m_Template.clone(); + if (o.template != null) { + template = (AbstractEAIndividual)o.template.clone(); } } @@ -65,7 +65,7 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem // /** // * Initialize a single individual with index k in the -// * initPopulation cycle. +// * initializePopulation cycle. // * @param k // * @param indy // */ @@ -74,13 +74,13 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem // } @Override - public void initPopulation(Population population) { - ((InterfaceDataTypeBinary)this.m_Template).setBinaryDataLength(this.getProblemDimension()); - AbstractOptimizationProblem.defaultInitPopulation(population, m_Template, this); + public void initializePopulation(Population population) { + ((InterfaceDataTypeBinary)this.template).setBinaryDataLength(this.getProblemDimension()); + AbstractOptimizationProblem.defaultInitPopulation(population, template, this); } @Override - public void initProblem() { + public void initializeProblem() { initTemplate(); } diff --git a/src/eva2/optimization/problems/AbstractProblemDouble.java b/src/eva2/optimization/problems/AbstractProblemDouble.java index cfccb00c..65614a3d 100644 --- a/src/eva2/optimization/problems/AbstractProblemDouble.java +++ b/src/eva2/optimization/problems/AbstractProblemDouble.java @@ -36,7 +36,7 @@ import eva2.tools.math.RNG; * that case, the default range parameter is not used. * * Anything you want to do before any optimization is started on the problem - * should go into {@link #initProblem()}, but remember to call the super-method + * should go into {@link #initializeProblem()}, but remember to call the super-method * in your implementation. The individual template will be initialized to an * ESIndividualDoubleData by then. * @@ -44,21 +44,14 @@ import eva2.tools.math.RNG; * {@link #getName()} methods to provide some distinctive information for the * user. * - * - * @author mkron - * */ -public abstract class AbstractProblemDouble extends AbstractOptimizationProblem - implements InterfaceProblemDouble, Interface2DBorderProblem/* - * , - * InterfaceParamControllable - */{ +public abstract class AbstractProblemDouble extends AbstractOptimizationProblem implements InterfaceProblemDouble, Interface2DBorderProblem { /** * Generated serial version identifier. */ private static final long serialVersionUID = -3904130243174390134L; - private double m_DefaultRange = 10; - private double m_Noise = 0; + private double defaultRange = 10; + private double noise = 0; private boolean doRotation = false; // should really be false by default private Matrix rotation; @@ -80,14 +73,14 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem } protected void initTemplate() { - if (m_Template == null) { - m_Template = new ESIndividualDoubleData(); + if (template == null) { + template = new ESIndividualDoubleData(); } if (getProblemDimension() > 0) { // avoid evil case setting dim to 0 // during object init - ((InterfaceDataTypeDouble) this.m_Template) + ((InterfaceDataTypeDouble) this.template) .setDoubleDataLength(getProblemDimension()); - ((InterfaceDataTypeDouble) this.m_Template) + ((InterfaceDataTypeDouble) this.template) .SetDoubleRange(makeRange()); } } @@ -97,11 +90,11 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem } protected void cloneObjects(AbstractProblemDouble o) { - this.m_DefaultRange = o.m_DefaultRange; - this.m_Noise = o.m_Noise; + this.defaultRange = o.defaultRange; + this.noise = o.noise; this.SetDefaultAccuracy(o.getDefaultAccuracy()); - if (o.m_Template != null) { - this.m_Template = (AbstractEAIndividual) o.m_Template.clone(); + if (o.template != null) { + this.template = (AbstractEAIndividual) o.template.clone(); } if (o.constraintArray != null) { this.constraintArray = o.constraintArray.clone(); @@ -126,11 +119,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem * @return the double solution representation */ protected double[] getEvalArray(AbstractEAIndividual individual) { - double[] x = new double[((InterfaceDataTypeDouble) individual) - .getDoubleData().length]; - System.arraycopy( - ((InterfaceDataTypeDouble) individual).getDoubleData(), 0, x, - 0, x.length); + double[] x = new double[((InterfaceDataTypeDouble) individual).getDoubleData().length]; + System.arraycopy(((InterfaceDataTypeDouble) individual).getDoubleData(), 0, x, 0, x.length); return x; } @@ -151,9 +141,9 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem // evaluate the vector fitness = this.eval(x); // if indicated, add Gaussian noise - if (m_Noise != 0) { - RNG.addNoise(fitness, m_Noise); - } + if (noise != 0) { + RNG.addNoise(fitness, noise); + } // set the fitness setEvalFitness(individual, x, fitness); if (isWithConstraints()) { @@ -165,8 +155,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem protected double[] rotateMaybe(double[] x) { if (isDoRotation()) { if (rotation == null) { - initProblem(); - } + initializeProblem(); + } x = Mathematics.rotate(x, rotation); } return x; @@ -175,8 +165,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem protected double[] inverseRotateMaybe(double[] x) { if (isDoRotation()) { if (rotation == null) { - initProblem(); - } + initializeProblem(); + } x = Mathematics.rotate(x, rotation.inverse()); } return x; @@ -190,16 +180,11 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem * @param indyPos * may contain the decoded individual position */ - protected void addConstraints(AbstractEAIndividual individual, - double[] indyPos) { - AbstractConstraint[] cnstr = getConstraints(); - for (int i = 0; i < cnstr.length; i++) { - // String name= (String)BeanInspector.callIfAvailable(cnstr[i], - // "getName", new Object[]{}); - // System.out.println("checking constraint " + (name==null ? - // cnstr[i].getClass().getSimpleName() : name)); - ((AbstractConstraint) cnstr[i]).addViolation(individual, indyPos); - } + protected void addConstraints(AbstractEAIndividual individual, double[] indyPos) { + AbstractConstraint[] contraints = getConstraints(); + for (AbstractConstraint contraint : contraints) { + contraint.addViolation(individual, indyPos); + } } /** @@ -210,8 +195,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem * @param x * @param fit */ - protected void setEvalFitness(AbstractEAIndividual individual, double[] x, - double[] fit) { + protected void setEvalFitness(AbstractEAIndividual individual, double[] x, double[] fit) { individual.setFitness(fit); } @@ -236,10 +220,9 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem public abstract int getProblemDimension(); @Override - public void initPopulation(Population population) { + public void initializePopulation(Population population) { initTemplate(); - AbstractOptimizationProblem.defaultInitPopulation(population, - m_Template, this); + AbstractOptimizationProblem.defaultInitPopulation(population, template, this); } /** @@ -289,14 +272,13 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem } @Override - public void initProblem() { + public void initializeProblem() { initTemplate(); if (isDoRotation()) { - rotation = initDefaultRotationMatrix(rotAngle, - getProblemDimension()); + rotation = initializeDefaultRotationMatrix(rotAngle, getProblemDimension()); } else { - rotation = null; - } + rotation = null; + } } /** @@ -307,17 +289,9 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem * @param dim * @return */ - public static Matrix initDefaultRotationMatrix(double rotAngle, int dim) { + public static Matrix initializeDefaultRotationMatrix(double rotAngle, int dim) { Matrix rotation = null; - // Matrix vec = new Matrix(dim, 1); - // for (int i=0; i1e-20) { -// m_ListOfOptima.clear(); +// listOfOptima.clear(); // return true; // } // } @@ -300,14 +300,14 @@ public class F8Problem extends AbstractProblemDoubleOffset } // private double[] refineSolution(double[] pos) { -// Population pop = new Population(); +// Population population = new Population(); // InterfaceDataTypeDouble tmpIndy; -// tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.m_Template).clone(); +// tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.template).clone(); // tmpIndy.SetDoubleGenotype(pos); // ((AbstractEAIndividual)tmpIndy).SetFitness(eval(pos)); -// pop.add(tmpIndy); +// population.add(tmpIndy); // FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(1e-15, 10, false, true); -// int calls = PostProcess.processWithGDA(pop, this, convTerm, 0, 0.0000000000000001, 0.01); -// return ((InterfaceDataTypeDouble)pop.getBestEAIndividual()).getDoubleData(); +// int calls = PostProcess.processWithGDA(population, this, convTerm, 0, 0.0000000000000001, 0.01); +// return ((InterfaceDataTypeDouble)population.getBestEAIndividual()).getDoubleData(); // } } \ No newline at end of file diff --git a/src/eva2/optimization/problems/F9Problem.java b/src/eva2/optimization/problems/F9Problem.java index b90f6c11..f37ce760 100644 --- a/src/eva2/optimization/problems/F9Problem.java +++ b/src/eva2/optimization/problems/F9Problem.java @@ -5,7 +5,7 @@ import eva2.optimization.individuals.ESIndividualDoubleData; public class F9Problem extends AbstractProblemDoubleOffset implements java.io.Serializable { public F9Problem() { - this.m_Template = new ESIndividualDoubleData(); + this.template = new ESIndividualDoubleData(); } public F9Problem(F9Problem b) { super(b); @@ -27,9 +27,9 @@ public class F9Problem extends AbstractProblemDoubleOffset implements java.io.Se public double[] eval(double[] x) { x = rotateMaybe(x); double[] result = new double[1]; - result[0] = m_YOffset; + result[0] = yOffset; for (int i = 0; i < x.length; i++) { - result[0] += (i+1)*Math.pow(x[i]-m_XOffset, 2); + result[0] += (i+1)*Math.pow(x[i]- xOffset, 2); } return result; } @@ -42,10 +42,10 @@ public class F9Problem extends AbstractProblemDoubleOffset implements java.io.Se result += "F9 Weighted Sphere Model:\n"; result += "Parameters:\n"; - result += "Dimension : " + this.m_ProblemDimension +"\n"; + result += "Dimension : " + this.problemDimension +"\n"; result += "Noise level : " + this.getNoise() + "\n"; result += "Solution representation:\n"; - //result += this.m_Template.getSolutionRepresentationFor(); + //result += this.template.getSolutionRepresentationFor(); return result; } diff --git a/src/eva2/optimization/problems/FLensProblem.java b/src/eva2/optimization/problems/FLensProblem.java index e335ad5d..b9f86c54 100644 --- a/src/eva2/optimization/problems/FLensProblem.java +++ b/src/eva2/optimization/problems/FLensProblem.java @@ -171,7 +171,7 @@ class MyLensViewer extends JPanel implements InterfaceSolutionViewer { @Override public void updateView(Population pop, boolean showAllIfPossible) { if (showAllIfPossible) { -// indiesToPaint=pop; +// indiesToPaint=population; for (int i=0; i 0) { // avoid evil case setting dim to 0 during object init + ((InterfaceDataTypeDouble) this.template).setDoubleDataLength(getProblemDimension()); + ((InterfaceDataTypeDouble) this.template).SetDoubleRange(range); + } + break; + case typeBinary: + ///// binary alternative + if (template == null || !(template instanceof GAIndividualBinaryData)) { + template = new GAIndividualBinaryData(getProblemDimension()); + } + break; + case typeInteger: + int[][] intRange = makeIntRange(range); + if (template == null || !(template instanceof GIIndividualIntegerData)) { + template = new GIIndividualIntegerData(intRange); + } + break; + } + } + + private int[][] makeIntRange(double[][] r) { + int[][] intRange = new int[r.length][r[0].length]; + for (int i = 0; i < r.length; i++) { + for (int j = 0; j < r[0].length; j++) { + intRange[i][j] = (int) r[i][j]; } - if (getProblemDimension() > 0) { // avoid evil case setting dim to 0 during object init - ((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(getProblemDimension()); - ((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(range); - } - break; - case typeBinary: - ///// binary alternative - if (m_Template == null || !(m_Template instanceof GAIndividualBinaryData)) { - m_Template = new GAIndividualBinaryData(getProblemDimension()); - } - break; - case typeInteger: - int[][] intRange=makeIntRange(range); - if (m_Template == null || !(m_Template instanceof GIIndividualIntegerData)) { - m_Template = new GIIndividualIntegerData(intRange); - } - break; - } - } + } + return intRange; + } - private int[][] makeIntRange(double[][] r) { - int[][] intRange=new int[r.length][r[0].length]; - for (int i=0; i= 0) && (verboLevel <= 3)) { - verbosityLevel = verboLevel; - } - else { - System.err.println("Error, invalid verbosity level for statistics output!"); + dos = new PrintStream(new FileOutputStream(fname)); + } catch (FileNotFoundException e) { + e.printStackTrace(); } - } + } + } - public String jmiInterfaceNameTipText() { - return "Name of the JEInterface instance in Matlab"; - } + public void setStatsOutput(int verboLevel) { + if ((verboLevel >= 0) && (verboLevel <= 3)) { + verbosityLevel = verboLevel; + } else { + System.err.println("Error, invalid verbosity level for statistics output!"); + } + } - /** - * @param problemDimension the problemDimension to set - */ - public void setProblemDimension(int problemDimension) { - this.problemDimension = problemDimension; - } + public String jmiInterfaceNameTipText() { + return "Name of the JEInterface instance in Matlab"; + } + + /** + * @param problemDimension the problemDimension to set + */ + public void setProblemDimension(int problemDimension) { + this.problemDimension = problemDimension; + } - public int getProblemDimension() { - return problemDimension; - } + public int getProblemDimension() { + return problemDimension; + } - public String problemDimensionTipText() { - return "The dimension of the problem."; - } + public String problemDimensionTipText() { + return "The dimension of the problem."; + } -// public double[][] makeRange() { -// if (range==null) range=super.makeRange(); -// return range; -// } + public void log(String str) { + if (dos != null) { + dos.print((String) str); + dos.flush(); + } + } -// protected double getRangeLowerBound(int dim) { -// return (range==null) ? super.getRangeLowerBound(dim) : range[dim][0]; -// } + public void optimize(final int optType, String outputFilePrefix) { + optimize(optType, outputFilePrefix, null, null); + } -// protected double getRangeUpperBound(int dim) { -// return (range==null) ? super.getRangeUpperBound(dim) : range[dim][1]; -// } + public void clearSeedPopulation() { + seedPopulation = null; + } -// public double[] getCurrentDoubleArray() { -// return currArray; -// } - -// public double[] getNewDoubleArray() { -// currArray = new double[problemDimension]; -// for (int i=0; i0.5)); - } - return bs; - } + private int[] toInteger(double[] ds) { + int[] a = new int[ds.length]; + for (int i = 0; i < ds.length; i++) { + a[i] = (int) Math.round(ds[i]); + } + return a; + } - /** - * Start an optimization using the MatlabProblem. The optType references the standard - * optimizer as in OptimizerFactory. An output file prefix is optional. In two arrays, - * name-value mappings can be given as additional parameters to the optimizer. - * - * @see OptimizerFactory.getOptRunnable - * @param optType - * @param outputFilePrefix - * @param specParams - * @param specValues - */ - public void optimize(final int optType, String outputFilePrefix, Object[] specParams, Object[] specValues) { - if (allowSingleRunnable && (runnable != null) && (!runnable.isFinished())) { - System.err.println("Please wait for the current optimization to finish"); - } else { -// log("in MP optimize A\n"); - handler.setMatlabProblem(this); - handler.setFinished(false); - runnable = OptimizerFactory.getOptRunnable(optType, (AbstractOptimizationProblem)this, outputFilePrefix); -// runnable.getGOParams().setPostProcessParams(new PostProcessParams(0, 0.01, 5)); - log("in MP optimize B\n"); - log("Setting text listener, verbo " + verbosityLevel + "\n"); - runnable.setTextListener(this); - runnable.setVerbosityLevel(verbosityLevel); - if (verbosityLevel>0) { - runnable.setOutputTo(2); - } // both file + window - else { - runnable.setOutputTo(1); - } // only window - runnable.setOutputFullStatsToText(outputAllStatsField); + private BitSet toBinary(double[] ds) { + BitSet bs = new BitSet(ds.length); + for (int i = 0; i < ds.length; i++) { + bs.set(i, (ds[i] > 0.5)); + } + return bs; + } - if (seedPopulation!=null) { - runnable.getGOParams().getOptimizer().setPopulation(seedPopulation); - runnable.setDoRestart(true); - log("Setting seed population of size " + seedPopulation.size() + ", target size " + seedPopulation.getTargetSize() + "\n"); - log(BeanInspector.toString(seedPopulation.getStringRepresentation())+"\n"); - log("Restart of optimization targetted.\n"); - } + /** + * Start an optimization using the MatlabProblem. The optType references the standard + * optimizer as in OptimizerFactory. An output file prefix is optional. In two arrays, + * name-value mappings can be given as additional parameters to the optimizer. + * + * @param optType + * @param outputFilePrefix + * @param specParams + * @param specValues + * @see OptimizerFactory.getOptRunnable + */ + public void optimize(final int optType, String outputFilePrefix, Object[] specParams, Object[] specValues) { + if (allowSingleRunnable && (runnable != null) && (!runnable.isFinished())) { + System.err.println("Please wait for the current optimization to finish"); + } else { + handler.setMatlabProblem(this); + handler.setFinished(false); + runnable = OptimizerFactory.getOptRunnable(optType, (AbstractOptimizationProblem) this, outputFilePrefix); + log("in MP optimize B\n"); + log("Setting text listener, verbo " + verbosityLevel + "\n"); + runnable.setTextListener(this); + runnable.setVerbosityLevel(verbosityLevel); + if (verbosityLevel > 0) { + runnable.setOutputTo(2); + } // both file + window + else { + runnable.setOutputTo(1); + } // only window + runnable.setOutputFullStatsToText(outputAllStatsField); -// log("in MP optimize C\n"); - if ((specParams != null) && (specParams.length > 0)) { - if ((specValues == null) || (specValues.length != specParams.length)) { - System.err.println("mismatching value list for parameter arguments: " + specValues); - } else { - log("setting specific parameters...\n"); - InterfaceOptimizer opt = runnable.getGOParams().getOptimizer(); -// log(BeanInspector.toString(BeanInspector.getMemberDescriptions(opt, true))); - for (int i=0; i>>>>>>>>> Stop event!\n"); - if (runnable != null) { - runnable.stopOpt(); - } - PostProcess.stopAllPP(); - } - - public String getInfoString() { - if (runnable == null) { - return ""; + if ((specParams != null) && (specParams.length > 0)) { + if ((specValues == null) || (specValues.length != specParams.length)) { + System.err.println("mismatching value list for parameter arguments: " + specValues); + } else { + log("setting specific parameters...\n"); + InterfaceOptimizer opt = runnable.getGOParams().getOptimizer(); + for (int i = 0; i < specParams.length; i++) { // loop over settings + log("try setting " + specParams[i] + " to " + specValues[i]); + String paramName = null; + try { + paramName = (String) specParams[i]; + } catch (ClassCastException e) { + paramName = "" + specParams[i]; + if (!(specParams[i] instanceof Character)) { + System.err.println("Error, parameter " + specParams[i] + " could not be cast to String, trying " + paramName); + } + } + Object specVal = null; // avoid giving chars to the converter method here - the ascii value would be assigned instead of the string + if (specValues[i] instanceof Character) { + specVal = "" + specValues[i]; + } else { + specVal = specValues[i]; + } + if ((paramName == null) || (!BeanInspector.setMem(opt, paramName, specVal))) { + log("... Fail!\n"); + System.err.println("Unable to set parameter " + paramName + ", skipping..."); + } else { + log("... Ok.\n"); + } + } + log(BeanInspector.toString(BeanInspector.getMemberDescriptions(opt, true))); + } } - StringBuffer sb = new StringBuffer(""); - sb.append(runnable.terminatedBecause()); - return sb.toString(); - } + new Thread(new WaitForEvARunnable(runnable, this)).start(); + } + } - public int getFunctionCalls() { - if (runnable == null) { - return 0; + public void setOutputAllStatFields(boolean showAll) { + outputAllStatsField = showAll; + } + + public void startPostProcess(InterfacePostProcessParams ppp) { + if (ppp.isDoPostProcessing()) { + if (allowSingleRunnable && (runnable != null) && (!runnable.isFinished())) { + System.err.println("Please wait for the current optimization to finish"); + } else { + handler.setFinished(false); + log("\nstarting post process thread... " + BeanInspector.toString(ppp)); + runnable.setDoRestart(true); + runnable.setDoPostProcessOnly(true); + runnable.setPostProcessingParams(ppp); + new Thread(new WaitForEvARunnable(runnable, this)).start(); } - return runnable.getGOParams().getOptimizer().getPopulation().getFunctionCalls(); - } + } else { + System.err.println("Nothing to be done."); + } + } -// Matlab getMatlab() { -// return matlab; -// } + /** + * Request post processing of the last optimization results with given parameters + * and export the result solution set to matlab. + * + * @param steps post processing steps with hill climber + * @param sigma sigma parameter for clustering + * @param nBest maximum number of solutions to retrieve + */ + public void requestPostProcessing(int steps, double sigma, int nBest) { + PostProcessParams ppp = new PostProcessParams(steps, sigma, nBest); + startPostProcess(ppp); + } - void exportResultPopulationToMatlab(Population pop) { - if ((pop != null) && (pop.size()>0)) { - switch(dataType) { - case typeDouble: - double[][] rsolSet = new double[pop.size()][]; - for (int i=0; i>>>>>>>>> Stop event!\n"); + if (runnable != null) { + runnable.stopOpt(); + } + PostProcess.stopAllPP(); + } - /** - * To be called by the executing thread to inform that the thread is finished. - * We - */ - void notifyFinished() { - handler.setFinished(true); - } + public String getInfoString() { + if (runnable == null) { + return ""; + } + StringBuffer sb = new StringBuffer(""); + sb.append(runnable.terminatedBecause()); + return sb.toString(); + } - public Object getIntermediateResult() { - if (runnable == null) { - System.err.println("Warning, runnable is null in MatlabProblem!"); - return null; - } else { - switch(dataType) { - case typeDouble: return runnable.getDoubleSolution(); - case typeBinary: return runnable.getBinarySolution(); - case typeInteger: return runnable.getIntegerSolution(); - default: System.err.println("Warning, incompatible data type in MatlabProblem!");return null; - } - } - } + public int getFunctionCalls() { + if (runnable == null) { + return 0; + } + return runnable.getGOParams().getOptimizer().getPopulation().getFunctionCalls(); + } - /** - * Return the number of function calls performed so far. - * @return - */ - public int getProgress() { - if (runnable == null) { - return 0; + void exportResultPopulationToMatlab(Population pop) { + if ((pop != null) && (pop.size() > 0)) { + switch (dataType) { + case typeDouble: + double[][] rsolSet = new double[pop.size()][]; + for (int i = 0; i < pop.size(); i++) { + rsolSet[i] = ((InterfaceDataTypeDouble) pop.getEAIndividual(i)).getDoubleData(); + } + handler.setSolutionSet(rsolSet); + break; + case typeBinary: + BitSet[] bsolSet = new BitSet[pop.size()]; + for (int i = 0; i < pop.size(); i++) { + bsolSet[i] = ((InterfaceDataTypeBinary) pop.getEAIndividual(i)).getBinaryData(); + } + handler.setSolutionSet(bsolSet); + break; + case typeInteger: + int[][] isolSet = new int[pop.size()][]; + for (int i = 0; i < pop.size(); i++) { + isolSet[i] = ((InterfaceDataTypeInteger) pop.getEAIndividual(i)).getIntegerData(); + } + handler.setSolutionSet(isolSet); + break; } - else { - return runnable.getProgress(); + } else { + switch (dataType) { + case typeDouble: + handler.setSolutionSet((double[][]) null); + break; + case typeBinary: + handler.setSolutionSet((BitSet[]) null); + break; + case typeInteger: + handler.setSolutionSet((int[][]) null); + break; } - } + } + } - public static String globalInfo() { - return "Interface problem class for optimization in Matlab, only usable from within Matlab"; - } + public void exportResultToMatlab(OptimizerRunnable runnable) { + handler.setSolution(getIntermediateResult()); + } + + /** + * To be called by the executing thread to inform that the thread is finished. + * We + */ + void notifyFinished() { + handler.setFinished(true); + } + + public Object getIntermediateResult() { + if (runnable == null) { + System.err.println("Warning, runnable is null in MatlabProblem!"); + return null; + } else { + switch (dataType) { + case typeDouble: + return runnable.getDoubleSolution(); + case typeBinary: + return runnable.getBinarySolution(); + case typeInteger: + return runnable.getIntegerSolution(); + default: + System.err.println("Warning, incompatible data type in MatlabProblem!"); + return null; + } + } + } + + /** + * Return the number of function calls performed so far. + * + * @return + */ + public int getProgress() { + if (runnable == null) { + return 0; + } else { + return runnable.getProgress(); + } + } + + public static String globalInfo() { + return "Interface problem class for optimization in Matlab, only usable from within Matlab"; + } @Override - public void print(String str) { -// System.err.println("MP print: " + str); -// if (resOutStream==null) { -// try { -// resOutStream = new PrintStream(new FileOutputStream(resOutFile)); -// } catch (FileNotFoundException e) { -// e.printStackTrace(); -// } -// } - if (verbosityLevel > 0) { - // matlab displays sysout output in the command window, so we simply use this channel - System.out.print(str); -// if (resOutStream != null) resOutStream.print(str); - } - log(str); - } + public void print(String str) { + if (verbosityLevel > 0) { + // matlab displays sysout output in the command window, so we simply use this channel + System.out.print(str); + } + log(str); + } @Override - public void println(String str) { - print(str); - print("\n"); - } - // -// public double[] eval(double[] x) { -// log("evaluating " + BeanInspector.toString(x) + "\n"); -// double[] res = handler.requestEval(this, x); -// return res; -// } - - @Override - public void evaluate(AbstractEAIndividual indy) { - log("evaluating " + AbstractEAIndividual.getDefaultStringRepresentation(indy) + "\n"); - double[] res = handler.requestEval(this, AbstractEAIndividual.getIndyData(indy)); - log("evaluated to " + BeanInspector.toString(res) + "\n"); - log("Free mem is " + Runtime.getRuntime().freeMemory() + ", time is " + System.currentTimeMillis() + "\n"); - indy.setFitness(res); - } - - @Override - public void initPopulation(Population population) { - initTemplate(); - AbstractOptimizationProblem.defaultInitPopulation(population, m_Template, this); - } + public void println(String str) { + print(str); + print("\n"); + } + // @Override - public String getStringRepresentationForProblem(InterfaceOptimizer opt) { + public void evaluate(AbstractEAIndividual indy) { + log("evaluating " + AbstractEAIndividual.getDefaultStringRepresentation(indy) + "\n"); + double[] res = handler.requestEval(this, AbstractEAIndividual.getIndyData(indy)); + log("evaluated to " + BeanInspector.toString(res) + "\n"); + log("Free mem is " + Runtime.getRuntime().freeMemory() + ", time is " + System.currentTimeMillis() + "\n"); + indy.setFitness(res); + } + + @Override + public void initializePopulation(Population population) { + initTemplate(); + AbstractOptimizationProblem.defaultInitPopulation(population, template, this); + } + + @Override + public String getStringRepresentationForProblem(InterfaceOptimizer opt) { StringBuffer sb = new StringBuffer(200); sb.append("A general Matlab problem"); sb.append(this.getName()); //sb.append("\n"); return sb.toString(); - } + } @Override - public Object getInitRange() { - log("retrieving initial range..., first entry: " + ((initialRange==null) ? "null" : BeanInspector.toString(initialRange[0]))); - return initialRange; - } - - @Override - public String getName() { - return "MatlabProblem"; - } + public Object getInitRange() { + log("retrieving initial range..., first entry: " + ((initialRange == null) ? "null" : BeanInspector.toString(initialRange[0]))); + return initialRange; + } -// @Override -// public String[] getAdditionalDataHeader() { -// return ToolBox.appendArrays(super.getAdditionalDataHeader(), "matlabSol"); -// } -// @Override -// public String[] getAdditionalDataInfo() { -// return ToolBox.appendArrays(super.getAdditionalDataInfo(), "Additional solution representation"); -// } -// @Override -// public Object[] getAdditionalDataValue(PopulationInterface pop) { -//// String addStr=((AbstractEAIndividual)pop.getBestIndividual()).getStringRepresentation(); -// String addStr=BeanInspector.toString(pop.getBestIndividual()); -// return ToolBox.appendArrays(super.getAdditionalDataValue(pop), addStr); -// } + @Override + public String getName() { + return "MatlabProblem"; + } } diff --git a/src/eva2/optimization/problems/PSymbolicRegression.java b/src/eva2/optimization/problems/PSymbolicRegression.java index 7e230ecf..9a376dab 100644 --- a/src/eva2/optimization/problems/PSymbolicRegression.java +++ b/src/eva2/optimization/problems/PSymbolicRegression.java @@ -60,15 +60,15 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements private boolean m_Show = false; public PSymbolicRegression() { - this.m_Template = new GPIndividualProgramData(); - this.initProblem(); + this.template = new GPIndividualProgramData(); + this.initializeProblem(); this.compileArea(); } public PSymbolicRegression(PSymbolicRegression b) { //AbstractOptimizationProblem - if (b.m_Template != null) { - this.m_Template = (AbstractEAIndividual)((AbstractEAIndividual)b.m_Template).clone(); + if (b.template != null) { + this.template = (AbstractEAIndividual)((AbstractEAIndividual)b.template).clone(); } //F1Problem if (b.m_OverallBest != null) { @@ -113,7 +113,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements /** This method inits the Problem to log multiruns */ @Override - public void initProblem() { + public void initializeProblem() { if (m_TargetFunction == null) { m_TargetFunction = new RFKoza_GPI_7_3(); } @@ -164,7 +164,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements * @param population The populations that is to be inited */ @Override - public void initPopulation(Population population) { + public void initializePopulation(Population population) { initPopulation(population, this, m_UseInnerConst, m_NumberOfConstants); } @@ -438,7 +438,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements */ public void setNumberOfConstants(int b) { this.m_NumberOfConstants = b; - this.initProblem(); + this.initializeProblem(); m_GPArea.clear(); this.compileArea(); } @@ -472,13 +472,13 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements this.m_GPArea = i; GPArea tmpArea[] = new GPArea[1]; tmpArea[0] = this.m_GPArea; - ((InterfaceDataTypeProgram)this.m_Template).setProgramDataLength(1); - ((InterfaceDataTypeProgram)this.m_Template).SetFunctionArea(tmpArea); + ((InterfaceDataTypeProgram)this.template).setProgramDataLength(1); + ((InterfaceDataTypeProgram)this.template).SetFunctionArea(tmpArea); } @Override public GPArea getArea() { if (m_GPArea==null) { - initProblem(); + initializeProblem(); } return this.m_GPArea; } @@ -514,7 +514,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements } public InterfaceRegressionFunction getTargetFunction() { if (m_TargetFunction==null) { - initProblem(); + initializeProblem(); } return this.m_TargetFunction; } @@ -526,10 +526,10 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements * @param indy The EAIndividual type */ public void setGPIndividual(InterfaceDataTypeProgram indy) { - this.m_Template = (AbstractEAIndividual) indy; + this.template = (AbstractEAIndividual) indy; } public InterfaceDataTypeProgram getGPIndividual() { - return (InterfaceDataTypeProgram)this.m_Template; + return (InterfaceDataTypeProgram)this.template; } public String GPIndividualTipText() { return "Modify the properties of the template GP individual such as maximum tree depth etc."; diff --git a/src/eva2/optimization/problems/SimpleProblemWrapper.java b/src/eva2/optimization/problems/SimpleProblemWrapper.java index f83c0d18..05b14fc2 100644 --- a/src/eva2/optimization/problems/SimpleProblemWrapper.java +++ b/src/eva2/optimization/problems/SimpleProblemWrapper.java @@ -104,32 +104,32 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem { } @Override - public void initPopulation(Population population) { + public void initializePopulation(Population population) { initTemplate(); - AbstractOptimizationProblem.defaultInitPopulation(population, m_Template, this); + AbstractOptimizationProblem.defaultInitPopulation(population, template, this); } @Override - public void initProblem() { + public void initializeProblem() { bestIndy = null; initTemplate(); setSimpleProblem(getSimpleProblem()); // possibly create plot - BeanInspector.callIfAvailable(simProb, "initProblem", null); // possibly call initProblem of subproblem + BeanInspector.callIfAvailable(simProb, "initializeProblem", null); // possibly call initializeProblem of subproblem } protected void initTemplate() { if (resetTemplate) { if (simProb instanceof SimpleProblemDouble) { - this.m_Template = new ESIndividualDoubleData(); + this.template = new ESIndividualDoubleData(); } else if (simProb instanceof SimpleProblemBinary) { - this.m_Template = new GAIndividualBinaryData(); + this.template = new GAIndividualBinaryData(); } } - if (m_Template instanceof InterfaceDataTypeDouble) { - ((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(simProb.getProblemDimension()); - ((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(makeRange()); - } else if (m_Template instanceof InterfaceDataTypeBinary) { - ((InterfaceDataTypeBinary)this.m_Template).setBinaryDataLength(simProb.getProblemDimension()); + if (template instanceof InterfaceDataTypeDouble) { + ((InterfaceDataTypeDouble)this.template).setDoubleDataLength(simProb.getProblemDimension()); + ((InterfaceDataTypeDouble)this.template).SetDoubleRange(makeRange()); + } else if (template instanceof InterfaceDataTypeBinary) { + ((InterfaceDataTypeBinary)this.template).setBinaryDataLength(simProb.getProblemDimension()); } else { System.err.println("Individual type not valid!"); } @@ -245,7 +245,7 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem { public void setIndividualTemplate(AbstractEAIndividual indy) { resetTemplate = false; - m_Template = indy; + template = indy; } @Override diff --git a/src/eva2/optimization/problems/TF1Problem.java b/src/eva2/optimization/problems/TF1Problem.java index 1e9e55ea..77168d8f 100644 --- a/src/eva2/optimization/problems/TF1Problem.java +++ b/src/eva2/optimization/problems/TF1Problem.java @@ -41,8 +41,8 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem public TF1Problem(TF1Problem b) { //AbstractOptimizationProblem - if (b.m_Template != null) { - this.m_Template = (AbstractEAIndividual)((AbstractEAIndividual)b.m_Template).clone(); + if (b.template != null) { + this.template = (AbstractEAIndividual)((AbstractEAIndividual)b.template).clone(); } //AbstractMultiObjectiveOptimizationProblem if (b.m_MOSOConverter != null) { @@ -88,15 +88,15 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem * @param population The populations that is to be inited */ @Override - public void initPopulation(Population population) { + public void initializePopulation(Population population) { this.m_ParetoFront = new Population(); double[][] newRange = makeRange(); - ((InterfaceDataTypeDouble)this.m_Template).setDoubleDataLength(this.m_ProblemDimension); - ((InterfaceDataTypeDouble)this.m_Template).SetDoubleRange(newRange); + ((InterfaceDataTypeDouble)this.template).setDoubleDataLength(this.m_ProblemDimension); + ((InterfaceDataTypeDouble)this.template).SetDoubleRange(newRange); - AbstractOptimizationProblem.defaultInitPopulation(population, m_Template, this); + AbstractOptimizationProblem.defaultInitPopulation(population, template, this); } protected double[][] makeRange() { @@ -210,7 +210,7 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem result += "Dimension : " + this.m_ProblemDimension +"\n"; result += "Noise level : " + this.m_Noise + "\n"; result += "Solution representation:\n"; - //result += this.m_Template.getSolutionRepresentationFor(); + //result += this.template.getSolutionRepresentationFor(); return result; } @@ -342,10 +342,10 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem * @param indy The EAIndividual type */ public void setEAIndividual(InterfaceDataTypeDouble indy) { - this.m_Template = (AbstractEAIndividual) indy; + this.template = (AbstractEAIndividual) indy; } public InterfaceDataTypeDouble getEAIndividual() { - return (InterfaceDataTypeDouble)this.m_Template; + return (InterfaceDataTypeDouble)this.template; } /** This method allows you to set a Multiobjective to diff --git a/src/eva2/optimization/strategies/ANPSO.java b/src/eva2/optimization/strategies/ANPSO.java index 10a6a18b..87998e20 100644 --- a/src/eva2/optimization/strategies/ANPSO.java +++ b/src/eva2/optimization/strategies/ANPSO.java @@ -93,7 +93,7 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi */ public ANPSO() { // NichePSO.stdNPSO(anpso, problem, randSeed, evalCnt); -// NichePSO.stdNPSO((ANPSO)this, (AbstractOptimizationProblem)this.m_Problem, 0, 1000); +// NichePSO.stdNPSO((ANPSO)this, (AbstractOptimizationProblem)this.problem, 0, 1000); /////////// from NichePSO // super.initMainSwarm(); // not really necessary if init is called before optimization but this way init doesnt change the parameters of a newly constructed object @@ -302,7 +302,7 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi //// for (int i=0; i this.m_DifferenceThreshold) { + partners = this.recombSelectionOperator.findPartnerFor(tmpIndy, this.population, this.numberOfPartners); + if (this.computeHammingDistance(tmpIndy, partners) > this.differenceThreshold) { offSprings = tmpIndy.mateWith(partners); for (int j = 0; j < offSprings.length; j++) { offSprings[j].mutate(); @@ -182,17 +182,17 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S * mutation rate. */ private void diverge() { - AbstractEAIndividual best = this.m_Population.getBestEAIndividual(); + AbstractEAIndividual best = this.population.getBestEAIndividual(); InterfaceGAIndividual mutant; BitSet tmpBitSet; - this.m_Population.clear(); - this.m_Population.add(best); - for (int i = 1; i < this.m_Population.getTargetSize(); i++) { + this.population.clear(); + this.population.add(best); + for (int i = 1; i < this.population.getTargetSize(); i++) { mutant = (InterfaceGAIndividual) best.clone(); tmpBitSet = mutant.getBGenotype(); for (int j = 0; j < mutant.getGenotypeLength(); j++) { - if (RNG.flipCoin(this.m_DivergenceRate)) { + if (RNG.flipCoin(this.divergenceRate)) { if (tmpBitSet.get(j)) { tmpBitSet.clear(j); } else { @@ -201,13 +201,13 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S } } mutant.SetBGenotype(tmpBitSet); - this.m_Population.add(mutant); + this.population.add(mutant); } if (best instanceof InterfaceGAIndividual) { - this.m_DifferenceThreshold = (int) (this.m_DivergenceRate * (1 - this.m_DivergenceRate) * ((InterfaceGAIndividual) best).getGenotypeLength()); + this.differenceThreshold = (int) (this.divergenceRate * (1 - this.divergenceRate) * ((InterfaceGAIndividual) best).getGenotypeLength()); } - this.evaluatePopulation(this.m_Population); + this.evaluatePopulation(this.population); } @Override @@ -215,39 +215,39 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S Population nextGeneration, tmp; //AbstractEAIndividual elite; - if (this.m_DifferenceThreshold < 0) { + if (this.differenceThreshold < 0) { this.diverge(); } else { nextGeneration = this.generateChildren(); if (nextGeneration.size() == 0) { - this.m_DifferenceThreshold--; + this.differenceThreshold--; } else { this.evaluatePopulation(nextGeneration); - if (nextGeneration.getWorstEAIndividual().getFitness(0) > this.m_Population.getBestEAIndividual().getFitness(0)) { - this.m_DifferenceThreshold--; + if (nextGeneration.getWorstEAIndividual().getFitness(0) > this.population.getBestEAIndividual().getFitness(0)) { + this.differenceThreshold--; } } - nextGeneration.addPopulation(this.m_Population); + nextGeneration.addPopulation(this.population); // this.m_NormationOperator.computeSelectionProbability(nextGeneration, "Fitness"); - this.m_PopulSelectionOperator.prepareSelection(this.m_Population); - tmp = this.m_PopulSelectionOperator.selectFrom(nextGeneration, this.m_Population.getTargetSize()); + this.populationSelectionOperator.prepareSelection(this.population); + tmp = this.populationSelectionOperator.selectFrom(nextGeneration, this.population.getTargetSize()); nextGeneration.clear(); nextGeneration.addPopulation(tmp); - this.m_Population = nextGeneration; + this.population = nextGeneration; } this.firePropertyChangedEvent(Population.nextGenerationPerformed); } @Override public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) { - this.m_Listener = ea; + this.interfacePopulationChangedEventListener = ea; } @Override public boolean removePopulationChangedEventListener( InterfacePopulationChangedEventListener ea) { - if (m_Listener == ea) { - m_Listener = null; + if (interfacePopulationChangedEventListener == ea) { + interfacePopulationChangedEventListener = null; return true; } else { return false; @@ -258,8 +258,8 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S * Something has changed */ protected void firePropertyChangedEvent(String name) { - if (this.m_Listener != null) { - this.m_Listener.registerPopulationStateChanged(this, name); + if (this.interfacePopulationChangedEventListener != null) { + this.interfacePopulationChangedEventListener.registerPopulationStateChanged(this, name); } } @@ -270,12 +270,12 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S */ @Override public void setProblem(InterfaceOptimizationProblem problem) { - this.m_Problem = problem; + this.optimizationProblem = problem; } @Override public InterfaceOptimizationProblem getProblem() { - return this.m_Problem; + return this.optimizationProblem; } /** @@ -289,8 +289,8 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S String result = ""; result += "CHC Adaptive Search Algorithm:\n"; result += "Optimization Problem: "; - result += this.m_Problem.getStringRepresentationForProblem(this) + "\n"; - result += this.m_Population.getStringRepresentation(); + result += this.optimizationProblem.getStringRepresentationForProblem(this) + "\n"; + result += this.population.getStringRepresentation(); return result; } @@ -301,12 +301,12 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S */ @Override public void setIdentifier(String name) { - this.m_Identifier = name; + this.identifier = name; } @Override public String getIdentifier() { - return this.m_Identifier; + return this.identifier; } /** @@ -341,12 +341,12 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S */ @Override public Population getPopulation() { - return this.m_Population; + return this.population; } @Override public void setPopulation(Population pop) { - this.m_Population = pop; + this.population = pop; } public String populationTipText() { @@ -376,11 +376,11 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S * @param elitism */ public void setElitism(boolean elitism) { - this.m_UseElitism = elitism; + this.useElitism = elitism; } public boolean getElitism() { - return this.m_UseElitism; + return this.useElitism; } public String elitismTipText() { @@ -396,11 +396,11 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S if (partners < 0) { partners = 0; } - this.m_NumberOfPartners = partners; + this.numberOfPartners = partners; } public int getNumberOfPartners() { - return this.m_NumberOfPartners; + return this.numberOfPartners; } public String numberOfPartnersTipText() { diff --git a/src/eva2/optimization/strategies/ClusterBasedNichingEA.java b/src/eva2/optimization/strategies/ClusterBasedNichingEA.java index 19df476a..37551843 100644 --- a/src/eva2/optimization/strategies/ClusterBasedNichingEA.java +++ b/src/eva2/optimization/strategies/ClusterBasedNichingEA.java @@ -62,50 +62,42 @@ import java.util.PriorityQueue; public class ClusterBasedNichingEA implements InterfacePopulationChangedEventListener, InterfaceAdditionalPopulationInformer, InterfaceOptimizer, java.io.Serializable { private static final long serialVersionUID = -3143069327594708609L; - private Population m_Population = new Population(); - private transient Population m_Archive = new Population(); - private ArrayList m_Species = new ArrayList(); - private Population m_Undifferentiated = new Population(); - private transient Population m_doomedPop = new Population(); - private InterfaceOptimizationProblem m_Problem = new B1Problem(); - private InterfaceOptimizer m_Optimizer = new GeneticAlgorithm(); - private InterfaceClustering m_CAForSpeciesDifferentation = new ClusteringDensityBased(); - private InterfaceClustering m_CAForSpeciesMerging = new ClusteringDensityBased(); + private Population population = new Population(); + private transient Population poulationArchive = new Population(); + private ArrayList species = new ArrayList(); + private Population undifferentiatedPopulation = new Population(); + private transient Population doomedPopulation = new Population(); + private InterfaceOptimizationProblem optimizationProblem = new B1Problem(); + private InterfaceOptimizer optimizer = new GeneticAlgorithm(); + private InterfaceClustering caForSpeciesDifferentation = new ClusteringDensityBased(); + private InterfaceClustering caForSpeciesMerging = new ClusteringDensityBased(); private double clusterDiffDist = 0.05; -// private double clusterMergeDist = 0.0001; -// private Distraction distraction = null; private boolean useDistraction = false; -// private double distrDefaultStrength = .7; private double epsilonBound = 1e-10; - transient private String m_Identifier = ""; - transient private InterfacePopulationChangedEventListener m_Listener; - private int m_SpeciesCycle = 1; - // from which size on is a species considered active -// private int m_actSpecSize = 2; - private int m_minGroupSize = 3; -// private boolean m_UseClearing = false; -// private boolean m_UseArchive = true; - private boolean m_UseSpeciesDifferentiation = true; - private boolean m_mergeSpecies = true; - private int m_PopulationSize = 50; + transient private String identifier = ""; + transient private InterfacePopulationChangedEventListener populationChangedEventListener; + private int speciesCycle = 1; + + private int minGroupSize = 3; + private boolean useSpeciesDifferentiation = true; + private boolean mergeSpecies = true; + private int populationSize = 50; private int convergedCnt = 0; private int collisions = 0; private static boolean TRACE = false, TRACE_STATE = false, TRACE_EVTS = false; - private int m_ShowCycle = 0; - transient private TopoPlot m_Topology; + private int showCycle = 0; + transient private TopoPlot topologyPlot; private int haltingWindow = 15; private double muLambdaRatio = 0.5; private int sleepTime = 0; - private int m_maxSpeciesSize = 15; + private int maxSpeciesSize = 15; private AbstractEAIndividualComparator reduceSizeComparator = new AbstractEAIndividualComparator(); private AbstractEAIndividualComparator histComparator = new AbstractEAIndividualComparator("", -1, true); protected ParameterControlManager paramControl = new ParameterControlManager(); private double avgDistForConvergence = 0.1; // Upper bound for average indy distance in a species in the test for convergence public ClusterBasedNichingEA() { - this.m_CAForSpeciesMerging = new ClusteringDensityBased(); -// ((ClusteringDensityBased)this.m_CAForSpeciesMerging).setMinimumGroupSize(m_minGroupSize); -// if (useDistraction) distraction = new Distraction(distrDefaultStrength, Distraction.METH_BEST); + this.caForSpeciesMerging = new ClusteringDensityBased(); } /** @@ -146,30 +138,30 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis public ClusterBasedNichingEA(ClusterBasedNichingEA a) { this.epsilonBound = a.epsilonBound; - this.m_Population = (Population) a.m_Population.clone(); - this.m_Archive = (Population) a.m_Archive.clone(); - this.m_doomedPop = (Population) a.m_doomedPop.clone(); - this.m_Problem = (InterfaceOptimizationProblem) a.m_Problem.clone(); - this.m_Optimizer = (InterfaceOptimizer) a.m_Optimizer.clone(); - this.m_Species = (ArrayList) (a.m_Species.clone()); - this.m_Undifferentiated = (Population) a.m_Undifferentiated.clone(); - this.m_CAForSpeciesMerging = (InterfaceClustering) this.m_CAForSpeciesMerging.clone(); - this.m_CAForSpeciesDifferentation = (InterfaceClustering) this.m_CAForSpeciesDifferentation.clone(); - this.m_SpeciesCycle = a.m_SpeciesCycle; - this.m_minGroupSize = a.m_minGroupSize; - this.m_UseSpeciesDifferentiation = a.m_UseSpeciesDifferentiation; - this.m_mergeSpecies = a.m_mergeSpecies; - this.m_PopulationSize = a.m_PopulationSize; + this.population = (Population) a.population.clone(); + this.poulationArchive = (Population) a.poulationArchive.clone(); + this.doomedPopulation = (Population) a.doomedPopulation.clone(); + this.optimizationProblem = (InterfaceOptimizationProblem) a.optimizationProblem.clone(); + this.optimizer = (InterfaceOptimizer) a.optimizer.clone(); + this.species = (ArrayList) (a.species.clone()); + this.undifferentiatedPopulation = (Population) a.undifferentiatedPopulation.clone(); + this.caForSpeciesMerging = (InterfaceClustering) this.caForSpeciesMerging.clone(); + this.caForSpeciesDifferentation = (InterfaceClustering) this.caForSpeciesDifferentation.clone(); + this.speciesCycle = a.speciesCycle; + this.minGroupSize = a.minGroupSize; + this.useSpeciesDifferentiation = a.useSpeciesDifferentiation; + this.mergeSpecies = a.mergeSpecies; + this.populationSize = a.populationSize; this.haltingWindow = a.haltingWindow; - this.m_maxSpeciesSize = a.m_maxSpeciesSize; + this.maxSpeciesSize = a.maxSpeciesSize; this.muLambdaRatio = a.muLambdaRatio; this.sleepTime = a.sleepTime; this.convergedCnt = a.convergedCnt; this.collisions = a.collisions; this.clusterDiffDist = a.clusterDiffDist; this.useDistraction = a.useDistraction; - this.m_ShowCycle = a.m_ShowCycle; - this.m_maxSpeciesSize = a.m_maxSpeciesSize; + this.showCycle = a.showCycle; + this.maxSpeciesSize = a.maxSpeciesSize; } @Override @@ -179,26 +171,26 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis @Override public void init() { - if (m_Undifferentiated == null) { - this.m_Undifferentiated = new Population(m_PopulationSize); + if (undifferentiatedPopulation == null) { + this.undifferentiatedPopulation = new Population(populationSize); } else { - m_Undifferentiated.resetProperties(); - m_Undifferentiated.setTargetSize(m_PopulationSize); + undifferentiatedPopulation.resetProperties(); + undifferentiatedPopulation.setTargetSize(populationSize); } - this.m_Undifferentiated.setUseHistory(true); + this.undifferentiatedPopulation.setUseHistory(true); - this.m_Problem.initPopulation(this.m_Undifferentiated); - this.m_Optimizer.initByPopulation(m_Undifferentiated, true); - m_Undifferentiated = this.m_Optimizer.getPopulation(); // some optimizers clone the given one. - if (m_Optimizer instanceof EvolutionStrategies) { - EvolutionStrategies es = (EvolutionStrategies) m_Optimizer; + this.optimizationProblem.initializePopulation(this.undifferentiatedPopulation); + this.optimizer.initByPopulation(undifferentiatedPopulation, true); + undifferentiatedPopulation = this.optimizer.getPopulation(); // some optimizers clone the given one. + if (optimizer instanceof EvolutionStrategies) { + EvolutionStrategies es = (EvolutionStrategies) optimizer; es.setLambda(getPopulationSize()); es.setMu((int) (muLambdaRatio * (double) getPopulationSize())); } -// this.m_Optimizer.init(); - m_doomedPop = m_Undifferentiated.cloneWithoutInds(); - if (m_Undifferentiated.getFunctionCalls() != m_PopulationSize) { +// this.optimizer.init(); + doomedPopulation = undifferentiatedPopulation.cloneWithoutInds(); + if (undifferentiatedPopulation.getFunctionCalls() != populationSize) { System.err.println("Whats that in CBN!?"); } initDefaults(false); @@ -216,19 +208,19 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @param evalPop */ private void initDefaults(boolean evalPop) { - this.m_Optimizer.addPopulationChangedEventListener(this); - this.m_Undifferentiated.setTargetSize(this.m_PopulationSize); - this.m_Species = new ArrayList(); - this.m_Archive = m_Undifferentiated.cloneWithoutInds(); + this.optimizer.addPopulationChangedEventListener(this); + this.undifferentiatedPopulation.setTargetSize(this.populationSize); + this.species = new ArrayList(); + this.poulationArchive = undifferentiatedPopulation.cloneWithoutInds(); // if (useDistraction) distraction = new Distraction(distrDefaultStrength, Distraction.METH_BEST); convergedCnt = 0; collisions = 0; if (evalPop) { - this.evaluatePopulation(this.m_Undifferentiated); + this.evaluatePopulation(this.undifferentiatedPopulation); } - this.m_Optimizer.initByPopulation(m_Undifferentiated, false); - this.m_Undifferentiated = m_Optimizer.getPopulation(); // required for changes to the population by the optimizer - m_Population = m_Undifferentiated; + this.optimizer.initByPopulation(undifferentiatedPopulation, false); + this.undifferentiatedPopulation = optimizer.getPopulation(); // required for changes to the population by the optimizer + population = undifferentiatedPopulation; this.firePropertyChangedEvent("FirstGenerationPerformed"); } @@ -240,9 +232,9 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis */ @Override public void initByPopulation(Population pop, boolean reset) { - this.m_Undifferentiated = (Population) pop.clone(); + this.undifferentiatedPopulation = (Population) pop.clone(); if (reset) { - this.m_Undifferentiated.init(); + this.undifferentiatedPopulation.init(); } initDefaults(reset); } @@ -253,18 +245,18 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @param population The population that is to be evaluated */ private void evaluatePopulation(Population population) { - this.m_Problem.evaluate(population); + this.optimizationProblem.evaluate(population); population.incrGeneration(); } private void plot(int gen) { - if (!(this.m_Problem instanceof TF1Problem) && !(this.m_Problem instanceof Interface2DBorderProblem)) { + if (!(this.optimizationProblem instanceof TF1Problem) && !(this.optimizationProblem instanceof Interface2DBorderProblem)) { return; } double[] a = new double[2]; a[0] = 0.0; a[1] = 0.0; - if (this.m_Problem instanceof TF1Problem) { + if (this.optimizationProblem instanceof TF1Problem) { // now i need to plot the pareto fronts Plot plot = new Plot("TF3Problem at gen. " + gen, "y1", "y2", a, a); plot.setUnconnectedPoint(0, 0, 0); @@ -272,17 +264,17 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis GraphPointSet mySet = new GraphPointSet(10, plot.getFunctionArea()); DPoint point; mySet.setConnectedMode(false); - for (int i = 0; i < this.m_Undifferentiated.size(); i++) { - AbstractEAIndividual indy = (AbstractEAIndividual) this.m_Undifferentiated.get(i); + for (int i = 0; i < this.undifferentiatedPopulation.size(); i++) { + AbstractEAIndividual indy = (AbstractEAIndividual) this.undifferentiatedPopulation.get(i); double[] d = indy.getFitness(); point = new DPoint(d[0], d[1]); point.setIcon(new Chart2DDPointIconCircle()); mySet.addDPoint(point); } - for (int i = 0; i < this.m_Species.size(); i++) { + for (int i = 0; i < this.species.size(); i++) { mySet = new GraphPointSet(10 + i, plot.getFunctionArea()); mySet.setConnectedMode(false); - Population pop = (Population) this.m_Species.get(i); + Population pop = (Population) this.species.get(i); // ArchivingAllDomiating arch = new ArchivingAllDomiating(); // arch.plotParetoFront(pop, plot); for (int j = 0; j < pop.size(); j++) { @@ -296,28 +288,28 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis } } - if (this.m_Problem instanceof Interface2DBorderProblem) { + if (this.optimizationProblem instanceof Interface2DBorderProblem) { DPointSet popRep = new DPointSet(); InterfaceDataTypeDouble tmpIndy1; Population pop; - this.m_Topology = new TopoPlot("CBN-Species at gen. " + gen, "x", "y", a, a); - this.m_Topology.setParams(50, 50); - this.m_Topology.setTopology((Interface2DBorderProblem) this.m_Problem); + this.topologyPlot = new TopoPlot("CBN-Species at gen. " + gen, "x", "y", a, a); + this.topologyPlot.setParams(50, 50); + this.topologyPlot.setTopology((Interface2DBorderProblem) this.optimizationProblem); //draw the undifferentiated - for (int i = 0; i < this.m_Undifferentiated.size(); i++) { - tmpIndy1 = (InterfaceDataTypeDouble) this.m_Undifferentiated.get(i); + for (int i = 0; i < this.undifferentiatedPopulation.size(); i++) { + tmpIndy1 = (InterfaceDataTypeDouble) this.undifferentiatedPopulation.get(i); popRep.addDPoint(new DPoint(tmpIndy1.getDoubleData()[0], tmpIndy1.getDoubleData()[1])); } - this.m_Topology.getFunctionArea().addDElement(popRep); + this.topologyPlot.getFunctionArea().addDElement(popRep); //draw the species - for (int i = 0; i < this.m_Species.size(); i++) { - pop = (Population) this.m_Species.get(i); - plotPopConnected(m_Topology, pop); + for (int i = 0; i < this.species.size(); i++) { + pop = (Population) this.species.get(i); + plotPopConnected(topologyPlot, pop); } if (!useDistraction) { - for (int i = 0; i < this.m_Archive.size(); i++) { - plotIndy(m_Topology, 'x', (InterfaceDataTypeDouble) m_Archive.get(i)); + for (int i = 0; i < this.poulationArchive.size(); i++) { + plotIndy(topologyPlot, 'x', (InterfaceDataTypeDouble) poulationArchive.get(i)); } } else { // for (int i = 0; i < this.distraction.getDistractorSetSize(); i++) { @@ -384,13 +376,13 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @return A population of new individuals */ private Population initializeIndividuals(int n) { - Population result = m_Undifferentiated.cloneWithoutInds(); + Population result = undifferentiatedPopulation.cloneWithoutInds(); result.setUseHistory(true); result.setTargetSize(n); //@todo: crossover between species is to be implemented - m_Problem.initPopulation(result); - m_Problem.evaluate(result); - m_Optimizer.setPopulation(result); // for some initialization by the optimizer, such as PSO memory + optimizationProblem.initializePopulation(result); + optimizationProblem.evaluate(result); + optimizer.setPopulation(result); // for some initialization by the optimizer, such as PSO memory // capMutationRate(result, RNG.randomDouble(0.001, 0.1)); return result; } @@ -443,7 +435,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis // TODO something like this may be used as additional convergence criterion. // it influences the number of local optima archived and seems to increase the score, but not the best-found solutions, at least for a large clustering parameter // System.out.println("Terminated, subswarm measures: " + BeanInspector.toString(pop.getPopulationMeasures())); -// if (m_Optimizer instanceof ParticleSwarmOptimization) { +// if (optimizer instanceof ParticleSwarmOptimization) { // double swarmSp = ParticleSwarmOptimization.getPopulationVelSpeed(pop, 2, ParticleSwarmOptimization.partVelKey, null, null)[0]; // System.out.println("Swarm speed: " + swarmSp); // if (swarmSp > 0.05) { @@ -482,10 +474,10 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis } private Population optimizeSpecies(Population species, boolean minorPlot) { - m_Optimizer.setPopulation(species); -// m_Optimizer.initByPopulation(species, false); - if (m_Optimizer instanceof EvolutionStrategies) { - EvolutionStrategies es = (EvolutionStrategies) m_Optimizer; + optimizer.setPopulation(species); +// optimizer.initByPopulation(species, false); + if (optimizer instanceof EvolutionStrategies) { + EvolutionStrategies es = (EvolutionStrategies) optimizer; int mu = Math.max(1, (int) (muLambdaRatio * species.size())); if (mu >= species.size()) { if (TRACE) { @@ -501,16 +493,16 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis } if (TRACE) { System.out.println("Bef: spec size: " + species.size() + ", target size " + species.getTargetSize()); - System.out.println("Best bef: " + BeanInspector.toString(m_Optimizer.getPopulation().getBestFitness())); + System.out.println("Best bef: " + BeanInspector.toString(optimizer.getPopulation().getBestFitness())); } - if (BeanInspector.hasMethod(m_Optimizer, "getLastModelPopulation", null) != null) { - Object pc = BeanInspector.callIfAvailable(m_Optimizer, "getLastTrainingPatterns", null); + if (BeanInspector.hasMethod(optimizer, "getLastModelPopulation", null) != null) { + Object pc = BeanInspector.callIfAvailable(optimizer, "getLastTrainingPatterns", null); // System.out.println("MAPSO train set bef optSpec: " + BeanInspector.callIfAvailable(pc, "getStringRepresentation", null)); } - this.m_Optimizer.optimize(); - Population retPop = m_Optimizer.getPopulation(); + this.optimizer.optimize(); + Population retPop = optimizer.getPopulation(); if (TRACE) { System.out.println("Aft: spec size: " + retPop.size() + ", target size " + retPop.getTargetSize()); @@ -544,25 +536,25 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis public void optimize() { Population reinitPop = null; if (TRACE_STATE) { - printState("---- CBN Optimizing", m_doomedPop); - // System.out.println("-Funcalls: "+m_Undifferentiated.getFunctionCalls()); + printState("---- CBN Optimizing", doomedPopulation); + // System.out.println("-Funcalls: "+undifferentiatedPopulation.getFunctionCalls()); } - if (m_doomedPop.size() > 0) { - reinitPop = this.initializeIndividuals(m_doomedPop.size()); // do not add these to undifferentiated yet, that would mess up the evaluation count - m_doomedPop.clear(); + if (doomedPopulation.size() > 0) { + reinitPop = this.initializeIndividuals(doomedPopulation.size()); // do not add these to undifferentiated yet, that would mess up the evaluation count + doomedPopulation.clear(); // if (TRACE) -// System.out.println("At " + m_Undifferentiated.getFunctionCalls() + " reinited " + reinitPop.size() + " indies... "); +// System.out.println("At " + undifferentiatedPopulation.getFunctionCalls() + " reinited " + reinitPop.size() + " indies... "); } - int countIndies = (reinitPop != null ? reinitPop.size() : 0) + m_Undifferentiated.size(); - for (int i = 0; i < m_Species.size(); i++) { - countIndies += m_Species.get(i).size(); + int countIndies = (reinitPop != null ? reinitPop.size() : 0) + undifferentiatedPopulation.size(); + for (int i = 0; i < species.size(); i++) { + countIndies += species.get(i).size(); } if (TRACE) { System.out.println("NumIndies: " + countIndies); }; - if (this.m_ShowCycle > 0) { - if (m_Undifferentiated.getGeneration() <= 1) { - plot(m_Undifferentiated.getGeneration()); + if (this.showCycle > 0) { + if (undifferentiatedPopulation.getGeneration() <= 1) { + plot(undifferentiatedPopulation.getGeneration()); } } if (sleepTime > 0) { @@ -575,30 +567,30 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis // species evolution phase // optimize D_0 - this.m_Undifferentiated.synchSize(); - if (m_Undifferentiated.size() > 0) { -// this.capMutationRate(this.m_Undifferentiated, 0); // MK this sets mutation rate to 0! why? possibly to guarantee contraction of the species? - m_Undifferentiated.putData(InterfaceSpeciesAware.populationTagKey, InterfaceSpeciesAware.explorerPopTag); - m_Undifferentiated = optimizeSpecies(m_Undifferentiated, false); + this.undifferentiatedPopulation.synchSize(); + if (undifferentiatedPopulation.size() > 0) { +// this.capMutationRate(this.undifferentiatedPopulation, 0); // MK this sets mutation rate to 0! why? possibly to guarantee contraction of the species? + undifferentiatedPopulation.putData(InterfaceSpeciesAware.populationTagKey, InterfaceSpeciesAware.explorerPopTag); + undifferentiatedPopulation = optimizeSpecies(undifferentiatedPopulation, false); } else { - m_Undifferentiated.incrGeneration(); + undifferentiatedPopulation.incrGeneration(); } Population curSpecies; // optimize the clustered species - for (int i = this.m_Species.size() - 1; i >= 0; i--) { + for (int i = this.species.size() - 1; i >= 0; i--) { if (TRACE) { - System.out.println("-Deme " + i + " size: " + ((Population) this.m_Species.get(i)).size()); + System.out.println("-Deme " + i + " size: " + ((Population) this.species.get(i)).size()); } - curSpecies = ((Population) this.m_Species.get(i)); + curSpecies = ((Population) this.species.get(i)); curSpecies.SetFunctionCalls(0); curSpecies.synchSize(); // if (isActive(curSpecies)) { // Lets have only active species... if ((haltingWindow > 0) && (this.testSpeciesForConvergence(curSpecies))) { ///////////////////////////////////////////// Halting Window ///////////////////////////////////////////////// // if (this.m_Debug) { -// System.out.println("Undiff.Size: " + this.m_Undifferentiated.size() +"/"+this.m_Undifferentiated.getPopulationSize()); -// System.out.println("Diff.Size : " + ((Population)this.m_Species.get(i)).size() +"/"+((Population)this.m_Species.get(i)).getPopulationSize()); +// System.out.println("Undiff.Size: " + this.undifferentiatedPopulation.size() +"/"+this.undifferentiatedPopulation.getPopulationSize()); +// System.out.println("Diff.Size : " + ((Population)this.species.get(i)).size() +"/"+((Population)this.species.get(i)).getPopulationSize()); // } convergedCnt++; if (TRACE_EVTS) { @@ -625,9 +617,9 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis // } int toReinit = 0; if (true) { //if (m_UseArchive) { - m_Archive.add(best); -// System.out.println((""+ m_Population.getFunctionCalls() + " " + (BeanInspector.toString(best.getDoublePosition())).replaceAll(";|\\[|\\]", ""))); - m_Species.remove(i); // remove the converged Species + poulationArchive.add(best); +// System.out.println((""+ population.getFunctionCalls() + " " + (BeanInspector.toString(best.getDoublePosition())).replaceAll(";|\\[|\\]", ""))); + species.remove(i); // remove the converged Species toReinit = curSpecies.size(); } // else { @@ -636,12 +628,12 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis // deactivateSpecies(curSpecies, best, null); // } // those will not be optimized anymore, so we dont need to doom them, but can directly add them to undiff! - m_Undifferentiated.addPopulation(initializeIndividuals(toReinit)); - m_Undifferentiated.incrFunctionCallsBy(toReinit); + undifferentiatedPopulation.addPopulation(initializeIndividuals(toReinit)); + undifferentiatedPopulation.incrFunctionCallsBy(toReinit); // if (this.m_Debug) { -// System.out.println("Undiff.Size: " + this.m_Undifferentiated.size() +"/"+this.m_Undifferentiated.getPopulationSize()); -// System.out.println("Diff.Size : " + ((Population)this.m_Species.get(i)).size() +"/"+((Population)this.m_Species.get(i)).getPopulationSize()); +// System.out.println("Undiff.Size: " + this.undifferentiatedPopulation.size() +"/"+this.undifferentiatedPopulation.getPopulationSize()); +// System.out.println("Diff.Size : " + ((Population)this.species.get(i)).size() +"/"+((Population)this.species.get(i)).getPopulationSize()); // } // if (this.m_Debug) System.out.println("--------------------------End converged"); ////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -650,47 +642,47 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis // this.capMutationRate(curSpecies, 0.05); curSpecies.putData(InterfaceSpeciesAware.populationTagKey, InterfaceSpeciesAware.localPopTag); Population optimizedSpec = optimizeSpecies(curSpecies, true); - this.m_Species.set(i, optimizedSpec); - curSpecies = ((Population) this.m_Species.get(i)); // reset to expected population, just to be sure + this.species.set(i, optimizedSpec); + curSpecies = ((Population) this.species.get(i)); // reset to expected population, just to be sure } // } // This is necessary to keep track of the function calls needed - m_Undifferentiated.incrFunctionCallsBy(curSpecies.getFunctionCalls()); + undifferentiatedPopulation.incrFunctionCallsBy(curSpecies.getFunctionCalls()); if (TRACE) { - System.out.println("### funcalls: " + m_Undifferentiated.getFunctionCalls()); + System.out.println("### funcalls: " + undifferentiatedPopulation.getFunctionCalls()); } } ////////////////////// - synchronized (m_Population) { // fill the m_Population instance with the current individuals from undiff, spec, etc. - this.m_Population = (Population) this.m_Undifferentiated.clone(); - m_Population.setUseHistory(true); - for (int i = 0; i < this.m_Species.size(); i++) { - this.m_Population.addPopulation((Population) this.m_Species.get(i)); + synchronized (population) { // fill the population instance with the current individuals from undiff, spec, etc. + this.population = (Population) this.undifferentiatedPopulation.clone(); + population.setUseHistory(true); + for (int i = 0; i < this.species.size(); i++) { + this.population.addPopulation((Population) this.species.get(i)); } - if (m_doomedPop.size() > 0) { - m_Population.addPopulation(reinitPop); + if (doomedPopulation.size() > 0) { + population.addPopulation(reinitPop); } // this is just so that the numbers match up... - m_Population.synchSize(); + population.synchSize(); } ////////////////////// - if ((this.m_Undifferentiated.getFunctionCalls() + (reinitPop == null ? 0 : (reinitPop.size()))) % this.m_PopulationSize != 0) { + if ((this.undifferentiatedPopulation.getFunctionCalls() + (reinitPop == null ? 0 : (reinitPop.size()))) % this.populationSize != 0) { if (TRACE) { System.out.println("### mismatching number of funcalls, inactive species?"); - }// Correcting by " + (m_PopulationSize - (m_Undifferentiated.getFunctionCalls() % m_PopulationSize))); -// if (TRACE) System.out.println("### undiff " + ((isActive(m_Undifferentiated)) ? "active!" : "inactive!")); -// m_Undifferentiated.incrFunctionCallsBy(m_PopulationSize - (m_Undifferentiated.getFunctionCalls() % m_PopulationSize)); - } //else if (TRACE) System.out.println("### undiff active: " + isActive(m_Undifferentiated)); + }// Correcting by " + (populationSize - (undifferentiatedPopulation.getFunctionCalls() % populationSize))); +// if (TRACE) System.out.println("### undiff " + ((isActive(undifferentiatedPopulation)) ? "active!" : "inactive!")); +// undifferentiatedPopulation.incrFunctionCallsBy(populationSize - (undifferentiatedPopulation.getFunctionCalls() % populationSize)); + } //else if (TRACE) System.out.println("### undiff active: " + isActive(undifferentiatedPopulation)); // possible species differentiation and convergence - if (this.m_Undifferentiated.getGeneration() % this.m_SpeciesCycle == 0) { + if (this.undifferentiatedPopulation.getGeneration() % this.speciesCycle == 0) { if (TRACE) { System.out.println("Species cycle:"); } initClustering(); - if (this.m_UseSpeciesDifferentiation) { + if (this.useSpeciesDifferentiation) { ///////////////////////////// species differentiation phase if (TRACE) { printState("---Species Differentation", reinitPop); @@ -698,25 +690,25 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis Population[] clusters; ArrayList newSpecies = new ArrayList(); //cluster the undifferentiated population - clusters = this.m_CAForSpeciesDifferentation.cluster(this.m_Undifferentiated, m_Population); + clusters = this.caForSpeciesDifferentation.cluster(this.undifferentiatedPopulation, population); if (TRACE) { System.out.println("clustered undiff to " + clusters.length); } for (int j = 1; j < clusters.length; j++) { // loop new clusters - splitFromFirst(m_Undifferentiated, clusters[j], false); + splitFromFirst(undifferentiatedPopulation, clusters[j], false); newSpecies.add(clusters[j]); } replaceUndifferentiated(clusters[0]); - for (int i = 0; i < this.m_Species.size(); i++) { // loop old species - curSpecies = this.m_Species.get(i); -// if (curSpecies.size()>m_minGroupSize) { // only active populations are clustered + for (int i = 0; i < this.species.size(); i++) { // loop old species + curSpecies = this.species.get(i); +// if (curSpecies.size()>minGroupSize) { // only active populations are clustered // check if a species has differentiated any further - clusters = this.m_CAForSpeciesDifferentation.cluster(curSpecies, m_Population); + clusters = this.caForSpeciesDifferentation.cluster(curSpecies, population); if (TRACE) { System.out.println("clustered " + i + " to " + clusters.length); } if (clusters[0].size() > 0) { - mergeToFirst(m_Undifferentiated, clusters[0], false); + mergeToFirst(undifferentiatedPopulation, clusters[0], false); } for (int j = 1; j < clusters.length; j++) { // set up new species // this is treated as a split only if more than one cluster was found @@ -735,7 +727,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis // newSpecies.add(curSpecies); // } } - this.m_Species = newSpecies; + this.species = newSpecies; if (TRACE) { printState("---After differentiation", reinitPop); } @@ -744,31 +736,31 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis } // end of species differentiation // plot the populations - if (this.m_ShowCycle > 0) { - if ((this.m_Undifferentiated.getGeneration() <= 2) || (this.m_Undifferentiated.getGeneration() % this.m_ShowCycle == 0)) { - this.plot(this.m_Undifferentiated.getGeneration()); + if (this.showCycle > 0) { + if ((this.undifferentiatedPopulation.getGeneration() <= 2) || (this.undifferentiatedPopulation.getGeneration() % this.showCycle == 0)) { + this.plot(this.undifferentiatedPopulation.getGeneration()); } } - if (this.m_mergeSpecies && (m_Species.size() > 0)) { + if (this.mergeSpecies && (species.size() > 0)) { ///////////////////////////// species merging phase if (TRACE) { System.out.println("-Species merge:"); } // first test if loners belong to any species - int[] assocSpec = m_CAForSpeciesMerging.associateLoners(m_Undifferentiated, m_Species.toArray(new Population[m_Species.size()]), m_Population); - for (int i = m_Undifferentiated.size() - 1; i >= 0; i--) { // backwards or die! + int[] assocSpec = caForSpeciesMerging.associateLoners(undifferentiatedPopulation, species.toArray(new Population[species.size()]), population); + for (int i = undifferentiatedPopulation.size() - 1; i >= 0; i--) { // backwards or die! if (assocSpec[i] >= 0) { if (TRACE_EVTS) { System.out.println("!!! Loner merge to " + i); } // loner i should be merged to species assocSpec[i] - AbstractEAIndividual tmpIndy = (AbstractEAIndividual) this.m_Undifferentiated.get(i); - if (m_Topology != null) { - plotLine(m_Topology, tmpIndy, m_Species.get(assocSpec[i]).getBestEAIndividual()); + AbstractEAIndividual tmpIndy = (AbstractEAIndividual) this.undifferentiatedPopulation.get(i); + if (topologyPlot != null) { + plotLine(topologyPlot, tmpIndy, species.get(assocSpec[i]).getBestEAIndividual()); } - this.m_Undifferentiated.remove(i); - m_Species.get(assocSpec[i]).add(tmpIndy); // TODO merge information from loners? + this.undifferentiatedPopulation.remove(i); + species.get(assocSpec[i]).add(tmpIndy); // TODO merge information from loners? } } if (TRACE) { @@ -776,12 +768,12 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis } Population spec1, spec2; // test if species are close to already archived solutions - deactivate them if so - assocSpec = m_CAForSpeciesMerging.associateLoners(m_Archive, m_Species.toArray(new Population[m_Species.size()]), m_Population); + assocSpec = caForSpeciesMerging.associateLoners(poulationArchive, species.toArray(new Population[species.size()]), population); PriorityQueue specToRemove = new PriorityQueue(5, Collections.reverseOrder()); // backwards sorted or DIE! - for (int i = m_Archive.size() - 1; i >= 0; i--) { + for (int i = poulationArchive.size() - 1; i >= 0; i--) { if (assocSpec[i] >= 0) { - AbstractEAIndividual aIndy = m_Archive.getEAIndividual(i); - spec1 = (Population) this.m_Species.get(assocSpec[i]); + AbstractEAIndividual aIndy = poulationArchive.getEAIndividual(i); + spec1 = (Population) this.species.get(assocSpec[i]); // archived solution corresponds to an existing species if (!specToRemove.contains(assocSpec[i])) { // the species has not yet been deactivated @@ -792,12 +784,12 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis } if (spec1.getBestEAIndividual().isDominating(aIndy)) { // update the archived one with the better one? No rather not - it may happen that a large species is assoctiated which is quite large and spans over several optima - in that case an earlier found may get lost -// m_Archive.set(i, spec1.getBestEAIndividual()); +// poulationArchive.set(i, spec1.getBestEAIndividual()); } if (TRACE_EVTS) { System.out.println("!!! Reinit Spec " + assocSpec[i] + ", fit " + spec1.getBestEAIndividual()); } - m_doomedPop.addPopulation(spec1); + doomedPopulation.addPopulation(spec1); } } } @@ -810,24 +802,24 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis if (TRACE) { System.out.println("Removing species at index " + specIndex); } - m_Species.remove(specIndex); // warning, dont try to remove Integer object but index i! + species.remove(specIndex); // warning, dont try to remove Integer object but index i! lastRemoved = specIndex; } if (TRACE) { printState("---After archive-merges", reinitPop); } // Now test if species should be merged among each other - for (int i1 = 0; i1 < this.m_Species.size(); i1++) { - spec1 = (Population) this.m_Species.get(i1); - for (int i2 = i1 + 1; i2 < this.m_Species.size(); i2++) { - spec2 = (Population) this.m_Species.get(i2); - if (this.m_CAForSpeciesMerging.mergingSpecies(spec1, spec2, m_Population)) { + for (int i1 = 0; i1 < this.species.size(); i1++) { + spec1 = (Population) this.species.get(i1); + for (int i2 = i1 + 1; i2 < this.species.size(); i2++) { + spec2 = (Population) this.species.get(i2); + if (this.caForSpeciesMerging.mergingSpecies(spec1, spec2, population)) { if (TRACE_EVTS || TRACE) { System.out.println("!!! -Merging species (" + i1 + ", " + i2 + ") [" + spec1.size() + "/" + spec2.size() + "]"); } mergeToFirst(spec1, spec2, true); - this.m_Species.remove(i2); + this.species.remove(i2); i2--; } } @@ -837,25 +829,25 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis } } /// end of species merging - if (m_maxSpeciesSize >= m_minGroupSize) { + if (maxSpeciesSize >= minGroupSize) { // reinit worst n individuals from all species which are too large - for (int i = 0; i < m_Species.size(); i++) { - Population curSpec = m_Species.get(i); - if (curSpec.size() > m_maxSpeciesSize) { + for (int i = 0; i < species.size(); i++) { + Population curSpec = species.get(i); + if (curSpec.size() > maxSpeciesSize) { if (TRACE_EVTS) { - System.out.println("!!! Reinit indies " + (m_maxSpeciesSize - curSpec.size())); + System.out.println("!!! Reinit indies " + (maxSpeciesSize - curSpec.size())); } ArrayList sorted = curSpec.getSorted(reduceSizeComparator); - for (int k = m_maxSpeciesSize; k < sorted.size(); k++) { + for (int k = maxSpeciesSize; k < sorted.size(); k++) { if (curSpec.remove(sorted.get(k))) { - m_doomedPop.add(sorted.get(k)); + doomedPopulation.add(sorted.get(k)); } } -// reinitCount = sorted.size()-m_maxSpeciesSize; -// curSpec.setPopulationSize(m_maxSpeciesSize); +// reinitCount = sorted.size()-maxSpeciesSize; +// curSpec.setPopulationSize(maxSpeciesSize); // if (TRACE) System.out.println("Reduced spec " + i + " to size " + curSpec.size() + ", reinit of " + reinitCount + " indies immanent..."); -// this.m_Undifferentiated.addPopulation(this.initializeIndividuals(reinitCount)); -// this.m_Undifferentiated.setPopulationSize(this.m_Undifferentiated.getPopulationSize()+reinitCount); +// this.undifferentiatedPopulation.addPopulation(this.initializeIndividuals(reinitCount)); +// this.undifferentiatedPopulation.setPopulationSize(this.undifferentiatedPopulation.getPopulationSize()+reinitCount); } } } @@ -863,42 +855,42 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis // add new individuals from last step to undifferentiated set if ((reinitPop != null) && (reinitPop.size() > 0)) { - m_Undifferentiated.addPopulation(reinitPop); - m_Undifferentiated.incrFunctionCallsBy(reinitPop.size()); + undifferentiatedPopulation.addPopulation(reinitPop); + undifferentiatedPopulation.incrFunctionCallsBy(reinitPop.size()); } - m_Undifferentiated.setTargetSize(m_Undifferentiated.size()); + undifferentiatedPopulation.setTargetSize(undifferentiatedPopulation.size()); // output the result if (TRACE) { - System.out.println("-Funcalls: " + this.m_Undifferentiated.getFunctionCalls()); + System.out.println("-Funcalls: " + this.undifferentiatedPopulation.getFunctionCalls()); } - synchronized (m_Population) { // fill the m_Population instance with the current individuals from undiff, spec, etc. - this.m_Population = (Population) this.m_Undifferentiated.clone(); - m_Population.setUseHistory(true); - for (int i = 0; i < this.m_Species.size(); i++) { - this.m_Population.addPopulation((Population) this.m_Species.get(i)); + synchronized (population) { // fill the population instance with the current individuals from undiff, spec, etc. + this.population = (Population) this.undifferentiatedPopulation.clone(); + population.setUseHistory(true); + for (int i = 0; i < this.species.size(); i++) { + this.population.addPopulation((Population) this.species.get(i)); } - if (m_doomedPop.size() > 0) { - m_Population.addPopulation(m_doomedPop); + if (doomedPopulation.size() > 0) { + population.addPopulation(doomedPopulation); } // this is just so that the numbers match up... - m_Population.synchSize(); + population.synchSize(); if (TRACE) { - System.out.println("Doomed size: " + m_doomedPop.size()); - System.out.println("Population size: " + this.m_Population.size()); + System.out.println("Doomed size: " + doomedPopulation.size()); + System.out.println("Population size: " + this.population.size()); } - if (m_Population.size() != m_PopulationSize) { - System.err.println("Warning: Invalid population size in CBNEA! " + m_Population.size()); + if (population.size() != populationSize) { + System.err.println("Warning: Invalid population size in CBNEA! " + population.size()); } if (TRACE_STATE) { - printState("---- EoCBN", m_doomedPop); - System.out.println("Archive: " + m_Archive.getStringRepresentation()); + printState("---- EoCBN", doomedPopulation); + System.out.println("Archive: " + poulationArchive.getStringRepresentation()); } } // if (TRACE) { // // this is just a test adding all species centers as distractors with high strength -// Distraction distr = new Distraction(5., 0, m_Species); +// Distraction distr = new Distraction(5., 0, species); // if (!distr.isEmpty()) { -// double[] distVect = distr.calcDistractionFor(m_Undifferentiated.getBestEAIndividual()); +// double[] distVect = distr.calcDistractionFor(undifferentiatedPopulation.getBestEAIndividual()); // System.out.println("species distract best towards " + BeanInspector.toString(distVect)); // } // } @@ -912,16 +904,16 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis */ private void initClustering() { if (getClusterDiffDist() > 0) { // assume that it should be set - if (this.m_CAForSpeciesDifferentation instanceof InterfaceClusteringDistanceParam) { - ((InterfaceClusteringDistanceParam) m_CAForSpeciesDifferentation).setClustDistParam(getClusterDiffDist()); + if (this.caForSpeciesDifferentation instanceof InterfaceClusteringDistanceParam) { + ((InterfaceClusteringDistanceParam) caForSpeciesDifferentation).setClustDistParam(getClusterDiffDist()); if (TRACE) { System.out.println("### Clustering distance parameter set to " + getClusterDiffDist()); } } else { - EVAERROR.errorMsgOnce("Warning: cluster distance is defined in CBN but the clustering method " + m_CAForSpeciesDifferentation.getClass() + " cant interpret it!"); + EVAERROR.errorMsgOnce("Warning: cluster distance is defined in CBN but the clustering method " + caForSpeciesDifferentation.getClass() + " cant interpret it!"); } } - this.m_CAForSpeciesDifferentation.initClustering(m_Population); + this.caForSpeciesDifferentation.initClustering(population); } // @@ -934,8 +926,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis // */ // private Population getCurrentPop() { // Population pop = new Population(getPopulationSize()); -// pop.addPopulation(m_Undifferentiated); -// for (int i=0; i 0) { - sum += m_Species.get(0).size(); - System.out.print(specTag(m_Species.get(0))); - for (int i = 1; i < m_Species.size(); i++) { - System.out.print(", " + specTag(m_Species.get(i))); - sum += m_Species.get(i).size(); + int sum = undifferentiatedPopulation.size() + (reinit == null ? 0 : reinit.size()); + if (species.size() > 0) { + sum += species.get(0).size(); + System.out.print(specTag(species.get(0))); + for (int i = 1; i < species.size(); i++) { + System.out.print(", " + specTag(species.get(i))); + sum += species.get(i).size(); } } System.out.println(", reinit: " + (reinit == null ? 0 : reinit.size()) + ", sum: " + sum); @@ -979,8 +971,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis */ protected void mergeToFirst(Population spec1, Population spec2, boolean plot) { // System.out.println("Merging " + spec2.size() + " to " + spec1.size()); - if (plot && (m_Topology != null)) { - plotLine(m_Topology, spec1.getBestEAIndividual(), spec2.getBestEAIndividual()); + if (plot && (topologyPlot != null)) { + plotLine(topologyPlot, spec1.getBestEAIndividual(), spec2.getBestEAIndividual()); } spec1.addPopulation(spec2); // keep longer history @@ -991,8 +983,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis spec1.setGenerationTo(spec2.getGeneration()); } // possibly notify the optimizer of the merging event to merge population based information - if (m_Optimizer instanceof InterfaceSpeciesAware) { - ((InterfaceSpeciesAware) m_Optimizer).mergeToFirstPopulationEvent(spec1, spec2); + if (optimizer instanceof InterfaceSpeciesAware) { + ((InterfaceSpeciesAware) optimizer).mergeToFirstPopulationEvent(spec1, spec2); } } @@ -1015,8 +1007,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis newSp.SetHistory(new LinkedList()); } - if (m_Optimizer instanceof InterfaceSpeciesAware) { - ((InterfaceSpeciesAware) m_Optimizer).splitFromFirst(parentSp, newSp); + if (optimizer instanceof InterfaceSpeciesAware) { + ((InterfaceSpeciesAware) optimizer).splitFromFirst(parentSp, newSp); } } @@ -1044,8 +1036,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis // } // public int countActiveSpec() { // int k = 0; -// for (int i=0; i 0) { - sols.add(m_Undifferentiated.getBestIndividual()); + if (undifferentiatedPopulation.size() > 0) { + sols.add(undifferentiatedPopulation.getBestIndividual()); } // if (!sols.checkNoNullIndy()) { // System.err.println("error in CBN..."); @@ -1224,12 +1216,12 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @return The current status of this flag */ public boolean isUseMerging() { - return this.m_mergeSpecies; + return this.mergeSpecies; } public void setUseMerging(boolean b) { - this.m_mergeSpecies = b; - GenericObjectEditor.setHideProperty(this.getClass(), "mergingCA", !m_mergeSpecies); + this.mergeSpecies = b; + GenericObjectEditor.setHideProperty(this.getClass(), "mergingCA", !mergeSpecies); } public String useMergingTipText() { @@ -1242,11 +1234,11 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @return The current optimizing method */ public InterfaceOptimizer getOptimizer() { - return this.m_Optimizer; + return this.optimizer; } public void setOptimizer(InterfaceOptimizer b) { - this.m_Optimizer = b; + this.optimizer = b; if (b instanceof EvolutionStrategies) { EvolutionStrategies es = (EvolutionStrategies) b; setMuLambdaRatio(es.getMu() / (double) es.getLambda()); @@ -1263,11 +1255,11 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @return The current clustering method */ public InterfaceClustering getDifferentiationCA() { - return this.m_CAForSpeciesDifferentation; + return this.caForSpeciesDifferentation; } public void setDifferentiationCA(InterfaceClustering b) { - this.m_CAForSpeciesDifferentation = b; + this.caForSpeciesDifferentation = b; } public String differentiationCATipText() { @@ -1280,11 +1272,11 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @return The current clustering method */ public InterfaceClustering getMergingCA() { - return this.m_CAForSpeciesMerging; + return this.caForSpeciesMerging; } public void setMergingCA(InterfaceClustering b) { - this.m_CAForSpeciesMerging = b; + this.caForSpeciesMerging = b; } public String mergingCATipText() { @@ -1307,11 +1299,11 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * performed. */ public int getSpeciesCycle() { - return this.m_SpeciesCycle; + return this.speciesCycle; } public void setSpeciesCycle(int b) { - this.m_SpeciesCycle = b; + this.speciesCycle = b; } public String speciesCycleTipText() { @@ -1325,13 +1317,13 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * performed. */ public int getShowCycle() { - return this.m_ShowCycle; + return this.showCycle; } public void setShowCycle(int b) { - this.m_ShowCycle = b; + this.showCycle = b; if (b <= 0) { - m_Topology = null; + topologyPlot = null; } } @@ -1345,11 +1337,11 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @return This number gives initial population size. */ public int getPopulationSize() { - return this.m_PopulationSize; + return this.populationSize; } public void setPopulationSize(int b) { - this.m_PopulationSize = b; + this.populationSize = b; } public String populationSizeTipText() { @@ -1480,15 +1472,15 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis public Object[] getAdditionalDataValue(PopulationInterface pop) { // int actives = countActiveSpec(); return new Object[]{ - m_Undifferentiated.size(), - m_Species.size(), + undifferentiatedPopulation.size(), + species.size(), getAvgSpeciesMeasures()[0], - m_Archive.size(), - m_Archive.getCorrelations()[3], - m_Archive.getPopulationMeasures()[0], + poulationArchive.size(), + poulationArchive.getCorrelations()[3], + poulationArchive.getPopulationMeasures()[0], collisions, getClusterDiffDist()}; -// return m_Undifferentiated.size() + " \t " + m_Species.size() + " \t " + BeanInspector.toString(getAvgSpeciesMeasures()[0]) + " \t " + (m_Archive.size()); +// return undifferentiatedPopulation.size() + " \t " + species.size() + " \t " + BeanInspector.toString(getAvgSpeciesMeasures()[0]) + " \t " + (poulationArchive.size()); } /** @@ -1498,31 +1490,31 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @return average population measures */ protected double[] getAvgSpeciesMeasures() { - if (m_Species == null || (m_Species.size() == 0)) { + if (species == null || (species.size() == 0)) { return new double[]{0}; } else { - double[] measures = m_Species.get(0).getPopulationMeasures(); - for (int i = 1; i < m_Species.size(); i++) { - Mathematics.vvAdd(measures, m_Species.get(i).getPopulationMeasures(), measures); + double[] measures = species.get(0).getPopulationMeasures(); + for (int i = 1; i < species.size(); i++) { + Mathematics.vvAdd(measures, species.get(i).getPopulationMeasures(), measures); } - if (m_Species.size() > 1) { - Mathematics.svDiv((double) m_Species.size(), measures, measures); + if (species.size() > 1) { + Mathematics.svDiv((double) species.size(), measures, measures); } return measures; } } public int getMaxSpeciesSize() { - return m_maxSpeciesSize; + return maxSpeciesSize; } public void setMaxSpeciesSize(int mMaxSpeciesSize) { - m_maxSpeciesSize = mMaxSpeciesSize; - GenericObjectEditor.setShowProperty(this.getClass(), "reduceSizeComparator", (m_maxSpeciesSize >= m_minGroupSize)); + maxSpeciesSize = mMaxSpeciesSize; + GenericObjectEditor.setShowProperty(this.getClass(), "reduceSizeComparator", (maxSpeciesSize >= minGroupSize)); } public String maxSpeciesSizeTipText() { - return "If >= " + m_minGroupSize + ", larger species are reduced to the given size by reinitializing the worst individuals."; + return "If >= " + minGroupSize + ", larger species are reduced to the given size by reinitializing the worst individuals."; } public String reduceSizeComparatorTipText() { @@ -1555,10 +1547,10 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis public void setClusterDiffDist(double clusterDiffDist) { this.clusterDiffDist = clusterDiffDist; if (clusterDiffDist < 0) { - if ((m_Problem instanceof InterfaceProblemDouble) && (m_CAForSpeciesDifferentation instanceof ClusteringDensityBased)) { -// int numExpectedOptima = (int)((((double)getPopulationSize())*0.9)/((ClusteringDensityBased)m_CAForSpeciesDifferentation).getMinimumGroupSize()); -// this.clusterDiffDist = EsDpiNiching.calcEstimatedNicheRadius(((AbstractProblemDouble)m_Problem).makeRange(), numExpectedOptima, new EuclideanMetric()); - setUpperBoundClustDiff((InterfaceProblemDouble) m_Problem); + if ((optimizationProblem instanceof InterfaceProblemDouble) && (caForSpeciesDifferentation instanceof ClusteringDensityBased)) { +// int numExpectedOptima = (int)((((double)getPopulationSize())*0.9)/((ClusteringDensityBased)caForSpeciesDifferentation).getMinimumGroupSize()); +// this.clusterDiffDist = EsDpiNiching.calcEstimatedNicheRadius(((AbstractProblemDouble)problem).makeRange(), numExpectedOptima, new EuclideanMetric()); + setUpperBoundClustDiff((InterfaceProblemDouble) optimizationProblem); } else { System.err.println("Warning, unable to calculate standard niche radius in CBN-EA"); } @@ -1577,12 +1569,12 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis * @param q */ public void setUpperBoundClustDiff(InterfaceProblemDouble prob) { - if (m_CAForSpeciesDifferentation instanceof ClusteringDensityBased) { - double meanSubSwarmSize = 0.5 * (((ClusteringDensityBased) m_CAForSpeciesDifferentation).getMinimumGroupSize() + getMaxSpeciesSize()); + if (caForSpeciesDifferentation instanceof ClusteringDensityBased) { + double meanSubSwarmSize = 0.5 * (((ClusteringDensityBased) caForSpeciesDifferentation).getMinimumGroupSize() + getMaxSpeciesSize()); int numExpectedOptima = (int) ((((double) getPopulationSize())) / meanSubSwarmSize); - double[][] range = ((InterfaceProblemDouble) m_Problem).makeRange(); + double[][] range = ((InterfaceProblemDouble) optimizationProblem).makeRange(); int dim = range.length; - double nRad = EsDpiNiching.calcEstimatedNicheRadius(range, numExpectedOptima, ((ClusteringDensityBased) m_CAForSpeciesDifferentation).getMetric()); + double nRad = EsDpiNiching.calcEstimatedNicheRadius(range, numExpectedOptima, ((ClusteringDensityBased) caForSpeciesDifferentation).getMetric()); nRad *= Math.pow(0.5, 1 / dim); // System.out.println("Alternative clust diff from niche radius... " + nRad); this.clusterDiffDist = nRad; diff --git a/src/eva2/optimization/strategies/ClusteringHillClimbing.java b/src/eva2/optimization/strategies/ClusteringHillClimbing.java index ebaa2cd8..84166e94 100644 --- a/src/eva2/optimization/strategies/ClusteringHillClimbing.java +++ b/src/eva2/optimization/strategies/ClusteringHillClimbing.java @@ -147,7 +147,7 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi archive = new Population(); hideHideable(); m_Population.setTargetSize(initialPopSize); - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); m_Population.addPopulationChangedEventListener(null); // noone will be notified directly on pop changes this.m_Problem.evaluate(this.m_Population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); @@ -200,7 +200,7 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi System.out.println("evalCycle: " + hcEvalCycle + ", evals now: " + evalsNow); } popD = PostProcess.clusterLocalSearch(localSearchMethod, m_Population, (AbstractOptimizationProblem) m_Problem, sigmaClust, evalsNow, 0.5, mutator); - // (m_Population, (AbstractOptimizationProblem)m_Problem, sigmaClust, hcEvalCycle - (m_Population.getFunctionCalls() % hcEvalCycle), 0.5); + // (m_Population, (AbstractOptimizationProblem)problem, sigmaClust, hcEvalCycle - (m_Population.getFunctionCalls() % hcEvalCycle), 0.5); if (popD.head().getFunctionCalls() == funCallsBefore) { System.err.println("Bad case, increasing allowed evaluations!"); evalsNow = Math.max(evalsNow++, (int) (evalsNow * 1.2)); @@ -235,7 +235,7 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi Population tmpPop = new Population(); tmpPop.addPopulationChangedEventListener(null); tmpPop.setTargetSize(initialPopSize); - this.m_Problem.initPopulation(tmpPop); + this.m_Problem.initializePopulation(tmpPop); tmpPop.setSameParams(m_Population); tmpPop.setTargetSize(initialPopSize); this.m_Problem.evaluate(tmpPop); diff --git a/src/eva2/optimization/strategies/DifferentialEvolution.java b/src/eva2/optimization/strategies/DifferentialEvolution.java index effef920..f6e09481 100644 --- a/src/eva2/optimization/strategies/DifferentialEvolution.java +++ b/src/eva2/optimization/strategies/DifferentialEvolution.java @@ -99,7 +99,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); // children = new Population(m_Population.size()); this.evaluatePopulation(this.m_Population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); @@ -201,7 +201,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial private double[] fetchDeltaCurrentRandom(Population pop, InterfaceDataTypeDouble indy) { double[] x1, x2; double[] result; - boolean isEmpty; + boolean isEmpty; int iterations = 0; @@ -520,7 +520,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial // AbstractEAIndividual indy = null, orig; int parentIndex; // required for dynamic problems especially -// m_Problem.evaluatePopulationStart(m_Population); +// problem.evaluatePopulationStart(m_Population); if (children == null) { children = new Population(m_Population.size()); } else { @@ -657,7 +657,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial // if (children==null) children = new Population(m_Population.size()); // for (int i = 0; i < this.m_Population.size(); i++) { // indy = this.generateNewIndividual(this.m_Population); -// this.m_Problem.evaluate(indy); +// this.problem.evaluate(indy); // this.m_Population.incrFunctionCalls(); // children.add(indy); // } @@ -671,7 +671,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial // } else { // duel with random one // index = RNG.randomInt(0, this.m_Population.size()-1); // org = (AbstractEAIndividual)this.m_Population.get(index); -// // if (envHasChanged) this.m_Problem.evaluate(org); +// // if (envHasChanged) this.problem.evaluate(org); // if (indy.isDominatingDebConstraints(org)) { // this.m_Population.replaceIndividualAt(index, indy); // } @@ -681,7 +681,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial //////// this was the original version // for (int i = 0; i < this.m_Population.size(); i++) { // indy = this.generateNewIndividual(this.m_Population); -// this.m_Problem.evaluate(indy); +// this.problem.evaluate(indy); // this.m_Population.incrFunctionCalls(); // index = RNG.randomInt(0, this.m_Population.size()-1); // org = (AbstractEAIndividual)this.m_Population.get(index); diff --git a/src/eva2/optimization/strategies/DynamicParticleSwarmOptimization.java b/src/eva2/optimization/strategies/DynamicParticleSwarmOptimization.java index 273e7b51..24a7163e 100644 --- a/src/eva2/optimization/strategies/DynamicParticleSwarmOptimization.java +++ b/src/eva2/optimization/strategies/DynamicParticleSwarmOptimization.java @@ -254,52 +254,6 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization return rand; } - /** This method will update a given individual - * according to the PSO method - * @param index The individual to update. - * @param pop The current population. - * @param best The best individual found so far. - */ -// protected void updateIndividual(int index, Population pop, AbstractEAIndividual best) { -// AbstractEAIndividual indy = (AbstractEAIndividual)pop.get(index); -// if (indy instanceof InterfaceESIndividual) { -// InterfaceESIndividual endy = (InterfaceESIndividual) indy; -// -// if (isParticleType(indy, resetType)) { -// resetIndividual(indy); -// } else { -// indy.SetData(partTypeKey, defaultType); // reset in case it was quantum -// -// double[] personalBestPos = (double[]) indy.getData(partBestPosKey); -// double[] velocity = (double[]) indy.getData(partVelKey); -// double[] curPosition = endy.getDGenotype(); -// double[][] range = endy.getDoubleRange(); -// -// // search for the local best position -// double[] neighbourBestPos = findNeighbourhoodOptimum(index, pop, best); -// -// // now update the velocity -// double[] curVelocity = updateVelocity(index, velocity, personalBestPos, curPosition, neighbourBestPos, range); -// -// //System.out.println("localBestPos is " + localBestPosition[0] + "/" + localBestPosition[1]); -// -// // check the speed limit! -// if (checkSpeedLimit) enforceSpeedLimit(curVelocity, range, getSpeedLimit(index, pop.size())); -// -// // enforce range constraints if necessary -// if (m_CheckConstraints) ensureConstraints(curPosition, curVelocity, range); -// -// plotIndy(curPosition, curVelocity, (Integer)indy.getData(indexKey)); -// // finally update the position -// updatePosition(indy, curVelocity, curPosition, range); -// -// resetFitness(indy); -// } -// } else { -// System.err.println("Could not perform PSO update, because individual is not instance of InterfaceESIndividual!"); -// } -// } - @Override protected double[] updateVelocity(int index, double[] lastVelocity, double[] bestPosition, double[] curPosition, double[] localBestPos, double[][] range) { if (envHasChanged) { @@ -337,10 +291,10 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization } protected double getProblemSpecificAttraction(int i, double chi) { -// if (m_Problem instanceof DynLocalizationProblem) { +// if (problem instanceof DynLocalizationProblem) { // // TODO test this! // //hier weiter -// double[] att = ((DynLocalizationProblem)m_Problem).getProblemSpecificAttractor(); +// double[] att = ((DynLocalizationProblem)problem).getProblemSpecificAttractor(); // return (this.phi3 * chi * RNG.randomDouble(0, 1.))*att[i]; // } else return 0; @@ -363,7 +317,6 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization * Get the speed limit of an individual (respecting highEnergyRatio, so some individuals may be accelerated). * * @param index the individuals index - * @param popSize the size of the population * @return the speed limit of the individual */ @Override @@ -420,7 +373,7 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization * according to the PSO method * @param index The individual to update. * @param pop The current population. - * @param best The best individual found so far. + * @param indy The best individual found so far. */ @Override protected void updateIndividual(int index, AbstractEAIndividual indy, Population pop) { @@ -465,8 +418,8 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization if (doSpeedAdaptation) { adaptTrackingSpeed(((InterfaceDataTypeDouble)population.get(0)).getDoubleRange()); } -// if (m_Problem instanceof DynLocalizationProblem) { -// ((DynLocalizationProblem)m_Problem).adaptPSOByPopulation(population, this); +// if (problem instanceof DynLocalizationProblem) { +// ((DynLocalizationProblem)problem).adaptPSOByPopulation(population, this); // } } diff --git a/src/eva2/optimization/strategies/EsDpiNiching.java b/src/eva2/optimization/strategies/EsDpiNiching.java index bf99b9b5..99d21518 100644 --- a/src/eva2/optimization/strategies/EsDpiNiching.java +++ b/src/eva2/optimization/strategies/EsDpiNiching.java @@ -583,7 +583,7 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface loners.removeMembers(luckyLosers, true); // fill up with random indies // Population randomNewIndies = new Population(lambdaPerPeak - selected.size()); - // problem.initPopulation(randomNewIndies); // function calls?? + // problem.initializePopulation(randomNewIndies); // function calls?? // selected.addAll(randomNewIndies); } } @@ -767,7 +767,7 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface */ private Population initRandomPeakPop(int cntPerNewSpecies) { Population newPop = new Population(cntPerNewSpecies); - problem.initPopulation(newPop); + problem.initializePopulation(newPop); newPop.putData(EvolutionStrategies.esLambdaParam, getLambdaPerPeak()); newPop.putData(EvolutionStrategies.esMuParam, getMuPerPeak()); newPop.setMaxHistoryLength(haltingWindowLen); @@ -780,7 +780,7 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface private void generateEvalImmigrants(int cnt) { if (cnt > 0) { randomNewIndies = new Population(cnt); - problem.initPopulation(randomNewIndies); + problem.initializePopulation(randomNewIndies); problem.evaluate(randomNewIndies); population.incrFunctionCallsBy(cnt); if (TRACE) { diff --git a/src/eva2/optimization/strategies/EvolutionStrategies.java b/src/eva2/optimization/strategies/EvolutionStrategies.java index 9d2352e6..49b0cccf 100644 --- a/src/eva2/optimization/strategies/EvolutionStrategies.java +++ b/src/eva2/optimization/strategies/EvolutionStrategies.java @@ -95,7 +95,7 @@ public class EvolutionStrategies implements InterfaceOptimizer, java.io.Serializ checkPopulationConstraints(); population.putData(esMuParam, getMu()); population.putData(esLambdaParam, getLambda()); - this.optimizationProblem.initPopulation(this.population); + this.optimizationProblem.initializePopulation(this.population); this.evaluatePopulation(this.population); } diff --git a/src/eva2/optimization/strategies/EvolutionStrategyIPOP.java b/src/eva2/optimization/strategies/EvolutionStrategyIPOP.java index c614e9b2..9eeaf3db 100644 --- a/src/eva2/optimization/strategies/EvolutionStrategyIPOP.java +++ b/src/eva2/optimization/strategies/EvolutionStrategyIPOP.java @@ -136,7 +136,7 @@ public class EvolutionStrategyIPOP extends EvolutionStrategies implements Interf bestList.add(best); best = null; Population newPop = getPopulation().cloneWithoutInds(); - getProblem().initPopulation(newPop); // this is where the reinit event of Pop is called, meaning that the rank-mu-cma matrix is reinitialized as well + getProblem().initializePopulation(newPop); // this is where the reinit event of Pop is called, meaning that the rank-mu-cma matrix is reinitialized as well double[] badFit = getPopulation().getBestFitness().clone(); Arrays.fill(badFit, Double.MAX_VALUE); newPop.setAllFitnessValues(badFit); diff --git a/src/eva2/optimization/strategies/EvolutionaryProgramming.java b/src/eva2/optimization/strategies/EvolutionaryProgramming.java index a5a385c2..70e6d974 100644 --- a/src/eva2/optimization/strategies/EvolutionaryProgramming.java +++ b/src/eva2/optimization/strategies/EvolutionaryProgramming.java @@ -49,7 +49,7 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); this.evaluatePopulation(this.m_Population); this.m_PopulationSize = this.m_Population.size(); this.firePropertyChangedEvent(Population.nextGenerationPerformed); diff --git a/src/eva2/optimization/strategies/FloodAlgorithm.java b/src/eva2/optimization/strategies/FloodAlgorithm.java index dfe93428..1efd14fe 100644 --- a/src/eva2/optimization/strategies/FloodAlgorithm.java +++ b/src/eva2/optimization/strategies/FloodAlgorithm.java @@ -57,7 +57,7 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable */ @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); this.m_Problem.evaluate(this.m_Population); this.m_CurrentFloodPeak = this.m_InitialFloodPeak; this.firePropertyChangedEvent(Population.nextGenerationPerformed); diff --git a/src/eva2/optimization/strategies/GeneticAlgorithm.java b/src/eva2/optimization/strategies/GeneticAlgorithm.java index 5e7bb4b2..4091134e 100644 --- a/src/eva2/optimization/strategies/GeneticAlgorithm.java +++ b/src/eva2/optimization/strategies/GeneticAlgorithm.java @@ -57,7 +57,7 @@ public class GeneticAlgorithm implements InterfaceOptimizer, java.io.Serializabl @Override public void init() { - this.optimizationProblem.initPopulation(this.population); + this.optimizationProblem.initializePopulation(this.population); this.evaluatePopulation(this.population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); } @@ -71,7 +71,7 @@ public class GeneticAlgorithm implements InterfaceOptimizer, java.io.Serializabl public void initByPopulation(Population pop, boolean reset) { this.population = (Population) pop.clone(); if (reset) { - this.optimizationProblem.initPopulation(population); + this.optimizationProblem.initializePopulation(population); this.population.init(); this.evaluatePopulation(this.population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); diff --git a/src/eva2/optimization/strategies/GradientDescentAlgorithm.java b/src/eva2/optimization/strategies/GradientDescentAlgorithm.java index 220be2c3..e52e947a 100644 --- a/src/eva2/optimization/strategies/GradientDescentAlgorithm.java +++ b/src/eva2/optimization/strategies/GradientDescentAlgorithm.java @@ -108,7 +108,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser public void init() { //System.out.println("init() called "); // indyhash = new Hashtable(); - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); this.m_Problem.evaluate(this.m_Population); } @@ -231,7 +231,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser ((InterfaceDataTypeDouble) indy).SetDoubleGenotype(params); - } // end if ((this.m_Problem instanceof InterfaceFirstOrderDerivableProblem) && (indy instanceof InterfaceDataTypeDouble)) { + } // end if ((this.problem instanceof InterfaceFirstOrderDerivableProblem) && (indy instanceof InterfaceDataTypeDouble)) { else { String msg = "Warning, problem of type InterfaceFirstOrderDerivableProblem and template of type InterfaceDataTypeDouble is required for " + this.getClass(); EVAERROR.errorMsgOnce(msg); diff --git a/src/eva2/optimization/strategies/HillClimbing.java b/src/eva2/optimization/strategies/HillClimbing.java index 7363991c..91801587 100644 --- a/src/eva2/optimization/strategies/HillClimbing.java +++ b/src/eva2/optimization/strategies/HillClimbing.java @@ -53,7 +53,7 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable { */ @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); this.m_Problem.evaluate(this.m_Population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); } @@ -104,7 +104,7 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable { // indy1 = (AbstractEAIndividual) this.m_Population.get(i); // indy2 = (AbstractEAIndividual)(indy1).clone(); // indy2.mutate(); -// this.m_Problem.evaluate((AbstractEAIndividual) indy2); +// this.problem.evaluate((AbstractEAIndividual) indy2); // //indy2.SetFitness(0, indy2.evaulateAsMiniBits()); // this.m_Population.incrFunctionCalls(); // //if (indy2.getFitness(0) < indy1.getFitness(0)) { diff --git a/src/eva2/optimization/strategies/IslandModelEA.java b/src/eva2/optimization/strategies/IslandModelEA.java index 425364d8..0a8ffa3f 100644 --- a/src/eva2/optimization/strategies/IslandModelEA.java +++ b/src/eva2/optimization/strategies/IslandModelEA.java @@ -123,7 +123,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I } this.m_Islands = new InterfaceOptimizer[nodesList.length]; for (int i = 0; i < nodesList.length; i++) { - this.m_Islands[i] = (InterfaceOptimizer) RMIProxyRemoteThread.newInstance(this.m_Optimizer, nodesList[i]); + this.m_Islands[i] = (InterfaceOptimizer) RMIProxyRemoteThread.newInstance(this.optimizer, nodesList[i]); this.m_Islands[i].setIdentifier(""+i); this.m_Islands[i].init(); if (this.m_LogLocalChanges) { @@ -201,7 +201,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I } this.m_Islands = new InterfaceOptimizer[nodesList.length]; for (int i = 0; i < nodesList.length; i++) { - this.m_Islands[i] = (InterfaceOptimizer) RMIProxyRemoteThread.newInstance(this.m_Optimizer, nodesList[i]); + this.m_Islands[i] = (InterfaceOptimizer) RMIProxyRemoteThread.newInstance(this.optimizer, nodesList[i]); this.m_Islands[i].setIdentifier(""+i); this.m_Islands[i].init(); if (this.m_LogLocalChanges) { @@ -365,7 +365,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I result += this.m_Optimizer.getStringRepresentation() + "\n"; } //result += "=> The Optimization Problem: "; - //result += this.m_Problem.getStringRepresentationForProblem(this) +"\n"; + //result += this.problem.getStringRepresentationForProblem(this) +"\n"; //result += this.m_Population.getStringRepresentation(); return result; } @@ -387,9 +387,9 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I ((MultiObjectiveEA) imea.m_Optimizer).getPopulation().setTargetSize(50); imea.m_Problem = new TF1Problem(); ((TF1Problem) imea.m_Problem).setEAIndividual(new ESIndividualDoubleData()); -// ((TF1Problem)imea.m_Problem).setEAIndividual(new ESIndividualDoubleData()); -// imea.m_Problem = new TFPortfolioSelectionProblem(); -// ((TFPortfolioSelectionProblem)imea.m_Problem).setEAIndividual(new ESIndividualDoubleData()); +// ((TF1Problem)imea.problem).setEAIndividual(new ESIndividualDoubleData()); +// imea.problem = new TFPortfolioSelectionProblem(); +// ((TFPortfolioSelectionProblem)imea.problem).setEAIndividual(new ESIndividualDoubleData()); if (false) { MOClusteringSeparation c = new MOClusteringSeparation(); c.getKMeans().setUseSearchSpace(false); diff --git a/src/eva2/optimization/strategies/LTGA.java b/src/eva2/optimization/strategies/LTGA.java index 8cc1c5de..897e0bde 100644 --- a/src/eva2/optimization/strategies/LTGA.java +++ b/src/eva2/optimization/strategies/LTGA.java @@ -116,7 +116,7 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interface @Override public void init() { this.defaultInit(); - this.problem.initPopulation(this.population); + this.problem.initializePopulation(this.population); this.evaluatePopulation(this.population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); } diff --git a/src/eva2/optimization/strategies/MLTGA.java b/src/eva2/optimization/strategies/MLTGA.java index eb6662f9..f229b429 100644 --- a/src/eva2/optimization/strategies/MLTGA.java +++ b/src/eva2/optimization/strategies/MLTGA.java @@ -116,7 +116,7 @@ public class MLTGA implements InterfaceOptimizer, java.io.Serializable, Interfac @Override public void init() { defaultInit(); - this.problem.initPopulation(this.population); + this.problem.initializePopulation(this.population); this.evaluatePopulation(this.population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); } diff --git a/src/eva2/optimization/strategies/MonteCarloSearch.java b/src/eva2/optimization/strategies/MonteCarloSearch.java index e8ad9f60..ae1458c1 100644 --- a/src/eva2/optimization/strategies/MonteCarloSearch.java +++ b/src/eva2/optimization/strategies/MonteCarloSearch.java @@ -59,7 +59,7 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl */ @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); this.m_Problem.evaluate(this.m_Population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); } @@ -88,7 +88,7 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl public void optimize() { Population original = (Population) this.m_Population.clone(); -// this.m_Problem.initPopulation(this.m_Population); +// this.problem.initializePopulation(this.m_Population); for (int i = 0; i < m_Population.size(); i++) { m_Population.getEAIndividual(i).defaultInit(null); } diff --git a/src/eva2/optimization/strategies/MultiObjectiveCMAES.java b/src/eva2/optimization/strategies/MultiObjectiveCMAES.java index 9a11aaf9..344ca877 100644 --- a/src/eva2/optimization/strategies/MultiObjectiveCMAES.java +++ b/src/eva2/optimization/strategies/MultiObjectiveCMAES.java @@ -181,7 +181,7 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable { public void init() { // initByPopulation(m_Population, true); this.m_Population.setTargetSize(m_lambdamo); - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); // children = new Population(m_Population.size()); this.evaluatePopulation(this.m_Population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); @@ -199,7 +199,7 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable { public void initByPopulation(Population pop, boolean reset) { setPopulation(pop); if (reset) { - m_Problem.initPopulation(m_Population); + m_Problem.initializePopulation(m_Population); m_Problem.evaluate(m_Population); } diff --git a/src/eva2/optimization/strategies/MultiObjectiveEA.java b/src/eva2/optimization/strategies/MultiObjectiveEA.java index 9edd674e..79002c10 100644 --- a/src/eva2/optimization/strategies/MultiObjectiveEA.java +++ b/src/eva2/optimization/strategies/MultiObjectiveEA.java @@ -89,22 +89,22 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl */ @Override public void optimize() { -// double[][] may = this.showMay(this.m_Optimizer.getPopulation()); +// double[][] may = this.showMay(this.optimizer.getPopulation()); // This is in total compliance with Koch's framework nice isn't it? this.m_Optimizer.optimize(); // now comes all the multiobjective optimization stuff // This is the Environment Selection this.m_Archiver.addElementsToArchive(this.m_Optimizer.getPopulation()); - //if (true) this.m_Archiver.plotArchive(this.m_Optimizer.getPopulation()); + //if (true) this.m_Archiver.plotArchive(this.optimizer.getPopulation()); // if (false) { -// int popSize = this.m_Optimizer.getPopulation().size(); -// int archiveSize = this.m_Optimizer.getPopulation().getArchive().size(); +// int popSize = this.optimizer.getPopulation().size(); +// int archiveSize = this.optimizer.getPopulation().getArchive().size(); // int feasiblePop = 0, feasibleArch = 0; // for (int i = 0; i < popSize; i++) { -// if (((AbstractEAIndividual)this.m_Optimizer.getPopulation().get(i)).getConstraintViolation() == 0) feasiblePop++; +// if (((AbstractEAIndividual)this.optimizer.getPopulation().get(i)).getConstraintViolation() == 0) feasiblePop++; // } // for (int i = 0; i < archiveSize; i++) { -// if (((AbstractEAIndividual)this.m_Optimizer.getPopulation().getArchive().get(i)).getConstraintViolation() == 0) feasibleArch++; +// if (((AbstractEAIndividual)this.optimizer.getPopulation().getArchive().get(i)).getConstraintViolation() == 0) feasibleArch++; // } // System.out.println("Population size : "+popSize + " ("+feasiblePop+"/"+(popSize-feasiblePop)+")"); // System.out.println("Archive size : "+archiveSize + " ("+feasibleArch+"/"+(archiveSize-feasibleArch)+")"); @@ -114,7 +114,7 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl // the population from which in the next generation the parents will be selected. this.m_InformationRetrieval.retrieveInformationFrom(this.m_Optimizer.getPopulation()); -// double[][] mayday = this.showMay(this.m_Optimizer.getPopulation()); +// double[][] mayday = this.showMay(this.optimizer.getPopulation()); // if ((mayday[0][0] > may[0][0]) || (mayday[1][1] > may[1][1])) { // System.out.println("Losing the edges:"); // System.out.println("Before : (" +may[0][0]+"/"+may[0][1]+") and ("+may[1][0]+"/"+may[1][1]+")"); @@ -210,7 +210,7 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl result += " Optimizer = " + this.m_Optimizer.getClass().toString() + "\n"; result += this.m_Optimizer.getStringRepresentation() + "\n"; //result += "=> The Optimization Problem: "; - //result += this.m_Problem.getStringRepresentationForProblem(this) +"\n"; + //result += this.problem.getStringRepresentationForProblem(this) +"\n"; //result += this.m_Population.getStringRepresentation(); return result; } diff --git a/src/eva2/optimization/strategies/NelderMeadSimplex.java b/src/eva2/optimization/strategies/NelderMeadSimplex.java index 6a209e28..4c1ed672 100644 --- a/src/eva2/optimization/strategies/NelderMeadSimplex.java +++ b/src/eva2/optimization/strategies/NelderMeadSimplex.java @@ -165,7 +165,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte // AbstractEAIndividual reflectedInd = (AbstractEAIndividual)((AbstractEAIndividual)bestpop.getIndividual(1)).clone(); // ((InterfaceDataTypeDouble)reflectedInd).SetDoubleGenotype(r); // -// m_Problem.evaluate(reflectedInd); +// problem.evaluate(reflectedInd); AbstractEAIndividual reflectedInd = createEvalIndy(bestpop, r); this.m_Population.incrFunctionCalls(); @@ -200,7 +200,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte // AbstractEAIndividual c_ind = (AbstractEAIndividual)((AbstractEAIndividual)bestpop.getIndividual(1)).clone(); // ((InterfaceDataTypeDouble)c_ind).SetDoubleGenotype(c); -// m_Problem.evaluate(c_ind); +// problem.evaluate(c_ind); AbstractEAIndividual c_ind = createEvalIndy(bestpop, c); this.m_Population.incrFunctionCalls(); if (firstIsBetterEqual(c_ind, worst)) { @@ -265,7 +265,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte setPopulation(pop); pop.addPopulationChangedEventListener(this); if (reset) { - m_Problem.initPopulation(m_Population); + m_Problem.initializePopulation(m_Population); m_Problem.evaluate(m_Population); } // fireNextGenerationPerformed(); @@ -295,7 +295,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte System.err.println("WARNING: nelder mead step produced indy out of range!"); // Mathematics.projectToRange(x, range); // ((InterfaceDataTypeDouble)ind).SetDoubleGenotype(x); -// m_Problem.evaluate(ind); +// problem.evaluate(ind); // this.m_Population.incrFunctionCalls(); } m_Population.set(m_Population.getIndexOfWorstIndividualNoConstr(fitIndex), ind, fitIndex); @@ -372,7 +372,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte public static final NelderMeadSimplex createNelderMeadSimplex(AbstractOptimizationProblem problem, InterfacePopulationChangedEventListener listener) { - problem.initProblem(); + problem.initializeProblem(); NelderMeadSimplex nms = new NelderMeadSimplex(); nms.setProblemAndPopSize(problem); @@ -407,14 +407,14 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte InterfacePopulationChangedEventListener listener) { // TODO this method might be superfluous when using PostProcess - problem.initProblem(); + problem.initializeProblem(); NelderMeadSimplex nms = new NelderMeadSimplex(); nms.setProblemAndPopSize(problem); Population initialPop; if (perturbationRatio <= 0) { // random case initialPop = new Population(nms.getPopulationSize()); - problem.initPopulation(initialPop); + problem.initializePopulation(initialPop); initialPop.set(0, candidate); } else { double[][] range = ((InterfaceDataTypeDouble) candidate).getDoubleRange(); diff --git a/src/eva2/optimization/strategies/NichePSO.java b/src/eva2/optimization/strategies/NichePSO.java index 9f4d83ed..99b67b12 100644 --- a/src/eva2/optimization/strategies/NichePSO.java +++ b/src/eva2/optimization/strategies/NichePSO.java @@ -1499,7 +1499,7 @@ public class NichePSO implements InterfaceAdditionalPopulationInformer, Interfac result += ((InterfaceMultimodalProblemKnown) m_Problem).getNumberOfFoundOptima(elitepop); result += "(" + ((InterfaceMultimodalProblemKnown) m_Problem).getRealOptima().size() + ")\t"; result += ((InterfaceMultimodalProblemKnown) m_Problem).getMaximumPeakRatio(elitepop) + "\t"; - //boolean[] opts = ((InterfaceMultimodalProblem)m_Problem).whichOptimaAreFound(elitepop); + //boolean[] opts = ((InterfaceMultimodalProblem)problem).whichOptimaAreFound(elitepop); //result += "Optima:"; //for (int i = 0; i < opts.length; ++i){ //result += String.valueOf(opts[i])+" "; diff --git a/src/eva2/optimization/strategies/PDDifferentialEvolution.java b/src/eva2/optimization/strategies/PDDifferentialEvolution.java index 2514d4b8..d55659d7 100644 --- a/src/eva2/optimization/strategies/PDDifferentialEvolution.java +++ b/src/eva2/optimization/strategies/PDDifferentialEvolution.java @@ -99,7 +99,7 @@ public class PDDifferentialEvolution implements InterfaceOptimizer, java.io.Seri @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); this.evaluatePopulation(this.m_Population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); } diff --git a/src/eva2/optimization/strategies/ParticleFilterOptimization.java b/src/eva2/optimization/strategies/ParticleFilterOptimization.java index ca574c7c..b32b567f 100644 --- a/src/eva2/optimization/strategies/ParticleFilterOptimization.java +++ b/src/eva2/optimization/strategies/ParticleFilterOptimization.java @@ -105,7 +105,7 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S (((AbstractOptimizationProblem) m_Problem).getIndividualTemplate()).setMutationOperator(new MutateESCorrVector(mutationSigma, initialVelocity, rotationDeg)); } m_Population.setTargetSize(popSize); - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); setWithShow(withShow); diff --git a/src/eva2/optimization/strategies/ParticleSubSwarmOptimization.java b/src/eva2/optimization/strategies/ParticleSubSwarmOptimization.java index 335d99a0..40a4d527 100644 --- a/src/eva2/optimization/strategies/ParticleSubSwarmOptimization.java +++ b/src/eva2/optimization/strategies/ParticleSubSwarmOptimization.java @@ -334,7 +334,7 @@ public class ParticleSubSwarmOptimization extends ParticleSwarmOptimizationGCPSO public void updateMaxPosDist(){ // compute the maximal possible distance in the search space: AbstractOptimizationProblem prob = (AbstractOptimizationProblem)m_Problem; - // m_Problem must have called initProblem, so that the template is set correctly. This shouls always be the case here... + // problem must have called initializeProblem, so that the template is set correctly. This shouls always be the case here... AbstractEAIndividual template = prob.getIndividualTemplate(); if (template == null){ System.out.println("Problem does not implement getIndividualTemplate, updateMaxPosDist could not infer dimensions"); diff --git a/src/eva2/optimization/strategies/ParticleSwarmOptimization.java b/src/eva2/optimization/strategies/ParticleSwarmOptimization.java index d32dfb76..0d9554ba 100644 --- a/src/eva2/optimization/strategies/ParticleSwarmOptimization.java +++ b/src/eva2/optimization/strategies/ParticleSwarmOptimization.java @@ -40,8 +40,6 @@ import java.util.Vector; * Possible topologies are: "Linear", "Grid", "Star", "Multi-Swarm", "Tree", * "HPSO", "Random" in that order starting by 0. * - * Created by IntelliJ IDEA. User: streiche Date: 28.10.2004 Time: 11:23:21 To - * change this template use File | Settings | File Templates. */ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Serializable, InterfaceAdditionalPopulationInformer { @@ -74,9 +72,6 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se protected int minSubSwarmSize = 2; protected int treeStruct = 1; protected boolean wrapTopology = true; -// protected boolean doLocalSearch = false; -// protected int localSearchGens=100; -// protected int lsStepsPerInd=200; protected int treeLevels, treeOrphans, treeLastFullLevelNodeCnt; protected int dmsRegroupInterval = 10; private transient Vector dmsLinks = null; @@ -211,7 +206,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se } tracedVelocity = null; if (!externalInitialPop) { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); } // evaluation needs to be done here now, as its omitted if reset is false initDefaults(this.m_Population); @@ -1382,7 +1377,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se //// Population bestN = m_Population.getSortedNIndividuals(Math.max(1,(int)(lsCandidateRatio*m_Population.size())), false); // Population cands=(Population)bestN.clone(); // int maxSteps=cands.size()*lsStepsPerInd; -// int stepsDone = PostProcess.processSingleCandidates(PostProcessMethod.nelderMead, cands, maxSteps, 0.01, (AbstractOptimizationProblem)this.m_Problem, null); +// int stepsDone = PostProcess.processSingleCandidates(PostProcessMethod.nelderMead, cands, maxSteps, 0.01, (AbstractOptimizationProblem)this.problem, null); // for (int i=0; i 1e-20) { System.err.println("Warning: mismatching best fitness by " + relDiff); System.err.println("partInfo: " + i + " - " + getParticleInfo(population.getEAIndividual(i))); diff --git a/src/eva2/optimization/strategies/PopulationBasedIncrementalLearning.java b/src/eva2/optimization/strategies/PopulationBasedIncrementalLearning.java index 607903aa..83eefdfa 100644 --- a/src/eva2/optimization/strategies/PopulationBasedIncrementalLearning.java +++ b/src/eva2/optimization/strategies/PopulationBasedIncrementalLearning.java @@ -66,7 +66,7 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); if ((m_initialProbabilities != null) && (m_initialProbabilities.length == ((PBILPopulation) m_Population).getProbabilityVector().length)) { ((PBILPopulation) m_Population).setProbabilityVector(m_initialProbabilities); } else { diff --git a/src/eva2/optimization/strategies/ScatterSearch.java b/src/eva2/optimization/strategies/ScatterSearch.java index ec9d67b4..54b95a6f 100644 --- a/src/eva2/optimization/strategies/ScatterSearch.java +++ b/src/eva2/optimization/strategies/ScatterSearch.java @@ -881,7 +881,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable, InterfaceTerminator term, String dataPrefix, AbstractOptimizationProblem problem, InterfacePopulationChangedEventListener listener) { -// problem.initProblem(); +// problem.initializeProblem(); GOParameters params = specialSS(localSearchSteps, localSearchFitnessFilter, nmInitPerturb, relativeFitCrit, refSetSize, problem, term); @@ -900,7 +900,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable, int refSetSize, AbstractOptimizationProblem problem, InterfaceTerminator term) { ScatterSearch ss = new ScatterSearch(); - problem.initProblem(); + problem.initializeProblem(); ss.setProblem(problem); ss.setRefSetSize(refSetSize); ss.setNelderMeadInitPerturbation(nmInitPerturb); @@ -915,7 +915,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable, Population pop = new Population(); pop.setTargetSize(refSetSize); pop.init(); - problem.initPopulation(pop); + problem.initializePopulation(pop); ss.initByPopulation(pop, true); return OptimizerFactory.makeParams(ss, pop, problem, 0, term); diff --git a/src/eva2/optimization/strategies/SimulatedAnnealing.java b/src/eva2/optimization/strategies/SimulatedAnnealing.java index 5c16f3e5..ed698cba 100644 --- a/src/eva2/optimization/strategies/SimulatedAnnealing.java +++ b/src/eva2/optimization/strategies/SimulatedAnnealing.java @@ -56,7 +56,7 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa */ @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); this.m_Problem.evaluate(this.m_Population); this.m_CurrentTemperature = this.m_InitialTemperature; this.firePropertyChangedEvent(Population.nextGenerationPerformed); diff --git a/src/eva2/optimization/strategies/SteadyStateGA.java b/src/eva2/optimization/strategies/SteadyStateGA.java index 1e8b7d21..7473037e 100644 --- a/src/eva2/optimization/strategies/SteadyStateGA.java +++ b/src/eva2/optimization/strategies/SteadyStateGA.java @@ -51,7 +51,7 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable { @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); this.evaluatePopulation(this.m_Population); this.firePropertyChangedEvent(Population.nextGenerationPerformed); } diff --git a/src/eva2/optimization/strategies/ThresholdAlgorithm.java b/src/eva2/optimization/strategies/ThresholdAlgorithm.java index 38b8cf0a..9d9c1a77 100644 --- a/src/eva2/optimization/strategies/ThresholdAlgorithm.java +++ b/src/eva2/optimization/strategies/ThresholdAlgorithm.java @@ -52,7 +52,7 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa */ @Override public void init() { - this.m_Problem.initPopulation(this.m_Population); + this.m_Problem.initializePopulation(this.m_Population); this.m_Problem.evaluate(this.m_Population); this.m_CurrentT = this.m_InitialT; this.firePropertyChangedEvent(Population.nextGenerationPerformed); diff --git a/src/eva2/optimization/strategies/Tribes.java b/src/eva2/optimization/strategies/Tribes.java index ad38b3fb..2a58f365 100644 --- a/src/eva2/optimization/strategies/Tribes.java +++ b/src/eva2/optimization/strategies/Tribes.java @@ -203,7 +203,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable { initRange = (double[][]) ((InterfaceHasInitRange) problem).getInitRange(); } Population pop = new Population(1); - problem.initPopulation(pop); + problem.initializePopulation(pop); setPopulation(pop); } diff --git a/src/eva2/optimization/strategies/WingedMultiObjectiveEA.java b/src/eva2/optimization/strategies/WingedMultiObjectiveEA.java index 85a73687..dc43bc9e 100644 --- a/src/eva2/optimization/strategies/WingedMultiObjectiveEA.java +++ b/src/eva2/optimization/strategies/WingedMultiObjectiveEA.java @@ -174,7 +174,7 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria this.m_Problem.evaluate(this.m_Population); this.m_Population.SetFunctionCalls(oldFunctionCalls); this.firePropertyChangedEvent(Population.nextGenerationPerformed); -// double plotValue = (this.m_Problem.getDoublePlotValue(this.m_Population)).doubleValue(); +// double plotValue = (this.problem.getDoublePlotValue(this.m_Population)).doubleValue(); // now they are synchronized lets migrate this.migrate(); } diff --git a/src/eva2/tools/math/StatisticUtils.java b/src/eva2/tools/math/StatisticUtils.java index 4d765259..c8e2a409 100644 --- a/src/eva2/tools/math/StatisticUtils.java +++ b/src/eva2/tools/math/StatisticUtils.java @@ -419,7 +419,7 @@ public class StatisticUtils { 439.128, 112.370,-422.820,-43.119,-297.609,-438.940, 488.914,-512.000,-407.847, 386.611}, { 395.772, 191.634,-511.999,-93.078,-282.853,-444.621, 491.291,-512.000,-407.620, 386.493}}; - vs[1]=Mathematics.rotate(vs[0], AbstractProblemDouble.initDefaultRotationMatrix(10, 10)); + vs[1]=Mathematics.rotate(vs[0], AbstractProblemDouble.initializeDefaultRotationMatrix(10, 10)); for (int i=0; i