Little fixes in LTGA (Logging, deprecated method)

Refactored InterfaceOptimizer (Set* to set*)
This commit is contained in:
Fabian Becker 2012-12-22 12:27:10 +00:00
parent 7a6c814a56
commit 0f553039e4
32 changed files with 385 additions and 385 deletions

View File

@ -373,7 +373,7 @@ public class OptimizerFactory {
setTemplateOperators(problem, mutator, 1., new NoCrossover(), 0); setTemplateOperators(problem, mutator, 1., new NoCrossover(), 0);
HillClimbing hc = new HillClimbing(); HillClimbing hc = new HillClimbing();
hc.SetIdentifier("-"+popSize+"-"+mutator.getStringRepresentation()); hc.setIdentifier("-"+popSize+"-"+mutator.getStringRepresentation());
hc.getPopulation().setTargetSize(popSize); hc.getPopulation().setTargetSize(popSize);
hc.addPopulationChangedEventListener(listener); hc.addPopulationChangedEventListener(listener);
hc.SetProblem(problem); hc.SetProblem(problem);

View File

@ -592,7 +592,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
return new SolutionSet(this.population); return new SolutionSet(this.population);
} }
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }

View File

@ -723,7 +723,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
return new SolutionSet(this.refSet); return new SolutionSet(this.refSet);
} }
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }

View File

@ -261,7 +261,7 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -996,7 +996,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -97,7 +97,7 @@ InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
setLocalSearchMethod(getLocalSearchMethod()); setLocalSearchMethod(getLocalSearchMethod());
} }
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -687,7 +687,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The identifier * @param name The identifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -1062,7 +1062,7 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface
return identifier; return identifier;
} }
public void SetIdentifier(String name) { public void setIdentifier(String name) {
identifier = name; identifier = name;
} }

View File

@ -323,7 +323,7 @@ public class EvolutionStrategies implements InterfaceOptimizer, java.io.Serializ
* *
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.identifier = name; this.identifier = name;
} }

View File

@ -153,7 +153,7 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -200,7 +200,7 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -225,7 +225,7 @@ public class GeneticAlgorithm implements InterfaceOptimizer, java.io.Serializabl
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -316,7 +316,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }

View File

