Remove m_ from all operator classes

This commit is contained in:
Fabian Becker 2014-02-05 16:41:39 +01:00
parent 7223d27a08
commit 85fa426e30
37 changed files with 635 additions and 726 deletions

View File

@ -12,20 +12,15 @@ import java.util.ArrayList;
/**
* The DBSCAN method. As far as I recall this is an hierachical
* clustering method like the single-link method.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 24.04.2003
* Time: 15:17:53
* To change this template use Options | File Templates.
*/
public class ClusteringDensityBased implements InterfaceClusteringDistanceParam, InterfaceClusteringMetricBased, java.io.Serializable {
private InterfaceDistanceMetric m_Metric = new PhenotypeMetric();
private double m_ClusterDistance = 0.1;
private int m_MinimumGroupSize = 3;
private boolean[][] ConnectionMatrix;
private boolean[] Clustered;
private boolean m_TestConvergingSpeciesOnBestOnly = true;
private InterfaceDistanceMetric metric = new PhenotypeMetric();
private double clusterDistance = 0.1;
private int minimumGroupSize = 3;
private boolean[][] connectionMatrix;
private boolean[] clustered;
private boolean testConvergingSpeciesOnBestOnly = true;
public ClusteringDensityBased() {
}
@ -36,7 +31,7 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
* @param sigma the minimum cluster distance
*/
public ClusteringDensityBased(double sigma) {
m_ClusterDistance = sigma;
clusterDistance = sigma;
}
/**
@ -45,8 +40,8 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
* @param sigma the minimum cluster distance
*/
public ClusteringDensityBased(double sigma, int minGSize) {
m_ClusterDistance = sigma;
m_MinimumGroupSize = minGSize;
clusterDistance = sigma;
minimumGroupSize = minGSize;
}
/**
@ -55,36 +50,36 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
* @param sigma the minimum cluster distance
*/
public ClusteringDensityBased(double sigma, int minGSize, InterfaceDistanceMetric metric) {
m_ClusterDistance = sigma;
m_MinimumGroupSize = minGSize;
m_Metric = metric;
clusterDistance = sigma;
minimumGroupSize = minGSize;
this.metric = metric;
}
public ClusteringDensityBased(ClusteringDensityBased a) {
if (a.m_Metric != null) {
this.m_Metric = (InterfaceDistanceMetric) a.m_Metric.clone();
if (a.metric != null) {
this.metric = (InterfaceDistanceMetric) a.metric.clone();
}
this.m_TestConvergingSpeciesOnBestOnly = a.m_TestConvergingSpeciesOnBestOnly;
this.m_ClusterDistance = a.m_ClusterDistance;
this.m_MinimumGroupSize = a.m_MinimumGroupSize;
if (a.Clustered != null) {
this.Clustered = new boolean[a.Clustered.length];
for (int i = 0; i < this.Clustered.length; i++) {
if (a.Clustered[i]) {
this.Clustered[i] = true;
this.testConvergingSpeciesOnBestOnly = a.testConvergingSpeciesOnBestOnly;
this.clusterDistance = a.clusterDistance;
this.minimumGroupSize = a.minimumGroupSize;
if (a.clustered != null) {
this.clustered = new boolean[a.clustered.length];
for (int i = 0; i < this.clustered.length; i++) {
if (a.clustered[i]) {
this.clustered[i] = true;
} else {
this.Clustered[i] = false;
this.clustered[i] = false;
}
}
}
if (a.ConnectionMatrix != null) {
this.ConnectionMatrix = new boolean[a.ConnectionMatrix.length][a.ConnectionMatrix[0].length];
for (int i = 0; i < this.ConnectionMatrix.length; i++) {
for (int j = 0; j < this.ConnectionMatrix[i].length; j++) {
if (a.ConnectionMatrix[i][j]) {
this.ConnectionMatrix[i][j] = true;
if (a.connectionMatrix != null) {
this.connectionMatrix = new boolean[a.connectionMatrix.length][a.connectionMatrix[0].length];
for (int i = 0; i < this.connectionMatrix.length; i++) {
for (int j = 0; j < this.connectionMatrix[i].length; j++) {
if (a.connectionMatrix[i][j]) {
this.connectionMatrix[i][j] = true;
} else {
this.ConnectionMatrix[i][j] = false;
this.connectionMatrix[i][j] = false;
}
}
}
@ -104,8 +99,8 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
@Override
public Population[] cluster(Population pop, Population referencePop) {
ConnectionMatrix = new boolean[pop.size()][pop.size()];
Clustered = new boolean[pop.size()];
connectionMatrix = new boolean[pop.size()][pop.size()];
clustered = new boolean[pop.size()];
AbstractEAIndividual tmpIndy1, tmpIndy2;
Population PopulationOfUnclustered, Cluster, template;
ArrayList<Population> ClusteredPopulations = new ArrayList<Population>();
@ -118,32 +113,32 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
// Build the connection Matrix
for (int i = 0; i < pop.size(); i++) {
tmpIndy1 = (AbstractEAIndividual) pop.get(i);
ConnectionMatrix[i][i] = true;
connectionMatrix[i][i] = true;
for (int j = i + 1; j < pop.size(); j++) {
tmpIndy2 = (AbstractEAIndividual) pop.get(j);
if (tmpIndy1 == null || (tmpIndy2 == null)) {
System.err.println("Warning: Individual should not be null (ClusteringDensityBased)!");
}
if ((tmpIndy1 != null) && (tmpIndy2 != null) && (this.m_Metric.distance(tmpIndy1, tmpIndy2) < this.m_ClusterDistance)) {
ConnectionMatrix[i][j] = true;
ConnectionMatrix[j][i] = true;
if ((tmpIndy1 != null) && (tmpIndy2 != null) && (this.metric.distance(tmpIndy1, tmpIndy2) < this.clusterDistance)) {
connectionMatrix[i][j] = true;
connectionMatrix[j][i] = true;
} else {
ConnectionMatrix[i][j] = false;
ConnectionMatrix[j][i] = false;
connectionMatrix[i][j] = false;
connectionMatrix[j][i] = false;
}
}
}
for (int i = 0; i < Clustered.length; i++) {
Clustered[i] = false;
for (int i = 0; i < clustered.length; i++) {
clustered[i] = false;
}
// Now identify clusters within pop and add them to the result
for (int i = 0; i < ConnectionMatrix.length; i++) {
if (!Clustered[i]) {
for (int i = 0; i < connectionMatrix.length; i++) {
if (!clustered[i]) {
Cluster = (Population) template.clone();
this.addRowToPopulation(i, Cluster, pop);
if (Cluster.size() >= this.m_MinimumGroupSize) {
if (Cluster.size() >= this.minimumGroupSize) {
ClusteredPopulations.add(Cluster);
} else {
PopulationOfUnclustered.addPopulation(Cluster);
@ -159,7 +154,7 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
}
/**
* This method adds all Connected and !Clustered Individuals form row index
* This method adds all Connected and !clustered Individuals form row index
* to pop
*
* @param index The index of the row that is to be computed.
@ -167,11 +162,11 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
* @param source The source which is to be clustered.
*/
private void addRowToPopulation(int index, Population cluster, Population source) {
for (int i = 0; i < ConnectionMatrix[index].length; i++) {
if ((!Clustered[i]) && (ConnectionMatrix[index][i])) {
Clustered[i] = true;
ConnectionMatrix[index][i] = false;
ConnectionMatrix[i][index] = false;
for (int i = 0; i < connectionMatrix[index].length; i++) {
if ((!clustered[i]) && (connectionMatrix[index][i])) {
clustered[i] = true;
connectionMatrix[index][i] = false;
connectionMatrix[i][index] = false;
cluster.add(source.get(i));
this.addRowToPopulation(i, cluster, source);
}
@ -187,10 +182,10 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
*/
@Override
public boolean mergingSpecies(Population species1, Population species2, Population referencePop) {
if (m_TestConvergingSpeciesOnBestOnly) {
double specDist = this.m_Metric.distance(species1.getBestEAIndividual(), species2.getBestEAIndividual());
if (testConvergingSpeciesOnBestOnly) {
double specDist = this.metric.distance(species1.getBestEAIndividual(), species2.getBestEAIndividual());
// System.out.println("Dist between species is " + specDist);
return (specDist < this.m_ClusterDistance);
return (specDist < this.clusterDistance);
} else {
Population tmpPop = new Population(species1.size() + species2.size());
tmpPop.addPopulation(species1);
@ -209,8 +204,8 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
// * @return True or False.
// */
// public boolean belongsToSpecies(AbstractEAIndividual indy, Population species, Population pop) {
// if (this.m_TestConvergingSpeciesOnBestOnly) {
// if (this.distanceMetric.distance(indy, species.getBestEAIndividual()) < this.m_ClusterDistance) return true;
// if (this.testConvergingSpeciesOnBestOnly) {
// if (this.distanceMetric.distance(indy, species.getBestEAIndividual()) < this.clusterDistance) return true;
// else return false;
// } else {
// Population tmpPop = (Population)species.clone();
@ -238,8 +233,8 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
double minDist = -1;
res[l] = -1;
for (int spI = 0; spI < species.length; spI++) { // O(species.length^2)
Pair<Integer, Double> iDist = Population.getClosestFarthestIndy(loners.getEAIndividual(l), species[spI], m_Metric, true);
if (iDist.tail() < m_ClusterDistance) { // its close enough to be added
Pair<Integer, Double> iDist = Population.getClosestFarthestIndy(loners.getEAIndividual(l), species[spI], metric, true);
if (iDist.tail() < clusterDistance) { // its close enough to be added
// set SP ID only if its the closest species which is still below cluster distance
if (minDist < 0 || (iDist.tail() < minDist)) {
res[l] = spI;
@ -278,12 +273,12 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
*/
@Override
public InterfaceDistanceMetric getMetric() {
return this.m_Metric;
return this.metric;
}
@Override
public void setMetric(InterfaceDistanceMetric m) {
this.m_Metric = m;
this.metric = m;
}
public String metricTipText() {
@ -296,14 +291,14 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
* @return The currently used minimal group size.
*/
public int getMinimumGroupSize() {
return this.m_MinimumGroupSize;
return this.minimumGroupSize;
}
public void setMinimumGroupSize(int m) {
if (m < 1) {
m = 1;
}
this.m_MinimumGroupSize = m;
this.minimumGroupSize = m;
}
public String minimumGroupSizeTipText() {
@ -317,7 +312,7 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
@Override
public double getClustDistParam() {
return this.m_ClusterDistance;
return this.clusterDistance;
}
@Override
@ -325,7 +320,7 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
if (m < 0) {
m = 0;
}
this.m_ClusterDistance = m;
this.clusterDistance = m;
}
public String clustDistTipText() {
@ -348,7 +343,7 @@ public class ClusteringDensityBased implements InterfaceClusteringDistanceParam,
// plot.plotArea.addDElement(popRep);
// //System.out.println("Adding" + i + " : ("+tmpIndy1.getDoubleData()[0]+"/"+tmpIndy1.getDoubleData()[1]+")");
// for (int j = i; j < pop.size(); j++) {
// if (ConnectionMatrix[i][j]) {
// if (connectionMatrix[i][j]) {
// popRep = new DPointSet();
// popRep.setConnected(true);
// tmpIndy1 = (InterfaceDataTypeDouble)pop.get(i);

View File

@ -18,20 +18,15 @@ import java.util.Arrays;
/**
* The k-mean clustering algorithms. I guess it is not a hierachical
* clustering method.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 27.09.2004
* Time: 13:49:44
* To change this template use File | Settings | File Templates.
*/
public class ClusteringKMeans implements InterfaceClustering, java.io.Serializable {
private int m_K = 5;
private double[][] m_C = null;
private int k = 5;
private double[][] c = null;
private double mergeDist = 0.001;
private boolean m_UseSearchSpace = true;
private boolean m_ReuseC = false;
private boolean m_Debug = false;
private boolean useSearchSpace = true;
private boolean reuseC = false;
private boolean debug = false;
private int minClustSize = 1;
InterfaceDistanceMetric metric = new EuclideanMetric();
AbstractEAIndividual tmpIndy = null;
@ -41,16 +36,16 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
}
public ClusteringKMeans(ClusteringKMeans a) {
this.m_Debug = a.m_Debug;
this.m_K = a.m_K;
this.m_UseSearchSpace = a.m_UseSearchSpace;
this.debug = a.debug;
this.k = a.k;
this.useSearchSpace = a.useSearchSpace;
this.metric = a.metric;
this.minClustSize = a.minClustSize;
this.mergeDist = a.mergeDist;
if (a.m_C != null) {
this.m_C = new double[a.m_C.length][a.m_C[0].length];
for (int i = 0; i < this.m_C.length; i++) {
System.arraycopy(a.m_C[i], 0, this.m_C[i], 0, this.m_C[i].length);
if (a.c != null) {
this.c = new double[a.c.length][a.c[0].length];
for (int i = 0; i < this.c.length; i++) {
System.arraycopy(a.c[i], 0, this.c[i], 0, this.c[i].length);
}
}
}
@ -77,7 +72,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
*/
@Override
public Population[] cluster(Population pop, Population referencePop) {
if (pop.size() < m_K) {
if (pop.size() < k) {
// in this case, there arent enough indies to do anything, so we just return them as "unclustered"
Population[] res = new Population[1];
res[0] = pop.cloneShallowInds();
@ -85,15 +80,15 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
}
tmpIndy = (AbstractEAIndividual) pop.getEAIndividual(0).clone();
// double[][] data = this.extractClusterDataFrom(pop);
if (!(this.m_ReuseC) || (this.m_C == null)) {
this.m_C = new double[this.m_K][];
if (!(this.reuseC) || (this.c == null)) {
this.c = new double[this.k][];
// now choose random initial Cs
Population initialSeeds = pop.getRandNIndividuals(this.m_K);
for (int i = 0; i < this.m_K; i++) {
if (m_UseSearchSpace) {
this.m_C[i] = initialSeeds.getEAIndividual(i).getDoublePosition().clone();
Population initialSeeds = pop.getRandNIndividuals(this.k);
for (int i = 0; i < this.k; i++) {
if (useSearchSpace) {
this.c[i] = initialSeeds.getEAIndividual(i).getDoublePosition().clone();
} else {
this.m_C[i] = initialSeeds.getEAIndividual(i).getFitness().clone();
this.c[i] = initialSeeds.getEAIndividual(i).getFitness().clone();
}
// this.c[i] = data[RNG.randomInt(0, data.length-1)];
@ -115,8 +110,8 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
for (int i = 0; i < pop.size(); i++) {
// check which C is closest
assign = 0;
for (int j = 1; j < this.m_C.length; j++) {
if (this.distance(pop.getEAIndividual(i), this.m_C[assign]) > this.distance(pop.getEAIndividual(i), this.m_C[j])) {
for (int j = 1; j < this.c.length; j++) {
if (this.distance(pop.getEAIndividual(i), this.c[assign]) > this.distance(pop.getEAIndividual(i), this.c[j])) {
assign = j;
}
}
@ -124,18 +119,18 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
}
// now calcuate the mean of each cluster and calculate new C
newC = new double[this.m_K][m_C[0].length];
numbOfAssigned = new int[this.m_K];
newC = new double[this.k][c[0].length];
numbOfAssigned = new int[this.k];
for (int i = 0; i < newC.length; i++) {
numbOfAssigned[i] = 1;
for (int j = 0; j < newC[i].length; j++) {
newC[i][j] = this.m_C[i][j];
newC[i][j] = this.c[i][j];
}
}
for (int i = 0; i < assignment.length; i++) {
numbOfAssigned[assignment[i]]++;
for (int j = 0; j < newC[assignment[i]].length; j++) {
if (m_UseSearchSpace) {
if (useSearchSpace) {
newC[assignment[i]][j] += pop.getEAIndividual(i).getDoublePosition()[j];
} else {
newC[assignment[i]][j] += pop.getEAIndividual(i).getFitness(j);
@ -150,7 +145,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
//else System.out.println("Someone was not assigned any data!? "+ i +" "+numbOfAssigned[i] + ": Data.size()="+data.length);
}
}
if (this.m_Debug) {
if (this.debug) {
// let's see how they arrive here
Plot plot;
double[] tmpD = new double[2];
@ -166,10 +161,10 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
GraphPointSet mySet;
DPoint myPoint;
Chart2DDPointIconText tmp;
for (int i = 0; i < this.m_C.length; i++) {
for (int i = 0; i < this.c.length; i++) {
mySet = new GraphPointSet(10 + i, plot.getFunctionArea());
mySet.setConnectedMode(true);
myPoint = new DPoint(this.m_C[i][0], this.m_C[i][1]);
myPoint = new DPoint(this.c[i][0], this.c[i][1]);
tmp = new Chart2DDPointIconText("Old: " + i);
tmp.setIcon(new Chart2DDPointIconCircle());
myPoint.setIcon(tmp);
@ -181,7 +176,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
mySet.addDPoint(myPoint);
}
}
if (this.m_Debug) {
if (this.debug) {
// let's see how they arrive here
Plot plot;
double[] tmpD = new double[2];
@ -206,20 +201,20 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
}
// finally let's check whether or not the C changed and if i can terminate k_Means
finished = true;
for (int i = 0; i < this.m_C.length; i++) {
if (EuclideanMetric.euclideanDistance(this.m_C[i], newC[i]) > 0.0001) {
for (int i = 0; i < this.c.length; i++) {
if (EuclideanMetric.euclideanDistance(this.c[i], newC[i]) > 0.0001) {
finished = false;
}
this.m_C[i] = newC[i];
this.c[i] = newC[i];
}
} // gosh now i'm done
// finally lets build the new populations
Population[] result = this.cluster(pop, this.m_C);
// Population[] result = new Population[this.m_K];
Population[] result = this.cluster(pop, this.c);
// Population[] result = new Population[this.k];
// for (int i = 0; i < assignment.length; i++)
// result[assignment[i]].add(pop.get(i));
if (this.m_Debug) {
if (this.debug) {
// let's see how they arrive here
Plot plot;
double[] tmpD = new double[2];
@ -315,7 +310,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
* @return The scalar distances between d1 and d2
*/
private double distance(AbstractEAIndividual indy, double[] p) {
if (m_UseSearchSpace) {
if (useSearchSpace) {
((InterfaceDataTypeDouble) tmpIndy).setDoubleGenotype(p);
} else {
tmpIndy.setFitness(p);
@ -337,7 +332,7 @@ public class ClusteringKMeans 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();
}
@ -391,17 +386,17 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
* @return The centroids
*/
public double[][] getC() {
return this.m_C;
return this.c;
}
public void resetC() {
this.m_C = null;
this.c = null;
}
public static void main(String[] args) {
ClusteringKMeans ckm = new ClusteringKMeans();
ckm.setUseSearchSpace(true);
ckm.m_Debug = true;
ckm.debug = true;
Population pop = new Population();
F1Problem f1 = new F1Problem();
f1.setProblemDimension(2);
@ -439,14 +434,14 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
* @return The current number of clusters to find.
*/
public int getK() {
return this.m_K;
return this.k;
}
public void setK(int m) {
if (m < 1) {
m = 1;
}
this.m_K = m;
this.k = m;
}
public String kTipText() {
@ -460,11 +455,11 @@ public class ClusteringKMeans 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() {
@ -477,11 +472,11 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
* @return The distance type to use.
*/
public boolean getReuseC() {
return this.m_ReuseC;
return this.reuseC;
}
public void setReuseC(boolean m) {
this.m_ReuseC = m;
this.reuseC = m;
}
public String reuseCTipText() {

View File

@ -6,38 +6,33 @@ import eva2.optimization.individuals.InterfaceDataTypeDouble;
/**
* This area constraint for parallelization is based on
* the class type an individual belongs to.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 03.10.2004
* Time: 15:07:36
* To change this template use File | Settings | File Templates.
*/
public class ConstBelongsToDifferentClass implements InterfaceConstraint, java.io.Serializable {
private double[] m_Class;
private double[][] m_OtherClasses;
private boolean m_UsePhenotype = false;
private double[] classes;
private double[][] otherClasses;
private boolean usePhenotype = false;
public ConstBelongsToDifferentClass() {
}
public ConstBelongsToDifferentClass(double[] m, double[][] b, boolean p) {
this.m_Class = m;
this.m_OtherClasses = b;
this.m_UsePhenotype = p;
this.classes = m;
this.otherClasses = b;
this.usePhenotype = p;
}
public ConstBelongsToDifferentClass(ConstBelongsToDifferentClass a) {
this.m_UsePhenotype = a.m_UsePhenotype;
if (a.m_Class != null) {
this.m_Class = new double[a.m_Class.length];
System.arraycopy(a.m_Class, 0, this.m_Class, 0, a.m_Class.length);
this.usePhenotype = a.usePhenotype;
if (a.classes != null) {
this.classes = new double[a.classes.length];
System.arraycopy(a.classes, 0, this.classes, 0, a.classes.length);
}
if (a.m_OtherClasses != null) {
this.m_OtherClasses = new double[a.m_OtherClasses.length][];
for (int i = 0; i < a.m_OtherClasses.length; i++) {
this.m_OtherClasses[i] = new double[a.m_OtherClasses[i].length];
System.arraycopy(a.m_OtherClasses[i], 0, this.m_OtherClasses[i], 0, a.m_OtherClasses[i].length);
if (a.otherClasses != null) {
this.otherClasses = new double[a.otherClasses.length][];
for (int i = 0; i < a.otherClasses.length; i++) {
this.otherClasses[i] = new double[a.otherClasses[i].length];
System.arraycopy(a.otherClasses[i], 0, this.otherClasses[i], 0, a.otherClasses[i].length);
}
}
}
@ -57,14 +52,14 @@ public class ConstBelongsToDifferentClass implements InterfaceConstraint, java.i
@Override
public boolean isValid(AbstractEAIndividual indy) {
double[] data;
if (this.m_UsePhenotype && (indy instanceof InterfaceDataTypeDouble)) {
if (this.usePhenotype && (indy instanceof InterfaceDataTypeDouble)) {
data = ((InterfaceDataTypeDouble) indy).getDoubleData();
} else {
data = ((AbstractEAIndividual) indy).getFitness();
}
double distanceToMyClass = this.distance(data, this.m_Class);
for (int i = 0; i < this.m_OtherClasses.length; i++) {
if (distanceToMyClass > this.distance(data, this.m_OtherClasses[i])) {
double distanceToMyClass = this.distance(data, this.classes);
for (int i = 0; i < this.otherClasses.length; i++) {
if (distanceToMyClass > this.distance(data, this.otherClasses[i])) {
return false;
}
}

View File

@ -37,8 +37,8 @@ public class AdaptiveCrossoverEAMixer extends CrossoverEAMixer implements Interf
* @param mutators
*/
public AdaptiveCrossoverEAMixer(InterfaceCrossover... crossovers) {
this.m_Crossers = new PropertyCrossoverMixer(crossovers);
this.m_Crossers.m_SelectedTargets = m_Crossers.m_AvailableTargets.clone();
this.crossoverMixer = new PropertyCrossoverMixer(crossovers);
this.crossoverMixer.selectedTargets = crossoverMixer.availableTargets.clone();
}
@Override
@ -66,7 +66,7 @@ public class AdaptiveCrossoverEAMixer extends CrossoverEAMixer implements Interf
}
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt, Population pop, double fit) {
InterfaceCrossover[] mutators = this.m_Crossers.getSelectedCrossers();
InterfaceCrossover[] mutators = this.crossoverMixer.getSelectedCrossers();
for (int i = 0; i < mutators.length; i++) {
mutators[i].init(individual, opt);
}
@ -81,7 +81,7 @@ public class AdaptiveCrossoverEAMixer extends CrossoverEAMixer implements Interf
}
public void update(AbstractEAIndividual individual, InterfaceOptimizationProblem opt, Population pop, double fit) {
InterfaceCrossover[] mutators = this.m_Crossers.getSelectedCrossers();
InterfaceCrossover[] mutators = this.crossoverMixer.getSelectedCrossers();
for (int i = 0; i < mutators.length; i++) {
mutators[i].init(individual, opt);
}

View File

@ -16,13 +16,13 @@ import java.util.BitSet;
* @author Alex
*/
public class CM1 implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CM1() {
}
public CM1(CM1 c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
@Override
@ -58,7 +58,7 @@ public class CM1 implements InterfaceCrossover, java.io.Serializable {
@Override
public void init(AbstractEAIndividual individual,
InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -15,14 +15,14 @@ import java.util.BitSet;
* @author Alex
*/
public class CM3 implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CM3() {
}
public CM3(CM3 c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
@Override
@ -69,7 +69,7 @@ public class CM3 implements InterfaceCrossover, java.io.Serializable {
@Override
public void init(AbstractEAIndividual individual,
InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -15,14 +15,14 @@ import java.util.BitSet;
* @author Alex
*/
public class CM4 implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CM4() {
}
public CM4(CM4 c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
@Override
@ -71,7 +71,7 @@ public class CM4 implements InterfaceCrossover, java.io.Serializable {
@Override
public void init(AbstractEAIndividual individual,
InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -15,14 +15,14 @@ import java.util.BitSet;
* @author Alex
*/
public class CM5 implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CM5() {
}
public CM5(CM5 c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
@Override
@ -54,7 +54,7 @@ public class CM5 implements InterfaceCrossover, java.io.Serializable {
@Override
public void init(AbstractEAIndividual individual,
InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -17,14 +17,14 @@ import java.util.BitSet;
* @author Alex
*/
public class CM6 implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CM6() {
}
public CM6(CM6 c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
@Override
@ -60,7 +60,7 @@ public class CM6 implements InterfaceCrossover, java.io.Serializable {
@Override
public void init(AbstractEAIndividual individual,
InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -14,7 +14,7 @@ import java.util.BitSet;
* @author Alex
*/
public class CM7 implements InterfaceCrossover, java.io.Serializable, InterfaceEvaluatingCrossoverOperator {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
private int evaluations = 0;
public CM7() {
@ -22,7 +22,7 @@ public class CM7 implements InterfaceCrossover, java.io.Serializable, InterfaceE
}
public CM7(CM7 c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
this.evaluations = c.evaluations;
}
@ -51,7 +51,7 @@ public class CM7 implements InterfaceCrossover, java.io.Serializable, InterfaceE
different++;
data.flip(i);
((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
this.m_OptimizationProblem.evaluate(indy1);
this.optimizationProblem.evaluate(indy1);
this.evaluations++;
if (indy1.getFitness(0) < min) {
foundBetter = true;
@ -75,7 +75,7 @@ public class CM7 implements InterfaceCrossover, java.io.Serializable, InterfaceE
@Override
public void init(AbstractEAIndividual individual,
InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -17,7 +17,7 @@ import java.util.ArrayList;
public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluatingCrossoverOperator, java.io.Serializable {
public static final String CROSSOVER_EA_MIXER_OPERATOR_KEY = "CrossoverEAMixerOperatorKey";
protected PropertyCrossoverMixer m_Crossers;
protected PropertyCrossoverMixer crossoverMixer;
protected boolean useSelfAdaption = false;
protected double tau1 = 0.15;
protected double lowerLimitChance = 0.05;
@ -51,18 +51,18 @@ public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluating
System.out.println("Illegal access exception for " + (String) crossers.get(i));
}
}
this.m_Crossers = new PropertyCrossoverMixer(tmpList);
this.crossoverMixer = new PropertyCrossoverMixer(tmpList);
tmpList = new InterfaceCrossover[2];
tmpList[0] = new CrossoverESArithmetical();
tmpList[1] = new CrossoverESSBX();
this.m_Crossers.setSelectedCrossers(tmpList);
this.m_Crossers.normalizeWeights();
this.m_Crossers.setDescriptiveString("Combining alternative mutation operators, please norm the weights!");
this.m_Crossers.setWeightsLabel("Weights");
this.crossoverMixer.setSelectedCrossers(tmpList);
this.crossoverMixer.normalizeWeights();
this.crossoverMixer.setDescriptiveString("Combining alternative mutation operators, please norm the weights!");
this.crossoverMixer.setWeightsLabel("Weights");
}
public CrossoverEAMixer(CrossoverEAMixer mutator) {
this.m_Crossers = (PropertyCrossoverMixer) mutator.m_Crossers.clone();
this.crossoverMixer = (PropertyCrossoverMixer) mutator.crossoverMixer.clone();
this.useSelfAdaption = mutator.useSelfAdaption;
this.tau1 = mutator.tau1;
this.lowerLimitChance = mutator.lowerLimitChance;
@ -103,7 +103,7 @@ public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluating
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
InterfaceCrossover[] crossers = this.m_Crossers.getSelectedCrossers();
InterfaceCrossover[] crossers = this.crossoverMixer.getSelectedCrossers();
for (int i = 0; i < crossers.length; i++) {
crossers[i].init(individual, opt);
}
@ -118,8 +118,8 @@ public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluating
*/
@Override
public AbstractEAIndividual[] mate(AbstractEAIndividual indy1, Population partners) {
this.m_Crossers.normalizeWeights();
double[] probs = this.m_Crossers.getWeights();
this.crossoverMixer.normalizeWeights();
double[] probs = this.crossoverMixer.getWeights();
if (this.useSelfAdaption) {
for (int i = 0; i < probs.length; i++) {
probs[i] *= Math.exp(this.tau1 * RNG.gaussianDouble(1));
@ -130,10 +130,10 @@ public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluating
probs[i] = 1;
}
}
this.m_Crossers.normalizeWeights();
this.crossoverMixer.normalizeWeights();
}
InterfaceCrossover[] crossover = this.m_Crossers.getSelectedCrossers();
InterfaceCrossover[] crossover = this.crossoverMixer.getSelectedCrossers();
double pointer = RNG.randomFloat(0, 1);
double dum = probs[0];
lastOperatorIndex = 0;
@ -197,11 +197,11 @@ public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluating
* @param d The crossover operators.
*/
public void setCrossovers(PropertyCrossoverMixer d) {
this.m_Crossers = d;
this.crossoverMixer = d;
}
public PropertyCrossoverMixer getCrossovers() {
return this.m_Crossers;
return this.crossoverMixer;
}
public String CrossoversTipText() {
@ -268,7 +268,7 @@ public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluating
@Override
public int getEvaluations() {
int numEvals = 0;
InterfaceCrossover[] crossers = this.m_Crossers.getSelectedCrossers();
InterfaceCrossover[] crossers = this.crossoverMixer.getSelectedCrossers();
for (int i = 0; i < crossers.length; i++) {
if (crossers[i] instanceof InterfaceEvaluatingCrossoverOperator) {
numEvals += ((InterfaceEvaluatingCrossoverOperator) crossers[i]).getEvaluations();
@ -279,7 +279,7 @@ public class CrossoverEAMixer implements InterfaceCrossover, InterfaceEvaluating
@Override
public void resetEvaluations() {
InterfaceCrossover[] crossers = this.m_Crossers.getSelectedCrossers();
InterfaceCrossover[] crossers = this.crossoverMixer.getSelectedCrossers();
for (int i = 0; i < crossers.length; i++) {
if (crossers[i] instanceof InterfaceEvaluatingCrossoverOperator) {
((InterfaceEvaluatingCrossoverOperator) crossers[i]).resetEvaluations();

View File

@ -11,22 +11,16 @@ import eva2.tools.math.RNG;
* namely c[i]=Sum_j (r_i * p_ji)
* where r_i are uniform random numbers normed to the sum of one and
* p_ji is the i-th component of parent j.
* <p/>
* Created by IntelliJ IDEA.
* User: streiche
* Date: 25.07.2003
* Time: 16:14:54
* To change this template use Options | File Templates.
*/
public class CrossoverESArithmetical implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CrossoverESArithmetical() {
}
public CrossoverESArithmetical(CrossoverESArithmetical c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -126,7 +120,7 @@ public class CrossoverESArithmetical implements InterfaceCrossover, java.io.Seri
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -15,16 +15,16 @@ import eva2.tools.math.RNG;
*/
public class CrossoverESBLXAlpha implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private double m_Alpha = 0.5;
private InterfaceOptimizationProblem optimizationProblem;
private double alpha = 0.5;
public CrossoverESBLXAlpha() {
}
public CrossoverESBLXAlpha(CrossoverESBLXAlpha c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.m_Alpha = c.m_Alpha;
this.optimizationProblem = c.optimizationProblem;
this.alpha = c.alpha;
}
/**
@ -78,7 +78,7 @@ public class CrossoverESBLXAlpha implements InterfaceCrossover, java.io.Serializ
double I = 0;
for (int i = 0; i < children.length; i++) {
for (int j = 0; j < children[i].length; j++) {
I = (extremeValues[j][1] - extremeValues[j][0]) * this.m_Alpha;
I = (extremeValues[j][1] - extremeValues[j][0]) * this.alpha;
children[i][j] = RNG.randomDouble(extremeValues[j][0] - I, extremeValues[j][1] + I);
}
}
@ -105,7 +105,7 @@ public class CrossoverESBLXAlpha implements InterfaceCrossover, java.io.Serializ
public boolean equals(Object crossover) {
if (crossover instanceof CrossoverESBLXAlpha) {
CrossoverESBLXAlpha cross = (CrossoverESBLXAlpha) crossover;
if (this.m_Alpha != cross.m_Alpha) {
if (this.alpha != cross.alpha) {
return false;
}
return true;
@ -125,7 +125,7 @@ public class CrossoverESBLXAlpha implements InterfaceCrossover, java.io.Serializ
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override
@ -165,11 +165,11 @@ public class CrossoverESBLXAlpha implements InterfaceCrossover, java.io.Serializ
if (a < 0) {
a = 0;
}
this.m_Alpha = a;
this.alpha = a;
}
public double getAlpha() {
return this.m_Alpha;
return this.alpha;
}
public String alphaTipText() {

View File

@ -14,22 +14,16 @@ import eva2.tools.math.RNG;
* <p/>
* where c[i] is the i-th child component and p_ij is the i-th component
* of parent j.
* <p/>
* Created by IntelliJ IDEA.
* User: streiche
* Date: 02.12.2003
* Time: 14:01:31
* To change this template use Options | File Templates.
*/
public class CrossoverESFlat implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CrossoverESFlat() {
}
public CrossoverESFlat(CrossoverESFlat c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -125,7 +119,7 @@ public class CrossoverESFlat implements InterfaceCrossover, java.io.Serializable
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -13,14 +13,14 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
* To change this template use Options | File Templates.
*/
public class CrossoverESIntermediate implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CrossoverESIntermediate() {
}
public CrossoverESIntermediate(CrossoverESIntermediate c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -112,7 +112,7 @@ public class CrossoverESIntermediate implements InterfaceCrossover, java.io.Seri
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -7,23 +7,19 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG;
/**
* Created by IntelliJ IDEA.
* User: streiche
* Date: 25.07.2003
* Time: 15:32:33
* To change this template use Options | File Templates.
*
*/
public class CrossoverESNPointDiscrete implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private int m_NumberOfCrossovers = 3;
private InterfaceOptimizationProblem optimizationProblem;
private int numberOfCrossovers = 3;
public CrossoverESNPointDiscrete() {
}
public CrossoverESNPointDiscrete(CrossoverESNPointDiscrete mutator) {
this.m_OptimizationProblem = mutator.m_OptimizationProblem;
this.m_NumberOfCrossovers = mutator.m_NumberOfCrossovers;
this.optimizationProblem = mutator.optimizationProblem;
this.numberOfCrossovers = mutator.numberOfCrossovers;
}
/**
@ -59,7 +55,7 @@ public class CrossoverESNPointDiscrete implements InterfaceCrossover, java.io.Se
if ((indy1 instanceof InterfaceESIndividual) && (partners.get(0) instanceof InterfaceESIndividual)) {
int length = ((InterfaceESIndividual) result[0]).getDGenotype().length;
int mixer = RNG.randomInt(0, partners.size());
int[] crossoverPoints = new int[this.m_NumberOfCrossovers];
int[] crossoverPoints = new int[this.numberOfCrossovers];
parents = new double[partners.size() + 1][];
children = new double[partners.size() + 1][];
for (int i = 0; i < result.length; i++) {
@ -68,11 +64,11 @@ public class CrossoverESNPointDiscrete implements InterfaceCrossover, java.io.Se
System.arraycopy(((InterfaceESIndividual) result[i]).getDGenotype(), 0, parents[i], 0, parents[i].length);
System.arraycopy(((InterfaceESIndividual) result[i]).getDGenotype(), 0, children[i], 0, parents[i].length);
}
for (int i = 0; i < this.m_NumberOfCrossovers; i++) {
for (int i = 0; i < this.numberOfCrossovers; i++) {
crossoverPoints[i] = RNG.randomInt(0, length - 1);
}
for (int i = 0; i < length; i++) {
for (int j = 0; j < this.m_NumberOfCrossovers; j++) {
for (int j = 0; j < this.numberOfCrossovers; j++) {
if (i == crossoverPoints[j]) {
mixer++;
}
@ -105,7 +101,7 @@ public class CrossoverESNPointDiscrete implements InterfaceCrossover, java.io.Se
public boolean equals(Object crossover) {
if (crossover instanceof CrossoverESNPointDiscrete) {
CrossoverESNPointDiscrete cross = (CrossoverESNPointDiscrete) crossover;
if (this.m_NumberOfCrossovers != cross.m_NumberOfCrossovers) {
if (this.numberOfCrossovers != cross.numberOfCrossovers) {
return false;
}
return true;
@ -125,7 +121,7 @@ public class CrossoverESNPointDiscrete implements InterfaceCrossover, java.io.Se
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override
@ -165,11 +161,11 @@ public class CrossoverESNPointDiscrete implements InterfaceCrossover, java.io.Se
if (crossovers < 0) {
crossovers = 0;
}
this.m_NumberOfCrossovers = crossovers;
this.numberOfCrossovers = crossovers;
}
public int getNumberOfCrossovers() {
return this.m_NumberOfCrossovers;
return this.numberOfCrossovers;
}
public String numberOfCrossoversTipText() {

View File

@ -7,23 +7,19 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG;
/**
* Created by IntelliJ IDEA.
* User: streiche
* Date: 14.04.2004
* Time: 16:23:27
* To change this template use File | Settings | File Templates.
*
*/
public class CrossoverESNPointDiscreteDislocation implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private int m_NumberOfCrossovers = 3;
private InterfaceOptimizationProblem optimizationProblem;
private int numberOfCrossovers = 3;
public CrossoverESNPointDiscreteDislocation() {
}
public CrossoverESNPointDiscreteDislocation(CrossoverESNPointDiscreteDislocation mutator) {
this.m_OptimizationProblem = mutator.m_OptimizationProblem;
this.m_NumberOfCrossovers = mutator.m_NumberOfCrossovers;
this.optimizationProblem = mutator.optimizationProblem;
this.numberOfCrossovers = mutator.numberOfCrossovers;
}
/**
@ -59,7 +55,7 @@ public class CrossoverESNPointDiscreteDislocation implements InterfaceCrossover,
if ((indy1 instanceof InterfaceESIndividual) && (partners.get(0) instanceof InterfaceESIndividual)) {
int length = ((InterfaceESIndividual) result[0]).getDGenotype().length;
int mixer = RNG.randomInt(0, partners.size());
int[] crossoverPoints = new int[this.m_NumberOfCrossovers + 1];
int[] crossoverPoints = new int[this.numberOfCrossovers + 1];
parents = new double[partners.size() + 1][];
children = new double[partners.size() + 1][];
for (int i = 0; i < result.length; i++) {
@ -71,7 +67,7 @@ public class CrossoverESNPointDiscreteDislocation implements InterfaceCrossover,
for (int i = 0; i < crossoverPoints.length; i++) {
crossoverPoints[i] = RNG.randomInt(0, length - 1);
}
crossoverPoints[RNG.randomInt(0, this.m_NumberOfCrossovers)] = 0;
crossoverPoints[RNG.randomInt(0, this.numberOfCrossovers)] = 0;
int parIndex = 0;
int chiIndex = 0;
boolean bol;
@ -120,7 +116,7 @@ public class CrossoverESNPointDiscreteDislocation implements InterfaceCrossover,
public boolean equals(Object crossover) {
if (crossover instanceof CrossoverESNPointDiscreteDislocation) {
CrossoverESNPointDiscreteDislocation cross = (CrossoverESNPointDiscreteDislocation) crossover;
if (this.m_NumberOfCrossovers != cross.m_NumberOfCrossovers) {
if (this.numberOfCrossovers != cross.numberOfCrossovers) {
return false;
}
return true;
@ -140,7 +136,7 @@ public class CrossoverESNPointDiscreteDislocation implements InterfaceCrossover,
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override
@ -180,11 +176,11 @@ public class CrossoverESNPointDiscreteDislocation implements InterfaceCrossover,
if (crossovers < 0) {
crossovers = 0;
}
this.m_NumberOfCrossovers = crossovers;
this.numberOfCrossovers = crossovers;
}
public int getNumberOfCrossovers() {
return this.m_NumberOfCrossovers;
return this.numberOfCrossovers;
}
public String numberOfCrossoversTipText() {

View File

@ -14,26 +14,22 @@ import eva2.tools.math.RNG;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
* User: streiche
* Date: 09.02.2005
* Time: 11:17:17
* To change this template use File | Settings | File Templates.
*
*/
public class CrossoverESPCX implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private double m_Eta = 0.2;
private double m_Zeta = 0.2;
private InterfaceOptimizationProblem optimizationProblem;
private double eta = 0.2;
private double zeta = 0.2;
public CrossoverESPCX() {
}
public CrossoverESPCX(CrossoverESPCX c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.m_Eta = c.m_Eta;
this.m_Zeta = c.m_Zeta;
this.optimizationProblem = c.optimizationProblem;
this.eta = c.eta;
this.zeta = c.zeta;
}
/**
@ -106,12 +102,12 @@ public class CrossoverESPCX implements InterfaceCrossover, java.io.Serializable
// first the parent and the d
for (int j = 0; j < parents[i].length; j++) {
children[i][j] = parents[i][j];
children[i][j] += RNG.gaussianDouble(this.m_Zeta) * tmpD[j];
children[i][j] += RNG.gaussianDouble(this.zeta) * tmpD[j];
}
// then the other parents
for (int j = 1; j < subSpace.size(); j++) {
tmpD = (double[]) subSpace.get(j);
w = RNG.gaussianDouble(this.m_Zeta);
w = RNG.gaussianDouble(this.zeta);
children[i] = Mathematics.vvAdd(children[i], Mathematics.svMult(w, tmpD));
}
}
@ -217,7 +213,7 @@ public class CrossoverESPCX implements InterfaceCrossover, java.io.Serializable
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
public static void main(String[] args) {
@ -286,8 +282,8 @@ public class CrossoverESPCX implements InterfaceCrossover, java.io.Serializable
plot.setUnconnectedPoint(2, 2, 0);
}
CrossoverESPCX cross = new CrossoverESPCX();
cross.m_Eta = 0.2;
cross.m_Zeta = 0.2;
cross.eta = 0.2;
cross.zeta = 0.2;
AbstractEAIndividual[] offsprings;
for (int i = 0; i < 1; i++) {
offsprings = cross.mate(indy1, pop);
@ -333,11 +329,11 @@ public class CrossoverESPCX implements InterfaceCrossover, java.io.Serializable
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() {
@ -348,11 +344,11 @@ public class CrossoverESPCX implements InterfaceCrossover, java.io.Serializable
if (a < 0) {
a = 0;
}
this.m_Zeta = a;
this.zeta = a;
}
public double getZeta() {
return this.m_Zeta;
return this.zeta;
}
public String zetaTipText() {

View File

@ -10,28 +10,24 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG;
/**
* Created by IntelliJ IDEA.
* User: streiche
* Date: 27.02.2004
* Time: 17:49:16
* To change this template use File | Settings | File Templates.
*
*/
public class CrossoverESSBX implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private double m_Eta = 0.2;
private InterfaceOptimizationProblem optimizationProblem;
private double eta = 0.2;
public CrossoverESSBX() {
}
public CrossoverESSBX(double eta) {
m_Eta = eta;
this.eta = eta;
}
public CrossoverESSBX(CrossoverESSBX c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.m_Eta = c.m_Eta;
this.optimizationProblem = c.optimizationProblem;
this.eta = c.eta;
}
/**
@ -77,9 +73,9 @@ public class CrossoverESSBX implements InterfaceCrossover, java.io.Serializable
for (int i = 0; i < children[0].length; i++) {
u = RNG.randomDouble(0, 1);
if (u <= 0.5) {
beta = Math.pow((2 * u), 1 / (this.m_Eta + 1));
beta = Math.pow((2 * u), 1 / (this.eta + 1));
} else {
beta = Math.pow((0.5 / (1 - u)), 1 / (this.m_Eta + 1));
beta = Math.pow((0.5 / (1 - u)), 1 / (this.eta + 1));
}
children[0][i] = 0.5 * ((1 + beta) * parents[0][i] + (1 - beta) * parents[1][i]);
children[1][i] = 0.5 * ((1 - beta) * parents[0][i] + (1 + beta) * parents[1][i]);
@ -107,7 +103,7 @@ public class CrossoverESSBX implements InterfaceCrossover, java.io.Serializable
public boolean equals(Object crossover) {
if (crossover instanceof CrossoverESSBX) {
CrossoverESSBX cross = (CrossoverESSBX) crossover;
if (this.m_Eta != cross.m_Eta) {
if (this.eta != cross.eta) {
return false;
}
return true;
@ -127,7 +123,7 @@ public class CrossoverESSBX implements InterfaceCrossover, java.io.Serializable
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
public static void main(String[] args) {
@ -182,7 +178,7 @@ public class CrossoverESSBX implements InterfaceCrossover, java.io.Serializable
plot.setUnconnectedPoint(2, 2, 0);
CrossoverESSBX cross = new CrossoverESSBX();
cross.m_Eta = 0.2;
cross.eta = 0.2;
AbstractEAIndividual[] offsprings;
for (int i = 0; i < 5000; i++) {
offsprings = cross.mate(indy1, pop);
@ -232,11 +228,11 @@ public class CrossoverESSBX implements InterfaceCrossover, java.io.Serializable
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() {

View File

@ -11,24 +11,20 @@ import eva2.tools.math.Mathematics;
import eva2.tools.math.RNG;
/**
* Created by IntelliJ IDEA.
* User: streiche
* Date: 09.02.2005
* Time: 14:27:22
* To change this template use File | Settings | File Templates.
*
*/
public class CrossoverESSPX implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private double m_Epsilon = 1.2;
private InterfaceOptimizationProblem optimizationProblem;
private double epsilon = 1.2;
public CrossoverESSPX() {
}
public CrossoverESSPX(CrossoverESSPX c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.m_Epsilon = c.m_Epsilon;
this.optimizationProblem = c.optimizationProblem;
this.epsilon = c.epsilon;
}
/**
@ -77,7 +73,7 @@ public class CrossoverESSPX implements InterfaceCrossover, java.io.Serializable
// calculate the Y vectors
for (int i = 0; i < parents.length; i++) {
Y[i] = Mathematics.vvAdd(g, Mathematics.svMult(this.m_Epsilon, Mathematics.vvSub(parents[i], g)));
Y[i] = Mathematics.vvAdd(g, Mathematics.svMult(this.epsilon, Mathematics.vvSub(parents[i], g)));
}
// now for each child the C vectors and the result
@ -135,7 +131,7 @@ public class CrossoverESSPX implements InterfaceCrossover, java.io.Serializable
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
public static void main(String[] args) {
@ -204,7 +200,7 @@ public class CrossoverESSPX implements InterfaceCrossover, java.io.Serializable
plot.setUnconnectedPoint(2, 2, 0);
}
CrossoverESSPX cross = new CrossoverESSPX();
cross.m_Epsilon = 1.2;
cross.epsilon = 1.2;
AbstractEAIndividual[] offsprings;
for (int i = 0; i < 500; i++) {
offsprings = cross.mate(indy1, pop);
@ -250,11 +246,11 @@ public class CrossoverESSPX implements InterfaceCrossover, java.io.Serializable
if (a < 0) {
a = 0;
}
this.m_Epsilon = a;
this.epsilon = a;
}
public double getEpsilon() {
return this.m_Epsilon;
return this.epsilon;
}
public String epsilonTipText() {

View File

@ -37,18 +37,18 @@ import java.util.ArrayList;
*/
public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private double m_Eta = 0.2;
private double m_Zeta = 0.2;
private InterfaceOptimizationProblem optimizationProblem;
private double eta = 0.2;
private double zeta = 0.2;
public CrossoverESUNDX() {
}
public CrossoverESUNDX(CrossoverESUNDX c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.m_Eta = c.m_Eta;
this.m_Zeta = c.m_Zeta;
this.optimizationProblem = c.optimizationProblem;
this.eta = c.eta;
this.zeta = c.zeta;
}
/**
@ -109,13 +109,13 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
// then the given coordinates
for (int j = 0; j < givenCoordinates.size(); j++) {
tmpD = (double[]) givenCoordinates.get(j);
w = RNG.gaussianDouble(this.m_Zeta);
w = RNG.gaussianDouble(this.zeta);
children[i] = Mathematics.vvAdd(children[i], Mathematics.svMult(w, tmpD));
}
// now the missing stuff
for (int j = 0; j < missingCorrdinates.size(); j++) {
tmpD = (double[]) missingCorrdinates.get(j);
w = RNG.gaussianDouble(this.m_Eta);
w = RNG.gaussianDouble(this.eta);
children[i] = Mathematics.vvAdd(children[i], Mathematics.svMult(w, tmpD));
}
}
@ -219,7 +219,7 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
public static void main(String[] args) {
@ -288,8 +288,8 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
plot.setUnconnectedPoint(2, 2, 0);
}
CrossoverESUNDX cross = new CrossoverESUNDX();
cross.m_Eta = 0.2;
cross.m_Zeta = 0.2;
cross.eta = 0.2;
cross.zeta = 0.2;
AbstractEAIndividual[] offsprings;
for (int i = 0; i < 500; i++) {
offsprings = cross.mate(indy1, pop);
@ -335,11 +335,11 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
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() {
@ -350,11 +350,11 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
if (a < 0) {
a = 0;
}
this.m_Zeta = a;
this.zeta = a;
}
public double getZeta() {
return this.m_Zeta;
return this.zeta;
}
public String zetaTipText() {

View File

@ -7,21 +7,17 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG;
/**
* Created by IntelliJ IDEA.
* User: streiche
* Date: 02.12.2003
* Time: 14:14:52
* To change this template use Options | File Templates.
*
*/
public class CrossoverESUniformDiscrete implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CrossoverESUniformDiscrete() {
}
public CrossoverESUniformDiscrete(CrossoverESUniformDiscrete c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -113,7 +109,7 @@ public class CrossoverESUniformDiscrete implements InterfaceCrossover, java.io.S
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -10,21 +10,17 @@ import eva2.tools.math.RNG;
import java.util.BitSet;
/**
* Created by IntelliJ IDEA.
* User: streiche
* Date: 03.04.2003
* Time: 15:03:55
* To change this template use Options | File Templates.
*
*/
public class CrossoverGABitSimulated implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CrossoverGABitSimulated() {
}
public CrossoverGABitSimulated(CrossoverGABitSimulated c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -124,7 +120,7 @@ public class CrossoverGABitSimulated implements InterfaceCrossover, java.io.Seri
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -11,20 +11,17 @@ import java.util.BitSet;
/**
* This operator performs one-point crossover.
* <p/>
* Created by IntelliJ IDEA. User: streiche Date: 03.04.2003 Time: 10:34:17 To
* change this template use Options | File Templates.
*/
public class CrossoverGADefault implements InterfaceCrossover,
java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CrossoverGADefault() {
}
public CrossoverGADefault(CrossoverGADefault c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -127,7 +124,7 @@ public class CrossoverGADefault implements InterfaceCrossover,
@Override
public void init(AbstractEAIndividual individual,
InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -20,8 +20,7 @@ import java.util.BitSet;
* @author mkron, streiche
*/
public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializable {
// private InterfaceOptimizationProblem m_OptimizationProblem;
private int m_NumberOfCrossovers = 3;
private int numberOfCrossovers = 3;
private static boolean TRACE = false;
public CrossoverGAGINPoint() {
@ -34,8 +33,7 @@ public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializ
}
public CrossoverGAGINPoint(CrossoverGAGINPoint mutator) {
// this.m_OptimizationProblem = mutator.m_OptimizationProblem;
this.m_NumberOfCrossovers = mutator.m_NumberOfCrossovers;
this.numberOfCrossovers = mutator.numberOfCrossovers;
}
/**
@ -89,12 +87,12 @@ public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializ
System.out.println("Before CO: " + BeanInspector.toString(newGenotypes));
}
int mixer = RNG.randomInt(0, partners.size()); // partner index with which to exchange genes
int[] crossoverPoints = getCrossoverPoints(length, m_NumberOfCrossovers);
int[] crossoverPoints = getCrossoverPoints(length, numberOfCrossovers);
if (TRACE) {
System.out.println("CO points: " + BeanInspector.toString(crossoverPoints));
}
for (int i = 0; i < length; i++) { // loop positions
for (int j = 0; j < this.m_NumberOfCrossovers; j++) {
for (int j = 0; j < this.numberOfCrossovers; j++) {
if (i == crossoverPoints[j]) {
mixer++;
} // possibly switch partner to exchange with
@ -182,10 +180,10 @@ public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializ
// length = Math.max(length, ((InterfaceGAIndividual)partners.get(i)).getGenotypeLength());
// }
//
// crossoverPoints=getCrossoverPoints(length, m_NumberOfCrossovers);
// crossoverPoints=getCrossoverPoints(length, numberOfCrossovers);
//
// for (int i = 0; i < length; i++) {
// for (int j = 0; j < this.m_NumberOfCrossovers; j++) {
// for (int j = 0; j < this.numberOfCrossovers; j++) {
// if (i == crossoverPoints[j]) mixer++;
// }
// for (int j = 0; j < tmpBitSet[0].length; j++) {
@ -230,7 +228,7 @@ public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializ
public boolean equals(Object crossover) {
if (crossover instanceof CrossoverGAGINPoint) {
CrossoverGAGINPoint cross = (CrossoverGAGINPoint) crossover;
if (this.m_NumberOfCrossovers != cross.m_NumberOfCrossovers) {
if (this.numberOfCrossovers != cross.numberOfCrossovers) {
return false;
}
return true;
@ -250,7 +248,7 @@ public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializ
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
// this.m_OptimizationProblem = opt;
// this.optimizationProblem = opt;
}
@Override
@ -290,11 +288,11 @@ public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializ
if (crossovers < 0) {
crossovers = 0;
}
this.m_NumberOfCrossovers = crossovers;
this.numberOfCrossovers = crossovers;
}
public int getNumberOfCrossovers() {
return this.m_NumberOfCrossovers;
return this.numberOfCrossovers;
}
public String numberOfCrossoversTipText() {

View File

@ -17,14 +17,14 @@ import java.util.BitSet;
* To change this template use Options | File Templates.
*/
public class CrossoverGAUniform implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CrossoverGAUniform() {
}
public CrossoverGAUniform(CrossoverGAUniform c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -118,7 +118,7 @@ public class CrossoverGAUniform implements InterfaceCrossover, java.io.Serializa
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -8,22 +8,17 @@ import eva2.tools.math.RNG;
/**
* One-point crossover on integer individuals.
* <p/>
* User: mkron, streiche
* Date: 18.05.2005
* Time: 17:10:28
* To change this template use File | Settings | File Templates.
*/
public class CrossoverGIDefault implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CrossoverGIDefault() {
}
public CrossoverGIDefault(CrossoverGIDefault c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -125,7 +120,7 @@ public class CrossoverGIDefault implements InterfaceCrossover, java.io.Serializa
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -14,16 +14,16 @@ import eva2.tools.math.RNG;
* To change this template use File | Settings | File Templates.
*/
public class CrossoverGINPoint implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private int m_NumberOfCrossovers = 3;
private InterfaceOptimizationProblem optimizationProblem;
private int numberOfCrossovers = 3;
public CrossoverGINPoint() {
}
public CrossoverGINPoint(CrossoverGINPoint mutator) {
this.m_OptimizationProblem = mutator.m_OptimizationProblem;
this.m_NumberOfCrossovers = mutator.m_NumberOfCrossovers;
this.optimizationProblem = mutator.optimizationProblem;
this.numberOfCrossovers = mutator.numberOfCrossovers;
}
/**
@ -58,7 +58,7 @@ public class CrossoverGINPoint implements InterfaceCrossover, java.io.Serializab
if ((indy1 instanceof InterfaceGIIndividual) && (partners.get(0) instanceof InterfaceGIIndividual)) {
int length = ((InterfaceGIIndividual) indy1).getGenotypeLength();
int mixer = RNG.randomInt(0, partners.size());
int[] crossoverPoints = new int[this.m_NumberOfCrossovers];
int[] crossoverPoints = new int[this.numberOfCrossovers];
int[][][] tmpInts = new int[2][partners.size() + 1][];
tmpInts[0][0] = ((InterfaceGIIndividual) indy1).getIGenotype();
@ -70,12 +70,12 @@ public class CrossoverGINPoint implements InterfaceCrossover, java.io.Serializab
length = Math.max(length, ((InterfaceGIIndividual) partners.get(i)).getGenotypeLength());
}
for (int i = 0; i < this.m_NumberOfCrossovers; i++) {
for (int i = 0; i < this.numberOfCrossovers; i++) {
crossoverPoints[i] = RNG.randomInt(0, length - 1);
//System.out.println("crpoint: "+crossoverPoints[i]);
}
for (int i = 0; i < length; i++) {
for (int j = 0; j < this.m_NumberOfCrossovers; j++) {
for (int j = 0; j < this.numberOfCrossovers; j++) {
if (i == crossoverPoints[j]) {
mixer++;
}
@ -110,7 +110,7 @@ public class CrossoverGINPoint implements InterfaceCrossover, java.io.Serializab
public boolean equals(Object crossover) {
if (crossover instanceof CrossoverGINPoint) {
CrossoverGINPoint cross = (CrossoverGINPoint) crossover;
if (this.m_NumberOfCrossovers != cross.m_NumberOfCrossovers) {
if (this.numberOfCrossovers != cross.numberOfCrossovers) {
return false;
}
return true;
@ -130,7 +130,7 @@ public class CrossoverGINPoint implements InterfaceCrossover, java.io.Serializab
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override
@ -170,11 +170,11 @@ public class CrossoverGINPoint implements InterfaceCrossover, java.io.Serializab
if (crossovers < 0) {
crossovers = 0;
}
this.m_NumberOfCrossovers = crossovers;
this.numberOfCrossovers = crossovers;
}
public int getNumberOfCrossovers() {
return this.m_NumberOfCrossovers;
return this.numberOfCrossovers;
}
public String numberOfCrossoversTipText() {

View File

@ -16,16 +16,16 @@ import java.util.BitSet;
* To change this template use File | Settings | File Templates.
*/
public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private int m_NumberOfCrossovers = 3;
private InterfaceOptimizationProblem optimizationProblem;
private int numberOfCrossovers = 3;
public CrossoverGINPointVL() {
}
public CrossoverGINPointVL(CrossoverGINPointVL mutator) {
this.m_OptimizationProblem = mutator.m_OptimizationProblem;
this.m_NumberOfCrossovers = mutator.m_NumberOfCrossovers;
this.optimizationProblem = mutator.optimizationProblem;
this.numberOfCrossovers = mutator.numberOfCrossovers;
}
/**
@ -60,7 +60,7 @@ public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializ
if ((indy1 instanceof InterfaceGIIndividual) && (partners.get(0) instanceof InterfaceGIIndividual)) {
int[] length = new int[partners.size() + 1];
int mixer = RNG.randomInt(0, partners.size());
int[][] crossoverPoints = new int[length.length][this.m_NumberOfCrossovers];
int[][] crossoverPoints = new int[length.length][this.numberOfCrossovers];
int[][] parents = new int[partners.size() + 1][];
int[][] offsprings = new int[partners.size() + 1][];
@ -76,14 +76,14 @@ public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializ
for (int i = 0; i < offsprings.length; i++) {
index = 0;
tmpLen = 0;
for (int j = 0; j < this.m_NumberOfCrossovers; j++) {
for (int j = 0; j < this.numberOfCrossovers; j++) {
tmpLen += fragments[(i + j) % fragments.length][index].length;
index++;
}
offsprings[i] = new int[tmpLen];
index = 0;
tmpLen = 0;
for (int j = 0; j < this.m_NumberOfCrossovers; j++) {
for (int j = 0; j < this.numberOfCrossovers; j++) {
System.arraycopy(fragments[(i + j) % fragments.length][index], 0, offsprings[i], tmpLen, fragments[(i + j) % fragments.length][index].length);
tmpLen += fragments[(i + j) % fragments.length][index].length;
index++;
@ -108,19 +108,19 @@ public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializ
* This method will return n fragments from the int arrays
*/
private int[][][] getNFragmentsFrom(int[][] parents) {
int[][][] result = new int[parents.length][this.m_NumberOfCrossovers][];
int[][][] result = new int[parents.length][this.numberOfCrossovers][];
for (int i = 0; i < parents.length; i++) {
// for each parents get n fragments
if (this.m_NumberOfCrossovers + 2 > parents[i].length) {
for (int j = 0; j < this.m_NumberOfCrossovers; j++) {
if (this.numberOfCrossovers + 2 > parents[i].length) {
for (int j = 0; j < this.numberOfCrossovers; j++) {
result[i][j] = new int[parents[i].length];
System.arraycopy(parents[i], 0, result[i][j], 0, parents[i].length);
}
} else {
int[] crossoverpoints = this.getCrossoverPoints(parents[i].length);
int lastPoint = 0;
for (int j = 0; j < this.m_NumberOfCrossovers; j++) {
for (int j = 0; j < this.numberOfCrossovers; j++) {
result[i][j] = new int[crossoverpoints[j] - lastPoint];
System.arraycopy(parents[i], lastPoint, result[i][j], 0, crossoverpoints[j] - lastPoint);
lastPoint = crossoverpoints[j];
@ -138,10 +138,10 @@ public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializ
* @return int[] the list of crossover points
*/
private int[] getCrossoverPoints(int length) {
int[] result = new int[this.m_NumberOfCrossovers];
int[] result = new int[this.numberOfCrossovers];
BitSet bitset = new BitSet(length);
while (bitset.cardinality() < this.m_NumberOfCrossovers) {
while (bitset.cardinality() < this.numberOfCrossovers) {
bitset.set(RNG.randomInt(1, length - 2));
}
int index = 0;
@ -165,7 +165,7 @@ public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializ
public boolean equals(Object crossover) {
if (crossover instanceof CrossoverGINPointVL) {
CrossoverGINPointVL cross = (CrossoverGINPointVL) crossover;
if (this.m_NumberOfCrossovers != cross.m_NumberOfCrossovers) {
if (this.numberOfCrossovers != cross.numberOfCrossovers) {
return false;
}
return true;
@ -185,7 +185,7 @@ public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializ
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override
@ -225,11 +225,11 @@ public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializ
if (crossovers < 0) {
crossovers = 0;
}
this.m_NumberOfCrossovers = crossovers;
this.numberOfCrossovers = crossovers;
}
public int getNumberOfCrossovers() {
return this.m_NumberOfCrossovers;
return this.numberOfCrossovers;
}
public String numberOfCrossoversTipText() {

View File

@ -16,14 +16,14 @@ import eva2.tools.math.RNG;
*/
public class CrossoverGIUniform implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
public CrossoverGIUniform() {
}
public CrossoverGIUniform(CrossoverGIUniform c) {
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -117,7 +117,7 @@ public class CrossoverGIUniform implements InterfaceCrossover, java.io.Serializa
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -21,7 +21,7 @@ public class CrossoverGPDefault implements InterfaceCrossover, java.io.Serializa
*
*/
private static final long serialVersionUID = 8900427365914281930L;
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
private boolean maintainMaxDepth = true;
private static final boolean TRACE = false;
@ -30,7 +30,7 @@ public class CrossoverGPDefault implements InterfaceCrossover, java.io.Serializa
public CrossoverGPDefault(CrossoverGPDefault c) {
this.maintainMaxDepth = c.maintainMaxDepth;
this.m_OptimizationProblem = c.m_OptimizationProblem;
this.optimizationProblem = c.optimizationProblem;
}
/**
@ -157,7 +157,7 @@ public class CrossoverGPDefault implements InterfaceCrossover, java.io.Serializa
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -5,14 +5,10 @@ import eva2.optimization.population.Population;
import eva2.optimization.problems.InterfaceOptimizationProblem;
/**
* Created by IntelliJ IDEA.
* User: streiche
* Date: 25.03.2003
* Time: 11:18:54
* To change this template use Options | File Templates.
*
*/
public class NoCrossover implements InterfaceCrossover, java.io.Serializable {
private InterfaceOptimizationProblem m_OptimizationProblem;
private InterfaceOptimizationProblem optimizationProblem;
/**
* A constructor.
@ -79,7 +75,7 @@ public class NoCrossover implements InterfaceCrossover, java.io.Serializable {
*/
@Override
public void init(AbstractEAIndividual individual, InterfaceOptimizationProblem opt) {
this.m_OptimizationProblem = opt;
this.optimizationProblem = opt;
}
@Override

View File

@ -1,46 +1,42 @@
package eva2.optimization.operator.crossover;
/**
* Created by IntelliJ IDEA.
* User: Dante Alighieri
* Date: 21.05.2005
* Time: 17:34:15
* To change this template use File | Settings | File Templates.
*
*/
public class PropertyCrossoverMixer implements java.io.Serializable {
public InterfaceCrossover[] m_AvailableTargets;
public InterfaceCrossover[] m_SelectedTargets;
public double[] m_Weights;
public String m_DescriptiveString = "No Description given.";
public String m_WeightsLabel = "-";
public boolean m_NormalizationEnabled = true;
public InterfaceCrossover[] availableTargets;
public InterfaceCrossover[] selectedTargets;
public double[] weights;
public String descriptiveString = "No Description given.";
public String weightsLabel = "-";
public boolean normalizationEnabled = true;
public PropertyCrossoverMixer(InterfaceCrossover[] d) {
this.m_Weights = new double[d.length];
this.weights = new double[d.length];
for (int i = 0; i < d.length; i++) {
this.m_Weights[i] = 1 / ((double) d.length);
this.weights[i] = 1 / ((double) d.length);
}
this.m_AvailableTargets = d;
this.m_SelectedTargets = null;
this.availableTargets = d;
this.selectedTargets = null;
}
public PropertyCrossoverMixer(PropertyCrossoverMixer d) {
this.m_DescriptiveString = d.m_DescriptiveString;
this.m_WeightsLabel = d.m_WeightsLabel;
this.m_NormalizationEnabled = d.m_NormalizationEnabled;
this.m_AvailableTargets = new InterfaceCrossover[d.m_AvailableTargets.length];
for (int i = 0; i < this.m_AvailableTargets.length; i++) {
this.descriptiveString = d.descriptiveString;
this.weightsLabel = d.weightsLabel;
this.normalizationEnabled = d.normalizationEnabled;
this.availableTargets = new InterfaceCrossover[d.availableTargets.length];
for (int i = 0; i < this.availableTargets.length; i++) {
//this.availableTargets[i] = (InterfaceMutation)d.availableTargets[i].clone();
this.m_AvailableTargets[i] = d.m_AvailableTargets[i];
this.availableTargets[i] = d.availableTargets[i];
}
this.m_SelectedTargets = new InterfaceCrossover[d.m_SelectedTargets.length];
for (int i = 0; i < this.m_SelectedTargets.length; i++) {
this.m_SelectedTargets[i] = (InterfaceCrossover) d.m_SelectedTargets[i].clone();
this.selectedTargets = new InterfaceCrossover[d.selectedTargets.length];
for (int i = 0; i < this.selectedTargets.length; i++) {
this.selectedTargets[i] = (InterfaceCrossover) d.selectedTargets[i].clone();
}
if (d.m_Weights != null) {
this.m_Weights = new double[d.m_Weights.length];
System.arraycopy(d.m_Weights, 0, this.m_Weights, 0, this.m_Weights.length);
if (d.weights != null) {
this.weights = new double[d.weights.length];
System.arraycopy(d.weights, 0, this.weights, 0, this.weights.length);
}
}
@ -55,32 +51,32 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
* @param d The InterfaceOptimizationTarget[]
*/
public void setSelectedCrossers(InterfaceCrossover[] d) {
this.m_SelectedTargets = d;
this.selectedTargets = d;
if (this.m_Weights == null) {
this.m_Weights = new double[d.length];
for (int i = 0; i < this.m_Weights.length; i++) {
this.m_Weights[i] = 1 / ((double) d.length);
if (this.weights == null) {
this.weights = new double[d.length];
for (int i = 0; i < this.weights.length; i++) {
this.weights[i] = 1 / ((double) d.length);
}
return;
}
if (d.length == this.m_Weights.length) {
if (d.length == this.weights.length) {
return;
}
if (d.length > this.m_Weights.length) {
if (d.length > this.weights.length) {
double[] newWeights = new double[d.length];
for (int i = 0; i < this.m_Weights.length; i++) {
newWeights[i] = this.m_Weights[i];
for (int i = 0; i < this.weights.length; i++) {
newWeights[i] = this.weights[i];
}
this.m_Weights = newWeights;
this.weights = newWeights;
} else {
double[] newWeights = new double[d.length];
for (int i = 0; i < d.length; i++) {
newWeights[i] = this.m_Weights[i];
newWeights[i] = this.weights[i];
}
this.m_Weights = newWeights;
this.weights = newWeights;
}
}
@ -90,7 +86,7 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
* @return The InterfaceOptimizationTarget[].
*/
public InterfaceCrossover[] getSelectedCrossers() {
return this.m_SelectedTargets;
return this.selectedTargets;
}
/**
@ -99,7 +95,7 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
* @return The InterfaceOptimizationTarget[].
*/
public InterfaceCrossover[] getAvailableCrossers() {
return this.m_AvailableTargets;
return this.availableTargets;
}
/**
@ -108,13 +104,13 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
* @return the weights
*/
public double[] getWeights() {
return this.m_Weights;
return this.weights;
}
public void setWeights(double[] d) {
this.m_Weights = d;
for (int i = 0; i < this.m_Weights.length; i++) {
this.m_Weights[i] = Math.abs(this.m_Weights[i]);
this.weights = d;
for (int i = 0; i < this.weights.length; i++) {
this.weights[i] = Math.abs(this.weights[i]);
}
}
@ -124,11 +120,11 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
* @return the string
*/
public String getDescriptiveString() {
return this.m_DescriptiveString;
return this.descriptiveString;
}
public void setDescriptiveString(String d) {
this.m_DescriptiveString = d;
this.descriptiveString = d;
}
/**
@ -137,21 +133,21 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
* @return the string
*/
public String getWeigthsLabel() {
return this.m_WeightsLabel;
return this.weightsLabel;
}
public void setWeightsLabel(String d) {
this.m_WeightsLabel = d;
this.weightsLabel = d;
}
public void normalizeWeights() {
double sum = 0;
for (int i = 0; i < this.m_Weights.length; i++) {
sum += this.m_Weights[i];
for (int i = 0; i < this.weights.length; i++) {
sum += this.weights[i];
}
if (sum > 0) {
for (int i = 0; i < this.m_Weights.length; i++) {
this.m_Weights[i] /= sum;
for (int i = 0; i < this.weights.length; i++) {
this.weights[i] /= sum;
}
}
}
@ -162,22 +158,22 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
* @param index The index of the target to be removed.
*/
public void removeCrosser(int index) {
if ((index < 0) || (index >= this.m_SelectedTargets.length)) {
if ((index < 0) || (index >= this.selectedTargets.length)) {
return;
}
InterfaceCrossover[] newList = new InterfaceCrossover[this.m_SelectedTargets.length - 1];
double[] newWeights = new double[this.m_Weights.length - 1];
InterfaceCrossover[] newList = new InterfaceCrossover[this.selectedTargets.length - 1];
double[] newWeights = new double[this.weights.length - 1];
int j = 0;
for (int i = 0; i < this.m_SelectedTargets.length; i++) {
for (int i = 0; i < this.selectedTargets.length; i++) {
if (index != i) {
newList[j] = this.m_SelectedTargets[i];
newWeights[j] = this.m_Weights[i];
newList[j] = this.selectedTargets[i];
newWeights[j] = this.weights[i];
j++;
}
}
this.m_SelectedTargets = newList;
this.m_Weights = newWeights;
this.selectedTargets = newList;
this.weights = newWeights;
}
/**
@ -186,15 +182,15 @@ public class PropertyCrossoverMixer implements java.io.Serializable {
* @param optTarget
*/
public void addCrossers(InterfaceCrossover optTarget) {
InterfaceCrossover[] newList = new InterfaceCrossover[this.m_SelectedTargets.length + 1];
double[] newWeights = new double[this.m_Weights.length + 1];
for (int i = 0; i < this.m_SelectedTargets.length; i++) {
newList[i] = this.m_SelectedTargets[i];
newWeights[i] = this.m_Weights[i];
InterfaceCrossover[] newList = new InterfaceCrossover[this.selectedTargets.length + 1];
double[] newWeights = new double[this.weights.length + 1];
for (int i = 0; i < this.selectedTargets.length; i++) {
newList[i] = this.selectedTargets[i];
newWeights[i] = this.weights[i];
}
newList[this.m_SelectedTargets.length] = optTarget;
newWeights[this.m_SelectedTargets.length] = 1.0;
this.m_SelectedTargets = newList;
this.m_Weights = newWeights;
newList[this.selectedTargets.length] = optTarget;
newWeights[this.selectedTargets.length] = 1.0;
this.selectedTargets = newList;
this.weights = newWeights;
}
}

View File

@ -32,73 +32,69 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
/**
* Handles property change notification
*/
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
/**
* The filePath that is to be edited
*/
private PropertyCrossoverMixer m_CrossoversWithWeights;
private PropertyCrossoverMixer crossoverMixer;
/**
* The gaphix stuff
*/
private JComponent m_Editor;
private JPanel m_TargetList;
private JTextField[] m_Weights;
private JComponent[] m_Targets;
private JButton[] m_Delete;
private JScrollPane m_ScrollTargets;
private GeneralOptimizationEditorProperty[] m_Editors;
private GeneralGEOFaker m_Component;
private PropertyChangeListener m_self;
private JComponent editor;
private JPanel targetList;
private JTextField[] weights;
private JComponent[] targets;
private JButton[] deleteButtons;
private JScrollPane scrollTargets;
private GeneralOptimizationEditorProperty[] editors;
private GeneralGEOFaker component;
private PropertyChangeListener self;
public PropertyCrossoverMixerEditor() {
m_self = this;
self = this;
}
/**
* This method will init the CustomEditor Panel
*/
private void initCustomEditor() {
m_self = this;
this.m_Editor = new JPanel();
this.m_Editor.setPreferredSize(new Dimension(450, 200));
this.m_Editor.setMinimumSize(new Dimension(450, 200));
self = this;
this.editor = new JPanel();
this.editor.setPreferredSize(new Dimension(450, 200));
this.editor.setMinimumSize(new Dimension(450, 200));
// init the editors
InterfaceCrossover[] list = this.m_CrossoversWithWeights.getSelectedCrossers();
this.m_Editors = new GeneralOptimizationEditorProperty[list.length];
InterfaceCrossover[] list = this.crossoverMixer.getSelectedCrossers();
this.editors = new GeneralOptimizationEditorProperty[list.length];
for (int i = 0; i < list.length; i++) {
this.m_Editors[i] = new GeneralOptimizationEditorProperty();
this.m_Editors[i].name = list[i].getStringRepresentation();
this.editors[i] = new GeneralOptimizationEditorProperty();
this.editors[i].name = list[i].getStringRepresentation();
try {
this.m_Editors[i].value = list[i];
this.m_Editors[i].editor = PropertyEditorProvider.findEditor(this.m_Editors[i].value.getClass());
if (this.m_Editors[i].editor == null) {
this.m_Editors[i].editor = PropertyEditorProvider.findEditor(InterfaceCrossover.class);
this.editors[i].value = list[i];
this.editors[i].editor = PropertyEditorProvider.findEditor(this.editors[i].value.getClass());
if (this.editors[i].editor == null) {
this.editors[i].editor = PropertyEditorProvider.findEditor(InterfaceCrossover.class);
}
if (this.m_Editors[i].editor instanceof GenericObjectEditor) {
((GenericObjectEditor) this.m_Editors[i].editor).setClassType(InterfaceCrossover.class);
if (this.editors[i].editor instanceof GenericObjectEditor) {
((GenericObjectEditor) this.editors[i].editor).setClassType(InterfaceCrossover.class);
}
this.m_Editors[i].editor.setValue(this.m_Editors[i].value);
this.m_Editors[i].editor.addPropertyChangeListener(this);
AbstractObjectEditor.findViewFor(this.m_Editors[i]);
if (this.m_Editors[i].view != null) {
this.m_Editors[i].view.repaint();
this.editors[i].editor.setValue(this.editors[i].value);
this.editors[i].editor.addPropertyChangeListener(this);
AbstractObjectEditor.findViewFor(this.editors[i]);
if (this.editors[i].view != null) {
this.editors[i].view.repaint();
}
} catch (Exception e) {
System.out.println("Darn can't read the value...");
}
}
this.m_TargetList = new JPanel();
this.targetList = new JPanel();
this.updateTargetList();
this.m_ScrollTargets = new JScrollPane(this.m_TargetList);
this.scrollTargets = new JScrollPane(this.targetList);
this.m_Editor.setLayout(new BorderLayout());
this.m_Editor.add(this.m_ScrollTargets, BorderLayout.CENTER);
this.editor.setLayout(new BorderLayout());
this.editor.add(this.scrollTargets, BorderLayout.CENTER);
// The Button Panel
JPanel buttonPanel = new JPanel();
@ -111,7 +107,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
buttonPanel.add(normButton);
buttonPanel.add(addButton);
this.m_Editor.add(buttonPanel, BorderLayout.SOUTH);
this.editor.add(buttonPanel, BorderLayout.SOUTH);
// Some description would be nice
JTextArea jt = new JTextArea();
@ -119,7 +115,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
jt.setEditable(false);
jt.setLineWrap(true);
jt.setWrapStyleWord(true);
jt.setText(this.m_CrossoversWithWeights.getDescriptiveString());
jt.setText(this.crossoverMixer.getDescriptiveString());
jt.setBackground(getBackground());
JPanel jp = new JPanel();
jp.setBorder(BorderFactory.createCompoundBorder(
@ -136,7 +132,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
jp.add(p2, BorderLayout.EAST);
GridBagConstraints gbConstraints = new GridBagConstraints();
this.m_Editor.add(jp, BorderLayout.NORTH);
this.editor.add(jp, BorderLayout.NORTH);
this.updateEditor();
}
@ -147,15 +143,15 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
private void updateTargetList() {
BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes;
InterfaceCrossover[] list = this.m_CrossoversWithWeights.getSelectedCrossers();
double[] weights = this.m_CrossoversWithWeights.getWeights();
InterfaceCrossover[] list = this.crossoverMixer.getSelectedCrossers();
double[] weights = this.crossoverMixer.getWeights();
this.m_TargetList.removeAll();
this.m_TargetList.setLayout(new GridBagLayout());
this.targetList.removeAll();
this.targetList.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
this.m_Weights = new JTextField[list.length];
this.m_Targets = new JComponent[list.length];
this.m_Delete = new JButton[list.length];
this.weights = new JTextField[list.length];
this.targets = new JComponent[list.length];
this.deleteButtons = new JButton[list.length];
String[] cups = new String[8];
for (int i = 0; i < cups.length; i++) {
cups[i] = "" + (i + 1);
@ -165,52 +161,52 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0;
gbc.weightx = 2;
this.m_TargetList.add(new JLabel(this.m_CrossoversWithWeights.getWeigthsLabel()), gbc);
this.targetList.add(new JLabel(this.crossoverMixer.getWeigthsLabel()), gbc);
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 1;
gbc.weightx = 10;
this.m_TargetList.add(new JLabel("Target"), gbc);
this.targetList.add(new JLabel("Target"), gbc);
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.REMAINDER;
gbc.gridx = 2;
gbc.weightx = 1;
this.m_TargetList.add(new JLabel("Remove"), gbc);
this.targetList.add(new JLabel("Remove"), gbc);
for (int i = 0; i < list.length; i++) {
// the weight
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0;
gbc.weightx = 2;
this.m_Weights[i] = new JTextField("" + weights[i]);
this.m_Weights[i].addKeyListener(this.readDoubleArrayAction);
this.m_TargetList.add(this.m_Weights[i], gbc);
this.weights[i] = new JTextField("" + weights[i]);
this.weights[i].addKeyListener(this.readDoubleArrayAction);
this.targetList.add(this.weights[i], gbc);
// the status indicator
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 1;
gbc.weightx = 10;
this.m_Targets[i] = this.m_Editors[i].view;
this.m_TargetList.add(this.m_Targets[i], gbc);
this.targets[i] = this.editors[i].view;
this.targetList.add(this.targets[i], gbc);
// The delete button
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.REMAINDER;
gbc.gridx = 2;
gbc.weightx = 1;
bytes = loader.getBytesFromResourceLocation("images/Sub24.gif", true);
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
this.m_Delete[i].addActionListener(deleteTarget);
this.m_TargetList.add(this.m_Delete[i], gbc);
this.deleteButtons[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
this.deleteButtons[i].addActionListener(deleteTarget);
this.targetList.add(this.deleteButtons[i], gbc);
}
this.m_TargetList.repaint();
this.m_TargetList.validate();
if (this.m_ScrollTargets != null) {
this.m_ScrollTargets.validate();
this.m_ScrollTargets.repaint();
this.targetList.repaint();
this.targetList.validate();
if (this.scrollTargets != null) {
this.scrollTargets.validate();
this.scrollTargets.repaint();
}
if (this.m_Editor != null) {
this.m_Editor.validate();
this.m_Editor.repaint();
if (this.editor != null) {
this.editor.validate();
this.editor.repaint();
}
}
@ -230,13 +226,13 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
ActionListener addTarget = new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
m_CrossoversWithWeights.addCrossers((InterfaceCrossover) m_CrossoversWithWeights.getAvailableCrossers()[0].clone());
int l = m_CrossoversWithWeights.getSelectedCrossers().length;
crossoverMixer.addCrossers((InterfaceCrossover) crossoverMixer.getAvailableCrossers()[0].clone());
int l = crossoverMixer.getSelectedCrossers().length;
GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l];
for (int i = 0; i < m_Editors.length; i++) {
newEdit[i] = m_Editors[i];
for (int i = 0; i < editors.length; i++) {
newEdit[i] = editors[i];
}
InterfaceCrossover[] list = m_CrossoversWithWeights.getSelectedCrossers();
InterfaceCrossover[] list = crossoverMixer.getSelectedCrossers();
l--;
newEdit[l] = new GeneralOptimizationEditorProperty();
newEdit[l].name = list[l].getStringRepresentation();
@ -250,7 +246,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
((GenericObjectEditor) newEdit[l].editor).setClassType(InterfaceCrossover.class);
}
newEdit[l].editor.setValue(newEdit[l].value);
newEdit[l].editor.addPropertyChangeListener(m_self);
newEdit[l].editor.addPropertyChangeListener(self);
AbstractObjectEditor.findViewFor(newEdit[l]);
if (newEdit[l].view != null) {
newEdit[l].view.repaint();
@ -258,7 +254,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
} catch (Exception e) {
System.out.println("Darn can't read the value...");
}
m_Editors = newEdit;
editors = newEdit;
updateTargetList();
}
};
@ -269,17 +265,17 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
ActionListener deleteTarget = new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
int l = m_CrossoversWithWeights.getSelectedCrossers().length, j = 0;
int l = crossoverMixer.getSelectedCrossers().length, j = 0;
GeneralOptimizationEditorProperty[] newEdit = new GeneralOptimizationEditorProperty[l - 1];
for (int i = 0; i < m_Delete.length; i++) {
if (event.getSource().equals(m_Delete[i])) {
m_CrossoversWithWeights.removeCrosser(i);
for (int i = 0; i < deleteButtons.length; i++) {
if (event.getSource().equals(deleteButtons[i])) {
crossoverMixer.removeCrosser(i);
} else {
newEdit[j] = m_Editors[i];
newEdit[j] = editors[i];
j++;
}
}
m_Editors = newEdit;
editors = newEdit;
updateTargetList();
}
};
@ -290,7 +286,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
ActionListener normalizeWeights = new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
m_CrossoversWithWeights.normalizeWeights();
crossoverMixer.normalizeWeights();
updateTargetList();
}
};
@ -309,18 +305,18 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
@Override
public void keyReleased(KeyEvent event) {
double[] newW = m_CrossoversWithWeights.getWeights();
double[] newW = crossoverMixer.getWeights();
for (int i = 0; i < newW.length; i++) {
try {
double d = 0;
d = new Double(m_Weights[i].getText()).doubleValue();
d = new Double(weights[i].getText()).doubleValue();
newW[i] = d;
} catch (Exception e) {
}
}
m_CrossoversWithWeights.setWeights(newW);
crossoverMixer.setWeights(newW);
}
};
@ -328,13 +324,13 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
* The object may have changed update the editor.
*/
private void updateEditor() {
if (this.m_Editor != null) {
this.m_TargetList.validate();
this.m_TargetList.repaint();
this.m_ScrollTargets.validate();
this.m_ScrollTargets.repaint();
this.m_Editor.validate();
this.m_Editor.repaint();
if (this.editor != null) {
this.targetList.validate();
this.targetList.repaint();
this.scrollTargets.validate();
this.scrollTargets.repaint();
this.editor.validate();
this.editor.repaint();
}
}
@ -346,7 +342,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
@Override
public void setValue(Object o) {
if (o instanceof PropertyCrossoverMixer) {
this.m_CrossoversWithWeights = (PropertyCrossoverMixer) o;
this.crossoverMixer = (PropertyCrossoverMixer) o;
this.updateEditor();
}
}
@ -358,7 +354,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
*/
@Override
public Object getValue() {
return this.m_CrossoversWithWeights;
return this.crossoverMixer;
}
@Override
@ -396,7 +392,6 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
* @param a The action listener.
*/
public void addOkListener(ActionListener a) {
//m_OKButton.addActionListener(a);
}
/**
@ -405,7 +400,6 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
* @param a The action listener
*/
public void removeOkListener(ActionListener a) {
//m_OKButton.removeActionListener(a);
}
/**
@ -449,11 +443,11 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
*/
@Override
public Component getCustomEditor() {
if (this.m_Component == null) {
if (this.component == null) {
this.initCustomEditor();
this.m_Component = new GeneralGEOFaker((PropertyEditor) this, (JPanel) this.m_Editor);
this.component = new GeneralGEOFaker((PropertyEditor) this, (JPanel) this.editor);
}
return this.m_Component;
return this.component;
}
/**
@ -471,18 +465,18 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
@Override
public void addPropertyChangeListener(PropertyChangeListener l) {
if (m_Support == null) {
m_Support = new PropertyChangeSupport(this);
if (propertyChangeSupport == null) {
propertyChangeSupport = new PropertyChangeSupport(this);
}
m_Support.addPropertyChangeListener(l);
propertyChangeSupport.addPropertyChangeListener(l);
}
@Override
public void removePropertyChangeListener(PropertyChangeListener l) {
if (m_Support == null) {
m_Support = new PropertyChangeSupport(this);
if (propertyChangeSupport == null) {
propertyChangeSupport = new PropertyChangeSupport(this);
}
m_Support.removePropertyChangeListener(l);
propertyChangeSupport.removePropertyChangeListener(l);
}
/**
@ -495,35 +489,34 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
public void propertyChange(PropertyChangeEvent evt) {
Object newVal = evt.getNewValue();
Object oldVal = evt.getOldValue();
InterfaceCrossover[] list = this.m_CrossoversWithWeights.getSelectedCrossers();
InterfaceCrossover[] list = this.crossoverMixer.getSelectedCrossers();
for (int i = 0; i < list.length; i++) {
if (oldVal.equals(list[i])) {
list[i] = (InterfaceCrossover) newVal;
this.m_Editors[i].name = list[i].getStringRepresentation();
this.editors[i].name = list[i].getStringRepresentation();
try {
this.m_Editors[i].value = list[i];
this.m_Editors[i].editor = PropertyEditorProvider.findEditor(this.m_Editors[i].value.getClass());
if (this.m_Editors[i].editor == null) {
this.m_Editors[i].editor = PropertyEditorProvider.findEditor(InterfaceCrossover.class);
this.editors[i].value = list[i];
this.editors[i].editor = PropertyEditorProvider.findEditor(this.editors[i].value.getClass());
if (this.editors[i].editor == null) {
this.editors[i].editor = PropertyEditorProvider.findEditor(InterfaceCrossover.class);
}
if (this.m_Editors[i].editor instanceof GenericObjectEditor) {
((GenericObjectEditor) this.m_Editors[i].editor).setClassType(InterfaceCrossover.class);
if (this.editors[i].editor instanceof GenericObjectEditor) {
((GenericObjectEditor) this.editors[i].editor).setClassType(InterfaceCrossover.class);
}
this.m_Editors[i].editor.setValue(this.m_Editors[i].value);
this.m_Editors[i].editor.addPropertyChangeListener(this);
AbstractObjectEditor.findViewFor(this.m_Editors[i]);
if (this.m_Editors[i].view != null) {
this.m_Editors[i].view.repaint();
this.editors[i].editor.setValue(this.editors[i].value);
this.editors[i].editor.addPropertyChangeListener(this);
AbstractObjectEditor.findViewFor(this.editors[i]);
if (this.editors[i].view != null) {
this.editors[i].view.repaint();
}
} catch (Exception e) {
System.out.println("Darn can't read the value...");
}
this.m_Targets[i] = this.m_Editors[i].view;
this.targets[i] = this.editors[i].view;
i = list.length;
}
}
//this.m_OptimizationTargets.setSelectedTargets(list);
this.updateCenterComponent(evt); // Let our panel update before guys downstream
m_Support.firePropertyChange("", m_CrossoversWithWeights, m_CrossoversWithWeights);
propertyChangeSupport.firePropertyChange("", crossoverMixer, crossoverMixer);
}
}

View File

@ -25,108 +25,107 @@ import java.awt.event.WindowEvent;
* To change this template use Options | File Templates.
*/
public class TestESCrossover implements java.io.Serializable {
private JFrame m_Frame;
private JPanel m_MainPanel, m_GraphPanel, m_ButtonPanel;
private JComponent m_OptionsPanel;
private JButton m_InitButton, m_Init2Button, m_Init3Button, m_CrossButton;
private JFrame frame;
private JPanel mainPanel, buttonPanel;
private JComponent optionsPanel;
private JButton initButton, init2Button, init3Button, crossButton;
private InterfaceOptimizationProblem m_Problem = new F1Problem();
private InterfaceCrossover m_Crossover = new CrossoverESUNDX();
private Population m_Partners;
private AbstractEAIndividual m_Daddy;
private AbstractEAIndividual[] m_OffSprings;
private InterfaceOptimizationProblem optimizationProblem = new F1Problem();
private InterfaceCrossover crossover = new CrossoverESUNDX();
private Population partners;
private AbstractEAIndividual daddy;
private int m_NumberOfCrossovers = 100;
private int m_Dimension = 2;
private int m_NumberOfPartners = 1;
private int numberOfCrossovers = 100;
private int dimension = 2;
private int numberOfPartners = 1;
double[] pff;
private Plot m_Plot;
private Plot plot;
private void initFrame() {
// init the main frame
this.m_Frame = new JFrame();
this.m_Frame.setTitle("ES Crossover Tester");
this.m_Frame.setSize(300, 400);
this.m_Frame.setLocation(530, 50);
this.m_Frame.addWindowListener(new WindowAdapter() {
this.frame = new JFrame();
this.frame.setTitle("ES Crossover Tester");
this.frame.setSize(300, 400);
this.frame.setLocation(530, 50);
this.frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent ev) {
System.exit(0);
}
});
// build the main panel
this.m_MainPanel = new JPanel();
this.m_Frame.getContentPane().add(this.m_MainPanel);
this.m_MainPanel.setLayout(new BorderLayout());
this.mainPanel = new JPanel();
this.frame.getContentPane().add(this.mainPanel);
this.mainPanel.setLayout(new BorderLayout());
// build the button panel
this.m_ButtonPanel = new JPanel();
this.m_InitButton = new JButton("Init");
this.m_InitButton.addActionListener(this.initListener);
this.m_InitButton.setEnabled(true);
this.m_Init2Button = new JButton("Init 2");
this.m_Init2Button.addActionListener(this.init2Listener);
this.m_Init2Button.setEnabled(true);
this.m_Init3Button = new JButton("Init 3");
this.m_Init3Button.addActionListener(this.init3Listener);
this.m_Init3Button.setEnabled(true);
this.m_CrossButton = new JButton("X");
this.m_CrossButton.addActionListener(this.XListener);
this.m_CrossButton.setEnabled(true);
this.m_ButtonPanel.add(this.m_InitButton);
this.m_ButtonPanel.add(this.m_Init2Button);
this.m_ButtonPanel.add(this.m_Init3Button);
this.m_ButtonPanel.add(this.m_CrossButton);
this.m_MainPanel.add(this.m_ButtonPanel, BorderLayout.NORTH);
this.buttonPanel = new JPanel();
this.initButton = new JButton("Init");
this.initButton.addActionListener(this.initListener);
this.initButton.setEnabled(true);
this.init2Button = new JButton("Init 2");
this.init2Button.addActionListener(this.init2Listener);
this.init2Button.setEnabled(true);
this.init3Button = new JButton("Init 3");
this.init3Button.addActionListener(this.init3Listener);
this.init3Button.setEnabled(true);
this.crossButton = new JButton("X");
this.crossButton.addActionListener(this.XListener);
this.crossButton.setEnabled(true);
this.buttonPanel.add(this.initButton);
this.buttonPanel.add(this.init2Button);
this.buttonPanel.add(this.init3Button);
this.buttonPanel.add(this.crossButton);
this.mainPanel.add(this.buttonPanel, BorderLayout.NORTH);
// build the Options Panel
this.m_OptionsPanel = (new JParaPanel(this, "MyGUI").makePanel());
this.m_MainPanel.add(this.m_OptionsPanel, BorderLayout.CENTER);
this.optionsPanel = (new JParaPanel(this, "MyGUI").makePanel());
this.mainPanel.add(this.optionsPanel, BorderLayout.CENTER);
// The plot frame
double[] tmpD = new double[2];
tmpD[0] = 0;
tmpD[1] = 0;
// ToDo: Fix plot (it's internal and not showing)
this.m_Plot = new Plot("ES Crossover Tester", "x", "y", tmpD, tmpD);
this.plot = new Plot("ES Crossover Tester", "x", "y", tmpD, tmpD);
// validate and show
this.m_Frame.validate();
this.m_Frame.setVisible(true);
this.frame.validate();
this.frame.setVisible(true);
}
ActionListener initListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
m_Partners = new Population();
m_Partners.setTargetSize(m_NumberOfPartners);
m_Partners.clear();
partners = new Population();
partners.setTargetSize(numberOfPartners);
partners.clear();
InterfaceDataTypeDouble tmpIndyD = new ESIndividualDoubleData();
AbstractEAIndividual tmpIndyEA;
double[][] newRange = new double[m_Dimension][2];
for (int i = 0; i < m_Dimension; i++) {
double[][] newRange = new double[dimension][2];
for (int i = 0; i < dimension; i++) {
newRange[i][0] = -2;
newRange[i][1] = 2;
}
tmpIndyD.setDoubleDataLength(m_Dimension);
tmpIndyD.setDoubleDataLength(dimension);
tmpIndyD.setDoubleRange(newRange);
for (int i = 0; i < m_Partners.getTargetSize(); i++) {
for (int i = 0; i < partners.getTargetSize(); i++) {
tmpIndyEA = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
tmpIndyEA.init(m_Problem);
m_Partners.add(tmpIndyEA);
tmpIndyEA.init(optimizationProblem);
partners.add(tmpIndyEA);
}
m_Partners.init();
m_Daddy = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
m_Daddy.init(m_Problem);
m_Plot.clearAll();
m_Plot.setUnconnectedPoint(-2, -2, 0);
m_Plot.setUnconnectedPoint(2, 2, 0);
partners.init();
daddy = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
daddy.init(optimizationProblem);
plot.clearAll();
plot.setUnconnectedPoint(-2, -2, 0);
plot.setUnconnectedPoint(2, 2, 0);
double[] x;
x = ((InterfaceDataTypeDouble) m_Daddy).getDoubleData();
m_Plot.setUnconnectedPoint(x[0], x[1], 0);
for (int i = 0; i < m_Partners.size(); i++) {
x = ((InterfaceDataTypeDouble) m_Partners.get(i)).getDoubleData();
m_Plot.setUnconnectedPoint(x[0], x[1], 0);
m_Plot.setUnconnectedPoint(x[0], x[1], 0);
x = ((InterfaceDataTypeDouble) daddy).getDoubleData();
plot.setUnconnectedPoint(x[0], x[1], 0);
for (int i = 0; i < partners.size(); i++) {
x = ((InterfaceDataTypeDouble) partners.get(i)).getDoubleData();
plot.setUnconnectedPoint(x[0], x[1], 0);
plot.setUnconnectedPoint(x[0], x[1], 0);
pff = x;
}
}
@ -135,42 +134,42 @@ public class TestESCrossover implements java.io.Serializable {
ActionListener init2Listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
m_Partners = new Population();
m_Partners.setTargetSize(2);
m_Partners.clear();
partners = new Population();
partners.setTargetSize(2);
partners.clear();
InterfaceDataTypeDouble tmpIndyD = new ESIndividualDoubleData();
AbstractEAIndividual tmpIndyEA;
double[][] newRange = new double[m_Dimension][2];
for (int i = 0; i < m_Dimension; i++) {
double[][] newRange = new double[dimension][2];
for (int i = 0; i < dimension; i++) {
newRange[i][0] = -2;
newRange[i][1] = 2;
}
tmpIndyD.setDoubleDataLength(m_Dimension);
tmpIndyD.setDoubleDataLength(dimension);
tmpIndyD.setDoubleRange(newRange);
double[] tmpD = new double[2];
tmpD[0] = 1;
tmpD[1] = 1;
((AbstractEAIndividual) tmpIndyD).initByValue(tmpD, m_Problem);
((AbstractEAIndividual) tmpIndyD).initByValue(tmpD, optimizationProblem);
tmpIndyEA = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
tmpD = new double[2];
tmpD[0] = -1;
tmpD[1] = -1;
((AbstractEAIndividual) tmpIndyEA).initByValue(tmpD, m_Problem);
m_Partners.addIndividual(tmpIndyEA);
((AbstractEAIndividual) tmpIndyEA).initByValue(tmpD, optimizationProblem);
partners.addIndividual(tmpIndyEA);
m_Daddy = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
m_Plot.clearAll();
m_Plot.setUnconnectedPoint(-2, -2, 0);
m_Plot.setUnconnectedPoint(2, 2, 0);
daddy = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
plot.clearAll();
plot.setUnconnectedPoint(-2, -2, 0);
plot.setUnconnectedPoint(2, 2, 0);
double[] x;
x = ((InterfaceDataTypeDouble) m_Daddy).getDoubleData();
m_Plot.setUnconnectedPoint(x[0], x[1], 0);
for (int i = 0; i < m_Partners.size(); i++) {
x = ((InterfaceDataTypeDouble) m_Partners.get(i)).getDoubleData();
m_Plot.setUnconnectedPoint(x[0], x[1], 0);
m_Plot.setUnconnectedPoint(x[0], x[1], 0);
x = ((InterfaceDataTypeDouble) daddy).getDoubleData();
plot.setUnconnectedPoint(x[0], x[1], 0);
for (int i = 0; i < partners.size(); i++) {
x = ((InterfaceDataTypeDouble) partners.get(i)).getDoubleData();
plot.setUnconnectedPoint(x[0], x[1], 0);
plot.setUnconnectedPoint(x[0], x[1], 0);
pff = x;
}
}
@ -179,48 +178,48 @@ public class TestESCrossover implements java.io.Serializable {
ActionListener init3Listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
m_Partners = new Population();
m_Partners.setTargetSize(3);
m_Partners.clear();
partners = new Population();
partners.setTargetSize(3);
partners.clear();
InterfaceDataTypeDouble tmpIndyD = new ESIndividualDoubleData();
AbstractEAIndividual tmpIndyEA;
double[][] newRange = new double[m_Dimension][2];
for (int i = 0; i < m_Dimension; i++) {
double[][] newRange = new double[dimension][2];
for (int i = 0; i < dimension; i++) {
newRange[i][0] = -2;
newRange[i][1] = 2;
}
tmpIndyD.setDoubleDataLength(m_Dimension);
tmpIndyD.setDoubleDataLength(dimension);
tmpIndyD.setDoubleRange(newRange);
double[] tmpD = new double[2];
tmpD[0] = 0.5;
tmpD[1] = 1.1;
((AbstractEAIndividual) tmpIndyD).initByValue(tmpD, m_Problem);
((AbstractEAIndividual) tmpIndyD).initByValue(tmpD, optimizationProblem);
tmpIndyEA = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
tmpD = new double[2];
tmpD[0] = 0.1;
tmpD[1] = -0.65;
((AbstractEAIndividual) tmpIndyEA).initByValue(tmpD, m_Problem);
m_Partners.addIndividual(tmpIndyEA);
((AbstractEAIndividual) tmpIndyEA).initByValue(tmpD, optimizationProblem);
partners.addIndividual(tmpIndyEA);
tmpIndyEA = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
tmpD = new double[2];
tmpD[0] = -0.85;
tmpD[1] = 0.3;
((AbstractEAIndividual) tmpIndyEA).initByValue(tmpD, m_Problem);
m_Partners.addIndividual(tmpIndyEA);
((AbstractEAIndividual) tmpIndyEA).initByValue(tmpD, optimizationProblem);
partners.addIndividual(tmpIndyEA);
m_Daddy = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
m_Plot.clearAll();
m_Plot.setUnconnectedPoint(-2, -2, 2);
m_Plot.setUnconnectedPoint(2, 2, 2);
daddy = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
plot.clearAll();
plot.setUnconnectedPoint(-2, -2, 2);
plot.setUnconnectedPoint(2, 2, 2);
double[] x;
x = ((InterfaceDataTypeDouble) m_Daddy).getDoubleData();
m_Plot.setUnconnectedPoint(x[0], x[1], 0);
for (int i = 0; i < m_Partners.size(); i++) {
x = ((InterfaceDataTypeDouble) m_Partners.get(i)).getDoubleData();
m_Plot.setUnconnectedPoint(x[0], x[1], 1);
m_Plot.setUnconnectedPoint(x[0], x[1], 1);
x = ((InterfaceDataTypeDouble) daddy).getDoubleData();
plot.setUnconnectedPoint(x[0], x[1], 0);
for (int i = 0; i < partners.size(); i++) {
x = ((InterfaceDataTypeDouble) partners.get(i)).getDoubleData();
plot.setUnconnectedPoint(x[0], x[1], 1);
plot.setUnconnectedPoint(x[0], x[1], 1);
pff = x;
}
}
@ -231,13 +230,13 @@ public class TestESCrossover implements java.io.Serializable {
public void actionPerformed(ActionEvent event) {
double[] x;
AbstractEAIndividual[] result;
for (int i = 0; i < m_NumberOfCrossovers; i++) {
result = m_Crossover.mate(m_Daddy, m_Partners);
for (int i = 0; i < numberOfCrossovers; i++) {
result = crossover.mate(daddy, partners);
for (int j = 0; j < result.length; j++) {
x = ((InterfaceDataTypeDouble) result[j]).getDoubleData();
m_Plot.setUnconnectedPoint(x[0], x[1], 0);
m_Plot.setUnconnectedPoint(pff[0], pff[1], 1);
m_Plot.setUnconnectedPoint(2, 2, 2);
plot.setUnconnectedPoint(x[0], x[1], 0);
plot.setUnconnectedPoint(pff[0], pff[1], 1);
plot.setUnconnectedPoint(2, 2, 2);
}
}
}
@ -255,11 +254,11 @@ public class TestESCrossover implements java.io.Serializable {
}
public void setCrossover(InterfaceCrossover NumberOfCrossovers) {
this.m_Crossover = NumberOfCrossovers;
this.crossover = NumberOfCrossovers;
}
public InterfaceCrossover getCrossover() {
return this.m_Crossover;
return this.crossover;
}
public String crossoverTipText() {
@ -267,11 +266,11 @@ public class TestESCrossover implements java.io.Serializable {
}
public void setNumberOfCrossovers(int NumberOfCrossovers) {
this.m_NumberOfCrossovers = NumberOfCrossovers;
this.numberOfCrossovers = NumberOfCrossovers;
}
public int getNumberOfCrossovers() {
return this.m_NumberOfCrossovers;
return this.numberOfCrossovers;
}
public String numberOfCrossoversTipText() {
@ -279,11 +278,11 @@ public class TestESCrossover implements java.io.Serializable {
}
public void setNumberOfPartners(int NumberOfCrossovers) {
this.m_NumberOfPartners = NumberOfCrossovers;
this.numberOfPartners = NumberOfCrossovers;
}
public int getNumberOfPartners() {
return this.m_NumberOfPartners;
return this.numberOfPartners;
}
public String numberOfPartnersTipText() {

View File

@ -8,15 +8,10 @@ import eva2.optimization.population.Population;
/**
* The fitness modifier are defunct and are to be moved to
* the selection operators...
* Created by IntelliJ IDEA.
* User: streiche
* Date: 30.03.2004
* Time: 17:51:45
* To change this template use File | Settings | File Templates.
*/
public class FitnessAdaptiveClustering implements java.io.Serializable, InterfaceFitnessModifier {
private InterfaceClustering m_ClusteringAlgorithm = new ClusteringDensityBased();
private InterfaceClustering clusteringAlgorithm = new ClusteringDensityBased();
/**
* This method allows you to modify the fitness of the individuals
@ -49,9 +44,9 @@ public class FitnessAdaptiveClustering implements java.io.Serializable, Interfac
// also note that if all individual achieve equal fitness the sum will be zero
result[i] = data[i][x] - min + 0.1;
}
this.m_ClusteringAlgorithm.initClustering(population);
this.clusteringAlgorithm.initClustering(population);
// Now search for clusters
Population[] ClusterResult = this.m_ClusteringAlgorithm.cluster(population, population);
Population[] ClusterResult = this.clusteringAlgorithm.cluster(population, population);
Population cluster;
for (int i = 1; i < ClusterResult.length; i++) {
cluster = ClusterResult[i];
@ -85,11 +80,11 @@ public class FitnessAdaptiveClustering implements java.io.Serializable, Interfac
* @return The current clustering method
*/
public InterfaceClustering getClusteringAlgorithm() {
return this.m_ClusteringAlgorithm;
return this.clusteringAlgorithm;
}
public void setClusteringAlgorithm(InterfaceClustering b) {
this.m_ClusteringAlgorithm = b;
this.clusteringAlgorithm = b;
}
public String clusteringAlgorithmTipText() {

View File

@ -8,16 +8,11 @@ import eva2.optimization.population.Population;
/**
* The fitness modifier are defunct and are to be moved to
* the selection operators...
* Created by IntelliJ IDEA.
* User: streiche
* Date: 30.03.2004
* Time: 17:46:22
* To change this template use File | Settings | File Templates.
*/
public class FitnessSharing implements java.io.Serializable, InterfaceFitnessModifier {
private double m_SharingDistance = 0.05;
private InterfaceDistanceMetric m_Metric = new PhenotypeMetric();
private double sharingDistance = 0.05;
private InterfaceDistanceMetric distanceMetric = new PhenotypeMetric();
/**
* This method allows you to modify the fitness of the individuals
@ -56,8 +51,8 @@ public class FitnessSharing implements java.io.Serializable, InterfaceFitnessMod
tmpIndy = (AbstractEAIndividual) population.get(i);
fitnessSharing = 0;
for (int j = 0; j < population.size(); j++) {
if (this.m_SharingDistance < this.m_Metric.distance(tmpIndy, (AbstractEAIndividual) population.get(j))) {
fitnessSharing += 1 - (this.m_Metric.distance(tmpIndy, (AbstractEAIndividual) population.get(j)) / this.m_SharingDistance);
if (this.sharingDistance < this.distanceMetric.distance(tmpIndy, (AbstractEAIndividual) population.get(j))) {
fitnessSharing += 1 - (this.distanceMetric.distance(tmpIndy, (AbstractEAIndividual) population.get(j)) / this.sharingDistance);
}
}
result[i] /= fitnessSharing;
@ -87,11 +82,11 @@ public class FitnessSharing implements java.io.Serializable, InterfaceFitnessMod
* @param SharingDistance
*/
public void setSharingDistance(double SharingDistance) {
this.m_SharingDistance = SharingDistance;
this.sharingDistance = SharingDistance;
}
public double getSharingDistance() {
return this.m_SharingDistance;
return this.sharingDistance;
}
public String sharingDistanceTipText() {
@ -104,11 +99,11 @@ public class FitnessSharing implements java.io.Serializable, InterfaceFitnessMod
* @param Metric
*/
public void setMetric(InterfaceDistanceMetric Metric) {
this.m_Metric = Metric;
this.distanceMetric = Metric;
}
public InterfaceDistanceMetric getMetric() {
return this.m_Metric;
return this.distanceMetric;
}
public String metricTipText() {