Added MOEA to OptimizerFactory, moved construction sites to research package.

This commit is contained in:
Marcel Kronfeld 2008-06-27 14:05:27 +00:00
parent ff24ffcf80
commit 4ed16eee27
5 changed files with 69 additions and 314 deletions

View File

@ -455,12 +455,13 @@
</target>
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Generate Distribution
Generate Distribution and put it online. This also replaces the
Probs and ESModel packages so keep them synchronized.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<target name="distToWWW" depends="dist">
<target name="distToWWW" depends="init">
<mkdir dir="${web.download.directory}/old-${DSTAMP}-${TSTAMP}" />
<copy todir="${web.download.directory}/old-${DSTAMP}-${TSTAMP}">
<copy todir="${web.download.directory}/old-${DSTAMP}-${TSTAMP}">
<fileset dir="${web.download.directory}">
<include name="**Src.tar.gz" />
<include name="**.jar" />
@ -471,6 +472,9 @@
<include name="**Src.tar.gz" />
<include name="**.jar" />
</fileset>
<fileset dir="${source.directory}/eva2">
<include name="EvAInfo.java" />
</fileset>
</copy>
</target>

View File

@ -13,6 +13,10 @@ import eva2.server.go.individuals.AbstractEAIndividual;
import eva2.server.go.individuals.InterfaceDataTypeBinary;
import eva2.server.go.individuals.InterfaceDataTypeDouble;
import eva2.server.go.individuals.InterfaceESIndividual;
import eva2.server.go.operators.archiving.ArchivingNSGAII;
import eva2.server.go.operators.archiving.InformationRetrievalInserting;
import eva2.server.go.operators.archiving.InterfaceArchiving;
import eva2.server.go.operators.archiving.InterfaceInformationRetrieval;
import eva2.server.go.operators.cluster.ClusteringDensityBased;
import eva2.server.go.operators.crossover.CrossoverESDefault;
import eva2.server.go.operators.crossover.InterfaceCrossover;
@ -39,6 +43,7 @@ import eva2.server.go.strategies.GradientDescentAlgorithm;
import eva2.server.go.strategies.HillClimbing;
import eva2.server.go.strategies.InterfaceOptimizer;
import eva2.server.go.strategies.MonteCarloSearch;
import eva2.server.go.strategies.MultiObjectiveEA;
import eva2.server.go.strategies.ParticleSwarmOptimization;
import eva2.server.go.strategies.SimulatedAnnealing;
import eva2.server.go.strategies.Tribes;
@ -294,6 +299,49 @@ public class OptimizerFactory {
return ga;
}
/**
* This method creates a multi-objective EA optimizer. Remember to set a multi-objective
* selection method within the specific optimizer. This uses a standard archiving strategy (NSGAII)
* and InformationRetrievalInserting.
*
* @param subOpt the specific optimizer to use
* @param archiveSize maximum size of the archive
* @param problem
* @param listener
* @return An optimization algorithm that employs a multi-objective optimizer
*/
public static final MultiObjectiveEA createMultiObjectiveEA(
InterfaceOptimizer subOpt, int archiveSize,
AbstractOptimizationProblem problem,
InterfacePopulationChangedEventListener listener) {
return createMultiObjectiveEA(subOpt, new ArchivingNSGAII(), archiveSize, new InformationRetrievalInserting(), problem, listener);
}
/**
* This method creates a multi-objective EA optimizer. Remember to set a multi-objective
* selection method within the specific optimizer.
*
* @param subOpt the specific optimizer to use
* @param archiving the archiving strategy collecting the pareto front
* @param archiveSize maximum size of the archive
* @param infoRetrieval information retrieval strategy
* @param problem
* @param listener
* @return An optimization algorithm that employs a multi-objective optimizer
*/
public static final MultiObjectiveEA createMultiObjectiveEA(
InterfaceOptimizer subOpt, InterfaceArchiving archiving, int archiveSize,
InterfaceInformationRetrieval infoRetrieval,
AbstractOptimizationProblem problem,
InterfacePopulationChangedEventListener listener) {
problem.initProblem();
subOpt.SetProblem(problem);
return new MultiObjectiveEA(subOpt, archiving, archiveSize, infoRetrieval, problem);
}
/**
* This starts a Gradient Descent.

View File

@ -1,76 +0,0 @@
package eva2.server.go.operators.archiving;
import eva2.server.go.populations.Population;
/** This class is under construction and should be able to archive
* individuals, which actually give a set of solutions.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 24.02.2005
* Time: 17:16:19
* To change this template use File | Settings | File Templates.
*/
public class ArchivingMOMAIIAllDominating implements InterfaceArchiving, java.io.Serializable {
protected boolean m_Debug = false;
transient protected eva2.gui.Plot m_Plot = null;
protected int p = 0;
public ArchivingMOMAIIAllDominating() {
}
public ArchivingMOMAIIAllDominating(ArchivingMOMAIIAllDominating a) {
}
/** This method allows you to make a deep clone of
* the object
* @return the deep clone
*/
public Object clone() {
return (Object) new ArchivingMOMAIIAllDominating(this);
}
/** This method allows you to merge to populations into an archive.
* This method will add elements from pop to the archive but will also
* remove elements from the archive if the archive target size is exceeded.
* @param pop The population that may add Individuals to the archive.
*/
public void addElementsToArchive(Population pop) {
if (pop.getArchive() == null) pop.SetArchive(new Population());
// i guess it is much simpler get a list of all dominating elements
// from the archive, check all pop elements to this Pareto-front
// add the non-dominated and then remove the now dominated elements
// first get the dominant elements
}
/**********************************************************************************************************************
* These are for GUI
*/
/** This method returns a global info string
* @return description
*/
public String globalInfo() {
return "This is a straightforward strategy, which selects all dominating Pareto-front for MOMA-II (defunc).";
}
/** This method will return a naming String
* @return The name of the algorithm
*/
public String getName() {
return "MOMA-II AllDominating";
}
/** This method allows you to toggle the debug mode.
* @param b True in case of the debug mode.
*/
public void setDebugFront(boolean b) {
this.m_Debug = b;
}
public boolean getDebugFront() {
return this.m_Debug;
}
public String debugFrontTipText() {
return "Toggles the debug mode.";
}
}