@ -208,7 +208,7 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -83,8 +83,9 @@ public interface InterfaceOptimizer {
/** /**
* This method allows you to set an identifier for the algorithm * This method allows you to set an identifier for the algorithm
* @param name The identifier * @param name The identifier
* @deprecated
*/ */
public void SetIdentifier(String name); public void setIdentifier(String name);
public String getIdentifier(); public String getIdentifier();
/** /**

View File

@ -109,7 +109,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
this.m_Islands = new InterfaceOptimizer[this.m_numLocalCPUs]; this.m_Islands = new InterfaceOptimizer[this.m_numLocalCPUs];
for (int i = 0; i < this.m_numLocalCPUs; i++) { for (int i = 0; i < this.m_numLocalCPUs; i++) {
this.m_Islands[i] = (InterfaceOptimizer) this.m_Optimizer.clone(); this.m_Islands[i] = (InterfaceOptimizer) this.m_Optimizer.clone();
this.m_Islands[i].SetIdentifier(""+i); this.m_Islands[i].setIdentifier(""+i);
this.m_Islands[i].init(); this.m_Islands[i].init();
if (this.m_LogLocalChanges) if (this.m_LogLocalChanges)
this.m_Islands[i].addPopulationChangedEventListener(this); this.m_Islands[i].addPopulationChangedEventListener(this);
@ -129,7 +129,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
this.m_Islands = new InterfaceOptimizer[nodesList.length]; this.m_Islands = new InterfaceOptimizer[nodesList.length];
for (int i = 0; i < nodesList.length; i++) { for (int i = 0; i < nodesList.length; i++) {
this.m_Islands[i] = (InterfaceOptimizer) RMIProxyRemoteThread.newInstance(this.m_Optimizer, nodesList[i]); this.m_Islands[i] = (InterfaceOptimizer) RMIProxyRemoteThread.newInstance(this.m_Optimizer, nodesList[i]);
this.m_Islands[i].SetIdentifier(""+i); this.m_Islands[i].setIdentifier(""+i);
this.m_Islands[i].init(); this.m_Islands[i].init();
if (this.m_LogLocalChanges) if (this.m_LogLocalChanges)
this.m_Islands[i].addPopulationChangedEventListener(myLocal); this.m_Islands[i].addPopulationChangedEventListener(myLocal);
@ -178,7 +178,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
this.m_Islands = new InterfaceOptimizer[this.m_numLocalCPUs]; this.m_Islands = new InterfaceOptimizer[this.m_numLocalCPUs];
for (int i = 0; i < this.m_numLocalCPUs; i++) { for (int i = 0; i < this.m_numLocalCPUs; i++) {
this.m_Islands[i] = (InterfaceOptimizer) this.m_Optimizer.clone(); this.m_Islands[i] = (InterfaceOptimizer) this.m_Optimizer.clone();
this.m_Islands[i].SetIdentifier(""+i); this.m_Islands[i].setIdentifier(""+i);
this.m_Islands[i].init(); this.m_Islands[i].init();
if (this.m_LogLocalChanges) if (this.m_LogLocalChanges)
this.m_Islands[i].addPopulationChangedEventListener(this); this.m_Islands[i].addPopulationChangedEventListener(this);
@ -196,7 +196,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
this.m_Islands = new InterfaceOptimizer[nodesList.length]; this.m_Islands = new InterfaceOptimizer[nodesList.length];
for (int i = 0; i < nodesList.length; i++) { for (int i = 0; i < nodesList.length; i++) {
this.m_Islands[i] = (InterfaceOptimizer) RMIProxyRemoteThread.newInstance(this.m_Optimizer, nodesList[i]); this.m_Islands[i] = (InterfaceOptimizer) RMIProxyRemoteThread.newInstance(this.m_Optimizer, nodesList[i]);
this.m_Islands[i].SetIdentifier(""+i); this.m_Islands[i].setIdentifier(""+i);
this.m_Islands[i].init(); this.m_Islands[i].init();
if (this.m_LogLocalChanges) if (this.m_LogLocalChanges)
this.m_Islands[i].addPopulationChangedEventListener(myLocal); this.m_Islands[i].addPopulationChangedEventListener(myLocal);
@ -390,7 +390,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -25,10 +25,9 @@ import eva2.tools.math.SpecialFunction;
public class LTGA implements InterfaceOptimizer, java.io.Serializable, InterfacePopulationChangedEventListener { public class LTGA implements InterfaceOptimizer, java.io.Serializable, InterfacePopulationChangedEventListener {
private static final Logger LOGGER = Logger.getLogger(BOA.class.getName()); private static final Logger LOGGER = Logger.getLogger(LTGA.class.getName());
transient private InterfacePopulationChangedEventListener m_Listener = null; transient private InterfacePopulationChangedEventListener m_Listener = null;
private String m_Identifier = "LTGA"; private String m_Identifier = "LTGA";
private int probDim = 8; private int probDim = 8;
private int fitCrit = -1; private int fitCrit = -1;
private int popSize = 50; private int popSize = 50;
@ -50,6 +49,7 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
this.template = (AbstractEAIndividual) template.clone(); this.template = (AbstractEAIndividual) template.clone();
} }
@Override
public Object clone() { public Object clone() {
return new LTGA(this); return new LTGA(this);
} }
@ -76,9 +76,10 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
if (m_Listener == ea) { if (m_Listener == ea) {
m_Listener = null; m_Listener = null;
return true; return true;
} else } else {
return false; return false;
} }
}
private void defaultInit() { private void defaultInit() {
if (population == null) { if (population == null) {
@ -92,8 +93,9 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
} else { } else {
Object dim = BeanInspector.callIfAvailable(problem, Object dim = BeanInspector.callIfAvailable(problem,
"getProblemDimension", null); "getProblemDimension", null);
if (dim == null) if (dim == null) {
LOGGER.log(Level.WARNING, "Coudn't get problem dimension!"); LOGGER.log(Level.WARNING, "Couldn't get problem dimension!");
}
probDim = (Integer) dim; probDim = (Integer) dim;
((InterfaceDataTypeBinary) this.template).SetBinaryGenotype(new BitSet(probDim)); ((InterfaceDataTypeBinary) this.template).SetBinaryGenotype(new BitSet(probDim));
} }
@ -102,11 +104,11 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
} }
private static BitSet getBinaryData(AbstractEAIndividual indy) { private static BitSet getBinaryData(AbstractEAIndividual indy) {
if (indy instanceof InterfaceGAIndividual) if (indy instanceof InterfaceGAIndividual) {
return ((InterfaceGAIndividual) indy).getBGenotype(); return ((InterfaceGAIndividual) indy).getBGenotype();
else if (indy instanceof InterfaceDataTypeBinary) } else if (indy instanceof InterfaceDataTypeBinary) {
return ((InterfaceDataTypeBinary) indy).getBinaryData(); return ((InterfaceDataTypeBinary) indy).getBinaryData();
else { } else {
throw new RuntimeException( throw new RuntimeException(
"Unable to get binary representation for " "Unable to get binary representation for "
+ indy.getClass()); + indy.getClass());
@ -131,8 +133,7 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
* evaluate the given Individual and increments the counter. if the * evaluate the given Individual and increments the counter. if the
* individual is null, only the counter is incremented * individual is null, only the counter is incremented
* *
* @param indy * @param indy the individual you want to evaluate
* the individual you want to evaluate
*/ */
private void evaluate(AbstractEAIndividual indy) { private void evaluate(AbstractEAIndividual indy) {
// evaluate the given individual if it is not null // evaluate the given individual if it is not null
@ -300,9 +301,10 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
* Something has changed * Something has changed
*/ */
protected void firePropertyChangedEvent(String name) { protected void firePropertyChangedEvent(String name) {
if (this.m_Listener != null) if (this.m_Listener != null) {
this.m_Listener.registerPopulationStateChanged(this, name); this.m_Listener.registerPopulationStateChanged(this, name);
} }
}
@Override @Override
public Population getPopulation() { public Population getPopulation() {
@ -320,7 +322,7 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
} }
@Override @Override
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
@ -346,16 +348,14 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
@Override @Override
public void freeWilly() { public void freeWilly() {
} }
@SuppressWarnings("deprecation")
@Override @Override
public void registerPopulationStateChanged(Object source, String name) { public void registerPopulationStateChanged(Object source, String name) {
// The events of the interim hill climbing population will be caught here // The events of the interim hill climbing population will be caught here
if (name.compareTo(Population.funCallIntervalReached) == 0) { if (name.compareTo(Population.funCallIntervalReached) == 0) {
// set funcalls to real value // set funcalls to real value
this.population.SetFunctionCalls(((Population)source).getFunctionCalls()); this.population.setFunctionCalls(((Population) source).getFunctionCalls());
this.firePropertyChangedEvent(Population.nextGenerationPerformed); this.firePropertyChangedEvent(Population.nextGenerationPerformed);
} }
} }
@ -393,5 +393,4 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
System.out.println(p.getFunctionCalls() + "\t" + p.size()); System.out.println(p.getFunctionCalls() + "\t" + p.size());
System.out.println(p.getBestEAIndividual().getStringRepresentation()); System.out.println(p.getBestEAIndividual().getStringRepresentation());
} }
} }

