Remove setIdentifier/getIdentifier from InterfaceOptimizer as it was not used.

refs #2
This commit is contained in:
Fabian Becker 2014-10-25 01:27:18 +02:00
parent 6b05a71a86
commit a42bbf685a
34 changed files with 54 additions and 476 deletions

View File

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

View File

@ -8,6 +8,8 @@ import eva2.problems.F1Problem;
import eva2.problems.InterfaceOptimizationProblem;
import eva2.util.annotation.Description;
import java.util.ArrayList;
/**
*
*/
@ -17,6 +19,8 @@ public class ArtificialBeeColony implements InterfaceOptimizer {
protected AbstractOptimizationProblem optimizationProblem = new F1Problem();
protected Population population;
private ArrayList<InterfacePopulationChangedEventListener> populationChangedEventListeners;
public ArtificialBeeColony() {
}
@ -37,12 +41,15 @@ public class ArtificialBeeColony implements InterfaceOptimizer {
@Override
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
if (populationChangedEventListeners == null) {
populationChangedEventListeners = new ArrayList<>();
}
populationChangedEventListeners.add(ea);
}
@Override
public boolean removePopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
return false;
return populationChangedEventListeners != null && populationChangedEventListeners.remove(ea);
}
@Override
@ -50,13 +57,50 @@ public class ArtificialBeeColony implements InterfaceOptimizer {
}
/**
* This method will initialize the optimizer with a given population
*
* @param pop The initial population
* @param reset If true the population is reset.
*/
@Override
public void initializeByPopulation(Population pop, boolean reset) {
this.population = (Population) pop.clone();
if (reset) {
this.population.init();
this.evaluatePopulation(this.population);
this.firePropertyChangedEvent(Population.NEXT_GENERATION_PERFORMED);
}
}
/**
* Something has changed
*
* @param name Event name
*/
protected void firePropertyChangedEvent(String name) {
if (this.populationChangedEventListeners != null) {
for (InterfacePopulationChangedEventListener listener : this.populationChangedEventListeners) {
listener.registerPopulationStateChanged(this, name);
}
}
}
/**
* This method will evaluate the current population using the given problem.
*
* @param population The population that is to be evaluated
*/
private void evaluatePopulation(Population population) {
this.optimizationProblem.evaluate(population);
population.incrGeneration();
}
@Override
public void optimize() {
/**
*
*/
}
@ -75,16 +119,6 @@ public class ArtificialBeeColony implements InterfaceOptimizer {
return null;
}
@Override
public void setIdentifier(String name) {
}
@Override
public String getIdentifier() {
return null;
}
/**
* This method will set the problem that is to be optimized
*

View File

@ -558,16 +558,6 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
return new SolutionSet(this.population);
}
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
@Override
public void setProblem(InterfaceOptimizationProblem problem) {
this.problem = (AbstractOptimizationProblem) problem;
@ -583,9 +573,6 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
return "Bayesian Network";
}
// -------------------------------
// -------------GUI---------------
// -------------------------------
public int getNumberOfParents() {
return this.numberOfParents;
}

View File

@ -761,16 +761,6 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
return new SolutionSet(this.refSet);
}
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
@Override
public void setProblem(InterfaceOptimizationProblem problem) {
this.problem = (AbstractOptimizationProblem) problem;

View File

@ -287,21 +287,6 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String
*

View File

@ -837,21 +837,6 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String

View File

@ -99,16 +99,6 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi
setLocalSearchMethod(getLocalSearchMethod());
}
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will set the problem that is to be optimized
*

View File

@ -518,11 +518,15 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
*/
public void optimizeGenerational() {
int parentIndex;
// Initialize or clear child population
if (children == null) {
children = new Population(population.size());
} else {
children.clear();
}
// Create a new population based on the old one
for (int i = 0; i < this.population.size(); i++) {
if (cyclePop) {
parentIndex = i;
@ -728,21 +732,6 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The identifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String
*

View File

@ -925,16 +925,6 @@ public class EsDpiNiching implements InterfaceOptimizer, Serializable, Interface
return new SolutionSet(getPopulation(), peaks);
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public void setIdentifier(String name) {
identifier = name;
}
@Override
public void setPopulation(Population pop) {
// this might cause problems if the pop.size() does not fit the EsDpiNiching parameters mu/lamba per peak

View File

@ -333,21 +333,6 @@ public class EvolutionStrategies implements InterfaceOptimizer, java.io.Serializ
origPopSize = population.getTargetSize();
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* These are for GUI
*/

View File

@ -170,21 +170,6 @@ public class EvolutionaryProgramming implements InterfaceOptimizer, java.io.Seri
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String
*

View File

@ -235,21 +235,6 @@ public class FloodAlgorithm implements InterfaceOptimizer, java.io.Serializable
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String
*

View File

@ -226,26 +226,6 @@ public class GeneticAlgorithm implements InterfaceOptimizer, java.io.Serializabl
return result;
}
/**
* This method allows you to set an identifier for the algorithm.
*
* @param name The identifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* ********************************************************************************************************************
* These are for GUI
*/
/**
* This method will return a naming String
*

View File

@ -317,29 +317,9 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
@Override
public void setPopulation(Population pop) {
// Hashtable newindyhash = new Hashtable();
// for (int i = 0; i < pop.size(); i++) {
// if (indyhash.contains(pop.get(i))) newindyhash.put(pop.get(i), indyhash.get(pop.get(i)));
// }
// indyhash = newindyhash;
this.population = pop;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
@Override
public void setProblem(InterfaceOptimizationProblem problem) {

View File

@ -190,26 +190,6 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* ********************************************************************************************************************
* These are for GUI
*/
/**
* This method will return a naming String
*

View File

@ -77,15 +77,6 @@ public interface InterfaceOptimizer {
*/
InterfaceSolutionSet getAllSolutions();
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The identifier
*/
void setIdentifier(String name);
String getIdentifier();
/**
* This method will set the problem that is to be optimized. The problem
* should be initialized when this method is called.

View File

@ -92,7 +92,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
this.islands = new InterfaceOptimizer[this.numLocalCPUs];
for (int i = 0; i < this.numLocalCPUs; i++) {
this.islands[i] = (InterfaceOptimizer) this.optimizer.clone();
this.islands[i].setIdentifier("" + i);
//this.islands[i].setIdentifier("" + i);
this.islands[i].initialize();
if (this.logLocalChanges) {
this.islands[i].addPopulationChangedEventListener(this);
@ -161,7 +161,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
this.islands = new InterfaceOptimizer[this.numLocalCPUs];
for (int i = 0; i < this.numLocalCPUs; i++) {
this.islands[i] = (InterfaceOptimizer) this.optimizer.clone();
this.islands[i].setIdentifier("" + i);
//this.islands[i].setIdentifier("" + i);
this.islands[i].initialize();
if (this.logLocalChanges) {
this.islands[i].addPopulationChangedEventListener(this);
@ -386,21 +386,6 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
//System.exit(0);
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return the Optimizers
*
@ -434,9 +419,9 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
@Override
public void registerPopulationStateChanged(Object source, String name) {
InterfaceOptimizer opt = (InterfaceOptimizer) source;
int sourceID = Integer.parseInt(opt.getIdentifier());
int sourceID = 12; //Integer.parseInt(opt.getIdentifier());
double cFCOpt = opt.getPopulation().getFunctionCalls();
double plotValue = (this.optimizationProblem.getDoublePlotValue(opt.getPopulation())).doubleValue();
double plotValue = this.optimizationProblem.getDoublePlotValue(opt.getPopulation());
if (this.show) {
this.plot.setConnectedPoint(cFCOpt, plotValue, (sourceID + 1));

View File

@ -326,16 +326,6 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interface
return new SolutionSet(this.population);
}
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
@Override
public void setProblem(InterfaceOptimizationProblem problem) {
this.problem = (AbstractOptimizationProblem) problem;

View File

@ -307,16 +307,6 @@ public class MLTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
return new SolutionSet(this.population);
}
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
@Override
public void setProblem(InterfaceOptimizationProblem problem) {
this.problem = (AbstractOptimizationProblem) problem;

View File

@ -223,21 +223,6 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String

View File

@ -207,21 +207,6 @@ public class MonteCarloSearch implements InterfaceOptimizer, java.io.Serializabl
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String

View File

@ -67,18 +67,6 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable {
.setHideProperty(this.getClass(), "population", true);
}
/*
* (non-Javadoc)
*
* @see
* eva2.optimization.strategies.InterfaceOptimizer#setIdentifier(java.lang.
* String)
*/
@Override
public void setIdentifier(String name) {
identifier = name;
}
/*
* (non-Javadoc)
*
@ -113,16 +101,6 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable {
return new SolutionSet(pop, pop);
}
/*
* (non-Javadoc)
*
* @see eva2.optimization.strategies.InterfaceOptimizer#getIdentifier()
*/
@Override
public String getIdentifier() {
return identifier;
}
/*
* (non-Javadoc)
*

View File

@ -215,21 +215,6 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String
*

View File

@ -56,11 +56,6 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
return new NelderMeadSimplex(this);
}
@Override
public void setIdentifier(String name) {
identifier = name;
}
@Override
public void setProblem(InterfaceOptimizationProblem problem) {
optimizationProblem = (AbstractOptimizationProblem) problem;
@ -221,11 +216,6 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
return e_ind;
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public String getName() {
return identifier;
@ -360,7 +350,6 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
/**
* This method creates a Nelder-Mead instance.
*
* @param pop The size of the population
* @param problem The problem to be optimized
* @param listener
* @return An optimization procedure that performs nelder mead optimization.

View File

@ -1291,24 +1291,6 @@ public class NichePSO implements InterfaceAdditionalPopulationInformer, Interfac
getSubswarmOptimizerTemplate().setProblem(problem);
}
/**
* @param name The indenifier
* @tested nn This method allows you to set an identifier for the algorithm
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
/**
* @tested nn (non-Javadoc)
* @see javaeva.server.oa.go.Strategies.InterfaceOptimizer#getIdentifier()
*/
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* ********************************************************************************************************************
* getter: "descriptive parameters" for the mainswarm and subswarms

View File

@ -306,21 +306,6 @@ public class ParticleFilterOptimization implements InterfaceOptimizer, java.io.S
return strB.toString();
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String
*

View File

@ -1521,21 +1521,6 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.indentifier = name;
}
@Override
public String getIdentifier() {
return this.indentifier;
}
/**
* This method will return a naming String
*
@ -1543,7 +1528,6 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
*/
@Override
public String getName() {
// return "PSO-"+getTopology()+getTopologyRange()+(isDoLocalSearch() ? "-ls_" : "_")+getPhi1()+"_"+getPhi2();
return "PSO-" + getTopology() + getTopologyRange() + "_" + getPhi1() + "_" + getPhi2();
}

View File

@ -199,21 +199,6 @@ public class PopulationBasedIncrementalLearning implements InterfaceOptimizer, j
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String
*

View File

@ -679,11 +679,6 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
return RNG.randomDouble(lowB, upB);
}
///////////// Trivials...
@Override
public void setIdentifier(String name) {
identifier = name;
}
@Override
public InterfaceOptimizationProblem getProblem() {
@ -712,11 +707,6 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
}
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public String getName() {
return "ScatterSearch";

View File

@ -233,21 +233,6 @@ public class SimulatedAnnealing implements InterfaceOptimizer, java.io.Serializa
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String

View File

@ -176,21 +176,6 @@ public class SteadyStateGA implements InterfaceOptimizer, java.io.Serializable {
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String
*

View File

@ -224,21 +224,6 @@ public class ThresholdAlgorithm implements InterfaceOptimizer, java.io.Serializa
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.indentifier = name;
}
@Override
public String getIdentifier() {
return this.indentifier;
}
/**
* This method will return a naming String
*

View File

@ -637,16 +637,6 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
return (evals % notifyGenChangedEvery) == 0;
}
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public String getName() {
return "TRIBES";

View File

@ -269,21 +269,6 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
return result;
}
/**
* This method allows you to set an identifier for the algorithm
*
* @param name The indenifier
*/
@Override
public void setIdentifier(String name) {
this.identifier = name;
}
@Override
public String getIdentifier() {
return this.identifier;
}
/**
* This method will return a naming String
*