diff --git a/src/eva2/cli/Main.java b/src/eva2/cli/Main.java index 08c7dc8f..e40f6786 100644 --- a/src/eva2/cli/Main.java +++ b/src/eva2/cli/Main.java @@ -225,9 +225,38 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang if (commandLine.hasOption("optimizer")) { String optimizerName = commandLine.getOptionValue("optimizer"); - + try { + createOptimizerFromName(optimizerName, optimizerParams); + } catch(Exception ex) { + System.out.println(ex.getMessage()); + System.exit(-1); + } } + } + /** + * This method will create the various optimizers that are supported on the CLI. + * It's a really messy process since neither Java nor args4j/apache-cli can handle + * complex object parameters. The trick here is that all parameters after the + * double-dash (--) are treated as parameters for the optimization algorithm. + * + * @param optimizerName The name of the optimizer. + * @param optimizerParams The remaining command line parameters. + * @throws Exception + */ + private void createOptimizerFromName(String optimizerName, String[] optimizerParams) throws Exception { + Options opt = new Options(); + + switch(optimizerName) { + case "DifferentialEvolution": + System.out.println("DE"); + opt.addOption("-F", true, "Differential Weight"); + opt.addOption("-CR", true, "Crossover Rate"); + opt.addOption("-DEType", true, "DE Type ("); + break; + default: + throw new Exception("Unsupported Optimizer"); + } } private void setProblemFromName(String problemName) { diff --git a/src/eva2/gui/OptimizationEditorPanel.java b/src/eva2/gui/OptimizationEditorPanel.java index 37c64627..bcc8df0c 100644 --- a/src/eva2/gui/OptimizationEditorPanel.java +++ b/src/eva2/gui/OptimizationEditorPanel.java @@ -139,7 +139,7 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener { okayButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { - backupObject = copyObject(genericObjectEditor.getValue()); + //backupObject = copyObject(genericObjectEditor.getValue()); updateClassType(); updateChildPropertySheet(); diff --git a/src/eva2/optimization/mocco/MOCCOParameterizeRefPoint.java b/src/eva2/optimization/mocco/MOCCOParameterizeRefPoint.java index 7121f7c8..8bb254a6 100644 --- a/src/eva2/optimization/mocco/MOCCOParameterizeRefPoint.java +++ b/src/eva2/optimization/mocco/MOCCOParameterizeRefPoint.java @@ -132,7 +132,7 @@ public class MOCCOParameterizeRefPoint extends MOCCOPhase implements InterfacePr // IslandModelEA this.m_EIMEA = new GeneralOptimizationEditorProperty(); this.m_Island = new IslandModelEA(); - this.m_Island.setHeterogenuousProblems(true); + this.m_Island.setHeterogeneousProblems(true); this.m_Island.setLocalOnly(true); this.m_Island.setMigrationRate(2); this.m_Island.setMigrationStrategy(new SOBestMigration()); diff --git a/src/eva2/optimization/mocco/MOCCOParameterizeTchebycheff.java b/src/eva2/optimization/mocco/MOCCOParameterizeTchebycheff.java index 2ff5843f..1dc935d8 100644 --- a/src/eva2/optimization/mocco/MOCCOParameterizeTchebycheff.java +++ b/src/eva2/optimization/mocco/MOCCOParameterizeTchebycheff.java @@ -102,7 +102,7 @@ public class MOCCOParameterizeTchebycheff extends MOCCOPhase implements Interfac // IslandModelEA this.m_EIMEA = new GeneralOptimizationEditorProperty(); this.m_Island = new IslandModelEA(); - this.m_Island.setHeterogenuousProblems(true); + this.m_Island.setHeterogeneousProblems(true); this.m_Island.setLocalOnly(true); this.m_Island.setMigrationRate(2); this.m_Island.setMigrationStrategy(new SOBestMigration()); diff --git a/src/eva2/optimization/strategies/ArtificialBeeColony.java b/src/eva2/optimization/strategies/ArtificialBeeColony.java index fe669654..49d311b2 100644 --- a/src/eva2/optimization/strategies/ArtificialBeeColony.java +++ b/src/eva2/optimization/strategies/ArtificialBeeColony.java @@ -1,7 +1,99 @@ package eva2.optimization.strategies; +import eva2.optimization.go.InterfacePopulationChangedEventListener; +import eva2.optimization.population.InterfaceSolutionSet; +import eva2.optimization.population.Population; +import eva2.optimization.problems.InterfaceOptimizationProblem; +import eva2.util.annotation.Description; + /** * */ -public class ArtificialBeeColony { +@Description(text = "Artificial Bee Colony Optimizer") +public class ArtificialBeeColony implements InterfaceOptimizer { + + + + public ArtificialBeeColony() { + + } + + public ArtificialBeeColony(ArtificialBeeColony copy) { + + } + + @Override + public Object clone() { + return new ArtificialBeeColony(this); + } + + @Override + public String getName() { + return "Artificial Bee Colony"; + } + + @Override + public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) { + + } + + @Override + public boolean removePopulationChangedEventListener(InterfacePopulationChangedEventListener ea) { + return false; + } + + @Override + public void init() { + + } + + @Override + public void initByPopulation(Population pop, boolean reset) { + + } + + @Override + public void optimize() { + + } + + @Override + public Population getPopulation() { + return null; + } + + @Override + public void setPopulation(Population pop) { + + } + + @Override + public InterfaceSolutionSet getAllSolutions() { + return null; + } + + @Override + public void setIdentifier(String name) { + + } + + @Override + public String getIdentifier() { + return null; + } + + @Override + public void setProblem(InterfaceOptimizationProblem problem) { + + } + + @Override + public InterfaceOptimizationProblem getProblem() { + return null; + } + + @Override + public String getStringRepresentation() { + return this.toString(); + } } diff --git a/src/eva2/optimization/strategies/IslandModelEA.java b/src/eva2/optimization/strategies/IslandModelEA.java index 1c1f4bbc..10ef7b34 100644 --- a/src/eva2/optimization/strategies/IslandModelEA.java +++ b/src/eva2/optimization/strategies/IslandModelEA.java @@ -41,7 +41,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I private InterfaceOptimizationProblem m_Problem = new F8Problem(); // private String[] m_NodesList; private int m_MigrationRate = 10; - private boolean m_HeterogenuousProblems = false; + private boolean heterogeneousProblems = false; // These are the processor to run on private int m_numLocalCPUs = 1; private boolean m_localOnly = false; @@ -63,7 +63,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I this.m_Optimizer = (InterfaceOptimizer) a.m_Optimizer.clone(); this.m_Migration = (InterfaceMigration) a.m_Migration.clone(); this.m_MigrationRate = a.m_MigrationRate; - this.m_HeterogenuousProblems = a.m_HeterogenuousProblems; + this.heterogeneousProblems = a.heterogeneousProblems; this.m_numLocalCPUs = a.m_numLocalCPUs; this.m_localOnly = a.m_localOnly; } @@ -239,7 +239,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I this.communicate(); } // this is necessary for heterogeneous islands - if (this.m_HeterogenuousProblems) { + if (this.heterogeneousProblems) { for (int i = 0; i < this.m_Islands.length; i++) { this.m_Islands[i].getProblem().evaluate(this.m_Islands[i].getPopulation()); } @@ -350,8 +350,8 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I result += " Migration Strategy = " + this.m_Migration.getClass().toString() + "\n"; result += " Migration rate = " + this.m_MigrationRate + "\n"; result += " Local only = " + this.m_localOnly + "\n"; - result += " Het. Problems = " + this.m_HeterogenuousProblems + "\n"; - if (this.m_HeterogenuousProblems) { + result += " Het. Problems = " + this.heterogeneousProblems + "\n"; + if (this.heterogeneousProblems) { result += " Heterogenuous Optimizers: \n"; for (int i = 0; i < this.m_Islands.length; i++) { result += this.m_Islands[i].getStringRepresentation() + "\n"; @@ -440,14 +440,14 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I } /** - * This method will allow you to toggel between homogenuous and - * heterogenuous problems. In case of heterogenuous problems the individuals + * This method will allow you to toggle between homogeneous and + * heterogeneous problems. In case of heterogeneous problems the individuals * need to be reevaluated after migration. * * @param t */ - public void setHeterogenuousProblems(boolean t) { - this.m_HeterogenuousProblems = t; + public void setHeterogeneousProblems(boolean t) { + this.heterogeneousProblems = t; } /**