Removed another 1k m_
This commit is contained in:
parent
46bff71b69
commit
7223d27a08
@ -12,14 +12,9 @@ import eva2.tools.chart2d.DPointIcon;
|
||||
* This is an abstract archiving strategy giving default implementation of determining
|
||||
* dominance, inserting individuals in exsisting Pareto front (removing now dominated solutions)
|
||||
* and some plot methods typically used for debugging.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 04.08.2003
|
||||
* Time: 17:00:44
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public abstract class AbstractArchiving implements InterfaceArchiving, java.io.Serializable {
|
||||
transient protected Plot m_Plot = null;
|
||||
transient protected Plot plot = null;
|
||||
protected int p = 0;
|
||||
public boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
|
@ -7,11 +7,6 @@ import eva2.optimization.population.Population;
|
||||
/**
|
||||
* This simple strategy simply archives all Pareto optimal solutions. This method is
|
||||
* very prone to OutOfMemory errors!
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 28.07.2003
|
||||
* Time: 14:40:43
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class ArchivingAllDominating extends AbstractArchiving implements java.io.Serializable {
|
||||
|
||||
|
@ -20,17 +20,17 @@ import eva2.tools.chart2d.DPointIcon;
|
||||
*/
|
||||
public class ArchivingMaxiMin implements InterfaceArchiving, java.io.Serializable {
|
||||
|
||||
private MOSOMaxiMin m_MaxiMin = new MOSOMaxiMin();
|
||||
private InterfaceSelection m_Selection = new SelectBestIndividuals();
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private MOSOMaxiMin maxiMin = new MOSOMaxiMin();
|
||||
private InterfaceSelection selection = new SelectBestIndividuals();
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public ArchivingMaxiMin() {
|
||||
}
|
||||
|
||||
public ArchivingMaxiMin(ArchivingMaxiMin a) {
|
||||
this.m_MaxiMin = new MOSOMaxiMin();
|
||||
this.m_Selection = (InterfaceSelection) a.m_Selection.clone();
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.maxiMin = new MOSOMaxiMin();
|
||||
this.selection = (InterfaceSelection) a.selection.clone();
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,10 +60,10 @@ public class ArchivingMaxiMin implements InterfaceArchiving, java.io.Serializabl
|
||||
tmpPop.removeRedundantIndiesUsingFitness();
|
||||
|
||||
// Now calculate the MaxiMin Criterium
|
||||
this.m_MaxiMin.convertMultiObjective2SingleObjective(tmpPop);
|
||||
this.m_Selection.setObeyDebsConstViolationPrinciple(this.m_ObeyDebsConstViolationPrinciple);
|
||||
this.m_Selection.prepareSelection(tmpPop);
|
||||
archive = this.m_Selection.selectFrom(tmpPop, pop.getArchive().getTargetSize());
|
||||
this.maxiMin.convertMultiObjective2SingleObjective(tmpPop);
|
||||
this.selection.setObeyDebsConstViolationPrinciple(this.obeyDebsConstViolationPrinciple);
|
||||
this.selection.prepareSelection(tmpPop);
|
||||
archive = this.selection.selectFrom(tmpPop, pop.getArchive().getTargetSize());
|
||||
archive.setTargetSize(pop.getArchive().getTargetSize());
|
||||
|
||||
// now unconvert from SO to MO
|
||||
@ -113,11 +113,11 @@ public class ArchivingMaxiMin implements InterfaceArchiving, java.io.Serializabl
|
||||
* @param pop The selection method used.
|
||||
*/
|
||||
public void setSelectionMethod(InterfaceSelection pop) {
|
||||
this.m_Selection = pop;
|
||||
this.selection = pop;
|
||||
}
|
||||
|
||||
public InterfaceSelection getSelectionMethod() {
|
||||
return this.m_Selection;
|
||||
return this.selection;
|
||||
}
|
||||
|
||||
public String selectionMethodTipText() {
|
||||
@ -131,11 +131,11 @@ public class ArchivingMaxiMin implements InterfaceArchiving, java.io.Serializabl
|
||||
* @param b The new state
|
||||
*/
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
@ -144,15 +144,15 @@ public class ArchivingMaxiMin implements InterfaceArchiving, java.io.Serializabl
|
||||
}
|
||||
//extends AbstractArchiving implements java.io.Serializable {
|
||||
//
|
||||
// private MOSOMaxiMin m_MaxiMin = new MOSOMaxiMin();
|
||||
// private InterfaceSelection m_Selection = new SelectBestIndividuals();
|
||||
// private MOSOMaxiMin maxiMin = new MOSOMaxiMin();
|
||||
// private InterfaceSelection selections = new SelectBestIndividuals();
|
||||
//
|
||||
// public ArchivingMaxiMin() {
|
||||
// }
|
||||
//
|
||||
// public ArchivingMaxiMin(ArchivingMaxiMin a) {
|
||||
// this.m_MaxiMin = new MOSOMaxiMin();
|
||||
// this.m_Selection = (InterfaceSelection)a.m_Selection.clone();
|
||||
// this.maxiMin = new MOSOMaxiMin();
|
||||
// this.selections = (InterfaceSelection)a.selections.clone();
|
||||
// }
|
||||
//
|
||||
// public Object clone() {
|
||||
@ -176,9 +176,9 @@ public class ArchivingMaxiMin implements InterfaceArchiving, java.io.Serializabl
|
||||
// tmpPop.removeDoubleInstancesUsingFitness();
|
||||
//
|
||||
// // Now calculate the MaxiMin Criterium
|
||||
// this.m_MaxiMin.convertMultiObjective2SingleObjective(tmpPop);
|
||||
// this.m_Selection.prepareSelection(tmpPop);
|
||||
// archive = this.m_Selection.selectFrom(tmpPop, pop.getArchive().getPopulationSize());
|
||||
// this.maxiMin.convertMultiObjective2SingleObjective(tmpPop);
|
||||
// this.selections.prepareSelection(tmpPop);
|
||||
// archive = this.selections.selectFrom(tmpPop, pop.getArchive().getPopulationSize());
|
||||
// archive.setPopulationSize(pop.getArchive().getPopulationSize());
|
||||
//
|
||||
// // now unconvert from SO to MO
|
||||
@ -219,10 +219,10 @@ public class ArchivingMaxiMin implements InterfaceArchiving, java.io.Serializabl
|
||||
// * @param pop The selection method used.
|
||||
// */
|
||||
// public void setSelectionMethod(InterfaceSelection pop) {
|
||||
// this.m_Selection = pop;
|
||||
// this.selections = pop;
|
||||
// }
|
||||
// public InterfaceSelection getSelectionMethod() {
|
||||
// return this.m_Selection;
|
||||
// return this.selections;
|
||||
// }
|
||||
// public String selectionMethodTipText() {
|
||||
// return "Choose the selection method (single-criteria ones please).";
|
||||
|
@ -9,13 +9,13 @@ import eva2.optimization.population.Population;
|
||||
@eva2.util.annotation.Description(value ="Non-dominating sorting GA revision 1.0.")
|
||||
public class ArchivingNSGA extends AbstractArchiving implements java.io.Serializable {
|
||||
|
||||
public InterfaceRemoveSurplusIndividuals m_Cleaner = new RemoveSurplusIndividualsDynamicHyperCube();
|
||||
public InterfaceRemoveSurplusIndividuals cleaner = new RemoveSurplusIndividualsDynamicHyperCube();
|
||||
|
||||
public ArchivingNSGA() {
|
||||
}
|
||||
|
||||
public ArchivingNSGA(ArchivingNSGA a) {
|
||||
this.m_Cleaner = (InterfaceRemoveSurplusIndividuals) a.m_Cleaner.clone();
|
||||
this.cleaner = (InterfaceRemoveSurplusIndividuals) a.cleaner.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,7 +48,7 @@ public class ArchivingNSGA extends AbstractArchiving implements java.io.Serializ
|
||||
// Now clear the archive of surplus individuals
|
||||
Population archive = pop.getArchive();
|
||||
|
||||
this.m_Cleaner.removeSurplusIndividuals(archive);
|
||||
this.cleaner.removeSurplusIndividuals(archive);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,11 +67,11 @@ public class ArchivingNSGA extends AbstractArchiving implements java.io.Serializ
|
||||
* @param s The design mode.
|
||||
*/
|
||||
public void setCleaner(InterfaceRemoveSurplusIndividuals s) {
|
||||
this.m_Cleaner = s;
|
||||
this.cleaner = s;
|
||||
}
|
||||
|
||||
public InterfaceRemoveSurplusIndividuals getCleaner() {
|
||||
return this.m_Cleaner;
|
||||
return this.cleaner;
|
||||
}
|
||||
|
||||
public String cleanerTipText() {
|
||||
|
@ -72,7 +72,7 @@ public class ArchivingNSGAII extends ArchivingNSGA implements java.io.Serializab
|
||||
// therefore we could add some individuals from front[index]
|
||||
// to the archive using the crowding distance sorting
|
||||
fronts[index].setTargetSize(archive.getTargetSize() - archive.size());
|
||||
this.m_Cleaner.removeSurplusIndividuals(fronts[index]);
|
||||
this.cleaner.removeSurplusIndividuals(fronts[index]);
|
||||
archive.addPopulation(fronts[index]);
|
||||
}
|
||||
for (int i = 0; i < fronts.length; i++) {
|
||||
|
@ -17,13 +17,13 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class ArchivingPESAII extends AbstractArchiving implements java.io.Serializable {
|
||||
|
||||
private int m_GridSize = 4;
|
||||
private int gridSize = 4;
|
||||
|
||||
public ArchivingPESAII() {
|
||||
}
|
||||
|
||||
public ArchivingPESAII(ArchivingPESAII a) {
|
||||
this.m_GridSize = a.m_GridSize;
|
||||
this.gridSize = a.gridSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -112,7 +112,7 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
|
||||
}
|
||||
// if (debug) {
|
||||
// System.out.println("The bounds are ("+bounds[0][0]+"/"+bounds[0][1]+")("+bounds[1][0]+"/"+bounds[1][1]+")");
|
||||
// System.out.println("Gridwidth is "+((bounds[0][1] - bounds[0][0])/this.m_GridSize)+"/"+((bounds[1][1] - bounds[1][0])/this.m_GridSize));
|
||||
// System.out.println("Gridwidth is "+((bounds[0][1] - bounds[0][0])/this.gridSize)+"/"+((bounds[1][1] - bounds[1][0])/this.gridSize));
|
||||
// }
|
||||
|
||||
// now that i got the bounds i can calculate the squeeze grid
|
||||
@ -128,7 +128,7 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
|
||||
tmpFit = ((AbstractEAIndividual) pop.get(i)).getFitness();
|
||||
coll = new ArrayList();
|
||||
for (int j = 0; j < tmpFit.length; j++) {
|
||||
grid[j] = (bounds[j][1] - bounds[j][0]) / this.m_GridSize;
|
||||
grid[j] = (bounds[j][1] - bounds[j][0]) / this.gridSize;
|
||||
curGrid[j] = (int) ((tmpFit[j] - bounds[j][0]) / grid[j]);
|
||||
}
|
||||
// if (debug) {
|
||||
@ -201,11 +201,11 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
|
||||
* @param b The new size of a grid element.
|
||||
*/
|
||||
public void setGridSize(int b) {
|
||||
this.m_GridSize = b;
|
||||
this.gridSize = b;
|
||||
}
|
||||
|
||||
public int getGridSize() {
|
||||
return this.m_GridSize;
|
||||
return this.gridSize;
|
||||
}
|
||||
|
||||
public String gridSizeTipText() {
|
||||
|
@ -14,22 +14,17 @@ import eva2.tools.chart2d.DPoint;
|
||||
/**
|
||||
* The strength Pareto EA in it's second version, which is based on
|
||||
* dominance counts.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 31.03.2004
|
||||
* Time: 15:01:06
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class ArchivingSPEAII extends AbstractArchiving implements java.io.Serializable {
|
||||
|
||||
private InterfaceDistanceMetric m_Metric = new ObjectiveSpaceMetric();
|
||||
private InterfaceDistanceMetric metric = new ObjectiveSpaceMetric();
|
||||
private boolean soutDebug = false;
|
||||
|
||||
public ArchivingSPEAII() {
|
||||
}
|
||||
|
||||
public ArchivingSPEAII(ArchivingSPEAII a) {
|
||||
this.m_Metric = (InterfaceDistanceMetric) a.m_Metric.clone();
|
||||
this.metric = (InterfaceDistanceMetric) a.metric.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,7 +65,7 @@ public class ArchivingSPEAII extends AbstractArchiving implements java.io.Serial
|
||||
Population archive = new Population();
|
||||
archive.setTargetSize(pop.getArchive().getTargetSize());
|
||||
|
||||
// archive = this.m_Selection.selectFrom(tmpPop, archive.getPopulationSize());
|
||||
// archive = this.selections.selectFrom(tmpPop, archive.getPopulationSize());
|
||||
|
||||
// first i'll add all non-dominated
|
||||
for (int i = 0; i < RawFitness.length; i++) {
|
||||
@ -201,10 +196,10 @@ public class ArchivingSPEAII extends AbstractArchiving implements java.io.Serial
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
System.out.println("Result " + i + ": " + result[i]);
|
||||
}
|
||||
this.m_Plot = new Plot("Debug SPEAII", "Y1", "Y2", true);
|
||||
this.m_Plot.setUnconnectedPoint(0, 0, 11);
|
||||
this.m_Plot.setUnconnectedPoint(1.2, 2.0, 11);
|
||||
GraphPointSet mySet = new GraphPointSet(10, this.m_Plot.getFunctionArea());
|
||||
this.plot = new Plot("Debug SPEAII", "Y1", "Y2", true);
|
||||
this.plot.setUnconnectedPoint(0, 0, 11);
|
||||
this.plot.setUnconnectedPoint(1.2, 2.0, 11);
|
||||
GraphPointSet mySet = new GraphPointSet(10, this.plot.getFunctionArea());
|
||||
double[][] trueFitness;
|
||||
trueFitness = new double[pop.size()][];
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
@ -253,7 +248,7 @@ public class ArchivingSPEAII extends AbstractArchiving implements java.io.Serial
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
distMatrix[i][i] = 0.0;
|
||||
for (int j = i + 1; j < pop.size(); j++) {
|
||||
distMatrix[i][j] = this.m_Metric.distance((AbstractEAIndividual) pop.get(i), (AbstractEAIndividual) pop.get(j));
|
||||
distMatrix[i][j] = this.metric.distance((AbstractEAIndividual) pop.get(i), (AbstractEAIndividual) pop.get(j));
|
||||
distMatrix[j][i] = distMatrix[i][j];
|
||||
}
|
||||
}
|
||||
@ -345,7 +340,7 @@ public class ArchivingSPEAII extends AbstractArchiving implements java.io.Serial
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
distMatrix[i][i] = 0.0;
|
||||
for (int j = i + 1; j < pop.size(); j++) {
|
||||
distMatrix[i][j] = this.m_Metric.distance((AbstractEAIndividual) pop.get(i), (AbstractEAIndividual) pop.get(j));
|
||||
distMatrix[i][j] = this.metric.distance((AbstractEAIndividual) pop.get(i), (AbstractEAIndividual) pop.get(j));
|
||||
distMatrix[j][i] = distMatrix[i][j];
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,6 @@ import eva2.optimization.population.Population;
|
||||
* This information retrieval inserts the retrieved
|
||||
* solutions, by removing random individuals from the
|
||||
* population.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 11.03.2004
|
||||
* Time: 14:55:18
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class InformationRetrievalInserting implements InterfaceInformationRetrieval, java.io.Serializable {
|
||||
|
||||
|
@ -6,11 +6,6 @@ import eva2.tools.math.RNG;
|
||||
/**
|
||||
* This information retrieval method simply add the retrieved solutions
|
||||
* to the current population.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 11.03.2004
|
||||
* Time: 15:01:45
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class InformationRetrievalReplacing implements InterfaceInformationRetrieval, java.io.Serializable {
|
||||
|
||||
|
@ -10,11 +10,6 @@ import eva2.tools.math.RNG;
|
||||
* space. But i guess currently you can't toggel that. But here
|
||||
* the hybercubes are dynamic, e.g. theey are recalculated after
|
||||
* an individual is removed.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 13.05.2004
|
||||
* Time: 14:36:54
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class RemoveSurplusIndividualsDynamicHyperCube implements InterfaceRemoveSurplusIndividuals, java.io.Serializable {
|
||||
|
||||
|
@ -10,11 +10,6 @@ import eva2.tools.math.RNG;
|
||||
* space. But i guess currently you can't toggel that. But here
|
||||
* the hybercubes are dynamic, e.g. theey are recalculated after
|
||||
* an individual is removed.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 13.05.2004
|
||||
* Time: 14:36:54
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class RemoveSurplusIndividualsSMetric implements InterfaceRemoveSurplusIndividuals, java.io.Serializable {
|
||||
|
||||
|
@ -10,11 +10,6 @@ import eva2.tools.math.RNG;
|
||||
* space. But i guess currently you can't toggel that. But here
|
||||
* the hybercubes are static, e.g. theey are not recalculated after
|
||||
* an individual is removed.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 13.05.2004
|
||||
* Time: 14:43:15
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class RemoveSurplusIndividualsStaticHyperCube extends RemoveSurplusIndividualsDynamicHyperCube implements java.io.Serializable {
|
||||
|
||||
|
@ -12,11 +12,6 @@ import java.awt.event.WindowEvent;
|
||||
* Self-organizing maps, a simple, but easy to visualize method
|
||||
* for classification. The Dikel flag is an undocumented extension,
|
||||
* which seems to work but is not published.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 09.12.2004
|
||||
* Time: 15:10:45
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class ClassificationSelfOrganizingMaps implements java.io.Serializable, InterfaceClassification {
|
||||
|
||||
@ -24,55 +19,55 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
* Generated serial version identifer.
|
||||
*/
|
||||
private static final long serialVersionUID = 1447707947002269263L;
|
||||
private int m_Dim1 = 5, m_Dim2 = 15;
|
||||
private int m_AlternativeClasses;
|
||||
private double[][][] m_SOM;
|
||||
private int[][][] m_SOMClass;
|
||||
private double[][] m_Range; //[dimension][min, max, mean, sigma]
|
||||
private double m_Alpha = 0.4;
|
||||
private int m_TrainingCycles = 250;
|
||||
private int m_NeighborhoodSize = 2;
|
||||
private boolean m_DikelThis = true;
|
||||
private int dim1 = 5, dim2 = 15;
|
||||
private int alternativeClasses;
|
||||
private double[][][] SOM;
|
||||
private int[][][] SOMClass;
|
||||
private double[][] range; //[dimension][min, max, mean, sigma]
|
||||
private double alpha = 0.4;
|
||||
private int trainingCycles = 250;
|
||||
private int neighborhoodSize = 2;
|
||||
private boolean dikelThis = true;
|
||||
private boolean debug = false;
|
||||
|
||||
public ClassificationSelfOrganizingMaps() {
|
||||
}
|
||||
|
||||
public ClassificationSelfOrganizingMaps(ClassificationSelfOrganizingMaps a) {
|
||||
this.m_Dim1 = a.m_Dim1;
|
||||
this.m_Dim2 = a.m_Dim2;
|
||||
this.m_AlternativeClasses = a.m_AlternativeClasses;
|
||||
this.m_NeighborhoodSize = a.m_NeighborhoodSize;
|
||||
this.m_Alpha = a.m_Alpha;
|
||||
this.m_DikelThis = a.m_DikelThis;
|
||||
this.m_TrainingCycles = a.m_TrainingCycles;
|
||||
if (a.m_SOM != null) {
|
||||
this.m_SOM = new double[a.m_SOM.length][a.m_SOM[0].length][a.m_SOM[0][0].length];
|
||||
for (int i = 0; i < a.m_SOM.length; i++) {
|
||||
for (int j = 0; j < a.m_SOM[0].length; j++) {
|
||||
for (int k = 0; k < a.m_SOM[0][0].length; k++) {
|
||||
this.m_SOM[i][j][k] = a.m_SOM[i][j][k];
|
||||
this.dim1 = a.dim1;
|
||||
this.dim2 = a.dim2;
|
||||
this.alternativeClasses = a.alternativeClasses;
|
||||
this.neighborhoodSize = a.neighborhoodSize;
|
||||
this.alpha = a.alpha;
|
||||
this.dikelThis = a.dikelThis;
|
||||
this.trainingCycles = a.trainingCycles;
|
||||
if (a.SOM != null) {
|
||||
this.SOM = new double[a.SOM.length][a.SOM[0].length][a.SOM[0][0].length];
|
||||
for (int i = 0; i < a.SOM.length; i++) {
|
||||
for (int j = 0; j < a.SOM[0].length; j++) {
|
||||
for (int k = 0; k < a.SOM[0][0].length; k++) {
|
||||
this.SOM[i][j][k] = a.SOM[i][j][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a.m_SOMClass != null) {
|
||||
this.m_SOMClass = new int[a.m_SOMClass.length][a.m_SOMClass[0].length][a.m_SOMClass[0][0].length];
|
||||
for (int i = 0; i < a.m_SOMClass.length; i++) {
|
||||
for (int j = 0; j < a.m_SOMClass[0].length; j++) {
|
||||
for (int k = 0; k < a.m_SOMClass[0][0].length; k++) {
|
||||
this.m_SOMClass[i][j][k] = a.m_SOMClass[i][j][k];
|
||||
if (a.SOMClass != null) {
|
||||
this.SOMClass = new int[a.SOMClass.length][a.SOMClass[0].length][a.SOMClass[0][0].length];
|
||||
for (int i = 0; i < a.SOMClass.length; i++) {
|
||||
for (int j = 0; j < a.SOMClass[0].length; j++) {
|
||||
for (int k = 0; k < a.SOMClass[0][0].length; k++) {
|
||||
this.SOMClass[i][j][k] = a.SOMClass[i][j][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a.m_Range != null) {
|
||||
this.m_Range = new double[a.m_Range.length][4];
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
this.m_Range[i][0] = a.m_Range[i][0];
|
||||
this.m_Range[i][1] = a.m_Range[i][1];
|
||||
this.m_Range[i][2] = a.m_Range[i][2];
|
||||
this.m_Range[i][3] = a.m_Range[i][3];
|
||||
if (a.range != null) {
|
||||
this.range = new double[a.range.length][4];
|
||||
for (int i = 0; i < this.range.length; i++) {
|
||||
this.range[i][0] = a.range[i][0];
|
||||
this.range[i][1] = a.range[i][1];
|
||||
this.range[i][2] = a.range[i][2];
|
||||
this.range[i][3] = a.range[i][3];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,34 +91,34 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
*/
|
||||
@Override
|
||||
public void init(double[][] space, int[] type) {
|
||||
this.m_AlternativeClasses = 0;
|
||||
this.alternativeClasses = 0;
|
||||
for (int i = 0; i < type.length; i++) {
|
||||
this.m_AlternativeClasses = Math.max(type[i], this.m_AlternativeClasses);
|
||||
this.alternativeClasses = Math.max(type[i], this.alternativeClasses);
|
||||
}
|
||||
this.m_AlternativeClasses++;
|
||||
this.m_SOM = new double[this.m_Dim1][this.m_Dim2][space[0].length];
|
||||
this.m_SOMClass = new int[this.m_Dim1][this.m_Dim2][this.m_AlternativeClasses];
|
||||
this.m_Range = new double[space[0].length][4];
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
this.m_Range[i][0] = Double.POSITIVE_INFINITY;
|
||||
this.m_Range[i][1] = Double.NEGATIVE_INFINITY;
|
||||
this.m_Range[i][2] = 0;
|
||||
this.m_Range[i][3] = 0;
|
||||
this.alternativeClasses++;
|
||||
this.SOM = new double[this.dim1][this.dim2][space[0].length];
|
||||
this.SOMClass = new int[this.dim1][this.dim2][this.alternativeClasses];
|
||||
this.range = new double[space[0].length][4];
|
||||
for (int i = 0; i < this.range.length; i++) {
|
||||
this.range[i][0] = Double.POSITIVE_INFINITY;
|
||||
this.range[i][1] = Double.NEGATIVE_INFINITY;
|
||||
this.range[i][2] = 0;
|
||||
this.range[i][3] = 0;
|
||||
}
|
||||
for (int i = 0; i < space.length; i++) {
|
||||
for (int k = 0; k < space[0].length; k++) {
|
||||
this.m_Range[k][0] = Math.min(this.m_Range[k][0], space[i][k]);
|
||||
this.m_Range[k][1] = Math.max(this.m_Range[k][1], space[i][k]);
|
||||
this.m_Range[k][2] += space[i][k];
|
||||
this.range[k][0] = Math.min(this.range[k][0], space[i][k]);
|
||||
this.range[k][1] = Math.max(this.range[k][1], space[i][k]);
|
||||
this.range[k][2] += space[i][k];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
this.m_Range[i][2] /= ((double) space.length);
|
||||
for (int i = 0; i < this.range.length; i++) {
|
||||
this.range[i][2] /= ((double) space.length);
|
||||
for (int j = 0; j < space.length; j++) {
|
||||
this.m_Range[i][3] += Math.pow((this.m_Range[i][2] - space[j][i]), 2);
|
||||
this.range[i][3] += Math.pow((this.range[i][2] - space[j][i]), 2);
|
||||
}
|
||||
this.m_Range[i][3] = Math.sqrt(this.m_Range[i][3] / ((double) space.length));
|
||||
// System.out.println("Range: ["+this.m_Range[i][0]+", "+this.m_Range[i][1]+"] Mean: "+this.m_Range[i][2]+" Var: "+this.m_Range[i][3]);
|
||||
this.range[i][3] = Math.sqrt(this.range[i][3] / ((double) space.length));
|
||||
// System.out.println("Range: ["+this.range[i][0]+", "+this.range[i][1]+"] Mean: "+this.range[i][2]+" Var: "+this.range[i][3]);
|
||||
}
|
||||
this.initSOM();
|
||||
// if (this.debug) this.drawSOM(space, type);
|
||||
@ -133,15 +128,15 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
* This method inits the weights of the SOM in the current range
|
||||
*/
|
||||
private void initSOM() {
|
||||
for (int i = 0; i < this.m_SOM.length; i++) {
|
||||
for (int j = 0; j < this.m_SOM[0].length; j++) {
|
||||
for (int k = 0; k < this.m_SOM[0][0].length; k++) {
|
||||
this.m_SOM[i][j][k] = 0 * RNG.randomDouble(
|
||||
(this.m_Range[k][0] - this.m_Range[k][2]) / (1 + this.m_Range[k][3]),
|
||||
(this.m_Range[k][1] - this.m_Range[k][2]) / (1 + this.m_Range[k][3]));
|
||||
for (int i = 0; i < this.SOM.length; i++) {
|
||||
for (int j = 0; j < this.SOM[0].length; j++) {
|
||||
for (int k = 0; k < this.SOM[0][0].length; k++) {
|
||||
this.SOM[i][j][k] = 0 * RNG.randomDouble(
|
||||
(this.range[k][0] - this.range[k][2]) / (1 + this.range[k][3]),
|
||||
(this.range[k][1] - this.range[k][2]) / (1 + this.range[k][3]));
|
||||
}
|
||||
for (int k = 0; k < this.m_SOMClass[0][0].length; k++) {
|
||||
this.m_SOMClass[i][j][k] = 0;
|
||||
for (int k = 0; k < this.SOMClass[0][0].length; k++) {
|
||||
this.SOMClass[i][j][k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -158,24 +153,24 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
@Override
|
||||
public void train(double[][] space, int[] type) {
|
||||
// first init the assignment to zero
|
||||
for (int i = 0; i < this.m_SOM.length; i++) {
|
||||
for (int j = 0; j < this.m_SOM[0].length; j++) {
|
||||
for (int k = 0; k < this.m_SOMClass[0][0].length; k++) {
|
||||
this.m_SOMClass[i][j][k] = 0;
|
||||
for (int i = 0; i < this.SOM.length; i++) {
|
||||
for (int j = 0; j < this.SOM[0].length; j++) {
|
||||
for (int k = 0; k < this.SOMClass[0][0].length; k++) {
|
||||
this.SOMClass[i][j][k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// now train the stuff
|
||||
int[] order;
|
||||
int[] winner;
|
||||
for (int t = 0; t < this.m_TrainingCycles; t++) {
|
||||
for (int t = 0; t < this.trainingCycles; t++) {
|
||||
// train the full set
|
||||
order = RNG.randomPerm(space.length);
|
||||
for (int i = 0; i < order.length; i++) {
|
||||
winner = this.findWinningNeuron(space[order[i]]);
|
||||
// now i got the winning neuron *puh*
|
||||
// update this neuron and the neighbors
|
||||
this.update(winner, space[order[i]], t / ((double) this.m_TrainingCycles));
|
||||
this.update(winner, space[order[i]], t / ((double) this.trainingCycles));
|
||||
|
||||
}
|
||||
// if (this.debug) this.drawSOM(space, type);
|
||||
@ -184,7 +179,7 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
// most likely it is a percentage value
|
||||
for (int i = 0; i < space.length; i++) {
|
||||
winner = this.findWinningNeuron(space[i]);
|
||||
this.m_SOMClass[winner[0]][winner[1]][type[i]]++;
|
||||
this.SOMClass[winner[0]][winner[1]][type[i]]++;
|
||||
}
|
||||
if (this.debug) {
|
||||
this.drawSOM(space, type);
|
||||
@ -199,25 +194,25 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
* @param t The current time
|
||||
*/
|
||||
private void update(int[] w, double[] data, double t) {
|
||||
double a = this.m_Alpha * (1 - t);
|
||||
double a = this.alpha * (1 - t);
|
||||
double dist;
|
||||
int[] tmpI = new int[2];
|
||||
|
||||
// move the winner to the data point
|
||||
if (this.m_DikelThis) {
|
||||
if (this.dikelThis) {
|
||||
this.drikelWinnerTo(w, data, a);
|
||||
} else {
|
||||
this.moveNeuronTo(w, data, a);
|
||||
}
|
||||
|
||||
// move the neighbors to the data point
|
||||
for (int i = -this.m_NeighborhoodSize; i <= this.m_NeighborhoodSize; i++) {
|
||||
for (int j = -this.m_NeighborhoodSize; j <= this.m_NeighborhoodSize; j++) {
|
||||
for (int i = -this.neighborhoodSize; i <= this.neighborhoodSize; i++) {
|
||||
for (int j = -this.neighborhoodSize; j <= this.neighborhoodSize; j++) {
|
||||
// not the original point
|
||||
if ((j != 0) || (i != 0)) {
|
||||
// not outside the array
|
||||
if ((this.m_SOM.length > w[0] + i) && (w[0] + i >= 0)
|
||||
&& (this.m_SOM[0].length > w[1] + j) && (w[1] + j >= 0)) {
|
||||
if ((this.SOM.length > w[0] + i) && (w[0] + i >= 0)
|
||||
&& (this.SOM[0].length > w[1] + j) && (w[1] + j >= 0)) {
|
||||
dist = Math.sqrt(i * i + j * j);
|
||||
tmpI[0] = w[0] + i;
|
||||
tmpI[1] = w[1] + j;
|
||||
@ -239,9 +234,9 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
result[0] = 0;
|
||||
result[1] = 0;
|
||||
// find the winning neuron for order[j]
|
||||
for (int m = 0; m < this.m_SOM.length; m++) {
|
||||
for (int n = 0; n < this.m_SOM[0].length; n++) {
|
||||
dist = this.distance(this.m_SOM[m][n], data);
|
||||
for (int m = 0; m < this.SOM.length; m++) {
|
||||
for (int n = 0; n < this.SOM[0].length; n++) {
|
||||
dist = this.distance(this.SOM[m][n], data);
|
||||
if (minDist > dist) {
|
||||
minDist = dist;
|
||||
result[0] = m;
|
||||
@ -264,7 +259,7 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
double result = 0;
|
||||
|
||||
for (int i = 0; i < n.length; i++) {
|
||||
result += Math.pow(n[i] - (d[i] - this.m_Range[i][2]) / (1 + this.m_Range[i][3]), 2);
|
||||
result += Math.pow(n[i] - (d[i] - this.range[i][2]) / (1 + this.range[i][3]), 2);
|
||||
}
|
||||
result = Math.sqrt(result);
|
||||
|
||||
@ -279,11 +274,11 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
* @param a The scaling factor
|
||||
*/
|
||||
public void moveNeuronTo(int[] w, double[] d, double a) {
|
||||
double[] vec = new double[this.m_SOM[w[0]][w[1]].length];
|
||||
double[] vec = new double[this.SOM[w[0]][w[1]].length];
|
||||
|
||||
for (int i = 0; i < this.m_SOM[w[0]][w[1]].length; i++) {
|
||||
vec[i] = (d[i] - this.m_Range[i][2]) / (1 + this.m_Range[i][3]) - this.m_SOM[w[0]][w[1]][i];
|
||||
this.m_SOM[w[0]][w[1]][i] += a * vec[i];
|
||||
for (int i = 0; i < this.SOM[w[0]][w[1]].length; i++) {
|
||||
vec[i] = (d[i] - this.range[i][2]) / (1 + this.range[i][3]) - this.SOM[w[0]][w[1]][i];
|
||||
this.SOM[w[0]][w[1]][i] += a * vec[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,11 +291,11 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
* @param a The scaling factor
|
||||
*/
|
||||
public void drikelWinnerTo(int[] w, double[] d, double a) {
|
||||
double[] vec = new double[this.m_SOM[w[0]][w[1]].length];
|
||||
double[] nec = new double[this.m_SOM[w[0]][w[1]].length];
|
||||
double[] vec = new double[this.SOM[w[0]][w[1]].length];
|
||||
double[] nec = new double[this.SOM[w[0]][w[1]].length];
|
||||
|
||||
for (int i = 0; i < this.m_SOM[w[0]][w[1]].length; i++) {
|
||||
vec[i] = (d[i] - this.m_Range[i][2]) / (1 + this.m_Range[i][3]) - this.m_SOM[w[0]][w[1]][i];
|
||||
for (int i = 0; i < this.SOM[w[0]][w[1]].length; i++) {
|
||||
vec[i] = (d[i] - this.range[i][2]) / (1 + this.range[i][3]) - this.SOM[w[0]][w[1]][i];
|
||||
nec[i] = 0;
|
||||
}
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
@ -308,18 +303,18 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
// not the original point
|
||||
if ((j != 0) || (i != 0)) {
|
||||
// not outside the array
|
||||
if ((this.m_SOM.length > w[0] + i) && (w[0] + i >= 0)
|
||||
&& (this.m_SOM[0].length > w[1] + j) && (w[1] + j >= 0)) {
|
||||
for (int k = 0; k < this.m_SOM[0][0].length; k++) {
|
||||
nec[k] += (d[k] - this.m_Range[k][2]) / (1 + this.m_Range[k][3]) - this.m_SOM[w[0] + i][w[1] + j][k];
|
||||
if ((this.SOM.length > w[0] + i) && (w[0] + i >= 0)
|
||||
&& (this.SOM[0].length > w[1] + j) && (w[1] + j >= 0)) {
|
||||
for (int k = 0; k < this.SOM[0][0].length; k++) {
|
||||
nec[k] += (d[k] - this.range[k][2]) / (1 + this.range[k][3]) - this.SOM[w[0] + i][w[1] + j][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < this.m_SOM[w[0]][w[1]].length; i++) {
|
||||
for (int i = 0; i < this.SOM[w[0]][w[1]].length; i++) {
|
||||
vec[i] -= (a / 2.0) * nec[i];
|
||||
this.m_SOM[w[0]][w[1]][i] += a * vec[i];
|
||||
this.SOM[w[0]][w[1]][i] += a * vec[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,10 +330,10 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
int mostClasses = 0;
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < this.m_SOMClass[winner[0]][winner[1]].length; i++) {
|
||||
if (mostClasses < this.m_SOMClass[winner[0]][winner[1]][i]) {
|
||||
for (int i = 0; i < this.SOMClass[winner[0]][winner[1]].length; i++) {
|
||||
if (mostClasses < this.SOMClass[winner[0]][winner[1]][i]) {
|
||||
result = i;
|
||||
mostClasses = this.m_SOMClass[winner[0]][winner[1]][i];
|
||||
mostClasses = this.SOMClass[winner[0]][winner[1]][i];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -367,16 +362,16 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
DArea area = new DArea();
|
||||
area.setBorder(myBorder);
|
||||
area.setBackground(Color.white);
|
||||
for (int i = 0; i < this.m_SOM.length; i++) {
|
||||
for (int j = 0; j < this.m_SOM[0].length; j++) {
|
||||
pos1 = this.m_SOM[i][j];
|
||||
if ((i + 1) < this.m_SOM.length) {
|
||||
pos2 = this.m_SOM[i + 1][j];
|
||||
for (int i = 0; i < this.SOM.length; i++) {
|
||||
for (int j = 0; j < this.SOM[0].length; j++) {
|
||||
pos1 = this.SOM[i][j];
|
||||
if ((i + 1) < this.SOM.length) {
|
||||
pos2 = this.SOM[i + 1][j];
|
||||
tmpL = new DLine(pos1[0], pos1[1], pos2[0], pos2[1], Color.BLACK);
|
||||
area.addDElement(tmpL);
|
||||
}
|
||||
if ((j + 1) < this.m_SOM[i].length) {
|
||||
pos2 = this.m_SOM[i][j + 1];
|
||||
if ((j + 1) < this.SOM[i].length) {
|
||||
pos2 = this.SOM[i][j + 1];
|
||||
tmpL = new DLine(pos1[0], pos1[1], pos2[0], pos2[1], Color.BLACK);
|
||||
area.addDElement(tmpL);
|
||||
}
|
||||
@ -390,7 +385,7 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
// area.addDElement(tmpP);
|
||||
// }
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
tmpP = new DPoint((data[i][0] - this.m_Range[0][2]) / (1 + this.m_Range[0][3]), (data[i][1] - this.m_Range[1][2]) / (1 + this.m_Range[1][3]));
|
||||
tmpP = new DPoint((data[i][0] - this.range[0][2]) / (1 + this.range[0][3]), (data[i][1] - this.range[1][2]) / (1 + this.range[1][3]));
|
||||
tmpP.setIcon(new Chart2DDPointIconCross());
|
||||
tmpP.setColor(this.getColorFor(types[i]));
|
||||
area.addDElement(tmpP);
|
||||
@ -407,22 +402,22 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
public JComponent getViewOnSOM() {
|
||||
DArea result = new DArea();
|
||||
result.setBackground(Color.WHITE);
|
||||
result.setVisibleRectangle(0, 0, this.m_SOM.length, this.m_SOM[0].length);
|
||||
result.setPreferredSize(new Dimension(this.m_SOM.length * 10, this.m_SOM[0].length * 10));
|
||||
result.setMinimumSize(new Dimension(this.m_SOM.length * 2, this.m_SOM[0].length * 2));
|
||||
result.setVisibleRectangle(0, 0, this.SOM.length, this.SOM[0].length);
|
||||
result.setPreferredSize(new Dimension(this.SOM.length * 10, this.SOM[0].length * 10));
|
||||
result.setMinimumSize(new Dimension(this.SOM.length * 2, this.SOM[0].length * 2));
|
||||
DRectangle tmpRect;
|
||||
int best;
|
||||
double total;
|
||||
double currentP;
|
||||
double lastP;
|
||||
for (int i = 0; i < this.m_SOM.length; i++) {
|
||||
for (int j = 0; j < this.m_SOM[i].length; j++) {
|
||||
for (int i = 0; i < this.SOM.length; i++) {
|
||||
for (int j = 0; j < this.SOM[i].length; j++) {
|
||||
total = 0;
|
||||
currentP = 0;
|
||||
lastP = 0;
|
||||
// first determine how many instances have been assigned to
|
||||
for (int k = 0; k < this.m_SOMClass[i][j].length; k++) {
|
||||
total += this.m_SOMClass[i][j][k];
|
||||
for (int k = 0; k < this.SOMClass[i][j].length; k++) {
|
||||
total += this.SOMClass[i][j][k];
|
||||
}
|
||||
// now determine the percentage for each class and draw the box
|
||||
if (false) {
|
||||
@ -430,17 +425,17 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
tmpRect = new DRectangle(i, j, 1, 1);
|
||||
tmpRect.setColor(Color.BLACK);
|
||||
best = 0;
|
||||
for (int k = 0; k < this.m_SOMClass[i][j].length; k++) {
|
||||
if (best < this.m_SOMClass[i][j][k]) {
|
||||
best = this.m_SOMClass[i][j][k];
|
||||
for (int k = 0; k < this.SOMClass[i][j].length; k++) {
|
||||
if (best < this.SOMClass[i][j][k]) {
|
||||
best = this.SOMClass[i][j][k];
|
||||
tmpRect.setFillColor(this.getColorFor(k));
|
||||
}
|
||||
}
|
||||
result.addDElement(tmpRect);
|
||||
} else {
|
||||
// try to draw the percentage for each element
|
||||
for (int k = 0; k < this.m_SOMClass[i][j].length; k++) {
|
||||
currentP = this.m_SOMClass[i][j][k] / total;
|
||||
for (int k = 0; k < this.SOMClass[i][j].length; k++) {
|
||||
currentP = this.SOMClass[i][j][k] / total;
|
||||
if (currentP > 0) {
|
||||
tmpRect = new DRectangle(i, j + lastP, 1, currentP);
|
||||
tmpRect.setColor(this.getColorFor(k));
|
||||
@ -536,11 +531,11 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
if (t < 1) {
|
||||
t = 1;
|
||||
}
|
||||
this.m_Dim1 = t;
|
||||
this.dim1 = t;
|
||||
}
|
||||
|
||||
public int getSizeX() {
|
||||
return this.m_Dim1;
|
||||
return this.dim1;
|
||||
}
|
||||
|
||||
public String sizeXTipText() {
|
||||
@ -557,11 +552,11 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
if (t < 1) {
|
||||
t = 1;
|
||||
}
|
||||
this.m_Dim2 = t;
|
||||
this.dim2 = t;
|
||||
}
|
||||
|
||||
public int getSizeY() {
|
||||
return this.m_Dim2;
|
||||
return this.dim2;
|
||||
}
|
||||
|
||||
public String sizeYTipText() {
|
||||
@ -577,11 +572,11 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
if (t < 1) {
|
||||
t = 1;
|
||||
}
|
||||
this.m_TrainingCycles = t;
|
||||
this.trainingCycles = t;
|
||||
}
|
||||
|
||||
public int getTrainingCycles() {
|
||||
return this.m_TrainingCycles;
|
||||
return this.trainingCycles;
|
||||
}
|
||||
|
||||
public String trainingCyclesTipText() {
|
||||
@ -597,11 +592,11 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
if (t < 0) {
|
||||
t = 0;
|
||||
}
|
||||
this.m_NeighborhoodSize = t;
|
||||
this.neighborhoodSize = t;
|
||||
}
|
||||
|
||||
public int getNeighborhoodSize() {
|
||||
return this.m_NeighborhoodSize;
|
||||
return this.neighborhoodSize;
|
||||
}
|
||||
|
||||
public String neighborhoodSizeTipText() {
|
||||
@ -620,11 +615,11 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
if (t > 0.5) {
|
||||
t = 0.5;
|
||||
}
|
||||
this.m_Alpha = t;
|
||||
this.alpha = t;
|
||||
}
|
||||
|
||||
public double getAlpha() {
|
||||
return this.m_Alpha;
|
||||
return this.alpha;
|
||||
}
|
||||
|
||||
public String AlphaTipText() {
|
||||
@ -637,11 +632,11 @@ public class ClassificationSelfOrganizingMaps implements java.io.Serializable, I
|
||||
* @param t The dikel factor
|
||||
*/
|
||||
public void setDikelThis(boolean t) {
|
||||
this.m_DikelThis = t;
|
||||
this.dikelThis = t;
|
||||
}
|
||||
|
||||
public boolean getDikelThis() {
|
||||
return this.m_DikelThis;
|
||||
return this.dikelThis;
|
||||
}
|
||||
|
||||
public String dikelThisTipText() {
|
||||
|
@ -9,7 +9,7 @@ package eva2.optimization.operator.classification;
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface InterfaceClassification {
|
||||
/**
|
||||
/** x
|
||||
* This method allows you to make a deep clone of
|
||||
* the object
|
||||
*
|
||||
|
@ -26,19 +26,19 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class ClusteringXMeans implements InterfaceClustering, java.io.Serializable {
|
||||
|
||||
public int m_MaxK = 5;
|
||||
public double[][] m_C;
|
||||
public boolean m_UseSearchSpace = false;
|
||||
public boolean m_Debug = false;
|
||||
public int maxK = 5;
|
||||
public double[][] C;
|
||||
public boolean useSearchSpace = false;
|
||||
public boolean debug = false;
|
||||
|
||||
public ClusteringXMeans() {
|
||||
|
||||
}
|
||||
|
||||
public ClusteringXMeans(ClusteringXMeans a) {
|
||||
this.m_Debug = a.m_Debug;
|
||||
this.m_MaxK = a.m_MaxK;
|
||||
this.m_UseSearchSpace = a.m_UseSearchSpace;
|
||||
this.debug = a.debug;
|
||||
this.maxK = a.maxK;
|
||||
this.useSearchSpace = a.useSearchSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,8 +64,8 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
@Override
|
||||
public Population[] cluster(Population pop, Population referencePop) {
|
||||
ClusteringKMeans kmeans = new ClusteringKMeans();
|
||||
Population[][] tmpResults = new Population[this.m_MaxK][];
|
||||
double[][][] tmpC = new double[this.m_MaxK][][];
|
||||
Population[][] tmpResults = new Population[this.maxK][];
|
||||
double[][][] tmpC = new double[this.maxK][][];
|
||||
double[][] data = this.extractClusterDataFrom(pop);
|
||||
|
||||
// the first result is the unclustered population
|
||||
@ -74,8 +74,8 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
tmpC[0] = new double[1][];
|
||||
tmpC[0][0] = this.calculateMean(data);
|
||||
// the other solutions are kmeans results
|
||||
for (int i = 1; i < this.m_MaxK; i++) {
|
||||
kmeans.setUseSearchSpace(this.m_UseSearchSpace);
|
||||
for (int i = 1; i < this.maxK; i++) {
|
||||
kmeans.setUseSearchSpace(this.useSearchSpace);
|
||||
kmeans.setK(i + 1);
|
||||
tmpResults[i] = kmeans.cluster(pop, (Population) null);
|
||||
tmpC[i] = kmeans.getC();
|
||||
@ -86,7 +86,7 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
int index = 0;
|
||||
for (int i = 0; i < tmpResults.length; i++) {
|
||||
tmpBIC = this.calculateBIC(tmpResults[i], tmpC[i]);
|
||||
if (this.m_Debug) {
|
||||
if (this.debug) {
|
||||
Plot plot;
|
||||
double[] tmpD = new double[2], x;
|
||||
tmpD[0] = 0;
|
||||
@ -129,7 +129,7 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
}
|
||||
System.out.println("XMeans results in " + (index + 1) + " clusters.");
|
||||
Population[] result = tmpResults[index];
|
||||
this.m_C = tmpC[index];
|
||||
this.C = tmpC[index];
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -225,7 +225,7 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
// let's fetch the raw data either the double
|
||||
// phenotype or the coordinates in objective space
|
||||
// @todo: i case of repair i would need to set the phenotype!
|
||||
if (this.m_UseSearchSpace && (pop.get(0) instanceof InterfaceDataTypeDouble)) {
|
||||
if (this.useSearchSpace && (pop.get(0) instanceof InterfaceDataTypeDouble)) {
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
data[i] = ((InterfaceDataTypeDouble) pop.get(i)).getDoubleData();
|
||||
}
|
||||
@ -274,7 +274,7 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
* @return The centroids
|
||||
*/
|
||||
public double[][] getC() {
|
||||
return this.m_C;
|
||||
return this.C;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,7 +310,7 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
public static void main(String[] args) {
|
||||
ClusteringXMeans ckm = new ClusteringXMeans();
|
||||
ckm.setUseSearchSpace(true);
|
||||
ckm.m_Debug = true;
|
||||
ckm.debug = true;
|
||||
Population pop = new Population();
|
||||
pop.setTargetSize(100);
|
||||
F1Problem f1 = new F1Problem();
|
||||
@ -393,14 +393,14 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
* @return The current number of clusters to find.
|
||||
*/
|
||||
public int getMaxK() {
|
||||
return this.m_MaxK;
|
||||
return this.maxK;
|
||||
}
|
||||
|
||||
public void setMaxK(int m) {
|
||||
if (m < 1) {
|
||||
m = 1;
|
||||
}
|
||||
this.m_MaxK = m;
|
||||
this.maxK = m;
|
||||
}
|
||||
|
||||
public String maxKTipText() {
|
||||
@ -414,11 +414,11 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
|
||||
* @return The distance type to use.
|
||||
*/
|
||||
public boolean getUseSearchSpace() {
|
||||
return this.m_UseSearchSpace;
|
||||
return this.useSearchSpace;
|
||||
}
|
||||
|
||||
public void setUseSearchSpace(boolean m) {
|
||||
this.m_UseSearchSpace = m;
|
||||
this.useSearchSpace = m;
|
||||
}
|
||||
|
||||
public String useSearchSpaceTipText() {
|
||||
|
@ -38,7 +38,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
|
||||
*/
|
||||
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
* The filePath that is to be edited
|
||||
*/
|
||||
private PropertyCrossoverMixer m_CrossoversWithWeights;
|
||||
|
||||
|
@ -8,16 +8,11 @@ import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
/**
|
||||
* Migration based on a Multi-criterial selection mechanism
|
||||
* migrating the n best individuals between all populations.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 15.09.2004
|
||||
* Time: 15:41:15
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MOBestMigration implements InterfaceMigration, java.io.Serializable {
|
||||
|
||||
private InterfaceSelection m_Selection = new SelectMOMaxiMin();
|
||||
int m_N = 5;
|
||||
private InterfaceSelection selection = new SelectMOMaxiMin();
|
||||
int n = 5;
|
||||
|
||||
/**
|
||||
* The ever present clone method
|
||||
@ -67,9 +62,9 @@ public class MOBestMigration implements InterfaceMigration, java.io.Serializable
|
||||
comSet = oldIPOP;
|
||||
|
||||
// todo: Here i could implement multiple selection and replacement schemes
|
||||
newIPOP[i].removeNIndividuals(comSet.length * this.m_N);
|
||||
newIPOP[i].removeNIndividuals(comSet.length * this.n);
|
||||
for (int j = 0; j < comSet.length; j++) {
|
||||
selected = this.m_Selection.selectFrom(comSet[j], this.m_N);
|
||||
selected = this.selection.selectFrom(comSet[j], this.n);
|
||||
newIPOP[i].addPopulation((Population) selected.clone());
|
||||
}
|
||||
}
|
||||
@ -107,11 +102,11 @@ public class MOBestMigration implements InterfaceMigration, java.io.Serializable
|
||||
* @return The selection method
|
||||
*/
|
||||
public InterfaceSelection getSelection() {
|
||||
return this.m_Selection;
|
||||
return this.selection;
|
||||
}
|
||||
|
||||
public void setSelection(InterfaceSelection b) {
|
||||
this.m_Selection = b;
|
||||
this.selection = b;
|
||||
}
|
||||
|
||||
public String selectionTipText() {
|
||||
@ -125,14 +120,14 @@ public class MOBestMigration implements InterfaceMigration, java.io.Serializable
|
||||
* @return The current number of individuals to migrate
|
||||
*/
|
||||
public int getN() {
|
||||
return this.m_N;
|
||||
return this.n;
|
||||
}
|
||||
|
||||
public void setN(int b) {
|
||||
if (b < 1) {
|
||||
b = 1;
|
||||
}
|
||||
this.m_N = b;
|
||||
this.n = b;
|
||||
}
|
||||
|
||||
public String nTipText() {
|
||||
|
@ -24,20 +24,15 @@ import java.io.IOException;
|
||||
* scheme, this method rearanges the populations and may
|
||||
* impose area constraints on the subpopulations. This method
|
||||
* is suited for K-means only.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 27.09.2004
|
||||
* Time: 17:24:44
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MOClusteringSeparation implements InterfaceMigration, java.io.Serializable {
|
||||
|
||||
public boolean debug = false;
|
||||
private ClusteringKMeans m_KMeans = new ClusteringKMeans();
|
||||
private ArchivingNSGAII m_NSGAII = new ArchivingNSGAII();
|
||||
private boolean m_UseConstraints = true;
|
||||
private boolean m_ReuseC = false;
|
||||
private InterfaceSelection m_Selection = new SelectRandom();
|
||||
private ClusteringKMeans kMeans = new ClusteringKMeans();
|
||||
private ArchivingNSGAII NSGAII = new ArchivingNSGAII();
|
||||
private boolean useConstraints = true;
|
||||
private boolean reuseC = false;
|
||||
private InterfaceSelection selection = new SelectRandom();
|
||||
|
||||
public MOClusteringSeparation() {
|
||||
|
||||
@ -45,15 +40,15 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
|
||||
public MOClusteringSeparation(MOClusteringSeparation b) {
|
||||
this.debug = b.debug;
|
||||
this.m_UseConstraints = b.m_UseConstraints;
|
||||
if (b.m_KMeans != null) {
|
||||
this.m_KMeans = (ClusteringKMeans) b.m_KMeans.clone();
|
||||
this.useConstraints = b.useConstraints;
|
||||
if (b.kMeans != null) {
|
||||
this.kMeans = (ClusteringKMeans) b.kMeans.clone();
|
||||
}
|
||||
if (b.m_NSGAII != null) {
|
||||
this.m_NSGAII = (ArchivingNSGAII) b.m_NSGAII.clone();
|
||||
if (b.NSGAII != null) {
|
||||
this.NSGAII = (ArchivingNSGAII) b.NSGAII.clone();
|
||||
}
|
||||
if (b.m_Selection != null) {
|
||||
this.m_Selection = (InterfaceSelection) b.m_Selection.clone();
|
||||
if (b.selection != null) {
|
||||
this.selection = (InterfaceSelection) b.selection.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,8 +67,8 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
@Override
|
||||
public void initMigration(InterfaceOptimizer[] islands) {
|
||||
// pff at a later stage i could initialize a topology here
|
||||
if (this.m_ReuseC) {
|
||||
this.m_KMeans.resetC();
|
||||
if (this.reuseC) {
|
||||
this.kMeans.resetC();
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +126,7 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
// }
|
||||
|
||||
// Now lets cluster this stuff
|
||||
Population[] archives = this.m_NSGAII.getNonDominatedSortedFronts(collector);
|
||||
Population[] archives = this.NSGAII.getNonDominatedSortedFronts(collector);
|
||||
Population toCluster = new Population();
|
||||
int currentFront = 0;
|
||||
toCluster.addPopulation(archives[currentFront]);
|
||||
@ -141,10 +136,10 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
}
|
||||
|
||||
// first set the K to the K-Means
|
||||
this.m_KMeans.setK(islands.length);
|
||||
this.m_KMeans.cluster(toCluster, (Population) null);
|
||||
double[][] c = this.m_KMeans.getC();
|
||||
newIPOP = this.m_KMeans.cluster(collector, c);
|
||||
this.kMeans.setK(islands.length);
|
||||
this.kMeans.cluster(toCluster, (Population) null);
|
||||
double[][] c = this.kMeans.getC();
|
||||
newIPOP = this.kMeans.cluster(collector, c);
|
||||
|
||||
if (this.debug) {
|
||||
Plot plot;
|
||||
@ -178,7 +173,7 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
}
|
||||
}
|
||||
|
||||
if (this.m_UseConstraints) {
|
||||
if (this.useConstraints) {
|
||||
// i should set the constraints to the optimizers
|
||||
InterfaceOptimizationProblem prob;
|
||||
for (int i = 0; i < islands.length; i++) {
|
||||
@ -197,7 +192,7 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
myOtherClass[j] = c[index];
|
||||
index++;
|
||||
}
|
||||
ConstBelongsToDifferentClass b = new ConstBelongsToDifferentClass(myClass, myOtherClass, this.m_KMeans.getUseSearchSpace());
|
||||
ConstBelongsToDifferentClass b = new ConstBelongsToDifferentClass(myClass, myOtherClass, this.kMeans.getUseSearchSpace());
|
||||
((AbstractMultiObjectiveOptimizationProblem) prob).areaConst4Parallelization.add(b);
|
||||
// if (this.debug) {
|
||||
// String out = "";
|
||||
@ -211,7 +206,7 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
// }
|
||||
// out += "}";
|
||||
// }
|
||||
// if (this.m_KMeans.getUsePhenotype()) out += "\n Using phenotype.";
|
||||
// if (this.kMeans.getUsePhenotype()) out += "\n Using phenotype.";
|
||||
// else out += "\n Using objective space.";
|
||||
// System.out.println(""+out);
|
||||
// }
|
||||
@ -226,7 +221,7 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
oldIPOP[i].addPopulation(newIPOP[i]);
|
||||
// todo remove this for nice pictures
|
||||
if (!oldIPOP[i].targetSizeReached()) {
|
||||
oldIPOP[i].addPopulation(this.m_Selection.selectFrom(memory, oldIPOP[i].getTargetSize() - oldIPOP[i].size()));
|
||||
oldIPOP[i].addPopulation(this.selection.selectFrom(memory, oldIPOP[i].getTargetSize() - oldIPOP[i].size()));
|
||||
}
|
||||
if (this.debug) {
|
||||
System.out.println("Setting " + i + " to population size " + oldIPOP[i].size());
|
||||
@ -277,7 +272,7 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
// islands[i].init();
|
||||
// }
|
||||
//
|
||||
// cluster.m_KMeans.setUseSearchSpace(true);
|
||||
// cluster.kMeans.setUseSearchSpace(true);
|
||||
//
|
||||
// for (int i = 0; i < 20; i++) {
|
||||
// for (int j = 0; j < islands.length; j++) {
|
||||
@ -383,11 +378,11 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
* @return The clustering algorithm method
|
||||
*/
|
||||
public ClusteringKMeans getKMeans() {
|
||||
return this.m_KMeans;
|
||||
return this.kMeans;
|
||||
}
|
||||
|
||||
public void setKMeans(ClusteringKMeans b) {
|
||||
this.m_KMeans = b;
|
||||
this.kMeans = b;
|
||||
}
|
||||
|
||||
public String kMeansTipText() {
|
||||
@ -402,11 +397,11 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
* @return The modus of constraints.
|
||||
*/
|
||||
public boolean getUseConstraints() {
|
||||
return this.m_UseConstraints;
|
||||
return this.useConstraints;
|
||||
}
|
||||
|
||||
public void setUseConstraints(boolean b) {
|
||||
this.m_UseConstraints = b;
|
||||
this.useConstraints = b;
|
||||
}
|
||||
|
||||
public String useConstraintsTipText() {
|
||||
@ -419,13 +414,13 @@ public class MOClusteringSeparation implements InterfaceMigration, java.io.Seria
|
||||
* @return The distance type to use.
|
||||
*/
|
||||
public boolean getReuseC() {
|
||||
this.m_ReuseC = this.m_KMeans.getReuseC();
|
||||
return this.m_ReuseC;
|
||||
this.reuseC = this.kMeans.getReuseC();
|
||||
return this.reuseC;
|
||||
}
|
||||
|
||||
public void setReuseC(boolean m) {
|
||||
this.m_ReuseC = m;
|
||||
this.m_KMeans.setReuseC(this.m_ReuseC);
|
||||
this.reuseC = m;
|
||||
this.kMeans.setReuseC(this.reuseC);
|
||||
}
|
||||
|
||||
public String reuseCTipText() {
|
||||
|
@ -26,19 +26,14 @@ import java.io.IOException;
|
||||
* This method implements the cone separation subdivision
|
||||
* scheme, this method rearanges the populations and may
|
||||
* impose area constraints on the subpopulations.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 15.09.2004
|
||||
* Time: 17:39:26
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MOConeSeparation implements InterfaceMigration, java.io.Serializable {
|
||||
|
||||
public boolean debug = false;
|
||||
private boolean m_UseAllToDetermineR = false; // since i'm only interessted in the pareto-front this should be set to false!!
|
||||
private boolean m_UseConstraints = true;
|
||||
private InterfaceSelection m_Selection = new SelectRandom();
|
||||
private double[][] m_3DBounds;
|
||||
private boolean useAllToDetermineR = false; // since i'm only interessted in the pareto-front this should be set to false!!
|
||||
private boolean useConstraints = true;
|
||||
private InterfaceSelection selection = new SelectRandom();
|
||||
private double[][] bounds3D;
|
||||
|
||||
public MOConeSeparation() {
|
||||
|
||||
@ -46,10 +41,10 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
|
||||
public MOConeSeparation(MOConeSeparation b) {
|
||||
this.debug = b.debug;
|
||||
this.m_UseConstraints = b.m_UseConstraints;
|
||||
this.m_UseAllToDetermineR = b.m_UseAllToDetermineR;
|
||||
if (b.m_Selection != null) {
|
||||
this.m_Selection = (InterfaceSelection) b.m_Selection.clone();
|
||||
this.useConstraints = b.useConstraints;
|
||||
this.useAllToDetermineR = b.useAllToDetermineR;
|
||||
if (b.selection != null) {
|
||||
this.selection = (InterfaceSelection) b.selection.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +111,7 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
oldIPOP[i].addPopulation(newIPOP[i]);
|
||||
// todo remove this for nice pictures
|
||||
if (!oldIPOP[i].targetSizeReached()) {
|
||||
oldIPOP[i].addPopulation(this.m_Selection.selectFrom(memory, oldIPOP[i].getTargetSize() - oldIPOP[i].size()));
|
||||
oldIPOP[i].addPopulation(this.selection.selectFrom(memory, oldIPOP[i].getTargetSize() - oldIPOP[i].size()));
|
||||
}
|
||||
if (this.debug) {
|
||||
System.out.println("Setting island " + i + " to population size " + oldIPOP[i].size());
|
||||
@ -170,7 +165,7 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
Population archive = collector.getArchive();
|
||||
Population ref;
|
||||
|
||||
if (this.m_UseAllToDetermineR) {
|
||||
if (this.useAllToDetermineR) {
|
||||
ref = collector;
|
||||
} else {
|
||||
ref = archive;
|
||||
@ -264,7 +259,7 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
}
|
||||
}
|
||||
|
||||
if (this.m_UseConstraints) {
|
||||
if (this.useConstraints) {
|
||||
// i should set the constraints to the optimizers
|
||||
InterfaceOptimizationProblem prob;
|
||||
for (int i = 0; i < islands.length; i++) {
|
||||
@ -308,7 +303,7 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
Population archive = collector.getArchive();
|
||||
Population ref;
|
||||
|
||||
if (this.m_UseAllToDetermineR) {
|
||||
if (this.useAllToDetermineR) {
|
||||
ref = collector;
|
||||
} else {
|
||||
ref = archive;
|
||||
@ -342,12 +337,12 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
firstVec = this.getNormalized(firstVec);
|
||||
double[] normDist = this.getNormalized(distopian);
|
||||
|
||||
this.m_3DBounds = new double[normals.length + 2][3];
|
||||
this.m_3DBounds[0] = distopian;
|
||||
this.bounds3D = new double[normals.length + 2][3];
|
||||
this.bounds3D[0] = distopian;
|
||||
|
||||
for (int i = 0; i < normals.length; i++) {
|
||||
normals[i] = this.rotVector(firstVec, normDist, Math.toRadians(i * angIncr));
|
||||
this.m_3DBounds[i + 1] = normals[i];
|
||||
this.bounds3D[i + 1] = normals[i];
|
||||
}
|
||||
|
||||
// now i got the bounding planes
|
||||
@ -375,7 +370,7 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
// j--;
|
||||
}
|
||||
}
|
||||
if (this.m_UseConstraints) {
|
||||
if (this.useConstraints) {
|
||||
prob = (InterfaceOptimizationProblem) islands[i].getProblem();
|
||||
if (prob instanceof AbstractMultiObjectiveOptimizationProblem) {
|
||||
// set the boundaries to perform the constrained
|
||||
@ -416,7 +411,7 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
//
|
||||
// int last = newIPOP.length-1;
|
||||
// newIPOP[last].addPopulation(collector);
|
||||
// if (this.m_UseConstraints) {
|
||||
// if (this.useConstraints) {
|
||||
// prob = (InterfaceOptimizationProblem) islands[last].getProblem();
|
||||
// if (prob instanceof AbstractMultiObjectiveOptimizationProblem) {
|
||||
// // set the boundaries to perform the constrained
|
||||
@ -689,7 +684,7 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
// } catch (FileNotFoundException e) {
|
||||
// System.out.println("Could not open output file! Filename: ");
|
||||
// }
|
||||
// double[][] surf = cone.m_3DBounds;
|
||||
// double[][] surf = cone.bounds3D;
|
||||
// cone.writeToFile(outfile, "0\t 0\t 0");
|
||||
// cone.writeToFile(outfile, ""+surf[0][0]+"\t"+surf[0][1]+"\t"+surf[0][2]);
|
||||
// cone.writeToFile(outfile, ""+surf[0][0]+"\t"+surf[0][1]+"\t"+surf[0][2]);
|
||||
@ -778,11 +773,11 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
* @return The modus to calculate the reference point.
|
||||
*/
|
||||
public boolean getUseAllToDetermineR() {
|
||||
return this.m_UseAllToDetermineR;
|
||||
return this.useAllToDetermineR;
|
||||
}
|
||||
|
||||
public void setUseAllToDetermineR(boolean b) {
|
||||
this.m_UseAllToDetermineR = b;
|
||||
this.useAllToDetermineR = b;
|
||||
}
|
||||
|
||||
public String useAllToDetermineRTipText() {
|
||||
@ -797,11 +792,11 @@ public class MOConeSeparation implements InterfaceMigration, java.io.Serializabl
|
||||
* @return The modus of constraints.
|
||||
*/
|
||||
public boolean getUseConstraints() {
|
||||
return this.m_UseConstraints;
|
||||
return this.useConstraints;
|
||||
}
|
||||
|
||||
public void setUseConstraints(boolean b) {
|
||||
this.m_UseConstraints = b;
|
||||
this.useConstraints = b;
|
||||
}
|
||||
|
||||
public String useConstraintsTipText() {
|
||||
|
@ -24,35 +24,30 @@ import java.io.IOException;
|
||||
* This method implements the clustering based subdivision
|
||||
* scheme suited to identify uni- and multi-modal search spaces
|
||||
* under development and currently defunct.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 24.06.2005
|
||||
* Time: 10:38:26
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializable {
|
||||
|
||||
public boolean m_Debug = false;
|
||||
private ClusteringXMeans m_XMeans = new ClusteringXMeans();
|
||||
private ArchivingNSGAII m_NSGAII = new ArchivingNSGAII();
|
||||
private boolean m_UseConstraints = true;
|
||||
private InterfaceSelection m_Selection = new SelectRandom();
|
||||
public boolean debug = false;
|
||||
private ClusteringXMeans xMeans = new ClusteringXMeans();
|
||||
private ArchivingNSGAII NSGAII = new ArchivingNSGAII();
|
||||
private boolean useConstraints = true;
|
||||
private InterfaceSelection selection = new SelectRandom();
|
||||
|
||||
public MOXMeansSeparation() {
|
||||
|
||||
}
|
||||
|
||||
public MOXMeansSeparation(MOXMeansSeparation b) {
|
||||
this.m_Debug = b.m_Debug;
|
||||
this.m_UseConstraints = b.m_UseConstraints;
|
||||
if (b.m_XMeans != null) {
|
||||
this.m_XMeans = (ClusteringXMeans) b.m_XMeans.clone();
|
||||
this.debug = b.debug;
|
||||
this.useConstraints = b.useConstraints;
|
||||
if (b.xMeans != null) {
|
||||
this.xMeans = (ClusteringXMeans) b.xMeans.clone();
|
||||
}
|
||||
if (b.m_NSGAII != null) {
|
||||
this.m_NSGAII = (ArchivingNSGAII) b.m_NSGAII.clone();
|
||||
if (b.NSGAII != null) {
|
||||
this.NSGAII = (ArchivingNSGAII) b.NSGAII.clone();
|
||||
}
|
||||
if (b.m_Selection != null) {
|
||||
this.m_Selection = (InterfaceSelection) b.m_Selection.clone();
|
||||
if (b.selection != null) {
|
||||
this.selection = (InterfaceSelection) b.selection.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +89,7 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
// collect the populations
|
||||
for (int i = 0; i < islands.length; i++) {
|
||||
oldIPOP[i] = islands[i].getPopulation();
|
||||
if (this.m_Debug) {
|
||||
if (this.debug) {
|
||||
System.out.println("Got population from " + i + " of size " + oldIPOP[i].size());
|
||||
}
|
||||
collector.addPopulation((Population) oldIPOP[i].clone());
|
||||
@ -128,7 +123,7 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
// }
|
||||
|
||||
// Now lets cluster this stuff
|
||||
Population[] archives = this.m_NSGAII.getNonDominatedSortedFronts(collector);
|
||||
Population[] archives = this.NSGAII.getNonDominatedSortedFronts(collector);
|
||||
Population toCluster = new Population();
|
||||
int currentFront = 0;
|
||||
toCluster.addPopulation(archives[currentFront]);
|
||||
@ -138,16 +133,16 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
}
|
||||
|
||||
// first set the K to the K-Means
|
||||
this.m_XMeans.setMaxK(islands.length);
|
||||
this.m_XMeans.cluster(toCluster, (Population) null);
|
||||
double[][] c = this.m_XMeans.getC();
|
||||
this.xMeans.setMaxK(islands.length);
|
||||
this.xMeans.cluster(toCluster, (Population) null);
|
||||
double[][] c = this.xMeans.getC();
|
||||
//@todo Hier muss ich mal denk machen und weniger click...
|
||||
newIPOP = this.m_XMeans.cluster(collector, c);
|
||||
newIPOP = this.xMeans.cluster(collector, c);
|
||||
for (int i = 0; i < islands.length; i++) {
|
||||
islands[i].getPopulation().clear();
|
||||
islands[i].getPopulation().setTargetSize(0);
|
||||
}
|
||||
if (this.m_Debug) {
|
||||
if (this.debug) {
|
||||
Plot plot;
|
||||
double[] tmpD = new double[2];
|
||||
tmpD[0] = 0;
|
||||
@ -179,7 +174,7 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
}
|
||||
}
|
||||
|
||||
if ((this.m_UseConstraints) && (c.length > 1)) {
|
||||
if ((this.useConstraints) && (c.length > 1)) {
|
||||
// i should set the constraints to the optimizers
|
||||
InterfaceOptimizationProblem prob;
|
||||
|
||||
@ -199,7 +194,7 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
myOtherClass[j] = c[index];
|
||||
index++;
|
||||
}
|
||||
ConstBelongsToDifferentClass b = new ConstBelongsToDifferentClass(myClass, myOtherClass, this.m_XMeans.getUseSearchSpace());
|
||||
ConstBelongsToDifferentClass b = new ConstBelongsToDifferentClass(myClass, myOtherClass, this.xMeans.getUseSearchSpace());
|
||||
((AbstractMultiObjectiveOptimizationProblem) prob).areaConst4Parallelization.add(b);
|
||||
// if (this.debug) {
|
||||
// String out = "";
|
||||
@ -213,7 +208,7 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
// }
|
||||
// out += "}";
|
||||
// }
|
||||
// if (this.m_XMeans.getUsePhenotype()) out += "\n Using phenotype.";
|
||||
// if (this.xMeans.getUsePhenotype()) out += "\n Using phenotype.";
|
||||
// else out += "\n Using objective space.";
|
||||
// System.out.println(""+out);
|
||||
// }
|
||||
@ -229,9 +224,9 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
oldIPOP[i].addPopulation(newIPOP[i]);
|
||||
// todo remove this for nice pictures
|
||||
if (!oldIPOP[i].targetSizeReached()) {
|
||||
oldIPOP[i].addPopulation(this.m_Selection.selectFrom(memory, oldIPOP[i].getFreeSlots()));
|
||||
oldIPOP[i].addPopulation(this.selection.selectFrom(memory, oldIPOP[i].getFreeSlots()));
|
||||
}
|
||||
if (this.m_Debug) {
|
||||
if (this.debug) {
|
||||
System.out.println("Setting " + i + " to population size " + oldIPOP[i].size());
|
||||
}
|
||||
islands[i].setPopulation(oldIPOP[i]);
|
||||
@ -281,7 +276,7 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
// islands[i].init();
|
||||
// }
|
||||
//
|
||||
// cluster.m_XMeans.setUseSearchSpace(true);
|
||||
// cluster.xMeans.setUseSearchSpace(true);
|
||||
//
|
||||
// for (int i = 0; i < 20; i++) {
|
||||
// for (int j = 0; j < islands.length; j++) {
|
||||
@ -387,11 +382,11 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
* @return The clustering algorithm method
|
||||
*/
|
||||
public ClusteringXMeans getXMeans() {
|
||||
return this.m_XMeans;
|
||||
return this.xMeans;
|
||||
}
|
||||
|
||||
public void setXMeans(ClusteringXMeans b) {
|
||||
this.m_XMeans = b;
|
||||
this.xMeans = b;
|
||||
}
|
||||
|
||||
public String xMeansTipText() {
|
||||
@ -406,11 +401,11 @@ public class MOXMeansSeparation implements InterfaceMigration, java.io.Serializa
|
||||
* @return The modus of constraints.
|
||||
*/
|
||||
public boolean getUseConstraints() {
|
||||
return this.m_UseConstraints;
|
||||
return this.useConstraints;
|
||||
}
|
||||
|
||||
public void setUseConstraints(boolean b) {
|
||||
this.m_UseConstraints = b;
|
||||
this.useConstraints = b;
|
||||
}
|
||||
|
||||
public String useConstraintsTipText() {
|
||||
|
@ -8,16 +8,11 @@ import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
|
||||
/**
|
||||
* Simple single-objective migration scheme.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 15.09.2004
|
||||
* Time: 14:52:02
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SOBestMigration implements InterfaceMigration, java.io.Serializable {
|
||||
|
||||
private InterfaceSelection m_Selection = new SelectBestIndividuals();
|
||||
private int m_N = 5;
|
||||
private InterfaceSelection selection = new SelectBestIndividuals();
|
||||
private int n = 5;
|
||||
|
||||
/**
|
||||
* The ever present clone method
|
||||
@ -67,9 +62,9 @@ public class SOBestMigration implements InterfaceMigration, java.io.Serializable
|
||||
comSet = oldIPOP;
|
||||
|
||||
// todo: Here i could implement multiple selection and replacement schemes
|
||||
newIPOP[i].removeNIndividuals(comSet.length * this.m_N);
|
||||
newIPOP[i].removeNIndividuals(comSet.length * this.n);
|
||||
for (int j = 0; j < comSet.length; j++) {
|
||||
selected = this.m_Selection.selectFrom(comSet[j], this.m_N);
|
||||
selected = this.selection.selectFrom(comSet[j], this.n);
|
||||
newIPOP[i].add(((AbstractEAIndividual) selected.get(0)).clone());
|
||||
}
|
||||
}
|
||||
@ -106,11 +101,11 @@ public class SOBestMigration implements InterfaceMigration, java.io.Serializable
|
||||
* @return The selection method
|
||||
*/
|
||||
public InterfaceSelection getSelection() {
|
||||
return this.m_Selection;
|
||||
return this.selection;
|
||||
}
|
||||
|
||||
public void setSelection(InterfaceSelection b) {
|
||||
this.m_Selection = b;
|
||||
this.selection = b;
|
||||
}
|
||||
|
||||
public String selectionTipText() {
|
||||
@ -124,14 +119,14 @@ public class SOBestMigration implements InterfaceMigration, java.io.Serializable
|
||||
* @return The current number of individuals to migrate
|
||||
*/
|
||||
public int getN() {
|
||||
return this.m_N;
|
||||
return this.n;
|
||||
}
|
||||
|
||||
public void setN(int b) {
|
||||
if (b < 1) {
|
||||
b = 1;
|
||||
}
|
||||
this.m_N = b;
|
||||
this.n = b;
|
||||
}
|
||||
|
||||
public String nTipText() {
|
||||
|
@ -4,11 +4,6 @@ import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
|
||||
/**
|
||||
* Implements no migration as reference.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 16.09.2004
|
||||
* Time: 16:12:05
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SOMONoMigration implements InterfaceMigration, java.io.Serializable {
|
||||
|
||||
|
@ -4,25 +4,21 @@ import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 11.03.2004
|
||||
* Time: 18:59:14
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOSODynamicallyWeightedFitness implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private double m_F = 50;
|
||||
private int m_CurrentGeneration = 0;
|
||||
private int m_OutputDimension = 2;
|
||||
private double f = 50;
|
||||
private int currentGeneration = 0;
|
||||
private int outputDimension = 2;
|
||||
|
||||
public MOSODynamicallyWeightedFitness() {
|
||||
}
|
||||
|
||||
public MOSODynamicallyWeightedFitness(MOSODynamicallyWeightedFitness b) {
|
||||
this.m_CurrentGeneration = b.m_CurrentGeneration;
|
||||
this.m_F = b.m_F;
|
||||
this.m_OutputDimension = b.m_OutputDimension;
|
||||
this.currentGeneration = b.currentGeneration;
|
||||
this.f = b.f;
|
||||
this.outputDimension = b.outputDimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,7 +37,7 @@ public class MOSODynamicallyWeightedFitness implements InterfaceMOSOConverter, j
|
||||
*/
|
||||
@Override
|
||||
public void convertMultiObjective2SingleObjective(Population pop) {
|
||||
this.m_CurrentGeneration = pop.getGeneration();
|
||||
this.currentGeneration = pop.getGeneration();
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
this.convertSingleIndividual((AbstractEAIndividual) pop.get(i));
|
||||
}
|
||||
@ -63,7 +59,7 @@ public class MOSODynamicallyWeightedFitness implements InterfaceMOSOConverter, j
|
||||
weights = new double[tmpFit.length];
|
||||
|
||||
// calculate the dynamic weights
|
||||
weights[0] = Math.pow(Math.sin(2 * Math.PI * (double) this.m_CurrentGeneration / this.m_F), 2);
|
||||
weights[0] = Math.pow(Math.sin(2 * Math.PI * (double) this.currentGeneration / this.f), 2);
|
||||
weights[1] = 1 - weights[0];
|
||||
|
||||
for (int i = 0; (i < 2) && (i < tmpFit.length); i++) {
|
||||
@ -81,7 +77,7 @@ public class MOSODynamicallyWeightedFitness implements InterfaceMOSOConverter, j
|
||||
*/
|
||||
@Override
|
||||
public void setOutputDimension(int dim) {
|
||||
this.m_OutputDimension = dim;
|
||||
this.outputDimension = dim;
|
||||
// i think as far as i got not solution for the (n>2) dimensional case
|
||||
// i could simply ignore this....
|
||||
}
|
||||
@ -125,11 +121,11 @@ public class MOSODynamicallyWeightedFitness implements InterfaceMOSOConverter, j
|
||||
* @param f The frequency of change.
|
||||
*/
|
||||
public void setF(double f) {
|
||||
this.m_F = f;
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
public double getF() {
|
||||
return this.m_F;
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public String fTipText() {
|
||||
|
@ -13,21 +13,21 @@ import eva2.optimization.population.Population;
|
||||
*/
|
||||
public class MOSOEpsilonConstraint implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private PropertyEpsilonConstraint m_EpsilonConstraint = null;
|
||||
private PropertyEpsilonConstraint epsilonConstraint = null;
|
||||
|
||||
public MOSOEpsilonConstraint() {
|
||||
this.m_EpsilonConstraint = new PropertyEpsilonConstraint();
|
||||
this.m_EpsilonConstraint.m_OptimizeObjective = 0;
|
||||
this.epsilonConstraint = new PropertyEpsilonConstraint();
|
||||
this.epsilonConstraint.optimizeObjective = 0;
|
||||
double[] tmpD = new double[2];
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i] = 0.0;
|
||||
}
|
||||
this.m_EpsilonConstraint.m_TargetValue = tmpD;
|
||||
this.epsilonConstraint.targetValue = tmpD;
|
||||
}
|
||||
|
||||
public MOSOEpsilonConstraint(MOSOEpsilonConstraint b) {
|
||||
if (b.m_EpsilonConstraint != null) {
|
||||
this.m_EpsilonConstraint = (PropertyEpsilonConstraint) b.m_EpsilonConstraint.clone();
|
||||
if (b.epsilonConstraint != null) {
|
||||
this.epsilonConstraint = (PropertyEpsilonConstraint) b.epsilonConstraint.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,10 +64,10 @@ public class MOSOEpsilonConstraint implements InterfaceMOSOConverter, java.io.Se
|
||||
|
||||
tmpFit = indy.getFitness();
|
||||
indy.putData("MOFitness", tmpFit);
|
||||
resultFit[0] = tmpFit[this.m_EpsilonConstraint.m_OptimizeObjective];
|
||||
for (int i = 0; i < this.m_EpsilonConstraint.m_TargetValue.length; i++) {
|
||||
if (i != this.m_EpsilonConstraint.m_OptimizeObjective) {
|
||||
indy.addConstraintViolation(Math.max(0, tmpFit[i] - this.m_EpsilonConstraint.m_TargetValue[i]));
|
||||
resultFit[0] = tmpFit[this.epsilonConstraint.optimizeObjective];
|
||||
for (int i = 0; i < this.epsilonConstraint.targetValue.length; i++) {
|
||||
if (i != this.epsilonConstraint.optimizeObjective) {
|
||||
indy.addConstraintViolation(Math.max(0, tmpFit[i] - this.epsilonConstraint.targetValue[i]));
|
||||
}
|
||||
}
|
||||
indy.setFitness(resultFit);
|
||||
@ -87,14 +87,14 @@ public class MOSOEpsilonConstraint implements InterfaceMOSOConverter, java.io.Se
|
||||
for (int i = 0; i < newTarget.length; i++) {
|
||||
newTarget[i] = 0;
|
||||
}
|
||||
for (int i = 0; (i < this.m_EpsilonConstraint.m_TargetValue.length) && (i < newTarget.length); i++) {
|
||||
newTarget[i] = this.m_EpsilonConstraint.m_TargetValue[i];
|
||||
for (int i = 0; (i < this.epsilonConstraint.targetValue.length) && (i < newTarget.length); i++) {
|
||||
newTarget[i] = this.epsilonConstraint.targetValue[i];
|
||||
}
|
||||
if (this.m_EpsilonConstraint.m_OptimizeObjective >= dim) {
|
||||
this.m_EpsilonConstraint.m_OptimizeObjective = dim - 1;
|
||||
if (this.epsilonConstraint.optimizeObjective >= dim) {
|
||||
this.epsilonConstraint.optimizeObjective = dim - 1;
|
||||
}
|
||||
|
||||
this.m_EpsilonConstraint.m_TargetValue = newTarget;
|
||||
this.epsilonConstraint.targetValue = newTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,11 +137,11 @@ public class MOSOEpsilonConstraint implements InterfaceMOSOConverter, java.io.Se
|
||||
* @param weights The Epsilon Threshhold for the fitness sum.
|
||||
*/
|
||||
public void setEpsilonThreshhold(PropertyEpsilonConstraint weights) {
|
||||
this.m_EpsilonConstraint = weights;
|
||||
this.epsilonConstraint = weights;
|
||||
}
|
||||
|
||||
public PropertyEpsilonConstraint getEpsilonThreshhold() {
|
||||
return this.m_EpsilonConstraint;
|
||||
return this.epsilonConstraint;
|
||||
}
|
||||
|
||||
public String epsilonThreshholdTipText() {
|
||||
|
@ -5,34 +5,30 @@ import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 05.03.2004
|
||||
* Time: 14:53:47
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOSOEpsilonThreshold implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private PropertyEpsilonThreshold m_EpsilonThreshold = null;
|
||||
private PropertyEpsilonThreshold epsilonThreshold = null;
|
||||
|
||||
public MOSOEpsilonThreshold() {
|
||||
this.m_EpsilonThreshold = new PropertyEpsilonThreshold();
|
||||
this.m_EpsilonThreshold.m_OptimizeObjective = 0;
|
||||
this.epsilonThreshold = new PropertyEpsilonThreshold();
|
||||
this.epsilonThreshold.optimizeObjective = 0;
|
||||
double[] tmpD = new double[2];
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i] = 0.0;
|
||||
}
|
||||
this.m_EpsilonThreshold.m_TargetValue = tmpD;
|
||||
this.epsilonThreshold.targetValue = tmpD;
|
||||
tmpD = new double[2];
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i] = 1.0;
|
||||
}
|
||||
this.m_EpsilonThreshold.m_Punishment = tmpD;
|
||||
this.epsilonThreshold.punishment = tmpD;
|
||||
}
|
||||
|
||||
public MOSOEpsilonThreshold(MOSOEpsilonThreshold b) {
|
||||
if (b.m_EpsilonThreshold != null) {
|
||||
this.m_EpsilonThreshold = (PropertyEpsilonThreshold) b.m_EpsilonThreshold.clone();
|
||||
if (b.epsilonThreshold != null) {
|
||||
this.epsilonThreshold = (PropertyEpsilonThreshold) b.epsilonThreshold.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,16 +73,16 @@ public class MOSOEpsilonThreshold implements InterfaceMOSOConverter, java.io.Ser
|
||||
System.out.println("Fitness is Infinite");
|
||||
}
|
||||
}
|
||||
resultFit[0] = tmpFit[this.m_EpsilonThreshold.m_OptimizeObjective];
|
||||
resultFit[0] = tmpFit[this.epsilonThreshold.optimizeObjective];
|
||||
|
||||
// System.out.println("Optimize: " + this.m_EpsilonThreshold.m_OptimizeObjective);
|
||||
// System.out.println("Optimize: " + this.epsilonThreshold.optimizeObjective);
|
||||
// for (int i = 0; i < tmpFit.length; i++) {
|
||||
// System.out.println("Target: " + this.m_EpsilonThreshold.m_TargetValue[i] + " Punish: " + this.m_EpsilonThreshold.m_Punishment[i]);
|
||||
// System.out.println("Target: " + this.epsilonThreshold.targetValue[i] + " Punish: " + this.epsilonThreshold.punishment[i]);
|
||||
// }
|
||||
|
||||
for (int i = 0; i < this.m_EpsilonThreshold.m_Punishment.length; i++) {
|
||||
if (i != this.m_EpsilonThreshold.m_OptimizeObjective) {
|
||||
resultFit[0] += this.m_EpsilonThreshold.m_Punishment[i] * Math.max(0, tmpFit[i] - this.m_EpsilonThreshold.m_TargetValue[i]);
|
||||
for (int i = 0; i < this.epsilonThreshold.punishment.length; i++) {
|
||||
if (i != this.epsilonThreshold.optimizeObjective) {
|
||||
resultFit[0] += this.epsilonThreshold.punishment[i] * Math.max(0, tmpFit[i] - this.epsilonThreshold.targetValue[i]);
|
||||
}
|
||||
}
|
||||
tmpFit = (double[]) indy.getData("MOFitness");
|
||||
@ -117,16 +113,16 @@ public class MOSOEpsilonThreshold implements InterfaceMOSOConverter, java.io.Ser
|
||||
newPunish[i] = 1;
|
||||
newTarget[i] = 0;
|
||||
}
|
||||
for (int i = 0; (i < this.m_EpsilonThreshold.m_Punishment.length) && (i < newTarget.length); i++) {
|
||||
newPunish[i] = this.m_EpsilonThreshold.m_Punishment[i];
|
||||
newTarget[i] = this.m_EpsilonThreshold.m_TargetValue[i];
|
||||
for (int i = 0; (i < this.epsilonThreshold.punishment.length) && (i < newTarget.length); i++) {
|
||||
newPunish[i] = this.epsilonThreshold.punishment[i];
|
||||
newTarget[i] = this.epsilonThreshold.targetValue[i];
|
||||
}
|
||||
if (this.m_EpsilonThreshold.m_OptimizeObjective >= dim) {
|
||||
this.m_EpsilonThreshold.m_OptimizeObjective = dim - 1;
|
||||
if (this.epsilonThreshold.optimizeObjective >= dim) {
|
||||
this.epsilonThreshold.optimizeObjective = dim - 1;
|
||||
}
|
||||
|
||||
this.m_EpsilonThreshold.m_Punishment = newPunish;
|
||||
this.m_EpsilonThreshold.m_TargetValue = newTarget;
|
||||
this.epsilonThreshold.punishment = newPunish;
|
||||
this.epsilonThreshold.targetValue = newTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,11 +165,11 @@ public class MOSOEpsilonThreshold implements InterfaceMOSOConverter, java.io.Ser
|
||||
* @param weights The Epsilon Threshhold for the fitness sum.
|
||||
*/
|
||||
public void setEpsilonThreshhold(PropertyEpsilonThreshold weights) {
|
||||
this.m_EpsilonThreshold = weights;
|
||||
this.epsilonThreshold = weights;
|
||||
}
|
||||
|
||||
public PropertyEpsilonThreshold getEpsilonThreshhold() {
|
||||
return this.m_EpsilonThreshold;
|
||||
return this.epsilonThreshold;
|
||||
}
|
||||
|
||||
public String epsilonThreshholdTipText() {
|
||||
|
@ -5,27 +5,23 @@ import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 05.03.2004
|
||||
* Time: 15:49:16
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOSOGoalProgramming implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private PropertyDoubleArray m_Goals = null;
|
||||
private PropertyDoubleArray goals = null;
|
||||
|
||||
public MOSOGoalProgramming() {
|
||||
double[] tmpD = new double[2];
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i] = 0.0;
|
||||
}
|
||||
this.m_Goals = new PropertyDoubleArray(tmpD);
|
||||
this.goals = new PropertyDoubleArray(tmpD);
|
||||
}
|
||||
|
||||
public MOSOGoalProgramming(MOSOGoalProgramming b) {
|
||||
if (b.m_Goals != null) {
|
||||
this.m_Goals = (PropertyDoubleArray) b.m_Goals;
|
||||
if (b.goals != null) {
|
||||
this.goals = (PropertyDoubleArray) b.goals;
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,8 +59,8 @@ public class MOSOGoalProgramming implements InterfaceMOSOConverter, java.io.Seri
|
||||
tmpFit = indy.getFitness();
|
||||
indy.putData("MOFitness", tmpFit);
|
||||
resultFit[0] = 0;
|
||||
for (int i = 0; (i < this.m_Goals.getNumRows()) && (i < tmpFit.length); i++) {
|
||||
resultFit[0] += tmpFit[i] - this.m_Goals.getValue(i, 0);
|
||||
for (int i = 0; (i < this.goals.getNumRows()) && (i < tmpFit.length); i++) {
|
||||
resultFit[0] += tmpFit[i] - this.goals.getValue(i, 0);
|
||||
}
|
||||
indy.setFitness(resultFit);
|
||||
}
|
||||
@ -83,11 +79,11 @@ public class MOSOGoalProgramming implements InterfaceMOSOConverter, java.io.Seri
|
||||
for (int i = 0; i < newWeights.length; i++) {
|
||||
newWeights[i] = 0.0;
|
||||
}
|
||||
for (int i = 0; (i < this.m_Goals.getNumRows()) && (i < newWeights.length); i++) {
|
||||
newWeights[i] = this.m_Goals.getValue(i, 0);
|
||||
for (int i = 0; (i < this.goals.getNumRows()) && (i < newWeights.length); i++) {
|
||||
newWeights[i] = this.goals.getValue(i, 0);
|
||||
}
|
||||
|
||||
this.m_Goals.setDoubleArray(newWeights);
|
||||
this.goals.setDoubleArray(newWeights);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,11 +126,11 @@ public class MOSOGoalProgramming implements InterfaceMOSOConverter, java.io.Seri
|
||||
* @param goals The weights for the fitness sum.
|
||||
*/
|
||||
public void setGoals(PropertyDoubleArray goals) {
|
||||
this.m_Goals = goals;
|
||||
this.goals = goals;
|
||||
}
|
||||
|
||||
public PropertyDoubleArray getGoals() {
|
||||
return this.m_Goals;
|
||||
return this.goals;
|
||||
}
|
||||
|
||||
public String goalsTipText() {
|
||||
|
@ -5,29 +5,25 @@ import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 05.03.2004
|
||||
* Time: 15:49:16
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOSOLpMetric implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private PropertyDoubleArray m_Reference = null;
|
||||
private int m_P = 2;
|
||||
private PropertyDoubleArray reference = null;
|
||||
private int p = 2;
|
||||
|
||||
public MOSOLpMetric() {
|
||||
double[] tmpD = new double[2];
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i] = 0.0;
|
||||
}
|
||||
this.m_Reference = new PropertyDoubleArray(tmpD);
|
||||
this.reference = new PropertyDoubleArray(tmpD);
|
||||
}
|
||||
|
||||
public MOSOLpMetric(MOSOLpMetric b) {
|
||||
this.m_P = b.m_P;
|
||||
if (b.m_Reference != null) {
|
||||
this.m_Reference = (PropertyDoubleArray) b.m_Reference.clone();
|
||||
this.p = b.p;
|
||||
if (b.reference != null) {
|
||||
this.reference = (PropertyDoubleArray) b.reference.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,18 +60,18 @@ public class MOSOLpMetric implements InterfaceMOSOConverter, java.io.Serializabl
|
||||
|
||||
tmpFit = indy.getFitness();
|
||||
indy.putData("MOFitness", tmpFit);
|
||||
if (m_P >= 1) {
|
||||
if (p >= 1) {
|
||||
// standard Lp Metric
|
||||
resultFit[0] = 0;
|
||||
for (int i = 0; (i < this.m_Reference.getNumRows()) && (i < tmpFit.length); i++) {
|
||||
resultFit[0] += Math.pow(Math.abs(tmpFit[i] - this.m_Reference.getValue(i, 0)), this.m_P);
|
||||
for (int i = 0; (i < this.reference.getNumRows()) && (i < tmpFit.length); i++) {
|
||||
resultFit[0] += Math.pow(Math.abs(tmpFit[i] - this.reference.getValue(i, 0)), this.p);
|
||||
}
|
||||
resultFit[0] = Math.pow(resultFit[0], 1 / ((double) this.m_P));
|
||||
resultFit[0] = Math.pow(resultFit[0], 1 / ((double) this.p));
|
||||
} else {
|
||||
// Tchebycheff metric
|
||||
resultFit[0] = Double.NEGATIVE_INFINITY;
|
||||
for (int i = 0; (i < this.m_Reference.getNumRows()) && (i < tmpFit.length); i++) {
|
||||
resultFit[0] += Math.max(Math.abs(tmpFit[i] - this.m_Reference.getValue(i, 0)), resultFit[0]);
|
||||
for (int i = 0; (i < this.reference.getNumRows()) && (i < tmpFit.length); i++) {
|
||||
resultFit[0] += Math.max(Math.abs(tmpFit[i] - this.reference.getValue(i, 0)), resultFit[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,11 +92,11 @@ public class MOSOLpMetric implements InterfaceMOSOConverter, java.io.Serializabl
|
||||
for (int i = 0; i < newWeights.length; i++) {
|
||||
newWeights[i] = 0.0;
|
||||
}
|
||||
for (int i = 0; (i < this.m_Reference.getNumRows()) && (i < newWeights.length); i++) {
|
||||
newWeights[i] = this.m_Reference.getValue(i, 0);
|
||||
for (int i = 0; (i < this.reference.getNumRows()) && (i < newWeights.length); i++) {
|
||||
newWeights[i] = this.reference.getValue(i, 0);
|
||||
}
|
||||
|
||||
this.m_Reference.setDoubleArray(newWeights);
|
||||
this.reference.setDoubleArray(newWeights);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,11 +107,11 @@ public class MOSOLpMetric implements InterfaceMOSOConverter, java.io.Serializabl
|
||||
@Override
|
||||
public String getStringRepresentation() {
|
||||
String result = "Lp Metric\n";
|
||||
result += " P = " + this.m_P + "\n";
|
||||
result += " P = " + this.p + "\n";
|
||||
result += " Ref.Fitness = (";
|
||||
for (int i = 0; i < m_Reference.getNumRows(); i++) {
|
||||
result += m_Reference.getValue(i, 0);
|
||||
if (i < (m_Reference.getNumRows() - 1)) {
|
||||
for (int i = 0; i < reference.getNumRows(); i++) {
|
||||
result += reference.getValue(i, 0);
|
||||
if (i < (reference.getNumRows() - 1)) {
|
||||
result += "; ";
|
||||
}
|
||||
}
|
||||
@ -152,11 +148,11 @@ public class MOSOLpMetric implements InterfaceMOSOConverter, java.io.Serializabl
|
||||
* @param reference The reference vector.
|
||||
*/
|
||||
public void setReference(PropertyDoubleArray reference) {
|
||||
this.m_Reference = reference;
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public PropertyDoubleArray getReference() {
|
||||
return this.m_Reference;
|
||||
return this.reference;
|
||||
}
|
||||
|
||||
public String referenceTipText() {
|
||||
@ -169,11 +165,11 @@ public class MOSOLpMetric implements InterfaceMOSOConverter, java.io.Serializabl
|
||||
* @param p
|
||||
*/
|
||||
public void setP(int p) {
|
||||
this.m_P = Math.max(1, p);
|
||||
this.p = Math.max(1, p);
|
||||
}
|
||||
|
||||
public int getP() {
|
||||
return this.m_P;
|
||||
return this.p;
|
||||
}
|
||||
|
||||
public String pTipText() {
|
||||
|
@ -1,27 +1,21 @@
|
||||
package eva2.optimization.operator.moso;
|
||||
|
||||
import eva2.gui.plot.Plot;
|
||||
import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 06.08.2004
|
||||
* Time: 15:30:52
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOSOMaxiMin implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private int m_OutputDimension = 2;
|
||||
transient protected Plot m_Plot = null;
|
||||
private int outputDimension = 2;
|
||||
|
||||
public MOSOMaxiMin() {
|
||||
}
|
||||
|
||||
public MOSOMaxiMin(MOSOMaxiMin b) {
|
||||
this.m_OutputDimension = b.m_OutputDimension;
|
||||
this.outputDimension = b.outputDimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,8 +58,6 @@ public class MOSOMaxiMin implements InterfaceMOSOConverter, java.io.Serializable
|
||||
result[i] = Math.max(result[i], tmpResult);
|
||||
}
|
||||
}
|
||||
// result[i] is now negative and big for good individuals
|
||||
//result[i] = Math.exp(this.m_ScalingFactor * result[i]);
|
||||
// write the result to the individuals
|
||||
tmpIndy = (AbstractEAIndividual) pop.get(i);
|
||||
tmpFit = tmpIndy.getFitness();
|
||||
@ -74,32 +66,7 @@ public class MOSOMaxiMin implements InterfaceMOSOConverter, java.io.Serializable
|
||||
resultFit[0] = result[i];
|
||||
tmpIndy.setFitness(resultFit);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// if (false) {
|
||||
// this.plot = new eva2.gui.plot.Plot("Debug MaxiMin", "Y1", "Y2");
|
||||
// this.plot.setUnconnectedPoint(0, 0, 11);
|
||||
// this.plot.setUnconnectedPoint(1.2, 2.0, 11);
|
||||
// double[][] trueFitness, moFitness;
|
||||
// GraphPointSet mySet = new GraphPointSet(10, this.plot.getFunctionArea());
|
||||
// DPoint myPoint;
|
||||
// double tmp1, tmp2;
|
||||
// Chart2DDPointIconText tmp;
|
||||
// trueFitness = new double[pop.size()][];
|
||||
// moFitness = new double[pop.size()][];
|
||||
// for (int i = 0; i < pop.size(); i++) {
|
||||
// trueFitness[i] = ((AbstractEAIndividual)pop.get(i)).getFitness();
|
||||
// moFitness[i] = (double[])((AbstractEAIndividual)pop.get(i)).getData("MOFitness");
|
||||
// }
|
||||
// mySet.setConnectedMode(false);
|
||||
// for (int i = 0; i < trueFitness.length; i++) {
|
||||
// myPoint = new DPoint(moFitness[i][0], moFitness[i][1]);
|
||||
// tmp1 = Math.round(trueFitness[i][0] *100)/100.0;
|
||||
// tmp = new Chart2DDPointIconText(""+tmp1);
|
||||
// tmp.setIcon(new Chart2DDPointIconCircle());
|
||||
// myPoint.setIcon(tmp);
|
||||
// mySet.addDPoint(myPoint);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +95,7 @@ public class MOSOMaxiMin implements InterfaceMOSOConverter, java.io.Serializable
|
||||
*/
|
||||
@Override
|
||||
public void setOutputDimension(int dim) {
|
||||
this.m_OutputDimension = dim;
|
||||
this.outputDimension = dim;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,10 +108,6 @@ public class MOSOMaxiMin implements InterfaceMOSOConverter, java.io.Serializable
|
||||
return this.getName() + "\n";
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/**
|
||||
* This method allows the CommonJavaObjectEditorPanel to read the
|
||||
* name to the current object.
|
||||
@ -164,17 +127,4 @@ public class MOSOMaxiMin implements InterfaceMOSOConverter, java.io.Serializable
|
||||
public static String globalInfo() {
|
||||
return "This method calculate the maximum of minimum distance over all criterias over all individuals.";
|
||||
}
|
||||
// /** This method allows you to choose the ScalingFactor for
|
||||
// * the exp() function
|
||||
// * @param goals The scaling factor.
|
||||
// */
|
||||
// public void setScalingFactor(double goals) {
|
||||
// this.m_ScalingFactor = goals;
|
||||
// }
|
||||
// public double getScalingFactor() {
|
||||
// return this.m_ScalingFactor;
|
||||
// }
|
||||
// public String scalingFactorTipText() {
|
||||
// return "Choose the scaling factor for the exp() function.";
|
||||
// }
|
||||
}
|
@ -5,21 +5,17 @@ import eva2.optimization.population.Population;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 30.03.2004
|
||||
* Time: 17:56:39
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOSORandomChoice implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private int m_OutputDimension = 2;
|
||||
private int outputDimension = 2;
|
||||
|
||||
public MOSORandomChoice() {
|
||||
}
|
||||
|
||||
public MOSORandomChoice(MOSORandomChoice b) {
|
||||
this.m_OutputDimension = b.m_OutputDimension;
|
||||
this.outputDimension = b.outputDimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,7 +64,7 @@ public class MOSORandomChoice implements InterfaceMOSOConverter, java.io.Seriali
|
||||
*/
|
||||
@Override
|
||||
public void setOutputDimension(int dim) {
|
||||
this.m_OutputDimension = dim;
|
||||
this.outputDimension = dim;
|
||||
// i think as far as i got not solution for the (n>2) dimensional case
|
||||
// i could simply ignore this....
|
||||
}
|
||||
|
@ -5,22 +5,18 @@ import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 11.03.2004
|
||||
* Time: 13:44:55
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOSOUtilityFunction implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private int m_OutputDimension = 2;
|
||||
private int outputDimension = 2;
|
||||
|
||||
public MOSOUtilityFunction() {
|
||||
}
|
||||
|
||||
public MOSOUtilityFunction(MOSOUtilityFunction b) {
|
||||
System.out.println("Warning no source!");
|
||||
this.m_OutputDimension = b.m_OutputDimension;
|
||||
this.outputDimension = b.outputDimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,7 +75,7 @@ public class MOSOUtilityFunction implements InterfaceMOSOConverter, java.io.Seri
|
||||
*/
|
||||
@Override
|
||||
public void setOutputDimension(int dim) {
|
||||
this.m_OutputDimension = dim;
|
||||
this.outputDimension = dim;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,9 +88,6 @@ public class MOSOUtilityFunction implements InterfaceMOSOConverter, java.io.Seri
|
||||
return this.getName() + "\n";
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
* These are for GUI
|
||||
*/
|
||||
/**
|
||||
* This method allows the CommonJavaObjectEditorPanel to read the
|
||||
* name to the current object.
|
||||
@ -115,17 +108,4 @@ public class MOSOUtilityFunction implements InterfaceMOSOConverter, java.io.Seri
|
||||
return "This method allows you to progamm an individual utility function.";
|
||||
}
|
||||
|
||||
// /** This method allows you to edit the source for the MOSOUtilityFunction
|
||||
// * and therefore alter the utility function itself!
|
||||
// * @param newSource The new source code for the ultility function
|
||||
// */
|
||||
// public void setSource (Source newSource) {
|
||||
// m_Source = newSource;
|
||||
// }
|
||||
// public Source getSource() {
|
||||
// return m_Source;
|
||||
// }
|
||||
// public String sourceTipText() {
|
||||
// return "Edit the source code for the utility function, but limit editing to the convertSingleIndividual() method.";
|
||||
// }
|
||||
}
|
||||
|
@ -5,24 +5,20 @@ import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 05.03.2004
|
||||
* Time: 10:48:39
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOSOWeightedFitness implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private PropertyDoubleArray m_Weights = null;
|
||||
private PropertyDoubleArray weights = null;
|
||||
|
||||
public MOSOWeightedFitness() {
|
||||
double[][] tmpD = new double[2][1];
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i][0] = 1.0;
|
||||
}
|
||||
this.m_Weights = new PropertyDoubleArray(tmpD);
|
||||
for (int i = 0; i < this.m_Weights.getNumRows(); i++) {
|
||||
this.m_Weights.normalizeColumns();
|
||||
this.weights = new PropertyDoubleArray(tmpD);
|
||||
for (int i = 0; i < this.weights.getNumRows(); i++) {
|
||||
this.weights.normalizeColumns();
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,8 +28,8 @@ public class MOSOWeightedFitness implements InterfaceMOSOConverter, java.io.Seri
|
||||
}
|
||||
|
||||
public MOSOWeightedFitness(MOSOWeightedFitness b) {
|
||||
if (b.m_Weights != null) {
|
||||
this.m_Weights = (PropertyDoubleArray) b.m_Weights;
|
||||
if (b.weights != null) {
|
||||
this.weights = (PropertyDoubleArray) b.weights;
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,17 +66,17 @@ public class MOSOWeightedFitness implements InterfaceMOSOConverter, java.io.Seri
|
||||
|
||||
tmpFit = indy.getFitness();
|
||||
indy.putData("MOFitness", tmpFit);
|
||||
for (int i = 0; (i < this.m_Weights.getNumRows()) && (i < tmpFit.length); i++) {
|
||||
resultFit[0] += tmpFit[i] * this.m_Weights.getValue(i, 0);
|
||||
for (int i = 0; (i < this.weights.getNumRows()) && (i < tmpFit.length); i++) {
|
||||
resultFit[0] += tmpFit[i] * this.weights.getValue(i, 0);
|
||||
}
|
||||
indy.setFitness(resultFit);
|
||||
}
|
||||
|
||||
private void checkingWeights() {
|
||||
String s = "Using Weights: {";
|
||||
for (int i = 0; i < this.m_Weights.getNumRows(); i++) {
|
||||
s += this.m_Weights.getValue(i, 0);
|
||||
if (i < this.m_Weights.getNumRows() - 1) {
|
||||
for (int i = 0; i < this.weights.getNumRows(); i++) {
|
||||
s += this.weights.getValue(i, 0);
|
||||
if (i < this.weights.getNumRows() - 1) {
|
||||
s += "; ";
|
||||
}
|
||||
}
|
||||
@ -101,11 +97,11 @@ public class MOSOWeightedFitness implements InterfaceMOSOConverter, java.io.Seri
|
||||
for (int i = 0; i < newWeights.length; i++) {
|
||||
newWeights[i] = 1;
|
||||
}
|
||||
for (int i = 0; (i < this.m_Weights.getNumRows()) && (i < newWeights.length); i++) {
|
||||
newWeights[i] = this.m_Weights.getValue(i, 0);
|
||||
for (int i = 0; (i < this.weights.getNumRows()) && (i < newWeights.length); i++) {
|
||||
newWeights[i] = this.weights.getValue(i, 0);
|
||||
}
|
||||
|
||||
this.m_Weights.setDoubleArray(newWeights);
|
||||
this.weights.setDoubleArray(newWeights);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,11 +145,11 @@ public class MOSOWeightedFitness implements InterfaceMOSOConverter, java.io.Seri
|
||||
* @param weights The weights for the fitness sum.
|
||||
*/
|
||||
public void setWeights(PropertyDoubleArray weights) {
|
||||
this.m_Weights = weights;
|
||||
this.weights = weights;
|
||||
}
|
||||
|
||||
public PropertyDoubleArray getWeights() {
|
||||
return this.m_Weights;
|
||||
return this.weights;
|
||||
}
|
||||
|
||||
public String weightsTipText() {
|
||||
|
@ -5,34 +5,30 @@ import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 15.07.2005
|
||||
* Time: 10:12:28
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.io.Serializable {
|
||||
|
||||
private PropertyWeightedLPTchebycheff m_WLPT = null;
|
||||
private PropertyWeightedLPTchebycheff weightedLPTchebycheff = null;
|
||||
|
||||
public MOSOWeightedLPTchebycheff() {
|
||||
this.m_WLPT = new PropertyWeightedLPTchebycheff();
|
||||
this.m_WLPT.m_P = 0;
|
||||
this.weightedLPTchebycheff = new PropertyWeightedLPTchebycheff();
|
||||
this.weightedLPTchebycheff.p = 0;
|
||||
double[] tmpD = new double[2];
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i] = 0.0;
|
||||
}
|
||||
this.m_WLPT.idealValue = tmpD;
|
||||
this.weightedLPTchebycheff.idealValue = tmpD;
|
||||
tmpD = new double[2];
|
||||
for (int i = 0; i < tmpD.length; i++) {
|
||||
tmpD[i] = 1.0;
|
||||
}
|
||||
this.m_WLPT.weights = tmpD;
|
||||
this.weightedLPTchebycheff.weights = tmpD;
|
||||
}
|
||||
|
||||
public MOSOWeightedLPTchebycheff(MOSOWeightedLPTchebycheff b) {
|
||||
if (b.m_WLPT != null) {
|
||||
this.m_WLPT = (PropertyWeightedLPTchebycheff) b.m_WLPT.clone();
|
||||
if (b.weightedLPTchebycheff != null) {
|
||||
this.weightedLPTchebycheff = (PropertyWeightedLPTchebycheff) b.weightedLPTchebycheff.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,14 +67,14 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
indy.putData("MOFitness", tmpFit);
|
||||
resultFit[0] = 0;
|
||||
for (int i = 0; i < tmpFit.length; i++) {
|
||||
if (this.m_WLPT.m_P == 0) {
|
||||
resultFit[0] = Math.max(resultFit[0], this.m_WLPT.weights[i] * Math.abs(tmpFit[i] - this.m_WLPT.idealValue[i]));
|
||||
if (this.weightedLPTchebycheff.p == 0) {
|
||||
resultFit[0] = Math.max(resultFit[0], this.weightedLPTchebycheff.weights[i] * Math.abs(tmpFit[i] - this.weightedLPTchebycheff.idealValue[i]));
|
||||
} else {
|
||||
resultFit[0] += this.m_WLPT.weights[i] * Math.pow(tmpFit[i] - this.m_WLPT.idealValue[i], this.m_WLPT.m_P);
|
||||
resultFit[0] += this.weightedLPTchebycheff.weights[i] * Math.pow(tmpFit[i] - this.weightedLPTchebycheff.idealValue[i], this.weightedLPTchebycheff.p);
|
||||
}
|
||||
}
|
||||
if (this.m_WLPT.m_P > 0) {
|
||||
resultFit[0] = Math.pow(resultFit[0], 1 / ((double) this.m_WLPT.m_P));
|
||||
if (this.weightedLPTchebycheff.p > 0) {
|
||||
resultFit[0] = Math.pow(resultFit[0], 1 / ((double) this.weightedLPTchebycheff.p));
|
||||
}
|
||||
indy.setFitness(resultFit);
|
||||
}
|
||||
@ -99,12 +95,12 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
newTarget[i] = 0;
|
||||
newWeights[i] = 1.0;
|
||||
}
|
||||
for (int i = 0; (i < this.m_WLPT.idealValue.length) && (i < newTarget.length); i++) {
|
||||
newTarget[i] = this.m_WLPT.idealValue[i];
|
||||
newWeights[i] = this.m_WLPT.weights[i];
|
||||
for (int i = 0; (i < this.weightedLPTchebycheff.idealValue.length) && (i < newTarget.length); i++) {
|
||||
newTarget[i] = this.weightedLPTchebycheff.idealValue[i];
|
||||
newWeights[i] = this.weightedLPTchebycheff.weights[i];
|
||||
}
|
||||
this.m_WLPT.idealValue = newTarget;
|
||||
this.m_WLPT.weights = newWeights;
|
||||
this.weightedLPTchebycheff.idealValue = newTarget;
|
||||
this.weightedLPTchebycheff.weights = newWeights;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,9 +111,9 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
@Override
|
||||
public String getStringRepresentation() {
|
||||
String result = "Lp Metric\n";
|
||||
result += " P = " + this.m_WLPT.m_P + "\n";
|
||||
result += " P = " + this.weightedLPTchebycheff.p + "\n";
|
||||
result += " Ref.Fitness = (";
|
||||
double[] p = this.m_WLPT.idealValue;
|
||||
double[] p = this.weightedLPTchebycheff.idealValue;
|
||||
for (int i = 0; i < p.length; i++) {
|
||||
result += p[i];
|
||||
if (i < (p.length - 1)) {
|
||||
@ -126,7 +122,7 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
}
|
||||
result += ")\n";
|
||||
result += " Weights = (";
|
||||
p = this.m_WLPT.weights;
|
||||
p = this.weightedLPTchebycheff.weights;
|
||||
for (int i = 0; i < p.length; i++) {
|
||||
result += p[i];
|
||||
if (i < (p.length - 1)) {
|
||||
@ -167,11 +163,11 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
||||
* @param weights The Epsilon Threshhold for the fitness sum.
|
||||
*/
|
||||
public void setIdealPWeights(PropertyWeightedLPTchebycheff weights) {
|
||||
this.m_WLPT = weights;
|
||||
this.weightedLPTchebycheff = weights;
|
||||
}
|
||||
|
||||
public PropertyWeightedLPTchebycheff getIdealPWeights() {
|
||||
return this.m_WLPT;
|
||||
return this.weightedLPTchebycheff;
|
||||
}
|
||||
|
||||
public String idealPWeightsTipText() {
|
||||
|
@ -249,41 +249,6 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java
|
||||
}
|
||||
|
||||
protected void evaluateNewObjectX(double[] x, double[][] range) {
|
||||
// if (Double.isNaN((x[0]))) System.out.println("treffer in cma "+ x[0]);
|
||||
// if (Double.isNaN((c.get(0,0)))) System.out.println("treffer in cma");
|
||||
// for (int i=0;i<N;i++) { // evaluate new random values
|
||||
// Z[i] = RNG.gaussianDouble(1.0);
|
||||
// }
|
||||
// c = (c.plus(c.transpose()).times(0.5)); // MAKE C SYMMETRIC
|
||||
// EigenvalueDecomposition helper = new EigenvalueDecomposition(c);
|
||||
// B = helper.getV();
|
||||
// double [] Eigenvalues = helper.getRealEigenvalues();
|
||||
// double[] tmpD = new double[x.length];
|
||||
// boolean constraint = false;
|
||||
// while (constraint == false) {
|
||||
//
|
||||
// for (int i=0;i<N;i++) {
|
||||
// Bz[i] = 0;
|
||||
// for (int j=0;j<N;j++) {
|
||||
// Bz[i] = Bz[i] + Math.sqrt(Math.abs(Eigenvalues[j])) * B.get(i,j)*Z[j];
|
||||
// }
|
||||
// tmpD[i]=x[i]+m_SigmaScalar*Bz[i]; // here is the new value
|
||||
// }
|
||||
// constraint = true;
|
||||
// if (this.checkConstraints) {
|
||||
// for (int i=0;i<N;i++) {
|
||||
// if ((tmpD[i]<range[i][0]) || (tmpD[i]>range[i][1])) constraint = false;
|
||||
// }
|
||||
// if (!constraint) this.m_SigmaScalar = this.m_SigmaScalar/2;
|
||||
// if (this.m_SigmaScalar < 1.e-20) {
|
||||
// this.m_SigmaScalar = 1.e-10;
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (int i = 0; i < N; i++) x[i] = tmpD[i];
|
||||
// conservation of mutation direction:
|
||||
//double[] oldZ = (double[]) this.Z.clone();
|
||||
double[] oldX = (double[]) x.clone();
|
||||
|
||||
for (int i = 0; i < this.D; i++) {
|
||||
|
@ -14,17 +14,17 @@ import eva2.tools.math.RNG;
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MutateESFixedStepSize implements InterfaceMutation, java.io.Serializable {
|
||||
protected double m_Sigma = 0.005;
|
||||
protected double sigma = 0.005;
|
||||
|
||||
public MutateESFixedStepSize() {
|
||||
}
|
||||
|
||||
public MutateESFixedStepSize(MutateESFixedStepSize mutator) {
|
||||
this.m_Sigma = mutator.m_Sigma;
|
||||
this.sigma = mutator.sigma;
|
||||
}
|
||||
|
||||
public MutateESFixedStepSize(double sigma) {
|
||||
m_Sigma = sigma;
|
||||
this.sigma = sigma;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,7 +47,7 @@ public class MutateESFixedStepSize implements InterfaceMutation, java.io.Seriali
|
||||
public boolean equals(Object mutator) {
|
||||
if (mutator instanceof MutateESFixedStepSize) {
|
||||
MutateESFixedStepSize mut = (MutateESFixedStepSize) mutator;
|
||||
if (this.m_Sigma != mut.m_Sigma) {
|
||||
if (this.sigma != mut.sigma) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -80,7 +80,7 @@ public class MutateESFixedStepSize implements InterfaceMutation, java.io.Seriali
|
||||
double[] x = ((InterfaceESIndividual) individual).getDGenotype();
|
||||
double[][] range = ((InterfaceESIndividual) individual).getDoubleRange();
|
||||
for (int i = 0; i < x.length; i++) {
|
||||
x[i] += ((range[i][1] - range[i][0]) / 2) * RNG.gaussianDouble(this.m_Sigma);
|
||||
x[i] += ((range[i][1] - range[i][0]) / 2) * RNG.gaussianDouble(this.sigma);
|
||||
if (range[i][0] > x[i]) {
|
||||
x[i] = range[i][0];
|
||||
}
|
||||
@ -148,11 +148,11 @@ public class MutateESFixedStepSize implements InterfaceMutation, java.io.Seriali
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
this.m_Sigma = d;
|
||||
this.sigma = d;
|
||||
}
|
||||
|
||||
public double getSigma() {
|
||||
return this.m_Sigma;
|
||||
return this.sigma;
|
||||
}
|
||||
|
||||
public String sigmaTipText() {
|
||||
|
@ -13,17 +13,13 @@ import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 02.04.2003
|
||||
* Time: 16:29:47
|
||||
* To change this template use Options | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MutateESGlobal implements InterfaceMutation, java.io.Serializable, InterfaceAdditionalPopulationInformer {
|
||||
protected double m_MutationStepSize = 0.2;
|
||||
protected double m_Tau1 = 0.15;
|
||||
protected double m_LowerLimitStepSize = 0.0000005;
|
||||
protected MutateESCrossoverTypeEnum m_CrossoverType = MutateESCrossoverTypeEnum.none;
|
||||
protected double mutationStepSize = 0.2;
|
||||
protected double tau1 = 0.15;
|
||||
protected double lowerLimitStepSize = 0.0000005;
|
||||
protected MutateESCrossoverTypeEnum crossoverType = MutateESCrossoverTypeEnum.none;
|
||||
|
||||
public MutateESGlobal() {
|
||||
}
|
||||
@ -48,10 +44,10 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
}
|
||||
|
||||
public MutateESGlobal(MutateESGlobal mutator) {
|
||||
this.m_MutationStepSize = mutator.m_MutationStepSize;
|
||||
this.m_Tau1 = mutator.m_Tau1;
|
||||
this.m_LowerLimitStepSize = mutator.m_LowerLimitStepSize;
|
||||
this.m_CrossoverType = mutator.m_CrossoverType;
|
||||
this.mutationStepSize = mutator.mutationStepSize;
|
||||
this.tau1 = mutator.tau1;
|
||||
this.lowerLimitStepSize = mutator.lowerLimitStepSize;
|
||||
this.crossoverType = mutator.crossoverType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,13 +70,13 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
public boolean equals(Object mutator) {
|
||||
if (mutator instanceof MutateESGlobal) {
|
||||
MutateESGlobal mut = (MutateESGlobal) mutator;
|
||||
if (this.m_MutationStepSize != mut.m_MutationStepSize) {
|
||||
if (this.mutationStepSize != mut.mutationStepSize) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Tau1 != mut.m_Tau1) {
|
||||
if (this.tau1 != mut.tau1) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_LowerLimitStepSize != mut.m_LowerLimitStepSize) {
|
||||
if (this.lowerLimitStepSize != mut.lowerLimitStepSize) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -112,12 +108,12 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
if (individual instanceof InterfaceESIndividual) {
|
||||
double[] x = ((InterfaceESIndividual) individual).getDGenotype();
|
||||
double[][] range = ((InterfaceESIndividual) individual).getDoubleRange();
|
||||
this.m_MutationStepSize *= Math.exp(this.m_Tau1 * RNG.gaussianDouble(1));
|
||||
if (this.m_MutationStepSize < this.m_LowerLimitStepSize) {
|
||||
this.m_MutationStepSize = this.m_LowerLimitStepSize;
|
||||
this.mutationStepSize *= Math.exp(this.tau1 * RNG.gaussianDouble(1));
|
||||
if (this.mutationStepSize < this.lowerLimitStepSize) {
|
||||
this.mutationStepSize = this.lowerLimitStepSize;
|
||||
}
|
||||
for (int i = 0; i < x.length; i++) {
|
||||
x[i] += ((range[i][1] - range[i][0]) / 2) * RNG.gaussianDouble(this.m_MutationStepSize);
|
||||
x[i] += ((range[i][1] - range[i][0]) / 2) * RNG.gaussianDouble(this.mutationStepSize);
|
||||
if (range[i][0] > x[i]) {
|
||||
x[i] = range[i][0];
|
||||
}
|
||||
@ -140,14 +136,14 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
*/
|
||||
@Override
|
||||
public void crossoverOnStrategyParameters(AbstractEAIndividual indy1, Population partners) {
|
||||
if (m_CrossoverType != MutateESCrossoverTypeEnum.none) {
|
||||
if (crossoverType != MutateESCrossoverTypeEnum.none) {
|
||||
ArrayList<Double> tmpList = new ArrayList<Double>();
|
||||
if (indy1.getMutationOperator() instanceof MutateESGlobal) {
|
||||
tmpList.add(new Double(((MutateESGlobal) indy1.getMutationOperator()).m_MutationStepSize));
|
||||
tmpList.add(new Double(((MutateESGlobal) indy1.getMutationOperator()).mutationStepSize));
|
||||
}
|
||||
for (int i = 0; i < partners.size(); i++) {
|
||||
if (((AbstractEAIndividual) partners.get(i)).getMutationOperator() instanceof MutateESGlobal) {
|
||||
tmpList.add(new Double(((MutateESGlobal) ((AbstractEAIndividual) partners.get(i)).getMutationOperator()).m_MutationStepSize));
|
||||
tmpList.add(new Double(((MutateESGlobal) ((AbstractEAIndividual) partners.get(i)).getMutationOperator()).mutationStepSize));
|
||||
}
|
||||
}
|
||||
double[] list = new double[tmpList.size()];
|
||||
@ -158,16 +154,16 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
return;
|
||||
}
|
||||
|
||||
switch (this.m_CrossoverType) {
|
||||
switch (this.crossoverType) {
|
||||
case intermediate:
|
||||
this.m_MutationStepSize = 0;
|
||||
this.mutationStepSize = 0;
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
this.m_MutationStepSize += list[i];
|
||||
this.mutationStepSize += list[i];
|
||||
}
|
||||
this.m_MutationStepSize /= (double) list.length;
|
||||
this.mutationStepSize /= (double) list.length;
|
||||
break;
|
||||
case discrete:
|
||||
this.m_MutationStepSize = list[RNG.randomInt(0, list.length - 1)];
|
||||
this.mutationStepSize = list[RNG.randomInt(0, list.length - 1)];
|
||||
break;
|
||||
case none: // do nothing
|
||||
break;
|
||||
@ -215,13 +211,13 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
*/
|
||||
public void setMutationStepSize(double d) {
|
||||
if (d < 0) {
|
||||
d = this.m_LowerLimitStepSize;
|
||||
d = this.lowerLimitStepSize;
|
||||
}
|
||||
this.m_MutationStepSize = d;
|
||||
this.mutationStepSize = d;
|
||||
}
|
||||
|
||||
public double getMutationStepSize() {
|
||||
return this.m_MutationStepSize;
|
||||
return this.mutationStepSize;
|
||||
}
|
||||
|
||||
public String mutationStepSizeTipText() {
|
||||
@ -237,11 +233,11 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
this.m_LowerLimitStepSize = d;
|
||||
this.lowerLimitStepSize = d;
|
||||
}
|
||||
|
||||
public double getLowerLimitStepSize() {
|
||||
return this.m_LowerLimitStepSize;
|
||||
return this.lowerLimitStepSize;
|
||||
}
|
||||
|
||||
public String lowerLimitStepSizeTipText() {
|
||||
@ -257,11 +253,11 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
this.m_Tau1 = d;
|
||||
this.tau1 = d;
|
||||
}
|
||||
|
||||
public double getTau1() {
|
||||
return this.m_Tau1;
|
||||
return this.tau1;
|
||||
}
|
||||
|
||||
public String tau1TipText() {
|
||||
@ -274,11 +270,11 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
* @param d The mutation operator.
|
||||
*/
|
||||
public void setCrossoverType(MutateESCrossoverTypeEnum d) {
|
||||
this.m_CrossoverType = d;
|
||||
this.crossoverType = d;
|
||||
}
|
||||
|
||||
public MutateESCrossoverTypeEnum getCrossoverType() {
|
||||
return this.m_CrossoverType;
|
||||
return this.crossoverType;
|
||||
}
|
||||
|
||||
public String crossoverTypeTipText() {
|
||||
@ -309,6 +305,6 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
|
||||
*/
|
||||
@Override
|
||||
public Object[] getAdditionalDataValue(PopulationInterface pop) {
|
||||
return new Object[]{m_MutationStepSize};
|
||||
return new Object[]{mutationStepSize};
|
||||
}
|
||||
}
|
||||
|
@ -14,42 +14,38 @@ import eva2.tools.math.RNG;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 02.04.2003
|
||||
* Time: 17:58:30
|
||||
* To change this template use Options | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopulationInformer, java.io.Serializable {
|
||||
|
||||
protected double m_MutationStepSize = 0.2;
|
||||
protected double m_Tau1 = 0.15;
|
||||
protected double m_LowerLimitStepSize = 0.0000005;
|
||||
private double[] m_Sigmas;
|
||||
protected double m_Tau2 = 0.15;
|
||||
protected SelectedTag m_CrossoverType;
|
||||
protected double mutationStepSize = 0.2;
|
||||
protected double tau1 = 0.15;
|
||||
protected double lowerLimitStepSize = 0.0000005;
|
||||
private double[] sigmas;
|
||||
protected double tau2 = 0.15;
|
||||
protected SelectedTag crossoverType;
|
||||
|
||||
public MutateESLocal() {
|
||||
this.m_Sigmas = null;
|
||||
this.sigmas = null;
|
||||
Tag[] tag = new Tag[3];
|
||||
tag[0] = new Tag(0, "None");
|
||||
tag[1] = new Tag(1, "Intermediate");
|
||||
tag[2] = new Tag(2, "Discrete");
|
||||
this.m_CrossoverType = new SelectedTag(0, tag);
|
||||
this.crossoverType = new SelectedTag(0, tag);
|
||||
}
|
||||
|
||||
public MutateESLocal(MutateESLocal mutator) {
|
||||
if (mutator.m_Sigmas != null) {
|
||||
this.m_Sigmas = new double[mutator.m_Sigmas.length];
|
||||
for (int i = 0; i < this.m_Sigmas.length; i++) {
|
||||
this.m_Sigmas[i] = mutator.m_Sigmas[i];
|
||||
if (mutator.sigmas != null) {
|
||||
this.sigmas = new double[mutator.sigmas.length];
|
||||
for (int i = 0; i < this.sigmas.length; i++) {
|
||||
this.sigmas[i] = mutator.sigmas[i];
|
||||
}
|
||||
}
|
||||
this.m_MutationStepSize = mutator.m_MutationStepSize;
|
||||
this.m_Tau1 = mutator.m_Tau1;
|
||||
this.m_Tau2 = mutator.m_Tau2;
|
||||
this.m_LowerLimitStepSize = mutator.m_LowerLimitStepSize;
|
||||
this.m_CrossoverType = (SelectedTag) mutator.m_CrossoverType.clone();
|
||||
this.mutationStepSize = mutator.mutationStepSize;
|
||||
this.tau1 = mutator.tau1;
|
||||
this.tau2 = mutator.tau2;
|
||||
this.lowerLimitStepSize = mutator.lowerLimitStepSize;
|
||||
this.crossoverType = (SelectedTag) mutator.crossoverType.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,18 +71,18 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
}
|
||||
if (mutator instanceof MutateESLocal) {
|
||||
MutateESLocal mut = (MutateESLocal) mutator;
|
||||
if (this.m_Tau1 != mut.m_Tau1) {
|
||||
if (this.tau1 != mut.tau1) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Tau2 != mut.m_Tau2) {
|
||||
if (this.tau2 != mut.tau2) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_LowerLimitStepSize != mut.m_LowerLimitStepSize) {
|
||||
if (this.lowerLimitStepSize != mut.lowerLimitStepSize) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Sigmas != null) {
|
||||
for (int i = 0; i < this.m_Sigmas.length; i++) {
|
||||
if (this.m_Sigmas[i] != mut.m_Sigmas[i]) {
|
||||
if (this.sigmas != null) {
|
||||
for (int i = 0; i < this.sigmas.length; i++) {
|
||||
if (this.sigmas[i] != mut.sigmas[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -109,9 +105,9 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
|
||||
if (individual instanceof InterfaceESIndividual) {
|
||||
// init the Sigmas
|
||||
this.m_Sigmas = new double[((InterfaceESIndividual) individual).getDGenotype().length];
|
||||
for (int i = 0; i < this.m_Sigmas.length; i++) {
|
||||
this.m_Sigmas[i] = this.m_MutationStepSize;
|
||||
this.sigmas = new double[((InterfaceESIndividual) individual).getDGenotype().length];
|
||||
for (int i = 0; i < this.sigmas.length; i++) {
|
||||
this.sigmas[i] = this.mutationStepSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,11 +128,11 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
double tmpR = RNG.gaussianDouble(1);
|
||||
|
||||
for (int i = 0; i < x.length; i++) {
|
||||
this.m_Sigmas[i] *= Math.exp(this.m_Tau1 * tmpR + this.m_Tau2 * RNG.gaussianDouble(1));
|
||||
if (this.m_Sigmas[i] < this.m_LowerLimitStepSize) {
|
||||
this.m_Sigmas[i] = this.m_LowerLimitStepSize;
|
||||
this.sigmas[i] *= Math.exp(this.tau1 * tmpR + this.tau2 * RNG.gaussianDouble(1));
|
||||
if (this.sigmas[i] < this.lowerLimitStepSize) {
|
||||
this.sigmas[i] = this.lowerLimitStepSize;
|
||||
}
|
||||
x[i] += ((range[i][1] - range[i][0]) / 2) * RNG.gaussianDouble(this.m_Sigmas[i]);
|
||||
x[i] += ((range[i][1] - range[i][0]) / 2) * RNG.gaussianDouble(this.sigmas[i]);
|
||||
if (range[i][0] > x[i]) {
|
||||
x[i] = range[i][0];
|
||||
}
|
||||
@ -161,13 +157,13 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
ArrayList tmpListA = new ArrayList();
|
||||
ArrayList tmpListB = new ArrayList();
|
||||
if (indy1.getMutationOperator() instanceof MutateESLocal) {
|
||||
tmpListA.add(new Double(((MutateESLocal) indy1.getMutationOperator()).m_MutationStepSize));
|
||||
tmpListB.add(((MutateESLocal) indy1.getMutationOperator()).m_Sigmas);
|
||||
tmpListA.add(new Double(((MutateESLocal) indy1.getMutationOperator()).mutationStepSize));
|
||||
tmpListB.add(((MutateESLocal) indy1.getMutationOperator()).sigmas);
|
||||
}
|
||||
for (int i = 0; i < partners.size(); i++) {
|
||||
if (((AbstractEAIndividual) partners.get(i)).getMutationOperator() instanceof MutateESLocal) {
|
||||
tmpListA.add(new Double(((MutateESLocal) ((AbstractEAIndividual) partners.get(i)).getMutationOperator()).m_MutationStepSize));
|
||||
tmpListB.add(((MutateESLocal) ((AbstractEAIndividual) partners.get(i)).getMutationOperator()).m_Sigmas);
|
||||
tmpListA.add(new Double(((MutateESLocal) ((AbstractEAIndividual) partners.get(i)).getMutationOperator()).mutationStepSize));
|
||||
tmpListB.add(((MutateESLocal) ((AbstractEAIndividual) partners.get(i)).getMutationOperator()).sigmas);
|
||||
}
|
||||
}
|
||||
double[] listA = new double[tmpListA.size()];
|
||||
@ -179,30 +175,30 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
if (listA.length <= 1) {
|
||||
return;
|
||||
}
|
||||
switch (this.m_CrossoverType.getSelectedTag().getID()) {
|
||||
switch (this.crossoverType.getSelectedTag().getID()) {
|
||||
case 1: {
|
||||
this.m_MutationStepSize = 0;
|
||||
for (int i = 0; i < this.m_Sigmas.length; i++) {
|
||||
this.m_Sigmas[i] = 0;
|
||||
this.mutationStepSize = 0;
|
||||
for (int i = 0; i < this.sigmas.length; i++) {
|
||||
this.sigmas[i] = 0;
|
||||
}
|
||||
for (int i = 0; i < listA.length; i++) {
|
||||
this.m_MutationStepSize += listA[i];
|
||||
for (int j = 0; j < this.m_Sigmas.length; j++) {
|
||||
this.m_Sigmas[j] += listB[i][j];
|
||||
this.mutationStepSize += listA[i];
|
||||
for (int j = 0; j < this.sigmas.length; j++) {
|
||||
this.sigmas[j] += listB[i][j];
|
||||
}
|
||||
}
|
||||
this.m_MutationStepSize /= (double) listA.length;
|
||||
for (int i = 0; i < this.m_Sigmas.length; i++) {
|
||||
this.m_Sigmas[i] /= (double) listA.length;
|
||||
this.mutationStepSize /= (double) listA.length;
|
||||
for (int i = 0; i < this.sigmas.length; i++) {
|
||||
this.sigmas[i] /= (double) listA.length;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
int rn = RNG.randomInt(0, listA.length - 1);
|
||||
this.m_MutationStepSize = listA[rn];
|
||||
for (int i = 0; i < this.m_Sigmas.length; i++) {
|
||||
this.mutationStepSize = listA[rn];
|
||||
for (int i = 0; i < this.sigmas.length; i++) {
|
||||
rn = RNG.randomInt(0, listA.length - 1);
|
||||
this.m_Sigmas[i] = listB[rn][i];
|
||||
this.sigmas[i] = listB[rn][i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -252,13 +248,13 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
*/
|
||||
public void setMutationStepSize(double d) {
|
||||
if (d < 0) {
|
||||
d = this.m_LowerLimitStepSize;
|
||||
d = this.lowerLimitStepSize;
|
||||
}
|
||||
this.m_MutationStepSize = d;
|
||||
this.mutationStepSize = d;
|
||||
}
|
||||
|
||||
public double getMutationStepSize() {
|
||||
return this.m_MutationStepSize;
|
||||
return this.mutationStepSize;
|
||||
}
|
||||
|
||||
public String mutationStepSizeTipText() {
|
||||
@ -274,11 +270,11 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
this.m_LowerLimitStepSize = d;
|
||||
this.lowerLimitStepSize = d;
|
||||
}
|
||||
|
||||
public double getLowerLimitStepSize() {
|
||||
return this.m_LowerLimitStepSize;
|
||||
return this.lowerLimitStepSize;
|
||||
}
|
||||
|
||||
public String lowerLimitStepSizeTipText() {
|
||||
@ -294,11 +290,11 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
this.m_Tau1 = d;
|
||||
this.tau1 = d;
|
||||
}
|
||||
|
||||
public double getTau1() {
|
||||
return this.m_Tau1;
|
||||
return this.tau1;
|
||||
}
|
||||
|
||||
public String tau1TipText() {
|
||||
@ -314,11 +310,11 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
this.m_Tau2 = d;
|
||||
this.tau2 = d;
|
||||
}
|
||||
|
||||
public double getTau2() {
|
||||
return this.m_Tau2;
|
||||
return this.tau2;
|
||||
}
|
||||
|
||||
public String tau2TipText() {
|
||||
@ -331,11 +327,11 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
* @param d The mutation operator.
|
||||
*/
|
||||
public void setCrossoverType(SelectedTag d) {
|
||||
this.m_CrossoverType = d;
|
||||
this.crossoverType = d;
|
||||
}
|
||||
|
||||
public SelectedTag getCrossoverType() {
|
||||
return this.m_CrossoverType;
|
||||
return this.crossoverType;
|
||||
}
|
||||
|
||||
public String crossoverTypeTipText() {
|
||||
@ -366,6 +362,6 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
|
||||
*/
|
||||
@Override
|
||||
public Object[] getAdditionalDataValue(PopulationInterface pop) {
|
||||
return new Object[]{m_Sigmas};
|
||||
return new Object[]{sigmas};
|
||||
}
|
||||
}
|
||||
|
@ -8,26 +8,22 @@ import eva2.tools.math.Mathematics;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 26.03.2004
|
||||
* Time: 11:18:36
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Serializable {
|
||||
|
||||
private boolean m_CheckConstraints = true;
|
||||
private boolean checkConstraints = true;
|
||||
static public final String Name = "MVA";
|
||||
private int N;
|
||||
private double[] m_Z;
|
||||
private double m_SigmaScalar = 1.0;
|
||||
private double m_InitSigmaScalar = 1.0;
|
||||
private double m_c;
|
||||
private double m_cov;
|
||||
private double m_Beta;
|
||||
private double[] s_N;
|
||||
private double[] s_d_N;
|
||||
private double[] m_main_v;
|
||||
private double[] Z;
|
||||
private double sigmaScalar = 1.0;
|
||||
private double initSigmaScalar = 1.0;
|
||||
private double c;
|
||||
private double cov;
|
||||
private double beta;
|
||||
private double[] sN;
|
||||
private double[] dN;
|
||||
private double[] mainV;
|
||||
private double xi_dach;
|
||||
private double Z1;
|
||||
private double w_v = 3.0;
|
||||
@ -38,25 +34,25 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
|
||||
public MutateESMainVectorAdaption(MutateESMainVectorAdaption mutator) {
|
||||
this.N = mutator.N;
|
||||
this.m_SigmaScalar = mutator.m_SigmaScalar;
|
||||
this.m_InitSigmaScalar = mutator.m_InitSigmaScalar;
|
||||
this.m_c = mutator.m_c;
|
||||
this.m_cov = mutator.m_cov;
|
||||
this.m_Beta = mutator.m_Beta;
|
||||
this.sigmaScalar = mutator.sigmaScalar;
|
||||
this.initSigmaScalar = mutator.initSigmaScalar;
|
||||
this.c = mutator.c;
|
||||
this.cov = mutator.cov;
|
||||
this.beta = mutator.beta;
|
||||
this.xi_dach = mutator.xi_dach;
|
||||
this.Z1 = mutator.Z1;
|
||||
this.w_v = mutator.w_v;
|
||||
if (mutator.m_main_v != null) {
|
||||
this.m_main_v = (double[]) mutator.m_main_v.clone();
|
||||
if (mutator.mainV != null) {
|
||||
this.mainV = (double[]) mutator.mainV.clone();
|
||||
}
|
||||
if (mutator.m_Z != null) {
|
||||
this.m_Z = (double[]) mutator.m_Z.clone();
|
||||
if (mutator.Z != null) {
|
||||
this.Z = (double[]) mutator.Z.clone();
|
||||
}
|
||||
if (mutator.s_N != null) {
|
||||
this.s_N = (double[]) mutator.s_N.clone();
|
||||
if (mutator.sN != null) {
|
||||
this.sN = (double[]) mutator.sN.clone();
|
||||
}
|
||||
if (mutator.s_d_N != null) {
|
||||
this.s_d_N = (double[]) mutator.s_d_N.clone();
|
||||
if (mutator.dN != null) {
|
||||
this.dN = (double[]) mutator.dN.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,12 +80,12 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
if (mutator instanceof MutateESMainVectorAdaption) {
|
||||
MutateESMainVectorAdaption mut = (MutateESMainVectorAdaption) mutator;
|
||||
// i assume if the main_V is equal then the mutation operators are equal
|
||||
if (this.m_main_v == mut.m_main_v) {
|
||||
if (this.mainV == mut.mainV) {
|
||||
return true;
|
||||
}
|
||||
if (this.m_main_v != null) {
|
||||
for (int i = 0; i < this.m_main_v.length; i++) {
|
||||
if (this.m_main_v[i] != mut.m_main_v[i]) {
|
||||
if (this.mainV != null) {
|
||||
for (int i = 0; i < this.mainV.length; i++) {
|
||||
if (this.mainV[i] != mut.mainV[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -115,24 +111,24 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
}
|
||||
double[] x = ((InterfaceESIndividual) individual).getDGenotype();
|
||||
double[][] ranges = ((InterfaceESIndividual) individual).getDoubleRange();
|
||||
this.m_SigmaScalar = this.m_InitSigmaScalar;
|
||||
this.sigmaScalar = this.initSigmaScalar;
|
||||
this.N = x.length;
|
||||
this.m_c = Math.sqrt(1.0 / (double) this.N); // Sigma-Path-Constant
|
||||
this.m_Beta = this.m_c;
|
||||
this.m_cov = 2.0 / ((double) this.N * (double) this.N);
|
||||
this.m_Z = new double[this.N];
|
||||
this.s_N = new double[this.N];
|
||||
this.s_d_N = new double[this.N];
|
||||
this.m_main_v = new double[this.N];
|
||||
this.c = Math.sqrt(1.0 / (double) this.N); // Sigma-Path-Constant
|
||||
this.beta = this.c;
|
||||
this.cov = 2.0 / ((double) this.N * (double) this.N);
|
||||
this.Z = new double[this.N];
|
||||
this.sN = new double[this.N];
|
||||
this.dN = new double[this.N];
|
||||
this.mainV = new double[this.N];
|
||||
for (int i = 0; i < this.N; i++) {
|
||||
this.s_N[i] = 0;
|
||||
this.s_d_N[i] = 0;
|
||||
this.m_main_v[i] = 0;
|
||||
this.sN[i] = 0;
|
||||
this.dN[i] = 0;
|
||||
this.mainV[i] = 0;
|
||||
}
|
||||
;
|
||||
this.xi_dach = Math.sqrt(this.N - 0.5);
|
||||
for (int i = 0; i < this.N; i++) {
|
||||
this.m_Z[i] = RNG.gaussianDouble(1.0);
|
||||
this.Z[i] = RNG.gaussianDouble(1.0);
|
||||
}
|
||||
this.Z1 = RNG.gaussianDouble(1.0);
|
||||
evaluateNewObjectX(x, ranges);
|
||||
@ -152,7 +148,7 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
double[][] ranges = ((InterfaceESIndividual) individual).getDoubleRange();
|
||||
this.adaptStrategy();
|
||||
for (int i = 0; i < N; i++) {
|
||||
m_Z[i] = RNG.gaussianDouble(1.0);
|
||||
Z[i] = RNG.gaussianDouble(1.0);
|
||||
}
|
||||
Z1 = RNG.gaussianDouble(1.0);
|
||||
evaluateNewObjectX(x, ranges);
|
||||
@ -177,14 +173,14 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
private void adaptStrategy() {
|
||||
double length = 0.0;
|
||||
for (int i = 0; i < this.N; i++) {
|
||||
this.s_d_N[i] = (1.0 - this.m_c) * this.s_d_N[i] + Math.sqrt(this.m_c * (2.0 - this.m_c)) * this.m_Z[i]; // PATH
|
||||
length += this.s_d_N[i] * this.s_d_N[i];
|
||||
this.dN[i] = (1.0 - this.c) * this.dN[i] + Math.sqrt(this.c * (2.0 - this.c)) * this.Z[i]; // PATH
|
||||
length += this.dN[i] * this.dN[i];
|
||||
}
|
||||
this.m_SigmaScalar *= Math.exp(this.m_Beta * this.m_c * (Math.sqrt(length) - this.xi_dach));
|
||||
this.sigmaScalar *= Math.exp(this.beta * this.c * (Math.sqrt(length) - this.xi_dach));
|
||||
// SIGN OF SCALAR PRODUCT
|
||||
double Product = 0.0;
|
||||
for (int i = 0; i < this.N; i++) {
|
||||
Product += this.s_N[i] * this.m_main_v[i];
|
||||
Product += this.sN[i] * this.mainV[i];
|
||||
}
|
||||
if (Product < 0.0) {
|
||||
Product = -1.0;
|
||||
@ -192,8 +188,8 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
Product = 1.0;
|
||||
}
|
||||
for (int i = 0; i < this.N; i++) { // ADAPT MAIN VECTOR
|
||||
this.s_N[i] = (1.0 - this.m_c) * this.s_N[i] + Math.sqrt(this.m_c * (2.0 - this.m_c)) * (this.m_Z[i] + this.Z1 * this.w_v * this.m_main_v[i]); // PATH MAIN VECTOR
|
||||
this.m_main_v[i] = (1.0 - this.m_cov) * Product * this.m_main_v[i] + this.m_cov * this.s_N[i];
|
||||
this.sN[i] = (1.0 - this.c) * this.sN[i] + Math.sqrt(this.c * (2.0 - this.c)) * (this.Z[i] + this.Z1 * this.w_v * this.mainV[i]); // PATH MAIN VECTOR
|
||||
this.mainV[i] = (1.0 - this.cov) * Product * this.mainV[i] + this.cov * this.sN[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +201,7 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
// boolean constraint = false;
|
||||
// int counter = 0;
|
||||
// while (constraint == false) {
|
||||
// for (int i = 0; i < x.length; i++) x[i] = x[i] + m_SigmaScalar * (Z[i] + Z1 * w_v * m_main_v[i]);
|
||||
// for (int i = 0; i < x.length; i++) x[i] = x[i] + sigmaScalar * (Z[i] + Z1 * w_v * mainV[i]);
|
||||
// constraint = true;
|
||||
// if (counter++ > 30) break;
|
||||
// if (checkConstraints == true) {
|
||||
@ -216,7 +212,7 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
double[] v = (double[]) this.m_main_v.clone();
|
||||
double[] v = (double[]) this.mainV.clone();
|
||||
double[] grad = new double[x.length];
|
||||
double vl = 0;
|
||||
double gradl = 0;
|
||||
@ -230,7 +226,7 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
for (int i = 0; i < x.length; i++) {
|
||||
v[i] /= vl;
|
||||
grad[i] /= gradl;
|
||||
x[i] += this.m_SigmaScalar * (this.m_Z[i] + this.Z1 * this.w_v * this.m_main_v[i]);
|
||||
x[i] += this.sigmaScalar * (this.Z[i] + this.Z1 * this.w_v * this.mainV[i]);
|
||||
}
|
||||
if (getCheckConstraints()) { // MK: lets actually do a constraint check
|
||||
Mathematics.projectToRange(x, range);
|
||||
@ -275,11 +271,11 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
|
||||
* @param bit The new representation for the inner constants.
|
||||
*/
|
||||
public void setCheckConstraints(boolean bit) {
|
||||
this.m_CheckConstraints = bit;
|
||||
this.checkConstraints = bit;
|
||||
}
|
||||
|
||||
public boolean getCheckConstraints() {
|
||||
return this.m_CheckConstraints;
|
||||
return this.checkConstraints;
|
||||
}
|
||||
|
||||
public String checkConstraintsTipText() {
|
||||
|
@ -7,42 +7,38 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 10.09.2004
|
||||
* Time: 14:23:37
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MutateESMutativeStepSizeControl implements InterfaceMutation, java.io.Serializable {
|
||||
protected double m_MutationStepSize = 0.2;
|
||||
protected double m_Alpha = 1.2;
|
||||
protected double m_LowerLimitStepSize = 0.0000005;
|
||||
protected double m_UpperLimitStepSize = 0.4;
|
||||
protected double mutationStepSize = 0.2;
|
||||
protected double alpha = 1.2;
|
||||
protected double lowerLimitStepSize = 0.0000005;
|
||||
protected double upperLimitStepSize = 0.4;
|
||||
|
||||
public MutateESMutativeStepSizeControl() {
|
||||
}
|
||||
|
||||
public MutateESMutativeStepSizeControl(double initialStepSize, double lowerLimit, double upperLimit) {
|
||||
m_MutationStepSize = initialStepSize;
|
||||
if (m_LowerLimitStepSize > m_UpperLimitStepSize) {
|
||||
mutationStepSize = initialStepSize;
|
||||
if (lowerLimitStepSize > upperLimitStepSize) {
|
||||
System.err.println("Invalid step size bounds, switching upper and lower...");
|
||||
double tmp = upperLimit;
|
||||
upperLimit = lowerLimit;
|
||||
lowerLimit = tmp;
|
||||
}
|
||||
m_LowerLimitStepSize = lowerLimit;
|
||||
m_UpperLimitStepSize = upperLimit;
|
||||
lowerLimitStepSize = lowerLimit;
|
||||
upperLimitStepSize = upperLimit;
|
||||
if (initialStepSize < lowerLimit || initialStepSize > upperLimit) {
|
||||
m_MutationStepSize = (upperLimit + lowerLimit) / 2.;
|
||||
System.err.println("Invalid initial stepsize, setting it to " + m_MutationStepSize);
|
||||
mutationStepSize = (upperLimit + lowerLimit) / 2.;
|
||||
System.err.println("Invalid initial stepsize, setting it to " + mutationStepSize);
|
||||
}
|
||||
}
|
||||
|
||||
public MutateESMutativeStepSizeControl(MutateESMutativeStepSizeControl mutator) {
|
||||
this.m_MutationStepSize = mutator.m_MutationStepSize;
|
||||
this.m_Alpha = mutator.m_Alpha;
|
||||
this.m_LowerLimitStepSize = mutator.m_LowerLimitStepSize;
|
||||
this.m_UpperLimitStepSize = mutator.m_UpperLimitStepSize;
|
||||
this.mutationStepSize = mutator.mutationStepSize;
|
||||
this.alpha = mutator.alpha;
|
||||
this.lowerLimitStepSize = mutator.lowerLimitStepSize;
|
||||
this.upperLimitStepSize = mutator.upperLimitStepSize;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,16 +61,16 @@ public class MutateESMutativeStepSizeControl implements InterfaceMutation, java.
|
||||
public boolean equals(Object mutator) {
|
||||
if (mutator instanceof MutateESMutativeStepSizeControl) {
|
||||
MutateESMutativeStepSizeControl mut = (MutateESMutativeStepSizeControl) mutator;
|
||||
if (this.m_MutationStepSize != mut.m_MutationStepSize) {
|
||||
if (this.mutationStepSize != mut.mutationStepSize) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Alpha != mut.m_Alpha) {
|
||||
if (this.alpha != mut.alpha) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_LowerLimitStepSize != mut.m_LowerLimitStepSize) {
|
||||
if (this.lowerLimitStepSize != mut.lowerLimitStepSize) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_UpperLimitStepSize != mut.m_UpperLimitStepSize) {
|
||||
if (this.upperLimitStepSize != mut.upperLimitStepSize) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -107,18 +103,18 @@ public class MutateESMutativeStepSizeControl implements InterfaceMutation, java.
|
||||
double[] x = ((InterfaceESIndividual) individual).getDGenotype();
|
||||
double[][] range = ((InterfaceESIndividual) individual).getDoubleRange();
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
this.m_MutationStepSize *= this.m_Alpha;
|
||||
this.mutationStepSize *= this.alpha;
|
||||
} else {
|
||||
this.m_MutationStepSize /= this.m_Alpha;
|
||||
this.mutationStepSize /= this.alpha;
|
||||
}
|
||||
if (this.m_MutationStepSize < this.m_LowerLimitStepSize) {
|
||||
this.m_MutationStepSize = this.m_LowerLimitStepSize;
|
||||
if (this.mutationStepSize < this.lowerLimitStepSize) {
|
||||
this.mutationStepSize = this.lowerLimitStepSize;
|
||||
}
|
||||
if (this.m_MutationStepSize > this.m_UpperLimitStepSize) {
|
||||
this.m_MutationStepSize = this.m_UpperLimitStepSize;
|
||||
if (this.mutationStepSize > this.upperLimitStepSize) {
|
||||
this.mutationStepSize = this.upperLimitStepSize;
|
||||
}
|
||||
for (int i = 0; i < x.length; i++) {
|
||||
x[i] += ((range[i][1] - range[i][0]) / 2) * RNG.gaussianDouble(this.m_MutationStepSize);
|
||||
x[i] += ((range[i][1] - range[i][0]) / 2) * RNG.gaussianDouble(this.mutationStepSize);
|
||||
if (range[i][0] > x[i]) {
|
||||
x[i] = range[i][0];
|
||||
}
|
||||
@ -184,13 +180,13 @@ public class MutateESMutativeStepSizeControl implements InterfaceMutation, java.
|
||||
*/
|
||||
public void setMutationStepSize(double d) {
|
||||
if (d < 0) {
|
||||
d = this.m_LowerLimitStepSize;
|
||||
d = this.lowerLimitStepSize;
|
||||
}
|
||||
this.m_MutationStepSize = d;
|
||||
this.mutationStepSize = d;
|
||||
}
|
||||
|
||||
public double getMutationStepSize() {
|
||||
return this.m_MutationStepSize;
|
||||
return this.mutationStepSize;
|
||||
}
|
||||
|
||||
public String mutationStepSizeTipText() {
|
||||
@ -203,11 +199,11 @@ public class MutateESMutativeStepSizeControl implements InterfaceMutation, java.
|
||||
* @param d The mutation operator.
|
||||
*/
|
||||
public void setLowerLimitStepSize(double d) {
|
||||
this.m_LowerLimitStepSize = d;
|
||||
this.lowerLimitStepSize = d;
|
||||
}
|
||||
|
||||
public double getLowerLimitStepSize() {
|
||||
return this.m_LowerLimitStepSize;
|
||||
return this.lowerLimitStepSize;
|
||||
}
|
||||
|
||||
public String lowerLimitStepSizeTipText() {
|
||||
@ -220,11 +216,11 @@ public class MutateESMutativeStepSizeControl implements InterfaceMutation, java.
|
||||
* @param d The mutation operator.
|
||||
*/
|
||||
public void setUpperLimitStepSize(double d) {
|
||||
this.m_UpperLimitStepSize = d;
|
||||
this.upperLimitStepSize = d;
|
||||
}
|
||||
|
||||
public double getUpperLimitStepSize() {
|
||||
return this.m_UpperLimitStepSize;
|
||||
return this.upperLimitStepSize;
|
||||
}
|
||||
|
||||
public String upperLimitStepSizeTipText() {
|
||||
@ -240,11 +236,11 @@ public class MutateESMutativeStepSizeControl implements InterfaceMutation, java.
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
this.m_Alpha = d;
|
||||
this.alpha = d;
|
||||
}
|
||||
|
||||
public double getAlpha() {
|
||||
return this.m_Alpha;
|
||||
return this.alpha;
|
||||
}
|
||||
|
||||
public String alphaTipText() {
|
||||
|
@ -15,33 +15,33 @@ import eva2.tools.math.RNG;
|
||||
*/
|
||||
public class MutateESPathLengthAdaption implements InterfaceMutation, java.io.Serializable {
|
||||
|
||||
private int m_dim;
|
||||
private double[] m_randZ;
|
||||
private double[] m_Path;
|
||||
private double m_SigmaGlobal = 1.0;
|
||||
private double m_c;
|
||||
private boolean m_UsePath = true;
|
||||
private int dim;
|
||||
private double[] randZ;
|
||||
private double[] path;
|
||||
private double sigmaGlobal = 1.0;
|
||||
private double c;
|
||||
private boolean usePath = true;
|
||||
private double dampening = 1;
|
||||
private double expectedPathLen = -1;
|
||||
private double m_cu;
|
||||
private double cu;
|
||||
|
||||
public MutateESPathLengthAdaption() {
|
||||
|
||||
}
|
||||
|
||||
public MutateESPathLengthAdaption(MutateESPathLengthAdaption mutator) {
|
||||
this.m_UsePath = true;
|
||||
this.m_dim = mutator.m_dim;
|
||||
this.m_SigmaGlobal = mutator.m_SigmaGlobal;
|
||||
this.m_c = mutator.m_c;
|
||||
this.usePath = true;
|
||||
this.dim = mutator.dim;
|
||||
this.sigmaGlobal = mutator.sigmaGlobal;
|
||||
this.c = mutator.c;
|
||||
this.dampening = mutator.dampening;
|
||||
this.expectedPathLen = mutator.expectedPathLen;
|
||||
this.m_cu = mutator.m_cu;
|
||||
if (mutator.m_randZ != null) {
|
||||
this.m_randZ = (double[]) mutator.m_randZ.clone();
|
||||
this.cu = mutator.cu;
|
||||
if (mutator.randZ != null) {
|
||||
this.randZ = (double[]) mutator.randZ.clone();
|
||||
}
|
||||
if (mutator.m_Path != null) {
|
||||
this.m_Path = (double[]) mutator.m_Path.clone();
|
||||
if (mutator.path != null) {
|
||||
this.path = (double[]) mutator.path.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,25 +66,25 @@ public class MutateESPathLengthAdaption implements InterfaceMutation, java.io.Se
|
||||
if (mutator instanceof MutateESPathLengthAdaption) {
|
||||
MutateESPathLengthAdaption mut = (MutateESPathLengthAdaption) mutator;
|
||||
// i assume if the C Matrix is equal then the mutation operators are equal
|
||||
if (this.m_dim != mut.m_dim) {
|
||||
if (this.dim != mut.dim) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_SigmaGlobal != mut.m_SigmaGlobal) {
|
||||
if (this.sigmaGlobal != mut.sigmaGlobal) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_c != mut.m_c) {
|
||||
if (this.c != mut.c) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_randZ != null) && (mut.m_randZ != null)) {
|
||||
for (int i = 0; i < this.m_randZ.length; i++) {
|
||||
if (this.m_randZ[i] != mut.m_randZ[i]) {
|
||||
if ((this.randZ != null) && (mut.randZ != null)) {
|
||||
for (int i = 0; i < this.randZ.length; i++) {
|
||||
if (this.randZ[i] != mut.randZ[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((this.m_Path != null) && (mut.m_Path != null)) {
|
||||
for (int i = 0; i < this.m_Path.length; i++) {
|
||||
if (this.m_Path[i] != mut.m_Path[i]) {
|
||||
if ((this.path != null) && (mut.path != null)) {
|
||||
for (int i = 0; i < this.path.length; i++) {
|
||||
if (this.path[i] != mut.path[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -108,25 +108,25 @@ public class MutateESPathLengthAdaption implements InterfaceMutation, java.io.Se
|
||||
}
|
||||
double[] x = ((InterfaceESIndividual) individual).getDGenotype();
|
||||
double[][] ranges = ((InterfaceESIndividual) individual).getDoubleRange();
|
||||
this.m_dim = x.length;
|
||||
// if (this.m_UsePath) this.c = Math.sqrt(1.0 / (double) this.m_dim);
|
||||
this.dim = x.length;
|
||||
// if (this.usePath) this.c = Math.sqrt(1.0 / (double) this.dim);
|
||||
|
||||
this.m_randZ = new double[this.m_dim];
|
||||
this.m_Path = new double[this.m_dim];
|
||||
for (int i = 0; i < this.m_dim; i++) {
|
||||
this.m_randZ[i] = RNG.gaussianDouble(1.0);
|
||||
// this.m_Path[i]=1;
|
||||
this.randZ = new double[this.dim];
|
||||
this.path = new double[this.dim];
|
||||
for (int i = 0; i < this.dim; i++) {
|
||||
this.randZ[i] = RNG.gaussianDouble(1.0);
|
||||
// this.path[i]=1;
|
||||
}
|
||||
|
||||
if (this.m_UsePath) {
|
||||
this.m_c = 4. / (m_dim + 4);
|
||||
if (this.usePath) {
|
||||
this.c = 4. / (dim + 4);
|
||||
} else {
|
||||
this.m_c = 1.0;
|
||||
this.c = 1.0;
|
||||
}
|
||||
|
||||
expectedPathLen = Math.sqrt(m_dim) * (1 - (1. / (4 * m_dim)) + (1. / (21 * m_dim * m_dim)));
|
||||
dampening = (1. / m_c) + 1;
|
||||
m_cu = Math.sqrt(m_c * (2.0 - m_c));
|
||||
expectedPathLen = Math.sqrt(dim) * (1 - (1. / (4 * dim)) + (1. / (21 * dim * dim)));
|
||||
dampening = (1. / c) + 1;
|
||||
cu = Math.sqrt(c * (2.0 - c));
|
||||
|
||||
mutateX(x, ranges, true);
|
||||
}
|
||||
@ -167,8 +167,8 @@ public class MutateESPathLengthAdaption implements InterfaceMutation, java.io.Se
|
||||
}
|
||||
|
||||
private void calculateNewStep() {
|
||||
for (int i = 0; i < m_dim; i++) {
|
||||
m_randZ[i] = RNG.gaussianDouble(1.0);
|
||||
for (int i = 0; i < dim; i++) {
|
||||
randZ[i] = RNG.gaussianDouble(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,22 +185,22 @@ public class MutateESPathLengthAdaption implements InterfaceMutation, java.io.Se
|
||||
}
|
||||
|
||||
private void adaptStrategy() {
|
||||
// remember the path taken. m_randZ is at this time the last step before selection.
|
||||
for (int i = 0; i < m_dim; i++) {
|
||||
m_Path[i] = (1.0 - m_c) * m_Path[i] + m_cu * m_randZ[i];
|
||||
// remember the path taken. randZ is at this time the last step before selection.
|
||||
for (int i = 0; i < dim; i++) {
|
||||
path[i] = (1.0 - c) * path[i] + cu * randZ[i];
|
||||
}
|
||||
double pathLen = Mathematics.norm(m_Path);
|
||||
double pathLen = Mathematics.norm(path);
|
||||
|
||||
// double expectedPathLen = Math.sqrt(((double)m_dim)+0.5);
|
||||
// double kappa_d = ((double)m_dim)/4.0+1.0;
|
||||
// double expectedPathLen = Math.sqrt(((double)dim)+0.5);
|
||||
// double kappa_d = ((double)dim)/4.0+1.0;
|
||||
|
||||
double exp = (pathLen - expectedPathLen) / (dampening * expectedPathLen);
|
||||
m_SigmaGlobal *= Math.exp(exp);
|
||||
sigmaGlobal *= Math.exp(exp);
|
||||
}
|
||||
|
||||
private void mutateX(double[] x, double[][] range, boolean checkRange) {
|
||||
for (int i = 0; i < x.length; i++) {
|
||||
x[i] += m_SigmaGlobal * m_randZ[i];
|
||||
x[i] += sigmaGlobal * randZ[i];
|
||||
}
|
||||
if (checkRange) {
|
||||
checkRange(x, range);
|
||||
@ -243,10 +243,10 @@ public class MutateESPathLengthAdaption implements InterfaceMutation, java.io.Se
|
||||
// * @param bit The new representation for the inner constants.
|
||||
// */
|
||||
// public void setUsePath(boolean bit) {
|
||||
// this.m_UsePath = bit;
|
||||
// this.usePath = bit;
|
||||
// }
|
||||
// public boolean getUsePath() {
|
||||
// return this.m_UsePath;
|
||||
// return this.usePath;
|
||||
// }
|
||||
// public String usePathTipText() {
|
||||
// return "Use path.";
|
||||
@ -258,11 +258,11 @@ public class MutateESPathLengthAdaption implements InterfaceMutation, java.io.Se
|
||||
* @param d The initial sigma value.
|
||||
*/
|
||||
public void setSigmaGlobal(double d) {
|
||||
this.m_SigmaGlobal = d;
|
||||
this.sigmaGlobal = d;
|
||||
}
|
||||
|
||||
public double getSigmaGlobal() {
|
||||
return this.m_SigmaGlobal;
|
||||
return this.sigmaGlobal;
|
||||
}
|
||||
|
||||
public String initSigmaGlobalTipText() {
|
||||
|
@ -7,24 +7,20 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
import eva2.tools.math.RNG;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 08.09.2004
|
||||
* Time: 17:05:23
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MutateESPolynomial implements InterfaceMutation, java.io.Serializable {
|
||||
private double m_Eta = 0.2;
|
||||
private double eta = 0.2;
|
||||
|
||||
public MutateESPolynomial() {
|
||||
}
|
||||
|
||||
public MutateESPolynomial(MutateESPolynomial mutator) {
|
||||
this.m_Eta = mutator.m_Eta;
|
||||
this.eta = mutator.eta;
|
||||
}
|
||||
|
||||
public MutateESPolynomial(double eta) {
|
||||
m_Eta = eta;
|
||||
this.eta = eta;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,7 +43,7 @@ public class MutateESPolynomial implements InterfaceMutation, java.io.Serializab
|
||||
public boolean equals(Object mutator) {
|
||||
if (mutator instanceof MutateESPolynomial) {
|
||||
MutateESPolynomial mut = (MutateESPolynomial) mutator;
|
||||
if (this.m_Eta != mut.m_Eta) {
|
||||
if (this.eta != mut.eta) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -84,9 +80,9 @@ public class MutateESPolynomial implements InterfaceMutation, java.io.Serializab
|
||||
double r = RNG.randomDouble();
|
||||
double delta = 0;
|
||||
if (r < 0.5) {
|
||||
delta = Math.pow((2 * r), (1 / (m_Eta + 1))) - 1;
|
||||
delta = Math.pow((2 * r), (1 / (eta + 1))) - 1;
|
||||
} else {
|
||||
delta = 1 - Math.pow((2 * (1 - r)), (1 / (m_Eta + 1)));
|
||||
delta = 1 - Math.pow((2 * (1 - r)), (1 / (eta + 1)));
|
||||
}
|
||||
|
||||
x[i] += delta;
|
||||
@ -158,11 +154,11 @@ public class MutateESPolynomial implements InterfaceMutation, java.io.Serializab
|
||||
if (a < 0) {
|
||||
a = 0;
|
||||
}
|
||||
this.m_Eta = a;
|
||||
this.eta = a;
|
||||
}
|
||||
|
||||
public double getEta() {
|
||||
return this.m_Eta;
|
||||
return this.eta;
|
||||
}
|
||||
|
||||
public String etaTipText() {
|
||||
|
@ -5,27 +5,18 @@ import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Success rule implementation.
|
||||
* <p/>
|
||||
* User: streiche
|
||||
* Date: 10.05.2005
|
||||
* Time: 14:11:49
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MutateESSuccessRule extends MutateESFixedStepSize implements InterfaceMutation, InterfaceAdaptOperatorGenerational, java.io.Serializable {
|
||||
// it would be quite nice to make this variable static, but in that case
|
||||
// no one could runs n independent ES runs in parallel anymore *sigh*
|
||||
// protected static double mutationStepSize = 0.2;
|
||||
// protected double mutationStepSize = 0.2; // now in base class
|
||||
protected double m_SuccessRate = 0.2;
|
||||
protected double m_Alpha = 1.2;
|
||||
protected double successRate = 0.2;
|
||||
protected double alpha = 1.2;
|
||||
|
||||
public MutateESSuccessRule() {
|
||||
}
|
||||
|
||||
public MutateESSuccessRule(MutateESSuccessRule mutator) {
|
||||
super(mutator);
|
||||
this.m_SuccessRate = mutator.m_SuccessRate;
|
||||
this.m_Alpha = mutator.m_Alpha;
|
||||
this.successRate = mutator.successRate;
|
||||
this.alpha = mutator.alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,13 +39,13 @@ public class MutateESSuccessRule extends MutateESFixedStepSize implements Interf
|
||||
public boolean equals(Object mutator) {
|
||||
if (mutator instanceof MutateESSuccessRule) {
|
||||
MutateESSuccessRule mut = (MutateESSuccessRule) mutator;
|
||||
if (this.m_Sigma != mut.m_Sigma) {
|
||||
if (this.sigma != mut.sigma) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_SuccessRate != mut.m_SuccessRate) {
|
||||
if (this.successRate != mut.successRate) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Alpha != mut.m_Alpha) {
|
||||
if (this.alpha != mut.alpha) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -78,14 +69,14 @@ public class MutateESSuccessRule extends MutateESFixedStepSize implements Interf
|
||||
* This method increases the mutation step size.
|
||||
*/
|
||||
public void increaseMutationStepSize() {
|
||||
this.m_Sigma *= this.m_Alpha;
|
||||
this.sigma *= this.alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method decrease the mutation step size.
|
||||
*/
|
||||
public void decreaseMutationStepSize() {
|
||||
this.m_Sigma /= this.m_Alpha;
|
||||
this.sigma /= this.alpha;
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
@ -127,11 +118,11 @@ public class MutateESSuccessRule extends MutateESFixedStepSize implements Interf
|
||||
if (d > 1) {
|
||||
d = 1;
|
||||
}
|
||||
this.m_SuccessRate = d;
|
||||
this.successRate = d;
|
||||
}
|
||||
|
||||
public double getSuccessRate() {
|
||||
return this.m_SuccessRate;
|
||||
return this.successRate;
|
||||
}
|
||||
|
||||
public String successRateTipText() {
|
||||
@ -147,11 +138,11 @@ public class MutateESSuccessRule extends MutateESFixedStepSize implements Interf
|
||||
if (d < 1) {
|
||||
d = 1;
|
||||
}
|
||||
this.m_Alpha = d;
|
||||
this.alpha = d;
|
||||
}
|
||||
|
||||
public double getAlpha() {
|
||||
return this.m_Alpha;
|
||||
return this.alpha;
|
||||
}
|
||||
|
||||
public String alphaTipText() {
|
||||
|
@ -12,27 +12,21 @@ import java.util.BitSet;
|
||||
/**
|
||||
* The mutation probability is adapted using a parameter tau and stored in the individual.
|
||||
* Better mutation probabilities are selected indirectly as they produce better offspring.
|
||||
* <p/>
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 27.05.2003
|
||||
* Time: 19:52:16
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class MutateGAAdaptive implements InterfaceMutation, java.io.Serializable {
|
||||
|
||||
protected double m_MutationStep = 1;
|
||||
protected double m_Tau1 = 0.15;
|
||||
protected double m_LowerLimitStepSize = 0.0000005;
|
||||
protected double mutationStep = 1;
|
||||
protected double tau1 = 0.15;
|
||||
protected double lowerLimitStepSize = 0.0000005;
|
||||
|
||||
public MutateGAAdaptive() {
|
||||
|
||||
}
|
||||
|
||||
public MutateGAAdaptive(MutateGAAdaptive mutator) {
|
||||
this.m_MutationStep = mutator.m_MutationStep;
|
||||
this.m_Tau1 = mutator.m_Tau1;
|
||||
this.m_LowerLimitStepSize = mutator.m_LowerLimitStepSize;
|
||||
this.mutationStep = mutator.mutationStep;
|
||||
this.tau1 = mutator.tau1;
|
||||
this.lowerLimitStepSize = mutator.lowerLimitStepSize;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,13 +49,13 @@ public class MutateGAAdaptive implements InterfaceMutation, java.io.Serializable
|
||||
public boolean equals(Object mutator) {
|
||||
if (mutator instanceof MutateGAAdaptive) {
|
||||
MutateGAAdaptive mut = (MutateGAAdaptive) mutator;
|
||||
if (this.m_MutationStep != mut.m_MutationStep) {
|
||||
if (this.mutationStep != mut.mutationStep) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Tau1 != mut.m_Tau1) {
|
||||
if (this.tau1 != mut.tau1) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_LowerLimitStepSize != mut.m_LowerLimitStepSize) {
|
||||
if (this.lowerLimitStepSize != mut.lowerLimitStepSize) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -92,12 +86,12 @@ public class MutateGAAdaptive implements InterfaceMutation, java.io.Serializable
|
||||
//System.out.println("Before Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());
|
||||
if (individual instanceof InterfaceGAIndividual) {
|
||||
BitSet tmpBitSet = ((InterfaceGAIndividual) individual).getBGenotype();
|
||||
this.m_MutationStep *= Math.exp(this.m_Tau1 * RNG.gaussianDouble(1));
|
||||
if (this.m_MutationStep < this.m_LowerLimitStepSize) {
|
||||
this.m_MutationStep = this.m_LowerLimitStepSize;
|
||||
this.mutationStep *= Math.exp(this.tau1 * RNG.gaussianDouble(1));
|
||||
if (this.mutationStep < this.lowerLimitStepSize) {
|
||||
this.mutationStep = this.lowerLimitStepSize;
|
||||
}
|
||||
for (int i = 0; i < ((InterfaceGAIndividual) individual).getGenotypeLength(); i++) {
|
||||
if (RNG.flipCoin(this.m_MutationStep / ((InterfaceGAIndividual) individual).getGenotypeLength())) {
|
||||
if (RNG.flipCoin(this.mutationStep / ((InterfaceGAIndividual) individual).getGenotypeLength())) {
|
||||
tmpBitSet.flip(i);
|
||||
}
|
||||
}
|
||||
@ -158,13 +152,13 @@ public class MutateGAAdaptive implements InterfaceMutation, java.io.Serializable
|
||||
*/
|
||||
public void setMutationStep(double d) {
|
||||
if (d < 0) {
|
||||
d = this.m_LowerLimitStepSize;
|
||||
d = this.lowerLimitStepSize;
|
||||
}
|
||||
this.m_MutationStep = d;
|
||||
this.mutationStep = d;
|
||||
}
|
||||
|
||||
public double getMutationStepSize() {
|
||||
return this.m_MutationStep;
|
||||
return this.mutationStep;
|
||||
}
|
||||
|
||||
public String mutationStepSizeTipText() {
|
||||
@ -180,11 +174,11 @@ public class MutateGAAdaptive implements InterfaceMutation, java.io.Serializable
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
this.m_LowerLimitStepSize = d;
|
||||
this.lowerLimitStepSize = d;
|
||||
}
|
||||
|
||||
public double getLowerLimitStepSize() {
|
||||
return this.m_LowerLimitStepSize;
|
||||
return this.lowerLimitStepSize;
|
||||
}
|
||||
|
||||
public String lowerLimitStepSizeTipText() {
|
||||
@ -200,11 +194,11 @@ public class MutateGAAdaptive implements InterfaceMutation, java.io.Serializable
|
||||
if (d < 0) {
|
||||
d = 0;
|
||||
}
|
||||
this.m_Tau1 = d;
|
||||
this.tau1 = d;
|
||||
}
|
||||
|
||||
public double getTau1() {
|
||||
return this.m_Tau1;
|
||||
return this.tau1;
|
||||
}
|
||||
|
||||
public String tau1TipText() {
|
||||
|
@ -13,15 +13,15 @@ import java.util.BitSet;
|
||||
*/
|
||||
public class MutateGAInvertBits implements InterfaceMutation, java.io.Serializable {
|
||||
|
||||
private int m_NumberOfMutations = 1;
|
||||
private int m_MaxInveredBits = 5;
|
||||
private int numberOfMutations = 1;
|
||||
private int maxInveredBits = 5;
|
||||
|
||||
public MutateGAInvertBits() {
|
||||
}
|
||||
|
||||
public MutateGAInvertBits(MutateGAInvertBits mutator) {
|
||||
this.m_NumberOfMutations = mutator.m_NumberOfMutations;
|
||||
this.m_MaxInveredBits = mutator.m_MaxInveredBits;
|
||||
this.numberOfMutations = mutator.numberOfMutations;
|
||||
this.maxInveredBits = mutator.maxInveredBits;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,10 +44,10 @@ public class MutateGAInvertBits implements InterfaceMutation, java.io.Serializab
|
||||
public boolean equals(Object mutator) {
|
||||
if (mutator instanceof MutateGAInvertBits) {
|
||||
MutateGAInvertBits mut = (MutateGAInvertBits) mutator;
|
||||
if (this.m_NumberOfMutations != mut.m_NumberOfMutations) {
|
||||
if (this.numberOfMutations != mut.numberOfMutations) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_MaxInveredBits != mut.m_MaxInveredBits) {
|
||||
if (this.maxInveredBits != mut.maxInveredBits) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -76,11 +76,11 @@ public class MutateGAInvertBits implements InterfaceMutation, java.io.Serializab
|
||||
public void mutate(AbstractEAIndividual individual) {
|
||||
if (individual instanceof InterfaceGAIndividual) {
|
||||
BitSet tmpBitSet = ((InterfaceGAIndividual) individual).getBGenotype();
|
||||
int[][] mutationIndices = new int[this.m_NumberOfMutations][2];
|
||||
int[][] mutationIndices = new int[this.numberOfMutations][2];
|
||||
for (int i = 0; i < mutationIndices.length; i++) {
|
||||
mutationIndices[i][0] = RNG.randomInt(0, ((InterfaceGAIndividual) individual).getGenotypeLength());
|
||||
;
|
||||
mutationIndices[i][1] = RNG.randomInt(0, this.m_MaxInveredBits);
|
||||
mutationIndices[i][1] = RNG.randomInt(0, this.maxInveredBits);
|
||||
;
|
||||
}
|
||||
// ToDo: double instances of mutationIndices could be checked here... *sigh*
|
||||
@ -150,11 +150,11 @@ public class MutateGAInvertBits implements InterfaceMutation, java.io.Serializab
|
||||
if (mutations < 0) {
|
||||
mutations = 0;
|
||||
}
|
||||
this.m_NumberOfMutations = mutations;
|
||||
this.numberOfMutations = mutations;
|
||||
}
|
||||
|
||||
public int getNumberOfMutations() {
|
||||
return this.m_NumberOfMutations;
|
||||
return this.numberOfMutations;
|
||||
}
|
||||
|
||||
public String numberOfMutationsTipText() {
|
||||
@ -171,11 +171,11 @@ public class MutateGAInvertBits implements InterfaceMutation, java.io.Serializab
|
||||
if (mutations < 0) {
|
||||
mutations = 0;
|
||||
}
|
||||
this.m_MaxInveredBits = mutations;
|
||||
this.maxInveredBits = mutations;
|
||||
}
|
||||
|
||||
public int getMaxInveredBits() {
|
||||
return this.m_MaxInveredBits;
|
||||
return this.maxInveredBits;
|
||||
}
|
||||
|
||||
public String maxInveredBitsTipText() {
|
||||
|
@ -17,16 +17,16 @@ import java.util.BitSet;
|
||||
*/
|
||||
public class MutateGAShiftSubstring implements InterfaceMutation, java.io.Serializable {
|
||||
|
||||
private int m_subStringLength = 0;
|
||||
private int m_shiftDistance = 0;
|
||||
private int subStringLength = 0;
|
||||
private int shiftDistance = 0;
|
||||
|
||||
public MutateGAShiftSubstring() {
|
||||
|
||||
}
|
||||
|
||||
public MutateGAShiftSubstring(MutateGAShiftSubstring mutator) {
|
||||
this.m_subStringLength = mutator.m_subStringLength;
|
||||
this.m_shiftDistance = mutator.m_shiftDistance;
|
||||
this.subStringLength = mutator.subStringLength;
|
||||
this.shiftDistance = mutator.shiftDistance;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,10 +49,10 @@ public class MutateGAShiftSubstring implements InterfaceMutation, java.io.Serial
|
||||
public boolean equals(Object mutator) {
|
||||
if (mutator instanceof MutateGAShiftSubstring) {
|
||||
MutateGAShiftSubstring mut = (MutateGAShiftSubstring) mutator;
|
||||
if (this.m_subStringLength != mut.m_subStringLength) {
|
||||
if (this.subStringLength != mut.subStringLength) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_shiftDistance != mut.m_shiftDistance) {
|
||||
if (this.shiftDistance != mut.shiftDistance) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -106,21 +106,21 @@ public class MutateGAShiftSubstring implements InterfaceMutation, java.io.Serial
|
||||
}
|
||||
|
||||
private int selectShiftDist(int len) {
|
||||
if (m_shiftDistance <= 0) {
|
||||
if (shiftDistance <= 0) {
|
||||
return RNG.randomInt(len);
|
||||
} else {
|
||||
return m_shiftDistance;
|
||||
return shiftDistance;
|
||||
}
|
||||
}
|
||||
|
||||
private int[] selectSubstring(BitSet tmpBitSet, int len) {
|
||||
int[] str = new int[2];
|
||||
if (m_subStringLength <= 0) {
|
||||
if (subStringLength <= 0) {
|
||||
str[0] = RNG.randomInt(len); // TODO check for collision? Not a problem in higher dims...
|
||||
str[1] = RNG.randomInt(len);
|
||||
} else {
|
||||
str[0] = RNG.randomInt(len);
|
||||
str[1] = m_subStringLength + str[0] - 1; // this may be larger than len, but its modulo-ed away in mutate
|
||||
str[1] = subStringLength + str[0] - 1; // this may be larger than len, but its modulo-ed away in mutate
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@ -171,11 +171,11 @@ public class MutateGAShiftSubstring implements InterfaceMutation, java.io.Serial
|
||||
}
|
||||
|
||||
public int getSubStringLength() {
|
||||
return m_subStringLength;
|
||||
return subStringLength;
|
||||
}
|
||||
|
||||
public void setSubStringLength(int stringLength) {
|
||||
m_subStringLength = stringLength;
|
||||
subStringLength = stringLength;
|
||||
}
|
||||
|
||||
public String subStringLengthTipText() {
|
||||
@ -183,11 +183,11 @@ public class MutateGAShiftSubstring implements InterfaceMutation, java.io.Serial
|
||||
}
|
||||
|
||||
public int getShiftDistance() {
|
||||
return m_shiftDistance;
|
||||
return shiftDistance;
|
||||
}
|
||||
|
||||
public void setShiftDistance(int distance) {
|
||||
m_shiftDistance = distance;
|
||||
shiftDistance = distance;
|
||||
}
|
||||
|
||||
public String shiftDistanceTipText() {
|
||||
|
@ -1,11 +1,7 @@
|
||||
package eva2.optimization.operator.mutation;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 20.05.2005
|
||||
* Time: 13:54:25
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class PropertyMutationMixer implements java.io.Serializable {
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito
|
||||
*/
|
||||
private JLabel label = new JLabel("Can't edit", SwingConstants.CENTER);
|
||||
/**
|
||||
* The FilePath that is to be edited
|
||||
* The filePath that is to be edited
|
||||
*/
|
||||
private PropertyMutationMixer mutatorsWithWeights;
|
||||
|
||||
@ -394,7 +394,6 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito
|
||||
* @param a The action listener.
|
||||
*/
|
||||
public void addOkListener(ActionListener a) {
|
||||
//m_OKButton.addActionListener(a);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -403,7 +402,6 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito
|
||||
* @param a The action listener
|
||||
*/
|
||||
public void removeOkListener(ActionListener a) {
|
||||
//m_OKButton.removeActionListener(a);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -514,7 +512,6 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito
|
||||
i = list.length;
|
||||
}
|
||||
}
|
||||
//this.m_OptimizationTargets.setSelectedTargets(list);
|
||||
this.updateCenterComponent(evt); // Let our panel update before guys downstream
|
||||
propertyChangeSupport.firePropertyChange("", mutatorsWithWeights, mutatorsWithWeights);
|
||||
}
|
||||
|
@ -14,33 +14,28 @@ import java.util.ArrayList;
|
||||
* The D1* Pareto front metric requires a refrence Pareto front
|
||||
* and calculate the distance between the true Pareto front and
|
||||
* the current solution.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 09.06.2005
|
||||
* Time: 13:57:28
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MetricD1ApproxParetoFront implements eva2.optimization.operator.paretofrontmetrics.InterfaceParetoFrontMetric, java.io.Serializable {
|
||||
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private String[] m_Titles;
|
||||
private double[][] m_Reference;
|
||||
private PropertyFilePath inputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private String[] titles;
|
||||
private double[][] reference;
|
||||
|
||||
public MetricD1ApproxParetoFront() {
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public MetricD1ApproxParetoFront(MetricD1ApproxParetoFront b) {
|
||||
if (b.m_Titles != null) {
|
||||
this.m_Titles = new String[b.m_Titles.length];
|
||||
for (int i = 0; i < this.m_Titles.length; i++) {
|
||||
this.m_Titles[i] = b.m_Titles[i];
|
||||
if (b.titles != null) {
|
||||
this.titles = new String[b.titles.length];
|
||||
for (int i = 0; i < this.titles.length; i++) {
|
||||
this.titles[i] = b.titles[i];
|
||||
}
|
||||
}
|
||||
if (b.m_Reference != null) {
|
||||
this.m_Reference = new double[b.m_Reference.length][b.m_Reference[0].length];
|
||||
for (int i = 0; i < this.m_Reference.length; i++) {
|
||||
for (int j = 0; j < this.m_Reference[i].length; j++) {
|
||||
this.m_Reference[i][j] = b.m_Reference[i][j];
|
||||
if (b.reference != null) {
|
||||
this.reference = new double[b.reference.length][b.reference[0].length];
|
||||
for (int i = 0; i < this.reference.length; i++) {
|
||||
for (int j = 0; j < this.reference[i].length; j++) {
|
||||
this.reference[i][j] = b.reference[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,16 +62,16 @@ public class MetricD1ApproxParetoFront implements eva2.optimization.operator.par
|
||||
* This method loads the reference data
|
||||
*/
|
||||
private void loadReferenceData() {
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.m_InputFilePath.getCompleteFilePath());
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.inputFilePath.getCompleteFilePath());
|
||||
if (lines == null) {
|
||||
System.out.println("Failed to read " + this.m_InputFilePath.getCompleteFilePath());
|
||||
System.out.println("Failed to read " + this.inputFilePath.getCompleteFilePath());
|
||||
}
|
||||
lines[0].trim();
|
||||
this.m_Titles = lines[0].split("\t");
|
||||
this.titles = lines[0].split("\t");
|
||||
ArrayList tmpA = new ArrayList();
|
||||
double[] tmpD;
|
||||
for (int i = 1; i < lines.length; i++) {
|
||||
tmpD = new double[this.m_Titles.length];
|
||||
tmpD = new double[this.titles.length];
|
||||
lines[i].trim();
|
||||
tmpS = lines[i].split("\t");
|
||||
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
|
||||
@ -84,9 +79,9 @@ public class MetricD1ApproxParetoFront implements eva2.optimization.operator.par
|
||||
}
|
||||
tmpA.add(tmpD);
|
||||
}
|
||||
this.m_Reference = new double[tmpA.size()][];
|
||||
this.reference = new double[tmpA.size()][];
|
||||
for (int i = 0; i < tmpA.size(); i++) {
|
||||
this.m_Reference[i] = (double[]) tmpA.get(i);
|
||||
this.reference[i] = (double[]) tmpA.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,9 +97,9 @@ public class MetricD1ApproxParetoFront implements eva2.optimization.operator.par
|
||||
if (pop.getArchive() != null) {
|
||||
tmpPPO.addPopulation(pop.getArchive());
|
||||
}
|
||||
if (this.m_Reference == null) {
|
||||
if (this.reference == null) {
|
||||
this.loadReferenceData();
|
||||
if (this.m_Reference == null) {
|
||||
if (this.reference == null) {
|
||||
System.out.println("No reference data!");
|
||||
return 0;
|
||||
}
|
||||
@ -115,8 +110,8 @@ public class MetricD1ApproxParetoFront implements eva2.optimization.operator.par
|
||||
result = 0;
|
||||
for (int i = 0; i < tmpPPO.size(); i++) {
|
||||
min = Double.POSITIVE_INFINITY;
|
||||
for (int j = 0; j < this.m_Reference.length; j++) {
|
||||
min = Math.min(min, distance(((AbstractEAIndividual) tmpPPO.get(i)).getFitness(), this.m_Reference[j]));
|
||||
for (int j = 0; j < this.reference.length; j++) {
|
||||
min = Math.min(min, distance(((AbstractEAIndividual) tmpPPO.get(i)).getFitness(), this.reference[j]));
|
||||
}
|
||||
result += min;
|
||||
}
|
||||
@ -164,12 +159,12 @@ public class MetricD1ApproxParetoFront implements eva2.optimization.operator.par
|
||||
* @param b File path.
|
||||
*/
|
||||
public void setInputFilePath(PropertyFilePath b) {
|
||||
this.m_InputFilePath = b;
|
||||
this.inputFilePath = b;
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public PropertyFilePath getInputFilePath() {
|
||||
return this.m_InputFilePath;
|
||||
return this.inputFilePath;
|
||||
}
|
||||
|
||||
public String inputFilePathTipText() {
|
||||
|
@ -14,36 +14,29 @@ import java.util.ArrayList;
|
||||
* The D1 Pareto front metric requires a refrence Pareto front
|
||||
* and calculate the distance between the current solution and
|
||||
* the true Pareto front.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 09.06.2005
|
||||
* Time: 13:57:13
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MetricD1TrueParetoFront implements eva2.optimization.operator.paretofrontmetrics.InterfaceParetoFrontMetric, java.io.Serializable {
|
||||
|
||||
// private String base = System.getProperty("user.dir");
|
||||
// private String FS = System.getProperty("file.separator");
|
||||
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private String[] m_Titles;
|
||||
private double[][] m_Reference;
|
||||
private PropertyFilePath inputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private String[] titles;
|
||||
private double[][] reference;
|
||||
|
||||
public MetricD1TrueParetoFront() {
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public MetricD1TrueParetoFront(MetricD1TrueParetoFront b) {
|
||||
if (b.m_Titles != null) {
|
||||
this.m_Titles = new String[b.m_Titles.length];
|
||||
for (int i = 0; i < this.m_Titles.length; i++) {
|
||||
this.m_Titles[i] = b.m_Titles[i];
|
||||
if (b.titles != null) {
|
||||
this.titles = new String[b.titles.length];
|
||||
for (int i = 0; i < this.titles.length; i++) {
|
||||
this.titles[i] = b.titles[i];
|
||||
}
|
||||
}
|
||||
if (b.m_Reference != null) {
|
||||
this.m_Reference = new double[b.m_Reference.length][b.m_Reference[0].length];
|
||||
for (int i = 0; i < this.m_Reference.length; i++) {
|
||||
for (int j = 0; j < this.m_Reference[i].length; j++) {
|
||||
this.m_Reference[i][j] = b.m_Reference[i][j];
|
||||
if (b.reference != null) {
|
||||
this.reference = new double[b.reference.length][b.reference[0].length];
|
||||
for (int i = 0; i < this.reference.length; i++) {
|
||||
for (int j = 0; j < this.reference[i].length; j++) {
|
||||
this.reference[i][j] = b.reference[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,16 +63,16 @@ public class MetricD1TrueParetoFront implements eva2.optimization.operator.paret
|
||||
* This method loads the reference data
|
||||
*/
|
||||
private void loadReferenceData() {
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.m_InputFilePath.getCompleteFilePath());
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.inputFilePath.getCompleteFilePath());
|
||||
if (lines == null) {
|
||||
System.out.println("Failed to read " + this.m_InputFilePath.getCompleteFilePath());
|
||||
System.out.println("Failed to read " + this.inputFilePath.getCompleteFilePath());
|
||||
}
|
||||
lines[0].trim();
|
||||
this.m_Titles = lines[0].split("\t");
|
||||
this.titles = lines[0].split("\t");
|
||||
ArrayList tmpA = new ArrayList();
|
||||
double[] tmpD;
|
||||
for (int i = 1; i < lines.length; i++) {
|
||||
tmpD = new double[this.m_Titles.length];
|
||||
tmpD = new double[this.titles.length];
|
||||
lines[i].trim();
|
||||
tmpS = lines[i].split("\t");
|
||||
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
|
||||
@ -87,9 +80,9 @@ public class MetricD1TrueParetoFront implements eva2.optimization.operator.paret
|
||||
}
|
||||
tmpA.add(tmpD);
|
||||
}
|
||||
this.m_Reference = new double[tmpA.size()][];
|
||||
this.reference = new double[tmpA.size()][];
|
||||
for (int i = 0; i < tmpA.size(); i++) {
|
||||
this.m_Reference[i] = (double[]) tmpA.get(i);
|
||||
this.reference[i] = (double[]) tmpA.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,9 +98,9 @@ public class MetricD1TrueParetoFront implements eva2.optimization.operator.paret
|
||||
if (pop.getArchive() != null) {
|
||||
tmpPPO.addPopulation(pop.getArchive());
|
||||
}
|
||||
if (this.m_Reference == null) {
|
||||
if (this.reference == null) {
|
||||
this.loadReferenceData();
|
||||
if (this.m_Reference == null) {
|
||||
if (this.reference == null) {
|
||||
System.out.println("No reference data!");
|
||||
return 0;
|
||||
}
|
||||
@ -116,14 +109,14 @@ public class MetricD1TrueParetoFront implements eva2.optimization.operator.paret
|
||||
dom.addElementsToArchive(tmpPPO);
|
||||
tmpPPO = tmpPPO.getArchive();
|
||||
result = 0;
|
||||
for (int j = 0; j < this.m_Reference.length; j++) {
|
||||
for (int j = 0; j < this.reference.length; j++) {
|
||||
min = Double.POSITIVE_INFINITY;
|
||||
for (int i = 0; i < tmpPPO.size(); i++) {
|
||||
min = Math.min(min, distance(((AbstractEAIndividual) tmpPPO.get(i)).getFitness(), this.m_Reference[j]));
|
||||
min = Math.min(min, distance(((AbstractEAIndividual) tmpPPO.get(i)).getFitness(), this.reference[j]));
|
||||
}
|
||||
result += min;
|
||||
}
|
||||
return (result / ((double) this.m_Reference.length));
|
||||
return (result / ((double) this.reference.length));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,12 +160,12 @@ public class MetricD1TrueParetoFront implements eva2.optimization.operator.paret
|
||||
* @param b File path.
|
||||
*/
|
||||
public void setInputFilePath(PropertyFilePath b) {
|
||||
this.m_InputFilePath = b;
|
||||
this.inputFilePath = b;
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public PropertyFilePath getInputFilePath() {
|
||||
return this.m_InputFilePath;
|
||||
return this.inputFilePath;
|
||||
}
|
||||
|
||||
public String inputFilePathTipText() {
|
||||
|
@ -15,35 +15,30 @@ import java.util.ArrayList;
|
||||
* The error ratio metric only suited for small discrete
|
||||
* Pareto fronts, since it calculates the intersection between
|
||||
* the reference and the current solution.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 08.06.2005
|
||||
* Time: 17:22:23
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MetricErrorRatio implements eva2.optimization.operator.paretofrontmetrics.InterfaceParetoFrontMetric, java.io.Serializable {
|
||||
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private double m_Epsilon = 0.0001;
|
||||
private String[] m_Titles;
|
||||
private double[][] m_Reference;
|
||||
private PropertyFilePath inputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private double epsilon = 0.0001;
|
||||
private String[] titles;
|
||||
private double[][] reference;
|
||||
|
||||
public MetricErrorRatio() {
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public MetricErrorRatio(MetricErrorRatio b) {
|
||||
this.m_Epsilon = b.m_Epsilon;
|
||||
if (b.m_Titles != null) {
|
||||
this.m_Titles = new String[b.m_Titles.length];
|
||||
for (int i = 0; i < this.m_Titles.length; i++) {
|
||||
this.m_Titles[i] = b.m_Titles[i];
|
||||
this.epsilon = b.epsilon;
|
||||
if (b.titles != null) {
|
||||
this.titles = new String[b.titles.length];
|
||||
for (int i = 0; i < this.titles.length; i++) {
|
||||
this.titles[i] = b.titles[i];
|
||||
}
|
||||
}
|
||||
if (b.m_Reference != null) {
|
||||
this.m_Reference = new double[b.m_Reference.length][b.m_Reference[0].length];
|
||||
for (int i = 0; i < this.m_Reference.length; i++) {
|
||||
for (int j = 0; j < this.m_Reference[i].length; j++) {
|
||||
this.m_Reference[i][j] = b.m_Reference[i][j];
|
||||
if (b.reference != null) {
|
||||
this.reference = new double[b.reference.length][b.reference[0].length];
|
||||
for (int i = 0; i < this.reference.length; i++) {
|
||||
for (int j = 0; j < this.reference[i].length; j++) {
|
||||
this.reference[i][j] = b.reference[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,16 +65,16 @@ public class MetricErrorRatio implements eva2.optimization.operator.paretofrontm
|
||||
* This method loads the reference data
|
||||
*/
|
||||
private void loadReferenceData() {
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.m_InputFilePath.getCompleteFilePath());
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.inputFilePath.getCompleteFilePath());
|
||||
if (lines == null) {
|
||||
System.out.println("Failed to read " + this.m_InputFilePath.getCompleteFilePath());
|
||||
System.out.println("Failed to read " + this.inputFilePath.getCompleteFilePath());
|
||||
}
|
||||
lines[0].trim();
|
||||
this.m_Titles = lines[0].split("\t");
|
||||
this.titles = lines[0].split("\t");
|
||||
ArrayList tmpA = new ArrayList();
|
||||
double[] tmpD;
|
||||
for (int i = 1; i < lines.length; i++) {
|
||||
tmpD = new double[this.m_Titles.length];
|
||||
tmpD = new double[this.titles.length];
|
||||
lines[i].trim();
|
||||
tmpS = lines[i].split("\t");
|
||||
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
|
||||
@ -87,9 +82,9 @@ public class MetricErrorRatio implements eva2.optimization.operator.paretofrontm
|
||||
}
|
||||
tmpA.add(tmpD);
|
||||
}
|
||||
this.m_Reference = new double[tmpA.size()][];
|
||||
this.reference = new double[tmpA.size()][];
|
||||
for (int i = 0; i < tmpA.size(); i++) {
|
||||
this.m_Reference[i] = (double[]) tmpA.get(i);
|
||||
this.reference[i] = (double[]) tmpA.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,9 +101,9 @@ public class MetricErrorRatio implements eva2.optimization.operator.paretofrontm
|
||||
if (pop.getArchive() != null) {
|
||||
tmpPPO.addPopulation(pop.getArchive());
|
||||
}
|
||||
if (this.m_Reference == null) {
|
||||
if (this.reference == null) {
|
||||
this.loadReferenceData();
|
||||
if (this.m_Reference == null) {
|
||||
if (this.reference == null) {
|
||||
System.out.println("No reference data!");
|
||||
return 0;
|
||||
}
|
||||
@ -132,12 +127,12 @@ public class MetricErrorRatio implements eva2.optimization.operator.paretofrontm
|
||||
private boolean inReference(AbstractEAIndividual indy) {
|
||||
double[] fitness = indy.getFitness();
|
||||
double result = 0;
|
||||
for (int i = 0; i < this.m_Reference.length; i++) {
|
||||
for (int i = 0; i < this.reference.length; i++) {
|
||||
result = 0;
|
||||
for (int j = 0; (j < fitness.length) && (j < this.m_Reference[i].length); j++) {
|
||||
result += Math.pow((fitness[j] - this.m_Reference[i][j]), 2);
|
||||
for (int j = 0; (j < fitness.length) && (j < this.reference[i].length); j++) {
|
||||
result += Math.pow((fitness[j] - this.reference[i][j]), 2);
|
||||
}
|
||||
if (Math.sqrt(result) < this.m_Epsilon) {
|
||||
if (Math.sqrt(result) < this.epsilon) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -172,12 +167,12 @@ public class MetricErrorRatio implements eva2.optimization.operator.paretofrontm
|
||||
* @param b File path.
|
||||
*/
|
||||
public void setInputFilePath(PropertyFilePath b) {
|
||||
this.m_InputFilePath = b;
|
||||
this.inputFilePath = b;
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public PropertyFilePath getInputFilePath() {
|
||||
return this.m_InputFilePath;
|
||||
return this.inputFilePath;
|
||||
}
|
||||
|
||||
public String inputFilePathTipText() {
|
||||
@ -190,11 +185,11 @@ public class MetricErrorRatio implements eva2.optimization.operator.paretofrontm
|
||||
* @param d The upper border.
|
||||
*/
|
||||
public void setEpsilon(double d) {
|
||||
this.m_Epsilon = d;
|
||||
this.epsilon = d;
|
||||
}
|
||||
|
||||
public double getEpsilon() {
|
||||
return this.m_Epsilon;
|
||||
return this.epsilon;
|
||||
}
|
||||
|
||||
public String epsilonTipText() {
|
||||
|
@ -13,33 +13,28 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* Maximum Pareto Front Error gives the maximum distance of all minimum distances of each
|
||||
* element in the current solution to the true Pareto front.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 09.06.2005
|
||||
* Time: 13:25:44
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MetricMaximumParetoFrontError implements eva2.optimization.operator.paretofrontmetrics.InterfaceParetoFrontMetric, java.io.Serializable {
|
||||
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private String[] m_Titles;
|
||||
private double[][] m_Reference;
|
||||
private PropertyFilePath inputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private String[] titles;
|
||||
private double[][] reference;
|
||||
|
||||
public MetricMaximumParetoFrontError() {
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public MetricMaximumParetoFrontError(MetricMaximumParetoFrontError b) {
|
||||
if (b.m_Titles != null) {
|
||||
this.m_Titles = new String[b.m_Titles.length];
|
||||
for (int i = 0; i < this.m_Titles.length; i++) {
|
||||
this.m_Titles[i] = b.m_Titles[i];
|
||||
if (b.titles != null) {
|
||||
this.titles = new String[b.titles.length];
|
||||
for (int i = 0; i < this.titles.length; i++) {
|
||||
this.titles[i] = b.titles[i];
|
||||
}
|
||||
}
|
||||
if (b.m_Reference != null) {
|
||||
this.m_Reference = new double[b.m_Reference.length][b.m_Reference[0].length];
|
||||
for (int i = 0; i < this.m_Reference.length; i++) {
|
||||
for (int j = 0; j < this.m_Reference[i].length; j++) {
|
||||
this.m_Reference[i][j] = b.m_Reference[i][j];
|
||||
if (b.reference != null) {
|
||||
this.reference = new double[b.reference.length][b.reference[0].length];
|
||||
for (int i = 0; i < this.reference.length; i++) {
|
||||
for (int j = 0; j < this.reference[i].length; j++) {
|
||||
this.reference[i][j] = b.reference[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,16 +61,16 @@ public class MetricMaximumParetoFrontError implements eva2.optimization.operator
|
||||
* This method loads the reference data
|
||||
*/
|
||||
private void loadReferenceData() {
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.m_InputFilePath.getCompleteFilePath());
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.inputFilePath.getCompleteFilePath());
|
||||
if (lines == null) {
|
||||
System.out.println("Failed to read " + this.m_InputFilePath.getCompleteFilePath());
|
||||
System.out.println("Failed to read " + this.inputFilePath.getCompleteFilePath());
|
||||
}
|
||||
lines[0].trim();
|
||||
this.m_Titles = lines[0].split("\t");
|
||||
this.titles = lines[0].split("\t");
|
||||
ArrayList tmpA = new ArrayList();
|
||||
double[] tmpD;
|
||||
for (int i = 1; i < lines.length; i++) {
|
||||
tmpD = new double[this.m_Titles.length];
|
||||
tmpD = new double[this.titles.length];
|
||||
lines[i].trim();
|
||||
tmpS = lines[i].split("\t");
|
||||
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
|
||||
@ -83,9 +78,9 @@ public class MetricMaximumParetoFrontError implements eva2.optimization.operator
|
||||
}
|
||||
tmpA.add(tmpD);
|
||||
}
|
||||
this.m_Reference = new double[tmpA.size()][];
|
||||
this.reference = new double[tmpA.size()][];
|
||||
for (int i = 0; i < tmpA.size(); i++) {
|
||||
this.m_Reference[i] = (double[]) tmpA.get(i);
|
||||
this.reference[i] = (double[]) tmpA.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,9 +96,9 @@ public class MetricMaximumParetoFrontError implements eva2.optimization.operator
|
||||
if (pop.getArchive() != null) {
|
||||
tmpPPO.addPopulation(pop.getArchive());
|
||||
}
|
||||
if (this.m_Reference == null) {
|
||||
if (this.reference == null) {
|
||||
this.loadReferenceData();
|
||||
if (this.m_Reference == null) {
|
||||
if (this.reference == null) {
|
||||
System.out.println("No reference data!");
|
||||
return 0;
|
||||
}
|
||||
@ -112,10 +107,10 @@ public class MetricMaximumParetoFrontError implements eva2.optimization.operator
|
||||
dom.addElementsToArchive(tmpPPO);
|
||||
tmpPPO = tmpPPO.getArchive();
|
||||
result = Double.NEGATIVE_INFINITY;
|
||||
for (int j = 0; j < this.m_Reference.length; j++) {
|
||||
for (int j = 0; j < this.reference.length; j++) {
|
||||
min = Double.POSITIVE_INFINITY;
|
||||
for (int i = 0; i < tmpPPO.size(); i++) {
|
||||
min = Math.min(min, distance(((AbstractEAIndividual) tmpPPO.get(i)).getFitness(), this.m_Reference[j]));
|
||||
min = Math.min(min, distance(((AbstractEAIndividual) tmpPPO.get(i)).getFitness(), this.reference[j]));
|
||||
}
|
||||
result = Math.max(result, min);
|
||||
}
|
||||
@ -163,12 +158,12 @@ public class MetricMaximumParetoFrontError implements eva2.optimization.operator
|
||||
* @param b File path.
|
||||
*/
|
||||
public void setInputFilePath(PropertyFilePath b) {
|
||||
this.m_InputFilePath = b;
|
||||
this.inputFilePath = b;
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public PropertyFilePath getInputFilePath() {
|
||||
return this.m_InputFilePath;
|
||||
return this.inputFilePath;
|
||||
}
|
||||
|
||||
public String inputFilePathTipText() {
|
||||
|
@ -8,15 +8,10 @@ import eva2.optimization.problems.AbstractMultiObjectiveOptimizationProblem;
|
||||
/**
|
||||
* Overall Non-Dom. Vector Generation calculates simply the number of
|
||||
* non-dominated solutions in the current soltuion set.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 08.06.2005
|
||||
* Time: 14:27:44
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MetricOverallNonDominatedVectors implements InterfaceParetoFrontMetric, java.io.Serializable {
|
||||
|
||||
private ArchivingAllDominating m_Dom = new ArchivingAllDominating();
|
||||
private ArchivingAllDominating dominating = new ArchivingAllDominating();
|
||||
|
||||
public MetricOverallNonDominatedVectors() {
|
||||
|
||||
@ -55,8 +50,8 @@ public class MetricOverallNonDominatedVectors implements InterfaceParetoFrontMet
|
||||
tmpPPO.addPopulation(pop.getArchive());
|
||||
}
|
||||
for (int i = 0; i < tmpPPO.size(); i++) {
|
||||
if (this.m_Dom.isDominant((AbstractEAIndividual) tmpPPO.get(i), tmpPop)) {
|
||||
this.m_Dom.addIndividualToArchive((AbstractEAIndividual) tmpPPO.get(i), tmpPop);
|
||||
if (this.dominating.isDominant((AbstractEAIndividual) tmpPPO.get(i), tmpPop)) {
|
||||
this.dominating.addIndividualToArchive((AbstractEAIndividual) tmpPPO.get(i), tmpPop);
|
||||
}
|
||||
}
|
||||
return tmpPop.size();
|
||||
|
@ -9,15 +9,10 @@ import eva2.optimization.problems.AbstractMultiObjectiveOptimizationProblem;
|
||||
|
||||
/**
|
||||
* S-Metric calculates the hyper-volume covered between the current solutions and a reference point.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 08.06.2005
|
||||
* Time: 14:28:24
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MetricS implements InterfaceParetoFrontMetric, java.io.Serializable {
|
||||
|
||||
private double[][] m_ObjectiveSpaceRange;
|
||||
private double[][] objectiveSpaceRange;
|
||||
private static boolean TRACE = false;
|
||||
|
||||
public MetricS() {
|
||||
@ -25,11 +20,11 @@ public class MetricS implements InterfaceParetoFrontMetric, java.io.Serializable
|
||||
}
|
||||
|
||||
public MetricS(MetricS b) {
|
||||
if (b.m_ObjectiveSpaceRange != null) {
|
||||
this.m_ObjectiveSpaceRange = new double[b.m_ObjectiveSpaceRange.length][2];
|
||||
for (int i = 0; i < this.m_ObjectiveSpaceRange.length; i++) {
|
||||
this.m_ObjectiveSpaceRange[i][0] = b.m_ObjectiveSpaceRange[i][0];
|
||||
this.m_ObjectiveSpaceRange[i][1] = b.m_ObjectiveSpaceRange[i][1];
|
||||
if (b.objectiveSpaceRange != null) {
|
||||
this.objectiveSpaceRange = new double[b.objectiveSpaceRange.length][2];
|
||||
for (int i = 0; i < this.objectiveSpaceRange.length; i++) {
|
||||
this.objectiveSpaceRange[i][0] = b.objectiveSpaceRange[i][0];
|
||||
this.objectiveSpaceRange[i][1] = b.objectiveSpaceRange[i][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,7 +40,7 @@ public class MetricS implements InterfaceParetoFrontMetric, java.io.Serializable
|
||||
}
|
||||
|
||||
public void setObjectiveSpaceRange(double[][] range) {
|
||||
this.m_ObjectiveSpaceRange = range;
|
||||
this.objectiveSpaceRange = range;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,14 +56,14 @@ public class MetricS implements InterfaceParetoFrontMetric, java.io.Serializable
|
||||
*/
|
||||
@Override
|
||||
public double calculateMetricOn(Population pop, AbstractMultiObjectiveOptimizationProblem problem) {
|
||||
this.m_ObjectiveSpaceRange = problem.getObjectiveSpaceRange();
|
||||
this.objectiveSpaceRange = problem.getObjectiveSpaceRange();
|
||||
if (TRACE) {
|
||||
System.out.println("Border: " + BeanInspector.toString(m_ObjectiveSpaceRange));
|
||||
System.out.println("Border: " + BeanInspector.toString(objectiveSpaceRange));
|
||||
}
|
||||
double smetric = this.calculateSMetric(pop, this.m_ObjectiveSpaceRange, this.m_ObjectiveSpaceRange.length);
|
||||
double smetric = this.calculateSMetric(pop, this.objectiveSpaceRange, this.objectiveSpaceRange.length);
|
||||
double reference = 1;
|
||||
for (int i = 0; i < this.m_ObjectiveSpaceRange.length; i++) {
|
||||
reference *= (this.m_ObjectiveSpaceRange[i][1] - this.m_ObjectiveSpaceRange[i][0]);
|
||||
for (int i = 0; i < this.objectiveSpaceRange.length; i++) {
|
||||
reference *= (this.objectiveSpaceRange[i][1] - this.objectiveSpaceRange[i][0]);
|
||||
}
|
||||
//System.out.println("SMetric: "+smetric +" Reference: " + reference);
|
||||
double res = ((Math.abs(smetric) / Math.abs(reference)) * 100);
|
||||
@ -82,10 +77,10 @@ public class MetricS implements InterfaceParetoFrontMetric, java.io.Serializable
|
||||
// * an achieved Pareto-Front
|
||||
// */
|
||||
// public double calculateMetricOn(Population pop) {
|
||||
// double smetric = this.calculateSMetric(pop, this.m_ObjectiveSpaceRange, this.m_ObjectiveSpaceRange.length);
|
||||
// double smetric = this.calculateSMetric(pop, this.objectiveSpaceRange, this.objectiveSpaceRange.length);
|
||||
// double reference = 1;
|
||||
// for (int i = 0; i < this.m_ObjectiveSpaceRange.length; i++) {
|
||||
// reference *= (this.m_ObjectiveSpaceRange[i][1] - this.m_ObjectiveSpaceRange[i][0]);
|
||||
// for (int i = 0; i < this.objectiveSpaceRange.length; i++) {
|
||||
// reference *= (this.objectiveSpaceRange[i][1] - this.objectiveSpaceRange[i][0]);
|
||||
// }
|
||||
// //System.out.println("SMetric: "+smetric +" Reference: " + reference);
|
||||
// return ((Math.abs(smetric)/Math.abs(reference))*100);
|
||||
|
@ -14,41 +14,36 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* S-Metric calculates the hyper-volume covered between the current solutions and a reference point.
|
||||
* But here the difference to a given hybervolume is to be minimized.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 28.06.2005
|
||||
* Time: 10:58:33
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io.Serializable {
|
||||
private double[][] m_ObjectiveSpaceRange;
|
||||
private PropertyFilePath m_InputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private String[] m_Titles;
|
||||
private double[][] m_Reference;
|
||||
private double m_ReferenceSMetric = -1;
|
||||
private double[][] objectiveSpaceRange;
|
||||
private PropertyFilePath inputFilePath = PropertyFilePath.getFilePathFromResource("MOPReference/T1_250.txt");
|
||||
private String[] titles;
|
||||
private double[][] reference;
|
||||
private double referenceSMetric = -1;
|
||||
|
||||
public MetricSWithReference() {
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public MetricSWithReference(MetricSWithReference b) {
|
||||
if (b.m_ObjectiveSpaceRange != null) {
|
||||
this.m_ObjectiveSpaceRange = new double[b.m_ObjectiveSpaceRange.length][2];
|
||||
for (int i = 0; i < this.m_ObjectiveSpaceRange.length; i++) {
|
||||
this.m_ObjectiveSpaceRange[i][0] = b.m_ObjectiveSpaceRange[i][0];
|
||||
this.m_ObjectiveSpaceRange[i][1] = b.m_ObjectiveSpaceRange[i][1];
|
||||
if (b.objectiveSpaceRange != null) {
|
||||
this.objectiveSpaceRange = new double[b.objectiveSpaceRange.length][2];
|
||||
for (int i = 0; i < this.objectiveSpaceRange.length; i++) {
|
||||
this.objectiveSpaceRange[i][0] = b.objectiveSpaceRange[i][0];
|
||||
this.objectiveSpaceRange[i][1] = b.objectiveSpaceRange[i][1];
|
||||
}
|
||||
}
|
||||
this.m_InputFilePath = b.m_InputFilePath;
|
||||
if (b.m_Titles != null) {
|
||||
this.m_Titles = new String[b.m_Titles.length];
|
||||
System.arraycopy(b.m_Titles, 0, this.m_Titles, 0, this.m_Titles.length);
|
||||
this.inputFilePath = b.inputFilePath;
|
||||
if (b.titles != null) {
|
||||
this.titles = new String[b.titles.length];
|
||||
System.arraycopy(b.titles, 0, this.titles, 0, this.titles.length);
|
||||
}
|
||||
if (b.m_Reference != null) {
|
||||
this.m_Reference = new double[b.m_Reference.length][];
|
||||
for (int i = 0; i < this.m_Reference.length; i++) {
|
||||
this.m_Reference[i] = new double[b.m_Reference[i].length];
|
||||
System.arraycopy(b.m_Reference[i], 0, this.m_Reference[i], 0, this.m_Reference[i].length);
|
||||
if (b.reference != null) {
|
||||
this.reference = new double[b.reference.length][];
|
||||
for (int i = 0; i < this.reference.length; i++) {
|
||||
this.reference[i] = new double[b.reference[i].length];
|
||||
System.arraycopy(b.reference[i], 0, this.reference[i], 0, this.reference[i].length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,23 +66,23 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
|
||||
}
|
||||
|
||||
public void setObjectiveSpaceRange(double[][] range) {
|
||||
this.m_ObjectiveSpaceRange = range;
|
||||
this.objectiveSpaceRange = range;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method loads the reference data
|
||||
*/
|
||||
private void loadReferenceData() {
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.m_InputFilePath.getCompleteFilePath());
|
||||
String[] tmpS, lines = FileTools.loadStringsFromFile(this.inputFilePath.getCompleteFilePath());
|
||||
if (lines == null) {
|
||||
System.out.println("Failed to read " + this.m_InputFilePath.getCompleteFilePath());
|
||||
System.out.println("Failed to read " + this.inputFilePath.getCompleteFilePath());
|
||||
}
|
||||
lines[0].trim();
|
||||
this.m_Titles = lines[0].split("\t");
|
||||
this.titles = lines[0].split("\t");
|
||||
ArrayList tmpA = new ArrayList();
|
||||
double[] tmpD;
|
||||
for (int i = 1; i < lines.length; i++) {
|
||||
tmpD = new double[this.m_Titles.length];
|
||||
tmpD = new double[this.titles.length];
|
||||
lines[i].trim();
|
||||
tmpS = lines[i].split("\t");
|
||||
for (int j = 0; (j < tmpD.length) && (j < tmpS.length); j++) {
|
||||
@ -95,11 +90,11 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
|
||||
}
|
||||
tmpA.add(tmpD);
|
||||
}
|
||||
this.m_Reference = new double[tmpA.size()][];
|
||||
this.reference = new double[tmpA.size()][];
|
||||
for (int i = 0; i < tmpA.size(); i++) {
|
||||
this.m_Reference[i] = (double[]) tmpA.get(i);
|
||||
this.reference[i] = (double[]) tmpA.get(i);
|
||||
}
|
||||
this.m_ReferenceSMetric = -1;
|
||||
this.referenceSMetric = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,21 +103,21 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
|
||||
*/
|
||||
@Override
|
||||
public double calculateMetricOn(Population pop, AbstractMultiObjectiveOptimizationProblem problem) {
|
||||
this.m_ObjectiveSpaceRange = problem.getObjectiveSpaceRange();
|
||||
double smetric = this.calculateSMetric(pop, this.m_ObjectiveSpaceRange, this.m_ObjectiveSpaceRange.length);
|
||||
if (this.m_ReferenceSMetric < 0) {
|
||||
this.objectiveSpaceRange = problem.getObjectiveSpaceRange();
|
||||
double smetric = this.calculateSMetric(pop, this.objectiveSpaceRange, this.objectiveSpaceRange.length);
|
||||
if (this.referenceSMetric < 0) {
|
||||
Population tmpPop = new Population();
|
||||
AbstractEAIndividual tmpIndy;
|
||||
tmpPop.setTargetSize(this.m_Reference.length);
|
||||
tmpPop.setTargetSize(this.reference.length);
|
||||
tmpPop.clear();
|
||||
for (int i = 0; i < this.m_Reference.length; i++) {
|
||||
for (int i = 0; i < this.reference.length; i++) {
|
||||
tmpIndy = new ESIndividualDoubleData();
|
||||
tmpIndy.setFitness(this.m_Reference[i]);
|
||||
tmpIndy.setFitness(this.reference[i]);
|
||||
tmpPop.addIndividual(tmpIndy);
|
||||
}
|
||||
this.m_ReferenceSMetric = this.calculateSMetric(tmpPop, this.m_ObjectiveSpaceRange, this.m_ObjectiveSpaceRange.length);
|
||||
this.referenceSMetric = this.calculateSMetric(tmpPop, this.objectiveSpaceRange, this.objectiveSpaceRange.length);
|
||||
}
|
||||
return (smetric - this.m_ReferenceSMetric);
|
||||
return (smetric - this.referenceSMetric);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,12 +283,12 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
|
||||
* @param b File path.
|
||||
*/
|
||||
public void setInputFilePath(PropertyFilePath b) {
|
||||
this.m_InputFilePath = b;
|
||||
this.inputFilePath = b;
|
||||
this.loadReferenceData();
|
||||
}
|
||||
|
||||
public PropertyFilePath getInputFilePath() {
|
||||
return this.m_InputFilePath;
|
||||
return this.inputFilePath;
|
||||
}
|
||||
|
||||
public String inputFilePathTipText() {
|
||||
|
@ -3,41 +3,37 @@ package eva2.optimization.operator.selection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 24.02.2005
|
||||
* Time: 11:31:58
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*
|
||||
*/
|
||||
public class MOMultipleSolutions {
|
||||
|
||||
public int m_ParetoOptimalSolutions;
|
||||
private ArrayList m_Solutions = new ArrayList();
|
||||
public int m_Iterations;
|
||||
public int m_SizeDominantSolutions = 0;
|
||||
public int paretoOptimalSolutions;
|
||||
private ArrayList solutions = new ArrayList();
|
||||
public int iterations;
|
||||
public int sizeDominantSolutions = 0;
|
||||
|
||||
public void add(double[] fit, double[] w) {
|
||||
this.m_Solutions.add(new MOSolution(fit, w));
|
||||
this.solutions.add(new MOSolution(fit, w));
|
||||
}
|
||||
|
||||
public void add(MOSolution p) {
|
||||
this.m_Solutions.add(p);
|
||||
this.solutions.add(p);
|
||||
}
|
||||
|
||||
public MOSolution get(int i) {
|
||||
return (MOSolution) this.m_Solutions.get(i);
|
||||
return (MOSolution) this.solutions.get(i);
|
||||
}
|
||||
|
||||
public Object remove(int i) {
|
||||
return this.m_Solutions.remove(i);
|
||||
return this.solutions.remove(i);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.m_Solutions.size();
|
||||
return this.solutions.size();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.m_SizeDominantSolutions = 0;
|
||||
this.sizeDominantSolutions = 0;
|
||||
}
|
||||
|
||||
public void testDominance(MOMultipleSolutions malta) {
|
||||
|
@ -4,24 +4,19 @@ import eva2.optimization.individuals.AbstractEAIndividual;
|
||||
import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Simple method to selecet all.
|
||||
* Simple method to select all.
|
||||
* In case of multiple fitness values the selection
|
||||
* criteria is selected randomly for each selection event. pff
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 31.03.2004
|
||||
* Time: 15:08:53
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelectAll implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectAll() {
|
||||
}
|
||||
|
||||
public SelectAll(SelectAll a) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,7 +50,7 @@ public class SelectAll implements InterfaceSelection, java.io.Serializable {
|
||||
public Population selectFrom(Population population, int size) {
|
||||
Population result = new Population();
|
||||
result.setTargetSize(size);
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
if (this.obeyDebsConstViolationPrinciple) {
|
||||
int index = 0;
|
||||
while (result.size() < size) {
|
||||
if (!((AbstractEAIndividual) population.get(index % population.size())).violatesConstraint()) {
|
||||
@ -121,11 +116,11 @@ public class SelectAll implements InterfaceSelection, java.io.Serializable {
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -10,22 +10,17 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* Select the best individuals.
|
||||
* In case of multiple fitness values the selection
|
||||
* critria is selected randomly for each selection event.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 27.05.2003
|
||||
* Time: 19:34:16
|
||||
* To change this template use Options | File Templates.
|
||||
* criteria is selected randomly for each selection event.
|
||||
*/
|
||||
public class SelectBestIndividuals implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectBestIndividuals() {
|
||||
}
|
||||
|
||||
public SelectBestIndividuals(SelectBestIndividuals a) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -95,7 +90,7 @@ public class SelectBestIndividuals implements InterfaceSelection, java.io.Serial
|
||||
boolean member;
|
||||
AbstractEAIndividual indy;
|
||||
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
if (this.obeyDebsConstViolationPrinciple) {
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
indy = (AbstractEAIndividual) pop.get(i);
|
||||
// check if indy is tabu
|
||||
@ -203,11 +198,11 @@ public class SelectBestIndividuals implements InterfaceSelection, java.io.Serial
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -9,15 +9,10 @@ import eva2.tools.math.RNG;
|
||||
* Select best individual multiple times if necessary.
|
||||
* In case of multiple fitness values the selection
|
||||
* critria is selected randomly for each selection event.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 18.03.2003
|
||||
* Time: 16:17:10
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class SelectBestSingle implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
private boolean excludeSelfAsPartner = true; // try to avoid selecting as a mating partner the individual itself
|
||||
|
||||
public SelectBestSingle() {
|
||||
@ -28,7 +23,7 @@ public class SelectBestSingle implements InterfaceSelection, java.io.Serializabl
|
||||
}
|
||||
|
||||
public SelectBestSingle(SelectBestSingle a) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,7 +64,7 @@ public class SelectBestSingle implements InterfaceSelection, java.io.Serializabl
|
||||
} // trivial
|
||||
critSize = ((AbstractEAIndividual) population.get(0)).getFitness().length;
|
||||
result.setTargetSize(size);
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
if (this.obeyDebsConstViolationPrinciple) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
currentCriteria = RNG.randomInt(0, critSize - 1);
|
||||
currentBestValue = Double.POSITIVE_INFINITY;
|
||||
@ -161,11 +156,11 @@ public class SelectBestSingle implements InterfaceSelection, java.io.Serializabl
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -12,25 +12,20 @@ import java.util.ArrayList;
|
||||
* for EP.
|
||||
* In case of multiple fitness values the selection
|
||||
* critria is selected randomly for each selection event.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 01.04.2003
|
||||
* Time: 16:17:26
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class SelectEPTournaments implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private int m_TournamentSize = 4;
|
||||
private int m_Tournaments = 10;
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private int[][] m_Victories;
|
||||
private int tournamentSize = 4;
|
||||
private int tournaments = 10;
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
private int[][] victories;
|
||||
|
||||
public SelectEPTournaments() {
|
||||
}
|
||||
|
||||
public SelectEPTournaments(SelectEPTournaments a) {
|
||||
this.m_TournamentSize = a.m_TournamentSize;
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.tournamentSize = a.tournamentSize;
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,23 +47,23 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ
|
||||
int rand;
|
||||
AbstractEAIndividual tmpIndy;
|
||||
|
||||
this.m_Victories = new int[population.size()][population.getBestEAIndividual().getFitness().length];
|
||||
for (int i = 0; i < this.m_Victories.length; i++) {
|
||||
for (int j = 0; j < this.m_Victories[i].length; j++) {
|
||||
this.m_Victories[i][j] = 0;
|
||||
this.victories = new int[population.size()][population.getBestEAIndividual().getFitness().length];
|
||||
for (int i = 0; i < this.victories.length; i++) {
|
||||
for (int j = 0; j < this.victories[i].length; j++) {
|
||||
this.victories[i][j] = 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
for (int j = 0; j < this.m_Tournaments; j++) {
|
||||
for (int j = 0; j < this.tournaments; j++) {
|
||||
for (int k = 0; k < best.length; k++) {
|
||||
best[k] = i;
|
||||
}
|
||||
// perform tournament
|
||||
for (int k = 0; k < this.m_TournamentSize; k++) {
|
||||
for (int k = 0; k < this.tournamentSize; k++) {
|
||||
rand = RNG.randomInt(0, population.size() - 1);
|
||||
tmpIndy = ((AbstractEAIndividual) population.get(rand));
|
||||
for (int l = 0; l < best.length; l++) {
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
if (this.obeyDebsConstViolationPrinciple) {
|
||||
if ((!tmpIndy.violatesConstraint()) && (tmpIndy.getFitness(l) < ((AbstractEAIndividual) population.get(best[l])).getFitness(l))) {
|
||||
best[l] = rand;
|
||||
}
|
||||
@ -81,7 +76,7 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ
|
||||
}
|
||||
// assign victories
|
||||
for (int k = 0; k < best.length; k++) {
|
||||
this.m_Victories[best[k]][k]++;
|
||||
this.victories[best[k]][k]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,9 +142,9 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((!member) && (this.m_Victories[i][crit] > mostVictories)) {
|
||||
if ((!member) && (this.victories[i][crit] > mostVictories)) {
|
||||
index = i;
|
||||
mostVictories = this.m_Victories[i][crit];
|
||||
mostVictories = this.victories[i][crit];
|
||||
}
|
||||
}
|
||||
if (index >= 0) {
|
||||
@ -204,11 +199,11 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ
|
||||
}
|
||||
|
||||
public int getTournamentSize() {
|
||||
return m_TournamentSize;
|
||||
return tournamentSize;
|
||||
}
|
||||
|
||||
public void setTournamentSize(int g) {
|
||||
m_TournamentSize = g;
|
||||
tournamentSize = g;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,11 +214,11 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ
|
||||
}
|
||||
|
||||
public int getTournaments() {
|
||||
return m_Tournaments;
|
||||
return tournaments;
|
||||
}
|
||||
|
||||
public void setTournaments(int g) {
|
||||
m_Tournaments = g;
|
||||
tournaments = g;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -234,11 +229,11 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -8,23 +8,18 @@ import eva2.optimization.population.Population;
|
||||
/**
|
||||
* An experimental implementation for mating restriction.
|
||||
* Possibly defunct.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 06.08.2003
|
||||
* Time: 19:05:24
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class SelectHomologousMate extends SelectTournament implements java.io.Serializable {
|
||||
|
||||
private double m_MatingRadius = 0.1;
|
||||
private InterfaceDistanceMetric m_Metric = new ObjectiveSpaceMetric();
|
||||
private double matingRadius = 0.1;
|
||||
private InterfaceDistanceMetric metric = new ObjectiveSpaceMetric();
|
||||
|
||||
public SelectHomologousMate() {
|
||||
}
|
||||
|
||||
public SelectHomologousMate(SelectHomologousMate a) {
|
||||
this.m_MatingRadius = a.m_MatingRadius;
|
||||
this.m_Metric = (InterfaceDistanceMetric) a.m_Metric.clone();
|
||||
this.matingRadius = a.matingRadius;
|
||||
this.metric = (InterfaceDistanceMetric) a.metric.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,7 +55,7 @@ public class SelectHomologousMate extends SelectTournament implements java.io.Se
|
||||
// first select all possible partners for daddy
|
||||
// to be honest daddy himself is not omitted....
|
||||
for (int i = 0; i < availablePartners.size(); i++) {
|
||||
if (this.m_Metric.distance(dad, (AbstractEAIndividual) availablePartners.get(i)) < this.m_MatingRadius) {
|
||||
if (this.metric.distance(dad, (AbstractEAIndividual) availablePartners.get(i)) < this.matingRadius) {
|
||||
possibleMates.add(availablePartners.get(i));
|
||||
}
|
||||
}
|
||||
@ -102,11 +97,11 @@ public class SelectHomologousMate extends SelectTournament implements java.io.Se
|
||||
* @return The current optimizing method
|
||||
*/
|
||||
public double getMatingRadius() {
|
||||
return this.m_MatingRadius;
|
||||
return this.matingRadius;
|
||||
}
|
||||
|
||||
public void setMatingRadius(double b) {
|
||||
this.m_MatingRadius = b;
|
||||
this.matingRadius = b;
|
||||
}
|
||||
|
||||
public String matingRadiusTipText() {
|
||||
@ -119,11 +114,11 @@ public class SelectHomologousMate extends SelectTournament implements java.io.Se
|
||||
* @param Metric
|
||||
*/
|
||||
public void setMetric(InterfaceDistanceMetric Metric) {
|
||||
this.m_Metric = Metric;
|
||||
this.metric = Metric;
|
||||
}
|
||||
|
||||
public InterfaceDistanceMetric getMetric() {
|
||||
return this.m_Metric;
|
||||
return this.metric;
|
||||
}
|
||||
|
||||
public String metricTipText() {
|
||||
|
@ -7,23 +7,18 @@ import eva2.optimization.population.Population;
|
||||
* Experimental selection mechanism for MOMA II where
|
||||
* a single individual is a whole set of Pareto optimal
|
||||
* solution. Currently defunct.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 24.02.2005
|
||||
* Time: 16:51:52
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelectMOMAIIDominanceCounter implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private InterfaceSelection m_Selection = new SelectBestIndividuals();
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private InterfaceSelection selection = new SelectBestIndividuals();
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectMOMAIIDominanceCounter() {
|
||||
}
|
||||
|
||||
public SelectMOMAIIDominanceCounter(SelectMOMAIIDominanceCounter a) {
|
||||
this.m_Selection = (InterfaceSelection) a.m_Selection.clone();
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.selection = (InterfaceSelection) a.selection.clone();
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,7 +75,7 @@ public class SelectMOMAIIDominanceCounter implements InterfaceSelection, java.io
|
||||
domCount++;
|
||||
}
|
||||
}
|
||||
malta.m_SizeDominantSolutions = domCount;
|
||||
malta.sizeDominantSolutions = domCount;
|
||||
double[] fitness = new double[1];
|
||||
fitness[0] = 1 / ((double) (domCount + 1));
|
||||
tmpIndy1.setFitness(fitness);
|
||||
@ -103,7 +98,7 @@ public class SelectMOMAIIDominanceCounter implements InterfaceSelection, java.io
|
||||
*/
|
||||
@Override
|
||||
public Population selectFrom(Population population, int size) {
|
||||
return this.m_Selection.selectFrom(population, size);
|
||||
return this.selection.selectFrom(population, size);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,11 +142,11 @@ public class SelectMOMAIIDominanceCounter implements InterfaceSelection, java.io
|
||||
* @param pop The selection method used.
|
||||
*/
|
||||
public void setSelectionMethod(InterfaceSelection pop) {
|
||||
this.m_Selection = pop;
|
||||
this.selection = pop;
|
||||
}
|
||||
|
||||
public InterfaceSelection getSelectionMethod() {
|
||||
return this.m_Selection;
|
||||
return this.selection;
|
||||
}
|
||||
|
||||
public String selectionMethodTipText() {
|
||||
@ -166,11 +161,11 @@ public class SelectMOMAIIDominanceCounter implements InterfaceSelection, java.io
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -7,25 +7,20 @@ import eva2.optimization.population.Population;
|
||||
/**
|
||||
* A multi-objective selection criterion based on the maximin
|
||||
* method.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 09.08.2004
|
||||
* Time: 18:24:24
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelectMOMaxiMin implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private MOSOMaxiMin m_MaxiMin = new MOSOMaxiMin();
|
||||
private InterfaceSelection m_Selection = new SelectBestIndividuals();
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private MOSOMaxiMin maxiMin = new MOSOMaxiMin();
|
||||
private InterfaceSelection selection = new SelectBestIndividuals();
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectMOMaxiMin() {
|
||||
}
|
||||
|
||||
public SelectMOMaxiMin(SelectMOMaxiMin a) {
|
||||
this.m_MaxiMin = new MOSOMaxiMin();
|
||||
this.m_Selection = (InterfaceSelection) a.m_Selection.clone();
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.maxiMin = new MOSOMaxiMin();
|
||||
this.selection = (InterfaceSelection) a.selection.clone();
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,10 +56,10 @@ public class SelectMOMaxiMin implements InterfaceSelection, java.io.Serializable
|
||||
double[] tmpD;
|
||||
// Now calculate the MaxiMin Criterium
|
||||
|
||||
this.m_MaxiMin.convertMultiObjective2SingleObjective(tmpPop);
|
||||
this.m_Selection.setObeyDebsConstViolationPrinciple(this.m_ObeyDebsConstViolationPrinciple);
|
||||
this.m_Selection.prepareSelection(tmpPop);
|
||||
result = this.m_Selection.selectFrom(tmpPop, size);
|
||||
this.maxiMin.convertMultiObjective2SingleObjective(tmpPop);
|
||||
this.selection.setObeyDebsConstViolationPrinciple(this.obeyDebsConstViolationPrinciple);
|
||||
this.selection.prepareSelection(tmpPop);
|
||||
result = this.selection.selectFrom(tmpPop, size);
|
||||
|
||||
// now unconvert from SO to MO
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
@ -115,11 +110,11 @@ public class SelectMOMaxiMin implements InterfaceSelection, java.io.Serializable
|
||||
* @param pop The selection method used.
|
||||
*/
|
||||
public void setSelectionMethod(InterfaceSelection pop) {
|
||||
this.m_Selection = pop;
|
||||
this.selection = pop;
|
||||
}
|
||||
|
||||
public InterfaceSelection getSelectionMethod() {
|
||||
return this.m_Selection;
|
||||
return this.selection;
|
||||
}
|
||||
|
||||
public String selectionMethodTipText() {
|
||||
@ -134,11 +129,11 @@ public class SelectMOMaxiMin implements InterfaceSelection, java.io.Serializable
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -8,27 +8,22 @@ import eva2.tools.math.RNG;
|
||||
/**
|
||||
* The infamous NSGA-II selection scheme for multi-objective
|
||||
* optimization based on Pareto ranks and hybergrids.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 04.03.2004
|
||||
* Time: 17:22:40
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelectMONSGAIICrowedTournament implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private int m_TournamentSize = 4;
|
||||
private ArchivingNSGAII m_NSGAII = new ArchivingNSGAII();
|
||||
private Population[] m_Fronts;
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private int tournamentSize = 4;
|
||||
private ArchivingNSGAII NSGAII = new ArchivingNSGAII();
|
||||
private Population[] fronts;
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
|
||||
public SelectMONSGAIICrowedTournament() {
|
||||
}
|
||||
|
||||
public SelectMONSGAIICrowedTournament(SelectMONSGAIICrowedTournament a) {
|
||||
this.m_TournamentSize = a.m_TournamentSize;
|
||||
this.m_NSGAII = new ArchivingNSGAII();
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.tournamentSize = a.tournamentSize;
|
||||
this.NSGAII = new ArchivingNSGAII();
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,8 +41,8 @@ public class SelectMONSGAIICrowedTournament implements InterfaceSelection, java.
|
||||
*/
|
||||
@Override
|
||||
public void prepareSelection(Population population) {
|
||||
this.m_Fronts = this.m_NSGAII.getNonDominatedSortedFronts(population);
|
||||
this.m_NSGAII.calculateCrowdingDistance(this.m_Fronts);
|
||||
this.fronts = this.NSGAII.getNonDominatedSortedFronts(population);
|
||||
this.NSGAII.calculateCrowdingDistance(this.fronts);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +77,7 @@ public class SelectMONSGAIICrowedTournament implements InterfaceSelection, java.
|
||||
double curCrowdingDistance, tmpCrowdingDistance;
|
||||
|
||||
try {
|
||||
for (int i = 0; i < this.m_TournamentSize; i++) {
|
||||
for (int i = 0; i < this.tournamentSize; i++) {
|
||||
tmpIndy = (AbstractEAIndividual) population.get(RNG.randomInt(0, population.size() - 1));
|
||||
tmpL = ((Integer) tmpIndy.getData("ParetoLevel")).intValue();
|
||||
if (tmpL < smallestLevel) {
|
||||
@ -187,11 +182,11 @@ public class SelectMONSGAIICrowedTournament implements InterfaceSelection, java.
|
||||
}
|
||||
|
||||
public int getTournamentSize() {
|
||||
return m_TournamentSize;
|
||||
return tournamentSize;
|
||||
}
|
||||
|
||||
public void setTournamentSize(int g) {
|
||||
m_TournamentSize = g;
|
||||
tournamentSize = g;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,11 +197,11 @@ public class SelectMONSGAIICrowedTournament implements InterfaceSelection, java.
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -8,21 +8,16 @@ import eva2.tools.math.RNG;
|
||||
* This multi-objective selection method preferrs non-dominated
|
||||
* individuals over dominated ones. Actually, this fails in case
|
||||
* all individuals are Pareto optimal.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 28.07.2003
|
||||
* Time: 14:17:53
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class SelectMONonDominated implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectMONonDominated() {
|
||||
}
|
||||
|
||||
public SelectMONonDominated(SelectMONonDominated a) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,7 +52,7 @@ public class SelectMONonDominated implements InterfaceSelection, java.io.Seriali
|
||||
Population result = new Population();
|
||||
int index = RNG.randomInt(0, population.size() - 1);
|
||||
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
if (this.obeyDebsConstViolationPrinciple) {
|
||||
boolean feasible = false;
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
if (((AbstractEAIndividual) population.get(i)).getConstraintViolation() == 0) {
|
||||
@ -120,7 +115,7 @@ public class SelectMONonDominated implements InterfaceSelection, java.io.Seriali
|
||||
* @return True if the individual is dominating
|
||||
*/
|
||||
public boolean isDominant(AbstractEAIndividual indy, Population pop) {
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
if (this.obeyDebsConstViolationPrinciple) {
|
||||
for (int i = 0; i < pop.size(); i++) {
|
||||
if (!(indy.equals(pop.get(i))) && (((AbstractEAIndividual) pop.get(i)).isDominatingDebConstraintsEqual(indy))) {
|
||||
return false;
|
||||
@ -165,11 +160,11 @@ public class SelectMONonDominated implements InterfaceSelection, java.io.Seriali
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -7,26 +7,21 @@ import eva2.tools.math.RNG;
|
||||
|
||||
/**
|
||||
* The multi-objective PESA selection method.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 11.08.2004
|
||||
* Time: 10:56:47
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelectMOPESA implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
ArchivingPESAII m_PESAII = new ArchivingPESAII();
|
||||
int[] m_Squeeze;
|
||||
int m_TournamentSize = 2;
|
||||
boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
ArchivingPESAII PESAII = new ArchivingPESAII();
|
||||
int[] squeeze;
|
||||
int tournamentSize = 2;
|
||||
boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectMOPESA() {
|
||||
}
|
||||
|
||||
public SelectMOPESA(SelectMOPESA a) {
|
||||
this.m_PESAII = new ArchivingPESAII();
|
||||
this.m_TournamentSize = a.m_TournamentSize;
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.PESAII = new ArchivingPESAII();
|
||||
this.tournamentSize = a.tournamentSize;
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,7 +39,7 @@ public class SelectMOPESA implements InterfaceSelection, java.io.Serializable {
|
||||
*/
|
||||
@Override
|
||||
public void prepareSelection(Population population) {
|
||||
this.m_Squeeze = this.m_PESAII.calculateSqueezeFactor(population);
|
||||
this.squeeze = this.PESAII.calculateSqueezeFactor(population);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,9 +72,9 @@ public class SelectMOPESA implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
try {
|
||||
winner = RNG.randomInt(0, population.size() - 1);
|
||||
for (int i = 1; i < this.m_TournamentSize; i++) {
|
||||
for (int i = 1; i < this.tournamentSize; i++) {
|
||||
tmp = RNG.randomInt(0, population.size() - 1);
|
||||
if (this.m_Squeeze[tmp] < this.m_Squeeze[winner]) {
|
||||
if (this.squeeze[tmp] < this.squeeze[winner]) {
|
||||
winner = tmp;
|
||||
}
|
||||
}
|
||||
@ -133,11 +128,11 @@ public class SelectMOPESA implements InterfaceSelection, java.io.Serializable {
|
||||
}
|
||||
|
||||
public int getTournamentSize() {
|
||||
return m_TournamentSize;
|
||||
return tournamentSize;
|
||||
}
|
||||
|
||||
public void setTournamentSize(int g) {
|
||||
m_TournamentSize = g;
|
||||
tournamentSize = g;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,11 +143,11 @@ public class SelectMOPESA implements InterfaceSelection, java.io.Serializable {
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -13,27 +13,22 @@ import java.util.Hashtable;
|
||||
/**
|
||||
* The multi-objective PESA II selection criteria based on an n-dimensional
|
||||
* grid using a squeezing factor.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 11.08.2004
|
||||
* Time: 10:55:24
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelectMOPESAII implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
ArchivingPESAII m_PESAII = new ArchivingPESAII();
|
||||
int[] m_Squeeze;
|
||||
int m_TournamentSize = 2;
|
||||
ArrayList m_GridBoxes;
|
||||
boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
ArchivingPESAII PESAII = new ArchivingPESAII();
|
||||
int[] squeeze;
|
||||
int tournamentSize = 2;
|
||||
ArrayList gridBoxes;
|
||||
boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectMOPESAII() {
|
||||
}
|
||||
|
||||
public SelectMOPESAII(SelectMOPESAII a) {
|
||||
this.m_PESAII = new ArchivingPESAII();
|
||||
this.m_TournamentSize = a.m_TournamentSize;
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.PESAII = new ArchivingPESAII();
|
||||
this.tournamentSize = a.tournamentSize;
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,7 +46,7 @@ public class SelectMOPESAII implements InterfaceSelection, java.io.Serializable
|
||||
*/
|
||||
@Override
|
||||
public void prepareSelection(Population population) {
|
||||
this.m_Squeeze = this.m_PESAII.calculateSqueezeFactor(population);
|
||||
this.squeeze = this.PESAII.calculateSqueezeFactor(population);
|
||||
Hashtable tmpGridBoxes = new Hashtable();
|
||||
ArrayList tmp;
|
||||
AbstractEAIndividual tmpIndy;
|
||||
@ -75,10 +70,10 @@ public class SelectMOPESAII implements InterfaceSelection, java.io.Serializable
|
||||
tmp.add(tmpIndy);
|
||||
}
|
||||
// now build the arraylist from the Hashtable
|
||||
this.m_GridBoxes = new ArrayList();
|
||||
this.gridBoxes = new ArrayList();
|
||||
Enumeration myEnum = tmpGridBoxes.elements();
|
||||
while (myEnum.hasMoreElements()) {
|
||||
this.m_GridBoxes.add(myEnum.nextElement());
|
||||
this.gridBoxes.add(myEnum.nextElement());
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,8 +107,8 @@ public class SelectMOPESAII implements InterfaceSelection, java.io.Serializable
|
||||
int winner, tmp;
|
||||
|
||||
try {
|
||||
box1 = (ArrayList) this.m_GridBoxes.get(RNG.randomInt(0, this.m_GridBoxes.size() - 1));
|
||||
box2 = (ArrayList) this.m_GridBoxes.get(RNG.randomInt(0, this.m_GridBoxes.size() - 1));
|
||||
box1 = (ArrayList) this.gridBoxes.get(RNG.randomInt(0, this.gridBoxes.size() - 1));
|
||||
box2 = (ArrayList) this.gridBoxes.get(RNG.randomInt(0, this.gridBoxes.size() - 1));
|
||||
if (((Integer) ((AbstractEAIndividual) box1.get(0)).getData("SqueezeFactor")).intValue()
|
||||
< ((Integer) ((AbstractEAIndividual) box2.get(0)).getData("SqueezeFactor")).intValue()) {
|
||||
resultIndy = (AbstractEAIndividual) (box1.get(RNG.randomInt(0, box1.size() - 1)));
|
||||
@ -169,11 +164,11 @@ public class SelectMOPESAII implements InterfaceSelection, java.io.Serializable
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -12,26 +12,21 @@ import eva2.tools.chart2d.DPoint;
|
||||
/**
|
||||
* The SPEA II selection criteria using strength and raw fitness to determine
|
||||
* good individuals.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 31.03.2004
|
||||
* Time: 17:54:54
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelectMOSPEAII implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private InterfaceSelection m_EnvironmentSelection = new SelectTournament();
|
||||
private ArchivingSPEAII m_SPEAII = new ArchivingSPEAII();
|
||||
private double[] m_SPEAFitness;
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private InterfaceSelection environmentSelection = new SelectTournament();
|
||||
private ArchivingSPEAII SPEAII = new ArchivingSPEAII();
|
||||
private double[] SPEAFitness;
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
|
||||
public SelectMOSPEAII() {
|
||||
}
|
||||
|
||||
public SelectMOSPEAII(SelectMOSPEAII a) {
|
||||
this.m_SPEAII = new ArchivingSPEAII();
|
||||
this.m_EnvironmentSelection = (InterfaceSelection) a.m_EnvironmentSelection.clone();
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.SPEAII = new ArchivingSPEAII();
|
||||
this.environmentSelection = (InterfaceSelection) a.environmentSelection.clone();
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,7 +44,7 @@ public class SelectMOSPEAII implements InterfaceSelection, java.io.Serializable
|
||||
*/
|
||||
@Override
|
||||
public void prepareSelection(Population population) {
|
||||
m_SPEAFitness = this.m_SPEAII.calculateSPEA(population);
|
||||
SPEAFitness = this.SPEAII.calculateSPEA(population);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,12 +64,12 @@ public class SelectMOSPEAII implements InterfaceSelection, java.io.Serializable
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
orgFit[i] = ((AbstractEAIndividual) population.get(i)).getFitness();
|
||||
newFit = new double[1];
|
||||
newFit[0] = this.m_SPEAFitness[i];
|
||||
newFit[0] = this.SPEAFitness[i];
|
||||
((AbstractEAIndividual) population.get(i)).setFitness(newFit);
|
||||
}
|
||||
|
||||
// then select
|
||||
Population result = this.m_EnvironmentSelection.selectFrom(population, size);
|
||||
Population result = this.environmentSelection.selectFrom(population, size);
|
||||
|
||||
// finally replace the fitness with the original
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
@ -97,7 +92,7 @@ public class SelectMOSPEAII implements InterfaceSelection, java.io.Serializable
|
||||
mySet.setConnectedMode(false);
|
||||
for (int i = 0; i < orgFit.length; i++) {
|
||||
myPoint = new DPoint(orgFit[i][0], orgFit[i][1]);
|
||||
tmp1 = Math.round(m_SPEAFitness[i] * 100) / (double) 100;
|
||||
tmp1 = Math.round(SPEAFitness[i] * 100) / (double) 100;
|
||||
tmp = new Chart2DDPointIconText("" + tmp1);
|
||||
tmp.setIcon(new Chart2DDPointIconCircle());
|
||||
myPoint.setIcon(tmp);
|
||||
@ -155,11 +150,11 @@ public class SelectMOSPEAII implements InterfaceSelection, java.io.Serializable
|
||||
* @param selection
|
||||
*/
|
||||
public void setEnvironmentSelection(InterfaceSelection selection) {
|
||||
this.m_EnvironmentSelection = selection;
|
||||
this.environmentSelection = selection;
|
||||
}
|
||||
|
||||
public InterfaceSelection getEnvironmentSelection() {
|
||||
return this.m_EnvironmentSelection;
|
||||
return this.environmentSelection;
|
||||
}
|
||||
|
||||
public String environmentSelectionTipText() {
|
||||
@ -174,11 +169,11 @@ public class SelectMOSPEAII implements InterfaceSelection, java.io.Serializable
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -12,36 +12,31 @@ import eva2.tools.math.RNG;
|
||||
* This method implements the roulette wheel selection for
|
||||
* a partical filter. In case of multiple fitness values the selection
|
||||
* critria should be selected randomly for each selection event.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 18.03.2003
|
||||
* Time: 16:36:11
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class SelectParticleWheel implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = true;
|
||||
private boolean obeyDebsConstViolationPrinciple = true;
|
||||
/**
|
||||
* Comment for <code>serialVersionUID</code>
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private InterfaceSelectionProbability m_SelProbCalculator = new SelProbStandard();
|
||||
private InterfaceSelectionProbability selProbCalculator = new SelProbStandard();
|
||||
private boolean selectFixedSteps = false;
|
||||
|
||||
public SelectParticleWheel() {
|
||||
}
|
||||
|
||||
public SelectParticleWheel(double scalingProb) {
|
||||
m_SelProbCalculator = new SelProbStandardScaling(scalingProb);
|
||||
selProbCalculator = new SelProbStandardScaling(scalingProb);
|
||||
}
|
||||
|
||||
public SelectParticleWheel(InterfaceSelectionProbability selProb) {
|
||||
m_SelProbCalculator = selProb;
|
||||
selProbCalculator = selProb;
|
||||
}
|
||||
|
||||
public SelectParticleWheel(SelectParticleWheel a) {
|
||||
this.m_SelProbCalculator = (InterfaceSelectionProbability) a.m_SelProbCalculator.clone();
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.selProbCalculator = (InterfaceSelectionProbability) a.selProbCalculator.clone();
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,7 +46,7 @@ public class SelectParticleWheel implements InterfaceSelection, java.io.Serializ
|
||||
|
||||
@Override
|
||||
public void prepareSelection(Population population) {
|
||||
m_SelProbCalculator.computeSelectionProbability(population, "Fitness", m_ObeyDebsConstViolationPrinciple);
|
||||
selProbCalculator.computeSelectionProbability(population, "Fitness", obeyDebsConstViolationPrinciple);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,11 +173,11 @@ public class SelectParticleWheel implements InterfaceSelection, java.io.Serializ
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
@ -208,18 +203,18 @@ public class SelectParticleWheel implements InterfaceSelection, java.io.Serializ
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the m_SelProbCalculator
|
||||
* @return the selProbCalculator
|
||||
*/
|
||||
public InterfaceSelectionProbability getSelProbCalculator() {
|
||||
return m_SelProbCalculator;
|
||||
return selProbCalculator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param selProbCalculator the m_SelProbCalculator to set
|
||||
* @param selProbCalculator the selProbCalculator to set
|
||||
*/
|
||||
public void setSelProbCalculator(
|
||||
InterfaceSelectionProbability selProbCalculator) {
|
||||
m_SelProbCalculator = selProbCalculator;
|
||||
this.selProbCalculator = selProbCalculator;
|
||||
}
|
||||
|
||||
public String selProbCalculatorTipText() {
|
||||
|
@ -7,29 +7,23 @@ import eva2.tools.math.RNG;
|
||||
|
||||
/**
|
||||
* Random selection typically used for ES as mating selection.
|
||||
* <p/>
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 18.03.2003
|
||||
* Time: 11:36:00
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class SelectRandom implements InterfaceSelection, java.io.Serializable {
|
||||
|
||||
private boolean m_ObeyDebsConstViolationPrinciple = false;
|
||||
private boolean obeyDebsConstViolationPrinciple = false;
|
||||
private boolean withReplacement = true;
|
||||
|
||||
public SelectRandom() {
|
||||
}
|
||||
|
||||
public SelectRandom(SelectRandom a) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple;
|
||||
this.obeyDebsConstViolationPrinciple = a.obeyDebsConstViolationPrinciple;
|
||||
this.withReplacement = a.withReplacement;
|
||||
}
|
||||
|
||||
public SelectRandom(boolean withRepl) {
|
||||
withReplacement = withRepl;
|
||||
if (m_ObeyDebsConstViolationPrinciple) {
|
||||
if (obeyDebsConstViolationPrinciple) {
|
||||
System.err.println("Error, replacement selection not supported for constrained selection (SelectRandom)");
|
||||
}
|
||||
}
|
||||
@ -64,7 +58,7 @@ public class SelectRandom implements InterfaceSelection, java.io.Serializable {
|
||||
public Population selectFrom(Population population, int size) {
|
||||
Population result = new Population();
|
||||
result.setTargetSize(size);
|
||||
if (this.m_ObeyDebsConstViolationPrinciple) {
|
||||
if (this.obeyDebsConstViolationPrinciple) {
|
||||
int index = 0, rand;
|
||||
while (result.size() < size) {
|
||||
rand = RNG.randomInt(0, population.size() - 1);
|
||||
@ -141,11 +135,11 @@ public class SelectRandom implements InterfaceSelection, java.io.Serializable {
|
||||
*/
|
||||
@Override
|
||||
public void setObeyDebsConstViolationPrinciple(boolean b) {
|
||||
this.m_ObeyDebsConstViolationPrinciple = b;
|
||||
this.obeyDebsConstViolationPrinciple = b;
|
||||
}
|
||||
|
||||
public boolean getObeyDebsConstViolationPrinciple() {
|
||||
return this.m_ObeyDebsConstViolationPrinciple;
|
||||
return this.obeyDebsConstViolationPrinciple;
|
||||
}
|
||||
|
||||
public String obeyDebsConstViolationPrincipleToolTip() {
|
||||
|
@ -205,47 +205,47 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser
|
||||
|
||||
class TreeElement implements java.io.Serializable {
|
||||
public double separator = 0;
|
||||
public int m_Index = -1;
|
||||
public TreeElement m_Left = null, m_Right = null;
|
||||
public int index = -1;
|
||||
public TreeElement leftElement = null, rightElement = null;
|
||||
|
||||
public TreeElement(double[][] d, int list, int low, int high) {
|
||||
//System.out.println("Calling Low/high: "+low+"/"+high);
|
||||
if (low == high) {
|
||||
// end reached
|
||||
//System.out.println("This: "+low);
|
||||
this.m_Index = low;
|
||||
this.index = low;
|
||||
} else {
|
||||
if (low == high - 1) {
|
||||
//System.out.println("This: "+high);
|
||||
this.m_Index = high;
|
||||
this.index = high;
|
||||
} else {
|
||||
int midPoint = (int) ((high + low) / 2);
|
||||
this.separator = d[midPoint - 1][list];
|
||||
//System.out.println("Branching: "+midPoint + " : " + this.separator);
|
||||
this.m_Left = new TreeElement(d, list, low, midPoint);
|
||||
this.m_Right = new TreeElement(d, list, midPoint, high);
|
||||
this.leftElement = new TreeElement(d, list, low, midPoint);
|
||||
this.rightElement = new TreeElement(d, list, midPoint, high);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getIndexFor(double d) {
|
||||
if (this.m_Index >= 0) {
|
||||
return this.m_Index - 1;
|
||||
if (this.index >= 0) {
|
||||
return this.index - 1;
|
||||
} else {
|
||||
if (d < this.separator) {
|
||||
return this.m_Left.getIndexFor(d);
|
||||
return this.leftElement.getIndexFor(d);
|
||||
} else {
|
||||
return this.m_Right.getIndexFor(d);
|
||||
return this.rightElement.getIndexFor(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.m_Index >= 0) {
|
||||
return "Ind:" + this.m_Index;
|
||||
if (this.index >= 0) {
|
||||
return "Ind:" + this.index;
|
||||
} else {
|
||||
return "{" + this.m_Left.toString() + "} X<" + this.separator + " {" + this.m_Right.toString() + "}";
|
||||
return "{" + this.leftElement.toString() + "} X<" + this.separator + " {" + this.rightElement.toString() + "}";
|
||||
}
|
||||
}
|
||||
}
|
@ -7,25 +7,20 @@ import eva2.optimization.population.Population;
|
||||
* Boltzman selection, actually it is no a selection method
|
||||
* but a scaling method, but it is very good, because it is
|
||||
* invariant to any linear transition function.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 30.03.2004
|
||||
* Time: 16:59:49
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializable {
|
||||
|
||||
private double m_Q = 1.0;
|
||||
private double q = 1.0;
|
||||
|
||||
public SelProbBoltzman() {
|
||||
}
|
||||
|
||||
public SelProbBoltzman(double q) {
|
||||
m_Q = q;
|
||||
this.q = q;
|
||||
}
|
||||
|
||||
public SelProbBoltzman(SelProbBoltzman a) {
|
||||
this.m_Q = a.m_Q;
|
||||
this.q = a.q;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,9 +83,9 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
|
||||
sum = 0;
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
if (!((AbstractEAIndividual) population.get(i)).violatesConstraint()) {
|
||||
result[i] = Math.exp((this.m_Q * -data[i][x]) / dev);
|
||||
result[i] = Math.exp((this.q * -data[i][x]) / dev);
|
||||
} else {
|
||||
result[i] = Math.exp((this.m_Q * -worst) / dev);
|
||||
result[i] = Math.exp((this.q * -worst) / dev);
|
||||
}
|
||||
sum += result[i];
|
||||
}
|
||||
@ -145,7 +140,7 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
|
||||
}
|
||||
sum = 0;
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
result[i] = Math.exp((this.m_Q * -((AbstractEAIndividual) population.get(i)).getConstraintViolation()) / dev);
|
||||
result[i] = Math.exp((this.q * -((AbstractEAIndividual) population.get(i)).getConstraintViolation()) / dev);
|
||||
sum += result[i];
|
||||
}
|
||||
|
||||
@ -196,7 +191,7 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
|
||||
}
|
||||
sum = 0;
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
result[i] = Math.exp((this.m_Q * -data[i][x]) / dev);
|
||||
result[i] = Math.exp((this.q * -data[i][x]) / dev);
|
||||
sum += result[i];
|
||||
}
|
||||
|
||||
@ -257,11 +252,11 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
|
||||
* @return The new selection pressure q.
|
||||
*/
|
||||
public double getQ() {
|
||||
return this.m_Q;
|
||||
return this.q;
|
||||
}
|
||||
|
||||
public void setQ(double b) {
|
||||
this.m_Q = Math.abs(b);
|
||||
this.q = Math.abs(b);
|
||||
}
|
||||
|
||||
public String qTipText() {
|
||||
|
@ -7,29 +7,24 @@ import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* Here we have the infamous fitness sharing method.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 15.06.2005
|
||||
* Time: 15:23:05
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelProbFitnessSharing extends AbstractSelProb implements java.io.Serializable {
|
||||
|
||||
private InterfaceSelectionProbability m_BasicNormationMethod = new SelProbStandard();
|
||||
private InterfaceDistanceMetric m_DistanceMetric = new PhenotypeMetric();
|
||||
private double m_SharingDistance = 0.1;
|
||||
private InterfaceSelectionProbability basicNormationMethod = new SelProbStandard();
|
||||
private InterfaceDistanceMetric distanceMetric = new PhenotypeMetric();
|
||||
private double sharingDistance = 0.1;
|
||||
|
||||
public SelProbFitnessSharing() {
|
||||
}
|
||||
|
||||
public SelProbFitnessSharing(SelProbFitnessSharing a) {
|
||||
if (a.m_BasicNormationMethod != null) {
|
||||
this.m_BasicNormationMethod = (InterfaceSelectionProbability) a.m_BasicNormationMethod.clone();
|
||||
if (a.basicNormationMethod != null) {
|
||||
this.basicNormationMethod = (InterfaceSelectionProbability) a.basicNormationMethod.clone();
|
||||
}
|
||||
if (a.m_DistanceMetric != null) {
|
||||
this.m_DistanceMetric = (InterfaceDistanceMetric) a.m_DistanceMetric;
|
||||
if (a.distanceMetric != null) {
|
||||
this.distanceMetric = (InterfaceDistanceMetric) a.distanceMetric;
|
||||
}
|
||||
this.m_SharingDistance = a.m_SharingDistance;
|
||||
this.sharingDistance = a.sharingDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,7 +43,7 @@ public class SelProbFitnessSharing extends AbstractSelProb implements java.io.Se
|
||||
*/
|
||||
@Override
|
||||
public void computeSelectionProbability(Population population, double[][] data, boolean obeyConst) {
|
||||
this.m_BasicNormationMethod.computeSelectionProbability(population, data, obeyConst);
|
||||
this.basicNormationMethod.computeSelectionProbability(population, data, obeyConst);
|
||||
// now perform fitness sharing
|
||||
double[] selProb = new double[population.size()];
|
||||
double distance, sharing, sum = 0;
|
||||
@ -59,9 +54,9 @@ public class SelProbFitnessSharing extends AbstractSelProb implements java.io.Se
|
||||
sharing = 0;
|
||||
for (int j = 0; j < population.size(); j++) {
|
||||
if (i != j) {
|
||||
distance = this.m_DistanceMetric.distance(tmpIndy1, ((AbstractEAIndividual) population.get(i)));
|
||||
if (distance < this.m_SharingDistance) {
|
||||
sharing += (1 - distance / this.m_SharingDistance);
|
||||
distance = this.distanceMetric.distance(tmpIndy1, ((AbstractEAIndividual) population.get(i)));
|
||||
if (distance < this.sharingDistance) {
|
||||
sharing += (1 - distance / this.sharingDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,11 +96,11 @@ public class SelProbFitnessSharing extends AbstractSelProb implements java.io.Se
|
||||
* @return The new selection pressure q.
|
||||
*/
|
||||
public InterfaceSelectionProbability getBasicNormationMethod() {
|
||||
return this.m_BasicNormationMethod;
|
||||
return this.basicNormationMethod;
|
||||
}
|
||||
|
||||
public void setBasicNormationMethod(InterfaceSelectionProbability b) {
|
||||
this.m_BasicNormationMethod = b;
|
||||
this.basicNormationMethod = b;
|
||||
}
|
||||
|
||||
public String basicNormationMethodTipText() {
|
||||
@ -118,11 +113,11 @@ public class SelProbFitnessSharing extends AbstractSelProb implements java.io.Se
|
||||
* @return The new selection pressure q.
|
||||
*/
|
||||
public InterfaceDistanceMetric getDistanceMetric() {
|
||||
return this.m_DistanceMetric;
|
||||
return this.distanceMetric;
|
||||
}
|
||||
|
||||
public void setDistanceMetric(InterfaceDistanceMetric b) {
|
||||
this.m_DistanceMetric = b;
|
||||
this.distanceMetric = b;
|
||||
}
|
||||
|
||||
public String distanceMetricTipText() {
|
||||
@ -135,14 +130,14 @@ public class SelProbFitnessSharing extends AbstractSelProb implements java.io.Se
|
||||
* @return The new selection pressure q.
|
||||
*/
|
||||
public double getSharingDistance() {
|
||||
return this.m_SharingDistance;
|
||||
return this.sharingDistance;
|
||||
}
|
||||
|
||||
public void setSharingDistance(double b) {
|
||||
if (b < 0.000001) {
|
||||
b = 0.000001;
|
||||
}
|
||||
this.m_SharingDistance = b;
|
||||
this.sharingDistance = b;
|
||||
}
|
||||
|
||||
public String sharingDistanceTipText() {
|
||||
|
@ -6,25 +6,20 @@ import eva2.optimization.population.Population;
|
||||
/**
|
||||
* A non-linear ranking, which is difficult to tune to
|
||||
* the given optimization problem i guess.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 11.06.2004
|
||||
* Time: 11:57:55
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.Serializable {
|
||||
|
||||
private double m_C = 0.04;
|
||||
private double c = 0.04;
|
||||
|
||||
public SelProbNonLinearRanking() {
|
||||
}
|
||||
|
||||
public SelProbNonLinearRanking(double theC) {
|
||||
this.m_C = theC;
|
||||
this.c = theC;
|
||||
}
|
||||
|
||||
public SelProbNonLinearRanking(SelProbNonLinearRanking a) {
|
||||
this.m_C = a.m_C;
|
||||
this.c = a.c;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,7 +93,7 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
|
||||
// set the selection propability
|
||||
sum = 0;
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
result[i] = this.m_C * Math.pow(1 - this.m_C, i);
|
||||
result[i] = this.c * Math.pow(1 - this.c, i);
|
||||
sum += result[i];
|
||||
}
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
@ -137,7 +132,7 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
|
||||
// set the selection propability
|
||||
sum = 0;
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
result[i] = this.m_C * Math.pow(1 - this.m_C, i);
|
||||
result[i] = this.c * Math.pow(1 - this.c, i);
|
||||
sum += result[i];
|
||||
}
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
@ -178,7 +173,7 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
|
||||
// set the selection propability
|
||||
sum = 0;
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
result[i] = this.m_C * Math.pow(1 - this.m_C, i);
|
||||
result[i] = this.c * Math.pow(1 - this.c, i);
|
||||
sum += result[i];
|
||||
}
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
@ -220,11 +215,11 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
|
||||
if (x > 1) {
|
||||
x = 1;
|
||||
}
|
||||
this.m_C = x;
|
||||
this.c = x;
|
||||
}
|
||||
|
||||
public double getC() {
|
||||
return m_C;
|
||||
return c;
|
||||
}
|
||||
|
||||
public String cTipText() {
|
||||
|
@ -7,12 +7,6 @@ import eva2.optimization.population.Population;
|
||||
* A simple sum to calculate the selection probability.
|
||||
* <p/>
|
||||
* p(i is selected) = exp(-fitness(i))/sum_j(exp(-fitness(j)))
|
||||
* <p/>
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 30.03.2004
|
||||
* Time: 16:54:48
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelProbStandard extends AbstractSelProb implements java.io.Serializable {
|
||||
|
||||
|
@ -5,25 +5,20 @@ import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* A simple sum with a scaling factor.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 30.03.2004
|
||||
* Time: 16:57:51
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class SelProbStandardScaling extends AbstractSelProb implements java.io.Serializable {
|
||||
|
||||
private double m_Q = 0;
|
||||
private double Q = 0;
|
||||
|
||||
public SelProbStandardScaling() {
|
||||
}
|
||||
|
||||
public SelProbStandardScaling(double q) {
|
||||
m_Q = q;
|
||||
Q = q;
|
||||
}
|
||||
|
||||
public SelProbStandardScaling(SelProbStandardScaling a) {
|
||||
this.m_Q = a.m_Q;
|
||||
this.Q = a.Q;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -89,7 +84,7 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
result[i] = ((result[i] - min) / delta) + this.m_Q;
|
||||
result[i] = ((result[i] - min) / delta) + this.Q;
|
||||
sum += result[i];
|
||||
}
|
||||
|
||||
@ -119,7 +114,7 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
result[i] = ((result[i] - min) / delta) + this.m_Q;
|
||||
result[i] = ((result[i] - min) / delta) + this.Q;
|
||||
sum += result[i];
|
||||
}
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
@ -150,7 +145,7 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
result[i] = ((result[i] - min) / delta) + this.m_Q;
|
||||
result[i] = ((result[i] - min) / delta) + this.Q;
|
||||
sum += result[i];
|
||||
}
|
||||
|
||||
@ -188,11 +183,11 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
|
||||
* @return The new selection pressure q.
|
||||
*/
|
||||
public double getQ() {
|
||||
return this.m_Q;
|
||||
return this.Q;
|
||||
}
|
||||
|
||||
public void setQ(double b) {
|
||||
this.m_Q = Math.abs(b);
|
||||
this.Q = Math.abs(b);
|
||||
}
|
||||
|
||||
public String qTipText() {
|
||||
|
@ -7,17 +7,12 @@ import eva2.optimization.population.Population;
|
||||
|
||||
/**
|
||||
* This crowding method replaces the most similar individual from a random group if better.
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: streiche
|
||||
* Date: 19.07.2005
|
||||
* Time: 15:25:15
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class ReplacementCrowding implements InterfaceReplacement, java.io.Serializable {
|
||||
|
||||
PhenotypeMetric metric = new PhenotypeMetric();
|
||||
SelectRandom random = new SelectRandom();
|
||||
int m_C = 5;
|
||||
int C = 5;
|
||||
|
||||
public ReplacementCrowding() {
|
||||
|
||||
@ -26,7 +21,7 @@ public class ReplacementCrowding implements InterfaceReplacement, java.io.Serial
|
||||
public ReplacementCrowding(ReplacementCrowding b) {
|
||||
this.metric = new PhenotypeMetric();
|
||||
this.random = new SelectRandom();
|
||||
this.m_C = b.m_C;
|
||||
this.C = b.C;
|
||||
}
|
||||
|
||||
public ReplacementCrowding(int C) {
|
||||
@ -54,7 +49,7 @@ public class ReplacementCrowding implements InterfaceReplacement, java.io.Serial
|
||||
int index = 0;
|
||||
|
||||
double distance = Double.POSITIVE_INFINITY, tmpD;
|
||||
Population tmp = random.selectFrom(pop, this.m_C);
|
||||
Population tmp = random.selectFrom(pop, this.C);
|
||||
for (int i = 0; i < tmp.size(); i++) {
|
||||
tmpD = this.metric.distance(indy, (AbstractEAIndividual) tmp.get(i));
|
||||
if (tmpD < distance) {
|
||||
@ -95,11 +90,11 @@ public class ReplacementCrowding implements InterfaceReplacement, java.io.Serial
|
||||
* @param c
|
||||
*/
|
||||
public void setC(int c) {
|
||||
this.m_C = c;
|
||||
this.C = c;
|
||||
}
|
||||
|
||||
public int getC() {
|
||||
return this.m_C;
|
||||
return this.C;
|
||||
}
|
||||
|
||||
public String cTipText() {
|
||||
|
@ -1,17 +1,4 @@
|
||||
package eva2.optimization.operator.terminators;
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
* @version: $Revision: 319 $
|
||||
* $Date: 2007-12-05 11:29:32 +0100 (Wed, 05 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
*/
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
|
||||
import eva2.gui.BeanInspector;
|
||||
import eva2.optimization.population.InterfaceSolutionSet;
|
||||
@ -20,23 +7,19 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/*==========================================================================*
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class FitnessValueTerminator implements InterfaceTerminator,
|
||||
Serializable {
|
||||
protected double[] m_FitnessValue;
|
||||
protected double[] fitnessValue;
|
||||
private String msg = "";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public FitnessValueTerminator() {
|
||||
m_FitnessValue = new double[]{0.1};
|
||||
fitnessValue = new double[]{0.1};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,7 +38,7 @@ public class FitnessValueTerminator implements InterfaceTerminator,
|
||||
*
|
||||
*/
|
||||
public FitnessValueTerminator(double[] v) {
|
||||
m_FitnessValue = (double[]) v.clone();
|
||||
fitnessValue = (double[]) v.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,11 +50,11 @@ public class FitnessValueTerminator implements InterfaceTerminator,
|
||||
public boolean isTerminated(PopulationInterface Pop) {
|
||||
double[] fit = Pop.getBestFitness();
|
||||
for (int i = 0; i < fit.length; i++) {
|
||||
if (m_FitnessValue[i] < fit[i]) {
|
||||
if (fitnessValue[i] < fit[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
msg = "Fitness value reached " + BeanInspector.toString(m_FitnessValue);
|
||||
msg = "Fitness value reached " + BeanInspector.toString(fitnessValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -85,7 +68,7 @@ public class FitnessValueTerminator implements InterfaceTerminator,
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String ret = "FitnessValueTerminator,m_FitnessValue=" + m_FitnessValue;
|
||||
String ret = "FitnessValueTerminator,fitnessValue=" + fitnessValue;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -93,14 +76,14 @@ public class FitnessValueTerminator implements InterfaceTerminator,
|
||||
*
|
||||
*/
|
||||
public void setFitnessValue(double[] x) {
|
||||
m_FitnessValue = x;
|
||||
fitnessValue = x;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public double[] getFitnessValue() {
|
||||
return m_FitnessValue;
|
||||
return fitnessValue;
|
||||
}
|
||||
|
||||
public String fitnessValueTipText() {
|
||||
|
@ -79,31 +79,6 @@ public abstract class PopulationMeasureTerminator implements InterfaceTerminator
|
||||
// this.condImprovementOrChange.setSelectedTag(o.condImprovementOrChange.getSelectedTagID());
|
||||
}
|
||||
|
||||
// public void hideHideable() {
|
||||
// setConvergenceCondition(getConvergenceCondition());
|
||||
// }
|
||||
|
||||
// public PopulationMeasureTerminator() {
|
||||
// pMetric = new PhenotypeMetric();
|
||||
// }
|
||||
//
|
||||
// public PopulationMeasureTerminator(double thresh, int stagnPeriod, boolean bFitCallBased, boolean bAbsolute) {
|
||||
// pMetric = new PhenotypeMetric();
|
||||
// convThresh = thresh;
|
||||
// this.m_stagTime = stagnPeriod;
|
||||
// if (bFitCallBased) stagnationMeasure.setSelectedTag("Fitness calls");
|
||||
// else stagnationMeasure.setSelectedTag("Generations");
|
||||
// if (bAbsolute) convergenceCondition.setSelectedTag("Absolute");
|
||||
// else convergenceCondition.setSelectedTag("Relative");
|
||||
// }
|
||||
//
|
||||
// public PopulationMeasureTerminator(PopulationMeasureTerminator other) {
|
||||
// pMetric = new PhenotypeMetric();
|
||||
// convThresh = other.convThresh;
|
||||
// this.m_stagTime = other.m_stagTime;
|
||||
// stagnationMeasure.setSelectedTag(other.getStagnationMeasure().getSelectedTagID());
|
||||
// convergenceCondition.setSelectedTag(other.getConvergenceCondition().getSelectedTagID());
|
||||
// }
|
||||
|
||||
public static String globalInfo() {
|
||||
return "Stop if a convergence criterion has been met.";
|
||||
@ -290,10 +265,8 @@ public abstract class PopulationMeasureTerminator implements InterfaceTerminator
|
||||
*/
|
||||
private boolean stagnationTimeHasPassed(PopulationInterface pop) {
|
||||
if (stagnationMeasure == StagnationTypeEnum.fitnessCallBased) { // by fitness calls
|
||||
// System.out.println("stagnationTimeHasPassed returns " + ((pop.getFunctionCalls() - popFitCalls) >= m_stagTime) + " after " + (pop.getFunctionCalls() - popFitCalls));
|
||||
return (pop.getFunctionCalls() - oldPopFitCalls) >= stagTime;
|
||||
} else {// by generation
|
||||
// System.out.println("stagnationTimeHasPassed returns " + ((pop.getFunctionCalls() - popGens) >= m_stagTime) + " after " + (pop.getFunctionCalls() - popGens));
|
||||
return (pop.getGeneration() - oldPopGens) >= stagTime;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class OptimizationJobList extends PropertySelectableList<OptimizationJob>
|
||||
newArr = new OptimizationJob[curArr.length + 1];
|
||||
newSelection = new boolean[newArr.length];
|
||||
System.arraycopy(curArr, 0, newArr, 0, curArr.length);
|
||||
System.arraycopy(m_Selection, 0, newSelection, 0, curArr.length);
|
||||
System.arraycopy(selections, 0, newSelection, 0, curArr.length);
|
||||
} else {
|
||||
newArr = new OptimizationJob[1];
|
||||
newSelection = new boolean[1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user