Merging mk branch rev 130.
This commit is contained in:
parent
99e5ca1450
commit
18b63d9d97
@ -16,9 +16,11 @@ import eva2.server.go.populations.Population;
|
|||||||
import eva2.server.modules.GOParameters;
|
import eva2.server.modules.GOParameters;
|
||||||
import eva2.server.modules.Processor;
|
import eva2.server.modules.Processor;
|
||||||
import eva2.server.stat.AbstractStatistics;
|
import eva2.server.stat.AbstractStatistics;
|
||||||
|
import eva2.server.stat.InterfaceStatistics;
|
||||||
import eva2.server.stat.StatisticsDummy;
|
import eva2.server.stat.StatisticsDummy;
|
||||||
import eva2.server.stat.InterfaceTextListener;
|
import eva2.server.stat.InterfaceTextListener;
|
||||||
import eva2.server.stat.StatisticsStandalone;
|
import eva2.server.stat.StatisticsStandalone;
|
||||||
|
import eva2.server.stat.StatsParameter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,6 +79,10 @@ public class OptimizerRunnable implements Runnable {
|
|||||||
return proc.getGOParams();
|
return proc.getGOParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InterfaceStatistics getStats() {
|
||||||
|
return proc.getStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
public void setTextListener(InterfaceTextListener lsnr) {
|
public void setTextListener(InterfaceTextListener lsnr) {
|
||||||
proc.getStatistics().removeTextListener(listener);
|
proc.getStatistics().removeTextListener(listener);
|
||||||
this.listener = lsnr;
|
this.listener = lsnr;
|
||||||
@ -175,7 +181,9 @@ public class OptimizerRunnable implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the verbosity level in the statistics module to the given value. See StatsParameter.
|
* Set the verbosity level in the statistics module to the given value.
|
||||||
|
*
|
||||||
|
* @see StatsParameter
|
||||||
* @param vLev
|
* @param vLev
|
||||||
*/
|
*/
|
||||||
public void setVerbosityLevel(int vLev) {
|
public void setVerbosityLevel(int vLev) {
|
||||||
@ -183,4 +191,35 @@ public class OptimizerRunnable implements Runnable {
|
|||||||
proc.getStatistics().getStatisticsParameter().getOutputVerbosity().setSelectedTag(vLev);
|
proc.getStatistics().getStatisticsParameter().getOutputVerbosity().setSelectedTag(vLev);
|
||||||
} else System.err.println("Invalid verbosity leveln in OptimizerRunnable.setVerbosityLevel!");
|
} else System.err.println("Invalid verbosity leveln in OptimizerRunnable.setVerbosityLevel!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the output direction in the statistics module.
|
||||||
|
*
|
||||||
|
* @see StatsParameter
|
||||||
|
* @param outp
|
||||||
|
*/
|
||||||
|
public void setOutputTo(int outp) {
|
||||||
|
((StatsParameter)proc.getStatistics().getStatisticsParameter()).setOutputTo(outp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the number of multiruns in the statistics module.
|
||||||
|
* @param multis
|
||||||
|
*/
|
||||||
|
public void setMultiRuns(int multis) {
|
||||||
|
((AbstractStatistics)proc.getStatistics()).getStatisticsParameter().setMultiRuns(multis);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the additional info output.
|
||||||
|
* @see StatsParameter
|
||||||
|
* @param addInfo
|
||||||
|
*/
|
||||||
|
public void setOutputAdditionalInfo(boolean addInfo) {
|
||||||
|
((AbstractStatistics)proc.getStatistics()).getStatisticsParameter().setOutputAdditionalInfo(addInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void configureStats(int verbosityLevel, int outputDirection, int multiRuns, boolean additionalInfo) {
|
||||||
|
// asdf
|
||||||
|
// }
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ package eva2.server.go.individuals;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import wsi.ra.math.RNG;
|
import wsi.ra.math.RNG;
|
||||||
@ -57,8 +58,9 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
public double m_MutationProbability = 0.2;
|
public double m_MutationProbability = 0.2;
|
||||||
protected InterfaceMutation m_MutationOperator = new NoMutation();
|
protected InterfaceMutation m_MutationOperator = new NoMutation();
|
||||||
protected InterfaceCrossover m_CrossoverOperator = new NoCrossover();
|
protected InterfaceCrossover m_CrossoverOperator = new NoCrossover();
|
||||||
protected String[] m_Identifiers = new String[m_ObjectIncrement];
|
// protected String[] m_Identifiers = new String[m_ObjectIncrement];
|
||||||
protected Object[] m_Objects = new Object[m_ObjectIncrement];
|
// protected Object[] m_Objects = new Object[m_ObjectIncrement];
|
||||||
|
protected HashMap<String,Object> m_dataHash = new HashMap<String,Object>();
|
||||||
|
|
||||||
public AbstractEAIndividual() {
|
public AbstractEAIndividual() {
|
||||||
m_IDcounter++;
|
m_IDcounter++;
|
||||||
@ -111,8 +113,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
*/
|
*/
|
||||||
public void cloneAEAObjects(AbstractEAIndividual individual) {
|
public void cloneAEAObjects(AbstractEAIndividual individual) {
|
||||||
// m_Name = new String(individual.m_Name);
|
// m_Name = new String(individual.m_Name);
|
||||||
m_Identifiers = new String[individual.m_Identifiers.length];
|
m_dataHash = (HashMap<String,Object>)(individual.m_dataHash.clone());
|
||||||
m_Objects = new Object[individual.m_Identifiers.length];
|
|
||||||
m_ConstraintViolation = individual.m_ConstraintViolation;
|
m_ConstraintViolation = individual.m_ConstraintViolation;
|
||||||
m_AreaConst4ParallelViolated = individual.m_AreaConst4ParallelViolated;
|
m_AreaConst4ParallelViolated = individual.m_AreaConst4ParallelViolated;
|
||||||
m_Marked = individual.m_Marked;
|
m_Marked = individual.m_Marked;
|
||||||
@ -122,8 +123,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
parentTree = new AbstractEAIndividual[individual.parentTree.length];
|
parentTree = new AbstractEAIndividual[individual.parentTree.length];
|
||||||
for (int i=0; i<parentTree.length; i++) parentTree[i] = individual.parentTree[i];
|
for (int i=0; i<parentTree.length; i++) parentTree[i] = individual.parentTree[i];
|
||||||
}
|
}
|
||||||
System.arraycopy(individual.m_Identifiers,0,m_Identifiers,0,individual.m_Identifiers.length);
|
|
||||||
System.arraycopy(individual.m_Objects,0,m_Objects,0,individual.m_Objects.length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to compare two individuals
|
/** This method allows you to compare two individuals
|
||||||
@ -199,11 +198,12 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a hash code value for the object. This method is supported for the
|
/**
|
||||||
|
* Returns a hash code value for the object. This method is supported for the
|
||||||
* benefit of hashtables such as those provided by java.util.Hashtable
|
* benefit of hashtables such as those provided by java.util.Hashtable
|
||||||
*/
|
*/
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
String t = this.getStringRepresentation();
|
String t = AbstractEAIndividual.getDefaultStringRepresentation(this);
|
||||||
return t.hashCode();
|
return t.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,8 +412,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
/** This method allows you to reset the user data
|
/** This method allows you to reset the user data
|
||||||
*/
|
*/
|
||||||
public void resetUserData() {
|
public void resetUserData() {
|
||||||
this.m_Identifiers = new String[m_ObjectIncrement];
|
m_dataHash.clear();
|
||||||
this.m_Objects = new Object[m_ObjectIncrement];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows you to reset the level of constraint violation for an
|
/** This method allows you to reset the level of constraint violation for an
|
||||||
@ -741,28 +740,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
* @param obj The object that is to be stored.
|
* @param obj The object that is to be stored.
|
||||||
*/
|
*/
|
||||||
public void SetData(String name, Object obj) {
|
public void SetData(String name, Object obj) {
|
||||||
for (int i = 0; i < this.m_Identifiers.length; i++) {
|
m_dataHash.put(name, obj);
|
||||||
if (this.m_Identifiers[i] == null) {
|
|
||||||
// Identifier has not been found, but there is empty space to store it
|
|
||||||
this.m_Identifiers[i] = name;
|
|
||||||
this.m_Objects[i] = obj;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.m_Identifiers[i].equalsIgnoreCase(name)) {
|
|
||||||
this.m_Objects[i] = obj;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// The identifier could not be found and there is not enough space
|
|
||||||
String[] tmpId = new String[this.m_Identifiers.length + this.m_ObjectIncrement];
|
|
||||||
Object[] tmpOb = new Object[this.m_Identifiers.length + this.m_ObjectIncrement];
|
|
||||||
for (int i = 0; i < this.m_Identifiers.length; i++) {
|
|
||||||
tmpId[i] = this.m_Identifiers[i];
|
|
||||||
tmpOb[i] = this.m_Objects[i];
|
|
||||||
}
|
|
||||||
this.m_Identifiers = tmpId;
|
|
||||||
this.m_Objects = tmpOb;
|
|
||||||
this.SetData(name, obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will return a stored object.
|
/** This method will return a stored object.
|
||||||
@ -770,19 +748,13 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
* @return Object
|
* @return Object
|
||||||
*/
|
*/
|
||||||
public Object getData(String name) {
|
public Object getData(String name) {
|
||||||
if (name.equalsIgnoreCase("SelectionProbability")) return this.getSelectionProbability();
|
// if (name.equalsIgnoreCase("SelectionProbability")) return this.getSelectionProbability();
|
||||||
if (name.equalsIgnoreCase("SelectionProbabilityArray")) return this.getSelectionProbability();
|
// if (name.equalsIgnoreCase("SelectionProbabilityArray")) return this.getSelectionProbability();
|
||||||
if (name.equalsIgnoreCase("Fitness")) return this.getFitness();
|
// if (name.equalsIgnoreCase("Fitness")) return this.getFitness();
|
||||||
if (name.equalsIgnoreCase("FitnessArray")) return this.getFitness();
|
// if (name.equalsIgnoreCase("FitnessArray")) return this.getFitness();
|
||||||
for (int i = 0; i < this.m_Identifiers.length; i++) {
|
Object data = m_dataHash.get(name);
|
||||||
if (this.m_Identifiers[i] == null) {
|
if (data==null) System.err.println("Warning: data key " + name + " unknown!");
|
||||||
return null;
|
return data;
|
||||||
}
|
|
||||||
if (this.m_Identifiers[i].equalsIgnoreCase(name)) {
|
|
||||||
return this.m_Objects[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method will return a string description of the Individal
|
/** This method will return a string description of the Individal
|
||||||
@ -799,6 +771,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
* @return The description.
|
* @return The description.
|
||||||
*/
|
*/
|
||||||
public static String getDefaultStringRepresentation(AbstractEAIndividual individual) {
|
public static String getDefaultStringRepresentation(AbstractEAIndividual individual) {
|
||||||
|
// Note that changing this method might change the hashcode of an individual
|
||||||
|
// which might interfere with some functionality.
|
||||||
StringBuffer sb = new StringBuffer(getDefaultDataString(individual));
|
StringBuffer sb = new StringBuffer(getDefaultDataString(individual));
|
||||||
|
|
||||||
sb.append(", fitness: ");
|
sb.append(", fitness: ");
|
||||||
@ -818,6 +792,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getDefaultDataString(IndividualInterface individual) {
|
public static String getDefaultDataString(IndividualInterface individual) {
|
||||||
|
// Note that changing this method might change the hashcode of an individual
|
||||||
|
// which might interfere with some functionality.
|
||||||
return getDefaultDataString(individual, "; ");
|
return getDefaultDataString(individual, "; ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,6 +805,8 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getDefaultDataString(IndividualInterface individual, String separator) {
|
public static String getDefaultDataString(IndividualInterface individual, String separator) {
|
||||||
|
// Note that changing this method might change the hashcode of an individual
|
||||||
|
// which might interfere with some functionality.
|
||||||
if (individual == null) return "null";
|
if (individual == null) return "null";
|
||||||
StringBuffer sb = new StringBuffer("");
|
StringBuffer sb = new StringBuffer("");
|
||||||
char left = '[';
|
char left = '[';
|
||||||
|
@ -17,12 +17,13 @@ import eva2.server.go.operators.distancemetric.InterfaceDistanceMetric;
|
|||||||
import eva2.server.go.operators.distancemetric.PhenotypeMetric;
|
import eva2.server.go.operators.distancemetric.PhenotypeMetric;
|
||||||
import eva2.tools.EVAERROR;
|
import eva2.tools.EVAERROR;
|
||||||
import eva2.tools.Mathematics;
|
import eva2.tools.Mathematics;
|
||||||
|
import eva2.tools.Pair;
|
||||||
|
|
||||||
|
|
||||||
/** This is a basic implementation for a EA Population.
|
/** This is a basic implementation for a EA Population.
|
||||||
* Copyright: Copyright (c) 2003
|
* Copyright: Copyright (c) 2003
|
||||||
* Company: University of Tuebingen, Computer Architecture
|
* Company: University of Tuebingen, Computer Architecture
|
||||||
* @author Felix Streichert
|
* @author Felix Streichert, Marcel Kronfeld
|
||||||
* @version: $Revision: 307 $
|
* @version: $Revision: 307 $
|
||||||
* $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec 2007) $
|
* $Date: 2007-12-04 14:31:47 +0100 (Tue, 04 Dec 2007) $
|
||||||
* $Author: mkron $
|
* $Author: mkron $
|
||||||
@ -34,9 +35,11 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
protected int m_FunctionCalls = 0;
|
protected int m_FunctionCalls = 0;
|
||||||
protected int m_Size = 50;
|
protected int m_Size = 50;
|
||||||
protected Population m_Archive = null;
|
protected Population m_Archive = null;
|
||||||
|
|
||||||
transient private ArrayList<AbstractEAIndividual> sortedArr = null;
|
transient private ArrayList<AbstractEAIndividual> sortedArr = null;
|
||||||
private int lastQModCount = -1;
|
|
||||||
transient protected InterfacePopulationChangedEventListener m_Listener = null;
|
transient protected InterfacePopulationChangedEventListener m_Listener = null;
|
||||||
|
|
||||||
|
// the evaluation interval at which listeners are notified
|
||||||
protected int notifyEvalInterval = 0;
|
protected int notifyEvalInterval = 0;
|
||||||
protected HashMap<String, Object> additionalPopData = null;
|
protected HashMap<String, Object> additionalPopData = null;
|
||||||
|
|
||||||
@ -45,6 +48,13 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
boolean useHistory = false;
|
boolean useHistory = false;
|
||||||
public ArrayList<AbstractEAIndividual> m_History = new ArrayList<AbstractEAIndividual>();
|
public ArrayList<AbstractEAIndividual> m_History = new ArrayList<AbstractEAIndividual>();
|
||||||
|
|
||||||
|
// remember when the last sorted queue was prepared
|
||||||
|
private int lastQModCount = -1;
|
||||||
|
// remember when the last evaluation was performed
|
||||||
|
private Pair<Integer,Integer> evaluationTimeHashes = null;
|
||||||
|
// remember when the last evaluation was performed
|
||||||
|
private int evaluationTimeModCount = -1;
|
||||||
|
|
||||||
public Population() {
|
public Population() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +139,8 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
this.m_History = new ArrayList();
|
this.m_History = new ArrayList();
|
||||||
this.m_Generation = 0;
|
this.m_Generation = 0;
|
||||||
this.m_FunctionCalls = 0;
|
this.m_FunctionCalls = 0;
|
||||||
|
evaluationTimeHashes = null;
|
||||||
|
evaluationTimeModCount = -1;
|
||||||
if (this.m_Archive != null) {
|
if (this.m_Archive != null) {
|
||||||
this.m_Archive.clear();
|
this.m_Archive.clear();
|
||||||
this.m_Archive.init();
|
this.m_Archive.init();
|
||||||
@ -178,7 +190,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
*
|
*
|
||||||
* @param d The number of function calls to increment.
|
* @param d The number of function calls to increment.
|
||||||
*/
|
*/
|
||||||
public void incrFunctionCallsby(int d) {
|
public void incrFunctionCallsBy(int d) {
|
||||||
if (doEvalNotify()) {
|
if (doEvalNotify()) {
|
||||||
// System.out.println("checking funcall event...");
|
// System.out.println("checking funcall event...");
|
||||||
int nextStep; // next interval boundary
|
int nextStep; // next interval boundary
|
||||||
@ -271,7 +283,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the fitness to the maximum possible value for the given individual.
|
* Resets the fitnes to the maximum possible value for the given individual.
|
||||||
*
|
*
|
||||||
* @param indy an individual whose fitness will be reset
|
* @param indy an individual whose fitness will be reset
|
||||||
*/
|
*/
|
||||||
@ -915,4 +927,39 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
public void setNotifyEvalInterval(int notifyEvalInterval) {
|
public void setNotifyEvalInterval(int notifyEvalInterval) {
|
||||||
this.notifyEvalInterval = notifyEvalInterval;
|
this.notifyEvalInterval = notifyEvalInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the population at the current state has been marked as
|
||||||
|
* evaluated. This allows to avoid double evaluations.
|
||||||
|
*
|
||||||
|
* @return true if the population has been marked as evaluated in its current state, else false
|
||||||
|
*/
|
||||||
|
public boolean isEvaluated() {
|
||||||
|
Pair<Integer,Integer> hashes = getIndyHashSums();
|
||||||
|
|
||||||
|
if (evaluationTimeHashes == null) return false;
|
||||||
|
else return (hashes.head()==evaluationTimeHashes.head() && (hashes.tail() == evaluationTimeHashes.tail()) && (evaluationTimeModCount == modCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the population at the current state as evaluated. Changes to the modCount or hashes of individuals
|
||||||
|
* will invalidate the mark.
|
||||||
|
*
|
||||||
|
* @see isEvaluated()
|
||||||
|
*/
|
||||||
|
public void setEvaluated() {
|
||||||
|
evaluationTimeModCount = modCount;
|
||||||
|
evaluationTimeHashes = getIndyHashSums();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Pair<Integer,Integer> getIndyHashSums() {
|
||||||
|
int hashSum = 0, hashSumAbs = 0;
|
||||||
|
int hash;
|
||||||
|
for (int i=0; i<size(); i++) {
|
||||||
|
hash = get(i).hashCode();
|
||||||
|
hashSum += hash;
|
||||||
|
hashSumAbs += Math.abs(hash);
|
||||||
|
}
|
||||||
|
return new Pair(hashSum, hashSumAbs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,9 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
|
|||||||
public void evaluate(Population population) {
|
public void evaluate(Population population) {
|
||||||
AbstractEAIndividual tmpIndy;
|
AbstractEAIndividual tmpIndy;
|
||||||
|
|
||||||
|
if (population.isEvaluated()) {
|
||||||
|
System.err.println("Population evaluation seems not required!");
|
||||||
|
} else {
|
||||||
// @todo This is the position to implement a granular
|
// @todo This is the position to implement a granular
|
||||||
// @todo paralliziation scheme
|
// @todo paralliziation scheme
|
||||||
evaluatePopulationStart(population);
|
evaluatePopulationStart(population);
|
||||||
@ -63,6 +66,8 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
|
|||||||
population.incrFunctionCalls();
|
population.incrFunctionCalls();
|
||||||
}
|
}
|
||||||
evaluatePopulationEnd(population);
|
evaluatePopulationEnd(population);
|
||||||
|
population.setEvaluated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -425,7 +425,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
}
|
}
|
||||||
// reinit the surplus individuals and add these new individuals to undifferentiated
|
// reinit the surplus individuals and add these new individuals to undifferentiated
|
||||||
m_Undifferentiated.addPopulation(this.initializeIndividuals(reinitCount));
|
m_Undifferentiated.addPopulation(this.initializeIndividuals(reinitCount));
|
||||||
m_Undifferentiated.incrFunctionCallsby(reinitCount);
|
m_Undifferentiated.incrFunctionCallsBy(reinitCount);
|
||||||
m_Undifferentiated.setPopulationSize(this.m_Undifferentiated.getPopulationSize()+reinitCount);
|
m_Undifferentiated.setPopulationSize(this.m_Undifferentiated.getPopulationSize()+reinitCount);
|
||||||
// if (this.m_Debug) {
|
// if (this.m_Debug) {
|
||||||
// System.out.println("Undiff.Size: " + this.m_Undifferentiated.size() +"/"+this.m_Undifferentiated.getPopulationSize());
|
// System.out.println("Undiff.Size: " + this.m_Undifferentiated.size() +"/"+this.m_Undifferentiated.getPopulationSize());
|
||||||
@ -454,12 +454,12 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
//////////////////////
|
//////////////////////
|
||||||
if (!isActive(m_Undifferentiated)) {
|
if (!isActive(m_Undifferentiated)) {
|
||||||
if (TRACE) System.out.println("Inactive Undiff-pop, adding " + m_Undifferentiated.size() + " fun calls...");
|
if (TRACE) System.out.println("Inactive Undiff-pop, adding " + m_Undifferentiated.size() + " fun calls...");
|
||||||
m_Undifferentiated.incrFunctionCallsby(m_Undifferentiated.size());
|
m_Undifferentiated.incrFunctionCallsBy(m_Undifferentiated.size());
|
||||||
}
|
}
|
||||||
if (this.m_Undifferentiated.getFunctionCalls() % this.m_PopulationSize != 0) {
|
if (this.m_Undifferentiated.getFunctionCalls() % this.m_PopulationSize != 0) {
|
||||||
if (TRACE) System.out.println("### mismatching number of funcalls, inactive species? Correcting by " + (m_PopulationSize - (m_Undifferentiated.getFunctionCalls() % m_PopulationSize)));
|
if (TRACE) System.out.println("### mismatching number of funcalls, inactive species? Correcting by " + (m_PopulationSize - (m_Undifferentiated.getFunctionCalls() % m_PopulationSize)));
|
||||||
if (TRACE) System.out.println("### undiff " + ((isActive(m_Undifferentiated)) ? "active!" : "inactive!"));
|
if (TRACE) System.out.println("### undiff " + ((isActive(m_Undifferentiated)) ? "active!" : "inactive!"));
|
||||||
m_Undifferentiated.incrFunctionCallsby(m_PopulationSize - (m_Undifferentiated.getFunctionCalls() % m_PopulationSize));
|
m_Undifferentiated.incrFunctionCallsBy(m_PopulationSize - (m_Undifferentiated.getFunctionCalls() % m_PopulationSize));
|
||||||
} else if (TRACE) System.out.println("### undiff active: " + isActive(m_Undifferentiated));
|
} else if (TRACE) System.out.println("### undiff active: " + isActive(m_Undifferentiated));
|
||||||
|
|
||||||
// possible species differentiation and convergence
|
// possible species differentiation and convergence
|
||||||
|
@ -166,7 +166,7 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi
|
|||||||
// reset population while keeping function calls etc.
|
// reset population while keeping function calls etc.
|
||||||
m_Population.clear();
|
m_Population.clear();
|
||||||
m_Population.addPopulation(tmpPop);
|
m_Population.addPopulation(tmpPop);
|
||||||
m_Population.incrFunctionCallsby(tmpPop.size());
|
m_Population.incrFunctionCallsBy(tmpPop.size());
|
||||||
|
|
||||||
} else { // decrease step size
|
} else { // decrease step size
|
||||||
mutator.setSigma(mutator.getSigma()*reduceFactor);
|
mutator.setSigma(mutator.getSigma()*reduceFactor);
|
||||||
|
@ -63,8 +63,8 @@ public interface InterfaceOptimizer {
|
|||||||
* Return all found solutions (local optima) if they are not contained in the current population. Be
|
* Return all found solutions (local optima) if they are not contained in the current population. Be
|
||||||
* sure to set the Population properties, especially function calls and generation, with respect
|
* sure to set the Population properties, especially function calls and generation, with respect
|
||||||
* to the ongoing optimization.
|
* to the ongoing optimization.
|
||||||
* May return the same as getPopulation if the optimizer makes no distinction, i.e. does not collect
|
* May return the the same set as getPopulation if the optimizer makes no distinction, i.e. does
|
||||||
* solutions outside the current population.
|
* not collect solutions outside the current population.
|
||||||
*
|
*
|
||||||
* @return A population of found solutions.
|
* @return A population of found solutions.
|
||||||
*/
|
*/
|
||||||
|
@ -133,7 +133,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
|||||||
for (int i = 0; i < this.m_Islands.length; i++) {
|
for (int i = 0; i < this.m_Islands.length; i++) {
|
||||||
pop = (Population)this.m_Islands[i].getPopulation().clone();
|
pop = (Population)this.m_Islands[i].getPopulation().clone();
|
||||||
this.m_Population.addPopulation(pop);
|
this.m_Population.addPopulation(pop);
|
||||||
this.m_Population.incrFunctionCallsby(pop.getFunctionCalls());
|
this.m_Population.incrFunctionCallsBy(pop.getFunctionCalls());
|
||||||
}
|
}
|
||||||
this.firePropertyChangedEvent("NextGenerationPerformed", this.m_Optimizer.getPopulation());
|
this.firePropertyChangedEvent("NextGenerationPerformed", this.m_Optimizer.getPopulation());
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
|||||||
for (int i = 0; i < this.m_Islands.length; i++) {
|
for (int i = 0; i < this.m_Islands.length; i++) {
|
||||||
pop = (Population)this.m_Islands[i].getPopulation().clone();
|
pop = (Population)this.m_Islands[i].getPopulation().clone();
|
||||||
this.m_Population.addPopulation(pop);
|
this.m_Population.addPopulation(pop);
|
||||||
this.m_Population.incrFunctionCallsby(pop.getFunctionCalls());
|
this.m_Population.incrFunctionCallsBy(pop.getFunctionCalls());
|
||||||
}
|
}
|
||||||
this.firePropertyChangedEvent("NextGenerationPerformed", this.m_Optimizer.getPopulation());
|
this.firePropertyChangedEvent("NextGenerationPerformed", this.m_Optimizer.getPopulation());
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
|||||||
for (int i = 0; i < this.m_Islands.length; i++) {
|
for (int i = 0; i < this.m_Islands.length; i++) {
|
||||||
pop = (Population)this.m_Islands[i].getPopulation().clone();
|
pop = (Population)this.m_Islands[i].getPopulation().clone();
|
||||||
this.m_Population.addPopulation(pop);
|
this.m_Population.addPopulation(pop);
|
||||||
this.m_Population.incrFunctionCallsby(pop.getFunctionCalls());
|
this.m_Population.incrFunctionCallsBy(pop.getFunctionCalls());
|
||||||
}
|
}
|
||||||
// System.out.println("Fitnesscalls :" + this.m_Population.getFunctionCalls());
|
// System.out.println("Fitnesscalls :" + this.m_Population.getFunctionCalls());
|
||||||
this.firePropertyChangedEvent("NextGenerationPerformed", this.m_Optimizer.getPopulation());
|
this.firePropertyChangedEvent("NextGenerationPerformed", this.m_Optimizer.getPopulation());
|
||||||
|
@ -107,7 +107,7 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
|
|||||||
|
|
||||||
public void optimize() {
|
public void optimize() {
|
||||||
for (int i = 0; i < this.m_Population.size(); i++) this.generateChildren();
|
for (int i = 0; i < this.m_Population.size(); i++) this.generateChildren();
|
||||||
this.m_Population.incrFunctionCallsby(this.m_Population.size());
|
this.m_Population.incrFunctionCallsBy(this.m_Population.size());
|
||||||
this.m_Population.incrGeneration();
|
this.m_Population.incrGeneration();
|
||||||
this.firePropertyChangedEvent("NextGenerationPerformed");
|
this.firePropertyChangedEvent("NextGenerationPerformed");
|
||||||
}
|
}
|
||||||
|
@ -162,11 +162,11 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
|||||||
// first collect all the data
|
// first collect all the data
|
||||||
pop = (Population)this.m_MOOptimizer.getPopulation().clone();
|
pop = (Population)this.m_MOOptimizer.getPopulation().clone();
|
||||||
this.m_Population.addPopulation(pop);
|
this.m_Population.addPopulation(pop);
|
||||||
this.m_Population.incrFunctionCallsby(pop.getFunctionCalls());
|
this.m_Population.incrFunctionCallsBy(pop.getFunctionCalls());
|
||||||
for (int i = 0; i < this.m_SOOptimizers.length; i++) {
|
for (int i = 0; i < this.m_SOOptimizers.length; i++) {
|
||||||
pop = (Population)this.m_SOOptimizers[i].getPopulation().clone();
|
pop = (Population)this.m_SOOptimizers[i].getPopulation().clone();
|
||||||
this.m_Population.addPopulation(pop);
|
this.m_Population.addPopulation(pop);
|
||||||
this.m_Population.incrFunctionCallsby(pop.getFunctionCalls());
|
this.m_Population.incrFunctionCallsBy(pop.getFunctionCalls());
|
||||||
}
|
}
|
||||||
oldFunctionCalls = this.m_Population.getFunctionCalls();
|
oldFunctionCalls = this.m_Population.getFunctionCalls();
|
||||||
this.m_Problem.evaluate(this.m_Population);
|
this.m_Problem.evaluate(this.m_Population);
|
||||||
|
@ -150,8 +150,9 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
if (Mathematics.norm(bestCurrentIndividual.getFitness()) < this.m_StatsParams.getConvergenceRateThreshold()) {
|
if (Mathematics.norm(bestCurrentIndividual.getFitness()) < this.m_StatsParams.getConvergenceRateThreshold()) {
|
||||||
convergenceCnt++;
|
convergenceCnt++;
|
||||||
}
|
}
|
||||||
if (printRunStoppedVerbosity()) printToTextListener(" Best solution: " + BeanInspector.toString(bestCurrentIndividual) + "\n");
|
if (printRunStoppedVerbosity()) printToTextListener(" Run best individual : " + BeanInspector.toString(bestCurrentIndividual) + "\n");
|
||||||
if (printRunStoppedVerbosity()) printToTextListener(AbstractEAIndividual.getDefaultDataString(bestCurrentIndividual) + "\n");
|
if (printRunStoppedVerbosity()) printToTextListener(" run solution data : " + AbstractEAIndividual.getDefaultDataString(bestCurrentIndividual) + "\n");
|
||||||
|
if (printRunStoppedVerbosity()) printToTextListener(" run solution fit : " + BeanInspector.toString(bestCurrentIndividual.getFitness()) + "\n");
|
||||||
}
|
}
|
||||||
if (currentBestFit!= null) {
|
if (currentBestFit!= null) {
|
||||||
if (printRunStoppedVerbosity()) printToTextListener(" Best Fitness: " + BeanInspector.toString(currentBestFit) + "\n");
|
if (printRunStoppedVerbosity()) printToTextListener(" Best Fitness: " + BeanInspector.toString(currentBestFit) + "\n");
|
||||||
@ -162,9 +163,9 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter
|
|||||||
protected void finalizeOutput() {
|
protected void finalizeOutput() {
|
||||||
if (printFinalVerbosity()) printToTextListener("*******\n Runs performed: " + optRunsPerformed + ", reached target " + convergenceCnt + " times with threshold " + m_StatsParams.getConvergenceRateThreshold() + ", rate " + convergenceCnt/(double)m_StatsParams.getMultiRuns() + '\n');
|
if (printFinalVerbosity()) printToTextListener("*******\n Runs performed: " + optRunsPerformed + ", reached target " + convergenceCnt + " times with threshold " + m_StatsParams.getConvergenceRateThreshold() + ", rate " + convergenceCnt/(double)m_StatsParams.getMultiRuns() + '\n');
|
||||||
if (printFinalVerbosity()) printToTextListener(" Average function calls: " + (functionCallSum/optRunsPerformed) + "\n");
|
if (printFinalVerbosity()) printToTextListener(" Average function calls: " + (functionCallSum/optRunsPerformed) + "\n");
|
||||||
if (printFinalVerbosity() && (bestIndividualAllover != null)) printToTextListener("Best overall individual: " + BeanInspector.toString(bestIndividualAllover) + '\n');
|
if (printFinalVerbosity() && (bestIndividualAllover != null)) printToTextListener(" Overall best individual : " + BeanInspector.toString(bestIndividualAllover) + '\n');
|
||||||
if (printFinalVerbosity() && (bestIndividualAllover != null)) printToTextListener(" solution : " + AbstractEAIndividual.getDefaultDataString(bestIndividualAllover) + '\n');
|
if (printFinalVerbosity() && (bestIndividualAllover != null)) printToTextListener(" overall solution data : " + AbstractEAIndividual.getDefaultDataString(bestIndividualAllover) + '\n');
|
||||||
if (printFinalVerbosity() && (bestIndividualAllover != null)) printToTextListener(" fitness : " + BeanInspector.toString(bestIndividualAllover.getFitness()) + '\n');
|
if (printFinalVerbosity() && (bestIndividualAllover != null)) printToTextListener(" overall solution fit : " + BeanInspector.toString(bestIndividualAllover.getFitness()) + '\n');
|
||||||
if (refineMultiRuns && (optRunsPerformed>1) && (meanCollection != null)) {
|
if (refineMultiRuns && (optRunsPerformed>1) && (meanCollection != null)) {
|
||||||
if (printFinalVerbosity()) printToTextListener("Averaged performance:\n");
|
if (printFinalVerbosity()) printToTextListener("Averaged performance:\n");
|
||||||
for (int i=0; i<meanCollection.size(); i++) divideMean(meanCollection.get(i), optRunsPerformed);
|
for (int i=0; i<meanCollection.size(); i++) divideMean(meanCollection.get(i), optRunsPerformed);
|
||||||
|
@ -45,6 +45,10 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
public final static int VERBOSITY_KTH_IT = 2;
|
public final static int VERBOSITY_KTH_IT = 2;
|
||||||
public final static int VERBOSITY_ALL = 3;
|
public final static int VERBOSITY_ALL = 3;
|
||||||
SelectedTag outputVerbosity = new SelectedTag("No output", "Final results", "K-th iterations", "All iterations");
|
SelectedTag outputVerbosity = new SelectedTag("No output", "Final results", "K-th iterations", "All iterations");
|
||||||
|
|
||||||
|
public final static int OUTPUT_FILE = 0;
|
||||||
|
public final static int OUTPUT_WINDOW = 1;
|
||||||
|
public final static int OUTPUT_FILE_WINDOW = 2;
|
||||||
SelectedTag outputTo = new SelectedTag("File (current dir.)", "Text-window", "Both file and text-window");
|
SelectedTag outputTo = new SelectedTag("File (current dir.)", "Text-window", "Both file and text-window");
|
||||||
private int verboK = 10;
|
private int verboK = 10;
|
||||||
|
|
||||||
@ -297,7 +301,7 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
public boolean isShowTextOutput() {
|
public boolean isShowTextOutput() {
|
||||||
return outputTo.getSelectedTagID()>0;
|
return outputTo.getSelectedTagID()>0;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// /**
|
// /**
|
||||||
// *
|
// *
|
||||||
// */
|
// */
|
||||||
@ -330,7 +334,7 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
// public boolean isShowTextOutput() {
|
// public boolean isShowTextOutput() {
|
||||||
// return showTextOutput;
|
// return showTextOutput;
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// /**
|
// /**
|
||||||
// *
|
// *
|
||||||
// * @param showOutputData the showOutputData to set
|
// * @param showOutputData the showOutputData to set
|
||||||
@ -338,7 +342,7 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
// public void setShowTextOutput(boolean bShow) {
|
// public void setShowTextOutput(boolean bShow) {
|
||||||
// this.showTextOutput = bShow;
|
// this.showTextOutput = bShow;
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// public String showTextOutputTipText() {
|
// public String showTextOutputTipText() {
|
||||||
// return "Indicates whether further text output should be printed";
|
// return "Indicates whether further text output should be printed";
|
||||||
// }
|
// }
|
||||||
@ -358,10 +362,17 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
public void hideHideable() {
|
public void hideHideable() {
|
||||||
setOutputVerbosity(getOutputVerbosity());
|
setOutputVerbosity(getOutputVerbosity());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOutputVerbosity(SelectedTag sTag) {
|
public void setOutputVerbosity(SelectedTag sTag) {
|
||||||
outputVerbosity = sTag;
|
outputVerbosity = sTag;
|
||||||
GenericObjectEditor.setHideProperty(this.getClass(), "outputVerbosityK", sTag.getSelectedTagID() != VERBOSITY_KTH_IT);
|
GenericObjectEditor.setHideProperty(this.getClass(), "outputVerbosityK", sTag.getSelectedTagID() != VERBOSITY_KTH_IT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOutputVerbosity(int i) {
|
||||||
|
outputVerbosity.setSelectedTag(i);
|
||||||
|
GenericObjectEditor.setHideProperty(this.getClass(), "outputVerbosityK", outputVerbosity.getSelectedTagID() != VERBOSITY_KTH_IT);
|
||||||
|
}
|
||||||
|
|
||||||
public SelectedTag getOutputVerbosity() {
|
public SelectedTag getOutputVerbosity() {
|
||||||
return outputVerbosity;
|
return outputVerbosity;
|
||||||
}
|
}
|
||||||
@ -390,6 +401,10 @@ public class StatsParameter implements InterfaceStatisticsParameter, Serializabl
|
|||||||
outputTo = tag;
|
outputTo = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOutputTo(int i) {
|
||||||
|
outputTo.setSelectedTag(i);
|
||||||
|
}
|
||||||
|
|
||||||
public String outputToTipText() {
|
public String outputToTipText() {
|
||||||
return "Set the output destination; to deactivate output, set verbosity to none.";
|
return "Set the output destination; to deactivate output, set verbosity to none.";
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
package eva2.tools;
|
package eva2.tools;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple pair structure of two types, Scheme style, but typed.
|
* Simple pair structure of two types, Scheme style, but typed.
|
||||||
*
|
*
|
||||||
* @author mkron
|
* @author mkron
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Pair<S, T> {
|
public class Pair<S, T> implements Serializable {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -3620465393975181451L;
|
||||||
public S head;
|
public S head;
|
||||||
public T tail;
|
public T tail;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user