Removed m_ notation from classes in eva2.optimization.individuals

This commit is contained in:
Fabian Becker 2014-01-28 20:52:29 +01:00
parent 53b5111df7
commit 41f58bb2f9
35 changed files with 753 additions and 852 deletions

View File

@ -17,34 +17,34 @@ import java.util.BitSet;
@eva2.util.annotation.Description(value = "This is an ES individual adopted to optimize binary values.") @eva2.util.annotation.Description(value = "This is an ES individual adopted to optimize binary values.")
public class ESIndividualBinaryData extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypeBinary, java.io.Serializable { public class ESIndividualBinaryData extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypeBinary, java.io.Serializable {
private BitSet m_Phenotype = new BitSet(); private BitSet phenotype = new BitSet();
private double[] m_Genotype; private double[] genotype;
private boolean m_UseHardSwitch = false; private boolean useHardSwitch = false;
private double[][] m_Range; private double[][] initializationRange;
public ESIndividualBinaryData() { public ESIndividualBinaryData() {
this.mutationProbability = 1.0; this.mutationProbability = 1.0;
this.mutationOperator = new MutateESGlobal(); this.mutationOperator = new MutateESGlobal();
this.crossoverProbability = 0.5; this.crossoverProbability = 0.5;
this.crossoverOperator = new CrossoverESDefault(); this.crossoverOperator = new CrossoverESDefault();
this.m_Genotype = new double[1]; this.genotype = new double[1];
this.m_Range = new double[1][2]; this.initializationRange = new double[1][2];
this.m_Range[0][0] = 0; this.initializationRange[0][0] = 0;
this.m_Range[0][1] = 1; this.initializationRange[0][1] = 1;
} }
public ESIndividualBinaryData(ESIndividualBinaryData individual) { public ESIndividualBinaryData(ESIndividualBinaryData individual) {
if (individual.m_Phenotype != null) { if (individual.phenotype != null) {
this.m_Phenotype = (BitSet) individual.m_Phenotype.clone(); this.phenotype = (BitSet) individual.phenotype.clone();
} }
this.m_Genotype = new double[individual.m_Genotype.length]; this.genotype = new double[individual.genotype.length];
this.m_Range = new double[individual.m_Genotype.length][2]; this.initializationRange = new double[individual.genotype.length][2];
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
this.m_Genotype[i] = individual.m_Genotype[i]; this.genotype[i] = individual.genotype[i];
this.m_Range[i][0] = individual.m_Range[i][0]; this.initializationRange[i][0] = individual.initializationRange[i][0];
this.m_Range[i][1] = individual.m_Range[i][1]; this.initializationRange[i][1] = individual.initializationRange[i][1];
} }
this.m_UseHardSwitch = individual.m_UseHardSwitch; this.useHardSwitch = individual.useHardSwitch;
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
this.age = individual.age; this.age = individual.age;
@ -78,20 +78,20 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof ESIndividualBinaryData) { if (individual instanceof ESIndividualBinaryData) {
ESIndividualBinaryData indy = (ESIndividualBinaryData) individual; ESIndividualBinaryData indy = (ESIndividualBinaryData) individual;
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) { if ((this.genotype == null) || (indy.genotype == null)) {
return false; return false;
} }
if ((this.m_Range == null) || (indy.m_Range == null)) { if ((this.initializationRange == null) || (indy.initializationRange == null)) {
return false; return false;
} }
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
if (this.m_Genotype[i] != indy.m_Genotype[i]) { if (this.genotype[i] != indy.genotype[i]) {
return false; return false;
} }
if (this.m_Range[i][0] != indy.m_Range[i][0]) { if (this.initializationRange[i][0] != indy.initializationRange[i][0]) {
return false; return false;
} }
if (this.m_Range[i][1] != indy.m_Range[i][1]) { if (this.initializationRange[i][1] != indy.initializationRange[i][1]) {
return false; return false;
} }
} }
@ -111,11 +111,11 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void setBinaryDataLength(int length) { public void setBinaryDataLength(int length) {
this.m_Genotype = new double[length]; this.genotype = new double[length];
this.m_Range = new double[length][2]; this.initializationRange = new double[length][2];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
this.m_Range[i][0] = 0; this.initializationRange[i][0] = 0;
this.m_Range[i][1] = 1; this.initializationRange[i][1] = 1;
} }
} }
@ -126,7 +126,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public int size() { public int size() {
return this.m_Genotype.length; return this.genotype.length;
} }
/** /**
@ -136,26 +136,26 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public BitSet getBinaryData() { public BitSet getBinaryData() {
if (this.m_UseHardSwitch) { if (this.useHardSwitch) {
// In this case it is only tested if the genotyp is bigger than 0.5 // In this case it is only tested if the genotyp is bigger than 0.5
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
if (this.m_Genotype[i] > 0.5) { if (this.genotype[i] > 0.5) {
this.m_Phenotype.set(i); this.phenotype.set(i);
} else { } else {
this.m_Phenotype.clear(i); this.phenotype.clear(i);
} }
} }
} else { } else {
// in this case the value of the genotype is interpreted as a probability // in this case the value of the genotype is interpreted as a probability
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
if (RNG.flipCoin(this.m_Genotype[i])) { if (RNG.flipCoin(this.genotype[i])) {
this.m_Phenotype.set(i); this.phenotype.set(i);
} else { } else {
this.m_Phenotype.clear(i); this.phenotype.clear(i);
} }
} }
} }
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -166,7 +166,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public BitSet getBinaryDataWithoutUpdate() { public BitSet getBinaryDataWithoutUpdate() {
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -176,7 +176,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void setBinaryPhenotype(BitSet binaryData) { public void setBinaryPhenotype(BitSet binaryData) {
this.m_Phenotype = binaryData; this.phenotype = binaryData;
} }
/** /**
@ -188,26 +188,23 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
@Override @Override
public void setBinaryGenotype(BitSet binaryData) { public void setBinaryGenotype(BitSet binaryData) {
this.setBinaryPhenotype(binaryData); this.setBinaryPhenotype(binaryData);
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
if (this.m_UseHardSwitch) { if (this.useHardSwitch) {
if (binaryData.get(i)) { if (binaryData.get(i)) {
this.m_Genotype[i] = RNG.randomDouble(0.55, 1.0); this.genotype[i] = RNG.randomDouble(0.55, 1.0);
} else { } else {
this.m_Genotype[i] = RNG.randomDouble(0.0, 0.45); this.genotype[i] = RNG.randomDouble(0.0, 0.45);
} }
} else { } else {
if (binaryData.get(i)) { if (binaryData.get(i)) {
this.m_Genotype[i] = 0.9; this.genotype[i] = 0.9;
} else { } else {
this.m_Genotype[i] = 0.1; this.genotype[i] = 0.1;
} }
} }
} }
} }
/************************************************************************************
* AbstractEAIndividual methods
*/
/** /**
* This method will init the individual with a given value for the * This method will init the individual with a given value for the
* phenotype. * phenotype.
@ -248,17 +245,13 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
} }
result += "})\n Value: "; result += "})\n Value: ";
result += "["; result += "[";
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
result += this.m_Genotype[i] + "; "; result += this.genotype[i] + "; ";
} }
result += "]"; result += "]";
return result; return result;
} }
/************************************************************************************
* InterfaceESIndividual methods
*/
/** /**
* This method will allow the user to read the ES 'genotype' * This method will allow the user to read the ES 'genotype'
* *
@ -266,7 +259,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public double[] getDGenotype() { public double[] getDGenotype() {
return this.m_Genotype; return this.genotype;
} }
/** /**
@ -276,34 +269,26 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void setDGenotype(double[] b) { public void setDGenotype(double[] b) {
this.m_Genotype = b; this.genotype = b;
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
if (this.m_Genotype[i] < this.m_Range[i][0]) { if (this.genotype[i] < this.initializationRange[i][0]) {
this.m_Genotype[i] = this.m_Range[1][0]; this.genotype[i] = this.initializationRange[1][0];
} }
if (this.m_Genotype[i] > this.m_Range[i][1]) { if (this.genotype[i] > this.initializationRange[i][1]) {
this.m_Genotype[i] = this.m_Range[1][1]; this.genotype[i] = this.initializationRange[1][1];
} }
} }
} }
// /** This method will set the range of the double attributes. If range.length
// * does not equal doubledata.length only range[i] will be used to set all
// * ranges.
// * @param range The new range for the double data.
// */
// public void setDoubleRange(double[][] range) {
// this.m_Range = range;
// }
/** /**
* This method will return the range for all double attributes. * This method will return the range for all double attributes.
* *
* @return The range array. * @return The initializationRange array.
*/ */
@Override @Override
public double[][] getDoubleRange() { public double[][] getDoubleRange() {
return this.m_Range; return this.initializationRange;
} }
/** /**
@ -311,15 +296,15 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
ESIndividualDoubleData.defaultMutate(m_Genotype, m_Range); ESIndividualDoubleData.defaultMutate(genotype, initializationRange);
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) { if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
ESIndividualDoubleData.defaultInit(m_Genotype, (double[][]) ((InterfaceHasInitRange) prob).getInitRange()); ESIndividualDoubleData.defaultInit(genotype, (double[][]) ((InterfaceHasInitRange) prob).getInitRange());
} else { } else {
ESIndividualDoubleData.defaultInit(m_Genotype, m_Range); ESIndividualDoubleData.defaultInit(genotype, initializationRange);
} }
} }
/********************************************************************************************************************** /**********************************************************************************************************************
@ -343,11 +328,11 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
* @param b the Switch. * @param b the Switch.
*/ */
public void setToggleInterpretation(boolean b) { public void setToggleInterpretation(boolean b) {
this.m_UseHardSwitch = b; this.useHardSwitch = b;
} }
public boolean getToggleInterpretation() { public boolean getToggleInterpretation() {
return this.m_UseHardSwitch; return this.useHardSwitch;
} }
public String toggleInterpretationTipText() { public String toggleInterpretationTipText() {

View File

@ -137,14 +137,6 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
this.genotype = newDesPa; this.genotype = newDesPa;
this.range = newRange; this.range = newRange;
this.phenotype = null; // mark as invalid this.phenotype = null; // mark as invalid
// changed 28.08.03 by request of Spieth
// this.m_DecisionParameters = new double[length];
// this.range = new double[length][2];
// for (int i = 0; i < this.range.length; i++) {
// this.range[i][0] = -10;
// this.range[i][1] = 10;
// }
} }
/** /**

View File

@ -15,9 +15,9 @@ import eva2.util.annotation.Description;
@Description(value = "This is an ES individual suited to optimize permutations.") @Description(value = "This is an ES individual suited to optimize permutations.")
public class ESIndividualPermutationData extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypePermutation, java.io.Serializable { public class ESIndividualPermutationData extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypePermutation, java.io.Serializable {
private double[][] m_Genotype; private double[][] genotype;
private int[][] m_Phenotype; private int[][] phenotype;
private double[][][] m_Range; private double[][][] initializationRange;
private int[] firstindex; private int[] firstindex;
@ -26,34 +26,34 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
this.mutationOperator = new MutateESGlobal(); this.mutationOperator = new MutateESGlobal();
this.crossoverProbability = 0.5; this.crossoverProbability = 0.5;
this.crossoverOperator = new CrossoverESDefault(); this.crossoverOperator = new CrossoverESDefault();
this.m_Genotype = new double[1][1]; this.genotype = new double[1][1];
this.m_Range = new double[1][1][2]; this.initializationRange = new double[1][1][2];
this.m_Range[0][0][0] = 0; this.initializationRange[0][0][0] = 0;
this.m_Range[0][0][1] = 1; this.initializationRange[0][0][1] = 1;
this.firstindex = new int[]{0}; this.firstindex = new int[]{0};
} }
public ESIndividualPermutationData(ESIndividualPermutationData individual) { public ESIndividualPermutationData(ESIndividualPermutationData individual) {
if (individual.m_Phenotype != null) { if (individual.phenotype != null) {
this.m_Phenotype = new int[individual.m_Phenotype.length][]; this.phenotype = new int[individual.phenotype.length][];
for (int i = 0; i < m_Phenotype.length; i++) { for (int i = 0; i < phenotype.length; i++) {
this.m_Phenotype[i] = new int[individual.m_Phenotype[i].length]; this.phenotype[i] = new int[individual.phenotype[i].length];
System.arraycopy(individual.m_Phenotype[i], 0, this.m_Phenotype[i], 0, this.m_Phenotype[i].length); System.arraycopy(individual.phenotype[i], 0, this.phenotype[i], 0, this.phenotype[i].length);
} }
} }
this.firstindex = individual.firstindex; this.firstindex = individual.firstindex;
this.m_Genotype = new double[individual.m_Genotype.length][]; this.genotype = new double[individual.genotype.length][];
this.m_Range = new double[individual.m_Genotype.length][][]; this.initializationRange = new double[individual.genotype.length][][];
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
// if (individual.phenotype != null) { // if (individual.phenotype != null) {
this.m_Genotype[i] = new double[individual.m_Genotype[i].length]; this.genotype[i] = new double[individual.genotype[i].length];
this.m_Range[i] = new double[individual.m_Genotype[i].length][2]; this.initializationRange[i] = new double[individual.genotype[i].length][2];
for (int j = 0; j < this.m_Genotype[i].length; j++) { for (int j = 0; j < this.genotype[i].length; j++) {
this.m_Genotype[i][j] = individual.m_Genotype[i][j]; this.genotype[i][j] = individual.genotype[i][j];
this.m_Range[i][j][0] = individual.m_Range[i][j][0]; this.initializationRange[i][j][0] = individual.initializationRange[i][j][0];
this.m_Range[i][j][1] = individual.m_Range[i][j][1]; this.initializationRange[i][j][1] = individual.initializationRange[i][j][1];
// } // }
} }
} }
@ -91,23 +91,23 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof ESIndividualPermutationData) { if (individual instanceof ESIndividualPermutationData) {
ESIndividualPermutationData indy = (ESIndividualPermutationData) individual; ESIndividualPermutationData indy = (ESIndividualPermutationData) individual;
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) { if ((this.genotype == null) || (indy.genotype == null)) {
return false; return false;
} }
if ((this.m_Range == null) || (indy.m_Range == null)) { if ((this.initializationRange == null) || (indy.initializationRange == null)) {
return false; return false;
} }
if (this.m_Range.length != indy.m_Range.length) { if (this.initializationRange.length != indy.initializationRange.length) {
return false; return false;
} }
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
if (this.m_Genotype[i] != indy.m_Genotype[i]) { if (this.genotype[i] != indy.genotype[i]) {
return false; return false;
} }
if (this.m_Range[i][0] != indy.m_Range[i][0]) { if (this.initializationRange[i][0] != indy.initializationRange[i][0]) {
return false; return false;
} }
if (this.m_Range[i][1] != indy.m_Range[i][1]) { if (this.initializationRange[i][1] != indy.initializationRange[i][1]) {
return false; return false;
} }
} }
@ -125,40 +125,40 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
@Override @Override
public void setPermutationDataLength(int[] length) { public void setPermutationDataLength(int[] length) {
this.m_Genotype = new double[length.length][]; this.genotype = new double[length.length][];
this.m_Range = new double[length.length][][]; this.initializationRange = new double[length.length][][];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
this.m_Genotype[i] = new double[length[i]]; this.genotype[i] = new double[length[i]];
} }
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
this.m_Range[i] = new double[length[i]][2]; this.initializationRange[i] = new double[length[i]][2];
for (int j = 0; j < this.m_Range[i].length; j++) { for (int j = 0; j < this.initializationRange[i].length; j++) {
this.m_Range[i][j][0] = 0; this.initializationRange[i][j][0] = 0;
this.m_Range[i][j][1] = 1; this.initializationRange[i][j][1] = 1;
} }
} }
} }
@Override @Override
public int[] sizePermutation() { public int[] sizePermutation() {
int[] res = new int[m_Genotype.length]; int[] res = new int[genotype.length];
for (int i = 0; i < m_Genotype.length; i++) { for (int i = 0; i < genotype.length; i++) {
res[i] = m_Genotype[i].length; res[i] = genotype[i].length;
} }
return res; return res;
} }
@Override @Override
public void setPermutationPhenotype(int[][] perm) { public void setPermutationPhenotype(int[][] perm) {
this.m_Phenotype = perm; this.phenotype = perm;
this.m_Range = new double[perm.length][][]; this.initializationRange = new double[perm.length][][];
for (int i = 0; i < perm.length; i++) { for (int i = 0; i < perm.length; i++) {
this.m_Range[i] = new double[perm[i].length][2]; this.initializationRange[i] = new double[perm[i].length][2];
for (int j = 0; j < this.m_Range[i].length; j++) { for (int j = 0; j < this.initializationRange[i].length; j++) {
this.m_Range[i][j][0] = 0; this.initializationRange[i][j][0] = 0;
this.m_Range[i][j][1] = 1; this.initializationRange[i][j][1] = 1;
} }
} }
@ -168,12 +168,12 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
public void setPermutationGenotype(int[][] perm) { public void setPermutationGenotype(int[][] perm) {
this.setPermutationPhenotype(perm); this.setPermutationPhenotype(perm);
this.m_Genotype = new double[perm.length][]; this.genotype = new double[perm.length][];
this.m_Range = new double[perm.length][][]; this.initializationRange = new double[perm.length][][];
for (int p = 0; p < perm.length; p++) { for (int p = 0; p < perm.length; p++) {
int biggest = Integer.MIN_VALUE; int biggest = Integer.MIN_VALUE;
int smallest = Integer.MAX_VALUE; int smallest = Integer.MAX_VALUE;
this.m_Range[p] = new double[perm[p].length][2]; this.initializationRange[p] = new double[perm[p].length][2];
for (int i = 0; i < perm[p].length; i++) { for (int i = 0; i < perm[p].length; i++) {
if (perm[p][i] > biggest) { if (perm[p][i] > biggest) {
biggest = perm[p][i]; biggest = perm[p][i];
@ -181,11 +181,11 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
if (perm[p][i] < smallest) { if (perm[p][i] < smallest) {
smallest = perm[p][i]; smallest = perm[p][i];
} }
this.m_Range[p][i][0] = 0; this.initializationRange[p][i][0] = 0;
this.m_Range[p][i][1] = 1; this.initializationRange[p][i][1] = 1;
} }
for (int i = 0; i < this.m_Genotype[p].length; i++) { for (int i = 0; i < this.genotype[p].length; i++) {
this.m_Genotype[p][i] = (perm[p][i] - smallest) / (double) biggest; this.genotype[p][i] = (perm[p][i] - smallest) / (double) biggest;
} }
} }
@ -194,31 +194,31 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
@Override @Override
public int[][] getPermutationData() { public int[][] getPermutationData() {
this.m_Phenotype = new int[this.m_Genotype.length][]; this.phenotype = new int[this.genotype.length][];
for (int p = 0; p < m_Genotype.length; p++) { for (int p = 0; p < genotype.length; p++) {
this.m_Phenotype[p] = new int[m_Genotype[p].length]; this.phenotype[p] = new int[genotype[p].length];
boolean notValid = true; boolean notValid = true;
while (notValid) { while (notValid) {
notValid = false; notValid = false;
for (int i = 0; i < this.m_Genotype[p].length; i++) { for (int i = 0; i < this.genotype[p].length; i++) {
for (int j = 0; j < this.m_Genotype[p].length; j++) { for (int j = 0; j < this.genotype[p].length; j++) {
if ((i != j) && (this.m_Genotype[p][i] == this.m_Genotype[p][j])) { if ((i != j) && (this.genotype[p][i] == this.genotype[p][j])) {
notValid = true; notValid = true;
this.m_Genotype[p][j] = RNG.randomDouble(0, 1); this.genotype[p][j] = RNG.randomDouble(0, 1);
} }
} }
} }
} }
for (int i = 0; i < this.m_Genotype[p].length; i++) { for (int i = 0; i < this.genotype[p].length; i++) {
for (int j = 0; j < this.m_Genotype[p].length; j++) { for (int j = 0; j < this.genotype[p].length; j++) {
if (this.m_Genotype[p][i] > this.m_Genotype[p][j]) { if (this.genotype[p][i] > this.genotype[p][j]) {
this.m_Phenotype[p][i]++; this.phenotype[p][i]++;
} }
} }
} }
} }
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -229,7 +229,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
*/ */
@Override @Override
public int[][] getPermutationDataWithoutUpdate() { public int[][] getPermutationDataWithoutUpdate() {
return this.m_Phenotype; return this.phenotype;
} }
public int[] getFirstindex() { public int[] getFirstindex() {
@ -256,7 +256,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof int[][]) { if (obj instanceof int[][]) {
int[][] bs = (int[][]) obj; int[][] bs = (int[][]) obj;
if (bs.length != this.m_Genotype.length) { if (bs.length != this.genotype.length) {
System.out.println("Init value and requested length doesn't match!"); System.out.println("Init value and requested length doesn't match!");
} }
this.setPermutationGenotype(bs); this.setPermutationGenotype(bs);
@ -288,8 +288,8 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
} }
result += "})\n Value: "; result += "})\n Value: ";
result += "["; result += "[";
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
result += this.m_Genotype[i] + "; "; result += this.genotype[i] + "; ";
} }
result += "]"; result += "]";
return result; return result;
@ -305,7 +305,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
*/ */
@Override @Override
public double[] getDGenotype() { public double[] getDGenotype() {
return mapMatrixToVector(m_Genotype); return mapMatrixToVector(genotype);
} }
@ -346,14 +346,14 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
*/ */
@Override @Override
public void setDGenotype(double[] b) { public void setDGenotype(double[] b) {
this.m_Genotype = mapVectorToMatrix(b, this.sizePermutation()); this.genotype = mapVectorToMatrix(b, this.sizePermutation());
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
for (int j = 0; j < this.m_Genotype[i].length; j++) { for (int j = 0; j < this.genotype[i].length; j++) {
if (this.m_Genotype[i][j] < this.m_Range[i][j][0]) { if (this.genotype[i][j] < this.initializationRange[i][j][0]) {
this.m_Genotype[i][j] = this.m_Range[i][j][0]; this.genotype[i][j] = this.initializationRange[i][j][0];
} }
if (this.m_Genotype[i][j] > this.m_Range[i][j][1]) { if (this.genotype[i][j] > this.initializationRange[i][j][1]) {
this.m_Genotype[i][j] = this.m_Range[i][j][1]; this.genotype[i][j] = this.initializationRange[i][j][1];
} }
} }
} }
@ -366,20 +366,20 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
for (int i = 0; i < m_Genotype.length; i++) { for (int i = 0; i < genotype.length; i++) {
ESIndividualDoubleData.defaultMutate(m_Genotype[i], m_Range[i]); ESIndividualDoubleData.defaultMutate(genotype[i], initializationRange[i]);
} }
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
double[][][] range = m_Range; double[][][] range = initializationRange;
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) { if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
range = (double[][][]) ((InterfaceHasInitRange) prob).getInitRange(); range = (double[][][]) ((InterfaceHasInitRange) prob).getInitRange();
} }
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
ESIndividualDoubleData.defaultInit(m_Genotype[i], range[i]); ESIndividualDoubleData.defaultInit(genotype[i], range[i]);
} }
} }
@ -391,15 +391,15 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
@Override @Override
public double[][] getDoubleRange() { public double[][] getDoubleRange() {
int sumentries = 0; int sumentries = 0;
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
sumentries += this.m_Range[i].length; sumentries += this.initializationRange[i].length;
} }
double[][] res = new double[sumentries][2]; double[][] res = new double[sumentries][2];
int counter = 0; int counter = 0;
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
for (int j = 0; j < this.m_Range[i].length; j++) { for (int j = 0; j < this.initializationRange[i].length; j++) {
res[counter][0] = this.m_Range[i][j][0]; res[counter][0] = this.initializationRange[i][j][0];
res[counter][1] = this.m_Range[i][j][1]; res[counter][1] = this.initializationRange[i][j][1];
counter++; counter++;
} }
} }

