Without any loss of functionality, JE2Base can now also be compiled with Java 1.5.

This commit is contained in:
Andreas Dräger
2010-03-29 02:51:13 +00:00
parent 9848734f07
commit df9c625771
2 changed files with 313 additions and 249 deletions

View File

@@ -6,8 +6,9 @@ import eva2.server.go.populations.Population;
import eva2.server.go.problems.InterfaceOptimizationProblem; import eva2.server.go.problems.InterfaceOptimizationProblem;
import eva2.tools.math.Jama.Matrix; import eva2.tools.math.Jama.Matrix;
public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatrixAdaption implements InterfaceMutationGenerational public class MutateESCovarianceMatrixAdaptionPlus extends
{ MutateESCovarianceMatrixAdaption implements
InterfaceMutationGenerational {
protected double m_psuccess; protected double m_psuccess;
protected double m_cp; protected double m_cp;
protected double m_psuccesstarget = 0.44; protected double m_psuccesstarget = 0.44;
@@ -15,13 +16,12 @@ public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatr
protected double m_pthresh; protected double m_pthresh;
protected int m_lambda = 1; protected int m_lambda = 1;
public MutateESCovarianceMatrixAdaptionPlus() { public MutateESCovarianceMatrixAdaptionPlus() {
super(); super();
} }
public MutateESCovarianceMatrixAdaptionPlus(
public MutateESCovarianceMatrixAdaptionPlus(MutateESCovarianceMatrixAdaptionPlus mutator) { MutateESCovarianceMatrixAdaptionPlus mutator) {
super(mutator); super(mutator);
m_psuccess = mutator.m_psuccess; m_psuccess = mutator.m_psuccess;
m_cp = mutator.m_cp; m_cp = mutator.m_cp;
@@ -31,35 +31,42 @@ public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatr
m_stepd = mutator.m_stepd; m_stepd = mutator.m_stepd;
} }
/** This method will enable you to clone a given mutation operator /**
* This method will enable you to clone a given mutation operator
*
* @return The clone * @return The clone
*/ */
public Object clone() { public Object clone() {
return new MutateESCovarianceMatrixAdaptionPlus(this); return new MutateESCovarianceMatrixAdaptionPlus(this);
} }
/**
/** This method allows you to init the mutation operator * This method allows you to init the mutation operator
* @param individual The individual that will be mutated. *
* @param opt The optimization problem. * @param individual
* The individual that will be mutated.
* @param opt
* The optimization problem.
*/ */
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) { public void init(AbstractEAIndividual individual,
InterfaceOptimizationProblem opt) {
if (!(individual instanceof InterfaceESIndividual)) return; if (!(individual instanceof InterfaceESIndividual))
return;
super.init(individual, opt); super.init(individual, opt);
m_psuccesstarget = 1.0 / (5 + Math.sqrt(m_lambda) / 2); m_psuccesstarget = 1.0 / (5 + Math.sqrt(m_lambda) / 2);
m_psuccess = m_psuccesstarget; m_psuccess = m_psuccesstarget;
m_stepd = 1.0 + m_D / (2.0 * m_lambda); m_stepd = 1.0 + m_D / (2.0 * m_lambda);
m_cp = m_psuccesstarget * m_lambda / (2 + m_psuccesstarget * m_lambda); m_cp = m_psuccesstarget * m_lambda / (2 + m_psuccesstarget * m_lambda);
m_c = 2.0 / (2.0 + m_D); m_c = 2.0 / (2.0 + m_D);
this.cov = 2.0/(6.0+Math.pow(m_D, 2)); //ATTN: differs from the standard CMA-ES this.cov = 2.0 / (6.0 + Math.pow(m_D, 2)); // ATTN: differs from the
// standard CMA-ES
m_pthresh = 0.44; m_pthresh = 0.44;
} }
protected void adaptStrategyGen(AbstractEAIndividual child,
AbstractEAIndividual parent) {
protected void adaptStrategyGen(AbstractEAIndividual child,AbstractEAIndividual parent) {
if (child.getFitness(0) <= parent.getFitness(0)) { if (child.getFitness(0) <= parent.getFitness(0)) {
// updatecov // updatecov
updateCovariance(child, parent); updateCovariance(child, parent);
@@ -72,10 +79,12 @@ public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatr
* @param parent * @param parent
* @param child * @param child
*/ */
public void updateCovariance(AbstractEAIndividual child,AbstractEAIndividual parent) { public void updateCovariance(AbstractEAIndividual child,
AbstractEAIndividual parent) {
double[] step = new double[m_D]; double[] step = new double[m_D];
for (int i = 0; i < m_D; i++) { for (int i = 0; i < m_D; i++) {
step[i]=((InterfaceESIndividual)parent).getDGenotype()[i]-((InterfaceESIndividual)child).getDGenotype()[i]; step[i] = ((InterfaceESIndividual) parent).getDGenotype()[i]
- ((InterfaceESIndividual) child).getDGenotype()[i];
} }
updateCovariance(step); updateCovariance(step);
} }
@@ -87,6 +96,7 @@ public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatr
} }
updateCovariance(step); updateCovariance(step);
} }
/** /**
* @param step * @param step
* *
@@ -94,7 +104,9 @@ public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatr
public void updateCovariance(double[] step) { public void updateCovariance(double[] step) {
for (int i = 0; i < m_D; i++) { for (int i = 0; i < m_D; i++) {
if (m_psuccess < m_pthresh) { if (m_psuccess < m_pthresh) {
m_PathS[i]=(1.0-m_c)*m_PathS[i]+Math.sqrt(m_c*(2.0-m_c))*(step[i])/m_SigmaGlobal; m_PathS[i] = (1.0 - m_c) * m_PathS[i]
+ Math.sqrt(m_c * (2.0 - m_c)) * (step[i])
/ m_SigmaGlobal;
} else { } else {
m_PathS[i] = (1.0 - m_c) * m_PathS[i]; m_PathS[i] = (1.0 - m_c) * m_PathS[i];
} }
@@ -106,9 +118,7 @@ public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatr
} else { } else {
m_C = m_C.multi((1.0 - cov)).plus( m_C = m_C.multi((1.0 - cov)).plus(
(Matrix.outer(m_PathS, m_PathS).plus( (Matrix.outer(m_PathS, m_PathS).plus(
m_C.multi(m_c*(2.0-m_c)) m_C.multi(m_c * (2.0 - m_c))).multi(cov)));
).multi(cov))
);
} }
} }
@@ -123,7 +133,6 @@ public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatr
m_lambda = mLambda; m_lambda = mLambda;
} }
@Override @Override
public void crossoverOnStrategyParameters(AbstractEAIndividual indy1, public void crossoverOnStrategyParameters(AbstractEAIndividual indy1,
Population partners) { Population partners) {
@@ -131,55 +140,81 @@ public class MutateESCovarianceMatrixAdaptionPlus extends MutateESCovarianceMatr
} }
@Override // @Override
public void adaptAfterSelection(Population oldPop, Population selectedPop) { public void adaptAfterSelection(Population oldPop, Population selectedPop) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override // @Override
public void adaptGenerational(Population selectedPop, Population parentPop, Population newPop, boolean updateSelected) { public void adaptGenerational(Population selectedPop, Population parentPop,
Population newPop, boolean updateSelected) {
double rate = 0.; double rate = 0.;
for (int i = 0; i < parentPop.size(); i++) { for (int i = 0; i < parentPop.size(); i++) {
// calculate success rate // calculate success rate
// System.out.println("new fit / old fit: " + BeanInspector.toString(newPop.getEAIndividual(i).getFitness()) + " , " + BeanInspector.toString(parentPop.getEAIndividual(i).getFitness())); // System.out.println("new fit / old fit: " +
if (newPop.getEAIndividual(i).getFitness(0) < parentPop.getEAIndividual(i).getFitness(0)) rate++; // BeanInspector.toString(newPop.getEAIndividual(i).getFitness()) +
// " , " +
// BeanInspector.toString(parentPop.getEAIndividual(i).getFitness()));
if (newPop.getEAIndividual(i).getFitness(0) < parentPop
.getEAIndividual(i).getFitness(0))
rate++;
} }
rate = rate / parentPop.size(); rate = rate / parentPop.size();
if (updateSelected) for (int i = 0; i < selectedPop.size(); i++) { // applied to the old population as well in case of plus strategy if (updateSelected)
MutateESCovarianceMatrixAdaptionPlus mutator = (MutateESCovarianceMatrixAdaptionPlus)((AbstractEAIndividual)selectedPop.get(i)).getMutationOperator(); for (int i = 0; i < selectedPop.size(); i++) { // applied to the old
// population as
// well in case of
// plus strategy
MutateESCovarianceMatrixAdaptionPlus mutator = (MutateESCovarianceMatrixAdaptionPlus) ((AbstractEAIndividual) selectedPop
.get(i)).getMutationOperator();
updateMutator(rate, mutator); updateMutator(rate, mutator);
if(selectedPop.getEAIndividual(i).getFitness(0)<=parentPop.getEAIndividual(0).getFitness(0)){ if (selectedPop.getEAIndividual(i).getFitness(0) <= parentPop
mutator.adaptStrategyGen(selectedPop.getEAIndividual(i),parentPop.getEAIndividual(0)); .getEAIndividual(0).getFitness(0)) {
mutator.adaptStrategyGen(selectedPop.getEAIndividual(i),
parentPop.getEAIndividual(0));
} }
// System.out.println("old pop step size " + mutator.getSigma()+ " (" + mutator+ ")"); // System.out.println("old pop step size " + mutator.getSigma()+
// " (" + mutator+ ")");
} }
for (int i = 0; i < newPop.size(); i++) { for (int i = 0; i < newPop.size(); i++) {
MutateESCovarianceMatrixAdaptionPlus mutator = (MutateESCovarianceMatrixAdaptionPlus)((AbstractEAIndividual)newPop.get(i)).getMutationOperator(); MutateESCovarianceMatrixAdaptionPlus mutator = (MutateESCovarianceMatrixAdaptionPlus) ((AbstractEAIndividual) newPop
.get(i)).getMutationOperator();
updateMutator(rate, mutator); updateMutator(rate, mutator);
if(newPop.getEAIndividual(i).getFitness(0)<=parentPop.getEAIndividual(0).getFitness(0)){ if (newPop.getEAIndividual(i).getFitness(0) <= parentPop
mutator.adaptStrategyGen(newPop.getEAIndividual(i),parentPop.getEAIndividual(0)); .getEAIndividual(0).getFitness(0)) {
mutator.adaptStrategyGen(newPop.getEAIndividual(i), parentPop
.getEAIndividual(0));
} }
// System.out.println("new pop step size " + mutator.getSigma()+ " (" + mutator+ ")"); // System.out.println("new pop step size " + mutator.getSigma()+
// " (" + mutator+ ")");
} }
} }
private void updateMutator(double rate, MutateESCovarianceMatrixAdaptionPlus mutator) { private void updateMutator(double rate,
MutateESCovarianceMatrixAdaptionPlus mutator) {
mutator.updateStepSize(rate); mutator.updateStepSize(rate);
} }
public double getM_psuccess() { public double getM_psuccess() {
return m_psuccess; return m_psuccess;
} }
public void updateStepSize(double psuccess) { public void updateStepSize(double psuccess) {
this.m_psuccess = (1 - m_cp) * m_psuccess + m_cp * psuccess; this.m_psuccess = (1 - m_cp) * m_psuccess + m_cp * psuccess;
m_SigmaGlobal=m_SigmaGlobal*Math.exp(1/m_stepd*(m_psuccess-m_psuccesstarget)/(1-m_psuccesstarget)); m_SigmaGlobal = m_SigmaGlobal
* Math.exp(1 / m_stepd * (m_psuccess - m_psuccesstarget)
/ (1 - m_psuccesstarget));
} }
public String getName() { public String getName() {
return "CMA mutation for plus Strategies"; return "CMA mutation for plus Strategies";
} }
/** This method returns a global info string
/**
* This method returns a global info string
*
* @return description * @return description
*/ */
public static String globalInfo() { public static String globalInfo() {

View File

@@ -26,27 +26,24 @@ import eva2.server.go.populations.SolutionSet;
import eva2.server.go.problems.AbstractOptimizationProblem; import eva2.server.go.problems.AbstractOptimizationProblem;
import eva2.server.go.problems.InterfaceOptimizationProblem; import eva2.server.go.problems.InterfaceOptimizationProblem;
import eva2.tools.math.Mathematics; import eva2.tools.math.Mathematics;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
import eva2.tools.math.Jama.EigenvalueDecomposition; import eva2.tools.math.Jama.EigenvalueDecomposition;
import eva2.tools.math.Jama.Matrix; import eva2.tools.math.Jama.Matrix;
public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable {
{
class CounterClass { class CounterClass {
public CounterClass(int i) { public CounterClass(int i) {
value = i; value = i;
} }
public int value; public int value;
public boolean seen = false; public boolean seen = false;
} }
private String m_Identifier = "NelderMeadSimplex"; private String m_Identifier = "NelderMeadSimplex";
private Population m_Population; private Population m_Population;
private AbstractOptimizationProblem m_Problem; private AbstractOptimizationProblem m_Problem;
@@ -55,8 +52,6 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
private int m_lambda = 1; private int m_lambda = 1;
private int m_lambdamo = 1; private int m_lambdamo = 1;
public MultiObjectiveCMAES() { public MultiObjectiveCMAES() {
m_Population = new Population(m_lambdamo); m_Population = new Population(m_lambdamo);
} }
@@ -72,57 +67,58 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
return new MultiObjectiveCMAES(this); return new MultiObjectiveCMAES(this);
} }
// @Override
@Override
public void SetIdentifier(String name) { public void SetIdentifier(String name) {
m_Identifier = name; m_Identifier = name;
} }
@Override // @Override
public void SetProblem(InterfaceOptimizationProblem problem) { public void SetProblem(InterfaceOptimizationProblem problem) {
m_Problem = (AbstractOptimizationProblem) problem; m_Problem = (AbstractOptimizationProblem) problem;
} }
/** This method allows you to add the LectureGUI as listener to the Optimizer /**
* This method allows you to add the LectureGUI as listener to the Optimizer
*
* @param ea * @param ea
*/ */
public void addPopulationChangedEventListener(InterfacePopulationChangedEventListener ea) { public void addPopulationChangedEventListener(
InterfacePopulationChangedEventListener ea) {
this.m_Listener = ea; this.m_Listener = ea;
} }
// @Override
@Override
public void freeWilly() { public void freeWilly() {
} }
@Override // @Override
public InterfaceSolutionSet getAllSolutions() { public InterfaceSolutionSet getAllSolutions() {
Population pop = getPopulation(); Population pop = getPopulation();
return new SolutionSet(pop, pop); return new SolutionSet(pop, pop);
} }
@Override // @Override
public String getIdentifier() { public String getIdentifier() {
return m_Identifier; return m_Identifier;
} }
@Override // @Override
public String getName() { public String getName() {
return "(1+" + m_lambda + ") MO-CMA-ES"; return "(1+" + m_lambda + ") MO-CMA-ES";
} }
@Override // @Override
public Population getPopulation() { public Population getPopulation() {
return m_Population; return m_Population;
} }
@Override // @Override
public InterfaceOptimizationProblem getProblem() { public InterfaceOptimizationProblem getProblem() {
return m_Problem; return m_Problem;
} }
@Override // @Override
public String getStringRepresentation() { public String getStringRepresentation() {
StringBuilder strB = new StringBuilder(200); StringBuilder strB = new StringBuilder(200);
strB.append("(1+" + m_lambda + ") MO-CMA-ES:\nOptimization Problem: "); strB.append("(1+" + m_lambda + ") MO-CMA-ES:\nOptimization Problem: ");
@@ -132,7 +128,7 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
return strB.toString(); return strB.toString();
} }
@Override // @Override
public void init() { public void init() {
// initByPopulation(m_Population, true); // initByPopulation(m_Population, true);
this.m_Population.setTargetSize(m_lambdamo); this.m_Population.setTargetSize(m_lambdamo);
@@ -143,9 +139,7 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
} }
// @Override
@Override
public void initByPopulation(Population pop, boolean reset) { public void initByPopulation(Population pop, boolean reset) {
setPopulation(pop); setPopulation(pop);
if (reset) { if (reset) {
@@ -155,23 +149,27 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
} }
} }
/** This method will evaluate the current population using the /**
* given problem. * This method will evaluate the current population using the given problem.
* @param population The population that is to be evaluated *
* @param population
* The population that is to be evaluated
*/ */
private void evaluatePopulation(Population population) { private void evaluatePopulation(Population population) {
this.m_Problem.evaluate(population); this.m_Problem.evaluate(population);
} }
@Override // @Override
public void optimize() { public void optimize() {
HashMap<Long, CounterClass> SuccessCounterMap = new HashMap<Long, CounterClass>(); HashMap<Long, CounterClass> SuccessCounterMap = new HashMap<Long, CounterClass>();
//Eltern markieren und f<>r die Z<>hlung vorbereiten // Eltern markieren und f<>r die Z<>hlung vorbereiten
for (int j = 0; j < m_lambdamo && j < m_Population.size(); j++) { for (int j = 0; j < m_lambdamo && j < m_Population.size(); j++) {
m_Population.getEAIndividual(j).putData("Parent",m_Population.getEAIndividual(j) ); m_Population.getEAIndividual(j).putData("Parent",
SuccessCounterMap.put(m_Population.getEAIndividual(j).getIndyID(),new CounterClass(0)); m_Population.getEAIndividual(j));
SuccessCounterMap.put(m_Population.getEAIndividual(j).getIndyID(),
new CounterClass(0));
} }
// Kinder erzeugen // Kinder erzeugen
@@ -179,7 +177,8 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
children.setGenerationTo(m_Population.getGeneration()); children.setGenerationTo(m_Population.getGeneration());
for (int j = 0; j < children.getTargetSize(); j++) { for (int j = 0; j < children.getTargetSize(); j++) {
AbstractEAIndividual parent=m_Population.getEAIndividual(j%m_lambdamo); AbstractEAIndividual parent = m_Population.getEAIndividual(j
% m_lambdamo);
AbstractEAIndividual indy = (AbstractEAIndividual) parent.clone(); AbstractEAIndividual indy = (AbstractEAIndividual) parent.clone();
indy.mutate(); indy.mutate();
indy.putData("Parent", parent); indy.putData("Parent", parent);
@@ -187,23 +186,32 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
} }
evaluatePopulation(children); evaluatePopulation(children);
m_Population.addPopulation(children); m_Population.addPopulation(children);
// Ranking // Ranking
ArchivingNSGAII dummyArchive = new ArchivingNSGAIISMeasure(); ArchivingNSGAII dummyArchive = new ArchivingNSGAIISMeasure();
Population []store=dummyArchive.getNonDomiatedSortedFronts(m_Population); Population[] store = dummyArchive
.getNonDomiatedSortedFronts(m_Population);
store = dummyArchive.getNonDomiatedSortedFronts(m_Population); store = dummyArchive.getNonDomiatedSortedFronts(m_Population);
dummyArchive.calculateCrowdingDistance(store); dummyArchive.calculateCrowdingDistance(store);
//Vergleichen und den Successcounter hochz<68>hlen wenn wir besser als unser Elter sind // Vergleichen und den Successcounter hochz<68>hlen wenn wir besser als
// unser Elter sind
for (int j = 0; j < m_Population.size(); j++) { for (int j = 0; j < m_Population.size(); j++) {
AbstractEAIndividual parent= (AbstractEAIndividual) m_Population.getEAIndividual(j).getData("Parent"); AbstractEAIndividual parent = (AbstractEAIndividual) m_Population
if(m_Population.getEAIndividual(j)!=parent){ //Eltern nicht mit sich selber vergleichen .getEAIndividual(j).getData("Parent");
int parentParetoLevel=((Integer) parent.getData("ParetoLevel")).intValue(); if (m_Population.getEAIndividual(j) != parent) { // Eltern nicht mit
double parentSMeasure=((Double) parent.getData("HyperCube")).doubleValue(); // sich selber
int childParetoLevel=((Integer) m_Population.getEAIndividual(j).getData("ParetoLevel")).intValue(); // vergleichen
double childSMeasure=((Double) m_Population.getEAIndividual(j).getData("HyperCube")).doubleValue(); int parentParetoLevel = ((Integer) parent
if( childParetoLevel<parentParetoLevel||((childParetoLevel==parentParetoLevel)&&childSMeasure>parentSMeasure ) ){ .getData("ParetoLevel")).intValue();
double parentSMeasure = ((Double) parent.getData("HyperCube"))
.doubleValue();
int childParetoLevel = ((Integer) m_Population.getEAIndividual(
j).getData("ParetoLevel")).intValue();
double childSMeasure = ((Double) m_Population
.getEAIndividual(j).getData("HyperCube")).doubleValue();
if (childParetoLevel < parentParetoLevel
|| ((childParetoLevel == parentParetoLevel) && childSMeasure > parentSMeasure)) {
SuccessCounterMap.get(parent.getIndyID()).value++; SuccessCounterMap.get(parent.getIndyID()).value++;
} }
} else { // Debug } else { // Debug
@@ -212,20 +220,28 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
} }
} }
// Selection // Selection
m_Population.clear(); m_Population.clear();
for (int i = 0; i < store.length; i++) { for (int i = 0; i < store.length; i++) {
if(m_Population.size()+store[i].size()<=m_lambdamo){ //Die Front passt noch komplett if (m_Population.size() + store[i].size() <= m_lambdamo) { // Die
// Front
// passt
// noch
// komplett
m_Population.addPopulation(store[i]); m_Population.addPopulation(store[i]);
} else { // die besten aus der aktuellen Front heraussuchen bis voll } else { // die besten aus der aktuellen Front heraussuchen bis voll
while (store[i].size() > 0 && m_Population.size() < m_lambdamo) { while (store[i].size() > 0 && m_Population.size() < m_lambdamo) {
AbstractEAIndividual indy = store[i].getEAIndividual(0); AbstractEAIndividual indy = store[i].getEAIndividual(0);
double bestMeasure=((Double) indy.getData("HyperCube")).doubleValue(); //TODO mal noch effizient machen (sortieren und die besten n herausholen) double bestMeasure = ((Double) indy.getData("HyperCube"))
.doubleValue(); // TODO mal noch effizient machen
// (sortieren und die besten n
// herausholen)
for (int j = 1; j < store[i].size(); j++) { for (int j = 1; j < store[i].size(); j++) {
if(bestMeasure<((Double) store[i].getEAIndividual(j).getData("HyperCube")).doubleValue()){ if (bestMeasure < ((Double) store[i].getEAIndividual(j)
bestMeasure=((Double) store[i].getEAIndividual(j).getData("HyperCube")).doubleValue(); .getData("HyperCube")).doubleValue()) {
bestMeasure = ((Double) store[i].getEAIndividual(j)
.getData("HyperCube")).doubleValue();
indy = store[i].getEAIndividual(j); indy = store[i].getEAIndividual(j);
} }
} }
@@ -240,10 +256,23 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
for (int j = 0; j < m_Population.size(); j++) { for (int j = 0; j < m_Population.size(); j++) {
AbstractEAIndividual indy = m_Population.getEAIndividual(j); AbstractEAIndividual indy = m_Population.getEAIndividual(j);
if(indy.getMutationOperator() instanceof MutateESCovarianceMatrixAdaptionPlus ){ //Das geht nur wenn wir auch die richtige Mutation haben if (indy.getMutationOperator() instanceof MutateESCovarianceMatrixAdaptionPlus) { // Das
AbstractEAIndividual parent=(AbstractEAIndividual)indy.getData("Parent"); // geht
MutateESCovarianceMatrixAdaptionPlus muta=(MutateESCovarianceMatrixAdaptionPlus) indy.getMutationOperator(); // nur
double rate=((double) SuccessCounterMap.get(parent.getIndyID()).value)/((double) m_lambda); // wenn
// wir
// auch
// die
// richtige
// Mutation
// haben
AbstractEAIndividual parent = (AbstractEAIndividual) indy
.getData("Parent");
MutateESCovarianceMatrixAdaptionPlus muta = (MutateESCovarianceMatrixAdaptionPlus) indy
.getMutationOperator();
double rate = ((double) SuccessCounterMap.get(parent
.getIndyID()).value)
/ ((double) m_lambda);
if (indy != parent) { if (indy != parent) {
muta.updateCovariance(); muta.updateCovariance();
@@ -262,13 +291,13 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
} }
@Override // @Override
public boolean removePopulationChangedEventListener( public boolean removePopulationChangedEventListener(
InterfacePopulationChangedEventListener ea) { InterfacePopulationChangedEventListener ea) {
return false; return false;
} }
@Override // @Override
public void setPopulation(Population pop) { public void setPopulation(Population pop) {
m_Population = pop; m_Population = pop;
m_Population.setNotifyEvalInterval(1); m_Population.setNotifyEvalInterval(1);
@@ -276,11 +305,14 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
} }
/** Something has changed /**
* Something has changed
*
* @param name * @param name
*/ */
protected void firePropertyChangedEvent(String name) { protected void firePropertyChangedEvent(String name) {
if (this.m_Listener != null) this.m_Listener.registerPopulationStateChanged(this, name); if (this.m_Listener != null)
this.m_Listener.registerPopulationStateChanged(this, name);
} }
public int getLambda() { public int getLambda() {
@@ -291,13 +323,10 @@ public class MultiObjectiveCMAES implements InterfaceOptimizer, Serializable
m_lambda = mLambda; m_lambda = mLambda;
} }
/*public int getLambdaMo() { /*
return m_lambdamo; * public int getLambdaMo() { return m_lambdamo; }
} *
* public void setLambdaMo(int mLambda) { m_lambdamo = mLambda; }
public void setLambdaMo(int mLambda) { */
m_lambdamo = mLambda;
}*/
} }