Last RMI occurences have been removed. Free Willy is officially dead. Hooray! Also, code formatting :)
This commit is contained in:
@@ -772,15 +772,15 @@ public class EvAClient extends JFrame implements OptimizationStateListener {
|
||||
menuBar = new JMenuBar();
|
||||
setJMenuBar(menuBar);
|
||||
menuModule = new JExtMenu("&Module");
|
||||
menuModule.add(actModuleLoad);
|
||||
//menuModule.add(actModuleLoad);
|
||||
|
||||
menuSelHosts = new JExtMenu("&Select Hosts");
|
||||
menuSelHosts.setToolTipText("Select a host for the server application");
|
||||
menuSelHosts.add(actHost);
|
||||
menuSelHosts.add(actAvailableHost);
|
||||
menuSelHosts.addSeparator();
|
||||
menuSelHosts.add(actKillHost);
|
||||
menuSelHosts.add(actKillAllHosts);
|
||||
//menuSelHosts.setToolTipText("Select a host for the server application");
|
||||
//menuSelHosts.add(actHost);
|
||||
//menuSelHosts.add(actAvailableHost);
|
||||
//menuSelHosts.addSeparator();
|
||||
//menuSelHosts.add(actKillHost);
|
||||
//menuSelHosts.add(actKillAllHosts);
|
||||
|
||||
menuHelp = new JExtMenu("&Help");
|
||||
menuHelp.add(actHelp);
|
||||
@@ -790,13 +790,13 @@ public class EvAClient extends JFrame implements OptimizationStateListener {
|
||||
|
||||
menuOptions = new JExtMenu("&Options");
|
||||
menuOptions.add(actPreferences);
|
||||
menuOptions.add(menuSelHosts);
|
||||
//menuOptions.add(menuSelHosts);
|
||||
menuOptions.addSeparator();
|
||||
menuOptions.add(actQuit);
|
||||
// this is accessible if no default module is given
|
||||
if (showLoadModules) {
|
||||
menuBar.add(menuModule);
|
||||
}
|
||||
//if (showLoadModules) {
|
||||
// menuBar.add(menuModule);
|
||||
//}
|
||||
|
||||
menuBar.add(menuOptions);
|
||||
menuBar.add(((JExtDesktopPane) desktopPane).getWindowMenu());
|
||||
|
@@ -8,6 +8,6 @@ package eva2.server.go;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public interface InterfaceGOStandalone {
|
||||
public void startExperiment();
|
||||
public void setShow(boolean t);
|
||||
void startExperiment();
|
||||
void setShow(boolean t);
|
||||
}
|
||||
|
@@ -14,5 +14,5 @@ public interface InterfacePopulationChangedEventListener {
|
||||
* @param source The source of the event.
|
||||
* @param name Could be used to indicate the nature of the event.
|
||||
*/
|
||||
public void registerPopulationStateChanged(Object source, String name);
|
||||
void registerPopulationStateChanged(Object source, String name);
|
||||
}
|
||||
|
@@ -47,7 +47,6 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
private static final Logger LOGGER = Logger.getLogger(BOA.class.getName());
|
||||
transient private InterfacePopulationChangedEventListener m_Listener = null;
|
||||
private String m_Identifier = "BOA";
|
||||
|
||||
private int probDim = 8;
|
||||
private int fitCrit = -1;
|
||||
private int PopSize = 50;
|
||||
@@ -63,7 +62,6 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
private int count = 0;
|
||||
private String netFolder = "BOAOutput";
|
||||
private int[][] edgeRate = null;
|
||||
|
||||
private BOAScoringMethods scoringMethod = BOAScoringMethods.BDM;
|
||||
private boolean printNetworks = false;
|
||||
private boolean printEdgeRate = false;
|
||||
@@ -72,7 +70,6 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
// private boolean printExtraOutput = false;
|
||||
|
||||
public BOA() {
|
||||
|
||||
}
|
||||
|
||||
public BOA(int numberOfParents, int popSize, BOAScoringMethods method,
|
||||
@@ -185,11 +182,9 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
private static BitSet getBinaryData(AbstractEAIndividual indy) {
|
||||
if (indy instanceof InterfaceGAIndividual) {
|
||||
return ((InterfaceGAIndividual) indy).getBGenotype();
|
||||
}
|
||||
else if (indy instanceof InterfaceDataTypeBinary) {
|
||||
} else if (indy instanceof InterfaceDataTypeBinary) {
|
||||
return ((InterfaceDataTypeBinary) indy).getBinaryData();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
"Unable to get binary representation for "
|
||||
+ indy.getClass());
|
||||
@@ -200,8 +195,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
* evaluate the given Individual and increments the counter. if the
|
||||
* individual is null, only the counter is incremented
|
||||
*
|
||||
* @param indy
|
||||
* the individual you want to evaluate
|
||||
* @param indy the individual you want to evaluate
|
||||
*/
|
||||
private void evaluate(AbstractEAIndividual indy) {
|
||||
// evaluate the given individual if it is not null
|
||||
@@ -343,8 +337,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
* Generate a Bayesian network with the individuals of the population as a
|
||||
* reference Point
|
||||
*
|
||||
* @param pop
|
||||
* the individuals the network is based on
|
||||
* @param pop the individuals the network is based on
|
||||
*/
|
||||
private void constructNetwork(Population pop) {
|
||||
generateGreedy(pop);
|
||||
@@ -394,6 +387,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
/**
|
||||
* remove the individuals in pop from the population
|
||||
*
|
||||
* @param pop
|
||||
*/
|
||||
public void remove(Population pop) {
|
||||
@@ -627,15 +621,9 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
return "Bayesian Network";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// -------------GUI---------------
|
||||
// -------------------------------
|
||||
|
||||
public int getNumberOfParents() {
|
||||
return this.numberOfParents;
|
||||
}
|
||||
@@ -731,7 +719,6 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
// public boolean isPrintExtraOutput() {
|
||||
// return this.printExtraOutput;
|
||||
// }
|
||||
|
||||
// public void setPrintExtraOutput(boolean b) {
|
||||
// this.printExtraOutput = b;
|
||||
// GenericObjectEditor.setHideProperty(getClass(), "printNetworks",
|
||||
@@ -743,11 +730,9 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
// GenericObjectEditor.setHideProperty(getClass(), "printTimestamps",
|
||||
// !printExtraOutput);
|
||||
// }
|
||||
|
||||
// public String printExtraOutputTipText() {
|
||||
// return "do you want to print extra output files";
|
||||
// }
|
||||
|
||||
public boolean isPrintNetworks() {
|
||||
return this.printNetworks;
|
||||
}
|
||||
@@ -796,7 +781,6 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
return "Print the time starting time and a timestamp after each generation";
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Population pop = new Population();
|
||||
GAIndividualBinaryData indy1 = new GAIndividualBinaryData();
|
||||
@@ -980,5 +964,4 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
// b.print();
|
||||
// b.printNetworkToFile("test");
|
||||
}
|
||||
|
||||
}
|
@@ -30,15 +30,15 @@ import java.util.BitSet;
|
||||
*
|
||||
* @author Alex
|
||||
*
|
||||
* F. Gortazar, A. Duarte, M. Laguna and R. Marti: Black Box Scatter Search for General Classes of Binary Optimization Problems
|
||||
* Computers and Operations research, vol. 37, no. 11, pp. 1977-1986 (2010)
|
||||
* F. Gortazar, A. Duarte, M. Laguna and R. Marti: Black Box Scatter Search for
|
||||
* General Classes of Binary Optimization Problems Computers and Operations
|
||||
* research, vol. 37, no. 11, pp. 1977-1986 (2010)
|
||||
*/
|
||||
public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializable, InterfacePopulationChangedEventListener {
|
||||
|
||||
private static boolean TRACE = false;
|
||||
transient private InterfacePopulationChangedEventListener m_Listener = null;
|
||||
private String m_Identifier = "BinaryScatterSearch";
|
||||
|
||||
|
||||
private int MaxImpIter = 5;
|
||||
private int poolSize = 100;
|
||||
private int refSetSize = 10;
|
||||
@@ -63,7 +63,9 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new BinaryScatterSearch with the same parameters as the given BinaryScatterSearch
|
||||
* Create a new BinaryScatterSearch with the same parameters as the given
|
||||
* BinaryScatterSearch
|
||||
*
|
||||
* @param b
|
||||
*/
|
||||
public BinaryScatterSearch(BinaryScatterSearch b) {
|
||||
@@ -89,12 +91,15 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
|
||||
/**
|
||||
* Create a new BinaryScatterSearch with the given Parameters
|
||||
*
|
||||
* @param refSetS the refSetSize
|
||||
* @param poolS the poolSize
|
||||
* @param lowerThreshold the lower Boundary for the local Search
|
||||
* @param upperThreshold the upper Boundary for the local Search
|
||||
* @param perCentFirstIndGenerator how many individuals (in prospect of the poolSize) are generated through the first Generator
|
||||
* @param perCentSecondIndGenerator how many individuals (in prospect of the poolSize) are generated through the second Generator
|
||||
* @param perCentFirstIndGenerator how many individuals (in prospect of the
|
||||
* poolSize) are generated through the first Generator
|
||||
* @param perCentSecondIndGenerator how many individuals (in prospect of the
|
||||
* poolSize) are generated through the second Generator
|
||||
* @param prob the Problem
|
||||
*/
|
||||
public BinaryScatterSearch(
|
||||
@@ -111,12 +116,15 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
|
||||
/**
|
||||
* Create a new BinaryScatterSearch with the given Parameters
|
||||
*
|
||||
* @param refSetS the refSetSize
|
||||
* @param poolS the poolSize
|
||||
* @param lowerThreshold the lower Boundary for the local Search
|
||||
* @param upperThreshold the upper Boundary for the local Search
|
||||
* @param perCentFirstIndGenerator how many individuals (in prospect of the poolSize) are generated through the first Generator
|
||||
* @param perCentSecondIndGenerator how many individuals (in prospect of the poolSize) are generated through the second Generator
|
||||
* @param perCentFirstIndGenerator how many individuals (in prospect of the
|
||||
* poolSize) are generated through the first Generator
|
||||
* @param perCentSecondIndGenerator how many individuals (in prospect of the
|
||||
* poolSize) are generated through the second Generator
|
||||
* @param prob the Problem
|
||||
* @param cross the Crossover-Operators
|
||||
*/
|
||||
@@ -165,7 +173,9 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* evaluate the given Individual and increments the counter. if the individual is null, only the counter is incremented
|
||||
* evaluate the given Individual and increments the counter. if the
|
||||
* individual is null, only the counter is incremented
|
||||
*
|
||||
* @param indy the individual you want to evaluate
|
||||
*/
|
||||
private void evaluate(AbstractEAIndividual indy) {
|
||||
@@ -226,7 +236,8 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
/**
|
||||
*
|
||||
* @param pop the initial Population
|
||||
* @return a diversified Population with all the Individuals in the initial Population
|
||||
* @return a diversified Population with all the Individuals in the initial
|
||||
* Population
|
||||
*/
|
||||
private Population diversify(Population pop) {
|
||||
int numToInit = this.poolSize - pop.size();
|
||||
@@ -248,9 +259,10 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new Population with diverse Individuals starting with 000...000,
|
||||
* then 010101...01, 101010...10, 001001001...001, 110110110...110 and so on
|
||||
* The returned population is evaluated.
|
||||
* Generate a new Population with diverse Individuals starting with
|
||||
* 000...000, then 010101...01, 101010...10, 001001001...001,
|
||||
* 110110110...110 and so on The returned population is evaluated.
|
||||
*
|
||||
* @param pop the initial Population
|
||||
* @return the new Population
|
||||
*/
|
||||
@@ -263,8 +275,10 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new Population with diverse Individuals starting with 000...000, then 010101...01,
|
||||
* 101010...10, 001001001...001, 110110110...110 and so on
|
||||
* Generate a new Population with diverse Individuals starting with
|
||||
* 000...000, then 010101...01, 101010...10, 001001001...001,
|
||||
* 110110110...110 and so on
|
||||
*
|
||||
* @param pop the initial Population
|
||||
* @return the new Population
|
||||
*/
|
||||
@@ -303,7 +317,9 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate new Individuals that have the individuals of the given Population as a base
|
||||
* Generate new Individuals that have the individuals of the given
|
||||
* Population as a base
|
||||
*
|
||||
* @param pop the population
|
||||
* @return the new Population
|
||||
*/
|
||||
@@ -329,7 +345,9 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate new Individuals that have the individuals of the given Population as a base
|
||||
* Generate new Individuals that have the individuals of the given
|
||||
* Population as a base
|
||||
*
|
||||
* @param pop the population
|
||||
* @return the new Population
|
||||
*/
|
||||
@@ -355,7 +373,9 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate the number of individuals in the given Population that have a 1 at the i-th position
|
||||
* calculate the number of individuals in the given Population that have a 1
|
||||
* at the i-th position
|
||||
*
|
||||
* @param i the position
|
||||
* @param pop the population
|
||||
* @return The number of individuals that have a '1' on the i-th position
|
||||
@@ -373,7 +393,9 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate the number of individuals in the given Population that have a 0 at the i-th position
|
||||
* calculate the number of individuals in the given Population that have a 0
|
||||
* at the i-th position
|
||||
*
|
||||
* @param i the position
|
||||
* @param pop the population
|
||||
* @return The number of individuals that have a '0' on the i-th position
|
||||
@@ -393,17 +415,17 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
private static BitSet getBinaryData(AbstractEAIndividual indy) {
|
||||
if (indy instanceof InterfaceGAIndividual) {
|
||||
return ((InterfaceGAIndividual) indy).getBGenotype();
|
||||
}
|
||||
else if (indy instanceof InterfaceDataTypeBinary) {
|
||||
} else if (indy instanceof InterfaceDataTypeBinary) {
|
||||
return ((InterfaceDataTypeBinary) indy).getBinaryData();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new RuntimeException("Unable to get binary representation for " + indy.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate the sum of all the FitnessValues of the individuals that have a '0' at the i-th position
|
||||
* calculate the sum of all the FitnessValues of the individuals that have a
|
||||
* '0' at the i-th position
|
||||
*
|
||||
* @param i the position
|
||||
* @param pop the population
|
||||
* @return the sum
|
||||
@@ -421,7 +443,9 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate the sum of all the FitnessValues of the individuals that have a '0' at the i-th position
|
||||
* calculate the sum of all the FitnessValues of the individuals that have a
|
||||
* '0' at the i-th position
|
||||
*
|
||||
* @param i the position
|
||||
* @param pop the population
|
||||
* @return the sum
|
||||
@@ -439,9 +463,11 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates a score that gives a reference Point if the Bit on the i-th position is right.
|
||||
* If the bit is set to '1' and you get a high score then the Bit is probably set correct.
|
||||
* If the bit is set to '0' and you get a low score then the Bit is probably set correct.
|
||||
* calculates a score that gives a reference Point if the Bit on the i-th
|
||||
* position is right. If the bit is set to '1' and you get a high score then
|
||||
* the Bit is probably set correct. If the bit is set to '0' and you get a
|
||||
* low score then the Bit is probably set correct.
|
||||
*
|
||||
* @param i the position
|
||||
* @param pop the population
|
||||
* @return the score
|
||||
@@ -455,9 +481,9 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* calculate the first RefSet with the given Population as a reference Point
|
||||
*
|
||||
* @param pop the generated Pool
|
||||
*/
|
||||
private void initRefSet(Population pop) {
|
||||
@@ -479,6 +505,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
|
||||
/**
|
||||
* Update the reference Set
|
||||
*
|
||||
* @param replaceWorstHalf replaces the worst half of the RefSet if set
|
||||
* @return has the Population changed
|
||||
*/
|
||||
@@ -531,6 +558,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
|
||||
/**
|
||||
* Order the given List according to the score of the given values
|
||||
*
|
||||
* @param list the initial List
|
||||
* @return the ordered List
|
||||
*/
|
||||
@@ -557,6 +585,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
|
||||
/**
|
||||
* Do a local search
|
||||
*
|
||||
* @param indy the individual that will be improved
|
||||
* @return the new improved individual
|
||||
*/
|
||||
@@ -621,6 +650,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
|
||||
/**
|
||||
* Combine all the individuals in the reference Set (always 2)
|
||||
*
|
||||
* @return the List with all the combinations
|
||||
*/
|
||||
public ArrayList<Population> generateSubsets() {
|
||||
@@ -638,6 +668,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
|
||||
/**
|
||||
* combine the first individual with the second one
|
||||
*
|
||||
* @param pop the Population
|
||||
* @return the new Individual
|
||||
*/
|
||||
@@ -664,6 +695,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
|
||||
/**
|
||||
* look if the individual is already in the population
|
||||
*
|
||||
* @param indy the Individual to be tested
|
||||
* @param pop the population in where to search
|
||||
* @return is the individual already in the Population
|
||||
@@ -771,12 +803,6 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
return "BinaryScatterSearch";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
this.m_Listener.registerPopulationStateChanged(this, name);
|
||||
@@ -797,7 +823,6 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
}
|
||||
|
||||
//----------GUI----------
|
||||
|
||||
public int getPoolSize() {
|
||||
return this.poolSize;
|
||||
}
|
||||
@@ -850,7 +875,6 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
return this.cross;
|
||||
}
|
||||
|
||||
|
||||
public void setCrossoverMethods(AdaptiveCrossoverEAMixer c) {
|
||||
this.cross = c;
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package eva2.server.go.strategies;
|
||||
|
||||
|
||||
import eva2.server.go.InterfacePopulationChangedEventListener;
|
||||
import eva2.server.go.individuals.AbstractEAIndividual;
|
||||
import eva2.server.go.individuals.InterfaceGAIndividual;
|
||||
@@ -15,22 +14,22 @@ import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
import java.util.BitSet;
|
||||
|
||||
/** This is an implementation of the CHC Adaptive Search Algorithm by Eshelman. It is
|
||||
* limited to binary data and is based on massively disruptive crossover. I'm not
|
||||
* sure whether i've implemented this correctly, but i definitely wasn't able to make
|
||||
* it competitive to a standard GA.. *sigh*
|
||||
* This is a implementation of the CHC Adaptive Search Algorithm (Cross generational
|
||||
/**
|
||||
* This is an implementation of the CHC Adaptive Search Algorithm by Eshelman.
|
||||
* It is limited to binary data and is based on massively disruptive crossover.
|
||||
* I'm not sure whether i've implemented this correctly, but i definitely wasn't
|
||||
* able to make it competitive to a standard GA.. *sigh* This is a
|
||||
* implementation of the CHC Adaptive Search Algorithm (Cross generational
|
||||
* elitist selection, Heterogeneous recombination and Cataclysmic mutation).
|
||||
* Citation:
|
||||
*
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
|
||||
* Architecture
|
||||
*
|
||||
* @author Felix Streichert
|
||||
* @version: $Revision: 307 $
|
||||
* $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
* @version: $Revision: 307 $ $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec
|
||||
* 2007) $ $Author: mkron $
|
||||
*/
|
||||
|
||||
public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
private double m_InitialDifferenceThreshold = 0.25;
|
||||
@@ -42,7 +41,6 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
private InterfaceOptimizationProblem m_Problem = new B1Problem();
|
||||
private InterfaceSelection m_RecombSelectionOperator = new SelectRandom();
|
||||
private InterfaceSelection m_PopulSelectionOperator = new SelectBestSingle();
|
||||
|
||||
transient private String m_Identifier = "";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
|
||||
@@ -80,7 +78,9 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -103,8 +103,9 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will evaluate the current population using the
|
||||
* given problem.
|
||||
/**
|
||||
* This method will evaluate the current population using the given problem.
|
||||
*
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void evaluatePopulation(Population population) {
|
||||
@@ -112,8 +113,9 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
population.incrGeneration();
|
||||
}
|
||||
|
||||
/** This method will generate the offspring population from the
|
||||
* given population of evaluated individuals.
|
||||
/**
|
||||
* This method will generate the offspring population from the given
|
||||
* population of evaluated individuals.
|
||||
*/
|
||||
private Population generateChildren() {
|
||||
Population result = this.m_Population.cloneWithoutInds(), parents, partners;
|
||||
@@ -149,7 +151,9 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method computes the Hamming Distance between n-Individuals
|
||||
/**
|
||||
* This method computes the Hamming Distance between n-Individuals
|
||||
*
|
||||
* @param dad
|
||||
* @param partners
|
||||
* @return The maximal Hamming Distance between dad and the partners
|
||||
@@ -172,8 +176,10 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method method replaces the current population with copies of the current
|
||||
* best individual but all but one are randomized with a very high mutation rate.
|
||||
/**
|
||||
* This method method replaces the current population with copies of the
|
||||
* current best individual but all but one are randomized with a very high
|
||||
* mutation rate.
|
||||
*/
|
||||
private void diverge() {
|
||||
AbstractEAIndividual best = this.m_Population.getBestEAIndividual();
|
||||
@@ -189,8 +195,7 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
if (RNG.flipCoin(this.m_DivergenceRate)) {
|
||||
if (tmpBitSet.get(j)) {
|
||||
tmpBitSet.clear(j);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tmpBitSet.set(j);
|
||||
}
|
||||
}
|
||||
@@ -237,6 +242,7 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -248,7 +254,8 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
}
|
||||
}
|
||||
|
||||
/** Something has changed
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -256,20 +263,25 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -282,36 +294,37 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is an implementation of the CHC Adaptive Search Algorithm by Eselman.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -319,19 +332,23 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
return "CHC";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Edit the properties of the population used.";
|
||||
}
|
||||
@@ -353,21 +370,26 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
// public String normationMethodTipText() {
|
||||
// return "Select the normation method.";
|
||||
// }
|
||||
|
||||
/** Enable/disable elitism.
|
||||
/**
|
||||
* Enable/disable elitism.
|
||||
*
|
||||
* @param elitism
|
||||
*/
|
||||
public void setElitism(boolean elitism) {
|
||||
this.m_UseElitism = elitism;
|
||||
}
|
||||
|
||||
public boolean getElitism() {
|
||||
return this.m_UseElitism;
|
||||
}
|
||||
|
||||
public String elitismTipText() {
|
||||
return "Enable/disable elitism.";
|
||||
}
|
||||
|
||||
/** The number of mating partners needed to create offsprings.
|
||||
/**
|
||||
* The number of mating partners needed to create offsprings.
|
||||
*
|
||||
* @param partners
|
||||
*/
|
||||
public void setNumberOfPartners(int partners) {
|
||||
@@ -376,9 +398,11 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
}
|
||||
this.m_NumberOfPartners = partners;
|
||||
}
|
||||
|
||||
public int getNumberOfPartners() {
|
||||
return this.m_NumberOfPartners;
|
||||
}
|
||||
|
||||
public String numberOfPartnersTipText() {
|
||||
return "The number of mating partners needed to create offsprings.";
|
||||
}
|
||||
|
@@ -41,47 +41,44 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
/** The infamous clustering based niching EA, still under construction.
|
||||
* It should be able to identify and track multiple global/local optima
|
||||
* at the same time.
|
||||
/**
|
||||
* The infamous clustering based niching EA, still under construction. It should
|
||||
* be able to identify and track multiple global/local optima at the same time.
|
||||
*
|
||||
* Notes: For std. GA, the mutation rate may have to reduced, because the
|
||||
* initial step size tends to be rel. large and easily disperse clustered
|
||||
* species (so that they fall below the minimum swarm size and the local
|
||||
* optimum is lost).
|
||||
* species (so that they fall below the minimum swarm size and the local optimum
|
||||
* is lost).
|
||||
*
|
||||
* For the CBN-PSO remember to use the IndividualDataMetric so that the
|
||||
* remembered positions are used for clustering (which are rel. stable -
|
||||
* so that species clustering actually makes sense).
|
||||
* remembered positions are used for clustering (which are rel. stable - so that
|
||||
* species clustering actually makes sense).
|
||||
*
|
||||
* Copyright: Copyright (c) 2010 Company: University of Tuebingen, Computer
|
||||
* Architecture
|
||||
*
|
||||
* Copyright: Copyright (c) 2010
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Felix Streichert, Marcel Kronfeld
|
||||
*/
|
||||
|
||||
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<Population> m_Species = new ArrayList<Population>();
|
||||
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 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;
|
||||
@@ -93,7 +90,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
private int m_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;
|
||||
@@ -103,7 +99,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
private int m_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
|
||||
|
||||
@@ -113,10 +108,10 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// if (useDistraction) distraction = new Distraction(distrDefaultStrength, Distraction.METH_BEST);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for InterfaceParamControllable
|
||||
*/
|
||||
|
||||
public Object[] getParamControl() {
|
||||
List<Object> ctrlbls = ParameterControlManager.listOfControllables(this);
|
||||
ctrlbls.add(paramControl);
|
||||
@@ -127,18 +122,20 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
|
||||
/**
|
||||
* This method is necessary to allow access from the Processor.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// public ParameterControlManager getParamControl() {
|
||||
// return paramControl;
|
||||
// }
|
||||
|
||||
public ParamAdaption[] getParameterControl() {
|
||||
return paramControl.getSingleAdapters();
|
||||
}
|
||||
|
||||
public void setParameterControl(ParamAdaption[] paramControl) {
|
||||
this.paramControl.setSingleAdapters(paramControl);
|
||||
}
|
||||
|
||||
public String parameterControlTipText() {
|
||||
return "You may define dynamic paramter control strategies using the parameter name.";
|
||||
}
|
||||
@@ -184,8 +181,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
public void init() {
|
||||
if (m_Undifferentiated == null) {
|
||||
this.m_Undifferentiated = new Population(m_PopulationSize);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
m_Undifferentiated.resetProperties();
|
||||
m_Undifferentiated.setTargetSize(m_PopulationSize);
|
||||
}
|
||||
@@ -236,7 +232,9 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
this.firePropertyChangedEvent("FirstGenerationPerformed");
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -249,8 +247,9 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
initDefaults(reset);
|
||||
}
|
||||
|
||||
/** This method will evaluate the current population using the
|
||||
* given problem.
|
||||
/**
|
||||
* This method will evaluate the current population using the given problem.
|
||||
*
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void evaluatePopulation(Population population) {
|
||||
@@ -352,14 +351,12 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
double[] pos1, pos2;
|
||||
if (indy1 instanceof InterfaceDataTypeDouble) {
|
||||
pos1 = ((InterfaceDataTypeDouble) indy1).getDoubleData();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pos1 = (indy1).getDoublePosition();
|
||||
}
|
||||
if (indy2 instanceof InterfaceDataTypeDouble) {
|
||||
pos2 = ((InterfaceDataTypeDouble) indy2).getDoubleData();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pos2 = (indy2).getDoublePosition();
|
||||
}
|
||||
tp.getFunctionArea().drawLine(pos1, pos2);
|
||||
@@ -380,7 +377,9 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
p.getFunctionArea().addDElement(popRep);
|
||||
}
|
||||
|
||||
/** This method is called to generate n freshly initialized individuals
|
||||
/**
|
||||
* This method is called to generate n freshly initialized individuals
|
||||
*
|
||||
* @param n Number of new individuals
|
||||
* @return A population of new individuals
|
||||
*/
|
||||
@@ -397,8 +396,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks whether a species is converged, i.e. the best fitness has not improved
|
||||
* for a number of generations.
|
||||
* This method checks whether a species is converged, i.e. the best fitness
|
||||
* has not improved for a number of generations.
|
||||
*
|
||||
* @param pop The species to test
|
||||
* @return True if converged.
|
||||
@@ -459,14 +458,16 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the criterion by which individual improvement is judged. The original version defined
|
||||
* improvement strictly, but for some EA this should be done more laxly. E.g. DE will hardly ever
|
||||
* stop improving slightly, so optionally use an epsilon-bound: improvement only counts if it is
|
||||
* larger than epsilon in case useEpsilonBound is true.
|
||||
* Define the criterion by which individual improvement is judged. The
|
||||
* original version defined improvement strictly, but for some EA this
|
||||
* should be done more laxly. E.g. DE will hardly ever stop improving
|
||||
* slightly, so optionally use an epsilon-bound: improvement only counts if
|
||||
* it is larger than epsilon in case useEpsilonBound is true.
|
||||
*
|
||||
* @param firstIndy
|
||||
* @param secIndy
|
||||
* @return true if the second individual has improved in relation to the first one
|
||||
* @return true if the second individual has improved in relation to the
|
||||
* first one
|
||||
*/
|
||||
private boolean testSecondForImprovement(AbstractEAIndividual firstIndy, AbstractEAIndividual secIndy) {
|
||||
if (epsilonBound > 0) {
|
||||
@@ -938,7 +939,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// pop.synchSize();
|
||||
// return pop;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Replace the undifferentiated population with the given one.
|
||||
*
|
||||
@@ -971,8 +971,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge two species by adding the second to the first. Keep the longer history. The second
|
||||
* species should be deactivated after merging.
|
||||
* Merge two species by adding the second to the first. Keep the longer
|
||||
* history. The second species should be deactivated after merging.
|
||||
*
|
||||
* @param pop1
|
||||
* @param pop2
|
||||
@@ -997,7 +997,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
}
|
||||
|
||||
/**
|
||||
* A split event will reset the new species model so as to have a fresh start.
|
||||
* A split event will reset the new species model so as to have a fresh
|
||||
* start.
|
||||
*
|
||||
* @param parentSp
|
||||
* @param newSp
|
||||
@@ -1028,7 +1029,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// protected boolean isActive(Population pop) {
|
||||
// return (pop.size() >= m_actSpecSize);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Deactivate a given species by removing all individuals and inserting
|
||||
// * only the given survivor, sets the population size to one.
|
||||
@@ -1042,7 +1042,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// spec.add(survivor);
|
||||
// spec.setPopulationSize(1);
|
||||
// }
|
||||
|
||||
// public int countActiveSpec() {
|
||||
// int k = 0;
|
||||
// for (int i=0; i<m_Species.size(); i++) {
|
||||
@@ -1050,8 +1049,9 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// }
|
||||
// return k;
|
||||
// }
|
||||
|
||||
/** This method allows an optimizer to register a change in the optimizer.
|
||||
/**
|
||||
* This method allows an optimizer to register a change in the optimizer.
|
||||
*
|
||||
* @param source The source of the event.
|
||||
* @param name Could be used to indicate the nature of the event.
|
||||
*/
|
||||
@@ -1064,6 +1064,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -1074,13 +1075,16 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
this.m_Listener.registerPopulationStateChanged(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@@ -1088,13 +1092,16 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
this.m_Problem = problem;
|
||||
this.m_Optimizer.setProblem(this.m_Problem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -1107,36 +1114,37 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is a versatile species based niching EA method.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -1209,28 +1217,34 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// public String applyClearingTipText() {
|
||||
// return "Clearing removes all but the best individuals from an identified species.";
|
||||
// }
|
||||
|
||||
/** This method allows you to set/get the switch that toggles the use
|
||||
* of species convergence.
|
||||
/**
|
||||
* This method allows you to set/get the switch that toggles the use of
|
||||
* species convergence.
|
||||
*
|
||||
* @return The current status of this flag
|
||||
*/
|
||||
public boolean isUseMerging() {
|
||||
return this.m_mergeSpecies;
|
||||
}
|
||||
|
||||
public void setUseMerging(boolean b) {
|
||||
this.m_mergeSpecies = b;
|
||||
GenericObjectEditor.setHideProperty(this.getClass(), "mergingCA", !m_mergeSpecies);
|
||||
}
|
||||
|
||||
public String useMergingTipText() {
|
||||
return "Toggle the use of species merging.";
|
||||
}
|
||||
|
||||
/** Choose a population based optimizing technique to use
|
||||
/**
|
||||
* Choose a population based optimizing technique to use
|
||||
*
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public InterfaceOptimizer getOptimizer() {
|
||||
return this.m_Optimizer;
|
||||
}
|
||||
|
||||
public void setOptimizer(InterfaceOptimizer b) {
|
||||
this.m_Optimizer = b;
|
||||
if (b instanceof EvolutionStrategies) {
|
||||
@@ -1238,32 +1252,41 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
setMuLambdaRatio(es.getMu() / (double) es.getLambda());
|
||||
}
|
||||
}
|
||||
|
||||
public String optimizerTipText() {
|
||||
return "Choose a population based optimizing technique to use.";
|
||||
}
|
||||
|
||||
/** The cluster algorithm on which the species differentiation is based
|
||||
/**
|
||||
* The cluster algorithm on which the species differentiation is based
|
||||
*
|
||||
* @return The current clustering method
|
||||
*/
|
||||
public InterfaceClustering getDifferentiationCA() {
|
||||
return this.m_CAForSpeciesDifferentation;
|
||||
}
|
||||
|
||||
public void setDifferentiationCA(InterfaceClustering b) {
|
||||
this.m_CAForSpeciesDifferentation = b;
|
||||
}
|
||||
|
||||
public String differentiationCATipText() {
|
||||
return "The cluster algorithm on which the species differentation is based.";
|
||||
}
|
||||
|
||||
/** The Cluster Algorithm on which the species convergence is based.
|
||||
/**
|
||||
* The Cluster Algorithm on which the species convergence is based.
|
||||
*
|
||||
* @return The current clustering method
|
||||
*/
|
||||
public InterfaceClustering getMergingCA() {
|
||||
return this.m_CAForSpeciesMerging;
|
||||
}
|
||||
|
||||
public void setMergingCA(InterfaceClustering b) {
|
||||
this.m_CAForSpeciesMerging = b;
|
||||
}
|
||||
|
||||
public String mergingCATipText() {
|
||||
return "The cluster algorithm on which the species merging is based.";
|
||||
}
|
||||
@@ -1277,44 +1300,58 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// public String useArchiveTipText() {
|
||||
// return "Toggle usage of an archive where converged species are saved and the individuals reinitialized.";
|
||||
// }
|
||||
|
||||
/** Determines how often species differentation/convergence is performed.
|
||||
* @return This number gives the generations when specification is performed.
|
||||
/**
|
||||
* Determines how often species differentation/convergence is performed.
|
||||
*
|
||||
* @return This number gives the generations when specification is
|
||||
* performed.
|
||||
*/
|
||||
public int getSpeciesCycle() {
|
||||
return this.m_SpeciesCycle;
|
||||
}
|
||||
|
||||
public void setSpeciesCycle(int b) {
|
||||
this.m_SpeciesCycle = b;
|
||||
}
|
||||
|
||||
public String speciesCycleTipText() {
|
||||
return "Determines how often species differentation/convergence is performed.";
|
||||
}
|
||||
|
||||
/** TDetermines how often show is performed.
|
||||
* @return This number gives the generations when specification is performed.
|
||||
/**
|
||||
* TDetermines how often show is performed.
|
||||
*
|
||||
* @return This number gives the generations when specification is
|
||||
* performed.
|
||||
*/
|
||||
public int getShowCycle() {
|
||||
return this.m_ShowCycle;
|
||||
}
|
||||
|
||||
public void setShowCycle(int b) {
|
||||
this.m_ShowCycle = b;
|
||||
if (b <= 0) {
|
||||
m_Topology = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String showCycleTipText() {
|
||||
return "Determines how often show is performed (generations); set to zero to deactivate.";
|
||||
}
|
||||
/** Determines the size of the initial population.
|
||||
|
||||
/**
|
||||
* Determines the size of the initial population.
|
||||
*
|
||||
* @return This number gives initial population size.
|
||||
*/
|
||||
public int getPopulationSize() {
|
||||
return this.m_PopulationSize;
|
||||
}
|
||||
|
||||
public void setPopulationSize(int b) {
|
||||
this.m_PopulationSize = b;
|
||||
}
|
||||
|
||||
public String populationSizeTipText() {
|
||||
return "Determines the size of the initial population.";
|
||||
}
|
||||
@@ -1329,9 +1366,9 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// public double getMuLambdaRatio() {
|
||||
// return muLambdaRatio;
|
||||
// }
|
||||
|
||||
/**
|
||||
* This is now set if an ES is set as optimizer.
|
||||
*
|
||||
* @param muLambdaRatio the muLambdaRatio to set
|
||||
*/
|
||||
public void setMuLambdaRatio(double muLambdaRatio) {
|
||||
@@ -1369,7 +1406,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// public void setDistractionActive(boolean useDistraction) {
|
||||
// this.useDistraction = useDistraction;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @return the distrDefaultStrength
|
||||
// */
|
||||
@@ -1384,19 +1420,20 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// this.distrDefaultStrength = distrDefaultStrength;
|
||||
// distraction.setDefaultStrength(distrDefaultStrength);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return the sleepTime
|
||||
*/
|
||||
public int getSleepTime() {
|
||||
return sleepTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sleepTime the sleepTime to set
|
||||
*/
|
||||
public void setSleepTime(int sleepTime) {
|
||||
this.sleepTime = sleepTime;
|
||||
}
|
||||
|
||||
public String sleepTimeTipText() {
|
||||
return "Let the thread sleep between iterations (nice when visualizing)";
|
||||
}
|
||||
@@ -1407,12 +1444,14 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
public double getEpsilonBound() {
|
||||
return epsilonBound;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param epsilonBound the epsilonBound to set
|
||||
*/
|
||||
public void setEpsilonBound(double epsilonBound) {
|
||||
this.epsilonBound = epsilonBound;
|
||||
}
|
||||
|
||||
public String epsilonBoundTipText() {
|
||||
return "If fitness improves less than this value within the halting window, convergence is assumed. May be set to zero.";
|
||||
}
|
||||
@@ -1453,14 +1492,15 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate average of Population measures (mean, minimal and maximal distance within a species)
|
||||
* Calculate average of Population measures (mean, minimal and maximal
|
||||
* distance within a species)
|
||||
*
|
||||
* @return average population measures
|
||||
*/
|
||||
protected double[] getAvgSpeciesMeasures() {
|
||||
if (m_Species == null || (m_Species.size() == 0)) {
|
||||
return new double[]{0};
|
||||
}
|
||||
else {
|
||||
} 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);
|
||||
@@ -1475,10 +1515,12 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
public int getMaxSpeciesSize() {
|
||||
return m_maxSpeciesSize;
|
||||
}
|
||||
|
||||
public void setMaxSpeciesSize(int mMaxSpeciesSize) {
|
||||
m_maxSpeciesSize = mMaxSpeciesSize;
|
||||
GenericObjectEditor.setShowProperty(this.getClass(), "reduceSizeComparator", (m_maxSpeciesSize >= m_minGroupSize));
|
||||
}
|
||||
|
||||
public String maxSpeciesSizeTipText() {
|
||||
return "If >= " + m_minGroupSize + ", larger species are reduced to the given size by reinitializing the worst individuals.";
|
||||
}
|
||||
@@ -1486,9 +1528,11 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
public String reduceSizeComparatorTipText() {
|
||||
return "Set the comparator used to define the 'worst' individuals when reducing species size.";
|
||||
}
|
||||
|
||||
public AbstractEAIndividualComparator getReduceSizeComparator() {
|
||||
return reduceSizeComparator;
|
||||
}
|
||||
|
||||
public void setReduceSizeComparator(
|
||||
AbstractEAIndividualComparator reduceSizeComparator) {
|
||||
this.reduceSizeComparator = reduceSizeComparator;
|
||||
@@ -1523,10 +1567,11 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
|
||||
/**
|
||||
* Calculate the clustering parameter in such a way that about one q-th part
|
||||
* of the range of the given problem is within one hyper sphere of the clustering parameter.
|
||||
* of the range of the given problem is within one hyper sphere of the
|
||||
* clustering parameter.
|
||||
*
|
||||
* For certain types of parameter adaption schemes, this automatically sets the upper limit
|
||||
* if the clustering parameter is controlled.
|
||||
* For certain types of parameter adaption schemes, this automatically sets
|
||||
* the upper limit if the clustering parameter is controlled.
|
||||
*
|
||||
* @param prob
|
||||
* @param q
|
||||
|
@@ -16,27 +16,29 @@ import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.Pair;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* The clustering hill climber is similar to a multi-start hill climber. In addition so optimizing
|
||||
* a set of individuals in parallel using a (1+1) strategy, the population is clustered in regular
|
||||
* intervals. If several individuals have gathered together in the sense that they are interpreted
|
||||
* as a cluster, only a subset of representatives of the cluster is taken over to the next HC step
|
||||
* while the rest is discarded. This means that the population size may be reduced.
|
||||
* The clustering hill climber is similar to a multi-start hill climber. In
|
||||
* addition so optimizing a set of individuals in parallel using a (1+1)
|
||||
* strategy, the population is clustered in regular intervals. If several
|
||||
* individuals have gathered together in the sense that they are interpreted as
|
||||
* a cluster, only a subset of representatives of the cluster is taken over to
|
||||
* the next HC step while the rest is discarded. This means that the population
|
||||
* size may be reduced.
|
||||
*
|
||||
* As soon as the improvement by HC lies below a threshold, the mutation step size is decreased.
|
||||
* If the step size is decreased below a certain threshold, the current population is stored to
|
||||
* an archive and reinitialized. Thus, the number of optima that may be found and returned by
|
||||
* getAllSolutions is higher than the population size.
|
||||
* As soon as the improvement by HC lies below a threshold, the mutation step
|
||||
* size is decreased. If the step size is decreased below a certain threshold,
|
||||
* the current population is stored to an archive and reinitialized. Thus, the
|
||||
* number of optima that may be found and returned by getAllSolutions is higher
|
||||
* than the population size.
|
||||
*
|
||||
* @author mkron
|
||||
*
|
||||
*/
|
||||
public class ClusteringHillClimbing implements InterfacePopulationChangedEventListener,
|
||||
InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
public static final boolean TRACE = false;
|
||||
|
||||
transient private String m_Identifier = "";
|
||||
private Population m_Population = new Population();
|
||||
private transient Population archive = new Population();
|
||||
@@ -101,18 +103,22 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
@@ -122,6 +128,7 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -132,6 +139,7 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
loopCnt = 0;
|
||||
@@ -145,7 +153,9 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -161,7 +171,8 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
}
|
||||
}
|
||||
|
||||
/** Something has changed
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -181,8 +192,7 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
int evalsNow, lastOverhead = (m_Population.getFunctionCalls() % hcEvalCycle);
|
||||
if (lastOverhead > 0) {
|
||||
evalsNow = (2 * hcEvalCycle - (m_Population.getFunctionCalls() % hcEvalCycle));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
evalsNow = hcEvalCycle;
|
||||
}
|
||||
do {
|
||||
@@ -267,19 +277,23 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Change the number of starting individuals stored (Cluster-HC).";
|
||||
}
|
||||
@@ -295,8 +309,10 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
return new SolutionSet(m_Population, tmp);
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -310,17 +326,14 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeWilly() {}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ClustHC-" + initialPopSize + "-" + localSearchMethod;
|
||||
}
|
||||
|
||||
public static String globalInfo() {
|
||||
return "Similar to multi-start HC, but clusters the population during optimization to remove redundant individuals for efficiency." +
|
||||
"If the local search step does not achieve a minimum improvement, the population may be reinitialized.";
|
||||
return "Similar to multi-start HC, but clusters the population during optimization to remove redundant individuals for efficiency."
|
||||
+ "If the local search step does not achieve a minimum improvement, the population may be reinitialized.";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -21,12 +21,12 @@ import eva2.tools.math.RNG;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Differential evolution implementing DE1 and DE2 following the paper of Storm and
|
||||
* Price and the Trigonometric DE published recently.
|
||||
* Please note that DE will only work on real-valued genotypes and will ignore
|
||||
* all mutation and crossover operators selected.
|
||||
* Added aging mechanism to provide for dynamically changing problems. If an individual
|
||||
* reaches the age limit, it is doomed and replaced by the next challenge vector, even if its worse.
|
||||
* Differential evolution implementing DE1 and DE2 following the paper of Storm
|
||||
* and Price and the Trigonometric DE published recently. Please note that DE
|
||||
* will only work on real-valued genotypes and will ignore all mutation and
|
||||
* crossover operators selected. Added aging mechanism to provide for
|
||||
* dynamically changing problems. If an individual reaches the age limit, it is
|
||||
* doomed and replaced by the next challenge vector, even if its worse.
|
||||
*
|
||||
*/
|
||||
public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serializable {
|
||||
@@ -44,7 +44,6 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
// to log the parents of a newly created indy.
|
||||
public boolean doLogParents = false; // deactivate for better performance
|
||||
private transient Vector<AbstractEAIndividual> parents = null;
|
||||
|
||||
private boolean randomizeFKLambda = false;
|
||||
private boolean generational = true;
|
||||
private String m_Identifier = "";
|
||||
@@ -110,7 +109,9 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
setDEType(getDEType());
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -126,8 +127,9 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
// else children = new Population(m_Population.size());
|
||||
}
|
||||
|
||||
/** This method will evaluate the current population using the
|
||||
* given problem.
|
||||
/**
|
||||
* This method will evaluate the current population using the given problem.
|
||||
*
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void evaluatePopulation(Population population) {
|
||||
@@ -136,8 +138,8 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a difference vector between two random individuals from the population.
|
||||
* This method should make sure that delta is not zero.
|
||||
* This method returns a difference vector between two random individuals
|
||||
* from the population. This method should make sure that delta is not zero.
|
||||
*
|
||||
* @param pop The population to choose from
|
||||
* @return The delta vector
|
||||
@@ -178,8 +180,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
for (int i = 0; i < x1.length; i++) {
|
||||
if (RNG.flipCoin(1 / (double) x1.length)) {
|
||||
result[i] = 0.01 * RNG.gaussianDouble(0.1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result[i] = 0;
|
||||
}
|
||||
isEmpty = (isEmpty && (result[i] == 0));
|
||||
@@ -191,8 +192,8 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a difference vector between two random individuals from the population.
|
||||
* This method should make sure that delta is not zero.
|
||||
* This method returns a difference vector between two random individuals
|
||||
* from the population. This method should make sure that delta is not zero.
|
||||
*
|
||||
* @param pop The population to choose from
|
||||
* @return The delta vector
|
||||
@@ -234,8 +235,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
for (int i = 0; i < x1.length; i++) {
|
||||
if (RNG.flipCoin(1 / (double) x1.length)) {
|
||||
result[i] = 0.01 * RNG.gaussianDouble(0.1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result[i] = 0;
|
||||
}
|
||||
isEmpty = (isEmpty && (result[i] == 0));
|
||||
@@ -283,7 +283,9 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method returns two parents to the original individual
|
||||
/**
|
||||
* This method returns two parents to the original individual
|
||||
*
|
||||
* @param pop The population to choose from
|
||||
* @return the delta vector
|
||||
*/
|
||||
@@ -301,8 +303,9 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
// result[1] = indy2.getDGenotype();
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/** This method will generate one new individual from the given population
|
||||
/**
|
||||
* This method will generate one new individual from the given population
|
||||
*
|
||||
* @param pop The current population
|
||||
* @return AbstractEAIndividual
|
||||
*/
|
||||
@@ -313,8 +316,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
|
||||
if (doLogParents) {
|
||||
parents = new Vector<AbstractEAIndividual>();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
parents = null;
|
||||
}
|
||||
try {
|
||||
@@ -453,8 +455,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
private double getCurrentK() {
|
||||
if (randomizeFKLambda) {
|
||||
return RNG.randomDouble(m_k * 0.8, m_k * 1.2);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return m_k;
|
||||
}
|
||||
}
|
||||
@@ -462,8 +463,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
private double getCurrentLambda() {
|
||||
if (randomizeFKLambda) {
|
||||
return RNG.randomDouble(m_Lambda * 0.8, m_Lambda * 1.2);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return m_Lambda;
|
||||
}
|
||||
}
|
||||
@@ -471,8 +471,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
private double getCurrentF() {
|
||||
if (randomizeFKLambda) {
|
||||
return RNG.randomDouble(m_F * 0.8, m_F * 1.2);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return m_F;
|
||||
}
|
||||
}
|
||||
@@ -504,16 +503,16 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
public void optimize() {
|
||||
if (generational) {
|
||||
optimizeGenerational();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
optimizeSteadyState();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This generational DE variant calls the method AbstractOptimizationProblem.evaluate(Population).
|
||||
* Its performance may be slightly worse for schemes that rely on current best individuals,
|
||||
* because improvements are not immediately incorporated as in the steady state DE.
|
||||
* This generational DE variant calls the method
|
||||
* AbstractOptimizationProblem.evaluate(Population). Its performance may be
|
||||
* slightly worse for schemes that rely on current best individuals, because
|
||||
* improvements are not immediately incorporated as in the steady state DE.
|
||||
* However it may be easier to parallelize.
|
||||
*
|
||||
*/
|
||||
@@ -524,15 +523,13 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
// m_Problem.evaluatePopulationStart(m_Population);
|
||||
if (children == null) {
|
||||
children = new Population(m_Population.size());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
children.clear();
|
||||
}
|
||||
for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
if (cyclePop) {
|
||||
parentIndex = i;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
parentIndex = RNG.randomInt(0, this.m_Population.size() - 1);
|
||||
}
|
||||
AbstractEAIndividual indy = generateNewIndividual(m_Population, parentIndex);
|
||||
@@ -543,7 +540,8 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
m_Problem.evaluate(children);
|
||||
|
||||
/**
|
||||
* MdP: added a reevalutation mechanism for dynamically changing problems
|
||||
* MdP: added a reevalutation mechanism for dynamically changing
|
||||
* problems
|
||||
*/
|
||||
if (isReEvaluate()) {
|
||||
for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
@@ -561,8 +559,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
AbstractEAIndividual indy = children.getEAIndividual(i);
|
||||
if (cyclePop) {
|
||||
parentIndex = i;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
parentIndex = RNG.randomInt(0, this.m_Population.size() - 1);
|
||||
}
|
||||
if (nextDoomed >= 0) { // this one is lucky, may replace an 'old' one
|
||||
@@ -600,7 +597,8 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
|
||||
|
||||
/**
|
||||
* MdP: added a reevalutation mechanism for dynamically changing problems
|
||||
* MdP: added a reevalutation mechanism for dynamically changing
|
||||
* problems
|
||||
*/
|
||||
if (isReEvaluate()) {
|
||||
nextDoomed = -1;
|
||||
@@ -618,8 +616,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
for (int i = 0; i < this.m_Population.size(); i++) {
|
||||
if (cyclePop) {
|
||||
index = i;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
index = RNG.randomInt(0, this.m_Population.size() - 1);
|
||||
}
|
||||
indy = generateNewIndividual(m_Population, index);
|
||||
@@ -699,9 +696,10 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for the first individual which is older than the age limit and return its index.
|
||||
* If there is no age limit or all individuals are younger, -1 is returned. The start index
|
||||
* of the search may be provided to make iterative search efficient.
|
||||
* Search for the first individual which is older than the age limit and
|
||||
* return its index. If there is no age limit or all individuals are
|
||||
* younger, -1 is returned. The start index of the search may be provided to
|
||||
* make iterative search efficient.
|
||||
*
|
||||
* @param pop Population to search
|
||||
* @param startIndex index to start the search from
|
||||
@@ -718,7 +716,9 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
/**
|
||||
* This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
*
|
||||
* @param ea
|
||||
*/
|
||||
@Override
|
||||
@@ -728,6 +728,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
}
|
||||
this.m_Listener.add(ea);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -738,7 +739,10 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Something has changed
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
@@ -749,20 +753,25 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = (AbstractOptimizationProblem) problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return (InterfaceOptimizationProblem) this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -774,35 +783,38 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The identifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "Differential Evolution using a steady-state population scheme.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -810,19 +822,23 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
return "DE";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store their data in a population
|
||||
* we will allow access to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store their data in a population we will
|
||||
* allow access to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Edit the properties of the population used.";
|
||||
}
|
||||
@@ -833,20 +849,28 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
return new SolutionSet(pop, pop);
|
||||
}
|
||||
|
||||
/** F is a real and constant factor which controls the amplification of the differential variation
|
||||
/**
|
||||
* F is a real and constant factor which controls the amplification of the
|
||||
* differential variation
|
||||
*
|
||||
* @param f
|
||||
*/
|
||||
public void setF(double f) {
|
||||
this.m_F = f;
|
||||
}
|
||||
|
||||
public double getF() {
|
||||
return this.m_F;
|
||||
}
|
||||
|
||||
public String fTipText() {
|
||||
return "F is a real and constant factor which controls the amplification of the differential variation.";
|
||||
}
|
||||
|
||||
/** Probability of alteration through DE (something like a discrete uniform crossover is performed here)
|
||||
/**
|
||||
* Probability of alteration through DE (something like a discrete uniform
|
||||
* crossover is performed here)
|
||||
*
|
||||
* @param k
|
||||
*/
|
||||
public void setK(double k) {
|
||||
@@ -858,27 +882,36 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
}
|
||||
this.m_k = k;
|
||||
}
|
||||
|
||||
public double getK() {
|
||||
return this.m_k;
|
||||
}
|
||||
|
||||
public String kTipText() {
|
||||
return "Probability of alteration through DE (a.k.a. CR, similar to discrete uniform crossover).";
|
||||
}
|
||||
|
||||
/** Enhance greediness through amplification of the differential vector to the best individual for DE2
|
||||
/**
|
||||
* Enhance greediness through amplification of the differential vector to
|
||||
* the best individual for DE2
|
||||
*
|
||||
* @param l
|
||||
*/
|
||||
public void setLambda(double l) {
|
||||
this.m_Lambda = l;
|
||||
}
|
||||
|
||||
public double getLambda() {
|
||||
return this.m_Lambda;
|
||||
}
|
||||
|
||||
public String lambdaTipText() {
|
||||
return "Enhance greediness through amplification of the differential vector to the best individual for DE2.";
|
||||
}
|
||||
|
||||
/** In case of trig. mutation DE, the TMO is applied wit probability Mt
|
||||
/**
|
||||
* In case of trig. mutation DE, the TMO is applied wit probability Mt
|
||||
*
|
||||
* @param l
|
||||
*/
|
||||
public void setMt(double l) {
|
||||
@@ -890,14 +923,18 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
this.m_Mt = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public double getMt() {
|
||||
return this.m_Mt;
|
||||
}
|
||||
|
||||
public String mtTipText() {
|
||||
return "In case of trigonometric mutation DE, the TMO is applied with probability Mt.";
|
||||
}
|
||||
|
||||
/** This method allows you to choose the type of Differential Evolution.
|
||||
/**
|
||||
* This method allows you to choose the type of Differential Evolution.
|
||||
*
|
||||
* @param s The type.
|
||||
*/
|
||||
public void setDEType(DETypeEnum s) {
|
||||
@@ -906,23 +943,27 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
GenericObjectEditor.setShowProperty(this.getClass(), "lambda", s == DETypeEnum.DE2_CurrentToBest);
|
||||
GenericObjectEditor.setShowProperty(this.getClass(), "mt", s == DETypeEnum.TrigonometricDE);
|
||||
}
|
||||
|
||||
public DETypeEnum getDEType() {
|
||||
return this.m_DEType;
|
||||
}
|
||||
|
||||
public String dETypeTipText() {
|
||||
return "Choose the type of Differential Evolution.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximumAge
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public int getMaximumAge() {
|
||||
return maximumAge;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maximumAge the maximumAge to set
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void setMaximumAge(int maximumAge) {
|
||||
this.maximumAge = maximumAge;
|
||||
}
|
||||
@@ -933,6 +974,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
|
||||
/**
|
||||
* Check whether the problem range will be enforced.
|
||||
*
|
||||
* @return the forceRange
|
||||
*/
|
||||
public boolean isCheckRange() {
|
||||
@@ -973,7 +1015,6 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
// public String cyclePopTipText() {
|
||||
// return "Use all individuals as parents in cyclic sequence instead of randomly.";
|
||||
// }
|
||||
|
||||
public boolean isCompareToParent() {
|
||||
return compareToParent;
|
||||
}
|
||||
@@ -1012,14 +1053,16 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
|
||||
/**
|
||||
* @return the maximumAge
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public boolean isReEvaluate() {
|
||||
return reEvaluate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maximumAge the maximumAge to set
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void setReEvaluate(boolean reEvaluate) {
|
||||
this.reEvaluate = reEvaluate;
|
||||
}
|
||||
@@ -1027,5 +1070,4 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
public String reEvaluateTipText() {
|
||||
return "Reeavulates individuals which are older than maximum age instead of discarding them";
|
||||
}
|
||||
|
||||
}
|
@@ -284,6 +284,8 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface
|
||||
* with the given parameters. If windowLen <= 0, the deactivation mechanism
|
||||
* is disabled. This provides for semi-sequential niching with DPI-ES
|
||||
*
|
||||
*
|
||||
*
|
||||
|
||||
*
|
||||
* @param threshold
|
||||
@@ -948,7 +950,8 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface
|
||||
/**
|
||||
* Calculate the dynamic population size, which is the number of individuals
|
||||
* that are currently "alive" in the peak set. This must be implemented in
|
||||
* analogy to {@link #collectPopulationIncGen(Population, EvolutionStrategies[], Population)}
|
||||
* analogy to
|
||||
* {@link #collectPopulationIncGen(Population, EvolutionStrategies[], Population)}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -1048,10 +1051,6 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
Population peaks = new Population(peakOpts.length);
|
||||
|
@@ -12,20 +12,20 @@ import eva2.server.go.populations.SolutionSet;
|
||||
import eva2.server.go.problems.B1Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/** Evolution strategies by Rechenberg and Schwefel, but please remember that
|
||||
/**
|
||||
* Evolution strategies by Rechenberg and Schwefel, but please remember that
|
||||
* this only gives the generation strategy and not the coding. But this is the
|
||||
* only stategy that is able to utilize the 1/5 success rule mutation. Unfortunately,
|
||||
* there is a minor problem with the interpretation of the population size in constrast
|
||||
* to the parameters mu and lambda used by Rechenberg and Schwefel. Therefore, i'm
|
||||
* afraid that the interpretation of the population size may be subject to future
|
||||
* changes.
|
||||
* This is a implementation of Evolution Strategies.
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* only stategy that is able to utilize the 1/5 success rule mutation.
|
||||
* Unfortunately, there is a minor problem with the interpretation of the
|
||||
* population size in constrast to the parameters mu and lambda used by
|
||||
* Rechenberg and Schwefel. Therefore, i'm afraid that the interpretation of the
|
||||
* population size may be subject to future changes. This is a implementation of
|
||||
* Evolution Strategies. Copyright: Copyright (c) 2003 Company: University of
|
||||
* Tuebingen, Computer Architecture
|
||||
*
|
||||
* @author Felix Streichert
|
||||
* @version: $Revision: 307 $
|
||||
* $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
* @version: $Revision: 307 $ $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec
|
||||
* 2007) $ $Author: mkron $
|
||||
*/
|
||||
public class EvolutionStrategies implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
@@ -339,18 +339,9 @@ public class EvolutionStrategies implements InterfaceOptimizer, java.io.Serializ
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is required to free the memory on a RMIServer, but there is
|
||||
* nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
}
|
||||
|
||||
/**
|
||||
* These are for GUI
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
|
@@ -10,26 +10,25 @@ import eva2.server.go.populations.SolutionSet;
|
||||
import eva2.server.go.problems.F1Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/** Evolutionary programming by Fogel. Works fine but is actually a quite greedy local search
|
||||
* strategy solely based on mutation. To prevent any confusion, the mutation rate is temporaily
|
||||
* set to 1.0.
|
||||
* Potential citation: the PhD thesis of David B. Fogel (1992).
|
||||
/**
|
||||
* Evolutionary programming by Fogel. Works fine but is actually a quite greedy
|
||||
* local search strategy solely based on mutation. To prevent any confusion, the
|
||||
* mutation rate is temporaily set to 1.0. Potential citation: the PhD thesis of
|
||||
* David B. Fogel (1992).
|
||||
*
|
||||
* Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
|
||||
* Architecture
|
||||
*
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Felix Streichert
|
||||
* @version: $Revision: 307 $
|
||||
* $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
* @version: $Revision: 307 $ $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec
|
||||
* 2007) $ $Author: mkron $
|
||||
*/
|
||||
|
||||
public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
private int m_PopulationSize = 0;
|
||||
private Population m_Population = new Population();
|
||||
private InterfaceOptimizationProblem m_Problem = new F1Problem();
|
||||
private InterfaceSelection m_EnvironmentSelection = new SelectEPTournaments();
|
||||
|
||||
private String m_Identifier = "";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
|
||||
@@ -56,7 +55,9 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@Override
|
||||
@@ -69,8 +70,9 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will evaluate the current population using the
|
||||
* given problem.
|
||||
/**
|
||||
* This method will evaluate the current population using the given problem.
|
||||
*
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void evaluatePopulation(Population population) {
|
||||
@@ -78,8 +80,9 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
|
||||
population.incrGeneration();
|
||||
}
|
||||
|
||||
/** This method will generate the offspring population from the
|
||||
* given population of evaluated individuals.
|
||||
/**
|
||||
* This method will generate the offspring population from the given
|
||||
* population of evaluated individuals.
|
||||
*/
|
||||
private Population generateChildren() {
|
||||
Population result = (Population) this.m_Population.cloneWithoutInds();
|
||||
@@ -113,13 +116,16 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
/**
|
||||
* This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
*
|
||||
* @param ea
|
||||
*/
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -130,7 +136,9 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Something has changed
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -138,20 +146,25 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -163,35 +176,38 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is a basic Evolutionary Programming scheme.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -199,19 +215,23 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
|
||||
return "EP";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Edit the properties of the population used.";
|
||||
}
|
||||
@@ -220,15 +240,20 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
/** Choose a method for selecting the reduced population.
|
||||
|
||||
/**
|
||||
* Choose a method for selecting the reduced population.
|
||||
*
|
||||
* @param selection
|
||||
*/
|
||||
public void setEnvironmentSelection(InterfaceSelection selection) {
|
||||
this.m_EnvironmentSelection = selection;
|
||||
}
|
||||
|
||||
public InterfaceSelection getEnvironmentSelection() {
|
||||
return this.m_EnvironmentSelection;
|
||||
}
|
||||
|
||||
public String environmentSelectionTipText() {
|
||||
return "Choose a method for selecting the reduced population.";
|
||||
}
|
||||
|
@@ -9,21 +9,20 @@ import eva2.server.go.populations.SolutionSet;
|
||||
import eva2.server.go.problems.B1Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/** The flood algorithm, and alternative to the threshold algorithms. No really
|
||||
* good but commonly known and sometimes even used. Here the problem is to choose
|
||||
* the initial flood peak and the drain rate such that it fits the current optimization
|
||||
* problem. But again this is a greedy local search strategy. Similar to the
|
||||
* evolutionary programming strategy this strategy sets the mutation rate temporarily
|
||||
* to 1.0.
|
||||
* The algorithm regards only one-dimensional fitness.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 01.10.2004
|
||||
* Time: 13:46:02
|
||||
* To change this template use File | Settings | File Templates.
|
||||
/**
|
||||
* The flood algorithm, and alternative to the threshold algorithms. No really
|
||||
* good but commonly known and sometimes even used. Here the problem is to
|
||||
* choose the initial flood peak and the drain rate such that it fits the
|
||||
* current optimization problem. But again this is a greedy local search
|
||||
* strategy. Similar to the evolutionary programming strategy this strategy sets
|
||||
* the mutation rate temporarily to 1.0. The algorithm regards only
|
||||
* one-dimensional fitness. Created by IntelliJ IDEA. User: streiche Date:
|
||||
* 01.10.2004 Time: 13:46:02 To change this template use File | Settings | File
|
||||
* Templates.
|
||||
*/
|
||||
public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable {
|
||||
// These variables are necessary for the simple testcase
|
||||
|
||||
private InterfaceOptimizationProblem m_Problem = new B1Problem();
|
||||
private int m_MultiRuns = 100;
|
||||
private int m_FitnessCalls = 100;
|
||||
@@ -31,7 +30,6 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
GAIndividualBinaryData m_Best, m_Test;
|
||||
public double m_InitialFloodPeak = 2000.0, m_CurrentFloodPeak;
|
||||
public double m_DrainRate = 1.0;
|
||||
|
||||
// These variables are necessary for the more complex LectureGUI enviroment
|
||||
transient private String m_Identifier = "";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
@@ -54,7 +52,8 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
return (Object) new FloodAlgorithm(this);
|
||||
}
|
||||
|
||||
/** This method will init the HillClimber
|
||||
/**
|
||||
* This method will init the HillClimber
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
@@ -64,7 +63,9 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@Override
|
||||
@@ -78,7 +79,8 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
this.m_CurrentFloodPeak = this.m_InitialFloodPeak;
|
||||
}
|
||||
|
||||
/** This method will optimize
|
||||
/**
|
||||
* This method will optimize
|
||||
*/
|
||||
@Override
|
||||
public void optimize() {
|
||||
@@ -106,7 +108,9 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method calculates the difference between the fitness values
|
||||
/**
|
||||
* This method calculates the difference between the fitness values
|
||||
*
|
||||
* @param org The original
|
||||
* @param mut The mutant
|
||||
*/
|
||||
@@ -121,19 +125,23 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will init the HillClimber
|
||||
/**
|
||||
* This method will init the HillClimber
|
||||
*/
|
||||
public void defaultInit() {
|
||||
this.m_FitnessCallsNeeded = 0;
|
||||
@@ -141,7 +149,8 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
this.m_Best.defaultInit(m_Problem);
|
||||
}
|
||||
|
||||
/** This method will optimize
|
||||
/**
|
||||
* This method will optimize
|
||||
*/
|
||||
public void defaultOptimize() {
|
||||
for (int i = 0; i < m_FitnessCalls; i++) {
|
||||
@@ -157,8 +166,9 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
}
|
||||
}
|
||||
|
||||
/** This main method will start a simple hillclimber.
|
||||
* No arguments necessary.
|
||||
/**
|
||||
* This main method will start a simple hillclimber. No arguments necessary.
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
@@ -175,13 +185,16 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
System.out.println("(" + program.m_MultiRuns + "/" + program.m_FitnessCalls + ") Mean Fitness : " + TmpMeanFitness + " Mean Calls needed: " + TmpMeanCalls);
|
||||
}
|
||||
|
||||
/** This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
/**
|
||||
* This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
*
|
||||
* @param ea
|
||||
*/
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -192,7 +205,9 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Something has changed
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -200,8 +215,10 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -209,8 +226,7 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
String result = "";
|
||||
if (this.m_Population.size() > 1) {
|
||||
result += "Multi(" + this.m_Population.size() + ")-Start Hill Climbing:\n";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result += "Simulated Annealing:\n";
|
||||
}
|
||||
result += "Optimization Problem: ";
|
||||
@@ -218,35 +234,38 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "The flood algorithm uses an declining flood peak to accpect new solutions (*shudder* check inital flood peak and drain very carefully!).";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -254,55 +273,67 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
|
||||
return "MS-FA";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Change the number of best individuals stored (MS-FA).";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
/** This methods allow you to set/get the temperatur of the flood
|
||||
* algorithm procedure
|
||||
|
||||
/**
|
||||
* This methods allow you to set/get the temperatur of the flood algorithm
|
||||
* procedure
|
||||
*
|
||||
* @return The initial flood level.
|
||||
*/
|
||||
public double getInitialFloodPeak() {
|
||||
return this.m_InitialFloodPeak;
|
||||
}
|
||||
|
||||
public void setInitialFloodPeak(double pop) {
|
||||
this.m_InitialFloodPeak = pop;
|
||||
}
|
||||
|
||||
public String initialFloodPeakTipText() {
|
||||
return "Set the initial flood peak.";
|
||||
}
|
||||
|
||||
/** This methods allow you to set/get the drain rate of the flood
|
||||
* algorithm procedure
|
||||
/**
|
||||
* This methods allow you to set/get the drain rate of the flood algorithm
|
||||
* procedure
|
||||
*
|
||||
* @return The drain rate.
|
||||
*/
|
||||
public double getDrainRate() {
|
||||
return this.m_DrainRate;
|
||||
}
|
||||
|
||||
public void setDrainRate(double a) {
|
||||
this.m_DrainRate = a;
|
||||
if (this.m_DrainRate < 0) {
|
||||
this.m_DrainRate = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
public String drainRateTipText() {
|
||||
return "Set the drain rate that reduces the current flood level each generation.";
|
||||
}
|
||||
|
@@ -241,14 +241,6 @@ public class GeneticAlgorithm implements InterfaceOptimizer, java.io.Serializabl
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is required to free the memory on a RMIServer, but there is
|
||||
* nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
}
|
||||
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
|
@@ -22,11 +22,9 @@ import eva2.tools.ReflectPackage;
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
private InterfaceOptimizationProblem m_Problem;
|
||||
|
||||
InterfaceDataTypeDouble m_Best, m_Test;
|
||||
private int iterations = 1;
|
||||
private double wDecreaseStepSize = 0.5;
|
||||
@@ -46,13 +44,10 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
public double maximumabsolutechange = 0.2;
|
||||
// Hashtable indyhash;
|
||||
|
||||
// These variables are necessary for the more complex LectureGUI enviroment
|
||||
transient private String m_Identifier = "";
|
||||
private Population m_Population;
|
||||
|
||||
private static boolean TRACE = false;
|
||||
|
||||
private static final String lockKey = "gdaLockDataKey";
|
||||
private static final String lastFitnessKey = "gdaLastFitDataKey";
|
||||
private static final String stepSizeKey = "gdaStepSizeDataKey";
|
||||
@@ -98,7 +93,9 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
/**@todo Implement InterfaceOptimizer method*/
|
||||
/**
|
||||
* @todo Implement InterfaceOptimizer method
|
||||
*/
|
||||
throw new java.lang.UnsupportedOperationException("Method clone() not yet implemented.");
|
||||
}
|
||||
|
||||
@@ -311,7 +308,6 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
private double momentumweigth = 0.1;
|
||||
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
@@ -340,8 +336,9 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
@@ -374,6 +371,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -384,6 +382,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GradientDescentAlgorithm program = new GradientDescentAlgorithm();
|
||||
InterfaceOptimizationProblem problem = new F1Problem();
|
||||
@@ -399,22 +398,22 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeWilly() { }
|
||||
|
||||
public static String globalInfo() {
|
||||
return "Gradient Descent can be applied to derivable functions (" + InterfaceFirstOrderDerivableProblem.class.getSimpleName() + ").";
|
||||
}
|
||||
//////////////// for global adaption
|
||||
|
||||
public boolean isAdaptStepSizeGlobally() {
|
||||
return globalStepSizeAdaption;
|
||||
}
|
||||
|
||||
public void setAdaptStepSizeGlobally(boolean globalstepsizeadaption) {
|
||||
this.globalStepSizeAdaption = globalstepsizeadaption;
|
||||
if (globalstepsizeadaption && localStepSizeAdaption) {
|
||||
setAdaptStepSizeLocally(false);
|
||||
}
|
||||
}
|
||||
|
||||
public String adaptStepSizeGloballyTipText() {
|
||||
return "Use a single step size per individual - (priority over local step size).";
|
||||
}
|
||||
@@ -422,9 +421,11 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public double getGlobalMaxStepSize() {
|
||||
return globalmaxstepsize;
|
||||
}
|
||||
|
||||
public void setGlobalMaxStepSize(double p) {
|
||||
globalmaxstepsize = p;
|
||||
}
|
||||
|
||||
public String globalMaxStepSizeTipText() {
|
||||
return "Maximum step size for global adaption.";
|
||||
}
|
||||
@@ -432,9 +433,11 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public double getGlobalMinStepSize() {
|
||||
return globalminstepsize;
|
||||
}
|
||||
|
||||
public void setGlobalMinStepSize(double p) {
|
||||
globalminstepsize = p;
|
||||
}
|
||||
|
||||
public String globalMindStepSizeTipText() {
|
||||
return "Minimum step size for global adaption.";
|
||||
}
|
||||
@@ -442,9 +445,11 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public double getGlobalInitStepSize() {
|
||||
return globalinitstepsize;
|
||||
}
|
||||
|
||||
public void setGlobalInitStepSize(double initstepsize) {
|
||||
this.globalinitstepsize = initstepsize;
|
||||
}
|
||||
|
||||
public String globalInitStepSizeTipText() {
|
||||
return "Initial step size for global adaption.";
|
||||
}
|
||||
@@ -453,12 +458,14 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public boolean isAdaptStepSizeLocally() {
|
||||
return localStepSizeAdaption;
|
||||
}
|
||||
|
||||
public void setAdaptStepSizeLocally(boolean stepsizeadaption) {
|
||||
this.localStepSizeAdaption = stepsizeadaption;
|
||||
if (globalStepSizeAdaption && localStepSizeAdaption) {
|
||||
setAdaptStepSizeGlobally(false);
|
||||
}
|
||||
}
|
||||
|
||||
public String adaptStepSizeLocallyTipText() {
|
||||
return "Use a step size parameter in any dimension.";
|
||||
}
|
||||
@@ -466,6 +473,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public double getLocalMinStepSize() {
|
||||
return localminstepsize;
|
||||
}
|
||||
|
||||
public void setLocalMinStepSize(double localminstepsize) {
|
||||
this.localminstepsize = localminstepsize;
|
||||
}
|
||||
@@ -473,6 +481,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public double getLocalMaxStepSize() {
|
||||
return localmaxstepsize;
|
||||
}
|
||||
|
||||
public void setLocalMaxStepSize(double localmaxstepsize) {
|
||||
this.localmaxstepsize = localmaxstepsize;
|
||||
}
|
||||
@@ -480,9 +489,11 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public void setStepSizeIncreaseFact(double nplus) {
|
||||
this.wIncreaseStepSize = nplus;
|
||||
}
|
||||
|
||||
public double getStepSizeIncreaseFact() {
|
||||
return wIncreaseStepSize;
|
||||
}
|
||||
|
||||
public String stepSizeIncreaseFactTipText() {
|
||||
return "Factor for increasing the step size in adaption.";
|
||||
}
|
||||
@@ -490,9 +501,11 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public void setStepSizeDecreaseFact(double nminus) {
|
||||
this.wDecreaseStepSize = nminus;
|
||||
}
|
||||
|
||||
public double getStepSizeDecreaseFact() {
|
||||
return wDecreaseStepSize;
|
||||
}
|
||||
|
||||
public String stepSizeDecreaseFactTipText() {
|
||||
return "Factor for decreasing the step size in adaption.";
|
||||
}
|
||||
@@ -501,40 +514,47 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public boolean isRecovery() {
|
||||
return recovery;
|
||||
}
|
||||
|
||||
public void setRecovery(boolean recovery) {
|
||||
this.recovery = recovery;
|
||||
}
|
||||
|
||||
public int getRecoveryLocksteps() {
|
||||
return recoverylocksteps;
|
||||
}
|
||||
|
||||
public void setRecoveryLocksteps(int locksteps) {
|
||||
this.recoverylocksteps = locksteps;
|
||||
}
|
||||
|
||||
public double getRecoveryThreshold() {
|
||||
return recoverythreshold;
|
||||
}
|
||||
|
||||
public void setRecoveryThreshold(double recoverythreshold) {
|
||||
this.recoverythreshold = recoverythreshold;
|
||||
}
|
||||
|
||||
public String recoveryThresholdTipText() {
|
||||
return "If the fitness exceeds this threshold, an unstable area is assumed and one step recovered.";
|
||||
}
|
||||
|
||||
|
||||
public int getIterations() {
|
||||
return iterations;
|
||||
}
|
||||
|
||||
public void setIterations(int iterations) {
|
||||
this.iterations = iterations;
|
||||
}
|
||||
|
||||
public String iterationsTipText() {
|
||||
return "The number of GD-iterations per generation.";
|
||||
}
|
||||
|
||||
|
||||
public boolean isManhattan() {
|
||||
return manhattan;
|
||||
}
|
||||
|
||||
public void setManhattan(boolean manhattan) {
|
||||
this.manhattan = manhattan;
|
||||
}
|
||||
@@ -542,6 +562,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public boolean isMomentumTerm() {
|
||||
return momentumterm;
|
||||
}
|
||||
|
||||
public void setMomentumTerm(boolean momentum) {
|
||||
this.momentumterm = momentum;
|
||||
}
|
||||
@@ -549,6 +570,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public double getMomentumWeigth() {
|
||||
return momentumweigth;
|
||||
}
|
||||
|
||||
public void setMomentumWeigth(double momentumweigth) {
|
||||
this.momentumweigth = momentumweigth;
|
||||
}
|
||||
@@ -556,11 +578,12 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
|
||||
public double getMaximumAbsoluteChange() {
|
||||
return maximumabsolutechange;
|
||||
}
|
||||
|
||||
public void setMaximumAbsoluteChange(double maximumabsolutechange) {
|
||||
this.maximumabsolutechange = maximumabsolutechange;
|
||||
}
|
||||
|
||||
public String maximumAbsoluteChangeTipText() {
|
||||
return "The maximum change along a coordinate in one step.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,27 +9,25 @@ import eva2.server.go.populations.SolutionSet;
|
||||
import eva2.server.go.problems.B1Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
|
||||
/** This is a Multi-Start Hill-Climber, here the population size gives the number of
|
||||
* multi-starts. Similar to the evolutionary programming strategy this strategy sets the
|
||||
* mutation rate temporarily to 1.0.
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
/**
|
||||
* This is a Multi-Start Hill-Climber, here the population size gives the number
|
||||
* of multi-starts. Similar to the evolutionary programming strategy this
|
||||
* strategy sets the mutation rate temporarily to 1.0. Copyright: Copyright (c)
|
||||
* 2003 Company: University of Tuebingen, Computer Architecture
|
||||
*
|
||||
* @author Felix Streichert
|
||||
* @version: $Revision: 307 $
|
||||
* $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
* @version: $Revision: 307 $ $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec
|
||||
* 2007) $ $Author: mkron $
|
||||
*/
|
||||
|
||||
public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
// These variables are necessary for the simple testcase
|
||||
|
||||
private InterfaceOptimizationProblem m_Problem = new B1Problem();
|
||||
private InterfaceMutation mutator = null;
|
||||
// private int m_MultiRuns = 100;
|
||||
// private int m_FitnessCalls = 100;
|
||||
// private int m_FitnessCallsNeeded = 0;
|
||||
// GAIndividualBinaryData m_Best, m_Test;
|
||||
|
||||
// These variables are necessary for the more complex LectureGUI enviroment
|
||||
transient private String m_Identifier = "";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
@@ -50,7 +48,8 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
return (Object) new HillClimbing(this);
|
||||
}
|
||||
|
||||
/** This method will init the HillClimber
|
||||
/**
|
||||
* This method will init the HillClimber
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
@@ -69,7 +68,8 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will optimize
|
||||
/**
|
||||
* This method will optimize
|
||||
*/
|
||||
@Override
|
||||
public void optimize() {
|
||||
@@ -84,8 +84,7 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
indy.setMutationProbability(1.0);
|
||||
if (mutator == null) {
|
||||
indy.mutate();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mutator.mutate(indy);
|
||||
}
|
||||
indy.setMutationProbability(tmpD);
|
||||
@@ -123,8 +122,9 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to set a desired mutator by hand, which is used instead of the one in the individuals.
|
||||
* Set it to null to use the one in the individuals, which is the default.
|
||||
* Allows to set a desired mutator by hand, which is used instead of the one
|
||||
* in the individuals. Set it to null to use the one in the individuals,
|
||||
* which is the default.
|
||||
*
|
||||
* @param mute
|
||||
*/
|
||||
@@ -132,13 +132,16 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
mutator = mute;
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
@@ -163,7 +166,6 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
// if (this.m_Best.defaultEvaulateAsMiniBits() == 0) i = this.m_FitnessCalls +1;
|
||||
// }
|
||||
// }
|
||||
|
||||
// /** This main method will start a simple hillclimber.
|
||||
// * No arguments necessary.
|
||||
// * @param args
|
||||
@@ -181,14 +183,16 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
// TmpMeanFitness = TmpMeanFitness/program.m_MultiRuns;
|
||||
// System.out.println("("+program.m_MultiRuns+"/"+program.m_FitnessCalls+") Mean Fitness : " + TmpMeanFitness + " Mean Calls needed: " + TmpMeanCalls);
|
||||
// }
|
||||
|
||||
/** This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
/**
|
||||
* This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
*
|
||||
* @param ea
|
||||
*/
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -199,7 +203,9 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Something has changed
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -207,8 +213,10 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -216,8 +224,7 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
String result = "";
|
||||
if (this.m_Population.size() > 1) {
|
||||
result += "Multi(" + this.m_Population.size() + ")-Start Hill Climbing:\n";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result += "Hill Climbing:\n";
|
||||
}
|
||||
result += "Optimization Problem: ";
|
||||
@@ -225,45 +232,50 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "The Hill Climber uses the default EA mutation and initializing operators. If the population size is bigger than one a multi-start Hill Climber is performed.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MS-HC" + getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
@@ -273,6 +285,7 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Change the number of best individuals stored (MS-HC).";
|
||||
}
|
||||
|
@@ -22,29 +22,29 @@ public interface InterfaceOptimizer {
|
||||
/** This method will return deep clone of the optimizer
|
||||
* @return The clone
|
||||
*/
|
||||
public Object clone();
|
||||
Object clone();
|
||||
|
||||
/** This method will return a naming String
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
public String getName();
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* This method allows you to add a listener to the Optimizer.
|
||||
* @param ea
|
||||
*/
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea);
|
||||
void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea);
|
||||
|
||||
/**
|
||||
* This method removes a listener from the Optimizer. It returns true on success,
|
||||
* false if the listener could not be found.
|
||||
* @param ea
|
||||
*/
|
||||
public boolean removePopulationChangedEventListener(InterfacePopulationChangedEventListener ea);
|
||||
boolean removePopulationChangedEventListener(InterfacePopulationChangedEventListener ea);
|
||||
|
||||
/** This method will init the optimizer
|
||||
*/
|
||||
public void init();
|
||||
void init();
|
||||
|
||||
/**
|
||||
* This method will init the optimizer with a given population.
|
||||
@@ -52,22 +52,22 @@ public interface InterfaceOptimizer {
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reinitialized and reevaluated.
|
||||
*/
|
||||
public void initByPopulation(Population pop, boolean reset);
|
||||
void initByPopulation(Population pop, boolean reset);
|
||||
|
||||
/** This method will optimize for a single iteration, after this step
|
||||
* the population should be as big as possible (ie. the size of lambda
|
||||
* and not mu) and all individual should be evaluated. This allows more
|
||||
* usefull statistics on the population.
|
||||
*/
|
||||
public void optimize();
|
||||
void optimize();
|
||||
|
||||
/** Assuming that all optimizer will store their data in a population
|
||||
* we will allow access to this population to query to current state
|
||||
* of the optimizer.
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
public Population getPopulation();
|
||||
public void setPopulation(Population pop);
|
||||
Population getPopulation();
|
||||
void setPopulation(Population pop);
|
||||
|
||||
/**
|
||||
* Return all found solutions (local optima) if they are not contained in the current population. Be
|
||||
@@ -78,14 +78,14 @@ public interface InterfaceOptimizer {
|
||||
*
|
||||
* @return A solution set of the current population and possibly earlier solutions.
|
||||
*/
|
||||
public InterfaceSolutionSet getAllSolutions();
|
||||
InterfaceSolutionSet getAllSolutions();
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
* @param name The identifier
|
||||
*/
|
||||
public void setIdentifier(String name);
|
||||
public String getIdentifier();
|
||||
void setIdentifier(String name);
|
||||
String getIdentifier();
|
||||
|
||||
/**
|
||||
* This method will set the problem that is to be optimized. The problem
|
||||
@@ -93,17 +93,12 @@ public interface InterfaceOptimizer {
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
public void setProblem (InterfaceOptimizationProblem problem);
|
||||
public InterfaceOptimizationProblem getProblem ();
|
||||
void setProblem (InterfaceOptimizationProblem problem);
|
||||
InterfaceOptimizationProblem getProblem ();
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
* @return A descriptive string
|
||||
*/
|
||||
public String getStringRepresentation();
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
public void freeWilly();
|
||||
String getStringRepresentation();
|
||||
}
|
||||
|
@@ -17,27 +17,26 @@ import eva2.server.go.problems.F8Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
import eva2.server.go.problems.TF1Problem;
|
||||
|
||||
/** The one and only island model for parallelization. Since parallelization based
|
||||
* on the RMIProxyRemoteThread is on the one hand much slower than benchmark function
|
||||
* evaluation and on the other hand the GUI based distribution scheme is rather prone
|
||||
* to config errors (the correct ssh version is required, the jar needs to be in
|
||||
* the working dir and possible problem data must be on the servers to) an implicit
|
||||
* island-model has been implemented too to allow fast and reliable computation.
|
||||
* This is still usefull, since it is less prone to premature convergence and also
|
||||
* an heterogenuous island model can be used.
|
||||
/**
|
||||
* The one and only island model for parallelization. Since parallelization
|
||||
* based on the RMIProxyRemoteThread is on the one hand much slower than
|
||||
* benchmark function evaluation and on the other hand the GUI based
|
||||
* distribution scheme is rather prone to config errors (the correct ssh version
|
||||
* is required, the jar needs to be in the working dir and possible problem data
|
||||
* must be on the servers to) an implicit island-model has been implemented too
|
||||
* to allow fast and reliable computation. This is still usefull, since it is
|
||||
* less prone to premature convergence and also an heterogenuous island model
|
||||
* can be used.
|
||||
*
|
||||
* A population of the same size is sent to all nodes and evaluated there independently
|
||||
* for a cycle (more precisely: for MigrationRate generations) after which a communication
|
||||
* step is performed according to the migration model. Only after migration is a main
|
||||
* cycle complete, the statistics updated etc.
|
||||
* A population of the same size is sent to all nodes and evaluated there
|
||||
* independently for a cycle (more precisely: for MigrationRate generations)
|
||||
* after which a communication step is performed according to the migration
|
||||
* model. Only after migration is a main cycle complete, the statistics updated
|
||||
* etc.
|
||||
*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 12.09.2004
|
||||
* Time: 14:48:20
|
||||
* To change this template use File | Settings | File Templates.
|
||||
* Created by IntelliJ IDEA. User: streiche Date: 12.09.2004 Time: 14:48:20 To
|
||||
* change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
public class IslandModelEA implements InterfacePopulationChangedEventListener, InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
private Population m_Population = new Population();
|
||||
@@ -47,22 +46,18 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
// private String[] m_NodesList;
|
||||
private int m_MigrationRate = 10;
|
||||
private boolean m_HeterogenuousProblems = false;
|
||||
|
||||
// These are the processor to run on
|
||||
private int m_numLocalCPUs = 1;
|
||||
private boolean m_localOnly = false;
|
||||
transient private InterfaceOptimizer[] m_Islands;
|
||||
|
||||
// This is for debugging
|
||||
private boolean m_LogLocalChanges = true;
|
||||
private boolean m_Show = false;
|
||||
transient private Plot m_Plot = null;
|
||||
|
||||
transient private String m_Identifier = "";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
transient private final boolean TRACE = false;
|
||||
|
||||
|
||||
public IslandModelEA() {
|
||||
}
|
||||
|
||||
@@ -152,7 +147,9 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed, this.m_Optimizer.getPopulation());
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@Override
|
||||
@@ -223,7 +220,8 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed, this.m_Optimizer.getPopulation());
|
||||
}
|
||||
|
||||
/** The optimize method will compute an 'improved' and evaluated population
|
||||
/**
|
||||
* The optimize method will compute an 'improved' and evaluated population
|
||||
*/
|
||||
@Override
|
||||
public void optimize() {
|
||||
@@ -253,8 +251,8 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
System.gc();
|
||||
}
|
||||
|
||||
/** This method will manage communication between the
|
||||
* islands
|
||||
/**
|
||||
* This method will manage communication between the islands
|
||||
*/
|
||||
private void communicate() {
|
||||
// Here i'll have to wait until all islands are finished
|
||||
@@ -296,13 +294,16 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
this.m_Migration.migrate(this.m_Islands);
|
||||
}
|
||||
|
||||
/** This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
/**
|
||||
* This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
*
|
||||
* @param ea
|
||||
*/
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -313,7 +314,9 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Something has changed
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name, Population population) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -321,7 +324,9 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@@ -329,13 +334,16 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
this.m_Problem = problem;
|
||||
this.m_Optimizer.setProblem(problem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -362,7 +370,8 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method is to test the parallelization scheme
|
||||
/**
|
||||
* This method is to test the parallelization scheme
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
@@ -410,47 +419,48 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
//System.exit(0);
|
||||
}
|
||||
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method will return the Optimizers
|
||||
/**
|
||||
* This method will return the Optimizers
|
||||
*
|
||||
* @return An array of optimizers
|
||||
*/
|
||||
public InterfaceOptimizer[] getOptimizers() {
|
||||
return this.m_Islands;
|
||||
}
|
||||
|
||||
/** This method will allow you to toggel between homogenuous and heterogenuous problems.
|
||||
* In case of heterogenuous problems the individuals need to be reevaluated after migration.
|
||||
/**
|
||||
* This method will allow you to toggel between homogenuous and
|
||||
* heterogenuous problems. In case of heterogenuous problems the individuals
|
||||
* need to be reevaluated after migration.
|
||||
*
|
||||
* @param t
|
||||
*/
|
||||
public void setHeterogenuousProblems(boolean t) {
|
||||
this.m_HeterogenuousProblems = t;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
for (int i = 0; i < this.m_Islands.length; i++) {
|
||||
this.m_Islands[i].freeWilly();
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for InterfacePopulationChangedEventListener
|
||||
*/
|
||||
/** This method allows an optimizer to register a change in the EA-lecture
|
||||
/**
|
||||
* This method allows an optimizer to register a change in the EA-lecture
|
||||
*
|
||||
* @param source The source of the event.
|
||||
* @param name Could be used to indicate the nature of the event.
|
||||
*/
|
||||
@@ -469,16 +479,22 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
//System.out.println(sourceID + " is at generation "+ opt.getPopulation().getGeneration() +" i'm at " +this.m_Generation);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is an island model EA distributing the individuals across several (remote) CPUs for optimization.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -486,8 +502,10 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
return "IslandEA";
|
||||
}
|
||||
|
||||
/** This method allows you to toggle between a truly parallel
|
||||
* and a serial implementation.
|
||||
/**
|
||||
* This method allows you to toggle between a truly parallel and a serial
|
||||
* implementation.
|
||||
*
|
||||
* @return The current optimization mode
|
||||
*/
|
||||
// TODO Deactivated from GUI because the current implementation does not really parallelize on a multicore.
|
||||
@@ -498,59 +516,76 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
public void setLocalOnly(boolean b) {
|
||||
this.m_localOnly = b;
|
||||
}
|
||||
|
||||
public String localOnlyTipText() {
|
||||
return "Toggle between usage of local CPUs and remote servers.";
|
||||
}
|
||||
|
||||
/** This will show the local performance
|
||||
/**
|
||||
* This will show the local performance
|
||||
*
|
||||
* @return The current optimzation mode
|
||||
*/
|
||||
public boolean getShow() {
|
||||
return this.m_Show;
|
||||
}
|
||||
|
||||
public void setShow(boolean b) {
|
||||
this.m_Show = b;
|
||||
this.m_LogLocalChanges = b;
|
||||
}
|
||||
|
||||
public String showTipText() {
|
||||
return "This will show the local performance.";
|
||||
}
|
||||
|
||||
/** This method allows you to set/get the optimizing technique to use.
|
||||
/**
|
||||
* This method allows you to set/get the optimizing technique to use.
|
||||
*
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public InterfaceOptimizer getOptimizer() {
|
||||
return this.m_Optimizer;
|
||||
}
|
||||
|
||||
public void setOptimizer(InterfaceOptimizer b) {
|
||||
this.m_Optimizer = b;
|
||||
}
|
||||
|
||||
public String optimizerTipText() {
|
||||
return "Choose a population based optimizing technique to use.";
|
||||
}
|
||||
|
||||
/** This method allows you to set/get the migration strategy to use.
|
||||
/**
|
||||
* This method allows you to set/get the migration strategy to use.
|
||||
*
|
||||
* @return The current migration strategy
|
||||
*/
|
||||
public InterfaceMigration getMigrationStrategy() {
|
||||
return this.m_Migration;
|
||||
}
|
||||
|
||||
public void setMigrationStrategy(InterfaceMigration b) {
|
||||
this.m_Migration = b;
|
||||
}
|
||||
|
||||
public String migrationStrategyTipText() {
|
||||
return "Choose a migration strategy to use.";
|
||||
}
|
||||
|
||||
/** This method allows you to set/get the migration rate to use.
|
||||
/**
|
||||
* This method allows you to set/get the migration rate to use.
|
||||
*
|
||||
* @return The current migration rate
|
||||
*/
|
||||
public int getMigrationRate() {
|
||||
return this.m_MigrationRate;
|
||||
}
|
||||
|
||||
public void setMigrationRate(int b) {
|
||||
this.m_MigrationRate = b;
|
||||
}
|
||||
|
||||
public String migrationRateTipText() {
|
||||
return "Set the migration rate for communication between islands.";
|
||||
}
|
||||
@@ -559,20 +594,24 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
return "Choose and manage the servers (only active in parallelized mode).";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
// @todo Jetzt m<>sste ich die pop auch auf die Rechner verteilen...
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "(Defunct)";
|
||||
}
|
||||
@@ -581,14 +620,16 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
/** This method allows you to set the number of processors in local mode
|
||||
|
||||
/**
|
||||
* This method allows you to set the number of processors in local mode
|
||||
*
|
||||
* @param n Number of processors.
|
||||
*/
|
||||
public void setNumberLocalCPUs(int n) {
|
||||
if (n >= 1) {
|
||||
this.m_numLocalCPUs = n;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.err.println("Number of CPUs must be at least 1!");
|
||||
}
|
||||
}
|
||||
@@ -597,6 +638,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
// public int getNumberLocalCPUs() {
|
||||
// return this.m_LocalCPUs;
|
||||
// }
|
||||
|
||||
public String numberLocalCPUsTipText() {
|
||||
return "Set the number of local CPUS (>=1, only used in local mode).";
|
||||
}
|
||||
|
@@ -364,10 +364,6 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interface
|
||||
return "Linkage Tree GA";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPopulationStateChanged(Object source, String name) {
|
||||
// The events of the interim hill climbing population will be caught here
|
||||
|
@@ -343,10 +343,6 @@ public class MLTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
|
||||
return "Linkage Tree GA";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPopulationStateChanged(Object source, String name) {
|
||||
// The events of the interim hill climbing population will be caught here
|
||||
|
@@ -12,28 +12,15 @@ import eva2.server.go.problems.InterfaceLocalSearchable;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
import java.util.Hashtable;
|
||||
|
||||
|
||||
/**
|
||||
* A memetic algorithm by hannes planatscher. The local search strategy can only
|
||||
* be applied to problems which implement the InterfaceLocalSearchable else the
|
||||
* local search will not be activated at all.
|
||||
* <p>
|
||||
* Title: EvA2
|
||||
* </p>
|
||||
* <p>
|
||||
* Description:
|
||||
* </p>
|
||||
* <p>
|
||||
* Copyright: Copyright (c) 2003
|
||||
* </p>
|
||||
* <p>
|
||||
* Company:
|
||||
* </p>
|
||||
* local search will not be activated at all. <p> Title: EvA2 </p> <p>
|
||||
* Description: </p> <p> Copyright: Copyright (c) 2003 </p> <p> Company: </p>
|
||||
*
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
java.io.Serializable {
|
||||
|
||||
@@ -41,32 +28,20 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
* serial version uid.
|
||||
*/
|
||||
private static final long serialVersionUID = -1730086430763348568L;
|
||||
|
||||
private int localSearchSteps = 1;
|
||||
|
||||
private int subsetsize = 5;
|
||||
|
||||
private int globalSearchIterations = 1;
|
||||
|
||||
private boolean lamarckism = true;
|
||||
|
||||
// int counter = 0; !?
|
||||
// int maxfunctioncalls = 1000; !?
|
||||
|
||||
private boolean TRACE = false;
|
||||
|
||||
private String m_Identifier = "";
|
||||
|
||||
private InterfaceOptimizationProblem m_Problem = new F1Problem();
|
||||
|
||||
private InterfaceOptimizer m_GlobalOptimizer = new GeneticAlgorithm();
|
||||
|
||||
private InterfaceSelection selectorPlug = new SelectBestIndividuals();
|
||||
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
|
||||
public MemeticAlgorithm() {
|
||||
|
||||
}
|
||||
|
||||
public MemeticAlgorithm(MemeticAlgorithm a) {
|
||||
@@ -108,8 +83,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
/**
|
||||
* This method will evaluate the current population using the given problem.
|
||||
*
|
||||
* @param population
|
||||
* The population that is to be evaluated
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void evaluatePopulation(Population population) {
|
||||
this.m_Problem.evaluate(population);
|
||||
@@ -212,6 +186,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -222,6 +197,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
@@ -251,8 +227,8 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@@ -269,8 +245,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name
|
||||
* The indenifier
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
@@ -282,14 +257,6 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is required to free the memory on a RMIServer, but there is
|
||||
* nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* ========================================================================================
|
||||
@@ -301,9 +268,9 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is a basic generational Memetic Algorithm. Local search steps are performed on a selected subset " +
|
||||
"of individuals after certain numbers of global search iterations. Note " +
|
||||
"that the problem class must implement InterfaceLocalSearchable.";
|
||||
return "This is a basic generational Memetic Algorithm. Local search steps are performed on a selected subset "
|
||||
+ "of individuals after certain numbers of global search iterations. Note "
|
||||
+ "that the problem class must implement InterfaceLocalSearchable.";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +285,8 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the optimizer.
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@@ -356,16 +324,19 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose the number of local search steps to perform per selected individual.
|
||||
* Choose the number of local search steps to perform per selected
|
||||
* individual.
|
||||
*
|
||||
* @param localSearchSteps
|
||||
*/
|
||||
public void setLocalSearchSteps(int localSearchSteps) {
|
||||
this.localSearchSteps = localSearchSteps;
|
||||
}
|
||||
|
||||
public int getLocalSearchSteps() {
|
||||
return localSearchSteps;
|
||||
}
|
||||
|
||||
public String localSearchStepsTipText() {
|
||||
return "Choose the number of local search steps to perform per selected individual.";
|
||||
}
|
||||
@@ -378,9 +349,11 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
public void setGlobalSearchIterations(int globalSearchSteps) {
|
||||
this.globalSearchIterations = globalSearchSteps;
|
||||
}
|
||||
|
||||
public int getGlobalSearchIterations() {
|
||||
return globalSearchIterations;
|
||||
}
|
||||
|
||||
public String globalSearchIterationsTipText() {
|
||||
return "Choose the interval between the application of the local search.";
|
||||
}
|
||||
@@ -398,9 +371,11 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
public void setSubsetsize(int subsetsize) {
|
||||
this.subsetsize = subsetsize;
|
||||
}
|
||||
|
||||
public int getSubsetsize() {
|
||||
return subsetsize;
|
||||
}
|
||||
|
||||
public String subsetsizeTipText() {
|
||||
return "Choose the number of individuals to be locally optimized.";
|
||||
}
|
||||
@@ -413,9 +388,11 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
public void setLamarckism(boolean lamarckism) {
|
||||
this.lamarckism = lamarckism;
|
||||
}
|
||||
|
||||
public String lamarckismTipText() {
|
||||
return "Toggle between Lamarckism and the Baldwin Effect.";
|
||||
}
|
||||
|
||||
public boolean isLamarckism() {
|
||||
return lamarckism;
|
||||
}
|
||||
@@ -423,9 +400,11 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
public InterfaceSelection getSubSetSelector() {
|
||||
return selectorPlug;
|
||||
}
|
||||
|
||||
public void setSubSetSelector(InterfaceSelection selectorPlug) {
|
||||
this.selectorPlug = selectorPlug;
|
||||
}
|
||||
|
||||
public String subSetSelectorTipText() {
|
||||
return "Selection method to select the subset on which local search is to be performed.";
|
||||
}
|
||||
|
@@ -10,20 +10,20 @@ import eva2.server.go.problems.B1Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/**
|
||||
* The simple random or Monte-Carlo search, simple but useful
|
||||
* to evaluate the complexity of the search space.
|
||||
* This implements a Random Walk Search using the initialization
|
||||
* method of the problem instance, meaning that the random characteristics
|
||||
* may be problem dependent.
|
||||
* The simple random or Monte-Carlo search, simple but useful to evaluate the
|
||||
* complexity of the search space. This implements a Random Walk Search using
|
||||
* the initialization method of the problem instance, meaning that the random
|
||||
* characteristics may be problem dependent.
|
||||
*
|
||||
* Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
|
||||
* Architecture
|
||||
*
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Felix Streichert
|
||||
* @version: $Revision: 307 $
|
||||
* $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
* @version: $Revision: 307 $ $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec
|
||||
* 2007) $ $Author: mkron $
|
||||
*/
|
||||
public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
/**
|
||||
* Generated serial version id.
|
||||
*/
|
||||
@@ -35,7 +35,6 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
private int m_FitnessCallsNeeded = 0;
|
||||
private Population m_Population;
|
||||
private GAIndividualBinaryData m_Best, m_Test;
|
||||
|
||||
// These variables are necessary for the more complex LectureGUI enviroment
|
||||
transient private String m_Identifier = "";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
@@ -55,7 +54,8 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
return (Object) new MonteCarloSearch(this);
|
||||
}
|
||||
|
||||
/** This method will init the MonteCarloSearch
|
||||
/**
|
||||
* This method will init the MonteCarloSearch
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
@@ -64,7 +64,9 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -79,8 +81,8 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will optimize without specific operators, by just calling the individual method
|
||||
* for initialization.
|
||||
* This method will optimize without specific operators, by just calling the
|
||||
* individual method for initialization.
|
||||
*/
|
||||
@Override
|
||||
public void optimize() {
|
||||
@@ -103,20 +105,23 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will init the HillClimber
|
||||
/**
|
||||
* This method will init the HillClimber
|
||||
*/
|
||||
public void defaultInit() {
|
||||
this.m_FitnessCallsNeeded = 0;
|
||||
@@ -124,7 +129,8 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
this.m_Best.defaultInit(m_Problem);
|
||||
}
|
||||
|
||||
/** This method will optimize
|
||||
/**
|
||||
* This method will optimize
|
||||
*/
|
||||
public void defaultOptimize() {
|
||||
for (int i = 0; i < m_FitnessCalls; i++) {
|
||||
@@ -140,8 +146,9 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
}
|
||||
}
|
||||
|
||||
/** This main method will start a simple hillclimber.
|
||||
* No arguments necessary.
|
||||
/**
|
||||
* This main method will start a simple hillclimber. No arguments necessary.
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
@@ -158,13 +165,16 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
System.out.println("(" + program.m_MultiRuns + "/" + program.m_FitnessCalls + ") Mean Fitness : " + TmpMeanFitness + " Mean Calls needed: " + TmpMeanCalls);
|
||||
}
|
||||
|
||||
/** This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
/**
|
||||
* This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
*
|
||||
* @param ea
|
||||
*/
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -175,7 +185,9 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Something has changed
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -183,8 +195,10 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -196,54 +210,62 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "The Monte Carlo Search repeatively creates random individuals and stores the best individuals found.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MCS";
|
||||
}
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Change the number of best individuals stored.";
|
||||
}
|
||||
|
@@ -32,21 +32,17 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable {
|
||||
*
|
||||
*/
|
||||
class CounterClass {
|
||||
|
||||
public CounterClass(int i) {
|
||||
value = i;
|
||||
}
|
||||
|
||||
public int value;
|
||||
public boolean seen = false;
|
||||
}
|
||||
|
||||
private String m_Identifier = "MOCMAES";
|
||||
|
||||
private Population m_Population;
|
||||
private AbstractOptimizationProblem m_Problem;
|
||||
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
|
||||
private int m_lambda = 1;
|
||||
private int m_lambdamo = 1;
|
||||
|
||||
@@ -105,15 +101,6 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see eva2.server.go.strategies.InterfaceOptimizer#freeWilly()
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -221,8 +208,7 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable {
|
||||
/**
|
||||
* This method will evaluate the current population using the given problem.
|
||||
*
|
||||
* @param population
|
||||
* The population that is to be evaluated
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void evaluatePopulation(Population population) {
|
||||
this.m_Problem.evaluate(population);
|
||||
@@ -417,5 +403,4 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable {
|
||||
*
|
||||
* public void setLambdaMo(int mLambda) { m_lambdamo = mLambda; }
|
||||
*/
|
||||
|
||||
}
|
||||
|
@@ -16,28 +16,17 @@ import eva2.server.go.problems.FM0Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/**
|
||||
* A generic framework for multi-objecitve optimization, you need
|
||||
* to specify an optimization strategy (like GA), an archiver and
|
||||
* an information retrival strategy. With this scheme you can realized:
|
||||
* Vector Evaluated GA
|
||||
* Random Weight GA
|
||||
* Multiple Objective GA
|
||||
* NSGA
|
||||
* NSGA-II
|
||||
* SPEA
|
||||
* SPEA 2
|
||||
* PESA
|
||||
* PESA-II
|
||||
* In case you address a multi-objective optimization problem with a single-
|
||||
* objective optimizer instead of this MOEA, such an optimizer would randomly
|
||||
* toggle between the objective for each selection and thus explore at least
|
||||
* the extreme points of the objective space, but simpler methods like
|
||||
* random search or hill-climbing might even fail on that.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 05.06.2003
|
||||
* Time: 11:03:50
|
||||
* To change this template use Options | File Templates.
|
||||
* A generic framework for multi-objecitve optimization, you need to specify an
|
||||
* optimization strategy (like GA), an archiver and an information retrival
|
||||
* strategy. With this scheme you can realized: Vector Evaluated GA Random
|
||||
* Weight GA Multiple Objective GA NSGA NSGA-II SPEA SPEA 2 PESA PESA-II In case
|
||||
* you address a multi-objective optimization problem with a single- objective
|
||||
* optimizer instead of this MOEA, such an optimizer would randomly toggle
|
||||
* between the objective for each selection and thus explore at least the
|
||||
* extreme points of the objective space, but simpler methods like random search
|
||||
* or hill-climbing might even fail on that. Created by IntelliJ IDEA. User:
|
||||
* streiche Date: 05.06.2003 Time: 11:03:50 To change this template use Options
|
||||
* | File Templates.
|
||||
*/
|
||||
public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
@@ -82,8 +71,9 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -94,7 +84,8 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** The optimize method will compute a 'improved' and evaluated population
|
||||
/**
|
||||
* The optimize method will compute a 'improved' and evaluated population
|
||||
*/
|
||||
@Override
|
||||
public void optimize() {
|
||||
@@ -186,7 +177,9 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@@ -194,13 +187,16 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
this.m_Problem = problem;
|
||||
this.m_Optimizer.setProblem(problem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -219,35 +215,37 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is a general Multi-objective Evolutionary Optimization Framework.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -255,19 +253,23 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
return "MOEA";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Optimizer.getPopulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Optimizer.setPopulation(pop);
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Edit the properties of the Population used.";
|
||||
}
|
||||
@@ -277,47 +279,61 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
return new SolutionSet(getPopulation(), ArchivingNSGAII.getNonDominatedSortedFront(getPopulation().getArchive()).getSortedPop(new AbstractEAIndividualComparator(0)));
|
||||
}
|
||||
|
||||
/** This method allows you to set/get the optimizing technique to use.
|
||||
/**
|
||||
* This method allows you to set/get the optimizing technique to use.
|
||||
*
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public InterfaceOptimizer getOptimizer() {
|
||||
return this.m_Optimizer;
|
||||
}
|
||||
|
||||
public void setOptimizer(InterfaceOptimizer b) {
|
||||
this.m_Optimizer = b;
|
||||
}
|
||||
|
||||
public String optimizerTipText() {
|
||||
return "Choose a population based optimizing technique to use.";
|
||||
}
|
||||
|
||||
/** This method allows you to set/get the archiving strategy to use.
|
||||
/**
|
||||
* This method allows you to set/get the archiving strategy to use.
|
||||
*
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public InterfaceArchiving getArchivingStrategy() {
|
||||
return this.m_Archiver;
|
||||
}
|
||||
|
||||
public void setArchivingStrategy(InterfaceArchiving b) {
|
||||
this.m_Archiver = b;
|
||||
}
|
||||
|
||||
public String archivingStrategyTipText() {
|
||||
return "Choose the archiving strategy.";
|
||||
}
|
||||
|
||||
|
||||
/** This method allows you to set/get the Information Retrieval strategy to use.
|
||||
/**
|
||||
* This method allows you to set/get the Information Retrieval strategy to
|
||||
* use.
|
||||
*
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public InterfaceInformationRetrieval getInformationRetrieval() {
|
||||
return this.m_InformationRetrieval;
|
||||
}
|
||||
|
||||
public void setInformationRetrieval(InterfaceInformationRetrieval b) {
|
||||
this.m_InformationRetrieval = b;
|
||||
}
|
||||
|
||||
public String informationRetrievalTipText() {
|
||||
return "Choose the Information Retrieval strategy.";
|
||||
}
|
||||
|
||||
/** This method allows you to set/get the size of the archive.
|
||||
/**
|
||||
* This method allows you to set/get the size of the archive.
|
||||
*
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public int getArchiveSize() {
|
||||
@@ -328,6 +344,7 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
}
|
||||
return archive.getTargetSize();
|
||||
}
|
||||
|
||||
public void setArchiveSize(int b) {
|
||||
Population archive = this.m_Optimizer.getPopulation().getArchive();
|
||||
if (archive == null) {
|
||||
@@ -336,6 +353,7 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
}
|
||||
archive.setTargetSize(b);
|
||||
}
|
||||
|
||||
public String archiveSizeTipText() {
|
||||
return "Choose the size of the archive.";
|
||||
}
|
||||
|
@@ -15,9 +15,9 @@ import java.io.Serializable;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Nelder-Mead-Simplex does not guarantee an equal number of evaluations within each optimize call
|
||||
* because of the different step types.
|
||||
* Range check is now available by projection at the bounds.
|
||||
* Nelder-Mead-Simplex does not guarantee an equal number of evaluations within
|
||||
* each optimize call because of the different step types. Range check is now
|
||||
* available by projection at the bounds.
|
||||
*
|
||||
* @author mkron
|
||||
*
|
||||
@@ -27,9 +27,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
|
||||
private int populationSize = 100;
|
||||
// simulating the generational cycle. Set rather small (eg 5) for use as local search, higher for global search (eg 50)
|
||||
private int generationCycle = 50;
|
||||
|
||||
private int fitIndex = 0; // choose criterion for multi objective functions
|
||||
|
||||
private Population m_Population;
|
||||
private AbstractOptimizationProblem m_Problem;
|
||||
private transient Vector<InterfacePopulationChangedEventListener> m_Listener;
|
||||
@@ -101,15 +99,11 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
if (m_Listener == null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return m_Listener.remove(ea);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeWilly() {}
|
||||
|
||||
protected double[] calcChallengeVect(double[] centroid, double[] refX) {
|
||||
double[] r = new double[centroid.length];
|
||||
for (int i = 0; i < r.length; i++) {
|
||||
@@ -370,10 +364,8 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
|
||||
/**
|
||||
* This method creates a Nelder-Mead instance.
|
||||
*
|
||||
* @param pop
|
||||
* The size of the population
|
||||
* @param problem
|
||||
* The problem to be optimized
|
||||
* @param pop The size of the population
|
||||
* @param problem The problem to be optimized
|
||||
* @param listener
|
||||
* @return An optimization procedure that performs nelder mead optimization.
|
||||
*/
|
||||
@@ -398,15 +390,15 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
|
||||
|
||||
/**
|
||||
* This method creates a Nelder-Mead instance with an initial population
|
||||
* around a given candidate solution. The population is created as a simplex with given
|
||||
* perturbation ratio or randomly across the search range if the perturbation ratio is
|
||||
* zero or below zero.
|
||||
* around a given candidate solution. The population is created as a simplex
|
||||
* with given perturbation ratio or randomly across the search range if the
|
||||
* perturbation ratio is zero or below zero.
|
||||
*
|
||||
*
|
||||
* @param problem
|
||||
* The problem to be optimized
|
||||
* @param problem The problem to be optimized
|
||||
* @param candidate starting point of the search
|
||||
* @param perturbationRatio perturbation ratio relative to the problem range for the initial simplex creation
|
||||
* @param perturbationRatio perturbation ratio relative to the problem range
|
||||
* for the initial simplex creation
|
||||
* @param listener
|
||||
* @return An optimization procedure that performs nelder mead optimization.
|
||||
*/
|
||||
@@ -441,11 +433,12 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
|
||||
}
|
||||
|
||||
/**
|
||||
* From a given candidate solution, create n solutions around the candidate, where every i-th
|
||||
* new candidate differs in i dimensions by a distance of perturbRatio relative to the range in
|
||||
* that dimension (respecting the range).
|
||||
* The new solutions are returned as a population, which, if includeCand is true,
|
||||
* also contains the initial candidate. However, the new candidates have not been evaluated.
|
||||
* From a given candidate solution, create n solutions around the candidate,
|
||||
* where every i-th new candidate differs in i dimensions by a distance of
|
||||
* perturbRatio relative to the range in that dimension (respecting the
|
||||
* range). The new solutions are returned as a population, which, if
|
||||
* includeCand is true, also contains the initial candidate. However, the
|
||||
* new candidates have not been evaluated.
|
||||
*
|
||||
* @param candidate
|
||||
* @param perturbRelative
|
||||
@@ -515,5 +508,4 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
|
||||
public String critIndexTipText() {
|
||||
return "For multi-criterial problems, set the index of the fitness to be used in 0..n-1. Default is 0";
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,5 @@
|
||||
package eva2.server.go.strategies;
|
||||
|
||||
|
||||
import eva2.gui.BeanInspector;
|
||||
import eva2.gui.GenericObjectEditor;
|
||||
import eva2.gui.Plot;
|
||||
@@ -22,28 +21,27 @@ import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
/**
|
||||
* This is a Particle Filter implemented by Frank Senke, only some documentation
|
||||
* here and not completely checked whether this works on arbitrary problem
|
||||
* instances. MK did some adaptations, this should work on real valued problems now.
|
||||
* instances. MK did some adaptations, this should work on real valued problems
|
||||
* now.
|
||||
*
|
||||
* This is a implementation of Genetic Algorithms.
|
||||
* Copyright: Copyright (c) 2003
|
||||
* This is a implementation of Genetic Algorithms. Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
*
|
||||
* @author Felix Streichert
|
||||
* @version: $Revision: 307 $
|
||||
* $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
* @version: $Revision: 307 $ $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec
|
||||
* 2007) $ $Author: mkron $
|
||||
*/
|
||||
|
||||
public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
/**
|
||||
* Comment for <code>serialVersionUID</code>
|
||||
* Comment for
|
||||
* <code>serialVersionUID</code>
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Population m_Population = new Population();
|
||||
private InterfaceOptimizationProblem m_Problem = new F1Problem();
|
||||
private InterfaceSelection m_ParentSelection = new SelectParticleWheel(0.5);
|
||||
//private boolean m_UseElitism = true;
|
||||
|
||||
private String m_Identifier = "";
|
||||
private boolean withShow = false;
|
||||
private double mutationSigma = 0.01;
|
||||
@@ -51,9 +49,7 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
private double initialVelocity = 0.02;
|
||||
private double rotationDeg = 20.;
|
||||
private int popSize = 300;
|
||||
|
||||
private int sleepTime = 0;
|
||||
|
||||
transient private int indCount = 0;
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
transient Plot myPlot = null;
|
||||
@@ -117,7 +113,9 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -131,8 +129,9 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will evaluate the current population using the
|
||||
* given problem.
|
||||
/**
|
||||
* This method will evaluate the current population using the given problem.
|
||||
*
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private Population evaluatePopulation(Population population) {
|
||||
@@ -157,8 +156,7 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
if (randomImmigrationQuota > 0) {
|
||||
if (randomImmigrationQuota > 1.) {
|
||||
System.err.println("Error, invalid immigration quota!");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
targetSize = (int) (this.m_Population.getTargetSize() * (1. - randomImmigrationQuota));
|
||||
targetSize = Math.max(1, targetSize); // guarantee at least one to be selected
|
||||
if (targetSize < this.m_Population.getTargetSize()) {
|
||||
@@ -218,8 +216,7 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
|
||||
if (useCircles) {
|
||||
myPlot.getFunctionArea().drawCircle("", curPosition, graphLabel);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
myPlot.setUnconnectedPoint(curPosition[0], curPosition[1], graphLabel);
|
||||
}
|
||||
// myPlot.setConnectedPoint(curPosition[0], curPosition[1], graphLabel);
|
||||
@@ -252,7 +249,10 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
nextGeneration = resample(m_Population);
|
||||
|
||||
if (sleepTime > 0) {
|
||||
try { Thread.sleep(sleepTime); } catch(Exception e) {}
|
||||
try {
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
if (withShow) {
|
||||
clearPlot();
|
||||
@@ -276,6 +276,7 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -286,13 +287,16 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
this.m_Listener.registerPopulationStateChanged(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@@ -302,13 +306,16 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
((AbstractOptimizationProblem) problem).informAboutOptimizer(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -320,35 +327,38 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
strB.append(this.m_Population.getStringRepresentation());
|
||||
return strB.toString();
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is a Particle Filter Algorithm.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -356,19 +366,23 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
return "PF";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Edit the properties of the population used.";
|
||||
}
|
||||
@@ -377,22 +391,28 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
/** This method will set the selection method that is to be used
|
||||
|
||||
/**
|
||||
* This method will set the selection method that is to be used
|
||||
*
|
||||
* @param selection
|
||||
*/
|
||||
public void setParentSelection(InterfaceSelection selection) {
|
||||
this.m_ParentSelection = selection;
|
||||
}
|
||||
|
||||
public InterfaceSelection getParentSelection() {
|
||||
return this.m_ParentSelection;
|
||||
}
|
||||
|
||||
public String parentSelectionTipText() {
|
||||
return "Choose a parent selection method.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the withShow
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public boolean isWithShow() {
|
||||
return withShow;
|
||||
}
|
||||
@@ -416,18 +436,17 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
|
||||
/**
|
||||
* @param withShow the withShow to set
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void setWithShow(boolean wShow) {
|
||||
this.withShow = wShow;
|
||||
if (!withShow) {
|
||||
myPlot = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
double[][] range;
|
||||
if ((m_Population != null) && (m_Population.size() > 0)) {
|
||||
range = ((InterfaceDataTypeDouble) this.m_Population.get(0)).getDoubleRange();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
range = new double[2][];
|
||||
range[0] = new double[2];
|
||||
range[0][0] = 0;
|
||||
@@ -440,28 +459,32 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
|
||||
|
||||
/**
|
||||
* @return the sleepTime
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public int getSleepTime() {
|
||||
return sleepTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sleepTime the sleepTime to set
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void setSleepTime(int sleepTime) {
|
||||
this.sleepTime = sleepTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mutationSigma
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public double getMutationSigma() {
|
||||
return mutationSigma;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mutationSigma the mutationSigma to set
|
||||
**/
|
||||
*
|
||||
*/
|
||||
public void setMutationSigma(double mutationSigma) {
|
||||
this.mutationSigma = mutationSigma;
|
||||
}
|
||||
|
@@ -1731,14 +1731,6 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is required to free the memory on a RMIServer, but there is
|
||||
* nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
}
|
||||
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
|
@@ -13,23 +13,23 @@ import eva2.server.go.problems.AbstractOptimizationProblem;
|
||||
import eva2.server.go.problems.B1Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/** Population based incremental learning in the PSM by Monmarche
|
||||
* version with also allows to simulate ant systems due to the flexible
|
||||
* update rule of V. But both are limited to binary genotypes.
|
||||
* This is a simple implementation of Population Based Incremental Learning.
|
||||
/**
|
||||
* Population based incremental learning in the PSM by Monmarche version with
|
||||
* also allows to simulate ant systems due to the flexible update rule of V. But
|
||||
* both are limited to binary genotypes. This is a simple implementation of
|
||||
* Population Based Incremental Learning.
|
||||
*
|
||||
* Nicolas Monmarché , Eric Ramat , Guillaume Dromel , Mohamed Slimane , Gilles Venturini:
|
||||
* On the similarities between AS, BSC and PBIL: toward the birth of a new meta-heuristic.
|
||||
* TecReport 215. Univ. de Tours, 1999.
|
||||
* Nicolas Monmarché , Eric Ramat , Guillaume Dromel , Mohamed Slimane , Gilles
|
||||
* Venturini: On the similarities between AS, BSC and PBIL: toward the birth of
|
||||
* a new meta-heuristic. TecReport 215. Univ. de Tours, 1999.
|
||||
*
|
||||
* Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
|
||||
* Architecture
|
||||
*
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Felix Streichert
|
||||
* @version: $Revision: 307 $
|
||||
* $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
* @version: $Revision: 307 $ $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec
|
||||
* 2007) $ $Author: mkron $
|
||||
*/
|
||||
|
||||
public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
// These variables are necessary for the simple testcase
|
||||
@@ -78,7 +78,9 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -97,8 +99,9 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will evaluate the current population using the
|
||||
* given problem.
|
||||
/**
|
||||
* This method will evaluate the current population using the given problem.
|
||||
*
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void evaluatePopulation(Population population) {
|
||||
@@ -106,8 +109,9 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
population.incrGeneration();
|
||||
}
|
||||
|
||||
/** This method will generate the offspring population from the
|
||||
* given population of evaluated individuals.
|
||||
/**
|
||||
* This method will generate the offspring population from the given
|
||||
* population of evaluated individuals.
|
||||
*/
|
||||
private Population generateChildren() {
|
||||
PBILPopulation result = (PBILPopulation) this.m_Population.clone();
|
||||
@@ -141,7 +145,9 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@@ -153,14 +159,17 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -171,7 +180,9 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Something has changed
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -179,8 +190,10 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -192,35 +205,38 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "The Population based incremental learning is based on a statistical distribution of bit positions. Please note: This optimizer requires a binary genotype!";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -228,19 +244,23 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
return "PBIL";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Edit the properties of the PBIL population used.";
|
||||
}
|
||||
@@ -262,33 +282,43 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
// return "Select the normation method.";
|
||||
// }
|
||||
|
||||
/** This method will set the selection method that is to be used
|
||||
/**
|
||||
* This method will set the selection method that is to be used
|
||||
*
|
||||
* @param selection
|
||||
*/
|
||||
public void setSelectionMethod(InterfaceSelection selection) {
|
||||
this.m_SelectionOperator = selection;
|
||||
}
|
||||
|
||||
public InterfaceSelection getSelectionMethod() {
|
||||
return this.m_SelectionOperator;
|
||||
}
|
||||
|
||||
public String selectionMethodTipText() {
|
||||
return "Choose a selection method.";
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param elitism
|
||||
*/
|
||||
public void setElitism(boolean elitism) {
|
||||
this.m_UseElitism = elitism;
|
||||
}
|
||||
|
||||
public boolean getElitism() {
|
||||
return this.m_UseElitism;
|
||||
}
|
||||
|
||||
public String elitismTipText() {
|
||||
return "Enable/disable elitism.";
|
||||
}
|
||||
|
||||
/** This method will set the learning rate for PBIL
|
||||
/**
|
||||
* This method will set the learning rate for PBIL
|
||||
*
|
||||
* @param LearningRate
|
||||
*/
|
||||
public void setLearningRate(double LearningRate) {
|
||||
@@ -297,14 +327,18 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
this.m_LearningRate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getLearningRate() {
|
||||
return this.m_LearningRate;
|
||||
}
|
||||
|
||||
public String learningRateTipText() {
|
||||
return "The learing rate of PBIL.";
|
||||
}
|
||||
|
||||
/** This method will set the mutation rate for PBIL
|
||||
/**
|
||||
* This method will set the mutation rate for PBIL
|
||||
*
|
||||
* @param m
|
||||
*/
|
||||
public void setMutationRate(double m) {
|
||||
@@ -316,14 +350,18 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
this.m_MutationRate = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public double getMutationRate() {
|
||||
return this.m_MutationRate;
|
||||
}
|
||||
|
||||
public String mutationRateTipText() {
|
||||
return "The mutation rate of PBIL.";
|
||||
}
|
||||
|
||||
/** This method will set the mutation sigma for PBIL
|
||||
/**
|
||||
* This method will set the mutation sigma for PBIL
|
||||
*
|
||||
* @param m
|
||||
*/
|
||||
public void setMutateSigma(double m) {
|
||||
@@ -332,14 +370,18 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
this.m_MutateSigma = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getMutateSigma() {
|
||||
return this.m_MutateSigma;
|
||||
}
|
||||
|
||||
public String mutateSigmaTipText() {
|
||||
return "Set the sigma for the mutation of the probability vector.";
|
||||
}
|
||||
|
||||
/** This method will set the number of positive samples for PBIL
|
||||
/**
|
||||
* This method will set the number of positive samples for PBIL
|
||||
*
|
||||
* @param PositiveSamples
|
||||
*/
|
||||
public void setPositiveSamples(int PositiveSamples) {
|
||||
@@ -348,9 +390,11 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
|
||||
this.m_NumberOfPositiveSamples = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getPositiveSamples() {
|
||||
return this.m_NumberOfPositiveSamples;
|
||||
}
|
||||
|
||||
public String positiveSamplesTipText() {
|
||||
return "The number of positive samples that update the PBIL vector.";
|
||||
}
|
||||
|
@@ -25,19 +25,23 @@ import eva2.tools.math.RNG;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A ScatterSearch implementation taken mainly from [1]. Unfortunately, some parameters as well as
|
||||
* the local search method are not well defined in [1], so this implementation allows HC and Nelder-Mead
|
||||
* as local search. If local search is activated, an additional filter is defined, meaning that only those
|
||||
* A ScatterSearch implementation taken mainly from [1]. Unfortunately, some
|
||||
* parameters as well as the local search method are not well defined in [1], so
|
||||
* this implementation allows HC and Nelder-Mead as local search. If local
|
||||
* search is activated, an additional filter is defined, meaning that only those
|
||||
* individuals with a high quality fitness are further improved by local search.
|
||||
* The threshold fitness is either defined relatively to the best/worst fitness values in the reference set
|
||||
* or as an absolute value (in both cases only the first fitness criterion is regarded).
|
||||
* The threshold fitness is either defined relatively to the best/worst fitness
|
||||
* values in the reference set or as an absolute value (in both cases only the
|
||||
* first fitness criterion is regarded).
|
||||
*
|
||||
* @author mkron
|
||||
*
|
||||
* [1] M.Rodiguez-Fernandez, J.Egea, J.Banga: Novel metaheuristic for parameter estimation in nonlinear dynamic biological systems.
|
||||
* BMC Bioinformatics 2006, 7:483. BioMed Central 2006.
|
||||
* [1] M.Rodiguez-Fernandez, J.Egea, J.Banga: Novel metaheuristic for parameter
|
||||
* estimation in nonlinear dynamic biological systems. BMC Bioinformatics 2006,
|
||||
* 7:483. BioMed Central 2006.
|
||||
*/
|
||||
public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable, InterfacePopulationChangedEventListener {
|
||||
|
||||
transient private InterfacePopulationChangedEventListener m_Listener = null;
|
||||
private String m_Identifier = "ScatterSearch";
|
||||
private AbstractOptimizationProblem problem = new F1Problem();
|
||||
@@ -58,9 +62,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
// simulate an EvA generational cycle
|
||||
private int generationCycle = 50;
|
||||
private int fitCrit = -1;
|
||||
|
||||
protected boolean checkRange = true;
|
||||
|
||||
// private int lastLocalSearch = -1;
|
||||
// // nr of generations between local searches
|
||||
// protected int localSearchInterval = 10;
|
||||
@@ -71,7 +73,6 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
private double nelderMeadInitPerturbation = 0.01;
|
||||
private double improvementEpsilon = 0.1; // minimal relative fitness improvement for a candidate to be taken over into the refset
|
||||
private double minDiversityEpsilon = 0.0001; // minimal phenotypic distance for a candidate to be taken over into the refset
|
||||
|
||||
private static boolean TRACE = false;
|
||||
|
||||
public ScatterSearch() {
|
||||
@@ -134,6 +135,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
|
||||
/**
|
||||
* Eval an initial population and extract the first refset.
|
||||
*
|
||||
* @param pop
|
||||
*/
|
||||
private void initRefSet(Population pop) {
|
||||
@@ -160,8 +162,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
template = problem.getIndividualTemplate();
|
||||
if (!(template instanceof InterfaceDataTypeDouble)) {
|
||||
System.err.println("Requiring double data!");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Object dim = BeanInspector.callIfAvailable(problem, "getProblemDimension", null);
|
||||
if (dim == null) {
|
||||
System.err.println("Couldnt get problem dimension!");
|
||||
@@ -174,7 +175,8 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
}
|
||||
}
|
||||
|
||||
/** Something has changed
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -188,7 +190,6 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
// problem.evaluate(indy);
|
||||
// return indy.getFitness(0);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void registerPopulationStateChanged(Object source, String name) {
|
||||
// The events of the interim hill climbing population will be caught here
|
||||
@@ -351,10 +352,11 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe replace the single worst indy in the refset by the best candidate, which may
|
||||
* be locally optimized in a local search step.
|
||||
* The best candidate is removed from the candidate set in any case. The candidate set
|
||||
* may be cleared if all following individuals would never be taken over to the refset.
|
||||
* Maybe replace the single worst indy in the refset by the best candidate,
|
||||
* which may be locally optimized in a local search step. The best candidate
|
||||
* is removed from the candidate set in any case. The candidate set may be
|
||||
* cleared if all following individuals would never be taken over to the
|
||||
* refset.
|
||||
*
|
||||
* @param refSet
|
||||
* @param candidates
|
||||
@@ -407,8 +409,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
// so we can just clear the rest of the candidates
|
||||
if (!doLocalSearch && (bestCand.getFitness().length == 1)) {
|
||||
candidates.clear();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
candidates.remove(bestIndex);
|
||||
}
|
||||
}
|
||||
@@ -417,8 +418,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
private Pair<AbstractEAIndividual, Integer> localSolver(AbstractEAIndividual cand, int hcSteps) {
|
||||
if (localSearchMethod.getSelectedTagID() == 0) {
|
||||
return localSolverHC(cand, hcSteps);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return PostProcess.localSolverNMS(cand, hcSteps, nelderMeadInitPerturbation, problem);
|
||||
}
|
||||
}
|
||||
@@ -449,8 +449,8 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for both a genotype and phenotype diversity criterion which both must
|
||||
* be fulfilled for a candidate to be accepted.
|
||||
* Check for both a genotype and phenotype diversity criterion which both
|
||||
* must be fulfilled for a candidate to be accepted.
|
||||
*
|
||||
* @param cand
|
||||
* @param popCompGeno
|
||||
@@ -475,6 +475,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
|
||||
/**
|
||||
* Recombines the refset to new indies which are also evaluated.
|
||||
*
|
||||
* @param refSet
|
||||
* @return
|
||||
*/
|
||||
@@ -514,8 +515,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
combs.add(combineTypeTwo(indy1, indy2));
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
combs.add(combineTypeOne(indy1, indy2));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
combs.add(combineTypeThree(indy1, indy2));
|
||||
}
|
||||
}
|
||||
@@ -530,9 +530,11 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
private AbstractEAIndividual combineTypeOne(AbstractEAIndividual indy1, AbstractEAIndividual indy2) {
|
||||
return combine(indy1, indy2, true, false);
|
||||
}
|
||||
|
||||
private AbstractEAIndividual combineTypeTwo(AbstractEAIndividual indy1, AbstractEAIndividual indy2) {
|
||||
return combine(indy1, indy2, true, true);
|
||||
}
|
||||
|
||||
private AbstractEAIndividual combineTypeThree(AbstractEAIndividual indy1, AbstractEAIndividual indy2) {
|
||||
return combine(indy1, indy2, false, true);
|
||||
}
|
||||
@@ -737,7 +739,6 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
}
|
||||
|
||||
///////////// Trivials...
|
||||
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
m_Identifier = name;
|
||||
@@ -758,6 +759,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -768,8 +770,6 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void freeWilly() {}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
@@ -871,7 +871,6 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
}
|
||||
|
||||
////////////////////////////////////////////7
|
||||
|
||||
/**
|
||||
* This method performs a scatter search runnable.
|
||||
*/
|
||||
@@ -998,9 +997,11 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
public double getImprovementEpsilon() {
|
||||
return improvementEpsilon;
|
||||
}
|
||||
|
||||
public void setImprovementEpsilon(double improvementEpsilon) {
|
||||
this.improvementEpsilon = improvementEpsilon;
|
||||
}
|
||||
|
||||
public String improvementEpsilonTipText() {
|
||||
return "Minimal relative fitness improvement for a candidate to enter the refSet - set to zero to deactivate.";
|
||||
}
|
||||
@@ -1008,9 +1009,11 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
public double getMinDiversityEpsilon() {
|
||||
return minDiversityEpsilon;
|
||||
}
|
||||
|
||||
public void setMinDiversityEpsilon(double minDiversityEpsilon) {
|
||||
this.minDiversityEpsilon = minDiversityEpsilon;
|
||||
}
|
||||
|
||||
public String minDiversityEpsilonTipText() {
|
||||
return "Minimal distance to other individuals in the refSet for a candidate to enter the refSet - set to zero to deactivate.";
|
||||
}
|
||||
|
@@ -10,18 +10,17 @@ import eva2.server.go.problems.B1Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
/** Simulated Annealing by Nelder and Mead, a simple yet efficient local search
|
||||
/**
|
||||
* Simulated Annealing by Nelder and Mead, a simple yet efficient local search
|
||||
* method. But to become less prone to premature convergence the cooling rate
|
||||
* has to be tuned to the optimization problem at hand. Again the population size
|
||||
* gives the number of multi-starts.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 13.05.2004
|
||||
* Time: 10:30:26
|
||||
* To change this template use File | Settings | File Templates.
|
||||
* has to be tuned to the optimization problem at hand. Again the population
|
||||
* size gives the number of multi-starts. Created by IntelliJ IDEA. User:
|
||||
* streiche Date: 13.05.2004 Time: 10:30:26 To change this template use File |
|
||||
* Settings | File Templates.
|
||||
*/
|
||||
public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializable {
|
||||
// These variables are necessary for the simple testcase
|
||||
|
||||
private InterfaceOptimizationProblem m_Problem = new B1Problem();
|
||||
private int m_MultiRuns = 100;
|
||||
private int m_FitnessCalls = 100;
|
||||
@@ -29,7 +28,6 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
GAIndividualBinaryData m_Best, m_Test;
|
||||
public double m_InitialTemperature = 2, m_CurrentTemperature;
|
||||
public double m_Alpha = 0.9;
|
||||
|
||||
// These variables are necessary for the more complex LectureGUI enviroment
|
||||
transient private String m_Identifier = "";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
@@ -53,7 +51,8 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
return (Object) new SimulatedAnnealing(this);
|
||||
}
|
||||
|
||||
/** This method will init the HillClimber
|
||||
/**
|
||||
* This method will init the HillClimber
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
@@ -63,7 +62,9 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -78,7 +79,8 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will optimize
|
||||
/**
|
||||
* This method will optimize
|
||||
*/
|
||||
@Override
|
||||
public void optimize() {
|
||||
@@ -112,7 +114,9 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method calculates the difference between the fitness values
|
||||
/**
|
||||
* This method calculates the difference between the fitness values
|
||||
*
|
||||
* @param org The original
|
||||
* @param mut The mutant
|
||||
*/
|
||||
@@ -127,19 +131,23 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will init the HillClimber
|
||||
/**
|
||||
* This method will init the HillClimber
|
||||
*/
|
||||
public void defaultInit() {
|
||||
this.m_FitnessCallsNeeded = 0;
|
||||
@@ -147,7 +155,8 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
this.m_Best.defaultInit(m_Problem);
|
||||
}
|
||||
|
||||
/** This method will optimize
|
||||
/**
|
||||
* This method will optimize
|
||||
*/
|
||||
public void defaultOptimize() {
|
||||
for (int i = 0; i < m_FitnessCalls; i++) {
|
||||
@@ -163,8 +172,9 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
}
|
||||
}
|
||||
|
||||
/** This main method will start a simple hillclimber.
|
||||
* No arguments necessary.
|
||||
/**
|
||||
* This main method will start a simple hillclimber. No arguments necessary.
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
@@ -185,6 +195,7 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -195,14 +206,17 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
this.m_Listener.registerPopulationStateChanged(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -210,8 +224,7 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
String result = "";
|
||||
if (this.m_Population.size() > 1) {
|
||||
result += "Multi(" + this.m_Population.size() + ")-Start Hill Climbing:\n";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result += "Simulated Annealing:\n";
|
||||
}
|
||||
result += "Optimization Problem: ";
|
||||
@@ -219,54 +232,62 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "The simulated annealing uses an additional cooling rate instead of a simple dominate criteria to accpect worse solutions by chance.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MS-SA";
|
||||
}
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Change the number of best individuals stored (MS-SA)).";
|
||||
}
|
||||
@@ -275,31 +296,40 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
/** Set the initial temperature
|
||||
|
||||
/**
|
||||
* Set the initial temperature
|
||||
*
|
||||
* @return The initial temperature.
|
||||
*/
|
||||
public double getInitialTemperature() {
|
||||
return this.m_InitialTemperature;
|
||||
}
|
||||
|
||||
public void setInitialTemperature(double pop) {
|
||||
this.m_InitialTemperature = pop;
|
||||
}
|
||||
|
||||
public String initialTemperatureTipText() {
|
||||
return "Set the initial temperature.";
|
||||
}
|
||||
|
||||
/** Set alpha, which is used to degrade the temperaure
|
||||
/**
|
||||
* Set alpha, which is used to degrade the temperaure
|
||||
*
|
||||
* @return The cooling rate.
|
||||
*/
|
||||
public double getAlpha() {
|
||||
return this.m_Alpha;
|
||||
}
|
||||
|
||||
public void setAlpha(double a) {
|
||||
this.m_Alpha = a;
|
||||
if (this.m_Alpha > 1) {
|
||||
this.m_Alpha = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
public String alphaTipText() {
|
||||
return "Set alpha, which is used to degrade the temperaure.";
|
||||
}
|
||||
|
@@ -13,14 +13,12 @@ import eva2.server.go.populations.SolutionSet;
|
||||
import eva2.server.go.problems.B1Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/** A simple implementation of the steady-state GA with variable
|
||||
* replacement schemes. To reduce the logging effort population.size()
|
||||
* optimization steps are performed each time optimize() is called.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 19.07.2005
|
||||
* Time: 14:30:20
|
||||
* To change this template use File | Settings | File Templates.
|
||||
/**
|
||||
* A simple implementation of the steady-state GA with variable replacement
|
||||
* schemes. To reduce the logging effort population.size() optimization steps
|
||||
* are performed each time optimize() is called. Created by IntelliJ IDEA. User:
|
||||
* streiche Date: 19.07.2005 Time: 14:30:20 To change this template use File |
|
||||
* Settings | File Templates.
|
||||
*/
|
||||
public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
@@ -30,7 +28,6 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
private InterfaceSelection m_PartnerSelection = new SelectTournament();
|
||||
private InterfaceReplacement m_ReplacementSelection = new ReplaceWorst();
|
||||
private int m_NumberOfPartners = 1;
|
||||
|
||||
private String m_Identifier = "";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
|
||||
@@ -59,7 +56,9 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@Override
|
||||
@@ -72,8 +71,9 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will evaluate the current population using the
|
||||
* given problem.
|
||||
/**
|
||||
* This method will evaluate the current population using the given problem.
|
||||
*
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void evaluatePopulation(Population population) {
|
||||
@@ -81,8 +81,10 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
population.incrGeneration();
|
||||
}
|
||||
|
||||
/** This method will assign fitness values to all individual in the
|
||||
* current population.
|
||||
/**
|
||||
* This method will assign fitness values to all individual in the current
|
||||
* population.
|
||||
*
|
||||
* @param population The population that is to be evaluated
|
||||
*/
|
||||
private void defaultEvaluatePopulation(Population population) {
|
||||
@@ -95,8 +97,9 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
population.incrGeneration();
|
||||
}
|
||||
|
||||
/** This method will generate the offspring population from the
|
||||
* given population of evaluated individuals.
|
||||
/**
|
||||
* This method will generate the offspring population from the given
|
||||
* population of evaluated individuals.
|
||||
*/
|
||||
private void generateChildren() {
|
||||
this.m_ParentSelection.prepareSelection(this.m_Population);
|
||||
@@ -119,10 +122,12 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
this.m_Population.incrGeneration();
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -133,26 +138,32 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
this.m_Listener.registerPopulationStateChanged(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -164,35 +175,38 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is a Steady-State Genetic Algorithm.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -200,19 +214,23 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
return "SS-GA";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Edit the properties of the population used.";
|
||||
}
|
||||
@@ -221,21 +239,28 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
/** This method will set the parent selection method that is to be used
|
||||
|
||||
/**
|
||||
* This method will set the parent selection method that is to be used
|
||||
*
|
||||
* @param selection
|
||||
*/
|
||||
public void setParentSelection(InterfaceSelection selection) {
|
||||
this.m_ParentSelection = selection;
|
||||
}
|
||||
|
||||
public InterfaceSelection getParentSelection() {
|
||||
return this.m_ParentSelection;
|
||||
}
|
||||
|
||||
public String parentSelectionTipText() {
|
||||
return "Choose a parent selection method.";
|
||||
}
|
||||
|
||||
/** This method will set the number of partners that are needed to create
|
||||
/**
|
||||
* This method will set the number of partners that are needed to create
|
||||
* offsprings by mating
|
||||
*
|
||||
* @param partners
|
||||
*/
|
||||
public void setNumberOfPartners(int partners) {
|
||||
@@ -244,35 +269,46 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
this.m_NumberOfPartners = partners;
|
||||
}
|
||||
|
||||
public int getNumberOfPartners() {
|
||||
return this.m_NumberOfPartners;
|
||||
}
|
||||
|
||||
public String numberOfPartnersTipText() {
|
||||
return "The number of mating partners needed to create offsprings.";
|
||||
}
|
||||
|
||||
/** Choose a selection method for selecting recombination partners for given parents
|
||||
/**
|
||||
* Choose a selection method for selecting recombination partners for given
|
||||
* parents
|
||||
*
|
||||
* @param selection
|
||||
*/
|
||||
public void setPartnerSelection(InterfaceSelection selection) {
|
||||
this.m_PartnerSelection = selection;
|
||||
}
|
||||
|
||||
public InterfaceSelection getPartnerSelection() {
|
||||
return this.m_PartnerSelection;
|
||||
}
|
||||
|
||||
public String partnerSelectionTipText() {
|
||||
return "Choose a selection method for selecting recombination partners for given parents.";
|
||||
}
|
||||
|
||||
/** Choose a replacement strategy
|
||||
/**
|
||||
* Choose a replacement strategy
|
||||
*
|
||||
* @param selection
|
||||
*/
|
||||
public void setReplacementSelection(InterfaceReplacement selection) {
|
||||
this.m_ReplacementSelection = selection;
|
||||
}
|
||||
|
||||
public InterfaceReplacement getReplacementSelection() {
|
||||
return this.m_ReplacementSelection;
|
||||
}
|
||||
|
||||
public String replacementSelectionTipText() {
|
||||
return "Choose a replacement strategy.";
|
||||
}
|
||||
|
@@ -9,16 +9,14 @@ import eva2.server.go.populations.SolutionSet;
|
||||
import eva2.server.go.problems.B1Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/** Threshold accepting algorithm simliar strategy as the flood
|
||||
* algorithm, similar problems.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 01.10.2004
|
||||
* Time: 13:35:49
|
||||
* To change this template use File | Settings | File Templates.
|
||||
/**
|
||||
* Threshold accepting algorithm simliar strategy as the flood algorithm,
|
||||
* similar problems. Created by IntelliJ IDEA. User: streiche Date: 01.10.2004
|
||||
* Time: 13:35:49 To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializable {
|
||||
// These variables are necessary for the simple testcase
|
||||
|
||||
private InterfaceOptimizationProblem m_Problem = new B1Problem();
|
||||
private int m_MultiRuns = 100;
|
||||
private int m_FitnessCalls = 100;
|
||||
@@ -26,7 +24,6 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
GAIndividualBinaryData m_Best, m_Test;
|
||||
public double m_InitialT = 2, m_CurrentT;
|
||||
public double m_Alpha = 0.9;
|
||||
|
||||
// These variables are necessary for the more complex LectureGUI enviroment
|
||||
transient private String m_Identifier = "";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener;
|
||||
@@ -50,7 +47,8 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
return (Object) new ThresholdAlgorithm(this);
|
||||
}
|
||||
|
||||
/** This method will init the HillClimber
|
||||
/**
|
||||
* This method will init the HillClimber
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
@@ -60,7 +58,9 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -75,7 +75,8 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will optimize
|
||||
/**
|
||||
* This method will optimize
|
||||
*/
|
||||
@Override
|
||||
public void optimize() {
|
||||
@@ -103,7 +104,9 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method calculates the difference between the fitness values
|
||||
/**
|
||||
* This method calculates the difference between the fitness values
|
||||
*
|
||||
* @param org The original
|
||||
* @param mut The mutant
|
||||
*/
|
||||
@@ -118,19 +121,23 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will init the HillClimber
|
||||
/**
|
||||
* This method will init the HillClimber
|
||||
*/
|
||||
public void defaultInit() {
|
||||
this.m_FitnessCallsNeeded = 0;
|
||||
@@ -138,7 +145,8 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
this.m_Best.defaultInit(m_Problem);
|
||||
}
|
||||
|
||||
/** This method will optimize
|
||||
/**
|
||||
* This method will optimize
|
||||
*/
|
||||
public void defaultOptimize() {
|
||||
for (int i = 0; i < m_FitnessCalls; i++) {
|
||||
@@ -154,8 +162,9 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
}
|
||||
}
|
||||
|
||||
/** This main method will start a simple hillclimber.
|
||||
* No arguments necessary.
|
||||
/**
|
||||
* This main method will start a simple hillclimber. No arguments necessary.
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
@@ -171,10 +180,12 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
TmpMeanFitness /= program.m_MultiRuns;
|
||||
System.out.println("(" + program.m_MultiRuns + "/" + program.m_FitnessCalls + ") Mean Fitness : " + TmpMeanFitness + " Mean Calls needed: " + TmpMeanCalls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -185,14 +196,17 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
this.m_Listener.registerPopulationStateChanged(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -200,8 +214,7 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
String result = "";
|
||||
if (this.m_Population.size() > 1) {
|
||||
result += "Multi(" + this.m_Population.size() + ")-Start Hill Climbing:\n";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result += "Threshold Algorithm:\n";
|
||||
}
|
||||
result += "Optimization Problem: ";
|
||||
@@ -209,54 +222,62 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "The threshold algorithm uses an declining threshold to accpect new solutions.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MS-TA";
|
||||
}
|
||||
/** Assuming that all optimizer will store thier data in a population
|
||||
* we will allow acess to this population to query to current state
|
||||
* of the optimizer.
|
||||
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "Change the number of best individuals stored (MS-TA).";
|
||||
}
|
||||
@@ -265,31 +286,40 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
/** Set the initial threshold
|
||||
|
||||
/**
|
||||
* Set the initial threshold
|
||||
*
|
||||
* @return The initial temperature.
|
||||
*/
|
||||
public double getInitialT() {
|
||||
return this.m_InitialT;
|
||||
}
|
||||
|
||||
public void setInitialT(double pop) {
|
||||
this.m_InitialT = pop;
|
||||
}
|
||||
|
||||
public String initialTTipText() {
|
||||
return "Set the initial threshold.";
|
||||
}
|
||||
|
||||
/** Set alpha, which is used to degrade the threshold
|
||||
/**
|
||||
* Set alpha, which is used to degrade the threshold
|
||||
*
|
||||
* @return The initial temperature.
|
||||
*/
|
||||
public double getAlpha() {
|
||||
return this.m_Alpha;
|
||||
}
|
||||
|
||||
public void setAlpha(double a) {
|
||||
this.m_Alpha = a;
|
||||
if (this.m_Alpha > 1) {
|
||||
this.m_Alpha = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
public String alphaTipText() {
|
||||
return "Set alpha, which is used to degrade the threshold.";
|
||||
}
|
||||
|
@@ -17,30 +17,30 @@ import eva2.server.go.strategies.tribes.TribesSwarm;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* This is the TRIBES algorithm, an adaptive, parameter-less PSO implementation.
|
||||
* I (MK) ported M.Clerc's java version 2006-02 21 and added the original notes below.
|
||||
* I had to do some modifications for the EvA framework, namely:
|
||||
* - minor adaptations allover the code to fit into the framework
|
||||
* - the objective value parameter must now be set within the GUI for each problem by hand (EvA doesnt assume to know an objective beforehand)
|
||||
* - discrete search spaces are not directly supported any more (no "granularity")
|
||||
* - the benchmark-collection is gone, it might be included into the EvA benchmark set in the future, though
|
||||
* - fixed two bugs (SunnySpell link generation, findWorst method)
|
||||
* - fixed bugs in the CEC 2005 benchmarks (see the corresponding class)
|
||||
* - I widely kept the original comments, except for places I changed the code so much that they might mislead
|
||||
* - thats all, I think
|
||||
* I (MK) ported M.Clerc's java version 2006-02 21 and added the original notes
|
||||
* below. I had to do some modifications for the EvA framework, namely: - minor
|
||||
* adaptations allover the code to fit into the framework - the objective value
|
||||
* parameter must now be set within the GUI for each problem by hand (EvA doesnt
|
||||
* assume to know an objective beforehand) - discrete search spaces are not
|
||||
* directly supported any more (no "granularity") - the benchmark-collection is
|
||||
* gone, it might be included into the EvA benchmark set in the future, though -
|
||||
* fixed two bugs (SunnySpell link generation, findWorst method) - fixed bugs in
|
||||
* the CEC 2005 benchmarks (see the corresponding class) - I widely kept the
|
||||
* original comments, except for places I changed the code so much that they
|
||||
* might mislead - thats all, I think
|
||||
*
|
||||
* I could produce similar results as Clerc's on Rosenbrock and Griewank, (in his book on p. 148),
|
||||
* I couldnt reproduce the 100% success rate on Ackley, though.
|
||||
* I could produce similar results as Clerc's on Rosenbrock and Griewank, (in
|
||||
* his book on p. 148), I couldnt reproduce the 100% success rate on Ackley,
|
||||
* though.
|
||||
*
|
||||
* @author Maurice Clerc, Marcel Kronfeld
|
||||
* @date 2007-09-13
|
||||
*
|
||||
* Original notes:
|
||||
* @version 2006-02 21
|
||||
* @author Maurice.Clerc@WriteMe.com
|
||||
* {@link http://mauriceclerc.net}
|
||||
* @author Maurice.Clerc@WriteMe.com {@link http://mauriceclerc.net}
|
||||
* {@link http://clerc.maurice.free.fr/pso/}
|
||||
*
|
||||
*/
|
||||
@@ -129,47 +129,39 @@ import java.util.List;
|
||||
2005-11-21. Check if it is possible to easily find just the _value_ of the
|
||||
global minimum (not the position). "Chinese shadow" method?
|
||||
*/
|
||||
|
||||
public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
public static final boolean TRACE = false;
|
||||
|
||||
protected String m_Identifier = "TRIBES";
|
||||
transient private InterfacePopulationChangedEventListener m_Listener = null;
|
||||
protected AbstractOptimizationProblem m_problem;
|
||||
protected Population population;
|
||||
|
||||
public static int maxExplorerNb = 200;
|
||||
public static int maxMemoryNb = 300;
|
||||
public static int maxTribeNb = 300;
|
||||
|
||||
public static int[] strategies = new int[10]; // Just for information
|
||||
public static int[] status = new int[9]; // Just for information
|
||||
|
||||
public static boolean testBC = false; // TODO project to EvA2
|
||||
public static int adaptOption = 2;
|
||||
public static double blind = 0; // 0.5 //"Blind" move for very good particles, with a probability Tribes.blind
|
||||
public static boolean repel = false; // If 1, use a "repelling" strategy (see moveExplorer() )
|
||||
private boolean checkConstraints = true;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
TribesSwarm swarm = null;
|
||||
private int iter;
|
||||
protected double objectiveFirstDim = 0.;
|
||||
protected double[][] range, initRange;
|
||||
protected int notifyGenChangedEvery = 10;
|
||||
|
||||
protected int problemDim;
|
||||
protected int adaptThreshold, adaptMax, adapt;
|
||||
protected int informOption; /* For the best informant.
|
||||
-1 => really the best
|
||||
1 => the best according to a pseudo-gradient method
|
||||
*/
|
||||
|
||||
protected int initExplorerNb = 3; // Number of explorers at the very beginning
|
||||
// use full range (0) or subspace (1) for init options 0 and 1
|
||||
protected int rangeInitType = 1;
|
||||
|
||||
private boolean m_Show = false;
|
||||
transient protected eva2.gui.Plot m_Plot = null;
|
||||
// private int useAnchors = 0; // use anchors to detect environment changes?
|
||||
@@ -244,9 +236,10 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* As TRIBES manages an own structured set of particles (the list of Tribes containing explorers
|
||||
* and memories), the setPopulation method is only telling Tribes the range
|
||||
* of the indiviuals in the beginning of the run, the individuals will be discarded.
|
||||
* As TRIBES manages an own structured set of particles (the list of Tribes
|
||||
* containing explorers and memories), the setPopulation method is only
|
||||
* telling Tribes the range of the indiviuals in the beginning of the run,
|
||||
* the individuals will be discarded.
|
||||
*/
|
||||
@Override
|
||||
public void initByPopulation(Population pop, boolean reset) {
|
||||
@@ -296,8 +289,8 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
// adaptMax=swarmSize;
|
||||
adaptMax = swarm.linkNb(swarm);
|
||||
if (adaptThreshold >= adaptMax) {
|
||||
if (swarm.getBestMemory().getPrevPos().getTotalError() <=
|
||||
swarm.getBestMemory().getPos().getTotalError()) {
|
||||
if (swarm.getBestMemory().getPrevPos().getTotalError()
|
||||
<= swarm.getBestMemory().getPos().getTotalError()) {
|
||||
adapt = iter; // Memorize at which iteration adaptation occurs
|
||||
|
||||
for (int i = 0; i < swarm.getTribeCnt(); i++) {
|
||||
@@ -383,253 +376,161 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
public synchronized void search(param pb, PrintStream runSave, PrintStream synthSave) {
|
||||
|
||||
double epsMean, epsMin, epsMax;
|
||||
double evalMean;
|
||||
int n;
|
||||
int run, run1;
|
||||
int successNb;
|
||||
|
||||
// Exploratrices générées
|
||||
explorer explorer[] = new explorer[
|
||||
Tribes.maxExplorerNb];
|
||||
|
||||
double[] eps = new double[pb.maxRun];
|
||||
double[] evalNb = new double[pb.maxRun];
|
||||
double[] temp = new double[3];
|
||||
successNb = 0;
|
||||
for (n = 0; n < 9; n++) { // For information
|
||||
Tribes.strategies[n] = 0;
|
||||
Tribes.status[n] = 0;
|
||||
}
|
||||
;
|
||||
epsMin = Tribes.infinity;
|
||||
epsMax = 0;
|
||||
|
||||
// Titles
|
||||
|
||||
print("\nIter. Eval. Best_fitness", displayPb);
|
||||
save("\n\n PROBLEM "+pb.function[0],synthSave);
|
||||
save("\nRun Iter. Eval. Best_fitness Position", synthSave);
|
||||
save("\n\n PROBLEM "+pb.function[0],runSave);
|
||||
|
||||
// **
|
||||
// * Loop on runs
|
||||
// *
|
||||
for (run = 0; run < pb.maxRun; run++) {
|
||||
run1 = run + 1;
|
||||
save("\n" + run1 + " ", synthSave);
|
||||
temp = solve(pb, Tribes.initExplorerNb,runSave,synthSave);
|
||||
|
||||
eps[run] = temp[0];
|
||||
evalNb[run] = temp[1];
|
||||
successNb = successNb + (int) temp[2];
|
||||
if (eps[run] < epsMin) {
|
||||
epsMin = eps[run];
|
||||
}
|
||||
if (eps[run] > epsMax) {
|
||||
epsMax = eps[run];
|
||||
}
|
||||
}
|
||||
|
||||
// Mean values
|
||||
epsMean = 0;
|
||||
evalMean = 0;
|
||||
for (run = 0; run < pb.maxRun; run++) {
|
||||
epsMean = epsMean + eps[run];
|
||||
evalMean = evalMean + evalNb[run];
|
||||
}
|
||||
|
||||
epsMean = epsMean / pb.maxRun;
|
||||
evalMean = evalMean / pb.maxRun;
|
||||
print("\nStatuses ", displayPb);
|
||||
for (n = 1; n < 10; n++) {
|
||||
print("\n" + n + " " + Tribes.status[n - 1] + " times",
|
||||
displayPb);
|
||||
}
|
||||
print("\nStrategies ", displayPb);
|
||||
for (n = 1; n < 10; n++) {
|
||||
print("\n" + n + " " + Tribes.strategies[n - 1] + " times",
|
||||
displayPb);
|
||||
}
|
||||
print("\nMIN BEST TOTAL_ERROR " + epsMin, displayPb);
|
||||
print("\nMEAN BEST TOTAL_ERROR " + epsMean, displayPb);
|
||||
print("\nMEAN EVAL. NUMBER " + evalMean, displayPb);
|
||||
print("\n SUCCESS RATE " + (double) successNb / pb.maxRun,
|
||||
displayPb);
|
||||
|
||||
save("\nMIN BEST TOTAL_ERROR " + epsMin, synthSave);
|
||||
save("\nMEAN BEST TOTAL_ERROR " + epsMean, synthSave);
|
||||
save("\nMEAN EVAL. NUMBER " + evalMean, synthSave);
|
||||
save("\n SUCCESS RATE " + (double) successNb / pb.maxRun, synthSave);
|
||||
|
||||
save("\n-1", runSave); // Special value for the end of the file. Used for graphics
|
||||
|
||||
} // End of search()
|
||||
|
||||
public double[] solve(param pb, int initExplorerNb, PrintStream runSave, PrintStream synthSave) {
|
||||
int adapt, adaptMax;
|
||||
int adaptThreshold;
|
||||
int d, D = pb.H.Dimension;
|
||||
int evalF;
|
||||
int iter;
|
||||
int n;
|
||||
boolean stop;
|
||||
double[] temp = new double[3];
|
||||
int informOption;
|
||||
// For the best informant.
|
||||
// -1 => really the best
|
||||
// 1 => the best according to a pseudo-gradient method
|
||||
|
||||
// -----------INIT START
|
||||
// Generate a swarm
|
||||
evalF=0;
|
||||
swarm swarm = new swarm();
|
||||
evalF=swarm.generateSwarm(pb, initExplorerNb, pb.initType, displayPb,evalF);
|
||||
|
||||
// swarm.displaySwarm(swarm,out);
|
||||
// print("\n Best after init: "+swarm.Best.position.fitness,out);
|
||||
|
||||
// Move the swarm as long as the stop criterion is false
|
||||
iter = 0;
|
||||
adapt = 0;
|
||||
stop = false;
|
||||
informOption = -1;
|
||||
// Hard coded option
|
||||
// -1 = absolute best informant
|
||||
// 1 = relative (pseudo-gradient) best informant. For "niching"
|
||||
// See also moveExplorer, which can be modified in order to avoid this parameter
|
||||
//
|
||||
// -----------INIT END
|
||||
|
||||
|
||||
// -----------OPTIMIZE START
|
||||
iterations:while (!stop) {
|
||||
|
||||
swarm.size = swarm.swarmSize(swarm);
|
||||
iter++;
|
||||
// swarm.Best.positionPrev = swarm.Best.position;
|
||||
|
||||
evalF=swarm.moveSwarm(pb, swarm, informOption, displayPb, evalF); //*** HERE IT MOVES
|
||||
|
||||
// Some display each time there is "enough" improvement
|
||||
// fduring the process
|
||||
|
||||
double enough = 0.005;
|
||||
if ((1 - enough) * swarm.Best.positionPrev.totalError >
|
||||
swarm.Best.position.totalError) {
|
||||
print("\nIter. " + iter, displayPb);
|
||||
print(" Eval. " + evalF, displayPb);
|
||||
print(" totalError " + swarm.Best.position.totalError,
|
||||
displayPb);
|
||||
print(" " + swarm.size + " particles", displayPb);
|
||||
}
|
||||
// Save run info
|
||||
save("\n" + iter + " " + evalF + " " +
|
||||
swarm.Best.position.totalError + " " + swarm.size, runSave);
|
||||
|
||||
// Evaluate the stop criterion
|
||||
stop = evalF >= pb.maxEval ||
|
||||
pb.accuracy > swarm.Best.position.totalError;
|
||||
|
||||
if (Tribes.adaptOption == 0) {
|
||||
continue iterations;
|
||||
}
|
||||
|
||||
if (Tribes.adaptOption == 1) { // Just reinitialize the swarm
|
||||
adaptThreshold = iter - adapt;
|
||||
// adaptMax=swarmSize;
|
||||
adaptMax = swarm.linkNb(swarm);
|
||||
if (adaptThreshold >= adaptMax) {
|
||||
if (swarm.Best.positionPrev.totalError <=
|
||||
swarm.Best.position.totalError) {
|
||||
adapt = iter; // Memorize at which iteration adaptation occurs
|
||||
|
||||
for (n = 0; n < swarm.tribeNb; n++) {
|
||||
evalF=swarm.tribes[n].reinitTribe(pb,evalF);
|
||||
}
|
||||
}
|
||||
}
|
||||
continue iterations;
|
||||
}
|
||||
|
||||
// if(swarm.Best.positionPrev.totalError<=swarm.Best.position.totalError)
|
||||
{
|
||||
// Structural adaptations
|
||||
|
||||
//swarmSize = swarm.swarmSize(swarm);
|
||||
|
||||
// print("\nSwarm size (explorers): " + swarmSize,out);
|
||||
// print(" Tribes: (explorers/memories) ",out);
|
||||
// for (n = 0; n < swarm.tribeNumber; n++) {
|
||||
// print(swarm.tribes[n].explorerNb + "/" +
|
||||
// swarm.tribes[n].memoryNb + " ",out);
|
||||
// }
|
||||
//
|
||||
// On "laisse le temps" à chaque tribu de bouger avant éventuelle adaptation
|
||||
// La règle est empirique et peut être modifiée
|
||||
//
|
||||
|
||||
adaptThreshold = iter - adapt;
|
||||
// adaptMax=swarmSize;
|
||||
adaptMax = swarm.linkNb(swarm);
|
||||
|
||||
if (adaptThreshold >= adaptMax) {
|
||||
adapt = iter; // Memorize at which iteration adaptation occurs
|
||||
evalF=swarm.adaptSwarm(pb, Tribes.adaptOption, swarm,
|
||||
displayPb,evalF); // Réalise l'adaptation
|
||||
|
||||
// Modifie la recherche de la meilleure informatrice
|
||||
// normale (la "vraie" meilleure) ou dépendant d'un pseudo-gradient
|
||||
// (cf. informExplorer)
|
||||
//
|
||||
// informOption=-informOption;
|
||||
}
|
||||
// print("\n Nb of tribes: " + swarm.tribeNumber +
|
||||
// "\n Particles/tribe:",out);
|
||||
// for (n = 0; n < swarm.tribeNumber; n++) {
|
||||
// print(swarm.tribes[n].explorerNb + " ",out);
|
||||
// }
|
||||
//
|
||||
// print("\n Statuses :");
|
||||
// for (n = 0; n < swarm.tribeNumber; n++) {
|
||||
// print(swarm.tribes[n].status + " ",out);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
// -----------OPTIMIZE END
|
||||
}
|
||||
|
||||
// Result of the run
|
||||
print("\nBest: eval.= " + evalF + "\n", displayPb);
|
||||
swarm.Best.displayMemory(displayPb);
|
||||
|
||||
save(" " + iter + " " + evalF+ " ", synthSave);
|
||||
|
||||
for (d = 0; d < pb.fitnessSize; d++) {
|
||||
save(swarm.Best.position.fitness[d] + " ", synthSave);
|
||||
}
|
||||
|
||||
for (d = 0; d < D; d++) {
|
||||
save(" " + swarm.Best.position.x[d], synthSave);
|
||||
}
|
||||
|
||||
// Prepare return
|
||||
temp[0] = swarm.Best.position.totalError;
|
||||
temp[1] = evalF;
|
||||
if (evalF < pb.maxEval) {
|
||||
temp[2] = 1;
|
||||
} else {
|
||||
temp[2] = 0;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
**/
|
||||
|
||||
*
|
||||
* public synchronized void search(param pb, PrintStream runSave,
|
||||
* PrintStream synthSave) {
|
||||
*
|
||||
* double epsMean, epsMin, epsMax; double evalMean; int n; int run, run1;
|
||||
* int successNb;
|
||||
*
|
||||
* // Exploratrices générées explorer explorer[] = new explorer[
|
||||
* Tribes.maxExplorerNb];
|
||||
*
|
||||
* double[] eps = new double[pb.maxRun]; double[] evalNb = new
|
||||
* double[pb.maxRun]; double[] temp = new double[3]; successNb = 0; for (n =
|
||||
* 0; n < 9; n++) { // For information Tribes.strategies[n] = 0;
|
||||
* Tribes.status[n] = 0; } ; epsMin = Tribes.infinity; epsMax = 0;
|
||||
*
|
||||
* // Titles
|
||||
*
|
||||
* print("\nIter. Eval. Best_fitness", displayPb); save("\n\n PROBLEM
|
||||
* "+pb.function[0],synthSave); save("\nRun Iter. Eval. Best_fitness
|
||||
* Position", synthSave); save("\n\n PROBLEM "+pb.function[0],runSave);
|
||||
*
|
||||
* // ** // * Loop on runs // * for (run = 0; run < pb.maxRun; run++) { run1
|
||||
* = run + 1; save("\n" + run1 + " ", synthSave); temp = solve(pb,
|
||||
* Tribes.initExplorerNb,runSave,synthSave);
|
||||
*
|
||||
* eps[run] = temp[0]; evalNb[run] = temp[1]; successNb = successNb + (int)
|
||||
* temp[2]; if (eps[run] < epsMin) { epsMin = eps[run]; } if (eps[run] >
|
||||
* epsMax) { epsMax = eps[run]; } }
|
||||
*
|
||||
* // Mean values epsMean = 0; evalMean = 0; for (run = 0; run < pb.maxRun;
|
||||
* run++) { epsMean = epsMean + eps[run]; evalMean = evalMean + evalNb[run];
|
||||
* }
|
||||
*
|
||||
* epsMean = epsMean / pb.maxRun; evalMean = evalMean / pb.maxRun;
|
||||
* print("\nStatuses ", displayPb); for (n = 1; n < 10; n++) { print("\n" +
|
||||
* n + " " + Tribes.status[n - 1] + " times", displayPb); }
|
||||
* print("\nStrategies ", displayPb); for (n = 1; n < 10; n++) { print("\n"
|
||||
* + n + " " + Tribes.strategies[n - 1] + " times", displayPb); }
|
||||
* print("\nMIN BEST TOTAL_ERROR " + epsMin, displayPb); print("\nMEAN BEST
|
||||
* TOTAL_ERROR " + epsMean, displayPb); print("\nMEAN EVAL. NUMBER " +
|
||||
* evalMean, displayPb); print("\n SUCCESS RATE " + (double) successNb /
|
||||
* pb.maxRun, displayPb);
|
||||
*
|
||||
* save("\nMIN BEST TOTAL_ERROR " + epsMin, synthSave); save("\nMEAN BEST
|
||||
* TOTAL_ERROR " + epsMean, synthSave); save("\nMEAN EVAL. NUMBER " +
|
||||
* evalMean, synthSave); save("\n SUCCESS RATE " + (double) successNb /
|
||||
* pb.maxRun, synthSave);
|
||||
*
|
||||
* save("\n-1", runSave); // Special value for the end of the file. Used for
|
||||
* graphics
|
||||
*
|
||||
* } // End of search()
|
||||
*
|
||||
* public double[] solve(param pb, int initExplorerNb, PrintStream runSave,
|
||||
* PrintStream synthSave) { int adapt, adaptMax; int adaptThreshold; int d,
|
||||
* D = pb.H.Dimension; int evalF; int iter; int n; boolean stop; double[]
|
||||
* temp = new double[3]; int informOption; // For the best informant. // -1
|
||||
* => really the best // 1 => the best according to a pseudo-gradient method
|
||||
*
|
||||
* // -----------INIT START // Generate a swarm evalF=0; swarm swarm = new
|
||||
* swarm(); evalF=swarm.generateSwarm(pb, initExplorerNb, pb.initType,
|
||||
* displayPb,evalF);
|
||||
*
|
||||
* // swarm.displaySwarm(swarm,out); // print("\n Best after init:
|
||||
* "+swarm.Best.position.fitness,out);
|
||||
*
|
||||
* // Move the swarm as long as the stop criterion is false iter = 0; adapt
|
||||
* = 0; stop = false; informOption = -1; // Hard coded option // -1 =
|
||||
* absolute best informant // 1 = relative (pseudo-gradient) best informant.
|
||||
* For "niching" // See also moveExplorer, which can be modified in order to
|
||||
* avoid this parameter // // -----------INIT END
|
||||
*
|
||||
*
|
||||
* // -----------OPTIMIZE START iterations:while (!stop) {
|
||||
*
|
||||
* swarm.size = swarm.swarmSize(swarm); iter++; // swarm.Best.positionPrev =
|
||||
* swarm.Best.position;
|
||||
*
|
||||
* evalF=swarm.moveSwarm(pb, swarm, informOption, displayPb, evalF); //***
|
||||
* HERE IT MOVES
|
||||
*
|
||||
* // Some display each time there is "enough" improvement // fduring the
|
||||
* process
|
||||
*
|
||||
* double enough = 0.005; if ((1 - enough) *
|
||||
* swarm.Best.positionPrev.totalError > swarm.Best.position.totalError) {
|
||||
* print("\nIter. " + iter, displayPb); print(" Eval. " + evalF, displayPb);
|
||||
* print(" totalError " + swarm.Best.position.totalError, displayPb);
|
||||
* print(" " + swarm.size + " particles", displayPb); } // Save run info
|
||||
* save("\n" + iter + " " + evalF + " " + swarm.Best.position.totalError + "
|
||||
* " + swarm.size, runSave);
|
||||
*
|
||||
* // Evaluate the stop criterion stop = evalF >= pb.maxEval || pb.accuracy
|
||||
* > swarm.Best.position.totalError;
|
||||
*
|
||||
* if (Tribes.adaptOption == 0) { continue iterations; }
|
||||
*
|
||||
* if (Tribes.adaptOption == 1) { // Just reinitialize the swarm
|
||||
* adaptThreshold = iter - adapt; // adaptMax=swarmSize; adaptMax =
|
||||
* swarm.linkNb(swarm); if (adaptThreshold >= adaptMax) { if
|
||||
* (swarm.Best.positionPrev.totalError <= swarm.Best.position.totalError) {
|
||||
* adapt = iter; // Memorize at which iteration adaptation occurs
|
||||
*
|
||||
* for (n = 0; n < swarm.tribeNb; n++) {
|
||||
* evalF=swarm.tribes[n].reinitTribe(pb,evalF); } } } continue iterations; }
|
||||
*
|
||||
* // if(swarm.Best.positionPrev.totalError<=swarm.Best.position.totalError)
|
||||
* { // Structural adaptations
|
||||
*
|
||||
* //swarmSize = swarm.swarmSize(swarm);
|
||||
*
|
||||
* // print("\nSwarm size (explorers): " + swarmSize,out); // print("
|
||||
* Tribes: (explorers/memories) ",out); // for (n = 0; n <
|
||||
* swarm.tribeNumber; n++) { // print(swarm.tribes[n].explorerNb + "/" + //
|
||||
* swarm.tribes[n].memoryNb + " ",out); // } // // On "laisse le temps" Ã
|
||||
* chaque tribu de bouger avant éventuelle adaptation // La règle est
|
||||
* empirique et peut être modifiée //
|
||||
*
|
||||
* adaptThreshold = iter - adapt; // adaptMax=swarmSize; adaptMax =
|
||||
* swarm.linkNb(swarm);
|
||||
*
|
||||
* if (adaptThreshold >= adaptMax) { adapt = iter; // Memorize at which
|
||||
* iteration adaptation occurs evalF=swarm.adaptSwarm(pb,
|
||||
* Tribes.adaptOption, swarm, displayPb,evalF); // Réalise l'adaptation
|
||||
*
|
||||
* // Modifie la recherche de la meilleure informatrice // normale (la
|
||||
* "vraie" meilleure) ou dépendant d'un pseudo-gradient // (cf.
|
||||
* informExplorer) // // informOption=-informOption; } // print("\n Nb of
|
||||
* tribes: " + swarm.tribeNumber + // "\n Particles/tribe:",out); // for (n
|
||||
* = 0; n < swarm.tribeNumber; n++) { // print(swarm.tribes[n].explorerNb +
|
||||
* " ",out); // } // // print("\n Statuses :"); // for (n = 0; n <
|
||||
* swarm.tribeNumber; n++) { // print(swarm.tribes[n].status + " ",out); //
|
||||
* }
|
||||
*
|
||||
*
|
||||
* }
|
||||
* // -----------OPTIMIZE END }
|
||||
*
|
||||
* // Result of the run print("\nBest: eval.= " + evalF + "\n", displayPb);
|
||||
* swarm.Best.displayMemory(displayPb);
|
||||
*
|
||||
* save(" " + iter + " " + evalF+ " ", synthSave);
|
||||
*
|
||||
* for (d = 0; d < pb.fitnessSize; d++) {
|
||||
* save(swarm.Best.position.fitness[d] + " ", synthSave); }
|
||||
*
|
||||
* for (d = 0; d < D; d++) { save(" " + swarm.Best.position.x[d],
|
||||
* synthSave); }
|
||||
*
|
||||
* // Prepare return temp[0] = swarm.Best.position.totalError; temp[1] =
|
||||
* evalF; if (evalF < pb.maxEval) { temp[2] = 1; } else { temp[2] = 0; }
|
||||
*
|
||||
* return temp; }
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Population will be hidden.
|
||||
*/
|
||||
@@ -638,9 +539,10 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* As TRIBES manages an own structured set of particles (the list of Tribes containing explorers
|
||||
* and memories), the setPopulation method is only telling Tribes the range
|
||||
* of the indiviuals in the beginning of the run, the individuals will be discarded.
|
||||
* As TRIBES manages an own structured set of particles (the list of Tribes
|
||||
* containing explorers and memories), the setPopulation method is only
|
||||
* telling Tribes the range of the indiviuals in the beginning of the run,
|
||||
* the individuals will be discarded.
|
||||
*/
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
@@ -666,10 +568,11 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Be aware that TRIBES uses two kinds of particles: explorers and memories. As memories
|
||||
* are inactive in that they dont search the problem space directly, they are not included
|
||||
* in the returned population. This, however, means that the best found solution might not
|
||||
* be inluded as well at several if not most stages of the search.
|
||||
* Be aware that TRIBES uses two kinds of particles: explorers and memories.
|
||||
* As memories are inactive in that they dont search the problem space
|
||||
* directly, they are not included in the returned population. This,
|
||||
* however, means that the best found solution might not be inluded as well
|
||||
* at several if not most stages of the search.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
@@ -677,8 +580,9 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a SolutionSet of TribesExplorers (AbstractEAIndividuals) of which some where
|
||||
* memory particles, thus the returned population is larger than the current population.
|
||||
* Return a SolutionSet of TribesExplorers (AbstractEAIndividuals) of which
|
||||
* some where memory particles, thus the returned population is larger than
|
||||
* the current population.
|
||||
*
|
||||
* @return a population of possible solutions.
|
||||
*/
|
||||
@@ -709,13 +613,16 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
return indy;
|
||||
}
|
||||
|
||||
/** This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
/**
|
||||
* This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
*
|
||||
* @param ea
|
||||
*/
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -726,6 +633,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
this.m_Listener.registerPopulationStateChanged(this, name);
|
||||
@@ -736,13 +644,11 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
return (evals % notifyGenChangedEvery) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeWilly() {}
|
||||
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return m_Identifier;
|
||||
@@ -821,7 +727,6 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
||||
// public void setUseAnchor(boolean useAnchor) {
|
||||
// this.useAnchor = useAnchor;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return the m_Show
|
||||
*/
|
||||
|
@@ -11,17 +11,14 @@ import eva2.server.go.problems.AbstractMultiObjectiveOptimizationProblem;
|
||||
import eva2.server.go.problems.FM0Problem;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
|
||||
/** The winged MOEA was a nice idea, which didn't really work out.
|
||||
* Here a standard MOEA is assisted by n additional local searchers, each
|
||||
* optimizing just one objective. The idea was that these local optimizers
|
||||
* would span the search space and would allow the MOEA to converge faster.
|
||||
* But in the end the performance of this algorithm strongly depends on the
|
||||
* optimization problem.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 16.02.2005
|
||||
* Time: 16:34:22
|
||||
* To change this template use File | Settings | File Templates.
|
||||
/**
|
||||
* The winged MOEA was a nice idea, which didn't really work out. Here a
|
||||
* standard MOEA is assisted by n additional local searchers, each optimizing
|
||||
* just one objective. The idea was that these local optimizers would span the
|
||||
* search space and would allow the MOEA to converge faster. But in the end the
|
||||
* performance of this algorithm strongly depends on the optimization problem.
|
||||
* Created by IntelliJ IDEA. User: streiche Date: 16.02.2005 Time: 16:34:22 To
|
||||
* change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Serializable {
|
||||
|
||||
@@ -94,8 +91,9 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
|
||||
/** This method will init the optimizer with a given population
|
||||
/**
|
||||
* This method will init the optimizer with a given population
|
||||
*
|
||||
* @param pop The initial population
|
||||
* @param reset If true the population is reset.
|
||||
*/
|
||||
@@ -135,7 +133,8 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** The optimize method will compute a 'improved' and evaluated population
|
||||
/**
|
||||
* The optimize method will compute a 'improved' and evaluated population
|
||||
*/
|
||||
@Override
|
||||
public void optimize() {
|
||||
@@ -154,8 +153,8 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
this.firePropertyChangedEvent(Population.nextGenerationPerformed);
|
||||
}
|
||||
|
||||
/** This method will manage comunication between the
|
||||
* islands
|
||||
/**
|
||||
* This method will manage comunication between the islands
|
||||
*/
|
||||
private void communicate() {
|
||||
int oldFunctionCalls;
|
||||
@@ -180,7 +179,8 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
this.migrate();
|
||||
}
|
||||
|
||||
/** This method implements the migration between the optimzers
|
||||
/**
|
||||
* This method implements the migration between the optimzers
|
||||
*
|
||||
*/
|
||||
private void migrate() {
|
||||
@@ -210,13 +210,16 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
}
|
||||
}
|
||||
|
||||
/** This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
/**
|
||||
* This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
*
|
||||
* @param ea
|
||||
*/
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.m_Listener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
@@ -227,7 +230,9 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Something has changed
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.m_Listener != null) {
|
||||
@@ -235,20 +240,25 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will set the problem that is to be optimized
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.m_Problem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.m_Problem;
|
||||
}
|
||||
|
||||
/** This method will return a string describing all properties of the optimizer
|
||||
* and the applied methods.
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
*
|
||||
* @return A descriptive string
|
||||
*/
|
||||
@Override
|
||||
@@ -260,35 +270,38 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
result += this.m_Population.getStringRepresentation();
|
||||
return result;
|
||||
}
|
||||
/** This method allows you to set an identifier for the algorithm
|
||||
|
||||
/**
|
||||
* This method allows you to set an identifier for the algorithm
|
||||
*
|
||||
* @param name The indenifier
|
||||
*/
|
||||
@Override
|
||||
public void setIdentifier(String name) {
|
||||
this.m_Identifier = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.m_Identifier;
|
||||
}
|
||||
|
||||
/** This method is required to free the memory on a RMIServer,
|
||||
* but there is nothing to implement.
|
||||
*/
|
||||
@Override
|
||||
public void freeWilly() {
|
||||
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
/**
|
||||
* ********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/** This method returns a global info string
|
||||
/**
|
||||
* This method returns a global info string
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
public static String globalInfo() {
|
||||
return "This is Evolutionary Multi-Criteria Optimization Algorithm hybridized with Local Searchers to span the Pareto-Front.";
|
||||
}
|
||||
/** This method will return a naming String
|
||||
|
||||
/**
|
||||
* This method will return a naming String
|
||||
*
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
@Override
|
||||
@@ -296,19 +309,23 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
return "EMO-LS";
|
||||
}
|
||||
|
||||
/** Assuming that all optimizer will store their data in a population
|
||||
* we will allow access to this population to query to current state
|
||||
* of the optimizer.
|
||||
/**
|
||||
* Assuming that all optimizer will store their data in a population we will
|
||||
* allow access to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.m_Population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.m_Population = pop;
|
||||
}
|
||||
|
||||
public String populationTipText() {
|
||||
return "(Defunct)";
|
||||
}
|
||||
@@ -317,41 +334,54 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
/** This method allows you to set/get the optimizing technique to use.
|
||||
|
||||
/**
|
||||
* This method allows you to set/get the optimizing technique to use.
|
||||
*
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public InterfaceOptimizer getMOOptimizer() {
|
||||
return this.m_MOOptimizer;
|
||||
}
|
||||
|
||||
public void setMOOptimizer(InterfaceOptimizer b) {
|
||||
this.m_MOOptimizer = b;
|
||||
}
|
||||
|
||||
public String mOOptimizerTipText() {
|
||||
return "Choose a population based optimizing technique to use.";
|
||||
}
|
||||
|
||||
/** This method allows you to set/get the optimizing technique to use.
|
||||
/**
|
||||
* This method allows you to set/get the optimizing technique to use.
|
||||
*
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public InterfaceOptimizer getSOOptimizer() {
|
||||
return this.m_SOOptimizer;
|
||||
}
|
||||
|
||||
public void setSOOptimizer(InterfaceOptimizer b) {
|
||||
this.m_SOOptimizer = b;
|
||||
}
|
||||
|
||||
public String sOOptimizerTipText() {
|
||||
return "Choose a population based optimizing technique to use.";
|
||||
}
|
||||
|
||||
/** This method allows you to set/get the archiving strategy to use.
|
||||
/**
|
||||
* This method allows you to set/get the archiving strategy to use.
|
||||
*
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public int getMigrationRate() {
|
||||
return this.m_MigrationRate;
|
||||
}
|
||||
|
||||
public void setMigrationRate(int b) {
|
||||
this.m_MigrationRate = b;
|
||||
}
|
||||
|
||||
public String migrationRateTipText() {
|
||||
return "Choose a proper migration rate.";
|
||||
}
|
||||
|
Reference in New Issue
Block a user