Add new Artificial Bee Optimizer
Refactor method name and fix typos. Implement partial cli optimizer selection.
This commit is contained in:
parent
493b96fa68
commit
7a7f8f0d67
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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());
|
||||
|
@ -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());
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user