diff --git a/src/eva2/OptimizerRunnable.java b/src/eva2/OptimizerRunnable.java index 52fae031..d8807263 100644 --- a/src/eva2/OptimizerRunnable.java +++ b/src/eva2/OptimizerRunnable.java @@ -82,7 +82,7 @@ public class OptimizerRunnable implements Runnable { rnblID = cntID; cntID++; - proc = new Processor(stats, null, params); + proc = new Processor(stats, params); if (proc.getStatistics() instanceof AbstractStatistics) { ((AbstractStatistics) proc.getStatistics()).setSaveParams(false); } @@ -107,7 +107,7 @@ public class OptimizerRunnable implements Runnable { } public InterfaceOptimizationParameters getGOParams() { - return proc.getOptimizationParameterss(); + return proc.getOptimizationParameters(); } public InterfaceStatistics getStats() { @@ -118,8 +118,8 @@ public class OptimizerRunnable implements Runnable { if (proc.isOptimizationRunning()) { throw new RuntimeException("Error - cannot change statistics instance during optimization."); } - InterfaceOptimizationParameters params = proc.getOptimizationParameterss(); - proc = new Processor(stats, null, params); + InterfaceOptimizationParameters params = proc.getOptimizationParameters(); + proc = new Processor(stats, params); if (proc.getStatistics() instanceof AbstractStatistics) { ((AbstractStatistics) proc.getStatistics()).setSaveParams(false); } @@ -149,7 +149,7 @@ public class OptimizerRunnable implements Runnable { try { proc.setSaveParams(false); if (postProcessOnly) { - proc.performPostProcessing((PostProcessParams) proc.getOptimizationParameterss().getPostProcessParams(), listener); + proc.performPostProcessing((PostProcessParams) proc.getOptimizationParameters().getPostProcessParams(), listener); } else { if (doRestart) { proc.restartOptimization(); @@ -199,15 +199,15 @@ public class OptimizerRunnable implements Runnable { } public SolutionSet getSolutionSet() { - return (SolutionSet) proc.getOptimizationParameterss().getOptimizer().getAllSolutions(); + return (SolutionSet) proc.getOptimizationParameters().getOptimizer().getAllSolutions(); } public void setPostProcessingParams(InterfacePostProcessParams ppp) { - proc.getOptimizationParameterss().setPostProcessParams(ppp); + proc.getOptimizationParameters().setPostProcessParams(ppp); } public int getProgress() { - return proc.getOptimizationParameterss().getOptimizer().getPopulation().getFunctionCalls(); + return proc.getOptimizationParameters().getOptimizer().getPopulation().getFunctionCalls(); } public String terminatedBecause() { @@ -215,7 +215,7 @@ public class OptimizerRunnable implements Runnable { if (postProcessOnly) { return "Post processing finished"; } else { - InterfaceTerminator term = proc.getOptimizationParameterss().getTerminator(); + InterfaceTerminator term = proc.getOptimizationParameters().getTerminator(); return term.lastTerminationMessage(); } } else { diff --git a/src/eva2/optimization/ModuleServer.java b/src/eva2/optimization/ModuleServer.java index 6facb160..3aa6e25f 100644 --- a/src/eva2/optimization/ModuleServer.java +++ b/src/eva2/optimization/ModuleServer.java @@ -1,7 +1,6 @@ package eva2.optimization; import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.modules.GOModuleAdapter; import eva2.optimization.modules.ModuleAdapter; import eva2.tools.EVAERROR; import eva2.tools.ReflectPackage; @@ -121,7 +120,7 @@ public final class ModuleServer { /* create a module instance */ int constrIndex = 0; - if ((optimizationParameters == null && noGuiLogFile == null) || !module.equals(GOModuleAdapter.class)) { + if ((optimizationParameters == null && noGuiLogFile == null)) { if (optimizationParameters != null) { System.err.println("Cant set params - no matching constructor found for " + adapterName + " (ModuleServer)"); } diff --git a/src/eva2/optimization/modules/AbstractModuleAdapter.java b/src/eva2/optimization/modules/AbstractModuleAdapter.java index 0eec5524..38a00318 100644 --- a/src/eva2/optimization/modules/AbstractModuleAdapter.java +++ b/src/eva2/optimization/modules/AbstractModuleAdapter.java @@ -60,7 +60,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab */ @Override public boolean hasPostProcessing() { - return ((processor instanceof Processor) && ((Processor) processor).getOptimizationParameterss().getPostProcessParams().isDoPostProcessing()); + return ((processor instanceof Processor) && ((Processor) processor).getOptimizationParameters().getPostProcessParams().isDoPostProcessing()); } /** @@ -70,7 +70,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab */ @Override public boolean startPostProcessing() { - if (hasPostProcessing() && ((Processor) processor).getOptimizationParameterss().getPostProcessParams().isDoPostProcessing()) { + if (hasPostProcessing() && ((Processor) processor).getOptimizationParameters().getPostProcessParams().isDoPostProcessing()) { ((Processor) processor).performPostProcessing(); return true; } else { @@ -80,7 +80,7 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab public InterfaceOptimizationParameters getOptimizationParameters() { if ((processor != null) && (processor instanceof Processor)) { - return ((Processor) processor).getOptimizationParameterss(); + return ((Processor) processor).getOptimizationParameters(); } else { return null; } diff --git a/src/eva2/optimization/modules/DEModuleAdapter.java b/src/eva2/optimization/modules/DEModuleAdapter.java deleted file mode 100644 index 9815ddc1..00000000 --- a/src/eva2/optimization/modules/DEModuleAdapter.java +++ /dev/null @@ -1,22 +0,0 @@ -package eva2.optimization.modules; - -/** - * This the DE module adapter necessary to access this implementation from the EvA top level. - */ -public class DEModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { - - private static final String moduleName = "Differential_Evolution"; - - public DEModuleAdapter(String adapterName) { - super(adapterName, "DE.html", DEParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapters. - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/DEParameters.java b/src/eva2/optimization/modules/DEParameters.java deleted file mode 100644 index 89d96b21..00000000 --- a/src/eva2/optimization/modules/DEParameters.java +++ /dev/null @@ -1,171 +0,0 @@ -package eva2.optimization.modules; - - -import eva2.optimization.enums.DETypeEnum; -import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.population.Population; -import eva2.problems.F1Problem; -import eva2.optimization.strategies.DifferentialEvolution; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.tools.Serializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; - -/** - * The class gives access to all DE parameters for the EvA - * top level GUI. - * Created by IntelliJ IDEA. - * User: streiche - * Date: 27.10.2004 - * Time: 13:49:09 - * To change this template use File | Settings | File Templates. - */ -public class DEParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable { - - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static DEParameters getInstance() { - DEParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("DEParameters.ser"); - instance = (DEParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new DEParameters(); - } - return instance; - } - - /** - * - */ - public DEParameters() { - super(new DifferentialEvolution(), new F1Problem(), new EvaluationTerminator(1000)); - } - - private DEParameters(DEParameters Source) { - super(Source); - } - - @Override - public Object clone() { - return new DEParameters(this); - } - - /** - * This method returns a global info string - * - * @return description - */ - public static String globalInfo() { - return "This is a Differential Evolution optimization method, limit DE to real-valued genotypes."; - } - - /** - * This method allows you to set the current optimizing algorithm - * - * @param optimizer The new optimizing algorithm - */ - @Override - public void setOptimizer(InterfaceOptimizer optimizer) { - // *pff* i'll ignore that! - } - - /** - * 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.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Edit the properties of the population used."; - } - - /** - * This method will set the amplication factor f. - * - * @param f - */ - public void setF(double f) { - ((DifferentialEvolution) this.optimizer).setDifferentialWeight(f); - } - - public double getF() { - return ((DifferentialEvolution) this.optimizer).getDifferentialWeight(); - } - - public String differentialWeightTipText() { - return "F is a real and constant factor which controlls the amplification of the differential variation."; - } - - /** - * This method will set the crossover probability - * - * @param k - */ - public void setK(double k) { - ((DifferentialEvolution) this.optimizer).setCrossoverRate(k); - } - - public double getK() { - return ((DifferentialEvolution) this.optimizer).getCrossoverRate(); - } - - public String crossoverRateTipText() { - return "Probability of alteration through DE1."; - } - - /** - * This method will set greediness to move towards the best - * - * @param l - */ - public void setLambda(double l) { - ((DifferentialEvolution) this.optimizer).setLambda(l); - } - - public double getLambda() { - return ((DifferentialEvolution) this.optimizer).getLambda(); - } - - public String lambdaTipText() { - return "Enhance greediness through amplification of the differential vector to the best individual for DE2."; - } - - /** - * This method allows you to choose the type of Differential Evolution. - * - * @param s The type. - */ - public void setDEType(DETypeEnum s) { - ((DifferentialEvolution) this.optimizer).setDEType(s); - } - - public DETypeEnum getDEType() { - return ((DifferentialEvolution) this.optimizer).getDEType(); - } - - public String dETypeTipText() { - return "Choose the type of Differential Evolution."; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/EPModuleAdapter.java b/src/eva2/optimization/modules/EPModuleAdapter.java deleted file mode 100644 index 522e9f9a..00000000 --- a/src/eva2/optimization/modules/EPModuleAdapter.java +++ /dev/null @@ -1,22 +0,0 @@ -package eva2.optimization.modules; - -/** - * This the EP module adapter necessary to access this implementation from the EvA top level. - */ -public class EPModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { - - private static final String moduleName = "Evolutionary_Programming"; - - public EPModuleAdapter(String adapterName) { - super(adapterName, "EP.html", EPParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapter - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/EPParameters.java b/src/eva2/optimization/modules/EPParameters.java deleted file mode 100644 index 25e442a3..00000000 --- a/src/eva2/optimization/modules/EPParameters.java +++ /dev/null @@ -1,119 +0,0 @@ -package eva2.optimization.modules; - - -import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.operator.selection.InterfaceSelection; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.population.Population; -import eva2.problems.F1Problem; -import eva2.optimization.strategies.EvolutionaryProgramming; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.tools.Serializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - */ -public class EPParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable { - - private static final Logger LOGGER = Logger.getLogger(EPParameters.class.getName()); - - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static EPParameters getInstance() { - EPParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("EPParameters.ser"); - instance = (EPParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new EPParameters(); - } - return instance; - } - - /** - * - */ - public EPParameters() { - super(new EvolutionaryProgramming(), new F1Problem(), new EvaluationTerminator()); - } - - /** - * - */ - private EPParameters(EPParameters Source) { - super(Source); - } - - /** - * - */ - @Override - public Object clone() { - return new EPParameters(this); - } - - /** - * This method returns a global info string - * - * @return description - */ - public static String globalInfo() { - return "This is a Evolutionary Programming optimization method, limit EP to mutation operators only."; - } - - @Override - public void setOptimizer(InterfaceOptimizer optimizer) { - // i'm a Monte Carlo Search Algorithm - // *pff* i'll ignore that! - } - - /** - * 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.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Edit the properties of the population used."; - } - - /** - * Choose the type of environment selection to use. - * - * @param selection - */ - public void setEnvironmentSelection(InterfaceSelection selection) { - ((EvolutionaryProgramming) this.optimizer).setEnvironmentSelection(selection); - } - - public InterfaceSelection getEnvironmentSelection() { - return ((EvolutionaryProgramming) this.optimizer).getEnvironmentSelection(); - } - - public String environmentSelectionTipText() { - return "Choose a method for selecting the reduced population."; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/GAModuleAdapter.java b/src/eva2/optimization/modules/GAModuleAdapter.java deleted file mode 100644 index 17bcc97c..00000000 --- a/src/eva2/optimization/modules/GAModuleAdapter.java +++ /dev/null @@ -1,23 +0,0 @@ -package eva2.optimization.modules; - - -/** - * This the GA module adapter necessary to access this implementation from the EvA top level. - */ -public class GAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { - - private static final String moduleName = "Genetic_Algorithm"; - - public GAModuleAdapter(String adapterName) { - super(adapterName, "GA.html", GAParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapters - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} diff --git a/src/eva2/optimization/modules/GAParameters.java b/src/eva2/optimization/modules/GAParameters.java deleted file mode 100644 index 31e06e4e..00000000 --- a/src/eva2/optimization/modules/GAParameters.java +++ /dev/null @@ -1,190 +0,0 @@ -package eva2.optimization.modules; - -import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.operator.selection.InterfaceSelection; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.population.Population; -import eva2.problems.B1Problem; -import eva2.optimization.strategies.GeneticAlgorithm; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.tools.Serializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * The class gives access to all GA parameters for the EvA - * top level GUI. - * Created by IntelliJ IDEA. - * User: streiche - * Date: 08.06.2004 - * Time: 21:29:34 - * To change this template use File | Settings | File Templates. - */ -public class GAParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable { - - private static final Logger LOGGER = Logger.getLogger(GAParameters.class.getName()); - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static GAParameters getInstance() { - GAParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("GAParameters.ser"); - instance = (GAParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new GAParameters(); - } - return instance; - } - - /** - * - */ - public GAParameters() { - super(new GeneticAlgorithm(), new B1Problem(), new EvaluationTerminator()); - } - - /** - * - */ - private GAParameters(GAParameters Source) { - super(Source); - } - - /** - * - */ - @Override - public Object clone() { - return new GAParameters(this); - } - - /** - * This method returns a global info string - * - * @return description - */ - public static String globalInfo() { - return "This is a Genetic Algorithm, which transforms into a GP or GE if the appropriate problem and genotype is used."; - } - - @Override - public void setOptimizer(InterfaceOptimizer optimizer) { - // i'm a Monte Carlo Search Algorithm - // *pff* i'll ignore that! - } - - /** - * 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.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Edit the properties of the population used."; - } - -// /** This method will set the normation method that is to be used. -// * @param normation -// */ -// public void setNormationMethod (InterfaceNormation normation) { -// this.m_NormationOperator = normation; -// } -// public InterfaceNormation getNormationMethod () { -// return this.m_NormationOperator; -// } -// public String normationMethodTipText() { -// return "Select the normation method."; -// } - - /** - * Choose a parent selection method. - * - * @param selection - */ - public void setParentSelection(InterfaceSelection selection) { - ((GeneticAlgorithm) this.optimizer).setParentSelection(selection); - } - - public InterfaceSelection getParentSelection() { - return ((GeneticAlgorithm) this.optimizer).getParentSelection(); - } - - public String parentSelectionTipText() { - return "Choose a parent selection method."; - } - - /** - * Enable/disable elitism. - * - * @param elitism - */ - public void setElitism(boolean elitism) { - ((GeneticAlgorithm) this.optimizer).setElitism(elitism); - } - - public boolean getElitism() { - return ((GeneticAlgorithm) this.optimizer).getElitism(); - } - - public String elitismTipText() { - return "Enable/disable elitism."; - } - - /** - * The number of mating partners needed to create offsprings. - * - * @param partners - */ - public void setNumberOfPartners(int partners) { - if (partners < 0) { - partners = 0; - } - ((GeneticAlgorithm) this.optimizer).setNumberOfPartners(partners); - } - - public int getNumberOfPartners() { - return ((GeneticAlgorithm) this.optimizer).getNumberOfPartners(); - } - - public String numberOfPartnersTipText() { - return "The number of mating partners needed to create offsprings."; - } - - /** - * Choose a selection method for selecting recombination partners for given parents. - * - * @param selection - */ - public void setPartnerSelection(InterfaceSelection selection) { - ((GeneticAlgorithm) this.optimizer).setPartnerSelection(selection); - } - - public InterfaceSelection getPartnerSelection() { - return ((GeneticAlgorithm) this.optimizer).getPartnerSelection(); - } - - public String partnerSelectionTipText() { - return "Choose a selection method for selecting recombination partners for given parents."; - } -} diff --git a/src/eva2/optimization/modules/GenericModuleAdapter.java b/src/eva2/optimization/modules/GenericModuleAdapter.java index 3daba104..9ab25960 100644 --- a/src/eva2/optimization/modules/GenericModuleAdapter.java +++ b/src/eva2/optimization/modules/GenericModuleAdapter.java @@ -38,7 +38,8 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria } else { statisticsModule = new StatisticsStandalone(noGUIStatOut); } - processor = new Processor(statisticsModule, this, params); + processor = new Processor(statisticsModule, params); + processor.addListener(this); // the statistics want to be informed if the strategy or the optimizer (which provide statistical data as InterfaceAdditionalInformer) change. // THIS is now done directly in the constructor of a Processor @@ -87,7 +88,7 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria EvAModuleButtonPanelMaker buttonPanel = new EvAModuleButtonPanelMaker(remoteModuleAdapter, ((Processor) processor).isOptimizationRunning()); buttonPanel.setHelperFilename(helperFilename); frmMkr.addPanelMaker(buttonPanel); - InterfaceOptimizationParameters optimizationParameters = ((Processor) processor).getOptimizationParameterss(); + InterfaceOptimizationParameters optimizationParameters = ((Processor) processor).getOptimizationParameters(); frmMkr.addPanelMaker(paramPanel = new JParaPanel(optimizationParameters, optimizationParameters.getName())); @@ -102,7 +103,7 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria frmMkr.addPanelMaker(jobPanel); - ((Processor) processor).getOptimizationParameterss().addInformableInstance(frmMkr); + ((Processor) processor).getOptimizationParameters().addInformableInstance(frmMkr); return frmMkr; } @@ -133,7 +134,7 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria @Override public OptimizationJob scheduleJob() { - OptimizationJob job = jobList.addJob(((Processor) processor).getOptimizationParameterss(), (AbstractStatistics) (((Processor) processor).getStatistics())); + OptimizationJob job = jobList.addJob(((Processor) processor).getOptimizationParameters(), (AbstractStatistics) (((Processor) processor).getStatistics())); jobPanel.getEditor().setValue(jobList); return job; } diff --git a/src/eva2/optimization/modules/HCModuleAdapter.java b/src/eva2/optimization/modules/HCModuleAdapter.java deleted file mode 100644 index eed283fc..00000000 --- a/src/eva2/optimization/modules/HCModuleAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -package eva2.optimization.modules; - -/** - * This the HC module adapter necessary to access this implementation from the EvA top level. - */ -public class HCModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { - - private static final String moduleName = "Hill_Climber"; - - /** - * Constructor of the ModuleAdapter - * - * @param AdapterName The AdapterName - * @param Client The client to serve - */ - public HCModuleAdapter(String adapterName) { - super(adapterName, "HC.html", HCParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapters - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/HCParameters.java b/src/eva2/optimization/modules/HCParameters.java deleted file mode 100644 index 8b5b0faf..00000000 --- a/src/eva2/optimization/modules/HCParameters.java +++ /dev/null @@ -1,103 +0,0 @@ -package eva2.optimization.modules; - -import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.population.Population; -import eva2.problems.B1Problem; -import eva2.optimization.strategies.HillClimbing; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.tools.Serializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; - - -/** - * The class gives access to all HC parameters for the EvA - * top level GUI. - * Created by IntelliJ IDEA. - * User: streiche - * Date: 08.06.2004 - * Time: 21:19:20 - * To change this template use File | Settings | File Templates. - */ -public class HCParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable { - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static HCParameters getInstance() { - HCParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("HCParameters.ser"); - instance = (HCParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new HCParameters(); - } - return instance; - } - - /** - * - */ - public HCParameters() { - super(new HillClimbing(), new B1Problem(), new EvaluationTerminator()); - } - - /** - * - */ - private HCParameters(HCParameters Source) { - super(Source); - } - - /** - * - */ - @Override - public Object clone() { - return new HCParameters(this); - } - - /** - * This method returns a global info string - * - * @return description - */ - public static String globalInfo() { - return "This is a Hill-Climber, use a population size > 1 for a Multi-Start Hill-Climber."; - } - - @Override - public void setOptimizer(InterfaceOptimizer optimizer) { - // i'm a Monte Carlo Search Algorithm - // *pff* i'll ignore that! - } - - /** - * 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.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Edit the properties of the population used."; - } -} diff --git a/src/eva2/optimization/modules/MCModuleAdapter.java b/src/eva2/optimization/modules/MCModuleAdapter.java deleted file mode 100644 index d4382a61..00000000 --- a/src/eva2/optimization/modules/MCModuleAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -package eva2.optimization.modules; - -/** - * This the MC module adapter necessary to access this implementation from the EvA top level. - */ -public class MCModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { - - private static final String moduleName = "Monte_Carlo_Search"; - - /** - * Constructor of the ModuleAdapter. - * - * @param adapterName The AdapterName - * @param client The client to serve - */ - public MCModuleAdapter(String adapterName) { - super(adapterName, "MC.html", MCParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapters - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/MCParameters.java b/src/eva2/optimization/modules/MCParameters.java deleted file mode 100644 index edfd09f2..00000000 --- a/src/eva2/optimization/modules/MCParameters.java +++ /dev/null @@ -1,99 +0,0 @@ -package eva2.optimization.modules; - -import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.population.Population; -import eva2.problems.B1Problem; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.optimization.strategies.MonteCarloSearch; -import eva2.tools.Serializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; - -/** - * The class gives access to all HC parameters for the EvA - * top level GUI. - * Created by IntelliJ IDEA. - * User: streiche - * Date: 08.06.2004 - * Time: 21:07:40 - * To change this template use File | Settings | File Templates. - */ -public class MCParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable { - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static MCParameters getInstance() { - MCParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("MCParameters.ser"); - instance = (MCParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new MCParameters(); - } - return instance; - } - - /** - * - */ - public MCParameters() { - super(new MonteCarloSearch(), new B1Problem(), new EvaluationTerminator()); - } - - private MCParameters(MCParameters Source) { - super(Source); - } - - /** - * - */ - @Override - public Object clone() { - return new MCParameters(this); - } - - /** - * This method returns a global info string - * - * @return description - */ - public static String globalInfo() { - return "This is a simple Monte-Carlo Search, use big populations sizes for faster drawing."; - } - - @Override - public void setOptimizer(InterfaceOptimizer optimizer) { - // *pff* i'll ignore that! - } - - - /** - * 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.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Edit the properties of the population used."; - } -} diff --git a/src/eva2/optimization/modules/MOEAModuleAdapter.java b/src/eva2/optimization/modules/MOEAModuleAdapter.java deleted file mode 100644 index f84558e0..00000000 --- a/src/eva2/optimization/modules/MOEAModuleAdapter.java +++ /dev/null @@ -1,31 +0,0 @@ -package eva2.optimization.modules; - -import java.io.Serializable; - - -/** - * This the MOEA module adapter necessary to access this implementation from the EvA top level. - */ -public class MOEAModuleAdapter extends GenericModuleAdapter implements Serializable, ModuleAdapter { - - private static final String moduleName = "Multi-Objective_Evolutionary_Algorithms"; - - /** - * Constructor of the ModuleAdapter. - * - * @param AdapterName The AdapterName - * @param Client The client to serve - */ - public MOEAModuleAdapter(String adapterName) { - super(adapterName, "MOEA.html", MOEAParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapters - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} diff --git a/src/eva2/optimization/modules/MOEAParameters.java b/src/eva2/optimization/modules/MOEAParameters.java deleted file mode 100644 index 20458e34..00000000 --- a/src/eva2/optimization/modules/MOEAParameters.java +++ /dev/null @@ -1,169 +0,0 @@ -package eva2.optimization.modules; - -import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.operator.archiving.InterfaceArchiving; -import eva2.optimization.operator.archiving.InterfaceInformationRetrieval; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.population.Population; -import eva2.problems.TF1Problem; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.optimization.strategies.MultiObjectiveEA; -import eva2.tools.Serializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; - -/** - * The class gives access to all MOEA parameters for the EvA - * top level GUI. - * Created by IntelliJ IDEA. - * User: streiche - * Date: 27.10.2004 - * Time: 13:49:09 - * To change this template use File | Settings | File Templates. - */ -public class MOEAParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable { - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static MOEAParameters getInstance() { - MOEAParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("MOEAParameters.ser"); - instance = (MOEAParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new MOEAParameters(); - } - return instance; - } - - public MOEAParameters() { - super(new MultiObjectiveEA(), new TF1Problem(), new EvaluationTerminator(1000)); - } - - private MOEAParameters(MOEAParameters Source) { - super(Source); - } - - @Override - public Object clone() { - return new MOEAParameters(this); - } - - /** - * This method returns a global info string - * - * @return description - */ - public static String globalInfo() { - return "This is a multi-objective evoluationary algorithm, limit MOEA to multi-objective problems (due to the given framework only the fitness of objective one will be plotted)."; - } - - /** - * 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.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Edit the properties of the Population used."; - } - - /** - * This method allows you to set/get the optimizing technique to use. - * - * @return The current optimizing method - */ - @Override - public InterfaceOptimizer getOptimizer() { - return ((MultiObjectiveEA) this.optimizer).getOptimizer(); - } - - @Override - public void setOptimizer(InterfaceOptimizer b) { - ((MultiObjectiveEA) this.optimizer).setOptimizer(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 ((MultiObjectiveEA) this.optimizer).getArchivingStrategy(); - } - - public void setArchivingStrategy(InterfaceArchiving b) { - ((MultiObjectiveEA) this.optimizer).setArchivingStrategy(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 ((MultiObjectiveEA) this.optimizer).getInformationRetrieval(); - } - - public void setInformationRetrieval(InterfaceInformationRetrieval b) { - ((MultiObjectiveEA) this.optimizer).setInformationRetrieval(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.optimizer.getPopulation().getArchive(); - if (archive == null) { - archive = new Population(); - this.optimizer.getPopulation().SetArchive(archive); - } - return ((MultiObjectiveEA) this.optimizer).getArchiveSize(); - } - - public void setArchiveSize(int b) { - Population archive = this.optimizer.getPopulation().getArchive(); - if (archive == null) { - archive = new Population(); - this.optimizer.getPopulation().SetArchive(archive); - } - this.optimizer.getPopulation().getArchive().setTargetSize(b); - } - - public String archiveSizeTipText() { - return "Choose the size of the archive."; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/PBILModuleAdapter.java b/src/eva2/optimization/modules/PBILModuleAdapter.java deleted file mode 100644 index a62b47d0..00000000 --- a/src/eva2/optimization/modules/PBILModuleAdapter.java +++ /dev/null @@ -1,29 +0,0 @@ -package eva2.optimization.modules; - - -/** - * This the PBIL module adapter necessary to access this implementation from the EvA top level. - */ -public class PBILModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { - - private static final String moduleName = "Population_Based_Incremental_Learning"; - - /** - * Constructor of the ModuleAdapter - * - * @param AdapterName The AdapterName - * @param Client The client to serve - */ - public PBILModuleAdapter(String adapterName) { - super(adapterName, "PBIL.html", PBILParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapters - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/PBILParameters.java b/src/eva2/optimization/modules/PBILParameters.java deleted file mode 100644 index 77dbba2e..00000000 --- a/src/eva2/optimization/modules/PBILParameters.java +++ /dev/null @@ -1,212 +0,0 @@ -package eva2.optimization.modules; - -import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.operator.selection.InterfaceSelection; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.population.Population; -import eva2.problems.B1Problem; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.optimization.strategies.PopulationBasedIncrementalLearning; -import eva2.tools.Serializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; - - -/** - * The class gives access to all PBIL parameters for the EvA - * top level GUI. - * Created by IntelliJ IDEA. - * User: streiche - * Date: 08.06.2004 - * Time: 21:53:29 - * To change this template use File | Settings | File Templates. - */ -public class PBILParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable { - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static PBILParameters getInstance() { - PBILParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("PBILParameters.ser"); - instance = (PBILParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new PBILParameters(); - } - return instance; - } - - public PBILParameters() { - super(new PopulationBasedIncrementalLearning(), new B1Problem(), new EvaluationTerminator(1000)); - } - - private PBILParameters(PBILParameters Source) { - super(Source); - } - - @Override - public Object clone() { - return new PBILParameters(this); - } - - /** - * This method returns a global info string - * - * @return description - */ -// public static String globalInfo() { -// return ((PopulationBasedIncrementalLearning)this.optimizer).globalInfo(); -// } - @Override - public void setOptimizer(InterfaceOptimizer optimizer) { - // i'm a Monte Carlo Search Algorithm - // *pff* i'll ignore that! - } - - /** - * 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.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Edit the properties of the population used."; - } - - /** - * This method will set the selection method that is to be used - * - * @param selection - */ - public void setSelectionMethod(InterfaceSelection selection) { - ((PopulationBasedIncrementalLearning) this.optimizer).setSelectionMethod(selection); - } - - public InterfaceSelection getSelectionMethod() { - return ((PopulationBasedIncrementalLearning) this.optimizer).getSelectionMethod(); - } - - public String selectionMethodTipText() { - return "Choose a selection method."; - } - - /** - * Enable/disable elitism. - * - * @param elitism - */ - public void setElitism(boolean elitism) { - ((PopulationBasedIncrementalLearning) this.optimizer).setElitism(elitism); - } - - public boolean getElitism() { - return ((PopulationBasedIncrementalLearning) this.optimizer).getElitism(); - } - - public String elitismTipText() { - return "Enable/disable elitism."; - } - - /** - * This method will set the learning rate for PBIL - * - * @param LearningRate - */ - public void setLearningRate(double LearningRate) { - if (LearningRate < 0) { - LearningRate = 0; - } - ((PopulationBasedIncrementalLearning) this.optimizer).setLearningRate(LearningRate); - } - - public double getLearningRate() { - return ((PopulationBasedIncrementalLearning) this.optimizer).getLearningRate(); - } - - public String learningRateTipText() { - return "The learing rate of PBIL."; - } - - /** - * This method will set the mutation rate for PBIL - * - * @param m - */ - public void setMutationRate(double m) { - if (m < 0) { - m = 0; - } - if (m > 1) { - m = 1; - } - ((PopulationBasedIncrementalLearning) this.optimizer).setMutationRate(m); - - } - - public double getMutationRate() { - return ((PopulationBasedIncrementalLearning) this.optimizer).getMutationRate(); - } - - public String mutationRateTipText() { - return "The mutation rate of PBIL."; - } - - /** - * This method will set the mutation sigma for PBIL - * - * @param m - */ - public void setMutateSigma(double m) { - if (m < 0) { - m = 0; - } - ((PopulationBasedIncrementalLearning) this.optimizer).setMutateSigma(m); - } - - public double getMutateSigma() { - return ((PopulationBasedIncrementalLearning) this.optimizer).getMutateSigma(); - } - - 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 - * - * @param PositiveSamples - */ - public void setPositiveSamples(int PositiveSamples) { - if (PositiveSamples < 1) { - PositiveSamples = 1; - } - ((PopulationBasedIncrementalLearning) this.optimizer).setPositiveSamples(PositiveSamples); - } - - public int getPositiveSamples() { - return ((PopulationBasedIncrementalLearning) this.optimizer).getPositiveSamples(); - } - - public String positiveSamplesTipText() { - return "The number of positive samples that update the PBIL vector."; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/PSOModuleAdapter.java b/src/eva2/optimization/modules/PSOModuleAdapter.java deleted file mode 100644 index 9c9d9ed2..00000000 --- a/src/eva2/optimization/modules/PSOModuleAdapter.java +++ /dev/null @@ -1,29 +0,0 @@ -package eva2.optimization.modules; - - -/** - * This the PSO module adapter necessary to access this implementation from the EvA top level. - */ -public class PSOModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { - - private static final String moduleName = "Particle_Swarm_Optimization"; - - /** - * Constructor of the ModulAdapter. - * - * @param AdapterName The AdapterName - * @param Client The client to serve - */ - public PSOModuleAdapter(String adapterName) { - super(adapterName, "PSO.html", PSOParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapter - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/PSOParameters.java b/src/eva2/optimization/modules/PSOParameters.java deleted file mode 100644 index 2226756f..00000000 --- a/src/eva2/optimization/modules/PSOParameters.java +++ /dev/null @@ -1,333 +0,0 @@ -package eva2.optimization.modules; - - -import eva2.gui.editor.GenericObjectEditor; -import eva2.optimization.enums.PSOTopologyEnum; -import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.population.Population; -import eva2.problems.F1Problem; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.optimization.strategies.ParticleSwarmOptimization; -import eva2.tools.SelectedTag; -import eva2.tools.Serializer; -import eva2.util.annotation.Description; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; - -/** - */ -@Description("Particle Swarm Optimization by Kennedy and Eberhart.") -public class PSOParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable { - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static PSOParameters getInstance() { - PSOParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("PSOParameters.ser"); - instance = (PSOParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new PSOParameters(); - } - return instance; - } - - /** - * - */ - public PSOParameters() { - super(new ParticleSwarmOptimization(), new F1Problem(), new EvaluationTerminator()); - } - - private PSOParameters(PSOParameters Source) { - super(Source); - } - - @Override - public Object clone() { - return new PSOParameters(this); - } - - /** - * Take care that all properties which may be hidden (and currently are) send a "hide" message to the Java Bean properties. - * This is called by PropertySheetPanel in use with the GenericObjectEditor. - */ - public void hideHideable() { - setCheckSpeedLimit(isCheckSpeedLimit()); - setTopology(getTopology()); - } - - @Override - public void setOptimizer(InterfaceOptimizer optimizer) { - // *pff* i'll ignore that! - } - - /** - * 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.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Edit the properties of the population used."; - } - - /** - * This method will set the initial velocity - * - * @param f - */ - public void setInitialVelocity(double f) { - ((ParticleSwarmOptimization) this.optimizer).setInitialVelocity(f); - } - - public double getInitialVelocity() { - return ((ParticleSwarmOptimization) this.optimizer).getInitialVelocity(); - } - - public String initialVelocityTipText() { - return ((ParticleSwarmOptimization) this.optimizer).initialVelocityTipText(); - } - - /** - * This method will set the speed limit - * - * @param k - */ - public void setSpeedLimit(double k) { - ((ParticleSwarmOptimization) this.optimizer).setSpeedLimit(k); - } - - public double getSpeedLimit() { - return ((ParticleSwarmOptimization) this.optimizer).getSpeedLimit(); - } - - public String speedLimitTipText() { - return ((ParticleSwarmOptimization) this.optimizer).speedLimitTipText(); - } - - /** - * This method will set the inertness - * - * @param k - */ - public void setInertnessOrChi(double k) { -// if (k < 0) k = 0; -// if (k > 1) k = 1; - ((ParticleSwarmOptimization) this.optimizer).setInertnessOrChi(k); - } - - public double getInertnessOrChi() { - return ((ParticleSwarmOptimization) this.optimizer).getInertnessOrChi(); - } - - public String inertnessOrChiTipText() { - return ((ParticleSwarmOptimization) this.optimizer).inertnessOrChiTipText(); - } - - /** - * This method will set greediness to move towards the best solution - * based on the cognition model - * - * @param l - */ - public void setPhi1(double l) { - ((ParticleSwarmOptimization) this.optimizer).setPhi1(l); - } - - public double getPhi1() { - return ((ParticleSwarmOptimization) this.optimizer).getPhi1(); - } - - public String phi1TipText() { - return ((ParticleSwarmOptimization) this.optimizer).phi1TipText(); - } - - /** - * This method will set greediness to move towards the best solution - * based on the social model - * - * @param l - */ - public void setPhi2(double l) { - ((ParticleSwarmOptimization) this.optimizer).setPhi2(l); - } - - public double getPhi2() { - return ((ParticleSwarmOptimization) this.optimizer).getPhi2(); - } - - public String phi2TipText() { - return ((ParticleSwarmOptimization) this.optimizer).phi2TipText(); - } - - - /** - * Toggle Check Constraints. - * - * @param s Check Constraints. - */ - public void setCheckRange(boolean s) { - ((ParticleSwarmOptimization) this.optimizer).setCheckRange(s); - } - - public boolean isCheckRange() { - return ((ParticleSwarmOptimization) this.optimizer).isCheckRange(); - } - - public String checkConstraintsTipText() { - return ((ParticleSwarmOptimization) this.optimizer).checkRangeTipText(); - } - - /** - * This method allows you to choose the topology type. - * - * @param t The type. - */ - public void setTopology(PSOTopologyEnum t) { - ((ParticleSwarmOptimization) this.optimizer).setTopology(t); - ((ParticleSwarmOptimization) this.optimizer).setGOEShowProperties(getClass()); - } - - public PSOTopologyEnum getTopology() { - return ((ParticleSwarmOptimization) this.optimizer).getTopology(); - } - - public String topologyTipText() { - return ((ParticleSwarmOptimization) this.optimizer).topologyTipText(); - } - - /** - * The range of the local neighbourhood. - * - * @param s The range. - */ - public void setTopologyRange(int s) { - ((ParticleSwarmOptimization) this.optimizer).setTopologyRange(s); - } - - public int getTopologyRange() { - return ((ParticleSwarmOptimization) this.optimizer).getTopologyRange(); - } - - public String topologyRangeTipText() { - return ((ParticleSwarmOptimization) this.optimizer).topologyRangeTipText(); - } - - public double getSubSwarmRadius() { - return ((ParticleSwarmOptimization) this.optimizer).getSubSwarmRadius(); - } - - public void setSubSwarmRadius(double radius) { - ((ParticleSwarmOptimization) this.optimizer).setSubSwarmRadius(radius); - } - - public String subSwarmRadiusTipText() { - return ((ParticleSwarmOptimization) this.optimizer).subSwarmRadiusTipText(); - } - - public int getMaxSubSwarmSize() { - return ((ParticleSwarmOptimization) this.optimizer).getMaxSubSwarmSize(); - } - - public void setMaxSubSwarmSize(int subSize) { - ((ParticleSwarmOptimization) this.optimizer).setMaxSubSwarmSize(subSize); - } - - public String maxSubSwarmSizeTipText() { - return ((ParticleSwarmOptimization) this.optimizer).maxSubSwarmSizeTipText(); - } - - /** - * @return the checkSpeedLimit - */ - public boolean isCheckSpeedLimit() { - return ((ParticleSwarmOptimization) this.optimizer).isCheckSpeedLimit(); - } - - /** - * @param checkSpeedLimit the checkSpeedLimit to set - */ - public void setCheckSpeedLimit(boolean checkSpeedLimit) { - ((ParticleSwarmOptimization) this.optimizer).setCheckSpeedLimit(checkSpeedLimit); - GenericObjectEditor.setHideProperty(getClass(), "speedLimit", !checkSpeedLimit); - } - - public String checkSpeedLimitTipText() { - return ((ParticleSwarmOptimization) this.optimizer).checkSpeedLimitTipText(); - } - - /** - * This method allows you to choose the algorithm type. - * - * @param s The type. - */ - public void setAlgoType(SelectedTag s) { - ((ParticleSwarmOptimization) this.optimizer).setAlgoType(s); - } - - public SelectedTag getAlgoType() { - return ((ParticleSwarmOptimization) this.optimizer).getAlgoType(); - } - - public String algoTypeTipText() { - return ((ParticleSwarmOptimization) this.optimizer).algoTypeTipText(); - } - -// /** -// * @return the treeBranchDeg -// */ -// public int getTreeBranchDegree() { -// return ((ParticleSwarmOptimization)this.optimizer).getTreeBranchDegree(); -// } -// -// /** -// * @param treeBranchDeg the treeBranchDeg to set -// */ -// public void setTreeBranchDegree(int treeBranchDeg) { -// ((ParticleSwarmOptimization)this.optimizer).setTreeBranchDegree(treeBranchDeg); -// } -// -// public String treeBranchDegreeTipText() { -// return ((ParticleSwarmOptimization)this.optimizer).treeBranchDegreeTipText(); -// } - - /** - * @return the wrapTopology - */ - public boolean isWrapTopology() { - return ((ParticleSwarmOptimization) this.optimizer).isWrapTopology(); - } - - /** - * @param wrapTopology the wrapTopology to set - */ - public void setWrapTopology(boolean wrapTopology) { - ((ParticleSwarmOptimization) this.optimizer).setWrapTopology(wrapTopology); - } - - public String wrapTopologyTipText() { - return ((ParticleSwarmOptimization) this.optimizer).wrapTopologyTipText(); - } - -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/Processor.java b/src/eva2/optimization/modules/Processor.java index b6e49c73..3383db11 100644 --- a/src/eva2/optimization/modules/Processor.java +++ b/src/eva2/optimization/modules/Processor.java @@ -69,10 +69,9 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo * * @see InterfaceNotifyOnInformers */ - public Processor(InterfaceStatistics statistics, ModuleAdapter moduleAdapter, InterfaceOptimizationParameters optimizationParameters) { + public Processor(InterfaceStatistics statistics, InterfaceOptimizationParameters optimizationParameters) { this.optimizationParameters = optimizationParameters; this.statistics = statistics; - optimizationStateListener = moduleAdapter; // the statistics want to be informed if the strategy or the optimizer (which provide statistical data as InterfaceAdditionalInformer) change. if (statistics != null && (optimizationParameters != null)) { @@ -211,7 +210,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo Population resultPop = null; if (!isOptimizationRunning()) { - System.err.println("warning, this shouldnt happen in processor! Was startOptimization called?"); + LOGGER.warning("Was startOptimization already called?"); setOptimizationRunning(true); } @@ -407,11 +406,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo @Override public String getInfoString() { - //StringBuffer sb = new StringBuffer("processing "); - StringBuilder sb = new StringBuilder(this.optimizationParameters.getProblem().getName()); - sb.append("+"); - sb.append(this.optimizationParameters.getOptimizer().getName()); - return sb.toString(); + return this.optimizationParameters.getProblem().getName() + "+" + this.optimizationParameters.getOptimizer().getName(); } /** @@ -424,7 +419,7 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo /** * These methods allow you to get and set the Module Parameters. */ - public InterfaceOptimizationParameters getOptimizationParameterss() { + public InterfaceOptimizationParameters getOptimizationParameters() { return optimizationParameters; } diff --git a/src/eva2/optimization/modules/SAModuleAdapter.java b/src/eva2/optimization/modules/SAModuleAdapter.java deleted file mode 100644 index 53d5c2bf..00000000 --- a/src/eva2/optimization/modules/SAModuleAdapter.java +++ /dev/null @@ -1,29 +0,0 @@ -package eva2.optimization.modules; - -/** - * This the SA module adapter necessary to access this implementation from the - * EvA top level. - */ -public class SAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { - - private static final String moduleName = "Simulated_Annealing"; - - /** - * Constructor of the ModulAdapter. - * - * @param AdapterName The AdapterName - * @param Client The client to serve - */ - public SAModuleAdapter(String adapterName) { - super(adapterName, "SA.html", SAParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapter - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} diff --git a/src/eva2/optimization/modules/SAParameters.java b/src/eva2/optimization/modules/SAParameters.java deleted file mode 100644 index 3152758d..00000000 --- a/src/eva2/optimization/modules/SAParameters.java +++ /dev/null @@ -1,135 +0,0 @@ -package eva2.optimization.modules; - -import eva2.optimization.go.InterfacePopulationChangedEventListener; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.operator.terminators.InterfaceTerminator; -import eva2.optimization.population.Population; -import eva2.problems.B1Problem; -import eva2.problems.InterfaceOptimizationProblem; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.optimization.strategies.SimulatedAnnealing; -import eva2.tools.Serializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; - -/** - * - */ -public class SAParameters extends AbstractOptimizationParameters implements Serializable { - // Opt. Algorithms and Parameters - private InterfaceOptimizer optimizer = new SimulatedAnnealing(); - private InterfaceOptimizationProblem problem = new B1Problem(); - private InterfaceTerminator terminator = new EvaluationTerminator(); - transient private InterfacePopulationChangedEventListener changedEventListener; - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static SAParameters getInstance() { - SAParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("SAParameters.ser"); - instance = (SAParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new SAParameters(); - } - return instance; - } - - /** - * - */ - public SAParameters() { - super(new SimulatedAnnealing(), new B1Problem(), new EvaluationTerminator()); - } - - private SAParameters(SAParameters Source) { - super(Source); - } - - @Override - public Object clone() { - return new SAParameters(this); - } - - /** - * This method returns a global info string - * - * @return description - */ - public static String globalInfo() { - return "This is a simple Simulated Annealing algorithm."; - } - - @Override - public void setOptimizer(InterfaceOptimizer optimizer) { - // *pff* i'll ignore that! - } - - /** - * 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.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Change the number of best individuals stored (MS-SA)."; - } - - /** - * This methods allow you to set/get the temperatur of the simulated - * annealing procedure - * - * @return The initial temperature. - */ - public double getInitialTemperature() { - return ((SimulatedAnnealing) this.optimizer).getInitialTemperature(); - } - - public void setInitialTemperature(double pop) { - ((SimulatedAnnealing) this.optimizer).setInitialTemperature(pop); - } - - public String initialTemperatureTipText() { - return "Set the initial temperature."; - } - - /** - * This methods allow you to set/get the temperatur of the simulated - * annealing procedure - * - * @return The initial temperature. - */ - public double getAlpha() { - return ((SimulatedAnnealing) this.optimizer).getAlpha(); - } - - public void setAlpha(double a) { - if (a > 1) { - a = 1.0; - } - ((SimulatedAnnealing) this.optimizer).setAlpha(a); - } - - public String alphaTipText() { - return "Set alpha, which is used to degrade the temperaure."; - } -} diff --git a/src/eva2/optimization/modules/SSGAModuleAdapter.java b/src/eva2/optimization/modules/SSGAModuleAdapter.java deleted file mode 100644 index 88514f54..00000000 --- a/src/eva2/optimization/modules/SSGAModuleAdapter.java +++ /dev/null @@ -1,29 +0,0 @@ -package eva2.optimization.modules; - -/** - * This the SSGA module adapter necessary to access this implementation from the - * EvA top level. - */ -public class SSGAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { - - private static final String moduleName = "Steady_State_Genetic_Algorithm"; - - /** - * Constructor of the ModuleAdapter. - * - * @param AdapterName The AdapterName - * @param Client The client to serve - */ - public SSGAModuleAdapter(String adapterName) { - super(adapterName, "SSGA.html", SSGAParameters.getInstance(), true); - } - - /** - * This method returns the name of the ModulAdapters - * - * @return The name - */ - public static String getName() { - return moduleName; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/SSGAParameters.java b/src/eva2/optimization/modules/SSGAParameters.java deleted file mode 100644 index 523acbfc..00000000 --- a/src/eva2/optimization/modules/SSGAParameters.java +++ /dev/null @@ -1,182 +0,0 @@ -package eva2.optimization.modules; - -import eva2.optimization.go.InterfaceOptimizationParameters; -import eva2.optimization.operator.selection.InterfaceSelection; -import eva2.optimization.operator.selection.replacement.InterfaceReplacement; -import eva2.optimization.operator.terminators.EvaluationTerminator; -import eva2.optimization.population.Population; -import eva2.problems.B1Problem; -import eva2.optimization.strategies.InterfaceOptimizer; -import eva2.optimization.strategies.SteadyStateGA; -import eva2.tools.Serializer; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.Serializable; -import java.util.logging.Level; - -/** - * The class gives access to all SSGA parameters for the EvA - * top level GUI. - * Created by IntelliJ IDEA. - * User: streiche - * Date: 19.07.2005 - * Time: 15:44:34 - * To change this template use File | Settings | File Templates. - */ -public class SSGAParameters extends AbstractOptimizationParameters implements InterfaceOptimizationParameters, Serializable { - - /** - * Load or create a new instance of the class. - * - * @return A loaded (from file) or new instance of the class. - */ - public static SSGAParameters getInstance() { - SSGAParameters instance = null; - try { - FileInputStream fileStream = new FileInputStream("SSGAParameters.ser"); - instance = (SSGAParameters) Serializer.loadObject(fileStream); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not load instance object.", ex); - } - - if (instance == null) { - instance = new SSGAParameters(); - } - return instance; - } - - /** - * - */ - public SSGAParameters() { - super(new SteadyStateGA(), new B1Problem(), new EvaluationTerminator()); - } - - private SSGAParameters(SSGAParameters Source) { - super(Source); - } - - @Override - public Object clone() { - return new SSGAParameters(this); - } - - /** - * This method returns a global info string. - * - * @return description - */ - public static String globalInfo() { - return "This is a steady-state GA."; - } - - @Override - public void setOptimizer(InterfaceOptimizer optimizer) { - // *pff* i'll ignore that! - } - - /** - * 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() { - return this.optimizer.getPopulation(); - } - - public void setPopulation(Population pop) { - this.optimizer.setPopulation(pop); - } - - public String populationTipText() { - return "Edit the properties of the population used."; - } - -// /** This method will set the normation method that is to be used. -// * @param normation -// */ -// public void setNormationMethod (InterfaceNormation normation) { -// this.m_NormationOperator = normation; -// } -// public InterfaceNormation getNormationMethod () { -// return this.m_NormationOperator; -// } -// public String normationMethodTipText() { -// return "Select the normation method."; -// } - - /** - * Choose a parent selection method. - * - * @param selection - */ - public void setParentSelection(InterfaceSelection selection) { - ((SteadyStateGA) this.optimizer).setParentSelection(selection); - } - - public InterfaceSelection getParentSelection() { - return ((SteadyStateGA) this.optimizer).getParentSelection(); - } - - public String parentSelectionTipText() { - return "Choose a parent selection method."; - } - - /** - * This method will set the number of partners that are needed to create - * offsprings by mating. - * - * @param partners Number of partners needed for mating - */ - public void setNumberOfPartners(int partners) { - if (partners < 0) { - partners = 0; - } - ((SteadyStateGA) this.optimizer).setNumberOfPartners(partners); - } - - public int getNumberOfPartners() { - return ((SteadyStateGA) this.optimizer).getNumberOfPartners(); - } - - public String numberOfPartnersTipText() { - return "The number of mating partners needed to create offsprings."; - } - - /** - * Choose a selection method for selecting recombination partners for given parents. - * - * @param selection - */ - public void setPartnerSelection(InterfaceSelection selection) { - ((SteadyStateGA) this.optimizer).setPartnerSelection(selection); - } - - public InterfaceSelection getPartnerSelection() { - return ((SteadyStateGA) this.optimizer).getPartnerSelection(); - } - - public String partnerSelectionTipText() { - return "Choose a selection method for selecting recombination partners for given parents."; - } - - /** - * Choose a replacement strategy. - * - * @param s A InterfaceReplacement strategy. - */ - public void setReplacementSelection(InterfaceReplacement s) { - ((SteadyStateGA) this.optimizer).setReplacementSelection(s); - } - - public InterfaceReplacement getReplacementSelection() { - return ((SteadyStateGA) this.optimizer).getReplacementSelection(); - } - - public String replacementSelectionTipText() { - return "Choose a replacement strategy."; - } -} \ No newline at end of file