Improved the OptimizerFactory. However, the optimizer.init() methods have to be called after all settings were applied to the certain optimizer.
This commit is contained in:
parent
fe490f4b22
commit
2db50903f8
@ -1,3 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) ZBiT, University of Tübingen, Germany
|
||||||
|
*/
|
||||||
package javaeva;
|
package javaeva;
|
||||||
|
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
@ -59,37 +62,47 @@ import javaeva.server.modules.GOParameters;
|
|||||||
* while (!terminator.isTerminated(mc.getPopulation())) mc.optimize();
|
* while (!terminator.isTerminated(mc.getPopulation())) mc.optimize();
|
||||||
* </code>
|
* </code>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @author mkron
|
* @author mkron
|
||||||
* @author Andreas Dräger <andreas.draeger@uni-tuebingen.de>
|
* @author Andreas Dräger <andreas.draeger@uni-tuebingen.de>
|
||||||
* @date 17.04.2007 Copyright (c) ZBiT, University of Tübingen, Germany
|
* @date 17.04.2007
|
||||||
* Compiler: JDK 1.5.0_10
|
|
||||||
*/
|
*/
|
||||||
public class OptimizerFactory {
|
public class OptimizerFactory {
|
||||||
private static InterfaceTerminator term = null;
|
private static InterfaceTerminator term = null;
|
||||||
|
|
||||||
public final static int STD_ES = 1;
|
public final static int STD_ES = 1;
|
||||||
|
|
||||||
public final static int CMA_ES = 2;
|
public final static int CMA_ES = 2;
|
||||||
|
|
||||||
public final static int STD_GA = 3;
|
public final static int STD_GA = 3;
|
||||||
|
|
||||||
public final static int PSO = 4;
|
public final static int PSO = 4;
|
||||||
|
|
||||||
public final static int DE = 5;
|
public final static int DE = 5;
|
||||||
|
|
||||||
public final static int TRIBES = 6;
|
public final static int TRIBES = 6;
|
||||||
|
|
||||||
public final static int RANDOM = 7;
|
public final static int RANDOM = 7;
|
||||||
|
|
||||||
public final static int HILLCL = 8;
|
public final static int HILLCL = 8;
|
||||||
|
|
||||||
public final static int CBN_ES = 9;
|
public final static int CBN_ES = 9;
|
||||||
|
|
||||||
public final static int CL_HILLCL = 10;
|
public final static int CL_HILLCL = 10;
|
||||||
|
|
||||||
public final static int defaultFitCalls = 10000;
|
public final static int defaultFitCalls = 10000;
|
||||||
|
|
||||||
public final static int randSeed = 0;
|
public final static int randSeed = 0;
|
||||||
|
|
||||||
private static OptimizerRunnable lastRunnable = null;
|
private static OptimizerRunnable lastRunnable = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an InterfaceTerminator to any new optimizer in a boolean combination.
|
* Add an InterfaceTerminator to any new optimizer in a boolean combination.
|
||||||
* The old and the given terminator will be combined as in (TOld && TNew) if
|
* The old and the given terminator will be combined as in (TOld && TNew) if
|
||||||
* bAnd is true, and as in (TOld || TNew) if bAnd is false.
|
* bAnd is true, and as in (TOld || TNew) if bAnd is false.
|
||||||
*
|
*
|
||||||
* @param newTerm
|
* @param newTerm
|
||||||
* a new InterfaceTerminator instance
|
* a new InterfaceTerminator instance
|
||||||
* @param bAnd
|
* @param bAnd
|
||||||
@ -102,7 +115,7 @@ public class OptimizerFactory {
|
|||||||
bAnd));
|
bAnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters cbnES(AbstractOptimizationProblem problem) {
|
public static final GOParameters cbnES(AbstractOptimizationProblem problem) {
|
||||||
ClusterBasedNichingEA cbn = new ClusterBasedNichingEA();
|
ClusterBasedNichingEA cbn = new ClusterBasedNichingEA();
|
||||||
EvolutionStrategies es = new EvolutionStrategies();
|
EvolutionStrategies es = new EvolutionStrategies();
|
||||||
es.setMu(15);
|
es.setMu(15);
|
||||||
@ -112,7 +125,7 @@ public class OptimizerFactory {
|
|||||||
ClusteringDensityBased clustering = new ClusteringDensityBased(0.1);
|
ClusteringDensityBased clustering = new ClusteringDensityBased(0.1);
|
||||||
cbn.setConvergenceCA((ClusteringDensityBased) clustering.clone());
|
cbn.setConvergenceCA((ClusteringDensityBased) clustering.clone());
|
||||||
cbn.setDifferentationCA(clustering);
|
cbn.setDifferentationCA(clustering);
|
||||||
cbn.setShowCycle(0); // dont do graphical output
|
cbn.setShowCycle(0); // don't do graphical output
|
||||||
|
|
||||||
Population pop = new Population();
|
Population pop = new Population();
|
||||||
pop.setPopulationSize(100);
|
pop.setPopulationSize(100);
|
||||||
@ -121,7 +134,7 @@ public class OptimizerFactory {
|
|||||||
return makeParams(cbn, pop, problem, randSeed, defaultTerminator());
|
return makeParams(cbn, pop, problem, randSeed, defaultTerminator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters clusteringHillClimbing(
|
public static final GOParameters clusteringHillClimbing(
|
||||||
AbstractOptimizationProblem problem) {
|
AbstractOptimizationProblem problem) {
|
||||||
ClusteringHillClimbing chc = new ClusteringHillClimbing();
|
ClusteringHillClimbing chc = new ClusteringHillClimbing();
|
||||||
chc.SetProblem(problem);
|
chc.SetProblem(problem);
|
||||||
@ -138,35 +151,37 @@ public class OptimizerFactory {
|
|||||||
return makeParams(chc, pop, problem, randSeed, defaultTerminator());
|
return makeParams(chc, pop, problem, randSeed, defaultTerminator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters cmaES(AbstractOptimizationProblem problem) {
|
public static final GOParameters cmaES(AbstractOptimizationProblem problem) {
|
||||||
EvolutionStrategies es = new EvolutionStrategies();
|
EvolutionStrategies es = new EvolutionStrategies();
|
||||||
es.setMu(15);
|
es.setMu(15);
|
||||||
es.setLambda(50);
|
es.setLambda(50);
|
||||||
es.setPlusStrategy(false);
|
es.setPlusStrategy(false);
|
||||||
|
|
||||||
// TODO improve this by adding getEAIndividual to AbstractEAIndividual?
|
// TODO improve this by adding getEAIndividual to AbstractEAIndividual?
|
||||||
AbstractEAIndividual indyTemplate = problem.getIndividualTemplate();
|
AbstractEAIndividual indyTemplate = problem.getIndividualTemplate();
|
||||||
if ((indyTemplate != null) && (indyTemplate instanceof InterfaceESIndividual)) {
|
if ((indyTemplate != null)
|
||||||
|
&& (indyTemplate instanceof InterfaceESIndividual)) {
|
||||||
// Set CMA operator for mutation
|
// Set CMA operator for mutation
|
||||||
AbstractEAIndividual indy = (AbstractEAIndividual)indyTemplate;
|
AbstractEAIndividual indy = (AbstractEAIndividual) indyTemplate;
|
||||||
MutateESCovarianceMartixAdaption cmaMut = new MutateESCovarianceMartixAdaption();
|
MutateESCovarianceMartixAdaption cmaMut = new MutateESCovarianceMartixAdaption();
|
||||||
cmaMut.setCheckConstraints(true);
|
cmaMut.setCheckConstraints(true);
|
||||||
indy.setMutationOperator(cmaMut);
|
indy.setMutationOperator(cmaMut);
|
||||||
indy.setCrossoverOperator(new CrossoverESDefault());
|
indy.setCrossoverOperator(new CrossoverESDefault());
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Error, CMA-ES is implemented for ES individuals only (requires double data types)");
|
System.err
|
||||||
|
.println("Error, CMA-ES is implemented for ES individuals only (requires double data types)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Population pop = new Population();
|
Population pop = new Population();
|
||||||
pop.setPopulationSize(es.getLambda());
|
pop.setPopulationSize(es.getLambda());
|
||||||
|
|
||||||
return makeParams(es, pop, problem, randSeed, defaultTerminator());
|
return makeParams(es, pop, problem, randSeed, defaultTerminator());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method optimizes the given problem using differential evolution.
|
* This method optimizes the given problem using differential evolution.
|
||||||
*
|
*
|
||||||
* @param problem
|
* @param problem
|
||||||
* @param popsize
|
* @param popsize
|
||||||
* @param f
|
* @param f
|
||||||
@ -204,7 +219,7 @@ public class OptimizerFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method performs the optimization using an Evolution strategy.
|
* This method performs the optimization using an Evolution strategy.
|
||||||
*
|
*
|
||||||
* @param mu
|
* @param mu
|
||||||
* @param lambda
|
* @param lambda
|
||||||
* @param plus
|
* @param plus
|
||||||
@ -248,7 +263,7 @@ public class OptimizerFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method performs a Genetic Algorithm.
|
* This method performs a Genetic Algorithm.
|
||||||
*
|
*
|
||||||
* @param mut
|
* @param mut
|
||||||
* @param pm
|
* @param pm
|
||||||
* @param cross
|
* @param cross
|
||||||
@ -288,7 +303,7 @@ public class OptimizerFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This starts a Gradient Descent.
|
* This starts a Gradient Descent.
|
||||||
*
|
*
|
||||||
* @param problem
|
* @param problem
|
||||||
* @return An optimization algorithm that performs gradient descent.
|
* @return An optimization algorithm that performs gradient descent.
|
||||||
*/
|
*/
|
||||||
@ -312,7 +327,7 @@ public class OptimizerFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method performs a Hill Climber algorithm.
|
* This method performs a Hill Climber algorithm.
|
||||||
*
|
*
|
||||||
* @param pop
|
* @param pop
|
||||||
* The size of the population
|
* The size of the population
|
||||||
* @param problem
|
* @param problem
|
||||||
@ -335,7 +350,6 @@ public class OptimizerFactory {
|
|||||||
tmpIndi.setCrossoverProbability(0);
|
tmpIndi.setCrossoverProbability(0);
|
||||||
|
|
||||||
HillClimbing hc = new HillClimbing();
|
HillClimbing hc = new HillClimbing();
|
||||||
// System.out.println(hc.getStringRepresentation());
|
|
||||||
hc.getPopulation().setPopulationSize(pop);
|
hc.getPopulation().setPopulationSize(pop);
|
||||||
hc.addPopulationChangedEventListener(listener);
|
hc.addPopulationChangedEventListener(listener);
|
||||||
hc.SetProblem(problem);
|
hc.SetProblem(problem);
|
||||||
@ -349,7 +363,7 @@ public class OptimizerFactory {
|
|||||||
/**
|
/**
|
||||||
* This method performs a Monte Carlo Search with the given number of
|
* This method performs a Monte Carlo Search with the given number of
|
||||||
* fitnesscalls.
|
* fitnesscalls.
|
||||||
*
|
*
|
||||||
* @param problem
|
* @param problem
|
||||||
* @param listener
|
* @param listener
|
||||||
* @return An optimization procedure that performes the random walk.
|
* @return An optimization procedure that performes the random walk.
|
||||||
@ -377,7 +391,7 @@ public class OptimizerFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method performs a particle swarm optimization.
|
* This method performs a particle swarm optimization.
|
||||||
*
|
*
|
||||||
* @param problem
|
* @param problem
|
||||||
* @param mut
|
* @param mut
|
||||||
* @param popsize
|
* @param popsize
|
||||||
@ -421,7 +435,7 @@ public class OptimizerFactory {
|
|||||||
* This method performs a Simulated Annealing Optimization and prints the
|
* This method performs a Simulated Annealing Optimization and prints the
|
||||||
* result as R output. It uses real valued individuals. The mutation
|
* result as R output. It uses real valued individuals. The mutation
|
||||||
* probability is always 1.0.
|
* probability is always 1.0.
|
||||||
*
|
*
|
||||||
* @param problem
|
* @param problem
|
||||||
* @param popsize
|
* @param popsize
|
||||||
* @param alpha
|
* @param alpha
|
||||||
@ -467,35 +481,36 @@ public class OptimizerFactory {
|
|||||||
/**
|
/**
|
||||||
* The default Terminator finishes after n fitness calls, the default n is
|
* The default Terminator finishes after n fitness calls, the default n is
|
||||||
* returned here.
|
* returned here.
|
||||||
*
|
*
|
||||||
* @return the default number of fitness call done before termination
|
* @return the default number of fitness call done before termination
|
||||||
*/
|
*/
|
||||||
public static int getDefaultFitCalls() {
|
public static final int getDefaultFitCalls() {
|
||||||
return defaultFitCalls;
|
return defaultFitCalls;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////// constructing a default OptimizerRunnable
|
|
||||||
|
|
||||||
public static GOParameters getParams(final int optType, AbstractOptimizationProblem problem) {
|
// /////////////////////////// constructing a default OptimizerRunnable
|
||||||
|
|
||||||
|
public static GOParameters getParams(final int optType,
|
||||||
|
AbstractOptimizationProblem problem) {
|
||||||
switch (optType) {
|
switch (optType) {
|
||||||
case STD_ES:
|
case STD_ES:
|
||||||
return standardES(problem);
|
return standardES(problem);
|
||||||
case CMA_ES:
|
case CMA_ES:
|
||||||
return cmaES(problem);
|
return cmaES(problem);
|
||||||
case STD_GA:
|
case STD_GA:
|
||||||
return standardGA(problem);
|
return standardGA(problem);
|
||||||
case PSO:
|
case PSO:
|
||||||
return standardPSO(problem);
|
return standardPSO(problem);
|
||||||
case DE:
|
case DE:
|
||||||
return standardDE(problem);
|
return standardDE(problem);
|
||||||
case TRIBES:
|
case TRIBES:
|
||||||
return tribes(problem);
|
return tribes(problem);
|
||||||
case RANDOM:
|
case RANDOM:
|
||||||
return monteCarlo(problem);
|
return monteCarlo(problem);
|
||||||
case HILLCL:
|
case HILLCL:
|
||||||
return hillClimbing(problem);
|
return hillClimbing(problem);
|
||||||
case CBN_ES:
|
case CBN_ES:
|
||||||
return cbnES(problem);
|
return cbnES(problem);
|
||||||
case CL_HILLCL:
|
case CL_HILLCL:
|
||||||
return clusteringHillClimbing(problem);
|
return clusteringHillClimbing(problem);
|
||||||
default:
|
default:
|
||||||
@ -503,13 +518,15 @@ public class OptimizerFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OptimizerRunnable getOptRunnable(final int optType, AbstractOptimizationProblem problem, int fitCalls, String outputFilePrefix) {
|
public static OptimizerRunnable getOptRunnable(final int optType,
|
||||||
|
AbstractOptimizationProblem problem, int fitCalls, String outputFilePrefix) {
|
||||||
OptimizerRunnable opt = null;
|
OptimizerRunnable opt = null;
|
||||||
GOParameters params = getParams(optType, problem);
|
GOParameters params = getParams(optType, problem);
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
opt = new OptimizerRunnable(params, outputFilePrefix);
|
opt = new OptimizerRunnable(params, outputFilePrefix);
|
||||||
if (fitCalls != defaultFitCalls) opt.getGOParams().setTerminator(new EvaluationTerminator(fitCalls));
|
if (fitCalls != defaultFitCalls)
|
||||||
|
opt.getGOParams().setTerminator(new EvaluationTerminator(fitCalls));
|
||||||
}
|
}
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
@ -524,7 +541,8 @@ public class OptimizerFactory {
|
|||||||
return OptimizerFactory.term;
|
return OptimizerFactory.term;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters hillClimbing(AbstractOptimizationProblem problem) {
|
public static final GOParameters hillClimbing(
|
||||||
|
AbstractOptimizationProblem problem) {
|
||||||
HillClimbing hc = new HillClimbing();
|
HillClimbing hc = new HillClimbing();
|
||||||
hc.SetProblem(problem);
|
hc.SetProblem(problem);
|
||||||
Population pop = new Population();
|
Population pop = new Population();
|
||||||
@ -534,9 +552,7 @@ public class OptimizerFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int lastEvalsPerformed() {
|
public static int lastEvalsPerformed() {
|
||||||
if (lastRunnable != null)
|
return (lastRunnable != null) ? lastRunnable.getProgress() : -1;
|
||||||
return lastRunnable.getProgress();
|
|
||||||
else return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// /////////////////////// Creating default strategies
|
// /////////////////////// Creating default strategies
|
||||||
@ -552,7 +568,8 @@ public class OptimizerFactory {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters monteCarlo(AbstractOptimizationProblem problem) {
|
public static final GOParameters monteCarlo(
|
||||||
|
AbstractOptimizationProblem problem) {
|
||||||
MonteCarloSearch mc = new MonteCarloSearch();
|
MonteCarloSearch mc = new MonteCarloSearch();
|
||||||
Population pop = new Population();
|
Population pop = new Population();
|
||||||
pop.setPopulationSize(50);
|
pop.setPopulationSize(50);
|
||||||
@ -567,11 +584,10 @@ public class OptimizerFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static OptimizerRunnable optimize(OptimizerRunnable runnable) {
|
public static OptimizerRunnable optimize(OptimizerRunnable runnable) {
|
||||||
if (runnable != null) {
|
if (runnable == null) return null;
|
||||||
new Thread(runnable).run();
|
new Thread(runnable).run();
|
||||||
lastRunnable = runnable;
|
lastRunnable = runnable;
|
||||||
return runnable;
|
return runnable;
|
||||||
} else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -579,7 +595,7 @@ public class OptimizerFactory {
|
|||||||
* thread. The Runnable will notify waiting threads and set the isFinished
|
* thread. The Runnable will notify waiting threads and set the isFinished
|
||||||
* flag when the optimization is complete. If the optType is invalid, null
|
* flag when the optimization is complete. If the optType is invalid, null
|
||||||
* will be returned.
|
* will be returned.
|
||||||
*
|
*
|
||||||
* @param optType
|
* @param optType
|
||||||
* @param problem
|
* @param problem
|
||||||
* @param outputFilePrefix
|
* @param outputFilePrefix
|
||||||
@ -605,17 +621,13 @@ public class OptimizerFactory {
|
|||||||
public static BitSet optimizeToBinary(final int optType,
|
public static BitSet optimizeToBinary(final int optType,
|
||||||
AbstractOptimizationProblem problem, String outputFilePrefix) {
|
AbstractOptimizationProblem problem, String outputFilePrefix) {
|
||||||
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
|
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
|
||||||
if (runnable != null)
|
return (runnable != null) ? runnable.getBinarySolution() : null;
|
||||||
return runnable.getBinarySolution();
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ///////////////////////////// Optimize a given runnable
|
// ///////////////////////////// Optimize a given runnable
|
||||||
public static BitSet optimizeToBinary(OptimizerRunnable runnable) {
|
public static BitSet optimizeToBinary(OptimizerRunnable runnable) {
|
||||||
optimize(runnable);
|
optimize(runnable);
|
||||||
if (runnable != null)
|
return (runnable != null) ? runnable.getBinarySolution() : null;
|
||||||
return runnable.getBinarySolution();
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double[] optimizeToDouble(GOParameters params,
|
public static double[] optimizeToDouble(GOParameters params,
|
||||||
@ -628,16 +640,12 @@ public class OptimizerFactory {
|
|||||||
public static double[] optimizeToDouble(final int optType,
|
public static double[] optimizeToDouble(final int optType,
|
||||||
AbstractOptimizationProblem problem, String outputFilePrefix) {
|
AbstractOptimizationProblem problem, String outputFilePrefix) {
|
||||||
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
|
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
|
||||||
if (runnable != null)
|
return (runnable != null) ? runnable.getDoubleSolution() : null;
|
||||||
return runnable.getDoubleSolution();
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double[] optimizeToDouble(OptimizerRunnable runnable) {
|
public static double[] optimizeToDouble(OptimizerRunnable runnable) {
|
||||||
optimize(runnable);
|
optimize(runnable);
|
||||||
if (runnable != null)
|
return (runnable != null) ? runnable.getDoubleSolution() : null;
|
||||||
return runnable.getDoubleSolution();
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IndividualInterface optimizeToInd(GOParameters params,
|
public static IndividualInterface optimizeToInd(GOParameters params,
|
||||||
@ -650,16 +658,12 @@ public class OptimizerFactory {
|
|||||||
public static IndividualInterface optimizeToInd(final int optType,
|
public static IndividualInterface optimizeToInd(final int optType,
|
||||||
AbstractOptimizationProblem problem, String outputFilePrefix) {
|
AbstractOptimizationProblem problem, String outputFilePrefix) {
|
||||||
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
|
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
|
||||||
if (runnable != null)
|
return (runnable != null) ? runnable.getResult() : null;
|
||||||
return runnable.getResult();
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IndividualInterface optimizeToInd(OptimizerRunnable runnable) {
|
public static IndividualInterface optimizeToInd(OptimizerRunnable runnable) {
|
||||||
optimize(runnable);
|
optimize(runnable);
|
||||||
if (runnable != null)
|
return (runnable != null) ? runnable.getResult() : null;
|
||||||
return runnable.getResult();
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Population optimizeToPop(GOParameters params,
|
public static Population optimizeToPop(GOParameters params,
|
||||||
@ -672,16 +676,12 @@ public class OptimizerFactory {
|
|||||||
public static Population optimizeToPop(final int optType,
|
public static Population optimizeToPop(final int optType,
|
||||||
AbstractOptimizationProblem problem, String outputFilePrefix) {
|
AbstractOptimizationProblem problem, String outputFilePrefix) {
|
||||||
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
|
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
|
||||||
if (runnable != null)
|
return (runnable != null) ? runnable.getSolutionSet() : null;
|
||||||
return runnable.getSolutionSet();
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Population optimizeToPop(OptimizerRunnable runnable) {
|
public static Population optimizeToPop(OptimizerRunnable runnable) {
|
||||||
optimize(runnable);
|
optimize(runnable);
|
||||||
if (runnable != null)
|
return (runnable != null) ? runnable.getSolutionSet() : null;
|
||||||
return runnable.getSolutionSet();
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Population postProcess(int steps, double sigma, int nBest) {
|
public static Population postProcess(int steps, double sigma, int nBest) {
|
||||||
@ -746,9 +746,7 @@ public class OptimizerFactory {
|
|||||||
|
|
||||||
public static Vector<double[]> postProcessDblVec(
|
public static Vector<double[]> postProcessDblVec(
|
||||||
InterfacePostProcessParams ppp) {
|
InterfacePostProcessParams ppp) {
|
||||||
if (lastRunnable != null)
|
return (lastRunnable != null) ? postProcessDblVec(lastRunnable, ppp) : null;
|
||||||
return postProcessDblVec(lastRunnable, ppp);
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector<double[]> postProcessDblVec(OptimizerRunnable runnable,
|
public static Vector<double[]> postProcessDblVec(OptimizerRunnable runnable,
|
||||||
@ -817,7 +815,7 @@ public class OptimizerFactory {
|
|||||||
/**
|
/**
|
||||||
* Return a simple String showing the accessible optimizers. For external
|
* Return a simple String showing the accessible optimizers. For external
|
||||||
* access."
|
* access."
|
||||||
*
|
*
|
||||||
* @return a String listing the accessible optimizers
|
* @return a String listing the accessible optimizers
|
||||||
*/
|
*/
|
||||||
public static String showOptimizers() {
|
public static String showOptimizers() {
|
||||||
@ -825,7 +823,8 @@ public class OptimizerFactory {
|
|||||||
+ "\n8: Hill-Climbing \n9: Cluster-based niching ES \n10: Clustering Hill-Climbing";
|
+ "\n8: Hill-Climbing \n9: Cluster-based niching ES \n10: Clustering Hill-Climbing";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters standardDE(AbstractOptimizationProblem problem) {
|
public static final GOParameters standardDE(
|
||||||
|
AbstractOptimizationProblem problem) {
|
||||||
DifferentialEvolution de = new DifferentialEvolution();
|
DifferentialEvolution de = new DifferentialEvolution();
|
||||||
Population pop = new Population();
|
Population pop = new Population();
|
||||||
pop.setPopulationSize(50);
|
pop.setPopulationSize(50);
|
||||||
@ -839,7 +838,8 @@ public class OptimizerFactory {
|
|||||||
return makeParams(de, pop, problem, randSeed, defaultTerminator());
|
return makeParams(de, pop, problem, randSeed, defaultTerminator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters standardES(AbstractOptimizationProblem problem) {
|
public static final GOParameters standardES(
|
||||||
|
AbstractOptimizationProblem problem) {
|
||||||
EvolutionStrategies es = new EvolutionStrategies();
|
EvolutionStrategies es = new EvolutionStrategies();
|
||||||
es.setMu(15);
|
es.setMu(15);
|
||||||
es.setLambda(50);
|
es.setLambda(50);
|
||||||
@ -863,7 +863,8 @@ public class OptimizerFactory {
|
|||||||
return makeParams(es, pop, problem, randSeed, defaultTerminator());
|
return makeParams(es, pop, problem, randSeed, defaultTerminator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters standardGA(AbstractOptimizationProblem problem) {
|
public static final GOParameters standardGA(
|
||||||
|
AbstractOptimizationProblem problem) {
|
||||||
GeneticAlgorithm ga = new GeneticAlgorithm();
|
GeneticAlgorithm ga = new GeneticAlgorithm();
|
||||||
Population pop = new Population();
|
Population pop = new Population();
|
||||||
pop.setPopulationSize(100);
|
pop.setPopulationSize(100);
|
||||||
@ -873,7 +874,8 @@ public class OptimizerFactory {
|
|||||||
return makeParams(ga, pop, problem, randSeed, defaultTerminator());
|
return makeParams(ga, pop, problem, randSeed, defaultTerminator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters standardPSO(AbstractOptimizationProblem problem) {
|
public static final GOParameters standardPSO(
|
||||||
|
AbstractOptimizationProblem problem) {
|
||||||
ParticleSwarmOptimization pso = new ParticleSwarmOptimization();
|
ParticleSwarmOptimization pso = new ParticleSwarmOptimization();
|
||||||
Population pop = new Population();
|
Population pop = new Population();
|
||||||
pop.setPopulationSize(30);
|
pop.setPopulationSize(30);
|
||||||
@ -884,12 +886,10 @@ public class OptimizerFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String terminatedBecause() {
|
public static String terminatedBecause() {
|
||||||
if (lastRunnable != null)
|
return (lastRunnable != null) ? lastRunnable.terminatedBecause() : null;
|
||||||
return lastRunnable.terminatedBecause();
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GOParameters tribes(AbstractOptimizationProblem problem) {
|
public static final GOParameters tribes(AbstractOptimizationProblem problem) {
|
||||||
Tribes tr = new Tribes();
|
Tribes tr = new Tribes();
|
||||||
Population pop = new Population();
|
Population pop = new Population();
|
||||||
pop.setPopulationSize(1); // only for init
|
pop.setPopulationSize(1); // only for init
|
||||||
|
Loading…
x
Reference in New Issue
Block a user