View File

@ -15,19 +15,19 @@ import java.util.BitSet;
@Description(value = "This is a mixed data type combining a BitSet and a real-valued vector.") @Description(value = "This is a mixed data type combining a BitSet and a real-valued vector.")
public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual implements InterfaceDataTypeBinary, InterfaceDataTypeDouble, java.io.Serializable { public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual implements InterfaceDataTypeBinary, InterfaceDataTypeDouble, java.io.Serializable {
private InterfaceDataTypeDouble m_Numbers = new ESIndividualDoubleData(); private InterfaceDataTypeDouble doubleIndividual = new ESIndividualDoubleData();
private InterfaceDataTypeBinary m_BitSet = new GAIndividualBinaryData(); private InterfaceDataTypeBinary binaryIndividual = new GAIndividualBinaryData();
public GAESIndividualBinaryDoubleData() { public GAESIndividualBinaryDoubleData() {
this.mutationProbability = 1.0; this.mutationProbability = 1.0;
this.crossoverProbability = 1.0; this.crossoverProbability = 1.0;
this.m_Numbers = new GAIndividualDoubleData(); this.doubleIndividual = new GAIndividualDoubleData();
this.m_BitSet = new GAIndividualBinaryData(); this.binaryIndividual = new GAIndividualBinaryData();
} }
public GAESIndividualBinaryDoubleData(GAESIndividualBinaryDoubleData individual) { public GAESIndividualBinaryDoubleData(GAESIndividualBinaryDoubleData individual) {
this.m_Numbers = (InterfaceDataTypeDouble) ((AbstractEAIndividual) individual.getNumbers()).clone(); this.doubleIndividual = (InterfaceDataTypeDouble) ((AbstractEAIndividual) individual.getNumbers()).clone();
this.m_BitSet = (InterfaceDataTypeBinary) ((AbstractEAIndividual) individual.getBitSet()).clone(); this.binaryIndividual = (InterfaceDataTypeBinary) ((AbstractEAIndividual) individual.getBitSet()).clone();
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
this.age = individual.age; this.age = individual.age;
@ -61,10 +61,10 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof GAESIndividualBinaryDoubleData) { if (individual instanceof GAESIndividualBinaryDoubleData) {
GAESIndividualBinaryDoubleData indy = (GAESIndividualBinaryDoubleData) individual; GAESIndividualBinaryDoubleData indy = (GAESIndividualBinaryDoubleData) individual;
if (!((AbstractEAIndividual) this.m_Numbers).equalGenotypes((AbstractEAIndividual) indy.m_Numbers)) { if (!((AbstractEAIndividual) this.doubleIndividual).equalGenotypes((AbstractEAIndividual) indy.doubleIndividual)) {
return false; return false;
} }
if (!((AbstractEAIndividual) this.m_BitSet).equalGenotypes((AbstractEAIndividual) indy.m_BitSet)) { if (!((AbstractEAIndividual) this.binaryIndividual).equalGenotypes((AbstractEAIndividual) indy.binaryIndividual)) {
return false; return false;
} }
return true; return true;
@ -80,14 +80,14 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public void init(InterfaceOptimizationProblem opt) { public void init(InterfaceOptimizationProblem opt) {
((AbstractEAIndividual) this.m_Numbers).init(opt); ((AbstractEAIndividual) this.doubleIndividual).init(opt);
((AbstractEAIndividual) this.m_BitSet).init(opt); ((AbstractEAIndividual) this.binaryIndividual).init(opt);
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
((AbstractEAIndividual) this.m_Numbers).defaultInit(prob); ((AbstractEAIndividual) this.doubleIndividual).defaultInit(prob);
((AbstractEAIndividual) this.m_BitSet).defaultInit(prob); ((AbstractEAIndividual) this.binaryIndividual).defaultInit(prob);
} }
/** /**
@ -101,15 +101,15 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof Object[]) { if (obj instanceof Object[]) {
if (((Object[]) obj)[0] instanceof double[]) { if (((Object[]) obj)[0] instanceof double[]) {
((AbstractEAIndividual) this.m_Numbers).initByValue(((Object[]) obj)[0], opt); ((AbstractEAIndividual) this.doubleIndividual).initByValue(((Object[]) obj)[0], opt);
((AbstractEAIndividual) this.m_BitSet).initByValue(((Object[]) obj)[1], opt); ((AbstractEAIndividual) this.binaryIndividual).initByValue(((Object[]) obj)[1], opt);
} else { } else {
((AbstractEAIndividual) this.m_Numbers).initByValue(((Object[]) obj)[1], opt); ((AbstractEAIndividual) this.doubleIndividual).initByValue(((Object[]) obj)[1], opt);
((AbstractEAIndividual) this.m_BitSet).initByValue(((Object[]) obj)[0], opt); ((AbstractEAIndividual) this.binaryIndividual).initByValue(((Object[]) obj)[0], opt);
} }
} else { } else {
((AbstractEAIndividual) this.m_Numbers).init(opt); ((AbstractEAIndividual) this.doubleIndividual).init(opt);
((AbstractEAIndividual) this.m_BitSet).init(opt); ((AbstractEAIndividual) this.binaryIndividual).init(opt);
System.out.println("Initial value for GAESIndividualDoubleData is not suitable!"); System.out.println("Initial value for GAESIndividualDoubleData is not suitable!");
} }
} }
@ -120,17 +120,17 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
@Override @Override
public void mutate() { public void mutate() {
if (RNG.flipCoin(this.mutationProbability)) { if (RNG.flipCoin(this.mutationProbability)) {
((AbstractEAIndividual) this.m_Numbers).mutate(); ((AbstractEAIndividual) this.doubleIndividual).mutate();
} }
if (RNG.flipCoin(this.mutationProbability)) { if (RNG.flipCoin(this.mutationProbability)) {
((AbstractEAIndividual) this.m_BitSet).mutate(); ((AbstractEAIndividual) this.binaryIndividual).mutate();
} }
} }
@Override @Override
public void defaultMutate() { public void defaultMutate() {
((AbstractEAIndividual) this.m_Numbers).defaultMutate(); ((AbstractEAIndividual) this.doubleIndividual).defaultMutate();
((AbstractEAIndividual) this.m_BitSet).defaultMutate(); ((AbstractEAIndividual) this.binaryIndividual).defaultMutate();
} }
/** /**
@ -173,7 +173,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
((GAESIndividualBinaryDoubleData) result[i]).setBitSet((InterfaceDataTypeBinary) resBin[i]); ((GAESIndividualBinaryDoubleData) result[i]).setBitSet((InterfaceDataTypeBinary) resBin[i]);
} }
// result = ((AbstractEAIndividual)this.m_Numbers).mateWith(partners); // result = ((AbstractEAIndividual)this.doubleIndividual).mateWith(partners);
// AbstractEAIndividual dad = (AbstractEAIndividual)result[0]; // AbstractEAIndividual dad = (AbstractEAIndividual)result[0];
// Population tpartners = new Population(); // Population tpartners = new Population();
// for (int i = 1; i < result.length; i++) tpartners.add(result[i]); // for (int i = 1; i < result.length; i++) tpartners.add(result[i]);
@ -206,8 +206,8 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
@Override @Override
public String getStringRepresentation() { public String getStringRepresentation() {
String result = "This is a hybrid Individual:\n"; String result = "This is a hybrid Individual:\n";
result += "The Numbers Part:\n" + ((AbstractEAIndividual) this.m_Numbers).getStringRepresentation(); result += "The Numbers Part:\n" + ((AbstractEAIndividual) this.doubleIndividual).getStringRepresentation();
result += "\nThe Binarys Part:\n" + ((AbstractEAIndividual) this.m_BitSet).getStringRepresentation(); result += "\nThe Binarys Part:\n" + ((AbstractEAIndividual) this.binaryIndividual).getStringRepresentation();
return result; return result;
} }
@ -221,8 +221,8 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public void setDoubleDataLength(int length) { public void setDoubleDataLength(int length) {
this.m_Numbers.setDoubleDataLength(length); this.doubleIndividual.setDoubleDataLength(length);
this.m_BitSet.setBinaryDataLength(length); this.binaryIndividual.setBinaryDataLength(length);
} }
/** /**
@ -232,7 +232,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public int size() { public int size() {
return this.m_Numbers.size(); return this.doubleIndividual.size();
} }
/** /**
@ -244,7 +244,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public void setDoubleRange(double[][] range) { public void setDoubleRange(double[][] range) {
this.m_Numbers.setDoubleRange(range); this.doubleIndividual.setDoubleRange(range);
} }
/** /**
@ -254,7 +254,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public double[][] getDoubleRange() { public double[][] getDoubleRange() {
return this.m_Numbers.getDoubleRange(); return this.doubleIndividual.getDoubleRange();
} }
/** /**
@ -264,7 +264,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public double[] getDoubleData() { public double[] getDoubleData() {
return this.m_Numbers.getDoubleData(); return this.doubleIndividual.getDoubleData();
} }
/** /**
@ -275,7 +275,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public double[] getDoubleDataWithoutUpdate() { public double[] getDoubleDataWithoutUpdate() {
return this.m_Numbers.getDoubleDataWithoutUpdate(); return this.doubleIndividual.getDoubleDataWithoutUpdate();
} }
/** /**
@ -286,7 +286,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public void setDoublePhenotype(double[] doubleData) { public void setDoublePhenotype(double[] doubleData) {
this.m_Numbers.setDoublePhenotype(doubleData); this.doubleIndividual.setDoublePhenotype(doubleData);
} }
/** /**
@ -298,7 +298,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public void setDoubleGenotype(double[] doubleData) { public void setDoubleGenotype(double[] doubleData) {
this.m_Numbers.setDoubleGenotype(doubleData); this.doubleIndividual.setDoubleGenotype(doubleData);
} }
/** /**
@ -311,8 +311,8 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public void setBinaryDataLength(int length) { public void setBinaryDataLength(int length) {
this.m_Numbers.setDoubleDataLength(length); this.doubleIndividual.setDoubleDataLength(length);
this.m_BitSet.setBinaryDataLength(length); this.binaryIndividual.setBinaryDataLength(length);
} }
/** /**
@ -321,7 +321,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
* @return The number of bits stored * @return The number of bits stored
*/ */
public int GetBinaryDataLength() { public int GetBinaryDataLength() {
return this.m_BitSet.size(); return this.binaryIndividual.size();
} }
/** /**
@ -331,7 +331,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public BitSet getBinaryData() { public BitSet getBinaryData() {
return this.m_BitSet.getBinaryData(); return this.binaryIndividual.getBinaryData();
} }
/** /**
@ -342,7 +342,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public BitSet getBinaryDataWithoutUpdate() { public BitSet getBinaryDataWithoutUpdate() {
return this.m_BitSet.getBinaryDataWithoutUpdate(); return this.binaryIndividual.getBinaryDataWithoutUpdate();
} }
/** /**
@ -353,7 +353,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public void setBinaryPhenotype(BitSet binaryData) { public void setBinaryPhenotype(BitSet binaryData) {
this.m_BitSet.setBinaryPhenotype(binaryData); this.binaryIndividual.setBinaryPhenotype(binaryData);
} }
/** /**
@ -365,7 +365,7 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
*/ */
@Override @Override
public void setBinaryGenotype(BitSet binaryData) { public void setBinaryGenotype(BitSet binaryData) {
this.m_BitSet.setBinaryGenotype(binaryData); this.binaryIndividual.setBinaryGenotype(binaryData);
} }
/********************************************************************************************************************** /**********************************************************************************************************************
@ -388,11 +388,11 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
* @param Numbers The new representation for the inner constants. * @param Numbers The new representation for the inner constants.
*/ */
public void setNumbers(InterfaceDataTypeDouble Numbers) { public void setNumbers(InterfaceDataTypeDouble Numbers) {
this.m_Numbers = Numbers; this.doubleIndividual = Numbers;
} }
public InterfaceDataTypeDouble getNumbers() { public InterfaceDataTypeDouble getNumbers() {
return this.m_Numbers; return this.doubleIndividual;
} }
public String numbersTipText() { public String numbersTipText() {
@ -405,11 +405,11 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
* @param BitSet The new representation for the inner constants. * @param BitSet The new representation for the inner constants.
*/ */
public void setBitSet(InterfaceDataTypeBinary BitSet) { public void setBitSet(InterfaceDataTypeBinary BitSet) {
this.m_BitSet = BitSet; this.binaryIndividual = BitSet;
} }
public InterfaceDataTypeBinary getBitSet() { public InterfaceDataTypeBinary getBitSet() {
return this.m_BitSet; return this.binaryIndividual;
} }
public String bitSetTipText() { public String bitSetTipText() {

View File

@ -17,17 +17,17 @@ import java.util.BitSet;
@Description(value = "This is a GA individual suited to optimize binary values.") @Description(value = "This is a GA individual suited to optimize binary values.")
public class GAIndividualBinaryData extends AbstractEAIndividual implements InterfaceDataTypeBinary, InterfaceGAIndividual, java.io.Serializable { public class GAIndividualBinaryData extends AbstractEAIndividual implements InterfaceDataTypeBinary, InterfaceGAIndividual, java.io.Serializable {
protected BitSet m_Genotype = new BitSet(); protected BitSet genotype = new BitSet();
protected BitSet m_Phenotype = new BitSet(); protected BitSet phenotype = new BitSet();
protected int m_GenotypeLength; protected int genotypeLength;
public GAIndividualBinaryData() { public GAIndividualBinaryData() {
this.mutationProbability = 0.1; this.mutationProbability = 0.1;
this.mutationOperator = new MutateGANBit(); this.mutationOperator = new MutateGANBit();
this.crossoverProbability = 1.0; this.crossoverProbability = 1.0;
this.crossoverOperator = new CrossoverGAGINPoint(); this.crossoverOperator = new CrossoverGAGINPoint();
this.m_GenotypeLength = 20; this.genotypeLength = 20;
this.m_Genotype = new BitSet(); this.genotype = new BitSet();
} }
public GAIndividualBinaryData(int genotypeLen) { public GAIndividualBinaryData(int genotypeLen) {
@ -36,12 +36,12 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
} }
public GAIndividualBinaryData(GAIndividualBinaryData individual) { public GAIndividualBinaryData(GAIndividualBinaryData individual) {
if (individual.m_Phenotype != null) { if (individual.phenotype != null) {
this.m_Phenotype = (BitSet) individual.m_Phenotype.clone(); this.phenotype = (BitSet) individual.phenotype.clone();
} }
this.m_GenotypeLength = individual.m_GenotypeLength; this.genotypeLength = individual.genotypeLength;
if (individual.m_Genotype != null) { if (individual.genotype != null) {
this.m_Genotype = (BitSet) individual.m_Genotype.clone(); this.genotype = (BitSet) individual.genotype.clone();
} }
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
@ -76,13 +76,13 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof GAIndividualBinaryData) { if (individual instanceof GAIndividualBinaryData) {
GAIndividualBinaryData indy = (GAIndividualBinaryData) individual; GAIndividualBinaryData indy = (GAIndividualBinaryData) individual;
if (this.m_GenotypeLength != indy.m_GenotypeLength) { if (this.genotypeLength != indy.genotypeLength) {
return false; return false;
} }
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) { if ((this.genotype == null) || (indy.genotype == null)) {
return false; return false;
} }
if (!this.m_Genotype.equals(indy.m_Genotype)) { if (!this.genotype.equals(indy.genotype)) {
return false; return false;
} }
return true; return true;
@ -99,8 +99,8 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
public double defaultEvaulateAsMiniBits() { public double defaultEvaulateAsMiniBits() {
double result = 0; double result = 0;
for (int i = 0; i < this.m_GenotypeLength; i++) { for (int i = 0; i < this.genotypeLength; i++) {
if (this.m_Genotype.get(i)) { if (this.genotype.get(i)) {
result++; result++;
} }
} }
@ -162,11 +162,11 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
} }
result += "})\n Value: "; result += "})\n Value: ";
result += "{"; result += "{";
for (int i = 0; i < this.m_GenotypeLength; i++) { for (int i = 0; i < this.genotypeLength; i++) {
if (i % 8 == 0) { if (i % 8 == 0) {
result += "|"; result += "|";
} }
if (this.m_Genotype.get(i)) { if (this.genotype.get(i)) {
result += "1"; result += "1";
} else { } else {
result += "0"; result += "0";
@ -184,7 +184,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public BitSet getBGenotype() { public BitSet getBGenotype() {
return this.m_Genotype; return this.genotype;
} }
/** /**
@ -195,7 +195,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void setBGenotype(BitSet binaryData) { public void setBGenotype(BitSet binaryData) {
this.m_Genotype = binaryData; this.genotype = binaryData;
} }
/** /**
@ -207,16 +207,16 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public int getGenotypeLength() { public int getGenotypeLength() {
return this.m_GenotypeLength; return this.genotypeLength;
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
for (int i = 0; i < this.m_GenotypeLength; i++) { for (int i = 0; i < this.genotypeLength; i++) {
if (RNG.flipCoin(0.5)) { if (RNG.flipCoin(0.5)) {
this.m_Genotype.set(i); this.genotype.set(i);
} else { } else {
this.m_Genotype.clear(i); this.genotype.clear(i);
} }
} }
} }
@ -226,12 +226,12 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
int mutationIndex = RNG.randomInt(0, this.m_GenotypeLength); int mutationIndex = RNG.randomInt(0, this.genotypeLength);
//if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor()); //if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor());
if (this.m_Genotype.get(mutationIndex)) { if (this.genotype.get(mutationIndex)) {
this.m_Genotype.clear(mutationIndex); this.genotype.clear(mutationIndex);
} else { } else {
this.m_Genotype.set(mutationIndex); this.genotype.set(mutationIndex);
} }
//if (mutationIndex > 28) System.out.println(this.getSolutionRepresentationFor()); //if (mutationIndex > 28) System.out.println(this.getSolutionRepresentationFor());
} }
@ -246,7 +246,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void setBinaryDataLength(int length) { public void setBinaryDataLength(int length) {
this.m_GenotypeLength = length; this.genotypeLength = length;
} }
/** /**
@ -256,7 +256,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public int size() { public int size() {
return this.m_GenotypeLength; return this.genotypeLength;
} }
/** /**
@ -266,8 +266,8 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public BitSet getBinaryData() { public BitSet getBinaryData() {
this.m_Phenotype = (BitSet) this.m_Genotype.clone(); this.phenotype = (BitSet) this.genotype.clone();
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -278,7 +278,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public BitSet getBinaryDataWithoutUpdate() { public BitSet getBinaryDataWithoutUpdate() {
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -288,7 +288,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void setBinaryPhenotype(BitSet binaryData) { public void setBinaryPhenotype(BitSet binaryData) {
this.m_Phenotype = binaryData; this.phenotype = binaryData;
} }
/** /**
@ -300,7 +300,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
@Override @Override
public void setBinaryGenotype(BitSet binaryData) { public void setBinaryGenotype(BitSet binaryData) {
this.setBinaryPhenotype(binaryData); this.setBinaryPhenotype(binaryData);
this.m_Genotype = (BitSet) binaryData.clone(); this.genotype = (BitSet) binaryData.clone();
} }
/** /**

View File

@ -20,36 +20,36 @@ import java.util.BitSet;
@Description(value = "This is a GA individual suited to optimize double values.") @Description(value = "This is a GA individual suited to optimize double values.")
public class GAIndividualDoubleData extends AbstractEAIndividual implements InterfaceGAIndividual, InterfaceDataTypeDouble, java.io.Serializable { public class GAIndividualDoubleData extends AbstractEAIndividual implements InterfaceGAIndividual, InterfaceDataTypeDouble, java.io.Serializable {
private double[] m_Phenotype; private double[] phenotype;
private double[][] m_Range; private double[][] initializationRange;
protected BitSet genotype; protected BitSet genotype;
protected int genotypeLength; protected int genotypeLength;
private int m_Precision = 32; private int precision = 32;
private InterfaceGADoubleCoding m_DoubleCoding = new GAStandardCodingDouble(); private InterfaceGADoubleCoding doubleCoding = new GAStandardCodingDouble();
public GAIndividualDoubleData() { public GAIndividualDoubleData() {
this.mutationProbability = 0.1; this.mutationProbability = 0.1;
this.mutationOperator = new MutateGAUniform(); this.mutationOperator = new MutateGAUniform();
this.crossoverProbability = 0.7; this.crossoverProbability = 0.7;
this.crossoverOperator = new CrossoverGAGINPoint(); this.crossoverOperator = new CrossoverGAGINPoint();
this.m_Range = new double[1][2]; this.initializationRange = new double[1][2];
this.m_Range[0][0] = -10; this.initializationRange[0][0] = -10;
this.m_Range[0][1] = 10; this.initializationRange[0][1] = 10;
this.genotypeLength = this.m_Precision; this.genotypeLength = this.precision;
this.genotype = new BitSet(); this.genotype = new BitSet();
} }
public GAIndividualDoubleData(GAIndividualDoubleData individual) { public GAIndividualDoubleData(GAIndividualDoubleData individual) {
if (individual.m_Phenotype != null) { if (individual.phenotype != null) {
this.m_Phenotype = new double[individual.m_Phenotype.length]; this.phenotype = new double[individual.phenotype.length];
System.arraycopy(individual.m_Phenotype, 0, this.m_Phenotype, 0, this.m_Phenotype.length); System.arraycopy(individual.phenotype, 0, this.phenotype, 0, this.phenotype.length);
} }
this.genotypeLength = individual.genotypeLength; this.genotypeLength = individual.genotypeLength;
this.genotype = (BitSet) individual.genotype.clone(); this.genotype = (BitSet) individual.genotype.clone();
this.m_Range = new double[individual.m_Range.length][2]; this.initializationRange = new double[individual.initializationRange.length][2];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
this.m_Range[i][0] = individual.m_Range[i][0]; this.initializationRange[i][0] = individual.initializationRange[i][0];
this.m_Range[i][1] = individual.m_Range[i][1]; this.initializationRange[i][1] = individual.initializationRange[i][1];
} }
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
@ -62,8 +62,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
for (int i = 0; i < this.selectionProbability.length; i++) { for (int i = 0; i < this.selectionProbability.length; i++) {
this.selectionProbability[i] = individual.selectionProbability[i]; this.selectionProbability[i] = individual.selectionProbability[i];
} }
this.m_Precision = individual.m_Precision; this.precision = individual.precision;
this.m_DoubleCoding = individual.m_DoubleCoding; this.doubleCoding = individual.doubleCoding;
this.fitness = new double[individual.fitness.length]; this.fitness = new double[individual.fitness.length];
for (int i = 0; i < this.fitness.length; i++) { for (int i = 0; i < this.fitness.length; i++) {
this.fitness[i] = individual.fitness[i]; this.fitness[i] = individual.fitness[i];
@ -96,11 +96,11 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
if (!this.genotype.equals(indy.genotype)) { if (!this.genotype.equals(indy.genotype)) {
return false; return false;
} }
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
if (this.m_Range[i][0] != indy.m_Range[i][0]) { if (this.initializationRange[i][0] != indy.initializationRange[i][0]) {
return false; return false;
} }
if (this.m_Range[i][1] != indy.m_Range[i][1]) { if (this.initializationRange[i][1] != indy.initializationRange[i][1]) {
return false; return false;
} }
} }
@ -124,26 +124,18 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
double[][] newRange = new double[length][2]; double[][] newRange = new double[length][2];
// copy the old values for the decision parameters and the range // copy the old values for the decision parameters and the range
for (int i = 0; ((i < newDesPa.length) && (i < this.m_Range.length)); i++) { for (int i = 0; ((i < newDesPa.length) && (i < this.initializationRange.length)); i++) {
newRange[i][0] = this.m_Range[i][0]; newRange[i][0] = this.initializationRange[i][0];
newRange[i][1] = this.m_Range[i][1]; newRange[i][1] = this.initializationRange[i][1];
} }
// if the new length is bigger than the last value fills the extra elements // if the new length is bigger than the last value fills the extra elements
for (int i = this.m_Range.length; (i < newDesPa.length); i++) { for (int i = this.initializationRange.length; (i < newDesPa.length); i++) {
newRange[i][0] = this.m_Range[this.m_Range.length - 1][0]; newRange[i][0] = this.initializationRange[this.initializationRange.length - 1][0];
newRange[i][1] = this.m_Range[this.m_Range.length - 1][1]; newRange[i][1] = this.initializationRange[this.initializationRange.length - 1][1];
} }
this.m_Range = newRange; this.initializationRange = newRange;
this.genotypeLength = length * this.m_Precision; this.genotypeLength = length * this.precision;
// changed 28.08.03 by request of Spieth
// this.m_DecisionParameters = new double[length];
// this.m_Range = new double[length][2];
// for (int i = 0; i < this.m_Range.length; i++) {
// this.m_Range[i][0] = -10;
// this.m_Range[i][1] = 10;
// }
} }
/** /**
@ -153,7 +145,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public int size() { public int size() {
return this.m_Range.length; return this.initializationRange.length;
} }
/** /**
@ -165,13 +157,13 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void setDoubleRange(double[][] range) { public void setDoubleRange(double[][] range) {
if (range.length != this.m_Range.length) { if (range.length != this.initializationRange.length) {
System.out.println("Warning: Trying to set a range of length " + range.length + " to a vector of length " System.out.println("Warning: Trying to set a range of length " + range.length + " to a vector of length "
+ this.m_Range.length + "!\n Use method setDoubleDataLength first!"); + this.initializationRange.length + "!\n Use method setDoubleDataLength first!");
} }
for (int i = 0; ((i < this.m_Range.length) && (i < range.length)); i++) { for (int i = 0; ((i < this.initializationRange.length) && (i < range.length)); i++) {
this.m_Range[i][0] = range[i][0]; this.initializationRange[i][0] = range[i][0];
this.m_Range[i][1] = range[i][1]; this.initializationRange[i][1] = range[i][1];
} }
} }
@ -182,7 +174,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public double[][] getDoubleRange() { public double[][] getDoubleRange() {
return this.m_Range; return this.initializationRange;
} }
/** /**
@ -193,13 +185,13 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
@Override @Override
public double[] getDoubleData() { public double[] getDoubleData() {
int[] locus = new int[2]; int[] locus = new int[2];
this.m_Phenotype = new double[this.m_Range.length]; this.phenotype = new double[this.initializationRange.length];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
locus[0] = i * this.m_Precision; locus[0] = i * this.precision;
locus[1] = this.m_Precision; locus[1] = this.precision;
this.m_Phenotype[i] = this.m_DoubleCoding.decodeValue(this.genotype, this.m_Range[i], locus, false); this.phenotype[i] = this.doubleCoding.decodeValue(this.genotype, this.initializationRange[i], locus, false);
} }
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -210,7 +202,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public double[] getDoubleDataWithoutUpdate() { public double[] getDoubleDataWithoutUpdate() {
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -221,7 +213,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public void setDoublePhenotype(double[] doubleData) { public void setDoublePhenotype(double[] doubleData) {
this.m_Phenotype = doubleData; this.phenotype = doubleData;
} }
/** /**
@ -235,9 +227,9 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
this.setDoublePhenotype(doubleData); this.setDoublePhenotype(doubleData);
int[] locus = new int[2]; int[] locus = new int[2];
for (int i = 0; i < doubleData.length; i++) { for (int i = 0; i < doubleData.length; i++) {
locus[0] = i * this.m_Precision; locus[0] = i * this.precision;
locus[1] = this.m_Precision; locus[1] = this.precision;
this.m_DoubleCoding.codeValue(doubleData[i], this.m_Range[i], this.genotype, locus); this.doubleCoding.codeValue(doubleData[i], this.initializationRange[i], this.genotype, locus);
} }
} }
@ -256,7 +248,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof double[]) { if (obj instanceof double[]) {
double[] bs = (double[]) obj; double[] bs = (double[]) obj;
if (bs.length != this.m_Range.length) { if (bs.length != this.initializationRange.length) {
System.out.println("Init value and requested length doesn't match!"); System.out.println("Init value and requested length doesn't match!");
} }
this.setDoubleGenotype(bs); this.setDoubleGenotype(bs);
@ -386,11 +378,11 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param coding The used genotype coding method * @param coding The used genotype coding method
*/ */
public void setGACoding(InterfaceGADoubleCoding coding) { public void setGACoding(InterfaceGADoubleCoding coding) {
this.m_DoubleCoding = coding; this.doubleCoding = coding;
} }
public InterfaceGADoubleCoding getGACoding() { public InterfaceGADoubleCoding getGACoding() {
return this.m_DoubleCoding; return this.doubleCoding;
} }
public String gADoubleCodingTipText() { public String gADoubleCodingTipText() {
@ -404,11 +396,11 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param precision The number of multiruns that are to be performed * @param precision The number of multiruns that are to be performed
*/ */
public void setPrecision(int precision) { public void setPrecision(int precision) {
this.m_Precision = precision; this.precision = precision;
} }
public int getPrecision() { public int getPrecision() {
return this.m_Precision; return this.precision;
} }
public String precisionTipText() { public String precisionTipText() {

View File

@ -8,28 +8,23 @@ import eva2.optimization.problems.InterfaceOptimizationProblem;
import eva2.tools.math.RNG; import eva2.tools.math.RNG;
/** /**
* This individual combines a real-valued phenotype with a tree-based phenotype. *
* Created by IntelliJ IDEA.
* User: streiche
* Date: 08.04.2003
* Time: 10:04:44
* To change this template use Options | File Templates.
*/ */
public class GAPIndividualProgramData extends AbstractEAIndividual implements InterfaceDataTypeProgram, InterfaceDataTypeDouble, java.io.Serializable { public class GAPIndividualProgramData extends AbstractEAIndividual implements InterfaceDataTypeProgram, InterfaceDataTypeDouble, java.io.Serializable {
private InterfaceDataTypeDouble m_Numbers = new ESIndividualDoubleData(); private InterfaceDataTypeDouble numberData = new ESIndividualDoubleData();
private InterfaceDataTypeProgram m_Program = new GPIndividualProgramData(); private InterfaceDataTypeProgram programData = new GPIndividualProgramData();
public GAPIndividualProgramData() { public GAPIndividualProgramData() {
this.mutationProbability = 1.0; this.mutationProbability = 1.0;
this.crossoverProbability = 1.0; this.crossoverProbability = 1.0;
this.m_Numbers = new GAIndividualDoubleData(); this.numberData = new GAIndividualDoubleData();
this.m_Program = new GPIndividualProgramData(); this.programData = new GPIndividualProgramData();
} }
public GAPIndividualProgramData(GAPIndividualProgramData individual) { public GAPIndividualProgramData(GAPIndividualProgramData individual) {
this.m_Numbers = (InterfaceDataTypeDouble) ((AbstractEAIndividual) individual.getNumbers()).clone(); this.numberData = (InterfaceDataTypeDouble) ((AbstractEAIndividual) individual.getNumbers()).clone();
this.m_Program = (InterfaceDataTypeProgram) ((AbstractEAIndividual) individual.getProgramRepresentation()).clone(); this.programData = (InterfaceDataTypeProgram) ((AbstractEAIndividual) individual.getProgramRepresentation()).clone();
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
this.age = individual.age; this.age = individual.age;
@ -63,10 +58,10 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof GAPIndividualProgramData) { if (individual instanceof GAPIndividualProgramData) {
GAPIndividualProgramData indy = (GAPIndividualProgramData) individual; GAPIndividualProgramData indy = (GAPIndividualProgramData) individual;
if (!((AbstractEAIndividual) this.m_Numbers).equalGenotypes((AbstractEAIndividual) indy.m_Numbers)) { if (!((AbstractEAIndividual) this.numberData).equalGenotypes((AbstractEAIndividual) indy.numberData)) {
return false; return false;
} }
if (!((AbstractEAIndividual) this.m_Program).equalGenotypes((AbstractEAIndividual) indy.m_Program)) { if (!((AbstractEAIndividual) this.programData).equalGenotypes((AbstractEAIndividual) indy.programData)) {
return false; return false;
} }
return true; return true;
@ -82,14 +77,14 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public void init(InterfaceOptimizationProblem opt) { public void init(InterfaceOptimizationProblem opt) {
((AbstractEAIndividual) this.m_Numbers).init(opt); ((AbstractEAIndividual) this.numberData).init(opt);
((AbstractEAIndividual) this.m_Program).init(opt); ((AbstractEAIndividual) this.programData).init(opt);
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
((AbstractEAIndividual) this.m_Numbers).defaultInit(prob); ((AbstractEAIndividual) this.numberData).defaultInit(prob);
((AbstractEAIndividual) this.m_Program).defaultInit(prob); ((AbstractEAIndividual) this.programData).defaultInit(prob);
} }
/** /**
@ -103,15 +98,15 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof Object[]) { if (obj instanceof Object[]) {
if (((Object[]) obj)[0] instanceof double[]) { if (((Object[]) obj)[0] instanceof double[]) {
((AbstractEAIndividual) this.m_Numbers).initByValue(((Object[]) obj)[0], opt); ((AbstractEAIndividual) this.numberData).initByValue(((Object[]) obj)[0], opt);
((AbstractEAIndividual) this.m_Program).initByValue(((Object[]) obj)[1], opt); ((AbstractEAIndividual) this.programData).initByValue(((Object[]) obj)[1], opt);
} else { } else {
((AbstractEAIndividual) this.m_Numbers).initByValue(((Object[]) obj)[1], opt); ((AbstractEAIndividual) this.numberData).initByValue(((Object[]) obj)[1], opt);
((AbstractEAIndividual) this.m_Program).initByValue(((Object[]) obj)[0], opt); ((AbstractEAIndividual) this.programData).initByValue(((Object[]) obj)[0], opt);
} }
} else { } else {
((AbstractEAIndividual) this.m_Numbers).init(opt); ((AbstractEAIndividual) this.numberData).init(opt);
((AbstractEAIndividual) this.m_Program).init(opt); ((AbstractEAIndividual) this.programData).init(opt);
System.out.println("Initial value for GAPIndividualDoubleData is not suitable!"); System.out.println("Initial value for GAPIndividualDoubleData is not suitable!");
} }
} }
@ -122,17 +117,17 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
@Override @Override
public void mutate() { public void mutate() {
if (RNG.flipCoin(this.mutationProbability)) { if (RNG.flipCoin(this.mutationProbability)) {
((AbstractEAIndividual) this.m_Numbers).mutate(); ((AbstractEAIndividual) this.numberData).mutate();
} }
if (RNG.flipCoin(this.mutationProbability)) { if (RNG.flipCoin(this.mutationProbability)) {
((AbstractEAIndividual) this.m_Program).mutate(); ((AbstractEAIndividual) this.programData).mutate();
} }
} }
@Override @Override
public void defaultMutate() { public void defaultMutate() {
((AbstractEAIndividual) this.m_Numbers).defaultMutate(); ((AbstractEAIndividual) this.numberData).defaultMutate();
((AbstractEAIndividual) this.m_Program).defaultMutate(); ((AbstractEAIndividual) this.programData).defaultMutate();
} }
/** /**
@ -193,8 +188,8 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
@Override @Override
public String getStringRepresentation() { public String getStringRepresentation() {
String result = "This is a hybrid Individual:\n"; String result = "This is a hybrid Individual:\n";
result += "The Numbers Part:\n" + ((AbstractEAIndividual) this.m_Numbers).getStringRepresentation(); result += "The Numbers Part:\n" + ((AbstractEAIndividual) this.numberData).getStringRepresentation();
result += "\nThe Binarys Part:\n" + ((AbstractEAIndividual) this.m_Program).getStringRepresentation(); result += "\nThe Binarys Part:\n" + ((AbstractEAIndividual) this.programData).getStringRepresentation();
return result; return result;
} }
@ -208,7 +203,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public void setDoubleDataLength(int length) { public void setDoubleDataLength(int length) {
this.m_Numbers.setDoubleDataLength(length); this.numberData.setDoubleDataLength(length);
} }
/** /**
@ -218,7 +213,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public int size() { public int size() {
return this.m_Numbers.size(); return this.numberData.size();
} }
/** /**
@ -230,7 +225,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public void setDoubleRange(double[][] range) { public void setDoubleRange(double[][] range) {
this.m_Numbers.setDoubleRange(range); this.numberData.setDoubleRange(range);
} }
/** /**
@ -240,7 +235,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public double[][] getDoubleRange() { public double[][] getDoubleRange() {
return this.m_Numbers.getDoubleRange(); return this.numberData.getDoubleRange();
} }
/** /**
@ -250,7 +245,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public double[] getDoubleData() { public double[] getDoubleData() {
return this.m_Numbers.getDoubleData(); return this.numberData.getDoubleData();
} }
/** /**
@ -261,7 +256,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public double[] getDoubleDataWithoutUpdate() { public double[] getDoubleDataWithoutUpdate() {
return this.m_Numbers.getDoubleDataWithoutUpdate(); return this.numberData.getDoubleDataWithoutUpdate();
} }
/** /**
@ -272,7 +267,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public void setDoublePhenotype(double[] doubleData) { public void setDoublePhenotype(double[] doubleData) {
this.m_Numbers.setDoublePhenotype(doubleData); this.numberData.setDoublePhenotype(doubleData);
} }
/** /**
@ -283,7 +278,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public void setDoubleGenotype(double[] doubleData) { public void setDoubleGenotype(double[] doubleData) {
this.m_Numbers.setDoubleGenotype(doubleData); this.numberData.setDoubleGenotype(doubleData);
} }
/************************************************************************************ /************************************************************************************
@ -296,7 +291,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public void setProgramDataLength(int length) { public void setProgramDataLength(int length) {
this.m_Program.setProgramDataLength(length); this.programData.setProgramDataLength(length);
} }
/** /**
@ -306,7 +301,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public InterfaceProgram[] getProgramData() { public InterfaceProgram[] getProgramData() {
return this.m_Program.getProgramData(); return this.programData.getProgramData();
} }
/** /**
@ -317,7 +312,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public InterfaceProgram[] getProgramDataWithoutUpdate() { public InterfaceProgram[] getProgramDataWithoutUpdate() {
return this.m_Program.getProgramDataWithoutUpdate(); return this.programData.getProgramDataWithoutUpdate();
} }
/** /**
@ -327,7 +322,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public void SetProgramPhenotype(InterfaceProgram[] program) { public void SetProgramPhenotype(InterfaceProgram[] program) {
this.m_Program.SetProgramPhenotype(program); this.programData.SetProgramPhenotype(program);
} }
/** /**
@ -337,7 +332,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public void SetProgramGenotype(InterfaceProgram[] program) { public void SetProgramGenotype(InterfaceProgram[] program) {
this.m_Program.SetProgramGenotype(program); this.programData.SetProgramGenotype(program);
} }
/** /**
@ -347,7 +342,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public void SetFunctionArea(Object[] area) { public void SetFunctionArea(Object[] area) {
this.m_Program.SetFunctionArea(area); this.programData.SetFunctionArea(area);
} }
/** /**
@ -357,7 +352,7 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
*/ */
@Override @Override
public Object[] getFunctionArea() { public Object[] getFunctionArea() {
return this.m_Program.getFunctionArea(); return this.programData.getFunctionArea();
} }
/********************************************************************************************************************** /**********************************************************************************************************************
@ -380,11 +375,11 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
* @param Numbers The new representation for the inner constants. * @param Numbers The new representation for the inner constants.
*/ */
public void setNumbers(InterfaceDataTypeDouble Numbers) { public void setNumbers(InterfaceDataTypeDouble Numbers) {
this.m_Numbers = Numbers; this.numberData = Numbers;
} }
public InterfaceDataTypeDouble getNumbers() { public InterfaceDataTypeDouble getNumbers() {
return this.m_Numbers; return this.numberData;
} }
public String numbersTipText() { public String numbersTipText() {
@ -397,11 +392,11 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
* @param program The new representation for the program. * @param program The new representation for the program.
*/ */
public void setProgramRepresentation(InterfaceDataTypeProgram program) { public void setProgramRepresentation(InterfaceDataTypeProgram program) {
this.m_Program = program; this.programData = program;
} }
public InterfaceDataTypeProgram getProgramRepresentation() { public InterfaceDataTypeProgram getProgramRepresentation() {
return this.m_Program; return this.programData;
} }
public String programRepresentationTipText() { public String programRepresentationTipText() {

View File

@ -21,25 +21,25 @@ import java.util.BitSet;
@Description(value = "This is a GE individual suited to optimize programs.") @Description(value = "This is a GE individual suited to optimize programs.")
public class GEIndividualProgramData extends AbstractEAIndividual implements InterfaceGAIndividual, InterfaceDataTypeProgram, java.io.Serializable { public class GEIndividualProgramData extends AbstractEAIndividual implements InterfaceGAIndividual, InterfaceDataTypeProgram, java.io.Serializable {
protected GPArea[] m_Area; protected GPArea[] gpAreas;
protected double m_InitFullGrowRatio = 0.5; protected double initFullGrowRatio = 0.5;
protected int m_InitDepth = 5; protected int initDepth = 5;
protected int m_TargetDepth = 10; protected int targetDepth = 10;
protected boolean m_CheckTargetDepth = true; protected boolean checkTargetDepth = true;
protected BitSet m_Genotype; protected BitSet genotype;
protected AbstractGPNode[] m_Phenotype; protected AbstractGPNode[] phenotype;
protected int m_GenotypeLengthPerProgram = 240; // this is the overall length protected int genotypeLengthPerProgram = 240; // this is the overall length
protected int m_MaxNumberOfNodes = 80; protected int maxNumberOfNodes = 80;
protected int m_NumberOfBitPerInt = 6; protected int numberOfBitPerInt = 6;
protected int m_CurrentIndex = 0; protected int currentIndex = 0;
protected int m_CurrentNumberOfNodes = 0; protected int currentNumberOfNodes = 0;
protected Object[][] m_Rules; protected Object[][] rules;
public GEIndividualProgramData() { public GEIndividualProgramData() {
this.m_Area = new GPArea[1]; this.gpAreas = new GPArea[1];
this.m_GenotypeLengthPerProgram = 240; this.genotypeLengthPerProgram = 240;
this.m_Genotype = new BitSet(); this.genotype = new BitSet();
this.mutationOperator = new MutateDefault(); this.mutationOperator = new MutateDefault();
this.crossoverOperator = new CrossoverGADefault(); this.crossoverOperator = new CrossoverGADefault();
this.mutationProbability = 0.5; this.mutationProbability = 0.5;
@ -47,46 +47,46 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
} }
public GEIndividualProgramData(GEIndividualProgramData individual) { public GEIndividualProgramData(GEIndividualProgramData individual) {
if (individual.m_Phenotype != null) { if (individual.phenotype != null) {
this.m_Phenotype = new AbstractGPNode[individual.m_Phenotype.length]; this.phenotype = new AbstractGPNode[individual.phenotype.length];
for (int i = 0; i < individual.m_Phenotype.length; i++) { for (int i = 0; i < individual.phenotype.length; i++) {
this.m_Phenotype[i] = (AbstractGPNode) individual.m_Phenotype[i].clone(); this.phenotype[i] = (AbstractGPNode) individual.phenotype[i].clone();
} }
} }
this.m_GenotypeLengthPerProgram = individual.m_GenotypeLengthPerProgram; this.genotypeLengthPerProgram = individual.genotypeLengthPerProgram;
this.m_MaxNumberOfNodes = individual.m_MaxNumberOfNodes; this.maxNumberOfNodes = individual.maxNumberOfNodes;
this.m_NumberOfBitPerInt = individual.m_NumberOfBitPerInt; this.numberOfBitPerInt = individual.numberOfBitPerInt;
this.m_CurrentIndex = individual.m_CurrentIndex; this.currentIndex = individual.currentIndex;
if (individual.m_Genotype != null) { if (individual.genotype != null) {
this.m_Genotype = (BitSet) individual.m_Genotype.clone(); this.genotype = (BitSet) individual.genotype.clone();
} }
if (individual.m_Area != null) { if (individual.gpAreas != null) {
this.m_Area = new GPArea[individual.m_Area.length]; this.gpAreas = new GPArea[individual.gpAreas.length];
for (int i = 0; i < this.m_Area.length; i++) { for (int i = 0; i < this.gpAreas.length; i++) {
this.m_Area[i] = (GPArea) individual.m_Area[i].clone(); this.gpAreas[i] = (GPArea) individual.gpAreas[i].clone();
} }
} }
// User : "Copy the rules set!" // User : "Copy the rules set!"
// GEIndividualProgramData : "Naay! I wanna go playing with my friends... !" // GEIndividualProgramData : "Naay! I wanna go playing with my friends... !"
if (individual.m_Rules != null) { if (individual.rules != null) {
this.m_Rules = new Object[individual.m_Rules.length][]; this.rules = new Object[individual.rules.length][];
for (int t = 0; t < this.m_Rules.length; t++) { for (int t = 0; t < this.rules.length; t++) {
this.m_Rules[t] = new Object[individual.m_Rules[t].length]; this.rules[t] = new Object[individual.rules[t].length];
int[][] copyRulz, orgRulz = (int[][]) individual.m_Rules[t][0]; int[][] copyRulz, orgRulz = (int[][]) individual.rules[t][0];
copyRulz = new int[orgRulz.length][]; copyRulz = new int[orgRulz.length][];
for (int i = 0; i < copyRulz.length; i++) { for (int i = 0; i < copyRulz.length; i++) {
copyRulz[i] = new int[orgRulz[i].length]; copyRulz[i] = new int[orgRulz[i].length];
System.arraycopy(orgRulz[i], 0, copyRulz[i], 0, orgRulz[i].length); System.arraycopy(orgRulz[i], 0, copyRulz[i], 0, orgRulz[i].length);
} }
this.m_Rules[t][0] = copyRulz; this.rules[t][0] = copyRulz;
AbstractGPNode[] copyNode, orgNode; AbstractGPNode[] copyNode, orgNode;
for (int i = 1; i < this.m_Rules[t].length; i++) { for (int i = 1; i < this.rules[t].length; i++) {
orgNode = (AbstractGPNode[]) individual.m_Rules[t][i]; orgNode = (AbstractGPNode[]) individual.rules[t][i];
copyNode = new AbstractGPNode[orgNode.length]; copyNode = new AbstractGPNode[orgNode.length];
for (int j = 0; j < orgNode.length; j++) { for (int j = 0; j < orgNode.length; j++) {
copyNode[j] = (AbstractGPNode) orgNode[j].clone(); copyNode[j] = (AbstractGPNode) orgNode[j].clone();
} }
this.m_Rules[t][i] = copyNode; this.rules[t][i] = copyNode;
} }
} }
} }
@ -122,19 +122,19 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof GEIndividualProgramData) { if (individual instanceof GEIndividualProgramData) {
GEIndividualProgramData indy = (GEIndividualProgramData) individual; GEIndividualProgramData indy = (GEIndividualProgramData) individual;
if (this.m_GenotypeLengthPerProgram != indy.m_GenotypeLengthPerProgram) { if (this.genotypeLengthPerProgram != indy.genotypeLengthPerProgram) {
return false; return false;
} }
if (this.m_MaxNumberOfNodes != indy.m_MaxNumberOfNodes) { if (this.maxNumberOfNodes != indy.maxNumberOfNodes) {
return false; return false;
} }
if (this.m_NumberOfBitPerInt != indy.m_NumberOfBitPerInt) { if (this.numberOfBitPerInt != indy.numberOfBitPerInt) {
return false; return false;
} }
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) { if ((this.genotype == null) || (indy.genotype == null)) {
return false; return false;
} }
if (!this.m_Genotype.equals(indy.m_Genotype)) { if (!this.genotype.equals(indy.genotype)) {
return false; return false;
} }
return true; return true;
@ -147,18 +147,18 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
* This method compiles the area * This method compiles the area
*/ */
private void compileArea() { private void compileArea() {
if (this.m_Area == null) { if (this.gpAreas == null) {
this.m_Rules = null; this.rules = null;
return; return;
} }
//this.m_Rules = new Object[this.gpArea.length][]; //this.rules = new Object[this.gpArea.length][];
for (int t = 0; t < this.m_Area.length; t++) { for (int t = 0; t < this.gpAreas.length; t++) {
// first lets find out what kind of elements are available // first lets find out what kind of elements are available
int arity, maxArity = 0; int arity, maxArity = 0;
// first find out the max arity in the GPArea // first find out the max arity in the GPArea
this.m_Area[t].compileReducedList(); this.gpAreas[t].compileReducedList();
ArrayList area = this.m_Area[t].getReducedList(); ArrayList area = this.gpAreas[t].getReducedList();
for (int i = 0; i < area.size(); i++) { for (int i = 0; i < area.size(); i++) {
arity = ((AbstractGPNode) area.get(i)).getArity(); arity = ((AbstractGPNode) area.get(i)).getArity();
if (arity > maxArity) { if (arity > maxArity) {
@ -175,7 +175,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
directList[((AbstractGPNode) area.get(i)).getArity()].add(area.get(i)); directList[((AbstractGPNode) area.get(i)).getArity()].add(area.get(i));
} }
// Now write the rules // Now write the rules
this.m_Rules[t] = new Object[maxArity + 2]; this.rules[t] = new Object[maxArity + 2];
// the first rule describes how to decode an <expr> // the first rule describes how to decode an <expr>
int numberOfRules = 0, index = 0; int numberOfRules = 0, index = 0;
int[] tmpRule; int[] tmpRule;
@ -210,7 +210,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
index++; index++;
} }
} }
this.m_Rules[t][0] = trueExpr; this.rules[t][0] = trueExpr;
// now the rules that define <var>, <op1>, <op2>, .... // now the rules that define <var>, <op1>, <op2>, ....
AbstractGPNode[] tmpListOfGPNodes; AbstractGPNode[] tmpListOfGPNodes;
@ -219,7 +219,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
for (int j = 0; j < directList[i].size(); j++) { for (int j = 0; j < directList[i].size(); j++) {
tmpListOfGPNodes[j] = (AbstractGPNode) directList[i].get(j); tmpListOfGPNodes[j] = (AbstractGPNode) directList[i].get(j);
} }
this.m_Rules[t][i + 1] = tmpListOfGPNodes; this.rules[t][i + 1] = tmpListOfGPNodes;
} }
// this should be the complete rules set // this should be the complete rules set
//this.printRuleSet(); //this.printRuleSet();
@ -232,17 +232,17 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
private void printRuleSet() { private void printRuleSet() {
String result = ""; String result = "";
AbstractGPNode[] tmpNodes; AbstractGPNode[] tmpNodes;
for (int t = 0; t < this.m_Area.length; t++) { for (int t = 0; t < this.gpAreas.length; t++) {
// first the Non-Terminals // first the Non-Terminals
result += "N \t := \t{"; result += "N \t := \t{";
for (int i = 0; i < this.m_Rules[t].length; i++) { for (int i = 0; i < this.rules[t].length; i++) {
if (i == 0) { if (i == 0) {
result += "expr, "; result += "expr, ";
} else { } else {
if (i == 1) { if (i == 1) {
result += "var, "; result += "var, ";
} else { } else {
if (((AbstractGPNode[]) this.m_Rules[t][i]).length > 0) { if (((AbstractGPNode[]) this.rules[t][i]).length > 0) {
result += "op" + (i - 1) + ", "; result += "op" + (i - 1) + ", ";
} }
} }
@ -251,8 +251,8 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
result += "}\n"; result += "}\n";
// then the Ternimnals // then the Ternimnals
result += "T \t := \t{"; result += "T \t := \t{";
this.m_Area[t].compileReducedList(); this.gpAreas[t].compileReducedList();
ArrayList area = this.m_Area[t].getReducedList(); ArrayList area = this.gpAreas[t].getReducedList();
for (int i = 0; i < area.size(); i++) { for (int i = 0; i < area.size(); i++) {
result += ((AbstractGPNode) area.get(i)).getStringRepresentation() + ", "; result += ((AbstractGPNode) area.get(i)).getStringRepresentation() + ", ";
} }
@ -261,12 +261,12 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
result += "S \t := \t<expr>\n\n"; result += "S \t := \t<expr>\n\n";
// now the rules // now the rules
for (int i = 0; i < this.m_Rules[t].length; i++) { for (int i = 0; i < this.rules[t].length; i++) {
if (i == 0) { if (i == 0) {
// the first rules // the first rules
result += "0. \t := \t<expr> \t::\t"; result += "0. \t := \t<expr> \t::\t";
System.out.println("i: " + i); System.out.println("i: " + i);
int[][] rulz = (int[][]) this.m_Rules[t][i]; int[][] rulz = (int[][]) this.rules[t][i];
for (int j = 0; j < rulz.length; j++) { for (int j = 0; j < rulz.length; j++) {
result += this.getRuleString(rulz[j]) + "\n"; result += this.getRuleString(rulz[j]) + "\n";
if ((j + 1) < rulz.length) { if ((j + 1) < rulz.length) {
@ -277,14 +277,14 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
// now the rules for the terminals // now the rules for the terminals
if (i == 1) { if (i == 1) {
// These are the GP-Terminals // These are the GP-Terminals
tmpNodes = (AbstractGPNode[]) this.m_Rules[t][i]; tmpNodes = (AbstractGPNode[]) this.rules[t][i];
result += "1. \t := \t<var> \t::\t" + tmpNodes[0].getStringRepresentation() + "\n"; result += "1. \t := \t<var> \t::\t" + tmpNodes[0].getStringRepresentation() + "\n";
for (int j = 1; j < tmpNodes.length; j++) { for (int j = 1; j < tmpNodes.length; j++) {
result += "\t \t \t \t \t \t" + tmpNodes[j].getStringRepresentation() + "\n"; result += "\t \t \t \t \t \t" + tmpNodes[j].getStringRepresentation() + "\n";
} }
} else { } else {
// These are the GP-Functions // These are the GP-Functions
tmpNodes = (AbstractGPNode[]) this.m_Rules[t][i]; tmpNodes = (AbstractGPNode[]) this.rules[t][i];
if (tmpNodes.length > 0) { if (tmpNodes.length > 0) {
result += i + ". \t := \t<op" + (i - 1) + "> \t::\t" + tmpNodes[0].getStringRepresentation() + "\n"; result += i + ". \t := \t<op" + (i - 1) + "> \t::\t" + tmpNodes[0].getStringRepresentation() + "\n";
for (int j = 1; j < tmpNodes.length; j++) { for (int j = 1; j < tmpNodes.length; j++) {
@ -310,11 +310,11 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
private String getBitSetString() { private String getBitSetString() {
String result = ""; String result = "";
result += "{"; result += "{";
for (int i = 0; i < this.m_GenotypeLengthPerProgram * this.m_Area.length; i++) { for (int i = 0; i < this.genotypeLengthPerProgram * this.gpAreas.length; i++) {
if (i % this.m_NumberOfBitPerInt == 0) { if (i % this.numberOfBitPerInt == 0) {
result += " "; result += " ";
} }
if (this.m_Genotype.get(i)) { if (this.genotype.get(i)) {
result += "1"; result += "1";
} else { } else {
result += "0"; result += "0";
@ -356,59 +356,59 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public void setProgramDataLength(int length) { public void setProgramDataLength(int length) {
GPArea[] oldArea = this.m_Area; GPArea[] oldArea = this.gpAreas;
Object[][] oldRulz = this.m_Rules; Object[][] oldRulz = this.rules;
this.m_Area = new GPArea[length]; this.gpAreas = new GPArea[length];
for (int t = 0; ((t < this.m_Area.length) && (t < oldArea.length)); t++) { for (int t = 0; ((t < this.gpAreas.length) && (t < oldArea.length)); t++) {
this.m_Area[t] = oldArea[t]; this.gpAreas[t] = oldArea[t];
} }
for (int t = oldArea.length; t < this.m_Area.length; t++) { for (int t = oldArea.length; t < this.gpAreas.length; t++) {
this.m_Area[t] = oldArea[oldArea.length - 1]; this.gpAreas[t] = oldArea[oldArea.length - 1];
} }
this.m_Rules = new Object[length][]; this.rules = new Object[length][];
if (oldRulz == null) { if (oldRulz == null) {
return; return;
} }
for (int t = 0; ((t < this.m_Area.length) && (t < oldArea.length)); t++) { for (int t = 0; ((t < this.gpAreas.length) && (t < oldArea.length)); t++) {
if (oldRulz[t] != null) { if (oldRulz[t] != null) {
this.m_Rules[t] = new Object[oldRulz[t].length]; this.rules[t] = new Object[oldRulz[t].length];
int[][] copyRulz, orgRulz = (int[][]) oldRulz[t][0]; int[][] copyRulz, orgRulz = (int[][]) oldRulz[t][0];
copyRulz = new int[orgRulz.length][]; copyRulz = new int[orgRulz.length][];
for (int i = 0; i < copyRulz.length; i++) { for (int i = 0; i < copyRulz.length; i++) {
copyRulz[i] = new int[orgRulz[i].length]; copyRulz[i] = new int[orgRulz[i].length];
System.arraycopy(orgRulz[i], 0, copyRulz[i], 0, orgRulz[i].length); System.arraycopy(orgRulz[i], 0, copyRulz[i], 0, orgRulz[i].length);
} }
this.m_Rules[t][0] = copyRulz; this.rules[t][0] = copyRulz;
AbstractGPNode[] copyNode, orgNode; AbstractGPNode[] copyNode, orgNode;
for (int i = 1; i < this.m_Rules[t].length; i++) { for (int i = 1; i < this.rules[t].length; i++) {
orgNode = (AbstractGPNode[]) oldRulz[t][i]; orgNode = (AbstractGPNode[]) oldRulz[t][i];
copyNode = new AbstractGPNode[orgNode.length]; copyNode = new AbstractGPNode[orgNode.length];
for (int j = 0; j < orgNode.length; j++) { for (int j = 0; j < orgNode.length; j++) {
copyNode[j] = (AbstractGPNode) orgNode[j].clone(); copyNode[j] = (AbstractGPNode) orgNode[j].clone();
} }
this.m_Rules[t][i] = copyNode; this.rules[t][i] = copyNode;
} }
} }
} }
for (int t = oldArea.length; t < this.m_Area.length; t++) { for (int t = oldArea.length; t < this.gpAreas.length; t++) {
if (oldRulz[oldArea.length - 1] != null) { if (oldRulz[oldArea.length - 1] != null) {
this.m_Rules[t] = new Object[oldRulz[oldArea.length - 1].length]; this.rules[t] = new Object[oldRulz[oldArea.length - 1].length];
int[][] copyRulz, orgRulz = (int[][]) oldRulz[oldArea.length - 1][0]; int[][] copyRulz, orgRulz = (int[][]) oldRulz[oldArea.length - 1][0];
copyRulz = new int[orgRulz.length][]; copyRulz = new int[orgRulz.length][];
for (int i = 0; i < copyRulz.length; i++) { for (int i = 0; i < copyRulz.length; i++) {
copyRulz[i] = new int[orgRulz[i].length]; copyRulz[i] = new int[orgRulz[i].length];
System.arraycopy(orgRulz[i], 0, copyRulz[i], 0, orgRulz[i].length); System.arraycopy(orgRulz[i], 0, copyRulz[i], 0, orgRulz[i].length);
} }
this.m_Rules[t][0] = copyRulz; this.rules[t][0] = copyRulz;
AbstractGPNode[] copyNode, orgNode; AbstractGPNode[] copyNode, orgNode;
for (int i = 1; i < this.m_Rules[t].length; i++) { for (int i = 1; i < this.rules[t].length; i++) {
orgNode = (AbstractGPNode[]) oldRulz[oldArea.length - 1][i]; orgNode = (AbstractGPNode[]) oldRulz[oldArea.length - 1][i];
copyNode = new AbstractGPNode[orgNode.length]; copyNode = new AbstractGPNode[orgNode.length];
for (int j = 0; j < orgNode.length; j++) { for (int j = 0; j < orgNode.length; j++) {
copyNode[j] = (AbstractGPNode) orgNode[j].clone(); copyNode[j] = (AbstractGPNode) orgNode[j].clone();
} }
this.m_Rules[t][i] = copyNode; this.rules[t][i] = copyNode;
} }
} }
} }
@ -426,13 +426,13 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
*/ */
private int decodeNextInt(int t) { private int decodeNextInt(int t) {
int result = 0; int result = 0;
for (int i = 0; i < this.m_NumberOfBitPerInt; i++) { for (int i = 0; i < this.numberOfBitPerInt; i++) {
if (this.m_Genotype.get(this.m_CurrentIndex + (t * this.m_GenotypeLengthPerProgram))) { if (this.genotype.get(this.currentIndex + (t * this.genotypeLengthPerProgram))) {
result += Math.pow(2, i); result += Math.pow(2, i);
} }
this.m_CurrentIndex++; this.currentIndex++;
if (this.m_CurrentIndex >= (t + 1) * this.m_GenotypeLengthPerProgram) { if (this.currentIndex >= (t + 1) * this.genotypeLengthPerProgram) {
this.m_CurrentIndex = t * this.m_GenotypeLengthPerProgram; this.currentIndex = t * this.genotypeLengthPerProgram;
} }
} }
return result; return result;
@ -452,12 +452,12 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
// System.out.println("Decoding mode: " + mode); // System.out.println("Decoding mode: " + mode);
if (mode == 0) { if (mode == 0) {
int[][] rulz = (int[][]) this.m_Rules[t][0]; int[][] rulz = (int[][]) this.rules[t][0];
int[] myRule = rulz[value % rulz.length]; int[] myRule = rulz[value % rulz.length];
// System.out.print("Value % rulz : "+ value +" % " + rulz.length + " = " +(value%rulz.length)); // System.out.print("Value % rulz : "+ value +" % " + rulz.length + " = " +(value%rulz.length));
// System.out.println(" => my rule " + this.getRuleString(myRule)); // System.out.println(" => my rule " + this.getRuleString(myRule));
this.m_CurrentNumberOfNodes += myRule.length; this.currentNumberOfNodes += myRule.length;
if ((this.m_CurrentNumberOfNodes + myRule.length) > this.m_MaxNumberOfNodes) { if ((this.currentNumberOfNodes + myRule.length) > this.maxNumberOfNodes) {
// no i have to limit the number of nodes // no i have to limit the number of nodes
myRule = rulz[0]; myRule = rulz[0];
// System.out.println("Limiting to "+ this.getRuleString(myRule)); // System.out.println("Limiting to "+ this.getRuleString(myRule));
@ -468,7 +468,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
result.setNode(this.decodeGPNode(t, myRule[i + 1]), i); result.setNode(this.decodeGPNode(t, myRule[i + 1]), i);
} }
} else { } else {
AbstractGPNode[] availableNodes = (AbstractGPNode[]) this.m_Rules[t][mode]; AbstractGPNode[] availableNodes = (AbstractGPNode[]) this.rules[t][mode];
// System.out.print("Choosing a terminal : "+ value +" % " + availableNodes.length + " = " +(value%availableNodes.length)); // System.out.print("Choosing a terminal : "+ value +" % " + availableNodes.length + " = " +(value%availableNodes.length));
// System.out.println(" => " +availableNodes[value % availableNodes.length].getStringRepresentation()); // System.out.println(" => " +availableNodes[value % availableNodes.length].getStringRepresentation());
result = (AbstractGPNode) availableNodes[value % availableNodes.length].clone(); result = (AbstractGPNode) availableNodes[value % availableNodes.length].clone();
@ -486,34 +486,34 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
// if (true) { // if (true) {
// String test ="GE decoding:\n"; // String test ="GE decoding:\n";
// test += this.getBitSetString() +"\n{"; // test += this.getBitSetString() +"\n{";
// this.m_CurrentIndex = 0; // this.currentIndex = 0;
// for (int i = 0; i < this.m_MaxNumberOfNodes; i++) { // for (int i = 0; i < this.maxNumberOfNodes; i++) {
// test += this.decodeNextInt(); // test += this.decodeNextInt();
// if ((i + 1) < this.m_MaxNumberOfNodes) test += "; "; // if ((i + 1) < this.maxNumberOfNodes) test += "; ";
// } // }
// test += "}\n"; // test += "}\n";
// System.out.println(""+test); // System.out.println(""+test);
// } // }
// lets decode the stuff! // lets decode the stuff!
if (this.m_Rules == null) { if (this.rules == null) {
this.compileArea(); this.compileArea();
if (this.m_Rules == null) { if (this.rules == null) {
return null; return null;
} }
} }
this.m_CurrentIndex = 0; this.currentIndex = 0;
this.m_CurrentNumberOfNodes = 0; this.currentNumberOfNodes = 0;
int mode = 0; int mode = 0;
this.m_Phenotype = new AbstractGPNode[this.m_Area.length]; this.phenotype = new AbstractGPNode[this.gpAreas.length];
for (int t = 0; t < this.m_Area.length; t++) { for (int t = 0; t < this.gpAreas.length; t++) {
mode = 0; mode = 0;
this.m_CurrentIndex = t * this.m_GenotypeLengthPerProgram; this.currentIndex = t * this.genotypeLengthPerProgram;
this.m_CurrentNumberOfNodes = 0; this.currentNumberOfNodes = 0;
this.m_Phenotype[t] = this.decodeGPNode(t, mode); this.phenotype[t] = this.decodeGPNode(t, mode);
} }
// System.out.println("Decoded: "); // System.out.println("Decoded: ");
// System.out.println(""+ result.getStringRepresentation()); // System.out.println(""+ result.getStringRepresentation());
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -524,7 +524,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public InterfaceProgram[] getProgramDataWithoutUpdate() { public InterfaceProgram[] getProgramDataWithoutUpdate() {
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -535,9 +535,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
@Override @Override
public void SetProgramPhenotype(InterfaceProgram[] program) { public void SetProgramPhenotype(InterfaceProgram[] program) {
if (program instanceof AbstractGPNode[]) { if (program instanceof AbstractGPNode[]) {
this.m_Phenotype = new AbstractGPNode[program.length]; this.phenotype = new AbstractGPNode[program.length];
for (int t = 0; t < program.length; t++) { for (int t = 0; t < program.length; t++) {
this.m_Phenotype[t] = (AbstractGPNode) ((AbstractGPNode) program[t]).clone(); this.phenotype[t] = (AbstractGPNode) ((AbstractGPNode) program[t]).clone();
} }
} }
} }
@ -563,9 +563,9 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
@Override @Override
public void SetFunctionArea(Object[] area) { public void SetFunctionArea(Object[] area) {
if (area instanceof GPArea[]) { if (area instanceof GPArea[]) {
this.m_Area = new GPArea[area.length]; this.gpAreas = new GPArea[area.length];
for (int t = 0; t < this.m_Area.length; t++) { for (int t = 0; t < this.gpAreas.length; t++) {
this.m_Area[t] = (GPArea) area[t]; this.gpAreas[t] = (GPArea) area[t];
} }
this.compileArea(); this.compileArea();
} }
@ -578,7 +578,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public Object[] getFunctionArea() { public Object[] getFunctionArea() {
return this.m_Area; return this.gpAreas;
} }
/************************************************************************************ /************************************************************************************
@ -614,8 +614,8 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
String result = ""; String result = "";
result += "GEIndividual coding program:\n"; result += "GEIndividual coding program:\n";
result += "{"; result += "{";
for (int i = 0; i < this.m_GenotypeLengthPerProgram * this.m_Area.length; i++) { for (int i = 0; i < this.genotypeLengthPerProgram * this.gpAreas.length; i++) {
if (this.m_Genotype.get(i)) { if (this.genotype.get(i)) {
result += "1"; result += "1";
} else { } else {
result += "0"; result += "0";
@ -640,7 +640,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public BitSet getBGenotype() { public BitSet getBGenotype() {
return this.m_Genotype; return this.genotype;
} }
/** /**
@ -651,7 +651,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public void setBGenotype(BitSet binaryData) { public void setBGenotype(BitSet binaryData) {
this.m_Genotype = binaryData; this.genotype = binaryData;
} }
/** /**
@ -663,16 +663,16 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int getGenotypeLength() { public int getGenotypeLength() {
return this.m_GenotypeLengthPerProgram * this.m_Area.length; return this.genotypeLengthPerProgram * this.gpAreas.length;
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
for (int i = 0; i < this.m_GenotypeLengthPerProgram * this.m_Area.length; i++) { for (int i = 0; i < this.genotypeLengthPerProgram * this.gpAreas.length; i++) {
if (RNG.flipCoin(0.5)) { if (RNG.flipCoin(0.5)) {
this.m_Genotype.set(i); this.genotype.set(i);
} else { } else {
this.m_Genotype.clear(i); this.genotype.clear(i);
} }
} }
} }
@ -682,12 +682,12 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
int mutationIndex = RNG.randomInt(0, this.m_GenotypeLengthPerProgram * this.m_Area.length); int mutationIndex = RNG.randomInt(0, this.genotypeLengthPerProgram * this.gpAreas.length);
//if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor()); //if (mutationIndex > 28) System.out.println("Mutate: " + this.getSolutionRepresentationFor());
if (this.m_Genotype.get(mutationIndex)) { if (this.genotype.get(mutationIndex)) {
this.m_Genotype.clear(mutationIndex); this.genotype.clear(mutationIndex);
} else { } else {
this.m_Genotype.set(mutationIndex); this.genotype.set(mutationIndex);
} }
//if (mutationIndex > 28) System.out.println(this.getSolutionRepresentationFor()); //if (mutationIndex > 28) System.out.println(this.getSolutionRepresentationFor());
} }
@ -709,11 +709,11 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
* @param size The length * @param size The length
*/ */
public void setGenotypeLengthPerProgram(int size) { public void setGenotypeLengthPerProgram(int size) {
this.m_GenotypeLengthPerProgram = size; this.genotypeLengthPerProgram = size;
} }
public int getGenotypeLengthPerProgram() { public int getGenotypeLengthPerProgram() {
return this.m_GenotypeLengthPerProgram; return this.genotypeLengthPerProgram;
} }
public String genotypeLengthPerProgramTipText() { public String genotypeLengthPerProgramTipText() {
@ -727,11 +727,11 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
* @param nodes The maximum number of nodes * @param nodes The maximum number of nodes
*/ */
public void setMaxNumberOfNodes(int nodes) { public void setMaxNumberOfNodes(int nodes) {
this.m_MaxNumberOfNodes = nodes; this.maxNumberOfNodes = nodes;
} }
public int getMaxNumberOfNodes() { public int getMaxNumberOfNodes() {
return this.m_MaxNumberOfNodes; return this.maxNumberOfNodes;
} }
public String maxNumberOfNodesTipText() { public String maxNumberOfNodesTipText() {
@ -745,11 +745,11 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
* @param length The number of bits per int. * @param length The number of bits per int.
*/ */
public void setNumberOfBitPerInt(int length) { public void setNumberOfBitPerInt(int length) {
this.m_NumberOfBitPerInt = length; this.numberOfBitPerInt = length;
} }
public int getNumberOfBitPerInt() { public int getNumberOfBitPerInt() {
return this.m_NumberOfBitPerInt; return this.numberOfBitPerInt;
} }
public String numberOfBitPerIntTipText() { public String numberOfBitPerIntTipText() {

View File

@ -14,21 +14,21 @@ import eva2.util.annotation.Description;
@Description(value = "This is a GI individual suited to optimize int values.") @Description(value = "This is a GI individual suited to optimize int values.")
public class GIIndividualIntegerData extends AbstractEAIndividual implements InterfaceGIIndividual, InterfaceDataTypeInteger, java.io.Serializable { public class GIIndividualIntegerData extends AbstractEAIndividual implements InterfaceGIIndividual, InterfaceDataTypeInteger, java.io.Serializable {
private int[] m_Phenotype; private int[] phenotype;
private int[][] m_Range; private int[][] initializationRange;
protected int[] m_Genotype; protected int[] genotype;
public GIIndividualIntegerData() { public GIIndividualIntegerData() {
this.mutationProbability = 0.2; this.mutationProbability = 0.2;
this.mutationOperator = new MutateDefault(); this.mutationOperator = new MutateDefault();
this.crossoverProbability = 0.7; this.crossoverProbability = 0.7;
this.crossoverOperator = new CrossoverGIDefault(); this.crossoverOperator = new CrossoverGIDefault();
this.m_Range = new int[10][2]; this.initializationRange = new int[10][2];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
this.m_Range[i][0] = 0; this.initializationRange[i][0] = 0;
this.m_Range[i][1] = 7; this.initializationRange[i][1] = 7;
} }
this.m_Genotype = new int[10]; this.genotype = new int[10];
} }
public GIIndividualIntegerData(int[][] theRange) { public GIIndividualIntegerData(int[][] theRange) {
@ -37,19 +37,19 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
} }
public GIIndividualIntegerData(GIIndividualIntegerData individual) { public GIIndividualIntegerData(GIIndividualIntegerData individual) {
if (individual.m_Phenotype != null) { if (individual.phenotype != null) {
this.m_Phenotype = new int[individual.m_Phenotype.length]; this.phenotype = new int[individual.phenotype.length];
System.arraycopy(individual.m_Phenotype, 0, this.m_Phenotype, 0, this.m_Phenotype.length); System.arraycopy(individual.phenotype, 0, this.phenotype, 0, this.phenotype.length);
} }
if (individual.m_Genotype != null) { if (individual.genotype != null) {
this.m_Genotype = new int[individual.m_Genotype.length]; this.genotype = new int[individual.genotype.length];
System.arraycopy(individual.m_Genotype, 0, this.m_Genotype, 0, this.m_Genotype.length); System.arraycopy(individual.genotype, 0, this.genotype, 0, this.genotype.length);
} }
this.m_Range = new int[individual.m_Range.length][2]; this.initializationRange = new int[individual.initializationRange.length][2];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
this.m_Range[i][0] = individual.m_Range[i][0]; this.initializationRange[i][0] = individual.initializationRange[i][0];
this.m_Range[i][1] = individual.m_Range[i][1]; this.initializationRange[i][1] = individual.initializationRange[i][1];
} }
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
@ -85,20 +85,20 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof GIIndividualIntegerData) { if (individual instanceof GIIndividualIntegerData) {
GIIndividualIntegerData indy = (GIIndividualIntegerData) individual; GIIndividualIntegerData indy = (GIIndividualIntegerData) individual;
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) { if ((this.genotype == null) || (indy.genotype == null)) {
return false; return false;
} }
if (this.m_Genotype.length != indy.m_Genotype.length) { if (this.genotype.length != indy.genotype.length) {
return false; return false;
} }
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
if (this.m_Genotype[i] != indy.m_Genotype[i]) { if (this.genotype[i] != indy.genotype[i]) {
return false; return false;
} }
if (this.m_Range[i][0] != indy.m_Range[i][0]) { if (this.initializationRange[i][0] != indy.initializationRange[i][0]) {
return false; return false;
} }
if (this.m_Range[i][1] != indy.m_Range[i][1]) { if (this.initializationRange[i][1] != indy.initializationRange[i][1]) {
return false; return false;
} }
} }
@ -122,20 +122,20 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
int[][] newRange = new int[length][2]; int[][] newRange = new int[length][2];
// copy the old values for the decision parameters and the range // copy the old values for the decision parameters and the range
for (int i = 0; ((i < newDesPa.length) && (i < this.m_Genotype.length)); i++) { for (int i = 0; ((i < newDesPa.length) && (i < this.genotype.length)); i++) {
newDesPa[i] = this.m_Genotype[i]; newDesPa[i] = this.genotype[i];
newRange[i][0] = this.m_Range[i][0]; newRange[i][0] = this.initializationRange[i][0];
newRange[i][1] = this.m_Range[i][1]; newRange[i][1] = this.initializationRange[i][1];
} }
// if the new length is bigger than the last value fills the extra elements // if the new length is bigger than the last value fills the extra elements
for (int i = this.m_Genotype.length; (i < newDesPa.length); i++) { for (int i = this.genotype.length; (i < newDesPa.length); i++) {
newDesPa[i] = this.m_Genotype[this.m_Genotype.length - 1]; newDesPa[i] = this.genotype[this.genotype.length - 1];
newRange[i][0] = this.m_Range[this.m_Genotype.length - 1][0]; newRange[i][0] = this.initializationRange[this.genotype.length - 1][0];
newRange[i][1] = this.m_Range[this.m_Genotype.length - 1][1]; newRange[i][1] = this.initializationRange[this.genotype.length - 1][1];
} }
this.m_Genotype = newDesPa; this.genotype = newDesPa;
this.m_Range = newRange; this.initializationRange = newRange;
} }
/** /**
@ -145,7 +145,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int size() { public int size() {
return this.m_Range.length; return this.initializationRange.length;
} }
/** /**
@ -157,12 +157,12 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public void setIntRange(int[][] range) { public void setIntRange(int[][] range) {
if (range.length != this.m_Range.length) { if (range.length != this.initializationRange.length) {
this.setIntegerDataLength(range.length); this.setIntegerDataLength(range.length);
} }
for (int i = 0; ((i < this.m_Range.length) && (i < range.length)); i++) { for (int i = 0; ((i < this.initializationRange.length) && (i < range.length)); i++) {
this.m_Range[i][0] = range[i][0]; this.initializationRange[i][0] = range[i][0];
this.m_Range[i][1] = range[i][1]; this.initializationRange[i][1] = range[i][1];
} }
} }
@ -173,7 +173,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int[][] getIntRange() { public int[][] getIntRange() {
return this.m_Range; return this.initializationRange;
} }
/** /**
@ -183,11 +183,11 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int[] getIntegerData() { public int[] getIntegerData() {
this.m_Phenotype = new int[this.m_Range.length]; this.phenotype = new int[this.initializationRange.length];
for (int i = 0; i < this.m_Phenotype.length; i++) { for (int i = 0; i < this.phenotype.length; i++) {
this.m_Phenotype[i] = this.m_Genotype[i]; this.phenotype[i] = this.genotype[i];
} }
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -198,7 +198,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int[] getIntegerDataWithoutUpdate() { public int[] getIntegerDataWithoutUpdate() {
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -208,7 +208,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public void setIntPhenotype(int[] doubleData) { public void setIntPhenotype(int[] doubleData) {
this.m_Phenotype = doubleData; this.phenotype = doubleData;
} }
/** /**
@ -220,9 +220,9 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
@Override @Override
public void setIntGenotype(int[] doubleData) { public void setIntGenotype(int[] doubleData) {
this.setIntPhenotype(doubleData); this.setIntPhenotype(doubleData);
this.m_Genotype = new int[this.m_Range.length]; this.genotype = new int[this.initializationRange.length];
for (int i = 0; i < doubleData.length; i++) { for (int i = 0; i < doubleData.length; i++) {
this.m_Genotype[i] = doubleData[i]; this.genotype[i] = doubleData[i];
} }
} }
@ -240,7 +240,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof int[]) { if (obj instanceof int[]) {
int[] bs = (int[]) obj; int[] bs = (int[]) obj;
if (bs.length != this.m_Range.length) { if (bs.length != this.initializationRange.length) {
System.out.println("Init value and requested length doesn't match!"); System.out.println("Init value and requested length doesn't match!");
} }
this.setIntGenotype(bs); this.setIntGenotype(bs);
@ -278,8 +278,8 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
} }
result += "]\n"; result += "]\n";
result += "CodingRange: ["; result += "CodingRange: [";
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.initializationRange.length; i++) {
result += "(" + this.m_Range[i][0] + "; " + this.m_Range[i][1] + "); "; result += "(" + this.initializationRange[i][0] + "; " + this.initializationRange[i][1] + "); ";
} }
result += "]\n"; result += "]\n";
return result; return result;
@ -296,7 +296,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int[] getIGenotype() { public int[] getIGenotype() {
return this.m_Genotype; return this.genotype;
} }
/** /**
@ -309,7 +309,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public void setIGenotype(int[] b) { public void setIGenotype(int[] b) {
this.m_Genotype = b; this.genotype = b;
} }
/** /**
@ -321,7 +321,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int getGenotypeLength() { public int getGenotypeLength() {
return this.m_Genotype.length; return this.genotype.length;
} }
/** /**
@ -329,13 +329,13 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public void defaultMutate() { public void defaultMutate() {
int mutationIndex = RNG.randomInt(0, this.m_Genotype.length - 1); int mutationIndex = RNG.randomInt(0, this.genotype.length - 1);
this.m_Genotype[mutationIndex] = RNG.randomInt(this.m_Range[mutationIndex][0], this.m_Range[mutationIndex][1]); this.genotype[mutationIndex] = RNG.randomInt(this.initializationRange[mutationIndex][0], this.initializationRange[mutationIndex][1]);
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
int[][] range = m_Range; int[][] range = initializationRange;
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) { if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
Object rng = ((InterfaceHasInitRange) prob).getInitRange(); Object rng = ((InterfaceHasInitRange) prob).getInitRange();
if (rng instanceof double[][]) { if (rng instanceof double[][]) {
@ -353,8 +353,8 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
} }
} }
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
this.m_Genotype[i] = RNG.randomInt(range[i][0], range[i][1]); this.genotype[i] = RNG.randomInt(range[i][0], range[i][1]);
} }
} }

View File

@ -12,19 +12,19 @@ import eva2.util.annotation.Description;
@Description(value = "This is a mixed data type combining an integer vector with a permutation vector.") @Description(value = "This is a mixed data type combining an integer vector with a permutation vector.")
public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual implements InterfaceDataTypeInteger, InterfaceDataTypePermutation, java.io.Serializable { public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual implements InterfaceDataTypeInteger, InterfaceDataTypePermutation, java.io.Serializable {
private InterfaceDataTypeInteger m_Integer = new GIIndividualIntegerData(); private InterfaceDataTypeInteger integerData = new GIIndividualIntegerData();
private InterfaceDataTypePermutation m_Permutation = new OBGAIndividualPermutationData(); private InterfaceDataTypePermutation permutationData = new OBGAIndividualPermutationData();
public GIOBGAIndividualIntegerPermutationData() { public GIOBGAIndividualIntegerPermutationData() {
this.mutationProbability = 1.0; this.mutationProbability = 1.0;
this.crossoverProbability = 1.0; this.crossoverProbability = 1.0;
this.m_Integer = new GIIndividualIntegerData(); this.integerData = new GIIndividualIntegerData();
this.m_Permutation = new OBGAIndividualPermutationData(); this.permutationData = new OBGAIndividualPermutationData();
} }
public GIOBGAIndividualIntegerPermutationData(GIOBGAIndividualIntegerPermutationData individual) { public GIOBGAIndividualIntegerPermutationData(GIOBGAIndividualIntegerPermutationData individual) {
this.m_Integer = (InterfaceDataTypeInteger) ((AbstractEAIndividual) individual.getIntegers()).clone(); this.integerData = (InterfaceDataTypeInteger) ((AbstractEAIndividual) individual.getIntegers()).clone();
this.m_Permutation = (InterfaceDataTypePermutation) ((AbstractEAIndividual) individual.getPermutations()).clone(); this.permutationData = (InterfaceDataTypePermutation) ((AbstractEAIndividual) individual.getPermutations()).clone();
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
this.age = individual.age; this.age = individual.age;
@ -58,10 +58,10 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof GIOBGAIndividualIntegerPermutationData) { if (individual instanceof GIOBGAIndividualIntegerPermutationData) {
GIOBGAIndividualIntegerPermutationData indy = (GIOBGAIndividualIntegerPermutationData) individual; GIOBGAIndividualIntegerPermutationData indy = (GIOBGAIndividualIntegerPermutationData) individual;
if (!((AbstractEAIndividual) this.m_Integer).equalGenotypes((AbstractEAIndividual) indy.m_Integer)) { if (!((AbstractEAIndividual) this.integerData).equalGenotypes((AbstractEAIndividual) indy.integerData)) {
return false; return false;
} }
if (!((AbstractEAIndividual) this.m_Permutation).equalGenotypes((AbstractEAIndividual) indy.m_Permutation)) { if (!((AbstractEAIndividual) this.permutationData).equalGenotypes((AbstractEAIndividual) indy.permutationData)) {
return false; return false;
} }
return true; return true;
@ -77,14 +77,14 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public void init(InterfaceOptimizationProblem opt) { public void init(InterfaceOptimizationProblem opt) {
((AbstractEAIndividual) this.m_Integer).init(opt); ((AbstractEAIndividual) this.integerData).init(opt);
((AbstractEAIndividual) this.m_Permutation).init(opt); ((AbstractEAIndividual) this.permutationData).init(opt);
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
((AbstractEAIndividual) this.m_Integer).defaultInit(prob); ((AbstractEAIndividual) this.integerData).defaultInit(prob);
((AbstractEAIndividual) this.m_Permutation).defaultInit(prob); ((AbstractEAIndividual) this.permutationData).defaultInit(prob);
} }
/** /**
@ -98,15 +98,15 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof Object[]) { if (obj instanceof Object[]) {
if (((Object[]) obj)[0] instanceof double[]) { if (((Object[]) obj)[0] instanceof double[]) {
((AbstractEAIndividual) this.m_Integer).initByValue(((Object[]) obj)[0], opt); ((AbstractEAIndividual) this.integerData).initByValue(((Object[]) obj)[0], opt);
((AbstractEAIndividual) this.m_Permutation).initByValue(((Object[]) obj)[1], opt); ((AbstractEAIndividual) this.permutationData).initByValue(((Object[]) obj)[1], opt);
} else { } else {
((AbstractEAIndividual) this.m_Integer).initByValue(((Object[]) obj)[1], opt); ((AbstractEAIndividual) this.integerData).initByValue(((Object[]) obj)[1], opt);
((AbstractEAIndividual) this.m_Permutation).initByValue(((Object[]) obj)[0], opt); ((AbstractEAIndividual) this.permutationData).initByValue(((Object[]) obj)[0], opt);
} }
} else { } else {
((AbstractEAIndividual) this.m_Integer).init(opt); ((AbstractEAIndividual) this.integerData).init(opt);
((AbstractEAIndividual) this.m_Permutation).init(opt); ((AbstractEAIndividual) this.permutationData).init(opt);
System.out.println("Initial value for GIOBGAIndividualIntegerPermutationData is not suitable!"); System.out.println("Initial value for GIOBGAIndividualIntegerPermutationData is not suitable!");
} }
} }
@ -117,17 +117,17 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
@Override @Override
public void mutate() { public void mutate() {
if (RNG.flipCoin(this.mutationProbability)) { if (RNG.flipCoin(this.mutationProbability)) {
((AbstractEAIndividual) this.m_Integer).mutate(); ((AbstractEAIndividual) this.integerData).mutate();
} }
if (RNG.flipCoin(this.mutationProbability)) { if (RNG.flipCoin(this.mutationProbability)) {
((AbstractEAIndividual) this.m_Permutation).mutate(); ((AbstractEAIndividual) this.permutationData).mutate();
} }
} }
@Override @Override
public void defaultMutate() { public void defaultMutate() {
((AbstractEAIndividual) this.m_Integer).defaultMutate(); ((AbstractEAIndividual) this.integerData).defaultMutate();
((AbstractEAIndividual) this.m_Permutation).defaultMutate(); ((AbstractEAIndividual) this.permutationData).defaultMutate();
} }
/** /**
@ -169,17 +169,6 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
((GIOBGAIndividualIntegerPermutationData) result[i]).setIntegers((InterfaceDataTypeInteger) resNum[i]); ((GIOBGAIndividualIntegerPermutationData) result[i]).setIntegers((InterfaceDataTypeInteger) resNum[i]);
((GIOBGAIndividualIntegerPermutationData) result[i]).setPermutations((InterfaceDataTypePermutation) resBin[i]); ((GIOBGAIndividualIntegerPermutationData) result[i]).setPermutations((InterfaceDataTypePermutation) resBin[i]);
} }
// result = ((AbstractEAIndividual)this.m_Numbers).mateWith(partners);
// AbstractEAIndividual dad = (AbstractEAIndividual)result[0];
// Population tpartners = new Population();
// for (int i = 1; i < result.length; i++) tpartners.add(result[i]);
// result = dad.mateWith(tpartners);
// out = "Result:\n";
// for (int i = 0; i < result.length; i++) out += result[i].getSolutionRepresentationFor() + "\n";
// System.out.println(out);
} else { } else {
// simply return a number of perfect clones // simply return a number of perfect clones
result = new AbstractEAIndividual[partners.size() + 1]; result = new AbstractEAIndividual[partners.size() + 1];
@ -203,8 +192,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
@Override @Override
public String getStringRepresentation() { public String getStringRepresentation() {
String result = "This is a hybrid Individual:\n"; String result = "This is a hybrid Individual:\n";
result += "The Integer Part:\n" + ((AbstractEAIndividual) this.m_Integer).getStringRepresentation(); result += "The Integer Part:\n" + ((AbstractEAIndividual) this.integerData).getStringRepresentation();
result += "\nThe Permutation Part:\n" + ((AbstractEAIndividual) this.m_Permutation).getStringRepresentation(); result += "\nThe Permutation Part:\n" + ((AbstractEAIndividual) this.permutationData).getStringRepresentation();
return result; return result;
} }
@ -218,7 +207,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public void setIntegerDataLength(int length) { public void setIntegerDataLength(int length) {
this.m_Integer.setIntegerDataLength(length); this.integerData.setIntegerDataLength(length);
} }
/** /**
@ -228,7 +217,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public int size() { public int size() {
return this.m_Integer.size(); return this.integerData.size();
} }
/** /**
@ -240,7 +229,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public void setIntRange(int[][] range) { public void setIntRange(int[][] range) {
this.m_Integer.setIntRange(range); this.integerData.setIntRange(range);
} }
/** /**
@ -250,7 +239,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public int[][] getIntRange() { public int[][] getIntRange() {
return this.m_Integer.getIntRange(); return this.integerData.getIntRange();
} }
/** /**
@ -260,7 +249,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public int[] getIntegerData() { public int[] getIntegerData() {
return this.m_Integer.getIntegerData(); return this.integerData.getIntegerData();
} }
/** /**
@ -271,7 +260,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public int[] getIntegerDataWithoutUpdate() { public int[] getIntegerDataWithoutUpdate() {
return this.m_Integer.getIntegerDataWithoutUpdate(); return this.integerData.getIntegerDataWithoutUpdate();
} }
/** /**
@ -281,7 +270,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public void setIntPhenotype(int[] intData) { public void setIntPhenotype(int[] intData) {
this.m_Integer.setIntPhenotype(intData); this.integerData.setIntPhenotype(intData);
} }
/** /**
@ -292,7 +281,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public void setIntGenotype(int[] intData) { public void setIntGenotype(int[] intData) {
this.m_Integer.setIntGenotype(intData); this.integerData.setIntGenotype(intData);
} }
/********************************************************************************************************************** /**********************************************************************************************************************
@ -305,8 +294,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public void setPermutationDataLength(int[] length) { public void setPermutationDataLength(int[] length) {
this.m_Permutation.setPermutationDataLength(length); this.permutationData.setPermutationDataLength(length);
this.m_Integer.setIntegerDataLength(length.length); this.integerData.setIntegerDataLength(length.length);
} }
/** /**
@ -316,7 +305,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public int[] sizePermutation() { public int[] sizePermutation() {
return this.m_Permutation.sizePermutation(); return this.permutationData.sizePermutation();
} }
/** /**
@ -326,7 +315,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public int[][] getPermutationData() { public int[][] getPermutationData() {
return this.m_Permutation.getPermutationData(); return this.permutationData.getPermutationData();
} }
/** /**
@ -337,7 +326,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
*/ */
@Override @Override
public int[][] getPermutationDataWithoutUpdate() { public int[][] getPermutationDataWithoutUpdate() {
return this.m_Permutation.getPermutationDataWithoutUpdate(); return this.permutationData.getPermutationDataWithoutUpdate();
} }
/** /**
@ -363,7 +352,7 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
@Override @Override
public void setFirstindex(int[] firstindex) { public void setFirstindex(int[] firstindex) {
this.m_Permutation.setFirstindex(firstindex); this.permutationData.setFirstindex(firstindex);
} }
/** /**
@ -383,11 +372,11 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
* @param Numbers The new representation for the inner constants. * @param Numbers The new representation for the inner constants.
*/ */
public void setIntegers(InterfaceDataTypeInteger Numbers) { public void setIntegers(InterfaceDataTypeInteger Numbers) {
this.m_Integer = Numbers; this.integerData = Numbers;
} }
public InterfaceDataTypeInteger getIntegers() { public InterfaceDataTypeInteger getIntegers() {
return this.m_Integer; return this.integerData;
} }
public String integersTipText() { public String integersTipText() {
@ -400,11 +389,11 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
* @param p The new representation for the inner constants. * @param p The new representation for the inner constants.
*/ */
public void setPermutations(InterfaceDataTypePermutation p) { public void setPermutations(InterfaceDataTypePermutation p) {
this.m_Permutation = p; this.permutationData = p;
} }
public InterfaceDataTypePermutation getPermutations() { public InterfaceDataTypePermutation getPermutations() {
return this.m_Permutation; return this.permutationData;
} }
public String permutationsTipText() { public String permutationsTipText() {

View File

@ -153,7 +153,7 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
if ((this.checkMaxDepth) && (this.phenotype[i].isMaxDepthViolated(this.maxAllowedDepth))) { if ((this.checkMaxDepth) && (this.phenotype[i].isMaxDepthViolated(this.maxAllowedDepth))) {
System.err.println("Trying to meet the Target Depth! " + this.phenotype[i].isMaxDepthViolated(this.maxAllowedDepth) + " " + phenotype[i].getMaxDepth()); System.err.println("Trying to meet the Target Depth! " + this.phenotype[i].isMaxDepthViolated(this.maxAllowedDepth) + " " + phenotype[i].getMaxDepth());
this.phenotype[i].repairMaxDepth(this.gpArea[i], this.maxAllowedDepth); this.phenotype[i].repairMaxDepth(this.gpArea[i], this.maxAllowedDepth);
//System.out.println("TragetDepth: " + this.m_TargetDepth + " : " + this.m_Program.getMaxDepth()); //System.out.println("TragetDepth: " + this.targetDepth + " : " + this.m_Program.getMaxDepth());
} }
} }
return this.phenotype; return this.phenotype;

View File

@ -9,15 +9,10 @@ import java.util.BitSet;
/** /**
* This gives the gray coding for double with a variable number of bits for coding * This gives the gray coding for double with a variable number of bits for coding
* As far as i recall the least significant bit is to the left. * As far as i recall the least significant bit is to the left.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 24.03.2003
* Time: 18:39:51
* To change this template use Options | File Templates.
*/ */
public class GAGrayCodingDouble implements InterfaceGADoubleCoding, java.io.Serializable { public class GAGrayCodingDouble implements InterfaceGADoubleCoding, java.io.Serializable {
GAStandardCodingDouble m_HelpingHand = new GAStandardCodingDouble(); GAStandardCodingDouble standardCodingDouble = new GAStandardCodingDouble();
/** /**
* This method decodes a part of a given BitSet into a double value. This method may change the contens * This method decodes a part of a given BitSet into a double value. This method may change the contens
@ -52,7 +47,7 @@ public class GAGrayCodingDouble implements InterfaceGADoubleCoding, java.io.Seri
tmpBitSet.clear(i); tmpBitSet.clear(i);
} }
} }
return this.m_HelpingHand.decodeValue(tmpBitSet, range, tmpLocus, correction); return this.standardCodingDouble.decodeValue(tmpBitSet, range, tmpLocus, correction);
} }
/** /**
@ -74,7 +69,7 @@ public class GAGrayCodingDouble implements InterfaceGADoubleCoding, java.io.Seri
tmpLocus[0] = 0; tmpLocus[0] = 0;
tmpLocus[1] = locus[1]; tmpLocus[1] = locus[1];
tmpBitSet = new BitSet(tmpLocus.length); tmpBitSet = new BitSet(tmpLocus.length);
this.m_HelpingHand.codeValue(value, range, tmpBitSet, tmpLocus); this.standardCodingDouble.codeValue(value, range, tmpBitSet, tmpLocus);
if (tmpBitSet.get(0)) { if (tmpBitSet.get(0)) {
refBitSet.set(locus[0]); refBitSet.set(locus[0]);
} else { } else {

View File

@ -4,15 +4,10 @@ import java.util.BitSet;
/** /**
* This is a gray coding for integers, sorry no variable number of bits here. * This is a gray coding for integers, sorry no variable number of bits here.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 24.03.2003
* Time: 18:40:03
* To change this template use Options | File Templates.
*/ */
public class GAGrayCodingInteger implements InterfaceGAIntegerCoding, java.io.Serializable { public class GAGrayCodingInteger implements InterfaceGAIntegerCoding, java.io.Serializable {
GAStandardCodingInteger m_HelpingHand = new GAStandardCodingInteger(); GAStandardCodingInteger standardCodingInteger = new GAStandardCodingInteger();
/** /**
* This method decodes a part of a given BitSet into a int value. This method may change the contens * This method decodes a part of a given BitSet into a int value. This method may change the contens
@ -52,7 +47,7 @@ public class GAGrayCodingInteger implements InterfaceGAIntegerCoding, java.io.Se
tmpBitSet.clear(i); tmpBitSet.clear(i);
} }
} }
return this.m_HelpingHand.decodeValue(tmpBitSet, range, tmpLocus, correction); return this.standardCodingInteger.decodeValue(tmpBitSet, range, tmpLocus, correction);
} }
/** /**
@ -74,7 +69,7 @@ public class GAGrayCodingInteger implements InterfaceGAIntegerCoding, java.io.Se
tmpLocus[0] = 0; tmpLocus[0] = 0;
tmpLocus[1] = locus[1]; tmpLocus[1] = locus[1];
tmpBitSet = new BitSet(tmpLocus.length); tmpBitSet = new BitSet(tmpLocus.length);
this.m_HelpingHand.codeValue(value, range, tmpBitSet, tmpLocus); this.standardCodingInteger.codeValue(value, range, tmpBitSet, tmpLocus);
// if (tmpBitSet.get(0)) refBitSet.set(locus[1]); // if (tmpBitSet.get(0)) refBitSet.set(locus[1]);
// else refBitSet.clear(locus[1]); // else refBitSet.clear(locus[1]);
@ -103,7 +98,7 @@ public class GAGrayCodingInteger implements InterfaceGAIntegerCoding, java.io.Se
*/ */
@Override @Override
public int calculateNecessaryBits(int[] range) { public int calculateNecessaryBits(int[] range) {
return this.m_HelpingHand.calculateNecessaryBits(range); return this.standardCodingInteger.calculateNecessaryBits(range);
} }
/** /**

View File

@ -8,11 +8,6 @@ import java.util.BitSet;
/** /**
* The traditional binary coding for integer number, no variable number of bits here, sorry. * The traditional binary coding for integer number, no variable number of bits here, sorry.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 24.03.2003
* Time: 16:38:45
* To change this template use Options | File Templates.
*/ */
public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.io.Serializable { public class GAStandardCodingInteger implements InterfaceGAIntegerCoding, java.io.Serializable {

View File

@ -17,16 +17,11 @@ import java.util.Vector;
/** /**
* This gives an abstract node, with default functionality for get and set methods. * This gives an abstract node, with default functionality for get and set methods.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 04.04.2003
* Time: 13:12:53
* To change this template use Options | File Templates.
*/ */
public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serializable { public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serializable {
protected AbstractGPNode m_Parent; protected AbstractGPNode parentNode;
protected AbstractGPNode[] m_Nodes = new AbstractGPNode[0]; protected AbstractGPNode[] nodes = new AbstractGPNode[0];
protected int m_Depth = 0; protected int depth = 0;
private static final boolean TRACE = false; private static final boolean TRACE = false;
/** /**
@ -77,11 +72,11 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @param node the node to clone values from * @param node the node to clone values from
*/ */
protected void cloneMembers(AbstractGPNode node) { protected void cloneMembers(AbstractGPNode node) {
this.m_Depth = node.m_Depth; this.depth = node.depth;
this.m_Parent = node.m_Parent; this.parentNode = node.parentNode;
this.m_Nodes = new AbstractGPNode[node.m_Nodes.length]; this.nodes = new AbstractGPNode[node.nodes.length];
for (int i = 0; i < node.m_Nodes.length; i++) { for (int i = 0; i < node.nodes.length; i++) {
this.m_Nodes[i] = (AbstractGPNode) node.m_Nodes[i].clone(); this.nodes[i] = (AbstractGPNode) node.nodes[i].clone();
} }
} }
@ -90,9 +85,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
sbuf.append(op); sbuf.append(op);
if (node.getArity() > 0) { if (node.getArity() > 0) {
sbuf.append("("); sbuf.append("(");
for (int i = 0; i < node.m_Nodes.length; i++) { for (int i = 0; i < node.nodes.length; i++) {
sbuf.append(node.m_Nodes[i].getStringRepresentation()); sbuf.append(node.nodes[i].getStringRepresentation());
if (i < node.m_Nodes.length - 1) { if (i < node.nodes.length - 1) {
sbuf.append(", "); sbuf.append(", ");
} }
} }
@ -156,10 +151,10 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
return new Pair<AbstractGPNode, String>(currentNode, restStr); return new Pair<AbstractGPNode, String>(currentNode, restStr);
} else { } else {
restStr = str.substring(cutFront + 1).trim(); // cut this op and front brace restStr = str.substring(cutFront + 1).trim(); // cut this op and front brace
currentNode.m_Nodes = new AbstractGPNode[currentNode.getArity()]; currentNode.nodes = new AbstractGPNode[currentNode.getArity()];
for (int i = 0; i < currentNode.getArity(); i++) { for (int i = 0; i < currentNode.getArity(); i++) {
Pair<AbstractGPNode, String> nextState = parseFromString(restStr, nodeTypes); Pair<AbstractGPNode, String> nextState = parseFromString(restStr, nodeTypes);
currentNode.m_Nodes[i] = nextState.head(); currentNode.nodes[i] = nextState.head();
try { try {
restStr = nextState.tail().substring(1).trim(); // cut comma or brace restStr = nextState.tail().substring(1).trim(); // cut comma or brace
} catch (StringIndexOutOfBoundsException e) { } catch (StringIndexOutOfBoundsException e) {
@ -384,7 +379,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @return The depth. * @return The depth.
*/ */
public int getDepth() { public int getDepth() {
return this.m_Depth; return this.depth;
} }
/** /**
@ -393,7 +388,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @param depth The depth of the node * @param depth The depth of the node
*/ */
public void setDepth(int depth) { public void setDepth(int depth) {
this.m_Depth = depth; this.depth = depth;
} }
/** /**
@ -403,7 +398,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @return The requested node. * @return The requested node.
*/ */
public AbstractGPNode getNode(int index) { public AbstractGPNode getNode(int index) {
return this.m_Nodes[index]; return this.nodes[index];
} }
/** /**
@ -414,8 +409,8 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
*/ */
public void setNode(AbstractGPNode node, int index) { public void setNode(AbstractGPNode node, int index) {
node.setParent(this); node.setParent(this);
node.setDepth(this.m_Depth + 1); node.setDepth(this.depth + 1);
this.m_Nodes[index] = node; this.nodes[index] = node;
} }
/** /**
@ -426,10 +421,10 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
*/ */
public void setNode(AbstractGPNode newnode, AbstractGPNode oldnode) { public void setNode(AbstractGPNode newnode, AbstractGPNode oldnode) {
newnode.setParent(this); newnode.setParent(this);
newnode.updateDepth(this.m_Depth + 1); newnode.updateDepth(this.depth + 1);
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
if (this.m_Nodes[i] == oldnode) { if (this.nodes[i] == oldnode) {
this.m_Nodes[i] = newnode; this.nodes[i] = newnode;
// System.out.println("SWITCHED " + i); // System.out.println("SWITCHED " + i);
} }
} }
@ -442,8 +437,8 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
*/ */
public void addNodesTo(ArrayList ListOfNodes) { public void addNodesTo(ArrayList ListOfNodes) {
ListOfNodes.add(this); ListOfNodes.add(this);
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
this.m_Nodes[i].addNodesTo(ListOfNodes); this.nodes[i].addNodesTo(ListOfNodes);
} }
} }
@ -464,9 +459,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @return * @return
*/ */
public AbstractGPNode getRandomLeaf() { public AbstractGPNode getRandomLeaf() {
if (m_Nodes.length > 0) { if (nodes.length > 0) {
int k = RNG.randomInt(m_Nodes.length); int k = RNG.randomInt(nodes.length);
return m_Nodes[k].getRandomLeaf(); return nodes[k].getRandomLeaf();
} else { } else {
return this; return this;
} }
@ -478,14 +473,14 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @param parent The new parent * @param parent The new parent
*/ */
public void setParent(AbstractGPNode parent) { public void setParent(AbstractGPNode parent) {
this.m_Parent = parent; this.parentNode = parent;
} }
/** /**
* This method allows you to get the parent of the node * This method allows you to get the parent of the node
*/ */
public AbstractGPNode getParent() { public AbstractGPNode getParent() {
return this.m_Parent; return this.parentNode;
} }
/** /**
@ -494,14 +489,14 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @param parent The parent * @param parent The parent
*/ */
public void connect(AbstractGPNode parent) { public void connect(AbstractGPNode parent) {
this.m_Parent = parent; this.parentNode = parent;
if (parent != null) { if (parent != null) {
this.m_Depth = this.m_Parent.getDepth() + 1; this.depth = this.parentNode.getDepth() + 1;
} else { } else {
this.m_Depth = 0; this.depth = 0;
} }
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
this.m_Nodes[i].connect(this); this.nodes[i].connect(this);
} }
} }
@ -509,7 +504,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* This method will simply init the array of nodes * This method will simply init the array of nodes
*/ */
public void initNodeArray() { public void initNodeArray() {
this.m_Nodes = new AbstractGPNode[this.getArity()]; this.nodes = new AbstractGPNode[this.getArity()];
} }
/** /**
@ -519,16 +514,16 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @param depth The absolute target depth. * @param depth The absolute target depth.
*/ */
public void initFull(GPArea area, int depth) { public void initFull(GPArea area, int depth) {
this.m_Nodes = new AbstractGPNode[this.getArity()]; this.nodes = new AbstractGPNode[this.getArity()];
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
if (this.m_Depth + 1 >= depth) { if (this.depth + 1 >= depth) {
this.m_Nodes[i] = (AbstractGPNode) area.getRandomNodeWithArity(0).clone(); this.nodes[i] = (AbstractGPNode) area.getRandomNodeWithArity(0).clone();
} else { } else {
this.m_Nodes[i] = (AbstractGPNode) area.getRandomNonTerminal().clone(); this.nodes[i] = (AbstractGPNode) area.getRandomNonTerminal().clone();
} }
this.m_Nodes[i].setDepth(this.m_Depth + 1); this.nodes[i].setDepth(this.depth + 1);
this.m_Nodes[i].setParent(this); this.nodes[i].setParent(this);
this.m_Nodes[i].initFull(area, depth); this.nodes[i].initFull(area, depth);
} }
} }
@ -539,16 +534,16 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @param depth The absolute target depth. * @param depth The absolute target depth.
*/ */
public void initGrow(GPArea area, int depth) { public void initGrow(GPArea area, int depth) {
this.m_Nodes = new AbstractGPNode[this.getArity()]; this.nodes = new AbstractGPNode[this.getArity()];
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
if (this.m_Depth + 1 >= depth) { if (this.depth + 1 >= depth) {
this.m_Nodes[i] = (AbstractGPNode) area.getRandomNodeWithArity(0).clone(); this.nodes[i] = (AbstractGPNode) area.getRandomNodeWithArity(0).clone();
} else { } else {
this.m_Nodes[i] = (AbstractGPNode) area.getRandomNode().clone(); this.nodes[i] = (AbstractGPNode) area.getRandomNode().clone();
} }
this.m_Nodes[i].setDepth(this.m_Depth + 1); this.nodes[i].setDepth(this.depth + 1);
this.m_Nodes[i].setParent(this); this.nodes[i].setParent(this);
this.m_Nodes[i].initGrow(area, depth); this.nodes[i].initGrow(area, depth);
} }
} }
@ -559,8 +554,8 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
*/ */
public int getNumberOfNodes() { public int getNumberOfNodes() {
int result = 1; int result = 1;
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
result += this.m_Nodes[i].getNumberOfNodes(); result += this.nodes[i].getNumberOfNodes();
} }
return result; return result;
} }
@ -571,10 +566,10 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @return The max depth. * @return The max depth.
*/ */
public int getMaxDepth() { public int getMaxDepth() {
int result = this.m_Depth; int result = this.depth;
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
if (this.m_Nodes[i] != null) { if (this.nodes[i] != null) {
result = Math.max(result, this.m_Nodes[i].getMaxDepth()); result = Math.max(result, this.nodes[i].getMaxDepth());
} }
} }
return result; return result;
@ -587,7 +582,7 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
*/ */
public int getSubtreeDepth() { public int getSubtreeDepth() {
int maxDepth = getMaxDepth(); int maxDepth = getMaxDepth();
return maxDepth - m_Depth; return maxDepth - depth;
} }
/** /**
@ -602,11 +597,11 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
} else { } else {
return false; return false;
} }
// if (depth > this.m_Depth) return false; // if (depth > this.depth) return false;
// else { // else {
// boolean result = true; // boolean result = true;
// for (int i = 0; i < this.m_Nodes.length; i++) { // for (int i = 0; i < this.nodes.length; i++) {
// result = result & this.m_Nodes[i].isMaxDepthViolated(depth); // result = result & this.nodes[i].isMaxDepthViolated(depth);
// } // }
// return result; // return result;
// } // }
@ -618,21 +613,21 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @param depth The max depth. * @param depth The max depth.
*/ */
public void repairMaxDepth(GPArea area, int depth) { public void repairMaxDepth(GPArea area, int depth) {
if (this.m_Depth == depth - 1) { if (this.depth == depth - 1) {
// in this case i need to check whether or not my // in this case i need to check whether or not my
// follow-up nodes are terminals // follow-up nodes are terminals
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
if (this.m_Nodes[i].getArity() != 0) { if (this.nodes[i].getArity() != 0) {
// replace this node with a new node // replace this node with a new node
this.m_Nodes[i] = (AbstractGPNode) area.getRandomNodeWithArity(0).clone(); this.nodes[i] = (AbstractGPNode) area.getRandomNodeWithArity(0).clone();
this.m_Nodes[i].setDepth(this.m_Depth + 1); this.nodes[i].setDepth(this.depth + 1);
this.m_Nodes[i].setParent(this); this.nodes[i].setParent(this);
} }
} }
} else { } else {
// else i call the method on my followup nodes // else i call the method on my followup nodes
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
this.m_Nodes[i].repairMaxDepth(area, depth); this.nodes[i].repairMaxDepth(area, depth);
} }
} }
@ -652,11 +647,11 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
if (this.getArity() != node.getArity()) { if (this.getArity() != node.getArity()) {
return false; return false;
} }
if (this.m_Nodes.length != node.m_Nodes.length) { if (this.nodes.length != node.nodes.length) {
return false; return false;
} }
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
if (!this.m_Nodes[i].equals(node.m_Nodes[i])) { if (!this.nodes[i].equals(node.nodes[i])) {
return false; return false;
} }
} }
@ -672,9 +667,9 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @param myDepth * @param myDepth
*/ */
public void updateDepth(int myDepth) { public void updateDepth(int myDepth) {
m_Depth = myDepth; depth = myDepth;
for (int i = 0; i < m_Nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
m_Nodes[i].updateDepth(myDepth + 1); nodes[i].updateDepth(myDepth + 1);
} }
} }
@ -684,12 +679,12 @@ public abstract class AbstractGPNode implements InterfaceProgram, java.io.Serial
* @param myDepth * @param myDepth
*/ */
public boolean checkDepth(int myDepth) { public boolean checkDepth(int myDepth) {
if (m_Depth != myDepth) { if (depth != myDepth) {
System.err.println("Depth was wrong at level " + myDepth); System.err.println("Depth was wrong at level " + myDepth);
return false; return false;
} }
for (int i = 0; i < m_Nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
if (!m_Nodes[i].checkDepth(myDepth + 1)) { if (!nodes[i].checkDepth(myDepth + 1)) {
return false; return false;
} }
} }

View File

@ -11,35 +11,30 @@ import java.util.ArrayList;
/** /**
* This class gives the area of GPNodes for a GP problem. The area gives * This class gives the area of GPNodes for a GP problem. The area gives
* the range of possible nodes to select from for a GP. * the range of possible nodes to select from for a GP.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 13.06.2003
* Time: 18:32:26
* To change this template use Options | File Templates.
*/ */
public class GPArea implements java.io.Serializable { public class GPArea implements java.io.Serializable {
/** /**
* Handles property change notification * Handles property change notification
*/ */
private transient PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private transient PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
private ArrayList<AbstractGPNode> m_CompleteList = new ArrayList<AbstractGPNode>(); private ArrayList<AbstractGPNode> completeList = new ArrayList<AbstractGPNode>();
private ArrayList<AbstractGPNode> m_ReducedList = new ArrayList<AbstractGPNode>(); private ArrayList<AbstractGPNode> reducedList = new ArrayList<AbstractGPNode>();
private ArrayList<Boolean> m_BlackList = new ArrayList<Boolean>(); private ArrayList<Boolean> blackList = new ArrayList<Boolean>();
public GPArea() { public GPArea() {
} }
public GPArea(GPArea g) { public GPArea(GPArea g) {
if (g.m_BlackList != null) { if (g.blackList != null) {
this.m_BlackList = (ArrayList<Boolean>) g.m_BlackList.clone(); this.blackList = (ArrayList<Boolean>) g.blackList.clone();
} }
if (g.m_ReducedList != null) { if (g.reducedList != null) {
this.m_ReducedList = (ArrayList<AbstractGPNode>) g.m_ReducedList.clone(); this.reducedList = (ArrayList<AbstractGPNode>) g.reducedList.clone();
} }
if (g.m_CompleteList != null) { if (g.completeList != null) {
this.m_CompleteList = (ArrayList<AbstractGPNode>) g.m_CompleteList.clone(); this.completeList = (ArrayList<AbstractGPNode>) g.completeList.clone();
} }
} }
@ -54,8 +49,8 @@ public class GPArea implements java.io.Serializable {
* @param n The Node that is to be added * @param n The Node that is to be added
*/ */
public void add2CompleteList(AbstractGPNode n) { public void add2CompleteList(AbstractGPNode n) {
this.m_CompleteList.add(n); this.completeList.add(n);
this.m_BlackList.add(new Boolean(true)); this.blackList.add(new Boolean(true));
} }
/** /**
@ -65,8 +60,8 @@ public class GPArea implements java.io.Serializable {
* @param b The initial BlacklLst value * @param b The initial BlacklLst value
*/ */
public void add2CompleteList(AbstractGPNode n, boolean b) { public void add2CompleteList(AbstractGPNode n, boolean b) {
this.m_CompleteList.add(n); this.completeList.add(n);
this.m_BlackList.add(new Boolean(b)); this.blackList.add(new Boolean(b));
} }
/** /**
@ -75,7 +70,7 @@ public class GPArea implements java.io.Serializable {
* @return blacklist * @return blacklist
*/ */
public ArrayList<Boolean> getBlackList() { public ArrayList<Boolean> getBlackList() {
return this.m_BlackList; return this.blackList;
} }
/** /**
@ -84,7 +79,7 @@ public class GPArea implements java.io.Serializable {
* @param a blacklist * @param a blacklist
*/ */
public void SetBlackList(ArrayList<Boolean> a) { public void SetBlackList(ArrayList<Boolean> a) {
this.m_BlackList = a; this.blackList = a;
} }
/** /**
@ -94,7 +89,7 @@ public class GPArea implements java.io.Serializable {
* @param b the boolean value * @param b the boolean value
*/ */
public void setBlackListElement(int i, boolean b) { public void setBlackListElement(int i, boolean b) {
this.m_BlackList.set(i, new Boolean(b)); this.blackList.set(i, new Boolean(b));
} }
/** /**
@ -103,7 +98,7 @@ public class GPArea implements java.io.Serializable {
* @return blacklist * @return blacklist
*/ */
public ArrayList<AbstractGPNode> getCompleteList() { public ArrayList<AbstractGPNode> getCompleteList() {
return this.m_CompleteList; return this.completeList;
} }
/** /**
@ -112,7 +107,7 @@ public class GPArea implements java.io.Serializable {
* @return blacklist * @return blacklist
*/ */
public ArrayList<AbstractGPNode> getReducedList() { public ArrayList<AbstractGPNode> getReducedList() {
return this.m_ReducedList; return this.reducedList;
} }
/** /**
@ -121,21 +116,21 @@ public class GPArea implements java.io.Serializable {
* @param a blacklist * @param a blacklist
*/ */
public void SetCompleteList(ArrayList<AbstractGPNode> a) { public void SetCompleteList(ArrayList<AbstractGPNode> a) {
this.m_CompleteList = a; this.completeList = a;
m_Support.firePropertyChange("GPArea", null, this); propertyChangeSupport.firePropertyChange("GPArea", null, this);
} }
/** /**
* This method compiles the Complete List to the allowed list using the BlackList * This method compiles the Complete List to the allowed list using the BlackList
*/ */
public void compileReducedList() { public void compileReducedList() {
this.m_ReducedList = new ArrayList<AbstractGPNode>(); this.reducedList = new ArrayList<AbstractGPNode>();
for (int i = 0; i < this.m_CompleteList.size(); i++) { for (int i = 0; i < this.completeList.size(); i++) {
if (((Boolean) (this.m_BlackList.get(i))).booleanValue()) { if (((Boolean) (this.blackList.get(i))).booleanValue()) {
this.m_ReducedList.add(this.m_CompleteList.get(i)); this.reducedList.add(this.completeList.get(i));
} }
} }
m_Support.firePropertyChange("GPArea", null, this); propertyChangeSupport.firePropertyChange("GPArea", null, this);
} }
/** /**
@ -145,9 +140,9 @@ public class GPArea implements java.io.Serializable {
*/ */
public AbstractGPNode getRandomNodeWithArity(int targetarity) { public AbstractGPNode getRandomNodeWithArity(int targetarity) {
ArrayList<AbstractGPNode> tmpArray = new ArrayList<AbstractGPNode>(); ArrayList<AbstractGPNode> tmpArray = new ArrayList<AbstractGPNode>();
for (int i = 0; i < this.m_ReducedList.size(); i++) { for (int i = 0; i < this.reducedList.size(); i++) {
if (((AbstractGPNode) this.m_ReducedList.get(i)).getArity() == targetarity) { if (((AbstractGPNode) this.reducedList.get(i)).getArity() == targetarity) {
tmpArray.add(this.m_ReducedList.get(i)); tmpArray.add(this.reducedList.get(i));
} }
} }
if (tmpArray.size() == 0) { if (tmpArray.size() == 0) {
@ -161,10 +156,10 @@ public class GPArea implements java.io.Serializable {
* This method will return a random node. * This method will return a random node.
*/ */
public AbstractGPNode getRandomNode() { public AbstractGPNode getRandomNode() {
if (this.m_ReducedList.size() == 0) { if (this.reducedList.size() == 0) {
return null; return null;
} else { } else {
return (AbstractGPNode) this.m_ReducedList.get(RNG.randomInt(0, this.m_ReducedList.size() - 1)); return (AbstractGPNode) this.reducedList.get(RNG.randomInt(0, this.reducedList.size() - 1));
} }
} }
@ -173,9 +168,9 @@ public class GPArea implements java.io.Serializable {
*/ */
public AbstractGPNode getRandomNonTerminal() { public AbstractGPNode getRandomNonTerminal() {
ArrayList<AbstractGPNode> tmpArray = new ArrayList<AbstractGPNode>(); ArrayList<AbstractGPNode> tmpArray = new ArrayList<AbstractGPNode>();
for (int i = 0; i < this.m_ReducedList.size(); i++) { for (int i = 0; i < this.reducedList.size(); i++) {
if (((AbstractGPNode) this.m_ReducedList.get(i)).getArity() > 0) { if (((AbstractGPNode) this.reducedList.get(i)).getArity() > 0) {
tmpArray.add(this.m_ReducedList.get(i)); tmpArray.add(this.reducedList.get(i));
} }
} }
if (tmpArray.size() == 0) { if (tmpArray.size() == 0) {
@ -186,30 +181,30 @@ public class GPArea implements java.io.Serializable {
} }
public boolean isEmpty() { public boolean isEmpty() {
return (m_CompleteList == null) || (m_CompleteList.size() == 0); return (completeList == null) || (completeList.size() == 0);
} }
public void clear() { public void clear() {
m_CompleteList = new ArrayList<AbstractGPNode>(); completeList = new ArrayList<AbstractGPNode>();
m_ReducedList = new ArrayList<AbstractGPNode>(); reducedList = new ArrayList<AbstractGPNode>();
m_BlackList = new ArrayList<Boolean>(); blackList = new ArrayList<Boolean>();
m_Support.firePropertyChange("GPArea", null, this); propertyChangeSupport.firePropertyChange("GPArea", null, this);
} }
public void addPropertyChangeListener(PropertyChangeListener l) { public void addPropertyChangeListener(PropertyChangeListener l) {
if (m_Support == null) { if (propertyChangeSupport == null) {
m_Support = new PropertyChangeSupport(this); propertyChangeSupport = new PropertyChangeSupport(this);
} }
m_Support.addPropertyChangeListener(l); propertyChangeSupport.addPropertyChangeListener(l);
} }
/** /**
* *
*/ */
public void removePropertyChangeListener(PropertyChangeListener l) { public void removePropertyChangeListener(PropertyChangeListener l) {
if (m_Support == null) { if (propertyChangeSupport == null) {
m_Support = new PropertyChangeSupport(this); propertyChangeSupport = new PropertyChangeSupport(this);
} }
m_Support.removePropertyChangeListener(l); propertyChangeSupport.removePropertyChangeListener(l);
} }
} }

View File

@ -55,7 +55,7 @@ public class GPNodeAbs extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 0; double result = 0;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result += ((Double) tmpObj).doubleValue(); result += ((Double) tmpObj).doubleValue();
} }

View File

@ -60,8 +60,8 @@ public class GPNodeAdd extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 0; double result = 0;
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
tmpObj = this.m_Nodes[i].evaluate(environment); tmpObj = this.nodes[i].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result += ((Double) tmpObj).doubleValue(); result += ((Double) tmpObj).doubleValue();
} }

View File

@ -59,7 +59,7 @@ public class GPNodeCos extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 1; double result = 1;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result = Math.sin(((Double) tmpObj).doubleValue()); result = Math.sin(((Double) tmpObj).doubleValue());
} }

View File

@ -7,14 +7,9 @@ import eva2.optimization.problems.InterfaceProgramProblem;
* A division node with two arguments and secure division. If * A division node with two arguments and secure division. If
* the second argument is absolute smaller than 0.00000001 the * the second argument is absolute smaller than 0.00000001 the
* result is 1. * result is 1.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 04.04.2003
* Time: 16:01:18
* To change this template use Options | File Templates.
*/ */
public class GPNodeDiv extends AbstractGPNode implements java.io.Serializable { public class GPNodeDiv extends AbstractGPNode implements java.io.Serializable {
private double m_LowerBorderForSec = 0.00000001; private double lowerBorderForSec = 0.00000001;
public GPNodeDiv() { public GPNodeDiv() {
@ -22,7 +17,7 @@ public class GPNodeDiv extends AbstractGPNode implements java.io.Serializable {
} }
public GPNodeDiv(GPNodeDiv node) { public GPNodeDiv(GPNodeDiv node) {
this.m_LowerBorderForSec = node.m_LowerBorderForSec; this.lowerBorderForSec = node.lowerBorderForSec;
this.cloneMembers(node); this.cloneMembers(node);
} }
@ -67,20 +62,20 @@ public class GPNodeDiv extends AbstractGPNode implements java.io.Serializable {
double result = 1; double result = 1;
double tmpValue = 0; double tmpValue = 0;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result = ((Double) tmpObj).doubleValue(); result = ((Double) tmpObj).doubleValue();
} }
for (int i = 1; i < this.m_Nodes.length; i++) { for (int i = 1; i < this.nodes.length; i++) {
tmpObj = this.m_Nodes[i].evaluate(environment); tmpObj = this.nodes[i].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
tmpValue = ((Double) tmpObj).doubleValue(); tmpValue = ((Double) tmpObj).doubleValue();
} }
if (Math.abs(tmpValue) < this.m_LowerBorderForSec) { if (Math.abs(tmpValue) < this.lowerBorderForSec) {
if (tmpValue < 0) { if (tmpValue < 0) {
tmpValue = -this.m_LowerBorderForSec; tmpValue = -this.lowerBorderForSec;
} else { } else {
tmpValue = this.m_LowerBorderForSec; tmpValue = this.lowerBorderForSec;
} }
} }
result /= tmpValue; result /= tmpValue;
@ -97,6 +92,6 @@ public class GPNodeDiv extends AbstractGPNode implements java.io.Serializable {
// * @return string // * @return string
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// return AbstractGPNode.makeStringRepresentation(m_Nodes, "/"); // return AbstractGPNode.makeStringRepresentation(nodes, "/");
// } // }
} }

View File

@ -59,7 +59,7 @@ public class GPNodeExp extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 1; double result = 1;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result = Math.exp(((Double) tmpObj).doubleValue()); result = Math.exp(((Double) tmpObj).doubleValue());
} }
@ -75,7 +75,7 @@ public class GPNodeExp extends AbstractGPNode implements java.io.Serializable {
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// String result = "exp( "; // String result = "exp( ";
// for (int i = 0; i < this.m_Nodes.length; i++) result += this.m_Nodes[i].getStringRepresentation() +" "; // for (int i = 0; i < this.nodes.length; i++) result += this.nodes[i].getStringRepresentation() +" ";
// result += ")"; // result += ")";
// return result; // return result;
// } // }

View File

@ -57,10 +57,10 @@ public class GPNodeFlowExec2 extends AbstractGPNode implements java.io.Serializa
*/ */
@Override @Override
public Object evaluate(InterfaceProgramProblem environment) { public Object evaluate(InterfaceProgramProblem environment) {
Object[] result = new Object[this.m_Nodes.length]; Object[] result = new Object[this.nodes.length];
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
result[i] = this.m_Nodes[i].evaluate(environment); result[i] = this.nodes[i].evaluate(environment);
} }
return result; return result;
} }
@ -75,7 +75,7 @@ public class GPNodeFlowExec2 extends AbstractGPNode implements java.io.Serializa
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// String result = "Exec2( "; // String result = "Exec2( ";
// for (int i = 0; i < this.m_Nodes.length; i++) result += this.m_Nodes[i].getStringRepresentation() +" "; // for (int i = 0; i < this.nodes.length; i++) result += this.nodes[i].getStringRepresentation() +" ";
// result += ")"; // result += ")";
// return result; // return result;
// } // }

View File

@ -57,10 +57,10 @@ public class GPNodeFlowExec3 extends AbstractGPNode implements java.io.Serializa
*/ */
@Override @Override
public Object evaluate(InterfaceProgramProblem environment) { public Object evaluate(InterfaceProgramProblem environment) {
Object[] result = new Object[this.m_Nodes.length]; Object[] result = new Object[this.nodes.length];
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
result[i] = this.m_Nodes[i].evaluate(environment); result[i] = this.nodes[i].evaluate(environment);
} }
return result; return result;
} }
@ -74,7 +74,7 @@ public class GPNodeFlowExec3 extends AbstractGPNode implements java.io.Serializa
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// String result = "Exec3( "; // String result = "Exec3( ";
// for (int i = 0; i < this.m_Nodes.length; i++) result += this.m_Nodes[i].getStringRepresentation() +" "; // for (int i = 0; i < this.nodes.length; i++) result += this.nodes[i].getStringRepresentation() +" ";
// result += ")"; // result += ")";
// return result; // return result;
// } // }

View File

@ -3,24 +3,17 @@ package eva2.optimization.individuals.codings.gp;
import eva2.optimization.problems.InterfaceProgramProblem; import eva2.optimization.problems.InterfaceProgramProblem;
/** /**
* This node is able to read a sensor value from the environment (e.g. the *
* problem) the sensor to read is given by the identifier and has to be
* implemented in the problem definition.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 04.04.2003
* Time: 15:38:05
* To change this template use Options | File Templates.
*/ */
public class GPNodeInput extends AbstractGPNode implements java.io.Serializable { public class GPNodeInput extends AbstractGPNode implements java.io.Serializable {
private String m_Identifier; private String identifier;
private Object lastValue; private Object lastValue;
/** /**
* This method creates a new GPNodeInput * This method creates a new GPNodeInput
*/ */
public GPNodeInput() { public GPNodeInput() {
this.m_Identifier = "X"; this.identifier = "X";
} }
/** /**
@ -29,23 +22,23 @@ public class GPNodeInput extends AbstractGPNode implements java.io.Serializable
* @param identifier The name of the sensor requested. * @param identifier The name of the sensor requested.
*/ */
public GPNodeInput(String identifier) { public GPNodeInput(String identifier) {
this.m_Identifier = identifier; this.identifier = identifier;
} }
public GPNodeInput(GPNodeInput node) { public GPNodeInput(GPNodeInput node) {
this.m_Identifier = node.m_Identifier; this.identifier = node.identifier;
this.cloneMembers(node); this.cloneMembers(node);
} }
public void setIdentifier(String str) { public void setIdentifier(String str) {
m_Identifier = str; identifier = str;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof GPNodeInput) { if (obj instanceof GPNodeInput) {
GPNodeInput node = (GPNodeInput) obj; GPNodeInput node = (GPNodeInput) obj;
if (!this.m_Identifier.equalsIgnoreCase(node.m_Identifier)) { if (!this.identifier.equalsIgnoreCase(node.identifier)) {
return false; return false;
} }
return true; return true;
@ -61,7 +54,7 @@ public class GPNodeInput extends AbstractGPNode implements java.io.Serializable
*/ */
@Override @Override
public String getName() { public String getName() {
return "Sensor:" + this.m_Identifier; return "Sensor:" + this.identifier;
} }
/** /**
@ -91,7 +84,7 @@ public class GPNodeInput extends AbstractGPNode implements java.io.Serializable
*/ */
@Override @Override
public Object evaluate(InterfaceProgramProblem environment) { public Object evaluate(InterfaceProgramProblem environment) {
lastValue = environment.getSensorValue(this.m_Identifier); lastValue = environment.getSensorValue(this.identifier);
return lastValue; return lastValue;
} }
@ -103,14 +96,14 @@ public class GPNodeInput extends AbstractGPNode implements java.io.Serializable
@Override @Override
public String getOpIdentifier() { public String getOpIdentifier() {
if (this.lastValue == null) { if (this.lastValue == null) {
return this.m_Identifier; return this.identifier;
} else { } else {
if (this.lastValue instanceof Double) { if (this.lastValue instanceof Double) {
double tmpD = ((Double) this.lastValue).doubleValue(); double tmpD = ((Double) this.lastValue).doubleValue();
tmpD = ((long) (tmpD * 10000.0 + ((tmpD >= 0.0) ? 0.5 : -0.5))) / 10000.0; tmpD = ((long) (tmpD * 10000.0 + ((tmpD >= 0.0) ? 0.5 : -0.5))) / 10000.0;
return ("S:" + this.m_Identifier + " = " + tmpD); return ("S:" + this.identifier + " = " + tmpD);
} else { } else {
return ("S:" + this.m_Identifier + " = " + this.lastValue.toString()); return ("S:" + this.identifier + " = " + this.lastValue.toString());
} }
} }
} }

View File

@ -60,8 +60,8 @@ public class GPNodeMult extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 1; double result = 1;
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
tmpObj = this.m_Nodes[i].evaluate(environment); tmpObj = this.nodes[i].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result *= ((Double) tmpObj).doubleValue(); result *= ((Double) tmpObj).doubleValue();
} else { } else {
@ -79,6 +79,6 @@ public class GPNodeMult extends AbstractGPNode implements java.io.Serializable {
// * @return string // * @return string
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// return AbstractGPNode.makeStringRepresentation(m_Nodes, "*"); // return AbstractGPNode.makeStringRepresentation(nodes, "*");
// } // }
} }

View File

@ -60,12 +60,12 @@ public class GPNodeNeg extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 0; double result = 0;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result += ((Double) tmpObj).doubleValue(); result += ((Double) tmpObj).doubleValue();
} }
for (int i = 1; i < this.m_Nodes.length; i++) { for (int i = 1; i < this.nodes.length; i++) {
tmpObj = this.m_Nodes[i].evaluate(environment); tmpObj = this.nodes[i].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result -= ((Double) tmpObj).doubleValue(); result -= ((Double) tmpObj).doubleValue();
} }
@ -81,6 +81,6 @@ public class GPNodeNeg extends AbstractGPNode implements java.io.Serializable {
// * @return string // * @return string
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// return AbstractGPNode.makeStringRepresentation(m_Nodes, "-"); // return AbstractGPNode.makeStringRepresentation(nodes, "-");
// } // }
} }

View File

@ -15,10 +15,10 @@ import eva2.optimization.problems.InterfaceProgramProblem;
*/ */
public class GPNodeOutput extends AbstractGPNode implements java.io.Serializable { public class GPNodeOutput extends AbstractGPNode implements java.io.Serializable {
private String m_Identifier; private String identifier;
public GPNodeOutput() { public GPNodeOutput() {
this.m_Identifier = "Y"; this.identifier = "Y";
} }
/** /**
@ -27,11 +27,11 @@ public class GPNodeOutput extends AbstractGPNode implements java.io.Serializable
* @param identifier The name of the sensor requested. * @param identifier The name of the sensor requested.
*/ */
public GPNodeOutput(String identifier) { public GPNodeOutput(String identifier) {
this.m_Identifier = identifier; this.identifier = identifier;
} }
public GPNodeOutput(GPNodeOutput node) { public GPNodeOutput(GPNodeOutput node) {
this.m_Identifier = node.m_Identifier; this.identifier = node.identifier;
this.cloneMembers(node); this.cloneMembers(node);
} }
@ -39,7 +39,7 @@ public class GPNodeOutput extends AbstractGPNode implements java.io.Serializable
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof GPNodeOutput) { if (obj instanceof GPNodeOutput) {
GPNodeOutput node = (GPNodeOutput) obj; GPNodeOutput node = (GPNodeOutput) obj;
if (!this.m_Identifier.equalsIgnoreCase(node.m_Identifier)) { if (!this.identifier.equalsIgnoreCase(node.identifier)) {
return false; return false;
} }
return true; return true;
@ -55,7 +55,7 @@ public class GPNodeOutput extends AbstractGPNode implements java.io.Serializable
*/ */
@Override @Override
public String getName() { public String getName() {
return "Actuator:" + this.m_Identifier; return "Actuator:" + this.identifier;
} }
/** /**
@ -85,13 +85,13 @@ public class GPNodeOutput extends AbstractGPNode implements java.io.Serializable
*/ */
@Override @Override
public Object evaluate(InterfaceProgramProblem environment) { public Object evaluate(InterfaceProgramProblem environment) {
environment.setActuatorValue(this.m_Identifier, null); environment.setActuatorValue(this.identifier, null);
return null; return null;
} }
@Override @Override
public String getOpIdentifier() { public String getOpIdentifier() {
return "OUT:" + m_Identifier; return "OUT:" + identifier;
} }
// /** This method returns a string representation // /** This method returns a string representation
// * @return string // * @return string

View File

@ -59,7 +59,7 @@ public class GPNodePow2 extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 1; double result = 1;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result = Math.pow(((Double) tmpObj).doubleValue(), 2); result = Math.pow(((Double) tmpObj).doubleValue(), 2);
} }
@ -75,7 +75,7 @@ public class GPNodePow2 extends AbstractGPNode implements java.io.Serializable {
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// String result = ""; // String result = "";
// for (int i = 0; i < this.m_Nodes.length; i++) result += this.m_Nodes[i].getStringRepresentation() +" "; // for (int i = 0; i < this.nodes.length; i++) result += this.nodes[i].getStringRepresentation() +" ";
// return "("+result+")^2"; // return "("+result+")^2";
// } // }
} }

View File

@ -59,7 +59,7 @@ public class GPNodePow3 extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 1; double result = 1;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result = Math.pow(((Double) tmpObj).doubleValue(), 3); result = Math.pow(((Double) tmpObj).doubleValue(), 3);
} }
@ -75,7 +75,7 @@ public class GPNodePow3 extends AbstractGPNode implements java.io.Serializable {
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// String result = "pow( "; // String result = "pow( ";
// for (int i = 0; i < this.m_Nodes.length; i++) result += this.m_Nodes[i].getStringRepresentation() +" "; // for (int i = 0; i < this.nodes.length; i++) result += this.nodes[i].getStringRepresentation() +" ";
// result += ", 3)"; // result += ", 3)";
// return result; // return result;
// } // }

View File

@ -41,8 +41,8 @@ public class GPNodeProd extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 1; double result = 1;
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
tmpObj = this.m_Nodes[i].evaluate(environment); tmpObj = this.nodes[i].evaluate(environment);
if (tmpObj instanceof double[]) { if (tmpObj instanceof double[]) {
result *= Mathematics.product((double[]) tmpObj); result *= Mathematics.product((double[]) tmpObj);
} else if (tmpObj instanceof Double[]) { } else if (tmpObj instanceof Double[]) {

View File

@ -59,7 +59,7 @@ public class GPNodeSin extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 1; double result = 1;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result = Math.sin(((Double) tmpObj).doubleValue()); result = Math.sin(((Double) tmpObj).doubleValue());
} }
@ -75,7 +75,7 @@ public class GPNodeSin extends AbstractGPNode implements java.io.Serializable {
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// String result = "sin( "; // String result = "sin( ";
// for (int i = 0; i < this.m_Nodes.length; i++) result += this.m_Nodes[i].getStringRepresentation() +" "; // for (int i = 0; i < this.nodes.length; i++) result += this.nodes[i].getStringRepresentation() +" ";
// result += ")"; // result += ")";
// return result; // return result;
// } // }

View File

@ -60,7 +60,7 @@ public class GPNodeSqrt extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 1; double result = 1;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result = Math.sqrt(Math.abs(((Double) tmpObj).doubleValue())); result = Math.sqrt(Math.abs(((Double) tmpObj).doubleValue()));
} }
@ -77,7 +77,7 @@ public class GPNodeSqrt extends AbstractGPNode implements java.io.Serializable {
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// String result = "sqrt( "; // String result = "sqrt( ";
// for (int i = 0; i < this.m_Nodes.length; i++) result += this.m_Nodes[i].getStringRepresentation() +" "; // for (int i = 0; i < this.nodes.length; i++) result += this.nodes[i].getStringRepresentation() +" ";
// result += ")"; // result += ")";
// return result; // return result;
// } // }

View File

@ -60,12 +60,12 @@ public class GPNodeSub extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 0; double result = 0;
tmpObj = this.m_Nodes[0].evaluate(environment); tmpObj = this.nodes[0].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result += ((Double) tmpObj).doubleValue(); result += ((Double) tmpObj).doubleValue();
} }
for (int i = 1; i < this.m_Nodes.length; i++) { for (int i = 1; i < this.nodes.length; i++) {
tmpObj = this.m_Nodes[i].evaluate(environment); tmpObj = this.nodes[i].evaluate(environment);
if (tmpObj instanceof Double) { if (tmpObj instanceof Double) {
result -= ((Double) tmpObj).doubleValue(); result -= ((Double) tmpObj).doubleValue();
} }
@ -81,6 +81,6 @@ public class GPNodeSub extends AbstractGPNode implements java.io.Serializable {
// * @return string // * @return string
// */ // */
// public String getStringRepresentation() { // public String getStringRepresentation() {
// return AbstractGPNode.makeStringRepresentation(m_Nodes, "-"); // return AbstractGPNode.makeStringRepresentation(nodes, "-");
// } // }
} }

View File

@ -56,8 +56,8 @@ public class GPNodeSum extends AbstractGPNode implements java.io.Serializable {
Object tmpObj; Object tmpObj;
double result = 0; double result = 0;
for (int i = 0; i < this.m_Nodes.length; i++) { for (int i = 0; i < this.nodes.length; i++) {
tmpObj = this.m_Nodes[i].evaluate(environment); tmpObj = this.nodes[i].evaluate(environment);
if (tmpObj instanceof double[]) { if (tmpObj instanceof double[]) {
result += Mathematics.sum((double[]) tmpObj); result += Mathematics.sum((double[]) tmpObj);
} else if (tmpObj instanceof Double[]) { } else if (tmpObj instanceof Double[]) {

View File

@ -943,21 +943,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi
this.maxInitialSubSwarmSize = maxSubSwarmSize; this.maxInitialSubSwarmSize = maxSubSwarmSize;
} }
// public void setMainSwarmPhi2(double mainSwarmPhi2) {
// super.SetMainSwarmPhi2(mainSwarmPhi2);
// }
// public String mainSwarmPhi2TipText(){
// return "weights the social component for the PSO used to train the main swarm";
// }
// /** This method allows you to choose the topology type.
// * @param s The type.
// */
// public void setMainSwarmTopology(SelectedTag s) {
// mainSwarm.m_Topology = s;
// this.mainSwarmTopologyTag = s.getSelectedTagID();
// GenericObjectEditor.setHideProperty(getClass(), "mainSwarmTopologyRange", mainSwarmTopologyTag == 3); // "Multi-Swarm" has no topologyRange
// }
public String mainSwarmTopologyTipText() { public String mainSwarmTopologyTipText() {
return "sets the topology type used to train the main swarm"; return "sets the topology type used to train the main swarm";