Merging MK revs 383:386 (pimpifications)
This commit is contained in:
parent
87b8877d5d
commit
6142b21ea8
@ -1174,8 +1174,8 @@ public class OptimizerFactory {
|
||||
es.setPlusStrategy(false);
|
||||
cbn.setOptimizer(es);
|
||||
ClusteringDensityBased clustering = new ClusteringDensityBased(0.1);
|
||||
cbn.setConvergenceCA((ClusteringDensityBased) clustering.clone());
|
||||
cbn.setDifferentationCA(clustering);
|
||||
cbn.setMergingCA((ClusteringDensityBased) clustering.clone());
|
||||
cbn.setDifferentiationCA(clustering);
|
||||
cbn.setShowCycle(0); // don't do graphical output
|
||||
|
||||
return makeParams(cbn, 100, problem, randSeed, makeDefaultTerminator());
|
||||
@ -1186,8 +1186,8 @@ public class OptimizerFactory {
|
||||
GeneticAlgorithm ga = new GeneticAlgorithm();
|
||||
cbn.setOptimizer(ga);
|
||||
ClusteringDensityBased clustering = new ClusteringDensityBased(0.1);
|
||||
cbn.setConvergenceCA((ClusteringDensityBased) clustering.clone());
|
||||
cbn.setDifferentationCA(clustering);
|
||||
cbn.setMergingCA((ClusteringDensityBased) clustering.clone());
|
||||
cbn.setDifferentiationCA(clustering);
|
||||
cbn.setShowCycle(0); // don't do graphical output
|
||||
|
||||
return makeParams(cbn, 100, problem, randSeed, makeDefaultTerminator());
|
||||
|
@ -73,7 +73,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
m_Support = support;
|
||||
m_goe = goe;
|
||||
|
||||
//System.out.println("GOEPanel.Constructor !!");
|
||||
//System.out.println("GOEPanel.Constructor ! Backup is " + m_Backup + " " + BeanInspector.toString(m_goe.getValue()));
|
||||
if (!(Proxy.isProxyClass(m_Object.getClass()))) m_Backup = copyObject(m_Object);
|
||||
m_ObjectNames = new DefaultComboBoxModel(new String [0]);
|
||||
m_ObjectChooser = new JComboBox(m_ObjectNames);
|
||||
|
@ -29,7 +29,7 @@ import eva2.tools.jproxy.RMIProxyLocal;
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
/**
|
||||
*
|
||||
* Collect available ModuleAdapter implementations and load them on request.
|
||||
*/
|
||||
public class ModuleServer {
|
||||
public static boolean TRACE = false;
|
||||
@ -117,7 +117,11 @@ public class ModuleServer {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Load the module indicated by the selectedModuleName from all available
|
||||
* module classes; if necessary through a remote proxy. Try to load a given
|
||||
* parameter file in case its a GOModuleAdapter.
|
||||
*
|
||||
* @return the loaded module adapter instance
|
||||
*/
|
||||
public ModuleAdapter createModuleAdapter(String selectedModuleName,
|
||||
MainAdapterClient Client, boolean runWithoutRMI,
|
||||
|
@ -53,8 +53,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
public boolean m_isPenalized = false; // may be set true for penalty based constraints
|
||||
|
||||
protected double[] m_SelectionProbability = new double[1];;
|
||||
public double m_CrossoverProbability = 1.0;
|
||||
public double m_MutationProbability = 0.2;
|
||||
protected double m_CrossoverProbability = 1.0;
|
||||
protected double m_MutationProbability = 0.2;
|
||||
protected InterfaceMutation m_MutationOperator = new NoMutation();
|
||||
protected InterfaceCrossover m_CrossoverOperator = new NoCrossover();
|
||||
// protected String[] m_Identifiers = new String[m_ObjectIncrement];
|
||||
|
@ -23,7 +23,7 @@ import java.util.Comparator;
|
||||
public class AbstractEAIndividualComparator implements Comparator<Object>, Serializable {
|
||||
|
||||
// flag whether a data field should be used.
|
||||
String indyDataKey = null;
|
||||
String indyDataKey = "";
|
||||
int fitCriterion = -1;
|
||||
|
||||
/**
|
||||
@ -34,7 +34,7 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
*
|
||||
*/
|
||||
public AbstractEAIndividualComparator() {
|
||||
this(null, -1);
|
||||
this("", -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,7 +57,7 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
* @param fitnessCriterion
|
||||
*/
|
||||
public AbstractEAIndividualComparator(int fitnessCriterion) {
|
||||
this(null, fitnessCriterion);
|
||||
this("", fitnessCriterion);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,7 +92,7 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
public int compare(Object o1, Object o2) {
|
||||
boolean o1domO2, o2domO1;
|
||||
|
||||
if (indyDataKey != null) {
|
||||
if (indyDataKey != null && (indyDataKey.length()>0)) {
|
||||
double[] fit1 = (double[])((AbstractEAIndividual)o1).getData(indyDataKey);
|
||||
double[] fit2 = (double[])((AbstractEAIndividual)o2).getData(indyDataKey);
|
||||
if (fitCriterion < 0) {
|
||||
@ -114,4 +114,31 @@ public class AbstractEAIndividualComparator implements Comparator<Object>, Seria
|
||||
if (o1domO2 ^ o2domO1) return (o1domO2 ? -1 : 1);
|
||||
else return 0; // these are not comparable
|
||||
}
|
||||
|
||||
public String getIndyDataKey() {
|
||||
return indyDataKey;
|
||||
}
|
||||
public void setIndyDataKey(String indyDataKey) {
|
||||
this.indyDataKey = indyDataKey;
|
||||
}
|
||||
public String indyDataKeyTipText() {
|
||||
return "A String can be given which retrievies individual properties based on which the comparison is performed.";
|
||||
}
|
||||
|
||||
public int getFitCriterion() {
|
||||
return fitCriterion;
|
||||
}
|
||||
public void setFitCriterion(int fitCriterion) {
|
||||
this.fitCriterion = fitCriterion;
|
||||
}
|
||||
public String fitCriterionTipText() {
|
||||
return "If -1, dominance is used, otherwise the indexed fitness criterion (for multiobjective problems)";
|
||||
}
|
||||
|
||||
public String globalInfo() {
|
||||
return "A comparator class for general EA individuals. Compares individuals based on their fitness in context of minimization.";
|
||||
}
|
||||
public String getName() {
|
||||
return "IndividualComparator";
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package eva2.server.go.individuals;
|
||||
import java.util.BitSet;
|
||||
|
||||
import eva2.server.go.operators.crossover.CrossoverGANPoint;
|
||||
import eva2.server.go.operators.crossover.InterfaceCrossover;
|
||||
import eva2.server.go.operators.mutation.InterfaceMutation;
|
||||
import eva2.server.go.operators.mutation.MutateGAStandard;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
@ -40,7 +41,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
|
||||
// cloning the members of AbstractEAIndividual
|
||||
this.m_Age = individual.m_Age;
|
||||
this.m_CrossoverOperator = individual.m_CrossoverOperator;
|
||||
this.m_CrossoverOperator = (InterfaceCrossover)individual.m_CrossoverOperator.clone();
|
||||
this.m_CrossoverProbability = individual.m_CrossoverProbability;
|
||||
this.m_MutationOperator = (InterfaceMutation)individual.m_MutationOperator.clone();
|
||||
this.m_MutationProbability = individual.m_MutationProbability;
|
||||
|
@ -6,6 +6,7 @@ import java.util.BitSet;
|
||||
import eva2.server.go.individuals.codings.ga.GAStandardCodingDouble;
|
||||
import eva2.server.go.individuals.codings.ga.InterfaceGADoubleCoding;
|
||||
import eva2.server.go.operators.crossover.CrossoverGANPoint;
|
||||
import eva2.server.go.operators.crossover.InterfaceCrossover;
|
||||
import eva2.server.go.operators.mutation.InterfaceMutation;
|
||||
import eva2.server.go.operators.mutation.MutateGAStandard;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
@ -55,7 +56,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
|
||||
// cloning the members of AbstractEAIndividual
|
||||
this.m_Age = individual.m_Age;
|
||||
this.m_CrossoverOperator = individual.m_CrossoverOperator;
|
||||
this.m_CrossoverOperator = (InterfaceCrossover)individual.m_CrossoverOperator.clone();
|
||||
this.m_CrossoverProbability = individual.m_CrossoverProbability;
|
||||
this.m_MutationOperator = (InterfaceMutation)individual.m_MutationOperator.clone();
|
||||
this.m_MutationProbability = individual.m_MutationProbability;
|
||||
|
@ -151,7 +151,7 @@ public class ClusteringDensityBased implements InterfaceClustering, java.io.Seri
|
||||
* @param species2 The second species.
|
||||
* @return True if species converge, else False.
|
||||
*/
|
||||
public boolean convergingSpecies(Population species1, Population species2) {
|
||||
public boolean mergingSpecies(Population species1, Population species2) {
|
||||
if (m_TestConvergingSpeciesOnBestOnly) {
|
||||
if (this.m_Metric.distance(species1.getBestEAIndividual(), species2.getBestEAIndividual()) < this.m_ClusterDistance) return true;
|
||||
else return false;
|
||||
|
@ -167,7 +167,7 @@ public class ClusteringHierarchical implements InterfaceClustering, Serializable
|
||||
* @param species2 The second species.
|
||||
* @return True if species converge, else False.
|
||||
*/
|
||||
public boolean convergingSpecies(Population species1, Population species2) {
|
||||
public boolean mergingSpecies(Population species1, Population species2) {
|
||||
if (testConvergingSpeciesOnBestOnly) {
|
||||
if (this.metric.distance(species1.getBestEAIndividual(), species2.getBestEAIndividual()) < this.currentDistThreshold()) return true;
|
||||
else return false;
|
||||
|
@ -24,7 +24,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
|
||||
|
||||
public int m_K = 5;
|
||||
public double[][] m_C = null;
|
||||
public boolean m_UseSearchSpace = false;
|
||||
public boolean m_UseSearchSpace = true;
|
||||
public boolean m_ReuseC = false;
|
||||
public boolean m_Debug = false;
|
||||
|
||||
@ -278,7 +278,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
|
||||
* @param species2 The second species.
|
||||
* @return True if species converge, else False.
|
||||
*/
|
||||
public boolean convergingSpecies(Population species1, Population species2) {
|
||||
public boolean mergingSpecies(Population species1, Population species2) {
|
||||
// @todo i could use the BIC metric from X-means to calculate this
|
||||
return false;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
* @param species2 The second species.
|
||||
* @return True if species converge, else False.
|
||||
*/
|
||||
public boolean convergingSpecies(Population species1, Population species2) {
|
||||
public boolean mergingSpecies(Population species1, Population species2) {
|
||||
// @todo i could use the BIC metric from X-means to calculate this
|
||||
return false;
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ public interface InterfaceClustering {
|
||||
*/
|
||||
public Population[] cluster(Population pop);
|
||||
|
||||
/** This method allows you to decide if two species converge.
|
||||
/** This method allows you to decide if two species are to be merged regarding this clustering algorithm.
|
||||
* @param species1 The first species.
|
||||
* @param species2 The second species.
|
||||
* @return True if species converge, else False.
|
||||
*/
|
||||
public boolean convergingSpecies(Population species1, Population species2);
|
||||
public boolean mergingSpecies(Population species1, Population species2);
|
||||
|
||||
/** This method decides if an unclustered individual belongs to an already established species.
|
||||
* @param indy A unclustered individual.
|
||||
|
@ -34,7 +34,45 @@ public class EuclideanMetric implements InterfaceDistanceMetric {
|
||||
}
|
||||
return Math.sqrt(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* The euclidean distance normed by the given ranges lying between 0 and sqrt(n)
|
||||
* for n dimensions.
|
||||
*
|
||||
* @param pos1
|
||||
* @param range1
|
||||
* @param pos2
|
||||
* @param range2
|
||||
* @return
|
||||
*/
|
||||
public static double normedEuclideanDistance(double[] pos1, double[][] range1, double[] pos2, double[][] range2) {
|
||||
double tmpResult = 0, tmp=0;
|
||||
|
||||
for (int i = 0; (i < pos1.length) && (i < pos2.length); i++) {
|
||||
tmp=((pos1[i] - range1[i][0])/(range1[i][1] - range1[i][0])) - ((pos2[i] - range2[i][0])/(range2[i][1] - range2[i][0]));
|
||||
tmpResult += (tmp*tmp);
|
||||
}
|
||||
return Math.sqrt(tmpResult);
|
||||
}
|
||||
|
||||
public static double squaredEuclideanDistance(double[] v1, double[] v2) {
|
||||
double tmp, result = 0;
|
||||
for (int i = 0; (i < v1.length) && (i < v2.length); i++) {
|
||||
tmp=v1[i] - v2[i];
|
||||
result += (tmp*tmp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double euclideanDistance(double[] v1, double[] v2) {
|
||||
double result = 0, tmp=0;
|
||||
for (int i = 0; (i < v1.length) && (i < v2.length); i++) {
|
||||
tmp = v1[i] - v2[i];
|
||||
result += (tmp*tmp);
|
||||
}
|
||||
return Math.sqrt(result);
|
||||
}
|
||||
|
||||
/** This method returns a global info string
|
||||
* @return description
|
||||
*/
|
||||
|
@ -157,34 +157,6 @@ public class PhenotypeMetric implements InterfaceDistanceMetric, java.io.Seriali
|
||||
if (pMetric == null) pMetric = new PhenotypeMetric();
|
||||
return pMetric.distance(indy1, indy2);
|
||||
}
|
||||
|
||||
public static double euclidianDistance(double[] v1, double[] v2) {
|
||||
double result = 0, tmp=0;
|
||||
for (int i = 0; (i < v1.length) && (i < v2.length); i++) {
|
||||
tmp = v1[i] - v2[i];
|
||||
result += (tmp*tmp);
|
||||
}
|
||||
return Math.sqrt(result);
|
||||
}
|
||||
|
||||
public static double squaredEuclidianDistance(double[] v1, double[] v2) {
|
||||
double tmp, result = 0;
|
||||
for (int i = 0; (i < v1.length) && (i < v2.length); i++) {
|
||||
tmp=v1[i] - v2[i];
|
||||
result += (tmp*tmp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double normedDistance(double[] pos1, double[][] range1, double[] pos2, double[][] range2) {
|
||||
double tmpResult = 0, tmp=0;
|
||||
|
||||
for (int i = 0; (i < pos1.length) && (i < pos2.length); i++) {
|
||||
tmp=((pos1[i] - range1[i][0])/(range1[i][1] - range1[i][0])) - ((pos2[i] - range2[i][0])/(range2[i][1] - range2[i][0]));
|
||||
tmpResult += (tmp*tmp);
|
||||
}
|
||||
return Math.sqrt(tmpResult);
|
||||
}
|
||||
|
||||
public static double norm(AbstractEAIndividual indy) {
|
||||
double result = 0;
|
||||
|
@ -202,7 +202,7 @@ public class MutateESLocal implements InterfaceMutation, java.io.Serializable {
|
||||
return this.m_MutationStepSize;
|
||||
}
|
||||
public String mutationStepSizeTipText() {
|
||||
return "Choose the initial mutation step size.";
|
||||
return "Choose the initial mutation step size sigma.";
|
||||
}
|
||||
|
||||
/** Set the lower limit for the mutation step size with this method.
|
||||
|
@ -120,6 +120,11 @@ public class MutateESSuccessRule extends MutateESFixedStepSize implements Interf
|
||||
public String alphaTipText() {
|
||||
return "Choose the factor > 1 by which the mutation step size is to be increased/decreased.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sigmaTipText() {
|
||||
return "The initial step size.";
|
||||
}
|
||||
|
||||
public void adaptAfterSelection(Population oldGen, Population selected) {
|
||||
// nothing to do here
|
||||
|
@ -20,6 +20,7 @@ import eva2.server.go.individuals.InterfaceESIndividual;
|
||||
import eva2.server.go.operators.cluster.ClusteringDensityBased;
|
||||
import eva2.server.go.operators.cluster.InterfaceClustering;
|
||||
import eva2.server.go.operators.crossover.CrossoverESDefault;
|
||||
import eva2.server.go.operators.distancemetric.EuclideanMetric;
|
||||
import eva2.server.go.operators.distancemetric.InterfaceDistanceMetric;
|
||||
import eva2.server.go.operators.distancemetric.PhenotypeMetric;
|
||||
import eva2.server.go.operators.mutation.InterfaceMutation;
|
||||
@ -845,7 +846,7 @@ public class PostProcess {
|
||||
|
||||
clust.SetFunctionCalls(evalsBefore + evalsDone);
|
||||
|
||||
double improvement = PhenotypeMetric.euclidianDistance(meanFit, clust.getMeanFitness());
|
||||
double improvement = EuclideanMetric.euclideanDistance(meanFit, clust.getMeanFitness());
|
||||
if (TRACE) System.out.println("improvement by " + improvement + " funcalls done: " + evalsDone);
|
||||
return new Pair<Population, Double>(clust, improvement);
|
||||
}
|
||||
@ -1007,7 +1008,7 @@ public class PostProcess {
|
||||
boolean found=false;
|
||||
for (int k=0; k<candidates.size(); k++) {
|
||||
if (k!=i) {
|
||||
double dist = PhenotypeMetric.euclidianDistance(AbstractEAIndividual.getDoublePositionShallow(indy), AbstractEAIndividual.getDoublePositionShallow(candidates.getEAIndividual(k)));
|
||||
double dist = EuclideanMetric.euclideanDistance(AbstractEAIndividual.getDoublePositionShallow(indy), AbstractEAIndividual.getDoublePositionShallow(candidates.getEAIndividual(k)));
|
||||
if (dist == 0.) {
|
||||
// System.err.println("error, equal candidates in findNMSPerturb!");
|
||||
} else if (dist < minDistNeighbour) {
|
||||
@ -1093,7 +1094,7 @@ public class PostProcess {
|
||||
else {
|
||||
double[] indyPos = AbstractEAIndividual.getDoublePositionShallow(pop.getEAIndividual(index));
|
||||
for (int i=0; i<pop.size(); i++) {
|
||||
if (i!=index) distSum += PhenotypeMetric.euclidianDistance(AbstractEAIndividual.getDoublePositionShallow(pop.getEAIndividual(i)), indyPos);
|
||||
if (i!=index) distSum += EuclideanMetric.euclideanDistance(AbstractEAIndividual.getDoublePositionShallow(pop.getEAIndividual(i)), indyPos);
|
||||
}
|
||||
return distSum/((double)cnt);
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ package eva2.server.go.operators.terminators;
|
||||
import java.io.Serializable;
|
||||
|
||||
import eva2.gui.BeanInspector;
|
||||
import eva2.server.go.IndividualInterface;
|
||||
import eva2.server.go.InterfaceTerminator;
|
||||
import eva2.server.go.PopulationInterface;
|
||||
import eva2.server.go.operators.distancemetric.EuclideanMetric;
|
||||
import eva2.server.go.operators.distancemetric.PhenotypeMetric;
|
||||
import eva2.server.go.populations.InterfaceSolutionSet;
|
||||
import eva2.server.go.problems.InterfaceOptimizationProblem;
|
||||
@ -139,7 +139,7 @@ Serializable {
|
||||
*/
|
||||
protected boolean isStillConverged(PopulationInterface pop) {
|
||||
double[] curFit = pop.getBestFitness();
|
||||
double dist = PhenotypeMetric.euclidianDistance(oldFit, curFit);
|
||||
double dist = EuclideanMetric.euclideanDistance(oldFit, curFit);
|
||||
boolean ret;
|
||||
if (convergenceCondition.isSelectedString("Relative")) {
|
||||
ret = (dist < (oldNorm * convThresh));
|
||||
|
@ -15,6 +15,7 @@ import eva2.server.go.individuals.AbstractEAIndividual;
|
||||
import eva2.server.go.individuals.AbstractEAIndividualComparator;
|
||||
import eva2.server.go.individuals.GAIndividualBinaryData;
|
||||
import eva2.server.go.individuals.InterfaceDataTypeDouble;
|
||||
import eva2.server.go.operators.distancemetric.EuclideanMetric;
|
||||
import eva2.server.go.operators.distancemetric.InterfaceDistanceMetric;
|
||||
import eva2.server.go.operators.distancemetric.PhenotypeMetric;
|
||||
import eva2.server.go.operators.selection.probability.AbstractSelProb;
|
||||
@ -26,7 +27,14 @@ import eva2.tools.math.Jama.Matrix;
|
||||
import eva2.tools.tool.StatisticUtils;
|
||||
|
||||
|
||||
/** This is a basic implementation for a EA Population.
|
||||
/**
|
||||
* A basic implementation of an EA population. Manage a set of potential solutions
|
||||
* in form of AbstractEAIndividuals. They can be sorted using an AbstractEAIndividualComparator.
|
||||
* Optionally, a history list is kept storing a clone of the best individual of any generation.
|
||||
* The Population also provides for appropriate counting of function calls performed.
|
||||
* For initialization, the default individual initialization method may be used, as well as a
|
||||
* random latin hypercube implementation for InterfaceDataTypeDouble individuals.
|
||||
*
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Felix Streichert, Marcel Kronfeld
|
||||
@ -342,7 +350,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
||||
* Stagnation measured etc. pp.
|
||||
*/
|
||||
public void incrGeneration() {
|
||||
if (useHistory && (this.size() >= 1)) this.m_History.add(this.getBestEAIndividual());
|
||||
if (useHistory && (this.size() >= 1)) this.m_History.add((AbstractEAIndividual)this.getBestEAIndividual().clone());
|
||||
for (int i=0; i<size(); i++) ((AbstractEAIndividual)get(i)).incrAge();
|
||||
this.m_Generation++;
|
||||
firePropertyChangedEvent(nextGenerationPerformed);
|
||||
@ -947,9 +955,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
||||
}
|
||||
}
|
||||
|
||||
/** This method will remove double instances from the population.
|
||||
* This method relies on the implementation of the equals method
|
||||
* in the individuals.
|
||||
/** This method will remove instances with equal fitness from the population.
|
||||
*/
|
||||
public void removeDoubleInstancesUsingFitness() {
|
||||
for (int i = 0; i < this.size(); i++) {
|
||||
@ -1255,7 +1261,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
||||
|
||||
for (int i = 0; i < this.size(); i++) {
|
||||
for (int j = i+1; j < this.size(); j++) {
|
||||
if (metric == null) d = PhenotypeMetric.euclidianDistance(AbstractEAIndividual.getDoublePositionShallow(getEAIndividual(i)),
|
||||
if (metric == null) d = EuclideanMetric.euclideanDistance(AbstractEAIndividual.getDoublePositionShallow(getEAIndividual(i)),
|
||||
AbstractEAIndividual.getDoublePositionShallow(getEAIndividual(j)));
|
||||
else d = metric.distance((AbstractEAIndividual)this.get(i), (AbstractEAIndividual)this.get(j));
|
||||
meanDist += d;
|
||||
@ -1329,7 +1335,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
AbstractEAIndividual indy = pop.getEAIndividual(i);
|
||||
double[] indyPos = AbstractEAIndividual.getDoublePositionShallow(indy);
|
||||
double curDist = PhenotypeMetric.euclidianDistance(pos, indyPos);
|
||||
double curDist = EuclideanMetric.euclideanDistance(pos, indyPos);
|
||||
if ((dist<0) || (!closestOrFarthest && (dist < curDist))
|
||||
|| (closestOrFarthest && (dist > curDist))) {
|
||||
dist = curDist;
|
||||
@ -1411,7 +1417,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
||||
for (int i = 0; i < size(); ++i){
|
||||
AbstractEAIndividual currentindy = getEAIndividual(i);
|
||||
if (!indy.equals(currentindy)){ // dont compare particle to itself or a copy of itself
|
||||
double dist = PhenotypeMetric.euclidianDistance(AbstractEAIndividual.getDoublePositionShallow(indy),
|
||||
double dist = EuclideanMetric.euclideanDistance(AbstractEAIndividual.getDoublePositionShallow(indy),
|
||||
AbstractEAIndividual.getDoublePositionShallow(currentindy));
|
||||
if (dist < mindist){
|
||||
mindist = dist;
|
||||
@ -1448,7 +1454,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
||||
if (normalizedPhenoMetric){
|
||||
d = metric.distance(indy, neighbor);
|
||||
} else {
|
||||
d = PhenotypeMetric.euclidianDistance(AbstractEAIndividual.getDoublePositionShallow(indy),
|
||||
d = EuclideanMetric.euclideanDistance(AbstractEAIndividual.getDoublePositionShallow(indy),
|
||||
AbstractEAIndividual.getDoublePositionShallow(neighbor));
|
||||
}
|
||||
if (calcVariance) distances.add(d);
|
||||
|
@ -17,7 +17,7 @@ import eva2.tools.EVAERROR;
|
||||
public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDouble implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown {
|
||||
protected static InterfaceDistanceMetric m_Metric = new PhenotypeMetric();
|
||||
private double m_GlobalOpt = 0;
|
||||
protected Population m_Optima;
|
||||
protected Population m_ListOfOptima;
|
||||
protected double m_Epsilon = 0.05;
|
||||
// protected double[][] m_Range;
|
||||
// protected double[] m_Extrema;
|
||||
@ -36,8 +36,8 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
|
||||
|
||||
protected void cloneObjects(AbstractMultiModalProblemKnown b) {
|
||||
super.cloneObjects(b);
|
||||
if (b.m_Optima != null)
|
||||
this.m_Optima = (Population)((Population)b.m_Optima).clone();
|
||||
if (b.m_ListOfOptima != null)
|
||||
this.m_ListOfOptima = (Population)((Population)b.m_ListOfOptima).clone();
|
||||
// if (b.m_Range != null) {
|
||||
// this.m_Range = new double[b.m_Range.length][b.m_Range[0].length];
|
||||
// for (int i = 0; i < this.m_Range.length; i++) {
|
||||
@ -87,9 +87,9 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
|
||||
// population init must be last
|
||||
// it set's fitcalls and generation to zero
|
||||
population.init();
|
||||
if (m_Optima == null) {
|
||||
if (m_ListOfOptima == null) {
|
||||
this.m_GlobalOpt = Double.NEGATIVE_INFINITY;
|
||||
m_Optima = new Population();
|
||||
m_ListOfOptima = new Population();
|
||||
this.initListOfOptima();
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
|
||||
public void initProblem() {
|
||||
super.initProblem();
|
||||
this.m_GlobalOpt = Double.NEGATIVE_INFINITY;
|
||||
m_Optima = new Population();
|
||||
m_ListOfOptima = new Population();
|
||||
this.initListOfOptima();
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
|
||||
m_GlobalOpt = tmp;
|
||||
}
|
||||
}
|
||||
this.m_Optima.add(tmpIndy);
|
||||
this.m_ListOfOptima.add(tmpIndy);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,7 +210,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
|
||||
* @return population
|
||||
*/
|
||||
public Population getRealOptima() {
|
||||
return this.m_Optima;
|
||||
return this.m_ListOfOptima;
|
||||
}
|
||||
|
||||
/** This method returns the Number of Identified optima
|
||||
|
@ -5,6 +5,7 @@ import java.util.BitSet;
|
||||
import eva2.server.go.individuals.AbstractEAIndividual;
|
||||
import eva2.server.go.individuals.GAIndividualBinaryData;
|
||||
import eva2.server.go.individuals.InterfaceDataTypeBinary;
|
||||
import eva2.server.go.individuals.InterfaceGAIndividual;
|
||||
import eva2.server.go.populations.Population;
|
||||
import eva2.server.go.strategies.InterfaceOptimizer;
|
||||
|
||||
@ -16,8 +17,10 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
|
||||
}
|
||||
|
||||
protected void initTemplate() {
|
||||
this.m_Template = new GAIndividualBinaryData();
|
||||
((InterfaceDataTypeBinary)this.m_Template).setBinaryDataLength(this.getProblemDimension());
|
||||
if (m_Template == null) this.m_Template = new GAIndividualBinaryData();
|
||||
if (((InterfaceGAIndividual)this.m_Template).getGenotypeLength()!=this.getProblemDimension()) {
|
||||
((InterfaceDataTypeBinary)this.m_Template).setBinaryDataLength(this.getProblemDimension());
|
||||
}
|
||||
}
|
||||
|
||||
public void cloneObjects(AbstractProblemBinary o) {
|
||||
|
@ -23,7 +23,7 @@ import eva2.server.go.strategies.InterfaceOptimizer;
|
||||
|
||||
import eva2.server.go.problems.Interface2DBorderProblem;
|
||||
|
||||
public class ExternalRuntimeProblem extends AbstractOptimizationProblem implements Interface2DBorderProblem {
|
||||
public class ExternalRuntimeProblem extends AbstractOptimizationProblem implements Interface2DBorderProblem, InterfaceProblemDouble {
|
||||
|
||||
protected AbstractEAIndividual m_OverallBest = null;
|
||||
protected int m_ProblemDimension = 10;
|
||||
@ -53,8 +53,17 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem implemen
|
||||
writer.write(c);
|
||||
writer.flush();
|
||||
}
|
||||
// System.out.println("monitor-thread finished!");
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace(System.err);
|
||||
} finally {
|
||||
try {
|
||||
reader.close();
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -115,7 +124,7 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem implemen
|
||||
population.init();
|
||||
}
|
||||
|
||||
protected double[][] makeRange() {
|
||||
public double[][] makeRange() {
|
||||
double[][] range = new double[this.m_ProblemDimension][2];
|
||||
for (int i = 0; i < range.length; i++) {
|
||||
range[i][0] = getRangeLowerBound(i);
|
||||
@ -124,11 +133,11 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem implemen
|
||||
return range;
|
||||
}
|
||||
|
||||
protected double getRangeLowerBound(int dim) {
|
||||
public double getRangeLowerBound(int dim) {
|
||||
return m_lowerBound;
|
||||
}
|
||||
|
||||
protected double getRangeUpperBound(int dim) {
|
||||
public double getRangeUpperBound(int dim) {
|
||||
return m_upperBound;
|
||||
}
|
||||
|
||||
@ -137,14 +146,13 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem implemen
|
||||
}
|
||||
|
||||
/** This method evaluate a single individual and sets the fitness values
|
||||
* @param individual The individual that is to be evalutated
|
||||
* @param individual The individual that is to be evaluatated
|
||||
*/
|
||||
public void evaluate(AbstractEAIndividual individual) {
|
||||
double[] x;
|
||||
// double[] fitness;
|
||||
|
||||
x = new double[((InterfaceDataTypeDouble) individual).getDoubleData().length];
|
||||
System.arraycopy(((InterfaceDataTypeDouble) individual).getDoubleData(), 0, x, 0, x.length);
|
||||
x = getXVector(individual);
|
||||
|
||||
//TODO call external runtime
|
||||
double[] fit = eval(x);
|
||||
@ -158,22 +166,20 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem implemen
|
||||
}
|
||||
}
|
||||
|
||||
protected double[] eval(double[] x) {
|
||||
protected double[] getXVector(AbstractEAIndividual individual) {
|
||||
double[] x;
|
||||
x = new double[((InterfaceDataTypeDouble) individual).getDoubleData().length];
|
||||
System.arraycopy(((InterfaceDataTypeDouble) individual).getDoubleData(), 0, x, 0, x.length);
|
||||
return x;
|
||||
}
|
||||
|
||||
public static List<String> runProcess(List<String> parameters, String workingDir) {
|
||||
Process process;
|
||||
ProcessBuilder pb;
|
||||
|
||||
ArrayList<Double> fitList = new ArrayList<Double>();
|
||||
List<String> results = new ArrayList<String>();
|
||||
try {
|
||||
List<String> parameters=new ArrayList<String>();
|
||||
parameters.add(this.m_Command);
|
||||
if (additionalArg!=null && (additionalArg.length()>0)) {
|
||||
parameters.add(additionalArg);
|
||||
}
|
||||
for(int i=0;i<this.m_ProblemDimension;i++){
|
||||
parameters.add(new String(""+x[i]));
|
||||
}
|
||||
pb = new ProcessBuilder(parameters);
|
||||
pb.directory(new File(this.m_WorkingDir));
|
||||
pb.directory(new File(workingDir));
|
||||
process=pb.start();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
Thread thread = new MonitorInputStreamThread(process.getErrorStream());//grab the Error Stream
|
||||
@ -184,24 +190,58 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem implemen
|
||||
if (line.contains(" ")) {
|
||||
String[] parts = line.split(" ");
|
||||
for (String str : parts) {
|
||||
fitList.add(new Double(str));
|
||||
results.add(str);
|
||||
}
|
||||
} else {
|
||||
fitList.add(new Double(line));
|
||||
results.add(line);
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
System.err.println("IO Error in ExternalRuntimeProblem!");
|
||||
e.printStackTrace();
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Error: " + m_Command + " delivered malformatted output for " + BeanInspector.toString(x));
|
||||
System.err.println("IO Error when calling external command!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
double[] fit = new double[fitList.size()];
|
||||
for (int i=0; i<fit.length; i++) {
|
||||
fit[i] = fitList.get(i);
|
||||
}
|
||||
return fit;
|
||||
return results;
|
||||
}
|
||||
|
||||
public double[] eval(double[] x) {
|
||||
if (x==null) throw new RuntimeException("Error, x=null value received in ExternalRuntimeProblem.eval");
|
||||
ArrayList<Double> fitList = new ArrayList<Double>();
|
||||
|
||||
List<String> parameters=new ArrayList<String>();
|
||||
parameters.add(this.m_Command);
|
||||
if (additionalArg!=null && (additionalArg.length()>0)) parameters.add(additionalArg);
|
||||
for(int i=0;i<this.m_ProblemDimension;i++){
|
||||
String p = prepareParameter(x, i);
|
||||
parameters.add(p);
|
||||
}
|
||||
|
||||
List<String> res = runProcess(parameters, m_WorkingDir);
|
||||
try {
|
||||
for (String str : res) {
|
||||
fitList.add(new Double(str));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Error: " + m_Command + " delivered malformatted output for " + BeanInspector.toString(x));
|
||||
e.printStackTrace();
|
||||
}
|
||||
double[] fit = new double[fitList.size()];
|
||||
for (int i=0; i<fit.length; i++) {
|
||||
fit[i] = fitList.get(i);
|
||||
}
|
||||
return fit;
|
||||
}
|
||||
|
||||
/**
|
||||
* How to prepare a given parameter within a double array to present it
|
||||
* to the external program.
|
||||
*
|
||||
* @param x
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
protected String prepareParameter(double[] x, int i) {
|
||||
return new String(""+x[i]);
|
||||
}
|
||||
|
||||
/** This method returns a string describing the optimization problem.
|
||||
|
@ -13,9 +13,18 @@ import eva2.server.go.populations.Population;
|
||||
|
||||
public interface InterfaceLocalSearchable extends InterfaceOptimizationProblem {
|
||||
|
||||
|
||||
/**
|
||||
* Perform a single local search step on each of the given individuals.
|
||||
*
|
||||
* @param pop
|
||||
*/
|
||||
public void doLocalSearch(Population pop);
|
||||
|
||||
/**
|
||||
* Estimate the cost of one local search step -- more precisely the cost of the doLocalSearch call per one individual.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double getLocalSearchStepFunctionCallEquivalent();
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import eva2.gui.BeanInspector;
|
||||
import eva2.gui.Chart2DDPointIconCircle;
|
||||
import eva2.gui.Chart2DDPointIconText;
|
||||
import eva2.gui.GenericObjectEditor;
|
||||
import eva2.gui.GraphPointSet;
|
||||
import eva2.gui.Plot;
|
||||
import eva2.gui.TopoPlot;
|
||||
@ -65,7 +66,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
// private boolean m_UseClearing = false;
|
||||
private boolean m_UseArchive = true;
|
||||
private boolean m_UseSpeciesDifferentation = true;
|
||||
private boolean m_UseSpeciesConvergence = true;
|
||||
private boolean m_UseSpeciesMerging = true;
|
||||
// private boolean m_UseHaltingWindow = true;
|
||||
private int m_PopulationSize = 50;
|
||||
private int convergedCnt = 0;
|
||||
@ -96,7 +97,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
this.m_minGroupSize = a.m_minGroupSize;
|
||||
// this.m_UseClearing = a.m_UseClearing;
|
||||
this.m_UseSpeciesDifferentation = a.m_UseSpeciesDifferentation;
|
||||
this.m_UseSpeciesConvergence = a.m_UseSpeciesConvergence;
|
||||
this.m_UseSpeciesMerging = a.m_UseSpeciesMerging;
|
||||
// this.m_UseHaltingWindow = a.m_UseHaltingWindow;
|
||||
this.m_PopulationSize = a.m_PopulationSize;
|
||||
this.haltingWindow = a.haltingWindow;
|
||||
@ -140,7 +141,11 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
this.m_Undifferentiated = m_Optimizer.getPopulation(); // required for changes to the population by the optimizer
|
||||
this.firePropertyChangedEvent("FirstGenerationPerformed");
|
||||
}
|
||||
|
||||
|
||||
public void hideHideable() {
|
||||
GenericObjectEditor.setHideProperty(this.getClass(), "population", true);
|
||||
setUseMerging(isUseMerging());
|
||||
}
|
||||
/** This method will evaluate the current population using the
|
||||
* given problem.
|
||||
* @param population The population that is to be evaluated
|
||||
@ -511,7 +516,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
//if (this.m_Show) this.plot();
|
||||
}
|
||||
|
||||
if (this.m_UseSpeciesConvergence) {
|
||||
if (this.m_UseSpeciesMerging) {
|
||||
///////////////////////////// species convergence phase
|
||||
if (TRACE) {
|
||||
System.out.println("-Species convergence:");
|
||||
@ -549,7 +554,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
spec1 = (Population)this.m_Species.get(i1);
|
||||
for (int i2 = i1+1; i2 < this.m_Species.size(); i2++) {
|
||||
spec2 = (Population)this.m_Species.get(i2);
|
||||
if (this.m_CAForSpeciesConvergence.convergingSpecies(spec1, spec2)) {
|
||||
if (this.m_CAForSpeciesConvergence.mergingSpecies(spec1, spec2)) {
|
||||
if (TRACE) System.out.println("--------------------Merging species (" + i1 +", " +i2 +") ["+spec1.size()+"/"+spec2.size()+"]");
|
||||
// this.m_CAForSpeciesConvergence.convergingSpecies(spec1, spec2);
|
||||
if (isActive(spec1) && isActive(spec2)) {
|
||||
@ -756,13 +761,13 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
* of species differentiation.
|
||||
* @return The current status of this flag
|
||||
*/
|
||||
public boolean getApplyDifferentation() {
|
||||
public boolean getApplyDifferentiation() {
|
||||
return this.m_UseSpeciesDifferentation;
|
||||
}
|
||||
public void setApplyDifferentation(boolean b){
|
||||
public void setApplyDifferentiation(boolean b){
|
||||
this.m_UseSpeciesDifferentation = b;
|
||||
}
|
||||
public String applyDifferentationTipText() {
|
||||
public String applyDifferentiationTipText() {
|
||||
return "Toggle the species differentation mechanism.";
|
||||
}
|
||||
|
||||
@ -792,18 +797,19 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
return "With a halting window converged species are frozen.";
|
||||
}
|
||||
|
||||
/** This method allows you to set/get the switch that toggels the use
|
||||
/** This method allows you to set/get the switch that toggles the use
|
||||
* of species convergence.
|
||||
* @return The current status of this flag
|
||||
*/
|
||||
public boolean getApplyConvergence() {
|
||||
return this.m_UseSpeciesConvergence;
|
||||
public boolean isUseMerging() {
|
||||
return this.m_UseSpeciesMerging;
|
||||
}
|
||||
public void setApplyConvergence(boolean b){
|
||||
this.m_UseSpeciesConvergence = b;
|
||||
public void setUseMerging(boolean b){
|
||||
this.m_UseSpeciesMerging = b;
|
||||
GenericObjectEditor.setHideProperty(this.getClass(), "mergingCA", !m_UseSpeciesMerging);
|
||||
}
|
||||
public String applyConvergenceTipText() {
|
||||
return "Toggle the species convergence mechanism.";
|
||||
public String useMergingTipText() {
|
||||
return "Toggle the use of species merging.";
|
||||
}
|
||||
|
||||
/** Choose a population based optimizing technique to use
|
||||
@ -826,27 +832,27 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
/** The cluster algorithm on which the species differentiation is based
|
||||
* @return The current clustering method
|
||||
*/
|
||||
public InterfaceClustering getDifferentationCA() {
|
||||
public InterfaceClustering getDifferentiationCA() {
|
||||
return this.m_CAForSpeciesDifferentation;
|
||||
}
|
||||
public void setDifferentationCA(InterfaceClustering b){
|
||||
public void setDifferentiationCA(InterfaceClustering b){
|
||||
this.m_CAForSpeciesDifferentation = b;
|
||||
}
|
||||
public String differentationCATipText() {
|
||||
public String differentiationCATipText() {
|
||||
return "The cluster algorithm on which the species differentation is based.";
|
||||
}
|
||||
|
||||
/** The Cluster Algorithm on which the species convergence is based.
|
||||
* @return The current clustering method
|
||||
*/
|
||||
public InterfaceClustering getConvergenceCA() {
|
||||
public InterfaceClustering getMergingCA() {
|
||||
return this.m_CAForSpeciesConvergence;
|
||||
}
|
||||
public void setConvergenceCA(InterfaceClustering b){
|
||||
public void setMergingCA(InterfaceClustering b){
|
||||
this.m_CAForSpeciesConvergence = b;
|
||||
}
|
||||
public String convergenceCATipText() {
|
||||
return "The cluster algorithm on which the species convergence is based.";
|
||||
public String mergingCATipText() {
|
||||
return "The cluster algorithm on which the species merging is based.";
|
||||
}
|
||||
|
||||
public void setUseArchive(boolean v) {
|
||||
@ -869,7 +875,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
this.m_SpeciesCycle = b;
|
||||
}
|
||||
public String speciesCycleTipText() {
|
||||
return "Determines how often species differentation/convergence is performed.";
|
||||
return "Determines how often species differentation/merging is performed.";
|
||||
}
|
||||
|
||||
/** TDetermines how often show is performed.
|
||||
@ -884,6 +890,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
public String showCycleTipText() {
|
||||
return "Determines how often show is performed (generations); set to zero to deactivate.";
|
||||
}
|
||||
|
||||
/** Determines the size of the initial population.
|
||||
* @return This number gives initial population size.
|
||||
*/
|
||||
@ -922,14 +929,12 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
public int getHaltingWindow() {
|
||||
return haltingWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param haltingWindow the haltingWindow to set
|
||||
*/
|
||||
public void setHaltingWindow(int haltingWindow) {
|
||||
this.haltingWindow = haltingWindow;
|
||||
}
|
||||
|
||||
public String haltingWindowTipText() {
|
||||
return "Lenght of the halting window defining when a cluster is seen as converged and frozen; set to zero to disable.";
|
||||
}
|
||||
@ -943,4 +948,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
||||
return m_Undifferentiated.size() + " \t " + actives + " \t " + (m_Species.size()-actives);
|
||||
}
|
||||
|
||||
public String[] customPropertyOrder() {
|
||||
return new String[]{"mergingCA", "differentiationCA"};
|
||||
}
|
||||
}
|
||||
|
@ -690,6 +690,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
public void setDEType(DETypeEnum s) {
|
||||
this.m_DEType = s;
|
||||
// show mt for trig. DE only
|
||||
GenericObjectEditor.setShowProperty(this.getClass(), "lambda", s==DETypeEnum.DE2_CurrentToBest);
|
||||
GenericObjectEditor.setShowProperty(this.getClass(), "mt", s==DETypeEnum.TrigonometricDE);
|
||||
}
|
||||
public DETypeEnum getDEType() {
|
||||
|
@ -47,7 +47,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
|
||||
private int subsetsize = 5;
|
||||
|
||||
private int globalSearchSteps = 1;
|
||||
private int globalSearchIterations = 1;
|
||||
|
||||
private boolean lamarckism = true;
|
||||
|
||||
@ -78,7 +78,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
this.m_Identifier = a.m_Identifier;
|
||||
this.localSearchSteps = a.localSearchSteps;
|
||||
this.subsetsize = a.subsetsize;
|
||||
this.globalSearchSteps = a.globalSearchSteps;
|
||||
this.globalSearchIterations = a.globalSearchIterations;
|
||||
this.lamarckism = a.lamarckism;
|
||||
}
|
||||
|
||||
@ -120,9 +120,8 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
if (TRACE) System.out.println("global search");
|
||||
this.m_GlobalOptimizer.optimize();
|
||||
|
||||
if ((this.m_GlobalOptimizer.getPopulation().getGeneration()
|
||||
% this.globalSearchSteps == 0)
|
||||
&& (this.localSearchSteps != 0)
|
||||
if (((this.m_GlobalOptimizer.getPopulation().getGeneration() % this.globalSearchIterations) == 0)
|
||||
&& (this.localSearchSteps > 0)
|
||||
&& (this.m_Problem instanceof InterfaceLocalSearchable)) {
|
||||
// here the local search is performed
|
||||
if (TRACE)
|
||||
@ -282,7 +281,9 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
* @return description
|
||||
*/
|
||||
public String globalInfo() {
|
||||
return "This is a basic generational Memetic Algorithm.";
|
||||
return "This is a basic generational Memetic Algorithm. Local search steps are performed on a selected subset " +
|
||||
"of individuals after certain numbers of global search iterations. Note " +
|
||||
"that the problem class must implement InterfaceLocalSearchable.";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,7 +292,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
* @return The name of the algorithm
|
||||
*/
|
||||
public String getName() {
|
||||
return "Memetic-Algorithm";
|
||||
return "MemeticAlgorithm";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -332,18 +333,16 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose the number of local search steps to perform per selected individual
|
||||
* Choose the number of local search steps to perform per selected individual.
|
||||
*
|
||||
* @param localSearchSteps
|
||||
*/
|
||||
public void setLocalSearchSteps(int localSearchSteps) {
|
||||
this.localSearchSteps = localSearchSteps;
|
||||
}
|
||||
|
||||
public int getLocalSearchSteps() {
|
||||
return localSearchSteps;
|
||||
}
|
||||
|
||||
public String localSearchStepsTipText() {
|
||||
return "Choose the number of local search steps to perform per selected individual.";
|
||||
}
|
||||
@ -353,18 +352,20 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
*
|
||||
* @param globalSearchSteps
|
||||
*/
|
||||
public void setGlobalSearchSteps(int globalSearchSteps) {
|
||||
this.globalSearchSteps = globalSearchSteps;
|
||||
public void setGlobalSearchIterations(int globalSearchSteps) {
|
||||
this.globalSearchIterations = globalSearchSteps;
|
||||
}
|
||||
|
||||
public int getGlobalSearchSteps() {
|
||||
return globalSearchSteps;
|
||||
public int getGlobalSearchIterations() {
|
||||
return globalSearchIterations;
|
||||
}
|
||||
|
||||
public String globalSearchStepsTipText() {
|
||||
public String globalSearchIterationsTipText() {
|
||||
return "Choose the interval between the application of the local search.";
|
||||
}
|
||||
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose the number of individual to be locally optimized
|
||||
*
|
||||
@ -373,36 +374,35 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
||||
public void setSubsetsize(int subsetsize) {
|
||||
this.subsetsize = subsetsize;
|
||||
}
|
||||
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return new SolutionSet(getPopulation());
|
||||
}
|
||||
public int getSubsetsize() {
|
||||
public int getSubsetsize() {
|
||||
return subsetsize;
|
||||
}
|
||||
|
||||
public String subsetsizeTipText() {
|
||||
return "Choose the number of individual to be locally optimized.";
|
||||
return "Choose the number of individuals to be locally optimized.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggel between Lamarcksim and the Baldwin Effect
|
||||
* Toggle between Lamarckism and the Baldwin Effect
|
||||
*
|
||||
* @param lamarckism
|
||||
*/
|
||||
public void setLamarckism(boolean lamarckism) {
|
||||
this.lamarckism = lamarckism;
|
||||
}
|
||||
|
||||
public boolean getLamarckism() {
|
||||
return this.lamarckism;
|
||||
}
|
||||
|
||||
public String lamarckismTipText() {
|
||||
return "Toggel between Lamarcksim and the Baldwin Effect.";
|
||||
return "Toggle between Lamarckism and the Baldwin Effect.";
|
||||
}
|
||||
|
||||
public boolean isLamarckism() {
|
||||
return lamarckism;
|
||||
}
|
||||
|
||||
public InterfaceSelection getSubSetSelector() {
|
||||
return selectorPlug;
|
||||
}
|
||||
public void setSubSetSelector(InterfaceSelection selectorPlug) {
|
||||
this.selectorPlug = selectorPlug;
|
||||
}
|
||||
public String subSetSelectorTipText() {
|
||||
return "Selection method to select the subset on which local search is to be performed.";
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
||||
public static final int defaultType = 0;
|
||||
public static final int resetType = 99;
|
||||
transient final static String partTypeKey = "ParticleType";
|
||||
transient final static String partBestPosKey = "BestPosition";
|
||||
public transient final static String partBestPosKey = "BestPosition";
|
||||
transient final static String partBestFitKey = "BestFitness";
|
||||
transient final static String partVelKey = "Velocity";
|
||||
transient final static String multiSwTypeKey="MultiSwarmType";
|
||||
@ -1580,7 +1580,8 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
||||
public void setPopulation(Population pop){
|
||||
this.m_Population = pop;
|
||||
if (pop.size() != pop.getPopulationSize()) { // new particle count!
|
||||
init();
|
||||
tracedVelocity = null;
|
||||
initByPopulation(null, false);
|
||||
} else for (int i=0; i<pop.size(); i++) {
|
||||
AbstractEAIndividual indy = pop.getEAIndividual(i);
|
||||
if (indy==null) {
|
||||
|
@ -275,7 +275,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
||||
}
|
||||
|
||||
if (printFinalVerbosity() && (additionalInfoSums != null)) {
|
||||
printToTextListener(" Averaged additional info: ");
|
||||
printToTextListener(" Averaged additional info sums: ");
|
||||
for (int i=0; i<additionalInfoSums.length; i++) if (additionalInfoSums[i]!=null) printToTextListener(" \t"+(additionalInfoSums[i]/optRunsPerformed));
|
||||
printToTextListener("\n Averaged last additional info: ");
|
||||
for (int i=0; i<lastAdditionalInfoSums.length; i++) if (lastAdditionalInfoSums[i]!=null) printToTextListener(" \t"+(lastAdditionalInfoSums[i]/optRunsPerformed));
|
||||
|
@ -1035,4 +1035,14 @@ public class Mathematics {
|
||||
destRange[i][1] = Math.min(r1[i][1], r2[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the front of an array with data from a given source array.
|
||||
*
|
||||
* @param dest
|
||||
* @param src
|
||||
*/
|
||||
public static void fillFront(double[] dest, double[] src) {
|
||||
System.arraycopy(src, 0, dest, 0, Math.min(dest.length, src.length));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user