Renamed eval function to evaluate.
Implemented more of CLI core.
This commit is contained in:
parent
30381f4c04
commit
321796d2c4
@ -788,7 +788,6 @@ public class OptimizerFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
runnable.run();
|
runnable.run();
|
||||||
new Thread(runnable).start();
|
|
||||||
lastRunnable = runnable;
|
lastRunnable = runnable;
|
||||||
return runnable;
|
return runnable;
|
||||||
}
|
}
|
||||||
@ -872,8 +871,7 @@ public class OptimizerFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double[] optimizeToDouble(OptimizationParameters params) {
|
public static double[] optimizeToDouble(OptimizationParameters params) {
|
||||||
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params,
|
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params, false));
|
||||||
false));
|
|
||||||
return runnable.getDoubleSolution();
|
return runnable.getDoubleSolution();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,15 +881,13 @@ public class OptimizerFactory {
|
|||||||
return runnable.getDoubleSolution();
|
return runnable.getDoubleSolution();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double[] optimizeToDouble(final int optType,
|
public static double[] optimizeToDouble(final int optType, AbstractOptimizationProblem problem) {
|
||||||
AbstractOptimizationProblem problem) {
|
|
||||||
return optimizeToDouble(optType, problem, null);
|
return optimizeToDouble(optType, problem, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
|
||||||
outputFilePrefix);
|
|
||||||
return (runnable != null) ? runnable.getDoubleSolution() : null;
|
return (runnable != null) ? runnable.getDoubleSolution() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -901,13 +897,11 @@ public class OptimizerFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IndividualInterface optimizeToInd(OptimizationParameters params) {
|
public static IndividualInterface optimizeToInd(OptimizationParameters params) {
|
||||||
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params,
|
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params, false));
|
||||||
false));
|
|
||||||
return runnable.getResult();
|
return runnable.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IndividualInterface optimizeToInd(OptimizationParameters params,
|
public static IndividualInterface optimizeToInd(OptimizationParameters params, String outputFilePrefix) {
|
||||||
String outputFilePrefix) {
|
|
||||||
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params,
|
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params,
|
||||||
outputFilePrefix));
|
outputFilePrefix));
|
||||||
return runnable.getResult();
|
return runnable.getResult();
|
||||||
|
@ -254,7 +254,6 @@ public class OptimizerRunnable implements Runnable {
|
|||||||
* Set the verbosity level in the statistics module to the given value.
|
* Set the verbosity level in the statistics module to the given value.
|
||||||
*
|
*
|
||||||
* @param vLev
|
* @param vLev
|
||||||
* @see StatsParameter
|
|
||||||
*/
|
*/
|
||||||
public void setVerbosityLevel(int vLev) {
|
public void setVerbosityLevel(int vLev) {
|
||||||
if (vLev >= 0 && vLev < proc.getStatistics().getStatisticsParameter().getOutputVerbosity().getTags().length) {
|
if (vLev >= 0 && vLev < proc.getStatistics().getStatisticsParameter().getOutputVerbosity().getTags().length) {
|
||||||
@ -268,7 +267,6 @@ public class OptimizerRunnable implements Runnable {
|
|||||||
* Set the output direction in the statistics module.
|
* Set the output direction in the statistics module.
|
||||||
*
|
*
|
||||||
* @param outp
|
* @param outp
|
||||||
* @see StatsParameter
|
|
||||||
*/
|
*/
|
||||||
public void setOutputTo(int outp) {
|
public void setOutputTo(int outp) {
|
||||||
((StatisticsParameter) proc.getStatistics().getStatisticsParameter()).setOutputTo(outp);
|
((StatisticsParameter) proc.getStatistics().getStatisticsParameter()).setOutputTo(outp);
|
||||||
@ -287,7 +285,6 @@ public class OptimizerRunnable implements Runnable {
|
|||||||
* Indicate whether full stats should be printed as text (or only selected entries).
|
* Indicate whether full stats should be printed as text (or only selected entries).
|
||||||
*
|
*
|
||||||
* @param addInfo
|
* @param addInfo
|
||||||
* @see StatsParameter
|
|
||||||
*/
|
*/
|
||||||
public void setOutputFullStatsToText(boolean addInfo) {
|
public void setOutputFullStatsToText(boolean addInfo) {
|
||||||
((AbstractStatistics) proc.getStatistics()).getStatisticsParameter().setOutputAllFieldsAsText(addInfo);
|
((AbstractStatistics) proc.getStatistics()).getStatisticsParameter().setOutputAllFieldsAsText(addInfo);
|
||||||
|
@ -10,6 +10,8 @@ import eva2.optimization.operator.terminators.EvaluationTerminator;
|
|||||||
import eva2.optimization.operator.terminators.FitnessValueTerminator;
|
import eva2.optimization.operator.terminators.FitnessValueTerminator;
|
||||||
import eva2.optimization.population.Population;
|
import eva2.optimization.population.Population;
|
||||||
import eva2.optimization.problems.AbstractOptimizationProblem;
|
import eva2.optimization.problems.AbstractOptimizationProblem;
|
||||||
|
import eva2.optimization.problems.AbstractProblemDouble;
|
||||||
|
import eva2.optimization.problems.AbstractProblemDoubleOffset;
|
||||||
import eva2.optimization.strategies.DifferentialEvolution;
|
import eva2.optimization.strategies.DifferentialEvolution;
|
||||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
@ -181,6 +183,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
|||||||
|
|
||||||
this.jsonObject = new JsonObject();
|
this.jsonObject = new JsonObject();
|
||||||
this.optimizationRuns = new JsonArray();
|
this.optimizationRuns = new JsonArray();
|
||||||
|
this.generationsArray = new JsonArray();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default command line options only require help or optimizer.
|
* Default command line options only require help or optimizer.
|
||||||
@ -253,7 +256,6 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
|||||||
problemObject.addProperty("name", this.problem.getName());
|
problemObject.addProperty("name", this.problem.getName());
|
||||||
problemObject.addProperty("dimension", 30);
|
problemObject.addProperty("dimension", 30);
|
||||||
this.jsonObject.add("problem", problemObject);
|
this.jsonObject.add("problem", problemObject);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -312,6 +314,14 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
|||||||
System.out.println("Genetic Algorithm");
|
System.out.println("Genetic Algorithm");
|
||||||
break;
|
break;
|
||||||
case "ParticleSwarmOptimization":
|
case "ParticleSwarmOptimization":
|
||||||
|
opt.addOption("initialVelocity", true, "Initial Velocity");
|
||||||
|
opt.addOption("speedLimit", true, "Speed Limit");
|
||||||
|
opt.addOption("topology", true, "Particle Swarm Topology (0-7)");
|
||||||
|
opt.addOption("swarmRadius", true, "Radius of the Swarm");
|
||||||
|
opt.addOption("phi1", true, "Phi 1");
|
||||||
|
opt.addOption("phi2", true, "Phi 2");
|
||||||
|
opt.addOption("inertnessOrChi", true, "Inertness or Chi");
|
||||||
|
opt.addOption("algType", true, "Type of PSO");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -322,7 +332,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
|||||||
private void setProblemFromName(String problemName) {
|
private void setProblemFromName(String problemName) {
|
||||||
Map<String, Class<? extends AbstractOptimizationProblem>> problemList = createProblemList();
|
Map<String, Class<? extends AbstractOptimizationProblem>> problemList = createProblemList();
|
||||||
|
|
||||||
Class<? extends AbstractOptimizationProblem> problem = problemList.get(problemName);
|
Class<? extends AbstractProblemDoubleOffset> problem = problemList.get(problemName);
|
||||||
try {
|
try {
|
||||||
this.problem = problem.newInstance();
|
this.problem = problem.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
@ -334,32 +344,31 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
|||||||
|
|
||||||
private void runOptimization() {
|
private void runOptimization() {
|
||||||
for(int i = 0; i < this.numberOfRuns; i++) {
|
for(int i = 0; i < this.numberOfRuns; i++) {
|
||||||
|
|
||||||
this.generationsArray = new JsonArray();
|
|
||||||
// Terminate after 10000 function evaluations OR after reaching a fitness < 0.1
|
// Terminate after 10000 function evaluations OR after reaching a fitness < 0.1
|
||||||
OptimizerFactory.setEvaluationTerminator(50000);
|
OptimizerFactory.setEvaluationTerminator(50000);
|
||||||
OptimizerFactory.addTerminator(new FitnessValueTerminator(new double[]{0.01}), CombinedTerminator.OR);
|
OptimizerFactory.addTerminator(new FitnessValueTerminator(new double[]{0.00001}), CombinedTerminator.OR);
|
||||||
|
|
||||||
LOGGER.log(Level.INFO, "Running {0}", "Differential Evolution");
|
LOGGER.log(Level.INFO, "Running {0}", "Differential Evolution");
|
||||||
|
|
||||||
OptimizationParameters params = OptimizerFactory.makeParams(optimizer, this.populationSize, this.problem);
|
OptimizationParameters params = OptimizerFactory.makeParams(optimizer, this.populationSize, this.problem);
|
||||||
double[] result = OptimizerFactory.optimizeToDouble(params);
|
double[] result = OptimizerFactory.optimizeToDouble(params);
|
||||||
|
|
||||||
// This is stupid - why isn't there a way to wait for the optimization to finish?
|
|
||||||
while(OptimizerFactory.terminatedBecause().equals("Not yet terminated")) {
|
|
||||||
// wait
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonObject optimizationDetails = new JsonObject();
|
JsonObject optimizationDetails = new JsonObject();
|
||||||
optimizationDetails.addProperty("total_time", 1.0);
|
optimizationDetails.addProperty("total_time", 1.0);
|
||||||
optimizationDetails.addProperty("total_function_calls", optimizer.getPopulation().getFunctionCalls());
|
optimizationDetails.addProperty("total_function_calls", optimizer.getPopulation().getFunctionCalls());
|
||||||
optimizationDetails.addProperty("termination_criteria", OptimizerFactory.terminatedBecause());
|
optimizationDetails.addProperty("termination_criteria", OptimizerFactory.terminatedBecause());
|
||||||
optimizationDetails.add("generations", this.generationsArray);
|
optimizationDetails.add("generations", this.generationsArray);
|
||||||
|
|
||||||
|
JsonArray solutionArray = new JsonArray();
|
||||||
|
for(double val : result) {
|
||||||
|
solutionArray.add(new JsonPrimitive(val));
|
||||||
|
}
|
||||||
|
optimizationDetails.add("solution", solutionArray);
|
||||||
|
|
||||||
this.optimizationRuns.add(optimizationDetails);
|
this.optimizationRuns.add(optimizationDetails);
|
||||||
|
|
||||||
System.out.println(OptimizerFactory.terminatedBecause());
|
// Needs to be re-created here.
|
||||||
System.out.println(optimizer.getPopulation().getFunctionCalls());
|
this.generationsArray = new JsonArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.jsonObject.add("runs", this.optimizationRuns);
|
this.jsonObject.add("runs", this.optimizationRuns);
|
||||||
@ -407,8 +416,8 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
|
|||||||
meanFitness.add(new JsonPrimitive(val));
|
meanFitness.add(new JsonPrimitive(val));
|
||||||
}
|
}
|
||||||
newGeneration.add("mean_fitness", meanFitness);
|
newGeneration.add("mean_fitness", meanFitness);
|
||||||
System.out.println(newGeneration.toString());
|
//System.out.println(newGeneration.toString());
|
||||||
//this.generationsArray.add(newGeneration);
|
this.generationsArray.add(newGeneration);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
|
|||||||
public static void test(String constr, double[] pos) {
|
public static void test(String constr, double[] pos) {
|
||||||
AbstractGPNode node = AbstractGPNode.parseFromString(constr);
|
AbstractGPNode node = AbstractGPNode.parseFromString(constr);
|
||||||
GPFunctionProblem func = new GPFunctionProblem(node, null, pos.length, 0., 0.);
|
GPFunctionProblem func = new GPFunctionProblem(node, null, pos.length, 0., 0.);
|
||||||
double[] ret = func.eval(pos);
|
double[] ret = func.evaluate(pos);
|
||||||
System.out.println("testing " + constr + " evaluated to " + BeanInspector.toString(ret));
|
System.out.println("testing " + constr + " evaluated to " + BeanInspector.toString(ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class GenericConstraint extends AbstractConstraint implements InterfaceDo
|
|||||||
if (func == null) {
|
if (func == null) {
|
||||||
func = new GPFunctionProblem(constraintProgram, null, indyX.length, 0., 0.);
|
func = new GPFunctionProblem(constraintProgram, null, indyX.length, 0., 0.);
|
||||||
}
|
}
|
||||||
return func.eval(indyX)[0];
|
return func.evaluate(indyX)[0];
|
||||||
} else {
|
} else {
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
result[0] = this.globalOptimum - evalUnnormalized(x)[0];
|
result[0] = this.globalOptimum - evalUnnormalized(x)[0];
|
||||||
|
@ -26,7 +26,7 @@ import eva2.tools.math.RNG;
|
|||||||
/**
|
/**
|
||||||
* For a double valued problem, there are two main methods to implement:
|
* For a double valued problem, there are two main methods to implement:
|
||||||
* {@link #getProblemDimension()} must return the problem dimension, while
|
* {@link #getProblemDimension()} must return the problem dimension, while
|
||||||
* {@link #eval(double[])} is to evaluate a single double vector into the result
|
* {@link #evaluate(double[])} is to evaluate a single double vector into the result
|
||||||
* fitness vector.
|
* fitness vector.
|
||||||
* <p/>
|
* <p/>
|
||||||
* To define the problem range, you may use the default range parameter
|
* To define the problem range, you may use the default range parameter
|
||||||
@ -77,10 +77,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
}
|
}
|
||||||
if (getProblemDimension() > 0) { // avoid evil case setting dim to 0
|
if (getProblemDimension() > 0) { // avoid evil case setting dim to 0
|
||||||
// during object init
|
// during object init
|
||||||
((InterfaceDataTypeDouble) this.template)
|
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(getProblemDimension());
|
||||||
.setDoubleDataLength(getProblemDimension());
|
((InterfaceDataTypeDouble) this.template).setDoubleRange(makeRange());
|
||||||
((InterfaceDataTypeDouble) this.template)
|
|
||||||
.setDoubleRange(makeRange());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,9 +124,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
/**
|
/**
|
||||||
* When implementing a double problem, inheriting classes should not
|
* When implementing a double problem, inheriting classes should not
|
||||||
* override this method (or only extend it) and do the fitness calculations
|
* override this method (or only extend it) and do the fitness calculations
|
||||||
* in the method eval(double[]).
|
* in the method evaluate(double[]).
|
||||||
*
|
*
|
||||||
* @see eval(double[] x)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(AbstractEAIndividual individual) {
|
public void evaluate(AbstractEAIndividual individual) {
|
||||||
@ -138,7 +135,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
x = getEvalArray(individual);
|
x = getEvalArray(individual);
|
||||||
((InterfaceDataTypeDouble) individual).setDoublePhenotype(x);
|
((InterfaceDataTypeDouble) individual).setDoublePhenotype(x);
|
||||||
// evaluate the vector
|
// evaluate the vector
|
||||||
fitness = this.eval(x);
|
fitness = this.evaluate(x);
|
||||||
// if indicated, add Gaussian noise
|
// if indicated, add Gaussian noise
|
||||||
if (noise != 0) {
|
if (noise != 0) {
|
||||||
RNG.addNoise(fitness, noise);
|
RNG.addNoise(fitness, noise);
|
||||||
@ -206,7 +203,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
* @return the target function value
|
* @return the target function value
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public abstract double[] eval(double[] x);
|
public abstract double[] evaluate(double[] x);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the problem dimension.
|
* Get the problem dimension.
|
||||||
@ -410,7 +407,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
@Override
|
@Override
|
||||||
public double functionValue(double[] point) {
|
public double functionValue(double[] point) {
|
||||||
double[] x = project2DPoint(point);
|
double[] x = project2DPoint(point);
|
||||||
double v = eval(x)[0];
|
double v = evaluate(x)[0];
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +430,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
// required
|
// required
|
||||||
tmpIndy.setDoubleGenotype(pos);
|
tmpIndy.setDoubleGenotype(pos);
|
||||||
}
|
}
|
||||||
((AbstractEAIndividual) tmpIndy).setFitness(prob.eval(pos));
|
((AbstractEAIndividual) tmpIndy).setFitness(prob.evaluate(pos));
|
||||||
if (!Mathematics.isInRange(pos, prob.makeRange())) {
|
if (!Mathematics.isInRange(pos, prob.makeRange())) {
|
||||||
System.err.println("Warning, add optimum which is out of range!");
|
System.err.println("Warning, add optimum which is out of range!");
|
||||||
}
|
}
|
||||||
@ -454,7 +451,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
tmpIndy = (InterfaceDataTypeDouble) prob.getIndividualTemplate()
|
tmpIndy = (InterfaceDataTypeDouble) prob.getIndividualTemplate()
|
||||||
.clone();
|
.clone();
|
||||||
tmpIndy.setDoubleGenotype(pos);
|
tmpIndy.setDoubleGenotype(pos);
|
||||||
((AbstractEAIndividual) tmpIndy).setFitness(prob.eval(pos));
|
((AbstractEAIndividual) tmpIndy).setFitness(prob.evaluate(pos));
|
||||||
pop.add(tmpIndy);
|
pop.add(tmpIndy);
|
||||||
FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(
|
FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(
|
||||||
1e-25, 10, StagnationTypeEnum.generationBased,
|
1e-25, 10, StagnationTypeEnum.generationBased,
|
||||||
|
@ -10,7 +10,7 @@ package eva2.optimization.problems;
|
|||||||
public abstract class AbstractProblemDoubleOffset extends AbstractProblemDouble implements Interface2DBorderProblem {
|
public abstract class AbstractProblemDoubleOffset extends AbstractProblemDouble implements Interface2DBorderProblem {
|
||||||
|
|
||||||
protected int problemDimension = 10;
|
protected int problemDimension = 10;
|
||||||
protected double xOffset = 0.0; // TODO make them private, implement eval() and create abstract evalWithoutOffsets
|
protected double xOffset = 0.0; // TODO make them private, implement evaluate() and create abstract evalWithoutOffsets
|
||||||
protected double yOffset = 0.0;
|
protected double yOffset = 0.0;
|
||||||
|
|
||||||
public AbstractProblemDoubleOffset() {
|
public AbstractProblemDoubleOffset() {
|
||||||
@ -36,9 +36,7 @@ public abstract class AbstractProblemDoubleOffset extends AbstractProblemDouble
|
|||||||
setDefaultRange(defRange);
|
setDefaultRange(defRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************************************************************
|
|
||||||
* These are for GUI
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* This method allows the CommonJavaObjectEditorPanel to read the
|
* This method allows the CommonJavaObjectEditorPanel to read the
|
||||||
* name to the current object.
|
* name to the current object.
|
||||||
|
@ -110,7 +110,7 @@ public abstract class AbstractSynchronousOptimizationProblem extends
|
|||||||
// bogus. this must be reset right before population evaluation
|
// bogus. this must be reset right before population evaluation
|
||||||
setConstantProblemEvals(9999999);
|
setConstantProblemEvals(9999999);
|
||||||
} else {
|
} else {
|
||||||
// in absolute evals, so 1 means once per individual eval, .5 every second
|
// in absolute evals, so 1 means once per individual evaluate, .5 every second
|
||||||
setConstantProblemEvals(1 / frequency);
|
setConstantProblemEvals(1 / frequency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class ConstrHimmelblauProblem extends AbstractProblemDouble implements Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double v = 5.3578547 * x[2] * x[2] + 0.8356891 * x[0] * x[4] + 37.293239 * x[0] - 40792.141;
|
double v = 5.3578547 * x[2] * x[2] + 0.8356891 * x[0] * x[4] + 37.293239 * x[0] - 40792.141;
|
||||||
if (useYOffset) {
|
if (useYOffset) {
|
||||||
|
@ -62,7 +62,7 @@ public class ConstrPressureVessel extends AbstractProblemDouble {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
double v, thickS = x[0], thickH = x[1], R = x[2], L = x[3];
|
double v, thickS = x[0], thickH = x[1], R = x[2], L = x[3];
|
||||||
|
|
||||||
v = 0.6224 * thickS * R * L + 1.7781 * thickH * R * R + 3.1661 * thickS * thickS * L + 19.84 * thickS * thickS * R;
|
v = 0.6224 * thickS * R * L + 1.7781 * thickH * R * R + 3.1661 * thickS * thickS * L + 19.84 * thickS * thickS * R;
|
||||||
|
@ -209,7 +209,7 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
|
|||||||
|
|
||||||
x = getXVector(individual);
|
x = getXVector(individual);
|
||||||
|
|
||||||
double[] fit = eval(x);
|
double[] fit = evaluate(x);
|
||||||
individual.setFitness(fit);
|
individual.setFitness(fit);
|
||||||
|
|
||||||
// if (this.m_UseTestConstraint) {
|
// if (this.m_UseTestConstraint) {
|
||||||
@ -283,9 +283,9 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
if (x == null) {
|
if (x == null) {
|
||||||
throw new RuntimeException("Error, x=null value received in ExternalRuntimeProblem.eval");
|
throw new RuntimeException("Error, x=null value received in ExternalRuntimeProblem.evaluate");
|
||||||
}
|
}
|
||||||
ArrayList<Double> fitList = new ArrayList<Double>();
|
ArrayList<Double> fitList = new ArrayList<Double>();
|
||||||
|
|
||||||
@ -467,7 +467,7 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double functionValue(double[] point) {
|
public double functionValue(double[] point) {
|
||||||
return eval(project2DPoint(point))[0];
|
return evaluate(project2DPoint(point))[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,7 +43,7 @@ public class F10Problem extends AbstractProblemDoubleOffset implements Interface
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
double c1 = this.calculateC(1);
|
double c1 = this.calculateC(1);
|
||||||
|
@ -41,7 +41,7 @@ public class F11Problem extends AbstractProblemDoubleOffset implements Interface
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
double tmpProd = 1;
|
double tmpProd = 1;
|
||||||
|
@ -37,7 +37,7 @@ public class F12Problem extends AbstractProblemDoubleOffset implements Serializa
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
double tmp = 0;//-5;
|
double tmp = 0;//-5;
|
||||||
|
@ -57,7 +57,7 @@ public class F13Problem extends AbstractProblemDoubleOffset implements Interface
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
result[0] = yOffset;
|
result[0] = yOffset;
|
||||||
|
@ -34,7 +34,7 @@ public class F14Problem extends AbstractProblemDoubleOffset implements Interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
double x0 = x[0] - rotationDX - xOffset;
|
double x0 = x[0] - rotationDX - xOffset;
|
||||||
double x1 = x[1] - rotationDX - xOffset;
|
double x1 = x[1] - rotationDX - xOffset;
|
||||||
|
@ -30,7 +30,7 @@ public class F15Problem extends AbstractProblemDouble implements Serializable, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double t = 0, s = 0, sum = 0;
|
double t = 0, s = 0, sum = 0;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public class F16Problem extends AbstractProblemDouble implements InterfaceMultim
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] res = new double[1];
|
double[] res = new double[1];
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
@ -28,7 +28,7 @@ public class F17Problem extends AbstractProblemDouble implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] res = new double[1];
|
double[] res = new double[1];
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
@ -14,7 +14,7 @@ public class F18Problem extends AbstractProblemDouble implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] res = new double[1];
|
double[] res = new double[1];
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
@ -84,7 +84,7 @@ public class F19Problem extends AbstractProblemDouble implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] res = new double[1];
|
double[] res = new double[1];
|
||||||
double[] Bs = transform(x);
|
double[] Bs = transform(x);
|
||||||
|
@ -2,10 +2,12 @@ package eva2.optimization.problems;
|
|||||||
|
|
||||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||||
import eva2.tools.math.Mathematics;
|
import eva2.tools.math.Mathematics;
|
||||||
|
import eva2.util.annotation.Description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* F1 Sphere Problem
|
* F1 Sphere Problem
|
||||||
*/
|
*/
|
||||||
|
@Description(text="Sphere Problem")
|
||||||
public class F1Problem extends AbstractProblemDoubleOffset implements Interface2DBorderProblem, InterfaceHasInitRange, java.io.Serializable, InterfaceFirstOrderDerivableProblem {
|
public class F1Problem extends AbstractProblemDoubleOffset implements Interface2DBorderProblem, InterfaceHasInitRange, java.io.Serializable, InterfaceFirstOrderDerivableProblem {
|
||||||
private double initialRangeRatio = 1.; // reduce to initialize in a smaller subrange of the original range (in the corner box)
|
private double initialRangeRatio = 1.; // reduce to initialize in a smaller subrange of the original range (in the corner box)
|
||||||
|
|
||||||
@ -45,7 +47,7 @@ public class F1Problem extends AbstractProblemDoubleOffset implements Interface2
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
result[0] = yOffset;
|
result[0] = yOffset;
|
||||||
|
@ -32,7 +32,7 @@ public class F20Problem extends AbstractProblemDouble implements Serializable, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double sum = getYOffset();
|
double sum = getYOffset();
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class F21Problem extends AbstractProblemDouble implements InterfaceMultim
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
double res[] = new double[1];
|
double res[] = new double[1];
|
||||||
double tmp, innerSum, sum = 0;
|
double tmp, innerSum, sum = 0;
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
|
@ -45,7 +45,7 @@ public class F2Problem extends AbstractProblemDoubleOffset implements InterfaceL
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
result[0] = yOffset;
|
result[0] = yOffset;
|
||||||
|
@ -36,7 +36,7 @@ public class F3Problem extends AbstractProblemDoubleOffset implements java.io.Se
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
result[0] = yOffset + 6 * x.length;
|
result[0] = yOffset + 6 * x.length;
|
||||||
|
@ -37,7 +37,7 @@ public class F4Problem extends AbstractProblemDoubleOffset implements Serializab
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
result[0] = yOffset;
|
result[0] = yOffset;
|
||||||
|
@ -37,7 +37,7 @@ public class F5Problem extends AbstractProblemDoubleOffset implements Serializab
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
double tmp;
|
double tmp;
|
||||||
|
@ -47,7 +47,7 @@ public class F6Problem extends AbstractProblemDoubleOffset
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
result[0] = x.length * this.m_A + yOffset;
|
result[0] = x.length * this.m_A + yOffset;
|
||||||
|
@ -79,7 +79,7 @@ public class F7Problem extends AbstractProblemDoubleOffset implements Serializab
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
result[0] = yOffset;
|
result[0] = yOffset;
|
||||||
|
@ -64,7 +64,7 @@ public class F8Problem extends AbstractProblemDoubleOffset
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
double sum1 = 0, sum2 = 0, exp1, exp2;
|
double sum1 = 0, sum2 = 0, exp1, exp2;
|
||||||
@ -252,14 +252,14 @@ public class F8Problem extends AbstractProblemDoubleOffset
|
|||||||
double[] tmpP = pos.clone();
|
double[] tmpP = pos.clone();
|
||||||
double[] normedVect = Mathematics.normVect(vect);
|
double[] normedVect = Mathematics.normVect(vect);
|
||||||
double dx = initStep;
|
double dx = initStep;
|
||||||
double tmpFit, oldFit = prob.eval(pos)[fitCrit];
|
double tmpFit, oldFit = prob.evaluate(pos)[fitCrit];
|
||||||
|
|
||||||
int dir = 1;
|
int dir = 1;
|
||||||
while (dx > thresh) {
|
while (dx > thresh) {
|
||||||
// add a step to tmpP
|
// add a step to tmpP
|
||||||
Mathematics.svvAddScaled(dx * dir, normedVect, pos, tmpP);
|
Mathematics.svvAddScaled(dx * dir, normedVect, pos, tmpP);
|
||||||
// evaluate tmpP
|
// evaluate tmpP
|
||||||
tmpFit = prob.eval(tmpP)[fitCrit];
|
tmpFit = prob.evaluate(tmpP)[fitCrit];
|
||||||
if (tmpFit < oldFit) {
|
if (tmpFit < oldFit) {
|
||||||
// if tmpP is better than pos continue at new pos
|
// if tmpP is better than pos continue at new pos
|
||||||
double[] tmp = pos;
|
double[] tmp = pos;
|
||||||
@ -283,7 +283,7 @@ public class F8Problem extends AbstractProblemDoubleOffset
|
|||||||
return true;
|
return true;
|
||||||
} else { // the number of optima is corret - now check different offset or rotation by comparing one fitness value
|
} else { // the number of optima is corret - now check different offset or rotation by comparing one fitness value
|
||||||
AbstractEAIndividual indy = m_ListOfOptima.getEAIndividual(1);
|
AbstractEAIndividual indy = m_ListOfOptima.getEAIndividual(1);
|
||||||
double[] curFit = eval(indy.getDoublePosition());
|
double[] curFit = evaluate(indy.getDoublePosition());
|
||||||
if (Math.abs(Mathematics.dist(curFit, indy.getFitness(), 2)) > 1e-10) {
|
if (Math.abs(Mathematics.dist(curFit, indy.getFitness(), 2)) > 1e-10) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -316,7 +316,7 @@ public class F8Problem extends AbstractProblemDoubleOffset
|
|||||||
// InterfaceDataTypeDouble tmpIndy;
|
// InterfaceDataTypeDouble tmpIndy;
|
||||||
// tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.template).clone();
|
// tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.template).clone();
|
||||||
// tmpIndy.setDoubleGenotype(pos);
|
// tmpIndy.setDoubleGenotype(pos);
|
||||||
// ((AbstractEAIndividual)tmpIndy).SetFitness(eval(pos));
|
// ((AbstractEAIndividual)tmpIndy).SetFitness(evaluate(pos));
|
||||||
// population.add(tmpIndy);
|
// population.add(tmpIndy);
|
||||||
// FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(1e-15, 10, false, true);
|
// FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(1e-15, 10, false, true);
|
||||||
// int calls = PostProcess.processWithGDA(population, this, convTerm, 0, 0.0000000000000001, 0.01);
|
// int calls = PostProcess.processWithGDA(population, this, convTerm, 0, 0.0000000000000001, 0.01);
|
||||||
|
@ -29,7 +29,7 @@ public class F9Problem extends AbstractProblemDoubleOffset implements java.io.Se
|
|||||||
* @return The m-dimensional output vector.
|
* @return The m-dimensional output vector.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
x = rotateMaybe(x);
|
x = rotateMaybe(x);
|
||||||
double[] result = new double[1];
|
double[] result = new double[1];
|
||||||
result[0] = yOffset;
|
result[0] = yOffset;
|
||||||
|
@ -82,7 +82,7 @@ public class GPFunctionProblem extends AbstractProblemDouble implements Interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double[] eval(double[] x) {
|
public double[] evaluate(double[] x) {
|
||||||
if (x.length != dim) {
|
if (x.length != dim) {
|
||||||
EVAERROR.errorMsgOnce("mismatching dimension of GPFunctionProblem! Setting to " + x.length);
|
EVAERROR.errorMsgOnce("mismatching dimension of GPFunctionProblem! Setting to " + x.length);
|
||||||
setProblemDimension(x.length);
|
setProblemDimension(x.length);
|
||||||
|
@ -14,7 +14,7 @@ public interface InterfaceProblemDouble {
|
|||||||
* @param x the vector to evaluate
|
* @param x the vector to evaluate
|
||||||
* @return the target function value
|
* @return the target function value
|
||||||
*/
|
*/
|
||||||
public double[] eval(double[] x);
|
public double[] evaluate(double[] x);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the problem dimension.
|
* Get the problem dimension.
|
||||||
|
@ -96,7 +96,7 @@ public class MatlabEvalMediator {
|
|||||||
logMP(msg);
|
logMP(msg);
|
||||||
}
|
}
|
||||||
requesting = true;
|
requesting = true;
|
||||||
// logMPAndSysOut("-- Requesting eval for " + BeanInspector.toString(x) + ", req state is " + requesting + "\n");
|
// logMPAndSysOut("-- Requesting evaluate for " + BeanInspector.toString(x) + ", req state is " + requesting + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,19 +1,5 @@
|
|||||||
package eva2.optimization.stat;
|
package eva2.optimization.stat;
|
||||||
|
|
||||||
/*
|
|
||||||
* Title: EvA2
|
|
||||||
* Description:
|
|
||||||
* Copyright: Copyright (c) 2003
|
|
||||||
* Company: University of Tuebingen, Computer Architecture
|
|
||||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
|
||||||
* @version: $Revision: 306 $
|
|
||||||
* $Date: 2007-12-04 14:22:52 +0100 (Tue, 04 Dec 2007) $
|
|
||||||
* $Author: mkron $
|
|
||||||
*/
|
|
||||||
/*==========================================================================*
|
|
||||||
* IMPORTS
|
|
||||||
*==========================================================================*/
|
|
||||||
|
|
||||||
import eva2.optimization.population.PopulationInterface;
|
import eva2.optimization.population.PopulationInterface;
|
||||||
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
import eva2.optimization.problems.InterfaceAdditionalPopulationInformer;
|
||||||
|
|
||||||
@ -34,8 +20,6 @@ import java.util.List;
|
|||||||
public class StatisticsStandalone extends AbstractStatistics implements InterfaceStatistics, Serializable {
|
public class StatisticsStandalone extends AbstractStatistics implements InterfaceStatistics, Serializable {
|
||||||
private static final long serialVersionUID = -8451652609212653368L;
|
private static final long serialVersionUID = -8451652609212653368L;
|
||||||
|
|
||||||
private static String m_MyHostName = "unknown";
|
|
||||||
|
|
||||||
// private String m_InfoString;
|
// private String m_InfoString;
|
||||||
private ArrayList<ArrayList<Object[]>> m_ResultData = null;
|
private ArrayList<ArrayList<Object[]>> m_ResultData = null;
|
||||||
private ArrayList<String> m_ResultHeaderStrings = null;
|
private ArrayList<String> m_ResultHeaderStrings = null;
|
||||||
@ -45,11 +29,6 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
|
|||||||
public StatisticsStandalone(InterfaceStatisticsParameter statParams) {
|
public StatisticsStandalone(InterfaceStatisticsParameter statParams) {
|
||||||
super();
|
super();
|
||||||
statisticsParameter = statParams;
|
statisticsParameter = statParams;
|
||||||
try {
|
|
||||||
m_MyHostName = InetAddress.getLocalHost().getHostName();
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("ERROR getting HostName " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatisticsStandalone(String resultFileName) {
|
public StatisticsStandalone(String resultFileName) {
|
||||||
|
@ -265,9 +265,9 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization
|
|||||||
*/
|
*/
|
||||||
for (int i = 0; i < lastVelocity.length; i++) {
|
for (int i = 0; i < lastVelocity.length; i++) {
|
||||||
// the component from the old velocity
|
// the component from the old velocity
|
||||||
curVelocity[i] = this.m_InertnessOrChi * lastVelocity[i];
|
curVelocity[i] = this.inertnessOrChi * lastVelocity[i];
|
||||||
if (algType.getSelectedTag().getID() == 1) {
|
if (algType.getSelectedTag().getID() == 1) {
|
||||||
chi = m_InertnessOrChi;
|
chi = inertnessOrChi;
|
||||||
} else {
|
} else {
|
||||||
chi = 1.;
|
chi = 1.;
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,8 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
* InertnessOrChi may contain the inertness or chi parameter depending on
|
* InertnessOrChi may contain the inertness or chi parameter depending on
|
||||||
* algoType
|
* algoType
|
||||||
*/
|
*/
|
||||||
protected double m_InertnessOrChi = 0.73;
|
protected double inertnessOrChi = 0.73;
|
||||||
protected double m_ReduceSpeed = 0.8;
|
protected double reduceSpeed = 0.8;
|
||||||
private double reduceSpeedOnConstViolation = 0.5;
|
private double reduceSpeedOnConstViolation = 0.5;
|
||||||
public static final int defaultType = 0;
|
public static final int defaultType = 0;
|
||||||
public static final int resetType = 99;
|
public static final int resetType = 99;
|
||||||
@ -133,7 +133,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
this.m_SpeedLimit = a.m_SpeedLimit;
|
this.m_SpeedLimit = a.m_SpeedLimit;
|
||||||
this.m_Phi1 = a.m_Phi1;
|
this.m_Phi1 = a.m_Phi1;
|
||||||
this.m_Phi2 = a.m_Phi2;
|
this.m_Phi2 = a.m_Phi2;
|
||||||
this.m_InertnessOrChi = a.m_InertnessOrChi;
|
this.inertnessOrChi = a.inertnessOrChi;
|
||||||
this.m_TopologyRange = a.m_TopologyRange;
|
this.m_TopologyRange = a.m_TopologyRange;
|
||||||
this.paramControl = (ParameterControlManager) a.paramControl.clone();
|
this.paramControl = (ParameterControlManager) a.paramControl.clone();
|
||||||
//this.setCheckSpeedLimit(a.isCheckSpeedLimit());
|
//this.setCheckSpeedLimit(a.isCheckSpeedLimit());
|
||||||
@ -787,7 +787,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
// System.out.println("-- len aft " + vecLen(socCogn));
|
// System.out.println("-- len aft " + vecLen(socCogn));
|
||||||
// rotateAllAxes(neiDiff, .5, false);
|
// rotateAllAxes(neiDiff, .5, false);
|
||||||
// // TODO!!!
|
// // TODO!!!
|
||||||
// if (algType.getSelectedTag().getID()==1) chi=m_InertnessOrChi;
|
// if (algType.getSelectedTag().getID()==1) chi=inertnessOrChi;
|
||||||
// else chi = 1.;
|
// else chi = 1.;
|
||||||
//
|
//
|
||||||
// double scaleCog = this.m_Phi1*chi*RNG.randomDouble(0,1);
|
// double scaleCog = this.m_Phi1*chi*RNG.randomDouble(0,1);
|
||||||
@ -795,15 +795,15 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// for (int i=0; i<lastVelocity.length; i++) {
|
// for (int i=0; i<lastVelocity.length; i++) {
|
||||||
// curVelocity[i] = this.m_InertnessOrChi * lastVelocity[i];
|
// curVelocity[i] = this.inertnessOrChi * lastVelocity[i];
|
||||||
// curVelocity[i] += scaleCog*socCogn[i];
|
// curVelocity[i] += scaleCog*socCogn[i];
|
||||||
// curVelocity[i] += scaleNei*neiDiff[i];
|
// curVelocity[i] += scaleNei*neiDiff[i];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// for (int i = 0; i < lastVelocity.length; i++) {
|
// for (int i = 0; i < lastVelocity.length; i++) {
|
||||||
// // the component from the old velocity
|
// // the component from the old velocity
|
||||||
// curVelocity[i] = this.m_InertnessOrChi * lastVelocity[i];
|
// curVelocity[i] = this.inertnessOrChi * lastVelocity[i];
|
||||||
// if (algType.getSelectedTag().getID()==1) chi=m_InertnessOrChi;
|
// if (algType.getSelectedTag().getID()==1) chi=inertnessOrChi;
|
||||||
// else chi = 1.;
|
// else chi = 1.;
|
||||||
// // the component from the cognition model
|
// // the component from the cognition model
|
||||||
// //curVelocity[i] += this.m_Phi1*chi*RNG.randomDouble(0,1)*(personalBestPos[i]-curPosition[i]);
|
// //curVelocity[i] += this.m_Phi1*chi*RNG.randomDouble(0,1)*(personalBestPos[i]-curPosition[i]);
|
||||||
@ -828,7 +828,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
//System.out.println("accel is " + getVecNorm(accel));
|
//System.out.println("accel is " + getVecNorm(accel));
|
||||||
|
|
||||||
for (int i = 0; i < lastVelocity.length; i++) {
|
for (int i = 0; i < lastVelocity.length; i++) {
|
||||||
curVelocity[i] = this.m_InertnessOrChi * lastVelocity[i];
|
curVelocity[i] = this.inertnessOrChi * lastVelocity[i];
|
||||||
curVelocity[i] += accel[i];
|
curVelocity[i] += accel[i];
|
||||||
}
|
}
|
||||||
return curVelocity;
|
return curVelocity;
|
||||||
@ -844,7 +844,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
// the component from the old velocity
|
// the component from the old velocity
|
||||||
accel[i] = 0;
|
accel[i] = 0;
|
||||||
if (algType.getSelectedTag().getID() == 1) {
|
if (algType.getSelectedTag().getID() == 1) {
|
||||||
chi = m_InertnessOrChi;
|
chi = inertnessOrChi;
|
||||||
} else {
|
} else {
|
||||||
chi = 1.;
|
chi = 1.;
|
||||||
}
|
}
|
||||||
@ -891,7 +891,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
// double[] accel = new double[curPosition.length];
|
// double[] accel = new double[curPosition.length];
|
||||||
// double chi;
|
// double chi;
|
||||||
//
|
//
|
||||||
// if (algType.getSelectedTag().getID()==1) chi=m_InertnessOrChi;
|
// if (algType.getSelectedTag().getID()==1) chi=inertnessOrChi;
|
||||||
// else chi = 1.;
|
// else chi = 1.;
|
||||||
//
|
//
|
||||||
// boolean rotatedVect=false;
|
// boolean rotatedVect=false;
|
||||||
@ -1292,7 +1292,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
protected void enforceSpeedLimit(double[] curVelocity, double[][] range, double speedLim) {
|
protected void enforceSpeedLimit(double[] curVelocity, double[][] range, double speedLim) {
|
||||||
while (Mathematics.getRelativeLength(curVelocity, range) > speedLim) {
|
while (Mathematics.getRelativeLength(curVelocity, range) > speedLim) {
|
||||||
for (int i = 0; i < curVelocity.length; i++) {
|
for (int i = 0; i < curVelocity.length; i++) {
|
||||||
curVelocity[i] *= this.m_ReduceSpeed;
|
curVelocity[i] *= this.reduceSpeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1876,11 +1876,11 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
* @param k
|
* @param k
|
||||||
*/
|
*/
|
||||||
public void setInertnessOrChi(double k) {
|
public void setInertnessOrChi(double k) {
|
||||||
this.m_InertnessOrChi = k;
|
this.inertnessOrChi = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getInertnessOrChi() {
|
public double getInertnessOrChi() {
|
||||||
return this.m_InertnessOrChi;
|
return this.inertnessOrChi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String inertnessOrChiTipText() {
|
public String inertnessOrChiTipText() {
|
||||||
@ -2212,17 +2212,17 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
|
|
||||||
double relDiff;
|
double relDiff;
|
||||||
if (personalBestfit[0] != 0) {
|
if (personalBestfit[0] != 0) {
|
||||||
relDiff = (personalBestfit[0] - ((InterfaceProblemDouble) m_Problem).eval(personalBestPos)[0]) / personalBestfit[0];
|
relDiff = (personalBestfit[0] - ((InterfaceProblemDouble) m_Problem).evaluate(personalBestPos)[0]) / personalBestfit[0];
|
||||||
} else {
|
} else {
|
||||||
relDiff = (personalBestfit[0] - ((InterfaceProblemDouble) m_Problem).eval(personalBestPos)[0]); // absolute diff in this case
|
relDiff = (personalBestfit[0] - ((InterfaceProblemDouble) m_Problem).evaluate(personalBestPos)[0]); // absolute diff in this case
|
||||||
}// if (personalBestfit[0]!=((InterfaceProblemDouble)problem).eval(personalBestPos)[0]) {
|
}// if (personalBestfit[0]!=((InterfaceProblemDouble)problem).evaluate(personalBestPos)[0]) {
|
||||||
if (Math.abs(relDiff) > 1e-20) {
|
if (Math.abs(relDiff) > 1e-20) {
|
||||||
System.err.println("Warning: mismatching best fitness by " + relDiff);
|
System.err.println("Warning: mismatching best fitness by " + relDiff);
|
||||||
System.err.println("partInfo: " + i + " - " + getParticleInfo(population.getEAIndividual(i)));
|
System.err.println("partInfo: " + i + " - " + getParticleInfo(population.getEAIndividual(i)));
|
||||||
}
|
}
|
||||||
if (Math.abs(relDiff) > 1e-10) {
|
if (Math.abs(relDiff) > 1e-10) {
|
||||||
System.err.println("partInfo: " + i + " - " + getParticleInfo(population.getEAIndividual(i)));
|
System.err.println("partInfo: " + i + " - " + getParticleInfo(population.getEAIndividual(i)));
|
||||||
throw new RuntimeException("Mismatching best fitness!! " + personalBestfit[0] + " vs. " + ((InterfaceProblemDouble) m_Problem).eval(personalBestPos)[0]);
|
throw new RuntimeException("Mismatching best fitness!! " + personalBestfit[0] + " vs. " + ((InterfaceProblemDouble) m_Problem).evaluate(personalBestPos)[0]);
|
||||||
}
|
}
|
||||||
((InterfaceDataTypeDouble) indy).setDoubleGenotype(personalBestPos);
|
((InterfaceDataTypeDouble) indy).setDoubleGenotype(personalBestPos);
|
||||||
indy.setFitness(personalBestfit);
|
indy.setFitness(personalBestfit);
|
||||||
|
@ -112,7 +112,7 @@ public class ParticleSwarmOptimizationGCPSO extends ParticleSwarmOptimization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < lastVelocity.length; i++) {
|
for (int i = 0; i < lastVelocity.length; i++) {
|
||||||
curVelocity[i] = this.m_InertnessOrChi * lastVelocity[i];
|
curVelocity[i] = this.inertnessOrChi * lastVelocity[i];
|
||||||
curVelocity[i] += accel[i];
|
curVelocity[i] += accel[i];
|
||||||
}
|
}
|
||||||
return curVelocity;
|
return curVelocity;
|
||||||
|
@ -185,7 +185,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public double eval(double[] x) {
|
// public double evaluate(double[] x) {
|
||||||
// AbstractEAIndividual indy = (AbstractEAIndividual)template.clone();
|
// AbstractEAIndividual indy = (AbstractEAIndividual)template.clone();
|
||||||
// ((InterfaceDataTypeDouble)indy).setDoubleGenotype(x);
|
// ((InterfaceDataTypeDouble)indy).setDoubleGenotype(x);
|
||||||
// problem.evaluate(indy);
|
// problem.evaluate(indy);
|
||||||
|
@ -515,7 +515,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
|||||||
* }
|
* }
|
||||||
* // -----------OPTIMIZE END }
|
* // -----------OPTIMIZE END }
|
||||||
*
|
*
|
||||||
* // Result of the run print("\nBest: eval.= " + evalF + "\n", displayPb);
|
* // Result of the run print("\nBest: evaluate.= " + evalF + "\n", displayPb);
|
||||||
* swarm.Best.displayMemory(displayPb);
|
* swarm.Best.displayMemory(displayPb);
|
||||||
*
|
*
|
||||||
* save(" " + iter + " " + evalF+ " ", synthSave);
|
* save(" " + iter + " " + evalF+ " ", synthSave);
|
||||||
|
@ -94,7 +94,7 @@ public class Tribe implements java.io.Serializable {
|
|||||||
for (n = 0; n < explorerNb; n++) {
|
for (n = 0; n < explorerNb; n++) {
|
||||||
|
|
||||||
boolean eval = explorer[n].moveExplorer(tribeRank, n, swarm, informOption, prob);
|
boolean eval = explorer[n].moveExplorer(tribeRank, n, swarm, informOption, prob);
|
||||||
// if (eval) evals++;
|
// if (evaluate) evals++;
|
||||||
|
|
||||||
if (pb.constraint) {
|
if (pb.constraint) {
|
||||||
explorer[n].constraint(pb.gNb, pb.hNb, pb.ups);
|
explorer[n].constraint(pb.gNb, pb.hNb, pb.ups);
|
||||||
|
@ -139,7 +139,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
|
|||||||
// public int generateExplorer(TribesParam pb,
|
// public int generateExplorer(TribesParam pb,
|
||||||
// TribesSwarm swarm, TribesPosition center, double radius,
|
// TribesSwarm swarm, TribesPosition center, double radius,
|
||||||
// int option, int fromTribe,
|
// int option, int fromTribe,
|
||||||
// int initType, int eval, int label) {
|
// int initType, int evaluate, int label) {
|
||||||
// /*
|
// /*
|
||||||
// Generation of a new explorer ("scout")
|
// Generation of a new explorer ("scout")
|
||||||
// If fromTribe=-1, this is the very first generation
|
// If fromTribe=-1, this is the very first generation
|
||||||
@ -148,7 +148,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
|
|||||||
// TribesExplorer expl = this;
|
// TribesExplorer expl = this;
|
||||||
//
|
//
|
||||||
// int d, dmax, dmod;
|
// int d, dmax, dmod;
|
||||||
// int evalF = eval;
|
// int evalF = evaluate;
|
||||||
// int m;
|
// int m;
|
||||||
// // int rank;
|
// // int rank;
|
||||||
// // int shaman;
|
// // int shaman;
|
||||||
@ -433,7 +433,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
|
|||||||
if (Tribes.blind > 0 && strategy == 6) {
|
if (Tribes.blind > 0 && strategy == 6) {
|
||||||
if (RNG.randomDouble() < Tribes.blind) {
|
if (RNG.randomDouble() < Tribes.blind) {
|
||||||
fitnessEval = false;
|
fitnessEval = false;
|
||||||
//System.out.print("\n no fitness eval");
|
//System.out.print("\n no fitness evaluate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
|
|||||||
prob.evaluate(this);
|
prob.evaluate(this);
|
||||||
swarm.masterTribe.incEvalCnt();
|
swarm.masterTribe.incEvalCnt();
|
||||||
// evalF = position.fitnessEval(pb.function, pb.objective,
|
// evalF = position.fitnessEval(pb.function, pb.objective,
|
||||||
// pb.fitnessSize, eval);
|
// pb.fitnessSize, evaluate);
|
||||||
} else { // Artificial fitness by using penalties
|
} else { // Artificial fitness by using penalties
|
||||||
for (n = 0; n < position.fitness.length; n++) {
|
for (n = 0; n < position.fitness.length; n++) {
|
||||||
SetFitness(n, swarm.tribes[fromTribe].memory[
|
SetFitness(n, swarm.tribes[fromTribe].memory[
|
||||||
|
@ -117,9 +117,9 @@ public class TribesPosition implements java.io.Serializable {
|
|||||||
//
|
//
|
||||||
//// =================================================================== FITNESS EVALUATION
|
//// =================================================================== FITNESS EVALUATION
|
||||||
// public int fitnessEval(int[] codeFunction, double objective,
|
// public int fitnessEval(int[] codeFunction, double objective,
|
||||||
// int fitnessSize,int eval) {
|
// int fitnessSize,int evaluate) {
|
||||||
//
|
//
|
||||||
// //Tribes.eval++; // Incrémente le nombre total d'évaluations
|
// //Tribes.evaluate++; // Incrémente le nombre total d'évaluations
|
||||||
// int n;
|
// int n;
|
||||||
// double r;
|
// double r;
|
||||||
//
|
//
|
||||||
@ -301,7 +301,7 @@ public class TribesPosition implements java.io.Serializable {
|
|||||||
// */
|
// */
|
||||||
// totalError = totalError(fitness, fitnessSize);
|
// totalError = totalError(fitness, fitnessSize);
|
||||||
//
|
//
|
||||||
// return eval+1;
|
// return evaluate+1;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public double totalError(double[] fitness, int fitnessSize) {
|
// public double totalError(double[] fitness, int fitnessSize) {
|
||||||
|
@ -675,7 +675,7 @@ public class JMatLink extends Thread {
|
|||||||
// evaluate expression "evalS" in specified engine Ep
|
// evaluate expression "evalS" in specified engine Ep
|
||||||
|
|
||||||
if (debugB) {
|
if (debugB) {
|
||||||
System.out.println("eval(ep,String) in " + epI + " " + evalS);
|
System.out.println("evaluate(ep,String) in " + epI + " " + evalS);
|
||||||
}
|
}
|
||||||
|
|
||||||
lockEngineLock();
|
lockEngineLock();
|
||||||
@ -693,7 +693,7 @@ public class JMatLink extends Thread {
|
|||||||
releaseEngineLock();
|
releaseEngineLock();
|
||||||
|
|
||||||
if (debugB) {
|
if (debugB) {
|
||||||
System.out.println("eval(ep,String) out " + epI + " " + evalS);
|
System.out.println("evaluate(ep,String) out " + epI + " " + evalS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return retValI; Return value indicates success
|
// return retValI; Return value indicates success
|
||||||
|
Loading…
x
Reference in New Issue
Block a user