View File

@ -255,7 +255,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
* @param name * @param name
* The indenifier * The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }

View File

@ -182,7 +182,7 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -74,10 +74,10 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable {
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* eva2.server.go.strategies.InterfaceOptimizer#SetIdentifier(java.lang. * eva2.server.go.strategies.InterfaceOptimizer#setIdentifier(java.lang.
* String) * String)
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
m_Identifier = name; m_Identifier = name;
} }

View File

@ -201,7 +201,7 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -58,7 +58,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
return new NelderMeadSimplex(this); return new NelderMeadSimplex(this);
} }
public void SetIdentifier(String name) { public void setIdentifier(String name) {
m_Identifier = name; m_Identifier = name;
} }

View File

@ -1234,7 +1234,7 @@ public class NichePSO implements InterfaceAdditionalPopulationInformer, Interfac
* This method allows you to set an identifier for the algorithm * This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }

View File

@ -282,7 +282,7 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -1712,7 +1712,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
* *
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }

View File

@ -180,7 +180,7 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -664,7 +664,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
///////////// Trivials... ///////////// Trivials...
public void SetIdentifier(String name) { public void setIdentifier(String name) {
m_Identifier = name; m_Identifier = name;
} }

View File

@ -201,7 +201,7 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -152,7 +152,7 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -192,7 +192,7 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -715,7 +715,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
public void freeWilly() {} public void freeWilly() {}
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {

View File

@ -246,7 +246,7 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
/** This method allows you to set an identifier for the algorithm /** This method allows you to set an identifier for the algorithm
* @param name The indenifier * @param name The indenifier
*/ */
public void SetIdentifier(String name) { public void setIdentifier(String name) {
this.m_Identifier = name; this.m_Identifier = name;
} }
public String getIdentifier() { public String getIdentifier() {