Renamed eval function to evaluate.

Implemented more of CLI core.
This commit is contained in:
Fabian Becker 2013-12-10 15:49:22 +01:00
parent 30381f4c04
commit 321796d2c4
46 changed files with 111 additions and 135 deletions

View File

@ -788,7 +788,6 @@ public class OptimizerFactory {
return null;
}
runnable.run();
new Thread(runnable).start();
lastRunnable = runnable;
return runnable;
}
@ -872,8 +871,7 @@ public class OptimizerFactory {
}
public static double[] optimizeToDouble(OptimizationParameters params) {
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params,
false));
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params, false));
return runnable.getDoubleSolution();
}
@ -883,15 +881,13 @@ public class OptimizerFactory {
return runnable.getDoubleSolution();
}
public static double[] optimizeToDouble(final int optType,
AbstractOptimizationProblem problem) {
public static double[] optimizeToDouble(final int optType, AbstractOptimizationProblem problem) {
return optimizeToDouble(optType, problem, null);
}
public static double[] optimizeToDouble(final int optType,
AbstractOptimizationProblem problem, String outputFilePrefix) {
OptimizerRunnable runnable = optimize(optType, problem,
outputFilePrefix);
OptimizerRunnable runnable = optimize(optType, problem, outputFilePrefix);
return (runnable != null) ? runnable.getDoubleSolution() : null;
}
@ -901,13 +897,11 @@ public class OptimizerFactory {
}
public static IndividualInterface optimizeToInd(OptimizationParameters params) {
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params,
false));
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params, false));
return runnable.getResult();
}
public static IndividualInterface optimizeToInd(OptimizationParameters params,
String outputFilePrefix) {
public static IndividualInterface optimizeToInd(OptimizationParameters params, String outputFilePrefix) {
OptimizerRunnable runnable = optimize(new OptimizerRunnable(params,
outputFilePrefix));
return runnable.getResult();

View File

@ -254,7 +254,6 @@ public class OptimizerRunnable implements Runnable {
* Set the verbosity level in the statistics module to the given value.
*
* @param vLev
* @see StatsParameter
*/
public void setVerbosityLevel(int vLev) {
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.
*
* @param outp
* @see StatsParameter
*/
public void setOutputTo(int 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).
*
* @param addInfo
* @see StatsParameter
*/
public void setOutputFullStatsToText(boolean addInfo) {
((AbstractStatistics) proc.getStatistics()).getStatisticsParameter().setOutputAllFieldsAsText(addInfo);

View File

@ -10,6 +10,8 @@ import eva2.optimization.operator.terminators.EvaluationTerminator;
import eva2.optimization.operator.terminators.FitnessValueTerminator;
import eva2.optimization.population.Population;
import eva2.optimization.problems.AbstractOptimizationProblem;
import eva2.optimization.problems.AbstractProblemDouble;
import eva2.optimization.problems.AbstractProblemDoubleOffset;
import eva2.optimization.strategies.DifferentialEvolution;
import eva2.optimization.strategies.InterfaceOptimizer;
import com.google.gson.*;
@ -181,6 +183,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
this.jsonObject = new JsonObject();
this.optimizationRuns = new JsonArray();
this.generationsArray = new JsonArray();
/**
* 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("dimension", 30);
this.jsonObject.add("problem", problemObject);
}
/**
@ -312,6 +314,14 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
System.out.println("Genetic Algorithm");
break;
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;
default:
@ -322,7 +332,7 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
private void setProblemFromName(String problemName) {
Map<String, Class<? extends AbstractOptimizationProblem>> problemList = createProblemList();
Class<? extends AbstractOptimizationProblem> problem = problemList.get(problemName);
Class<? extends AbstractProblemDoubleOffset> problem = problemList.get(problemName);
try {
this.problem = problem.newInstance();
} catch (InstantiationException e) {
@ -334,32 +344,31 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
private void runOptimization() {
for(int i = 0; i < this.numberOfRuns; i++) {
this.generationsArray = new JsonArray();
// Terminate after 10000 function evaluations OR after reaching a fitness < 0.1
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");
OptimizationParameters params = OptimizerFactory.makeParams(optimizer, this.populationSize, this.problem);
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();
optimizationDetails.addProperty("total_time", 1.0);
optimizationDetails.addProperty("total_function_calls", optimizer.getPopulation().getFunctionCalls());
optimizationDetails.addProperty("termination_criteria", OptimizerFactory.terminatedBecause());
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);
System.out.println(OptimizerFactory.terminatedBecause());
System.out.println(optimizer.getPopulation().getFunctionCalls());
// Needs to be re-created here.
this.generationsArray = new JsonArray();
}
this.jsonObject.add("runs", this.optimizationRuns);
@ -407,8 +416,8 @@ public class Main implements OptimizationStateListener, InterfacePopulationChang
meanFitness.add(new JsonPrimitive(val));
}
newGeneration.add("mean_fitness", meanFitness);
System.out.println(newGeneration.toString());
//this.generationsArray.add(newGeneration);
//System.out.println(newGeneration.toString());
this.generationsArray.add(newGeneration);
}
}

View File

@ -374,7 +374,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
public static void test(String constr, double[] pos) {
AbstractGPNode node = AbstractGPNode.parseFromString(constr);
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));
}

View File

@ -93,7 +93,7 @@ public class GenericConstraint extends AbstractConstraint implements InterfaceDo
if (func == null) {
func = new GPFunctionProblem(constraintProgram, null, indyX.length, 0., 0.);
}
return func.eval(indyX)[0];
return func.evaluate(indyX)[0];
} else {
return 0.;
}

View File

@ -89,7 +89,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = this.globalOptimum - evalUnnormalized(x)[0];

View File

@ -26,7 +26,7 @@ import eva2.tools.math.RNG;
/**
* For a double valued problem, there are two main methods to implement:
* {@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.
* <p/>
* 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
// during object init
((InterfaceDataTypeDouble) this.template)
.setDoubleDataLength(getProblemDimension());
((InterfaceDataTypeDouble) this.template)
.setDoubleRange(makeRange());
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(getProblemDimension());
((InterfaceDataTypeDouble) this.template).setDoubleRange(makeRange());
}
}
@ -126,9 +124,8 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
/**
* When implementing a double problem, inheriting classes should not
* 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
public void evaluate(AbstractEAIndividual individual) {
@ -138,7 +135,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
x = getEvalArray(individual);
((InterfaceDataTypeDouble) individual).setDoublePhenotype(x);
// evaluate the vector
fitness = this.eval(x);
fitness = this.evaluate(x);
// if indicated, add Gaussian noise
if (noise != 0) {
RNG.addNoise(fitness, noise);
@ -206,7 +203,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
* @return the target function value
*/
@Override
public abstract double[] eval(double[] x);
public abstract double[] evaluate(double[] x);
/**
* Get the problem dimension.
@ -410,7 +407,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
@Override
public double functionValue(double[] point) {
double[] x = project2DPoint(point);
double v = eval(x)[0];
double v = evaluate(x)[0];
return v;
}
@ -433,7 +430,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
// required
tmpIndy.setDoubleGenotype(pos);
}
((AbstractEAIndividual) tmpIndy).setFitness(prob.eval(pos));
((AbstractEAIndividual) tmpIndy).setFitness(prob.evaluate(pos));
if (!Mathematics.isInRange(pos, prob.makeRange())) {
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()
.clone();
tmpIndy.setDoubleGenotype(pos);
((AbstractEAIndividual) tmpIndy).setFitness(prob.eval(pos));
((AbstractEAIndividual) tmpIndy).setFitness(prob.evaluate(pos));
pop.add(tmpIndy);
FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(
1e-25, 10, StagnationTypeEnum.generationBased,

View File

@ -10,7 +10,7 @@ package eva2.optimization.problems;
public abstract class AbstractProblemDoubleOffset extends AbstractProblemDouble implements Interface2DBorderProblem {
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;
public AbstractProblemDoubleOffset() {
@ -36,9 +36,7 @@ public abstract class AbstractProblemDoubleOffset extends AbstractProblemDouble
setDefaultRange(defRange);
}
/**********************************************************************************************************************
* These are for GUI
*/
/**
* This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object.

View File

@ -110,7 +110,7 @@ public abstract class AbstractSynchronousOptimizationProblem extends
// bogus. this must be reset right before population evaluation
setConstantProblemEvals(9999999);
} 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);
}
}

View File

@ -50,7 +50,7 @@ public class ConstrHimmelblauProblem extends AbstractProblemDouble implements Se
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double v = 5.3578547 * x[2] * x[2] + 0.8356891 * x[0] * x[4] + 37.293239 * x[0] - 40792.141;
if (useYOffset) {

View File

@ -62,7 +62,7 @@ public class ConstrPressureVessel extends AbstractProblemDouble {
}
@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];
v = 0.6224 * thickS * R * L + 1.7781 * thickH * R * R + 3.1661 * thickS * thickS * L + 19.84 * thickS * thickS * R;

View File

@ -209,7 +209,7 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
x = getXVector(individual);
double[] fit = eval(x);
double[] fit = evaluate(x);
individual.setFitness(fit);
// if (this.m_UseTestConstraint) {
@ -283,9 +283,9 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
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>();
@ -467,7 +467,7 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
@Override
public double functionValue(double[] point) {
return eval(project2DPoint(point))[0];
return evaluate(project2DPoint(point))[0];
}
@Override

View File

@ -43,7 +43,7 @@ public class F10Problem extends AbstractProblemDoubleOffset implements Interface
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
double c1 = this.calculateC(1);

View File

@ -41,7 +41,7 @@ public class F11Problem extends AbstractProblemDoubleOffset implements Interface
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
double tmpProd = 1;

View File

@ -37,7 +37,7 @@ public class F12Problem extends AbstractProblemDoubleOffset implements Serializa
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
double tmp = 0;//-5;

View File

@ -57,7 +57,7 @@ public class F13Problem extends AbstractProblemDoubleOffset implements Interface
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = yOffset;

View File

@ -34,7 +34,7 @@ public class F14Problem extends AbstractProblemDoubleOffset implements Interface
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
double[] result = new double[1];
double x0 = x[0] - rotationDX - xOffset;
double x1 = x[1] - rotationDX - xOffset;

View File

@ -30,7 +30,7 @@ public class F15Problem extends AbstractProblemDouble implements Serializable, I
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double t = 0, s = 0, sum = 0;

View File

@ -24,7 +24,7 @@ public class F16Problem extends AbstractProblemDouble implements InterfaceMultim
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] res = new double[1];
double sum = 0;

View File

@ -28,7 +28,7 @@ public class F17Problem extends AbstractProblemDouble implements
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] res = new double[1];
double sum = 0;

View File

@ -14,7 +14,7 @@ public class F18Problem extends AbstractProblemDouble implements
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] res = new double[1];
double sum = 0;

View File

@ -84,7 +84,7 @@ public class F19Problem extends AbstractProblemDouble implements
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] res = new double[1];
double[] Bs = transform(x);

View File

@ -2,10 +2,12 @@ package eva2.optimization.problems;
import eva2.optimization.strategies.InterfaceOptimizer;
import eva2.tools.math.Mathematics;
import eva2.util.annotation.Description;
/**
* F1 Sphere Problem
*/
@Description(text="Sphere Problem")
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)
@ -45,7 +47,7 @@ public class F1Problem extends AbstractProblemDoubleOffset implements Interface2
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = yOffset;

View File

@ -32,7 +32,7 @@ public class F20Problem extends AbstractProblemDouble implements Serializable, I
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double sum = getYOffset();

View File

@ -61,7 +61,7 @@ public class F21Problem extends AbstractProblemDouble implements InterfaceMultim
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
double res[] = new double[1];
double tmp, innerSum, sum = 0;
x = rotateMaybe(x);

View File

@ -45,7 +45,7 @@ public class F2Problem extends AbstractProblemDoubleOffset implements InterfaceL
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = yOffset;

View File

@ -36,7 +36,7 @@ public class F3Problem extends AbstractProblemDoubleOffset implements java.io.Se
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = yOffset + 6 * x.length;

View File

@ -37,7 +37,7 @@ public class F4Problem extends AbstractProblemDoubleOffset implements Serializab
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = yOffset;

View File

@ -37,7 +37,7 @@ public class F5Problem extends AbstractProblemDoubleOffset implements Serializab
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
double tmp;

View File

@ -47,7 +47,7 @@ public class F6Problem extends AbstractProblemDoubleOffset
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = x.length * this.m_A + yOffset;

View File

@ -79,7 +79,7 @@ public class F7Problem extends AbstractProblemDoubleOffset implements Serializab
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = yOffset;

View File

@ -64,7 +64,7 @@ public class F8Problem extends AbstractProblemDoubleOffset
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
double sum1 = 0, sum2 = 0, exp1, exp2;
@ -252,14 +252,14 @@ public class F8Problem extends AbstractProblemDoubleOffset
double[] tmpP = pos.clone();
double[] normedVect = Mathematics.normVect(vect);
double dx = initStep;
double tmpFit, oldFit = prob.eval(pos)[fitCrit];
double tmpFit, oldFit = prob.evaluate(pos)[fitCrit];
int dir = 1;
while (dx > thresh) {
// add a step to tmpP
Mathematics.svvAddScaled(dx * dir, normedVect, pos, tmpP);
// evaluate tmpP
tmpFit = prob.eval(tmpP)[fitCrit];
tmpFit = prob.evaluate(tmpP)[fitCrit];
if (tmpFit < oldFit) {
// if tmpP is better than pos continue at new pos
double[] tmp = pos;
@ -283,7 +283,7 @@ public class F8Problem extends AbstractProblemDoubleOffset
return true;
} else { // the number of optima is corret - now check different offset or rotation by comparing one fitness value
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) {
return true;
} else {
@ -316,7 +316,7 @@ public class F8Problem extends AbstractProblemDoubleOffset
// InterfaceDataTypeDouble tmpIndy;
// tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.template).clone();
// tmpIndy.setDoubleGenotype(pos);
// ((AbstractEAIndividual)tmpIndy).SetFitness(eval(pos));
// ((AbstractEAIndividual)tmpIndy).SetFitness(evaluate(pos));
// population.add(tmpIndy);
// FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(1e-15, 10, false, true);
// int calls = PostProcess.processWithGDA(population, this, convTerm, 0, 0.0000000000000001, 0.01);

View File

@ -29,7 +29,7 @@ public class F9Problem extends AbstractProblemDoubleOffset implements java.io.Se
* @return The m-dimensional output vector.
*/
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
x = rotateMaybe(x);
double[] result = new double[1];
result[0] = yOffset;

View File

@ -82,7 +82,7 @@ public class GPFunctionProblem extends AbstractProblemDouble implements Interfac
}
@Override
public double[] eval(double[] x) {
public double[] evaluate(double[] x) {
if (x.length != dim) {
EVAERROR.errorMsgOnce("mismatching dimension of GPFunctionProblem! Setting to " + x.length);
setProblemDimension(x.length);

View File

@ -14,7 +14,7 @@ public interface InterfaceProblemDouble {
* @param x the vector to evaluate
* @return the target function value
*/
public double[] eval(double[] x);
public double[] evaluate(double[] x);
/**
* Get the problem dimension.

View File

@ -96,7 +96,7 @@ public class MatlabEvalMediator {
logMP(msg);
}
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");
}

View File

@ -1,19 +1,5 @@
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.problems.InterfaceAdditionalPopulationInformer;
@ -34,8 +20,6 @@ import java.util.List;
public class StatisticsStandalone extends AbstractStatistics implements InterfaceStatistics, Serializable {
private static final long serialVersionUID = -8451652609212653368L;
private static String m_MyHostName = "unknown";
// private String m_InfoString;
private ArrayList<ArrayList<Object[]>> m_ResultData = null;
private ArrayList<String> m_ResultHeaderStrings = null;
@ -45,11 +29,6 @@ public class StatisticsStandalone extends AbstractStatistics implements Interfac
public StatisticsStandalone(InterfaceStatisticsParameter statParams) {
super();
statisticsParameter = statParams;
try {
m_MyHostName = InetAddress.getLocalHost().getHostName();
} catch (Exception e) {
System.err.println("ERROR getting HostName " + e.getMessage());
}
}
public StatisticsStandalone(String resultFileName) {

View File

@ -265,9 +265,9 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization
*/
for (int i = 0; i < lastVelocity.length; i++) {
// 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;
chi = inertnessOrChi;
} else {
chi = 1.;
}

View File

@ -77,8 +77,8 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
* InertnessOrChi may contain the inertness or chi parameter depending on
* algoType
*/
protected double m_InertnessOrChi = 0.73;
protected double m_ReduceSpeed = 0.8;
protected double inertnessOrChi = 0.73;
protected double reduceSpeed = 0.8;
private double reduceSpeedOnConstViolation = 0.5;
public static final int defaultType = 0;
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_Phi1 = a.m_Phi1;
this.m_Phi2 = a.m_Phi2;
this.m_InertnessOrChi = a.m_InertnessOrChi;
this.inertnessOrChi = a.inertnessOrChi;
this.m_TopologyRange = a.m_TopologyRange;
this.paramControl = (ParameterControlManager) a.paramControl.clone();
//this.setCheckSpeedLimit(a.isCheckSpeedLimit());
@ -787,7 +787,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
// System.out.println("-- len aft " + vecLen(socCogn));
// rotateAllAxes(neiDiff, .5, false);
// // TODO!!!
// if (algType.getSelectedTag().getID()==1) chi=m_InertnessOrChi;
// if (algType.getSelectedTag().getID()==1) chi=inertnessOrChi;
// else chi = 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++) {
// curVelocity[i] = this.m_InertnessOrChi * lastVelocity[i];
// curVelocity[i] = this.inertnessOrChi * lastVelocity[i];
// curVelocity[i] += scaleCog*socCogn[i];
// curVelocity[i] += scaleNei*neiDiff[i];
// }
// for (int i = 0; i < lastVelocity.length; i++) {
// // the component from the old velocity
// curVelocity[i] = this.m_InertnessOrChi * lastVelocity[i];
// if (algType.getSelectedTag().getID()==1) chi=m_InertnessOrChi;
// curVelocity[i] = this.inertnessOrChi * lastVelocity[i];
// if (algType.getSelectedTag().getID()==1) chi=inertnessOrChi;
// else chi = 1.;
// // the component from the cognition model
// //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));
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];
}
return curVelocity;
@ -844,7 +844,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
// the component from the old velocity
accel[i] = 0;
if (algType.getSelectedTag().getID() == 1) {
chi = m_InertnessOrChi;
chi = inertnessOrChi;
} else {
chi = 1.;
}
@ -891,7 +891,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
// double[] accel = new double[curPosition.length];
// double chi;
//
// if (algType.getSelectedTag().getID()==1) chi=m_InertnessOrChi;
// if (algType.getSelectedTag().getID()==1) chi=inertnessOrChi;
// else chi = 1.;
//
// boolean rotatedVect=false;
@ -1292,7 +1292,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
protected void enforceSpeedLimit(double[] curVelocity, double[][] range, double speedLim) {
while (Mathematics.getRelativeLength(curVelocity, range) > speedLim) {
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
*/
public void setInertnessOrChi(double k) {
this.m_InertnessOrChi = k;
this.inertnessOrChi = k;
}
public double getInertnessOrChi() {
return this.m_InertnessOrChi;
return this.inertnessOrChi;
}
public String inertnessOrChiTipText() {
@ -2212,17 +2212,17 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
double relDiff;
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 {
relDiff = (personalBestfit[0] - ((InterfaceProblemDouble) m_Problem).eval(personalBestPos)[0]); // absolute diff in this case
}// if (personalBestfit[0]!=((InterfaceProblemDouble)problem).eval(personalBestPos)[0]) {
relDiff = (personalBestfit[0] - ((InterfaceProblemDouble) m_Problem).evaluate(personalBestPos)[0]); // absolute diff in this case
}// if (personalBestfit[0]!=((InterfaceProblemDouble)problem).evaluate(personalBestPos)[0]) {
if (Math.abs(relDiff) > 1e-20) {
System.err.println("Warning: mismatching best fitness by " + relDiff);
System.err.println("partInfo: " + i + " - " + getParticleInfo(population.getEAIndividual(i)));
}
if (Math.abs(relDiff) > 1e-10) {
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);
indy.setFitness(personalBestfit);

View File

@ -112,7 +112,7 @@ public class ParticleSwarmOptimizationGCPSO extends ParticleSwarmOptimization {
}
}
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];
}
return curVelocity;

View File

@ -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();
// ((InterfaceDataTypeDouble)indy).setDoubleGenotype(x);
// problem.evaluate(indy);

View File

@ -515,7 +515,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
* }
* // -----------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);
*
* save(" " + iter + " " + evalF+ " ", synthSave);

View File

@ -94,7 +94,7 @@ public class Tribe implements java.io.Serializable {
for (n = 0; n < explorerNb; n++) {
boolean eval = explorer[n].moveExplorer(tribeRank, n, swarm, informOption, prob);
// if (eval) evals++;
// if (evaluate) evals++;
if (pb.constraint) {
explorer[n].constraint(pb.gNb, pb.hNb, pb.ups);

View File

@ -139,7 +139,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
// public int generateExplorer(TribesParam pb,
// TribesSwarm swarm, TribesPosition center, double radius,
// int option, int fromTribe,
// int initType, int eval, int label) {
// int initType, int evaluate, int label) {
// /*
// Generation of a new explorer ("scout")
// If fromTribe=-1, this is the very first generation
@ -148,7 +148,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
// TribesExplorer expl = this;
//
// int d, dmax, dmod;
// int evalF = eval;
// int evalF = evaluate;
// int m;
// // int rank;
// // int shaman;
@ -433,7 +433,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
if (Tribes.blind > 0 && strategy == 6) {
if (RNG.randomDouble() < Tribes.blind) {
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);
swarm.masterTribe.incEvalCnt();
// evalF = position.fitnessEval(pb.function, pb.objective,
// pb.fitnessSize, eval);
// pb.fitnessSize, evaluate);
} else { // Artificial fitness by using penalties
for (n = 0; n < position.fitness.length; n++) {
SetFitness(n, swarm.tribes[fromTribe].memory[

View File

@ -117,9 +117,9 @@ public class TribesPosition implements java.io.Serializable {
//
//// =================================================================== FITNESS EVALUATION
// 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;
// double r;
//
@ -301,7 +301,7 @@ public class TribesPosition implements java.io.Serializable {
// */
// totalError = totalError(fitness, fitnessSize);
//
// return eval+1;
// return evaluate+1;
// }
//
// public double totalError(double[] fitness, int fitnessSize) {

View File

@ -675,7 +675,7 @@ public class JMatLink extends Thread {
// evaluate expression "evalS" in specified engine Ep
if (debugB) {
System.out.println("eval(ep,String) in " + epI + " " + evalS);
System.out.println("evaluate(ep,String) in " + epI + " " + evalS);
}
lockEngineLock();
@ -693,7 +693,7 @@ public class JMatLink extends Thread {
releaseEngineLock();
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