View File

@ -10,10 +10,12 @@ import eva2.server.go.operators.selection.SelectMONonDominated;
import eva2.server.go.populations.InterfaceSolutionSet;
import eva2.server.go.populations.Population;
import eva2.server.go.populations.SolutionSet;
import eva2.server.go.problems.AbstractOptimizationProblem;
import eva2.server.go.problems.FM0Problem;
import eva2.server.go.problems.InterfaceOptimizationProblem;
/** A generic framework for multi-objecitve optimization, you need
/**
* 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
@ -28,7 +30,7 @@ import eva2.server.go.problems.InterfaceOptimizationProblem;
* 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 more simpler methods like
* 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
@ -58,6 +60,15 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
this.m_InformationRetrieval = (InterfaceInformationRetrieval)a.m_InformationRetrieval.clone();
}
public MultiObjectiveEA(InterfaceOptimizer subOpt, InterfaceArchiving archiving, int archiveSize,
InterfaceInformationRetrieval infoRetrieval, AbstractOptimizationProblem problem) {
setOptimizer(subOpt);
setArchivingStrategy(archiving);
setArchiveSize(archiveSize);
setInformationRetrieval(infoRetrieval);
SetProblem(problem);
}
public Object clone() {
return (Object) new MultiObjectiveEA(this);
}
@ -230,7 +241,7 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
}
public InterfaceSolutionSet getAllSolutions() {
return new SolutionSet(getPopulation());
return new SolutionSet(getPopulation(), getPopulation().getArchive());
}
/** This method allows you to set/get the optimizing technique to use.

View File

@ -1,232 +0,0 @@
package eva2.server.go.strategies;
import eva2.server.go.InterfacePopulationChangedEventListener;
import eva2.server.go.individuals.AbstractEAIndividual;
import eva2.server.go.operators.archiving.ArchivingMOMAIIAllDominating;
import eva2.server.go.operators.archiving.InformationRetrievalInserting;
import eva2.server.go.operators.archiving.InterfaceArchiving;
import eva2.server.go.operators.archiving.InterfaceInformationRetrieval;
import eva2.server.go.operators.selection.SelectMOMAIIDominanceCounter;
import eva2.server.go.operators.selection.SelectMONonDominated;
import eva2.server.go.populations.InterfaceSolutionSet;
import eva2.server.go.populations.Population;
import eva2.server.go.populations.SolutionSet;
import eva2.server.go.problems.FM0Problem;
import eva2.server.go.problems.InterfaceOptimizationProblem;
/** This is still under construction.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 24.02.2005
* Time: 16:39:05
* To change this template use File | Settings | File Templates.
*/
public class MultiObjectiveMemeticAlgorithmII implements InterfaceOptimizer, java.io.Serializable {
private InterfaceOptimizer m_Optimizer = new GeneticAlgorithm();
private InterfaceArchiving m_Archiver = new ArchivingMOMAIIAllDominating();
private InterfaceInformationRetrieval m_InformationRetrieval = new InformationRetrievalInserting();
private InterfaceOptimizationProblem m_Problem = new FM0Problem();
private String m_Identifier = "";
transient private InterfacePopulationChangedEventListener m_Listener;
public MultiObjectiveMemeticAlgorithmII() {
this.m_Optimizer.getPopulation().setPopulationSize(100);
((GeneticAlgorithm)this.m_Optimizer).setParentSelection(new SelectMOMAIIDominanceCounter());
((GeneticAlgorithm)this.m_Optimizer).setPartnerSelection(new SelectMOMAIIDominanceCounter());
}
public MultiObjectiveMemeticAlgorithmII(MultiObjectiveMemeticAlgorithmII a) {
this.m_Problem = (InterfaceOptimizationProblem)a.m_Problem.clone();
this.m_Optimizer = (InterfaceOptimizer)a.m_Optimizer.clone();
this.m_Archiver = (InterfaceArchiving)a.m_Archiver.clone();
this.m_InformationRetrieval = (InterfaceInformationRetrieval)a.m_InformationRetrieval.clone();
}
public Object clone() {
return (Object) new MultiObjectiveMemeticAlgorithmII(this);
}
public void init() {
this.m_Optimizer.init();
this.m_Archiver.addElementsToArchive(this.m_Optimizer.getPopulation());
this.firePropertyChangedEvent("NextGenerationPerformed");
}
/** This method will init the optimizer with a given population
* @param pop The initial population
* @param reset If true the population is reset.
*/
public void initByPopulation(Population pop, boolean reset) {
this.m_Optimizer.initByPopulation(pop, reset);
this.m_Archiver.addElementsToArchive(this.m_Optimizer.getPopulation());
this.firePropertyChangedEvent("NextGenerationPerformed");
}
/** The optimize method will compute a 'improved' and evaluated population
*/
public void optimize() {
// This is in total compliance with Koch's framework nice isn't it?
this.m_Optimizer.optimize();
// now comes all the multiobjective optimization stuff
// This is the Environment Selection
this.m_Archiver.addElementsToArchive(this.m_Optimizer.getPopulation());
// The InformationRetrieval will choose from the archive and the current population
// the population from which in the next generation the parents will be selected.
this.m_InformationRetrieval.retrieveInformationFrom(this.m_Optimizer.getPopulation());
System.gc();
this.firePropertyChangedEvent("NextGenerationPerformed");
}
/** This method allows you to add the LectureGUI as listener to the Optimizer
* @param ea
*/
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
this.m_Listener = ea;
}
/** Something has changed
*/
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
* @param problem
*/
public void SetProblem (InterfaceOptimizationProblem problem) {
this.m_Problem = problem;
this.m_Optimizer.SetProblem(problem);
}
public InterfaceOptimizationProblem getProblem () {
return this.m_Problem;
}
/** This method will return a string describing all properties of the optimizer
* and the applied methods.
* @return A descriptive string
*/
public String getStringRepresentation() {
String result = "";
result += "MOMA II:\n";
result += "Optimization Problem: ";
result += this.m_Problem.getStringRepresentationForProblem(this) +"\n";
result += this.m_Optimizer.getPopulation().getStringRepresentation();
return result;
}
/** This method allows you to set an identifier for the algorithm
* @param name The indenifier
*/
public void SetIdentifier(String name) {
this.m_Identifier = name;
}
public String getIdentifier() {
return this.m_Identifier;
}
/** This method is required to free the memory on a RMIServer,
* but there is nothing to implement.
*/
public void freeWilly() {
}
/**********************************************************************************************************************
* These are for GUI
*/
/** This method returns a global info string
* @return description
*/
public String globalInfo() {
return "Multi-Objective Memetic Algorithms level II.";
}
/** This method will return a naming String
* @return The name of the algorithm
*/
public String getName() {
return "MOMA II";
}
/** 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.
*/
public Population getPopulation() {
return this.m_Optimizer.getPopulation();
}
public void setPopulation(Population pop){
this.m_Optimizer.setPopulation(pop);
}
public String populationTipText() {
return "Edit the properties of the Population used.";
}
public InterfaceSolutionSet getAllSolutions() {
return new SolutionSet(getPopulation());
}
/** 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.
* @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.
* @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.
* @return The current optimizing method
*/
public int getArchiveSize() {
Population archive = this.m_Optimizer.getPopulation().getArchive();
if (archive == null) {
archive = new Population();
this.m_Optimizer.getPopulation().SetArchive(archive);
}
return archive.getPopulationSize();
}
public void setArchiveSize(int b){
Population archive = this.m_Optimizer.getPopulation().getArchive();
if (archive == null) {
archive = new Population();
this.m_Optimizer.getPopulation().SetArchive(archive);
}
archive.setPopulationSize(b);
}
public String archiveSizeTipText() {
return "Choose the size of the archive.";
}
}