Fix GUI hidden properties (setProblem) in Optimizers
This commit is contained in:
parent
6465afb3e9
commit
b9e43e1174
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||
* Yu, Shen, Chen, et.al. in 2014 (IEEE Transaction on Cybernetics, DOI: 10.1109/TCYB.2013.2279211).
|
||||
*/
|
||||
@Description("Differential Evolution with Two-Level Parameter Adaption (Yu, Shen, Chen, et.al., 2014")
|
||||
public class AdaptiveDifferentialEvolution implements InterfaceOptimizer {
|
||||
public class AdaptiveDifferentialEvolution extends AbstractOptimizer {
|
||||
protected Population population;
|
||||
|
||||
@Parameter(name = "groups", description = "Number of sub-groups to use during optimization.")
|
||||
@ -153,36 +153,11 @@ public class AdaptiveDifferentialEvolution implements InterfaceOptimizer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.population = pop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the optimization problem. Will cast to AbstractOptimizationProblem.
|
||||
*
|
||||
* @param problem The optimization problem.
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = (AbstractOptimizationProblem) problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.optimizationProblem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringRepresentation() {
|
||||
return null;
|
||||
|
@ -81,8 +81,6 @@ public class CBNPSO extends ClusterBasedNichingEA implements Serializable {
|
||||
|
||||
/**
|
||||
* Return the period of the sinusoidal sigma adaption or -1 if not applicable.
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
public int getSigmaAdaptionPeriod() {
|
||||
ParamAdaption[] prmAd = getParameterControl();
|
||||
@ -177,10 +175,6 @@ public class CBNPSO extends ClusterBasedNichingEA implements Serializable {
|
||||
* is in [0,1] if any solutions have been identified, or -1 if the archive
|
||||
* is empty.
|
||||
*
|
||||
* @param cbpso
|
||||
* @param pop
|
||||
* @param iteration
|
||||
* @param maxIteration
|
||||
* @return
|
||||
*/
|
||||
public double getInterestingSolutionRatio() {
|
||||
@ -196,9 +190,6 @@ public class CBNPSO extends ClusterBasedNichingEA implements Serializable {
|
||||
Population archived = solSet.getSolutions();
|
||||
Population interesting = archived.filterByFitness(fitThres, 0);
|
||||
|
||||
// Population archived = getArchivedSolutions();
|
||||
// Population interesting = archived.filterByFitness(fitThres, 0);
|
||||
|
||||
if (archived.size() > 0) {
|
||||
return ((double) interesting.size()) / ((double) archived.size());
|
||||
} else {
|
||||
|
@ -27,6 +27,7 @@ import eva2.tools.EVAERROR;
|
||||
import eva2.tools.chart2d.*;
|
||||
import eva2.tools.math.Mathematics;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -786,6 +787,7 @@ public class ClusterBasedNichingEA extends AbstractOptimizer implements Interfac
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
this.optimizer.setProblem(this.optimizationProblem);
|
||||
|
@ -10,7 +10,6 @@ import eva2.optimization.population.Population;
|
||||
import eva2.optimization.population.PopulationInterface;
|
||||
import eva2.optimization.population.SolutionSet;
|
||||
import eva2.problems.AbstractOptimizationProblem;
|
||||
import eva2.problems.F1Problem;
|
||||
import eva2.problems.InterfaceAdditionalPopulationInformer;
|
||||
import eva2.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.Pair;
|
||||
@ -36,17 +35,11 @@ import java.io.Serializable;
|
||||
*/
|
||||
@Description("Similar to multi-start HC, but clusters the population during optimization to remove redundant individuals for efficiency."
|
||||
+ "If the local search step does not achieve a minimum improvement, the population may be reinitialized.")
|
||||
public class ClusteringHillClimbing implements InterfacePopulationChangedEventListener,
|
||||
InterfaceOptimizer, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
public class ClusteringHillClimbing extends AbstractOptimizer implements InterfacePopulationChangedEventListener, Serializable, InterfaceAdditionalPopulationInformer {
|
||||
|
||||
transient private InterfacePopulationChangedEventListener populationChangedEventListener;
|
||||
transient private String identifier = "";
|
||||
private Population population = new Population();
|
||||
private transient Population archive = new Population();
|
||||
private InterfaceOptimizationProblem optimizationProblem = new F1Problem();
|
||||
private int hcEvalCycle = 1000;
|
||||
private int initialPopSize = 100;
|
||||
private int loopCnt = 0;
|
||||
private int notifyGuiEvery = 50;
|
||||
private double sigmaClust = 0.01;
|
||||
private double minImprovement = 0.000001;
|
||||
@ -82,7 +75,6 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi
|
||||
initialStepSize = other.initialStepSize;
|
||||
reduceFactor = other.reduceFactor;
|
||||
mutator = (MutateESFixedStepSize) other.mutator.clone();
|
||||
loopCnt = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -99,40 +91,8 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi
|
||||
setLocalSearchMethod(getLocalSearchMethod());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.optimizationProblem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.populationChangedEventListener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
if (populationChangedEventListener == ea) {
|
||||
populationChangedEventListener = null;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
loopCnt = 0;
|
||||
mutator = new MutateESFixedStepSize(initialStepSize);
|
||||
archive = new Population();
|
||||
hideHideable();
|
||||
@ -151,7 +111,6 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi
|
||||
*/
|
||||
@Override
|
||||
public void initializeByPopulation(Population pop, boolean reset) {
|
||||
loopCnt = 0;
|
||||
this.population = (Population) pop.clone();
|
||||
population.addPopulationChangedEventListener(null);
|
||||
if (reset) {
|
||||
@ -161,20 +120,10 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.populationChangedEventListener != null) {
|
||||
this.populationChangedEventListener.registerPopulationStateChanged(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void optimize() {
|
||||
double improvement;
|
||||
|
||||
loopCnt++;
|
||||
population.addPopulationChangedEventListener(this);
|
||||
population.setNotifyEvalInterval(notifyGuiEvery);
|
||||
Pair<Population, Double> popD;
|
||||
@ -244,23 +193,6 @@ public class ClusteringHillClimbing implements InterfacePopulationChangedEventLi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming that all optimizer will store thier data in a population we will
|
||||
* allow acess to this population to query to current state of the
|
||||
* optimizer.
|
||||
*
|
||||
* @return The population of current solutions to a given problem.
|
||||
*/
|
||||
@Override
|
||||
public Population getPopulation() {
|
||||
return this.population;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopulation(Population pop) {
|
||||
this.population = pop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceSolutionSet getAllSolutions() {
|
||||
Population tmp = new Population();
|
||||
|
@ -11,6 +11,7 @@ import eva2.tools.SelectedTag;
|
||||
import eva2.tools.math.Mathematics;
|
||||
import eva2.tools.math.RNG;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
/**
|
||||
* This extends our particle swarm implementation to dynamic optimization problems.
|
||||
@ -130,7 +131,7 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization
|
||||
*
|
||||
* @param index The individual to update.
|
||||
* @param pop The current population.
|
||||
* @param best The best individual found so far.
|
||||
* @param indy The best individual found so far.
|
||||
*/
|
||||
private void updateQuantumIndividual(int index, AbstractEAIndividual indy, Population pop) {
|
||||
InterfaceDataTypeDouble endy = (InterfaceDataTypeDouble) indy;
|
||||
@ -473,6 +474,7 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization
|
||||
|
||||
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
super.setProblem(problem);
|
||||
if (problem instanceof AbstractOptimizationProblem) {
|
||||
|
@ -186,16 +186,6 @@ public class GeneticAlgorithm extends AbstractOptimizer implements java.io.Seria
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.optimizationProblem;
|
||||
|
@ -12,6 +12,7 @@ import eva2.problems.F8Problem;
|
||||
import eva2.problems.InterfaceOptimizationProblem;
|
||||
import eva2.problems.TF1Problem;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
/**
|
||||
* The one and only island model for parallelization. Since parallelization
|
||||
@ -297,6 +298,7 @@ public class IslandModelEA implements InterfacePopulationChangedEventListener, I
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
this.optimizer.setProblem(problem);
|
||||
|
@ -11,6 +11,7 @@ import eva2.problems.F1Problem;
|
||||
import eva2.problems.InterfaceLocalSearchable;
|
||||
import eva2.problems.InterfaceOptimizationProblem;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
@ -196,6 +197,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer, java.io.Serializabl
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
this.globalOptimizer.setProblem(this.optimizationProblem);
|
||||
|
@ -15,6 +15,7 @@ import eva2.problems.AbstractOptimizationProblem;
|
||||
import eva2.problems.FM0Problem;
|
||||
import eva2.problems.InterfaceOptimizationProblem;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
/**
|
||||
* A generic framework for multi-objecitve optimization, you need to specify an
|
||||
@ -183,6 +184,7 @@ public class MultiObjectiveEA implements InterfaceOptimizer, java.io.Serializabl
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
this.optimizer.setProblem(problem);
|
||||
|
@ -52,11 +52,6 @@ public class NelderMeadSimplex extends AbstractOptimizer implements Serializable
|
||||
return new NelderMeadSimplex(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
optimizationProblem = (AbstractOptimizationProblem) problem;
|
||||
}
|
||||
|
||||
public boolean setProblemAndPopSize(InterfaceOptimizationProblem problem) {
|
||||
setProblem(problem);
|
||||
if (optimizationProblem instanceof AbstractProblemDouble) {
|
||||
@ -77,8 +72,6 @@ public class NelderMeadSimplex extends AbstractOptimizer implements Serializable
|
||||
for (int i = 0; i < r.length; i++) {
|
||||
r[i] = 2 * centroid[i] - refX[i];
|
||||
}
|
||||
// double alpha = 1.3;
|
||||
// for (int i=0; i<r.length; i++) r[i] = centroid[i] + alpha*(centroid[i] - refX[i]);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import eva2.problems.*;
|
||||
import eva2.tools.SelectedTag;
|
||||
import eva2.tools.chart2d.*;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -1194,6 +1195,7 @@ public class NichePSO extends AbstractOptimizer implements InterfaceAdditionalPo
|
||||
* @tested ps This method will set the problem that is to be optimized
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
// set member
|
||||
this.optimizationProblem = problem;
|
||||
|
@ -16,6 +16,7 @@ import eva2.problems.AbstractOptimizationProblem;
|
||||
import eva2.problems.F1Problem;
|
||||
import eva2.problems.InterfaceOptimizationProblem;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
/**
|
||||
* This is a Particle Filter implemented by Frank Senke, only some documentation
|
||||
@ -236,6 +237,7 @@ public class ParticleFilterOptimization extends AbstractOptimizer implements jav
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
if (problem instanceof AbstractOptimizationProblem) {
|
||||
|
@ -13,6 +13,9 @@ import eva2.problems.AbstractOptimizationProblem;
|
||||
import eva2.problems.B1Problem;
|
||||
import eva2.problems.InterfaceOptimizationProblem;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Population based incremental learning in the PSM by Monmarche version with
|
||||
@ -27,6 +30,7 @@ import eva2.util.annotation.Description;
|
||||
@Description("The Population based incremental learning is based on a statistical distribution of bit positions. Please note: This optimizer requires a binary genotype!")
|
||||
public class PopulationBasedIncrementalLearning extends AbstractOptimizer implements java.io.Serializable {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(PopulationBasedIncrementalLearning.class.getName());
|
||||
// These variables are necessary for the simple testcase
|
||||
private InterfaceOptimizationProblem optimizationProblem = new B1Problem();
|
||||
private boolean useElitism = true;
|
||||
@ -144,11 +148,12 @@ public class PopulationBasedIncrementalLearning extends AbstractOptimizer implem
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
if (optimizationProblem instanceof AbstractOptimizationProblem) {
|
||||
if (!(((AbstractOptimizationProblem) optimizationProblem).getIndividualTemplate() instanceof InterfaceGAIndividual)) {
|
||||
System.err.println("Error: PBIL only works with GAIndividuals!");
|
||||
LOGGER.warning("PBIL only works with GAIndividuals!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import eva2.tools.SelectedTag;
|
||||
import eva2.tools.math.Mathematics;
|
||||
import eva2.tools.math.RNG;
|
||||
import eva2.util.annotation.Description;
|
||||
import eva2.util.annotation.Hidden;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -102,6 +103,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
|
||||
}
|
||||
|
||||
@Override
|
||||
@Hidden
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = (AbstractOptimizationProblem) problem;
|
||||
}
|
||||
|
@ -115,21 +115,6 @@ public class ThresholdAlgorithm extends AbstractOptimizer implements java.io.Ser
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.optimizationProblem;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will initialize the HillClimber
|
||||
*/
|
||||
|
@ -20,16 +20,13 @@ import eva2.util.annotation.Description;
|
||||
* performance of this algorithm strongly depends on the optimization problem.
|
||||
*/
|
||||
@Description("This is Evolutionary Multi-Criteria Optimization Algorithm hybridized with Local Searchers to span the Pareto-Front.")
|
||||
public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Serializable {
|
||||
public class WingedMultiObjectiveEA extends AbstractOptimizer implements java.io.Serializable {
|
||||
|
||||
private InterfaceOptimizer multiObjectiveEA = new MultiObjectiveEA();
|
||||
private InterfaceOptimizer singleObjectiveEA = new GeneticAlgorithm();
|
||||
private InterfaceOptimizer[] singleObjectiveOptimizers;
|
||||
private Population population = new Population();
|
||||
private int migrationRate = 5;
|
||||
private int outputDimension = 2;
|
||||
private InterfaceOptimizationProblem optimizationProblem = new FM0Problem();
|
||||
transient private InterfacePopulationChangedEventListener populationChangedEventListener;
|
||||
|
||||
public WingedMultiObjectiveEA() {
|
||||
}
|
||||
@ -207,51 +204,6 @@ public class WingedMultiObjectiveEA implements InterfaceOptimizer, java.io.Seria
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to add the LectureGUI as listener to the Optimizer
|
||||
*
|
||||
* @param ea
|
||||
*/
|
||||
@Override
|
||||
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) {
|
||||
this.populationChangedEventListener = ea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePopulationChangedEventListener(
|
||||
InterfacePopulationChangedEventListener ea) {
|
||||
if (populationChangedEventListener == ea) {
|
||||
populationChangedEventListener = null;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Something has changed
|
||||
*/
|
||||
protected void firePropertyChangedEvent(String name) {
|
||||
if (this.populationChangedEventListener != null) {
|
||||
this.populationChangedEventListener.registerPopulationStateChanged(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will set the problem that is to be optimized
|
||||
*
|
||||
* @param problem
|
||||
*/
|
||||
@Override
|
||||
public void setProblem(InterfaceOptimizationProblem problem) {
|
||||
this.optimizationProblem = problem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceOptimizationProblem getProblem() {
|
||||
return this.optimizationProblem;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return a string describing all properties of the
|
||||
* optimizer and the applied methods.
|
||||
|
Loading…
x
Reference in New Issue
Block a user