More refactoring on public methods

This commit is contained in:
Fabian Becker 2013-09-27 13:13:43 +02:00
parent bbaead0515
commit 288bdbdd36
80 changed files with 432 additions and 451 deletions

View File

@ -1,14 +1,19 @@
package eva2.cli; package eva2.cli;
import eva2.optimization.strategies.DifferentialEvolution; import eva2.optimization.strategies.DifferentialEvolution;
import eva2.optimization.strategies.InterfaceOptimizer;
import eva2.util.annotation.Parameter; import eva2.util.annotation.Parameter;
import org.apache.commons.cli.*; import org.apache.commons.cli.*;
import eva2.optimization.OptimizationStateListener; import eva2.optimization.OptimizationStateListener;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
public class Main implements OptimizationStateListener { public class Main implements OptimizationStateListener {
private Options createCommandLineOptions() { private Options createCommandLineOptions() {
Options opt = new Options(); Options opt = new Options();
OptionGroup optGroup = new OptionGroup(); OptionGroup optGroup = new OptionGroup();
@ -54,6 +59,13 @@ public class Main implements OptimizationStateListener {
public static void main(String[] args) { public static void main(String[] args) {
Map<String, Class<? extends InterfaceOptimizer>> optimizerList = new HashMap<String, Class<? extends InterfaceOptimizer>>();
optimizerList.add("Differential Evolution", eva2.optimization.strategies.DifferentialEvolution.class);
optimizerList.add("Particle Swarm Optimization", eva2.optimization.strategies.ParticleSwarmOptimization.class);
optimizerList.add("Genetic Algorithm", eva2.optimization.strategies.GeneticAlgorithm.class);
optimizerList.add("Evolution Strategies", eva2.optimization.strategies.EvolutionStrategies.class);
eva2.optimization.strategies.DifferentialEvolution de = new DifferentialEvolution(); eva2.optimization.strategies.DifferentialEvolution de = new DifferentialEvolution();
for(Field field : de.getClass().getDeclaredFields()) { for(Field field : de.getClass().getDeclaredFields()) {

View File

@ -72,7 +72,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
return individualIndex; return individualIndex;
} }
public void SetIndividualIndex(int index) { public void setIndividualIndex(int index) {
this.individualIndex = index; this.individualIndex = index;
} }
@ -491,7 +491,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
* *
* @param age The new age. * @param age The new age.
*/ */
public void SetAge(int age) { public void setAge(int age) {
this.age = age; this.age = age;
} }
@ -543,11 +543,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
* @return True if constraints are violated * @return True if constraints are violated
*/ */
public boolean violatesConstraint() { public boolean violatesConstraint() {
if (this.constraintViolation > 0) { return this.constraintViolation > 0;
return true;
} else {
return false;
}
} }
/** /**
@ -560,7 +556,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
return this.isMarked; return this.isMarked;
} }
public void SetMarked(boolean t) { public void setMarked(boolean t) {
this.isMarked = t; this.isMarked = t;
} }
@ -590,7 +586,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
* *
* @return * @return
*/ */
public void SetMarkPenalized(boolean p) { public void setMarkPenalized(boolean p) {
isPenalized = p; isPenalized = p;
} }
@ -695,11 +691,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
return true; return true;
} }
return isDominatingFitness(getFitness(), indy.getFitness()); return isDominatingFitness(getFitness(), indy.getFitness());
// for (int i = 0; (i < this.fitness.length) && (i < tmpFitness.length); i++) {
// if (this.fitness[i] <= tmpFitness[i]) result &= true;
// else result &= false;
// }
// return result;
} }
/** /**
@ -724,19 +715,11 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
} }
private static boolean firstIsFiniteAndLargerOrEqual(double a, double b) { private static boolean firstIsFiniteAndLargerOrEqual(double a, double b) {
if (Double.isNaN(a) || Double.isInfinite(a)) { return !(Double.isNaN(a) || Double.isInfinite(a)) && (a >= b);
return false;
} else {
return (a >= b);
}
} }
private static boolean firstIsFiniteAndLargerNonEqual(double a, double b) { private static boolean firstIsFiniteAndLargerNonEqual(double a, double b) {
if (Double.isNaN(a) || Double.isInfinite(a)) { return !(Double.isNaN(a) || Double.isInfinite(a)) && (a > b);
return false;
} else {
return (a > b);
}
} }
/** /**
@ -805,11 +788,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
} else { } else {
return (constrViolComp > 0); return (constrViolComp > 0);
} }
// for (int i = 0; (i < this.fitness.length) && (i < tmpFitness.length); i++) {
// if (this.fitness[i] <= tmpFitness[i]) result &= true;
// else result &= false;
// }
// return result;
} }
/** /**
@ -882,7 +860,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
* *
* @param sel The new selection probability array * @param sel The new selection probability array
*/ */
public void SetSelectionProbability(double[] sel) { public void setSelectionProbability(double[] sel) {
this.selectionProbability = sel; this.selectionProbability = sel;
} }
@ -892,7 +870,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
* @param index The index of the selection probability value to set. * @param index The index of the selection probability value to set.
* @param sel The new selection probability value. * @param sel The new selection probability value.
*/ */
public void SetSelectionProbability(int index, double sel) { public void setSelectionProbability(int index, double sel) {
if (this.selectionProbability.length > index) { if (this.selectionProbability.length > index) {
this.selectionProbability[index] = sel; this.selectionProbability[index] = sel;
} else { } else {
@ -1020,22 +998,13 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
* @return Object The associated object or null if none is found * @return Object The associated object or null if none is found
*/ */
public Object getData(String name) { public Object getData(String name) {
// if (name.equalsIgnoreCase("SelectionProbability")) return this.getSelectionProbability();
// if (name.equalsIgnoreCase("SelectionProbabilityArray")) return this.getSelectionProbability();
// if (name.equalsIgnoreCase("Fitness")) return this.getFitness();
// if (name.equalsIgnoreCase("FitnessArray")) return this.getFitness();
Object data = dataHash.get(name); Object data = dataHash.get(name);
if (data == null) { // Fitness is actually in use... so lets have a minor special treatment if (data == null) { // Fitness is actually in use... so lets have a minor special treatment
// try {
if (name.compareToIgnoreCase("Fitness") == 0) { if (name.compareToIgnoreCase("Fitness") == 0) {
data = getFitness(); data = getFitness();
} else { } else {
EVAERROR.errorMsgOnce("Warning: data key " + name + " unknown (pot. multiple errors)!"); EVAERROR.errorMsgOnce("Warning: data key " + name + " unknown (pot. multiple errors)!");
// throw new RuntimeException(name + ": unknown key!");
} }
// } catch(Exception e) {
// e.printStackTrace(System.err);
// }
} }
return data; return data;
} }
@ -1273,7 +1242,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
for (int i = 0; i < intData.length; i++) { for (int i = 0; i < intData.length; i++) {
intData[i] = (int) pos[i]; intData[i] = (int) pos[i];
} }
((InterfaceDataTypeInteger) indy).SetIntGenotype(intData); ((InterfaceDataTypeInteger) indy).setIntGenotype(intData);
return true; return true;
} // TODO check some more types here? } // TODO check some more types here?
EVAERROR.errorMsgOnce("Unhandled case in AbstractEAIndividual.setDoublePosition()!"); EVAERROR.errorMsgOnce("Unhandled case in AbstractEAIndividual.setDoublePosition()!");

View File

@ -179,7 +179,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
public void SetBinaryPhenotype(BitSet binaryData) { public void setBinaryPhenotype(BitSet binaryData) {
this.m_Phenotype = binaryData; this.m_Phenotype = binaryData;
} }
@ -190,8 +190,8 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@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.m_Genotype.length; i++) {
if (this.m_UseHardSwitch) { if (this.m_UseHardSwitch) {
if (binaryData.get(i)) { if (binaryData.get(i)) {
@ -223,7 +223,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof BitSet) { if (obj instanceof BitSet) {
BitSet bs = (BitSet) obj; BitSet bs = (BitSet) obj;
this.SetBinaryGenotype(bs); this.setBinaryGenotype(bs);
} else { } else {
this.defaultInit(opt); this.defaultInit(opt);
System.out.println("Initial value for ESIndividualBinaryData is no BitSet!"); System.out.println("Initial value for ESIndividualBinaryData is no BitSet!");

View File

@ -17,32 +17,32 @@ import eva2.tools.math.RNG;
*/ */
public class ESIndividualIntegerData extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypeInteger, java.io.Serializable { public class ESIndividualIntegerData extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypeInteger, java.io.Serializable {
private double[] m_Genotype; private double[] genotype;
private int[] m_Phenotype; private int[] phenotype;
private int[][] m_Range; private int[][] range;
public ESIndividualIntegerData() { public ESIndividualIntegerData() {
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 int[1][2]; this.range = new int[1][2];
this.m_Range[0][0] = -10; this.range[0][0] = -10;
this.m_Range[0][1] = 10; this.range[0][1] = 10;
} }
public ESIndividualIntegerData(ESIndividualIntegerData individual) { public ESIndividualIntegerData(ESIndividualIntegerData 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);
} }
this.m_Genotype = new double[individual.m_Genotype.length]; this.genotype = new double[individual.genotype.length];
this.m_Range = new int[individual.m_Genotype.length][2]; this.range = new int[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.range[i][0] = individual.range[i][0];
this.m_Range[i][1] = individual.m_Range[i][1]; this.range[i][1] = individual.range[i][1];
} }
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
@ -77,20 +77,20 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof ESIndividualIntegerData) { if (individual instanceof ESIndividualIntegerData) {
ESIndividualIntegerData indy = (ESIndividualIntegerData) individual; ESIndividualIntegerData indy = (ESIndividualIntegerData) 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.range == null) || (indy.range == null)) {
return false; return false;
} }
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.range.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.range[i][0] != indy.range[i][0]) {
return false; return false;
} }
if (this.m_Range[i][1] != indy.m_Range[i][1]) { if (this.range[i][1] != indy.range[i][1]) {
return false; return false;
} }
} }
@ -114,20 +114,20 @@ public class ESIndividualIntegerData 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.range[i][0];
newRange[i][1] = this.m_Range[i][1]; newRange[i][1] = this.range[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.range[this.genotype.length - 1][0];
newRange[i][1] = this.m_Range[this.m_Genotype.length - 1][1]; newRange[i][1] = this.range[this.genotype.length - 1][1];
} }
this.m_Genotype = newDesPa; this.genotype = newDesPa;
this.m_Range = newRange; this.range = newRange;
} }
/** /**
@ -137,7 +137,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int size() { public int size() {
return this.m_Genotype.length; return this.genotype.length;
} }
/** /**
@ -148,14 +148,14 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
* @param range The new range for the int data. * @param range The new range for the int data.
*/ */
@Override @Override
public void SetIntRange(int[][] range) { public void setIntRange(int[][] range) {
if (range.length != this.m_Range.length) { if (range.length != this.range.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 setIntegerDataLength first (ESIndividualIntegerData::SetIntRange)!"); + this.range.length + "!\n Use method setIntegerDataLength first (ESIndividualIntegerData::setIntRange)!");
} }
for (int i = 0; ((i < this.m_Range.length) && (i < range.length)); i++) { for (int i = 0; ((i < this.range.length) && (i < range.length)); i++) {
this.m_Range[i][0] = range[i][0]; this.range[i][0] = range[i][0];
this.m_Range[i][1] = range[i][1]; this.range[i][1] = range[i][1];
} }
} }
@ -166,7 +166,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int[][] getIntRange() { public int[][] getIntRange() {
return this.m_Range; return this.range;
} }
/** /**
@ -176,17 +176,17 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int[] getIntegerData() { public int[] getIntegerData() {
this.m_Phenotype = new int[this.m_Genotype.length]; this.phenotype = new int[this.genotype.length];
for (int i = 0; i < this.m_Phenotype.length; i++) { for (int i = 0; i < this.phenotype.length; i++) {
this.m_Phenotype[i] = (int) this.m_Genotype[i]; this.phenotype[i] = (int) this.genotype[i];
if (this.m_Phenotype[i] < this.m_Range[i][0]) { if (this.phenotype[i] < this.range[i][0]) {
this.m_Phenotype[i] = this.m_Range[i][0]; this.phenotype[i] = this.range[i][0];
} }
if (this.m_Phenotype[i] > this.m_Range[i][1]) { if (this.phenotype[i] > this.range[i][1]) {
this.m_Phenotype[i] = this.m_Range[i][1]; this.phenotype[i] = this.range[i][1];
} }
} }
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -197,7 +197,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int[] getIntegerDataWithoutUpdate() { public int[] getIntegerDataWithoutUpdate() {
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -206,8 +206,8 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
* @param intData The new int data. * @param intData The new int data.
*/ */
@Override @Override
public void SetIntPhenotype(int[] intData) { public void setIntPhenotype(int[] intData) {
this.m_Phenotype = intData; this.phenotype = intData;
} }
/** /**
@ -217,9 +217,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
* @param intData The new int data. * @param intData The new int data.
*/ */
@Override @Override
public void SetIntGenotype(int[] intData) { public void setIntGenotype(int[] intData) {
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
m_Genotype[i] = (double) intData[i]; genotype[i] = (double) intData[i];
} }
getIntegerData(); getIntegerData();
} }
@ -239,10 +239,10 @@ public class ESIndividualIntegerData 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_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.SetIntGenotype(bs); this.setIntGenotype(bs);
} else { } else {
this.defaultInit(opt); this.defaultInit(opt);
System.out.println("Initial value for ESIndividualIntegerData is not int[]!"); System.out.println("Initial value for ESIndividualIntegerData is not int[]!");
@ -271,8 +271,8 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
} }
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;
@ -288,7 +288,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public double[] getDGenotype() { public double[] getDGenotype() {
return this.m_Genotype; return this.genotype;
} }
/** /**
@ -298,13 +298,13 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@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.range[i][0]) {
this.m_Genotype[i] = this.m_Range[i][0]; this.genotype[i] = this.range[i][0];
} }
if (this.m_Genotype[i] > this.m_Range[i][1]) { if (this.genotype[i] > this.range[i][1]) {
this.m_Genotype[i] = this.m_Range[i][1]; this.genotype[i] = this.range[i][1];
} }
} }
} }
@ -314,13 +314,13 @@ public class ESIndividualIntegerData 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] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0]) / 2) * RNG.gaussianDouble(0.05f); this.genotype[mutationIndex] += ((this.range[mutationIndex][1] - this.range[mutationIndex][0]) / 2) * RNG.gaussianDouble(0.05f);
if (this.m_Genotype[mutationIndex] < this.m_Range[mutationIndex][0]) { if (this.genotype[mutationIndex] < this.range[mutationIndex][0]) {
this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][0]; this.genotype[mutationIndex] = this.range[mutationIndex][0];
} }
if (this.m_Genotype[mutationIndex] > this.m_Range[mutationIndex][1]) { if (this.genotype[mutationIndex] > this.range[mutationIndex][1]) {
this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][1]; this.genotype[mutationIndex] = this.range[mutationIndex][1];
} }
} }
@ -331,22 +331,22 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public double[][] getDoubleRange() { public double[][] getDoubleRange() {
double[][] result = new double[this.m_Range.length][2]; double[][] result = new double[this.range.length][2];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.range.length; i++) {
result[i][0] = this.m_Range[i][0]; result[i][0] = this.range[i][0];
result[i][1] = this.m_Range[i][1]; result[i][1] = this.range[i][1];
} }
return result; return result;
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
int[][] range = m_Range; int[][] range = this.range;
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) { if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
range = (int[][]) ((InterfaceHasInitRange) prob).getInitRange(); range = (int[][]) ((InterfaceHasInitRange) prob).getInitRange();
} }
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

@ -49,7 +49,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
this.m_Genotype = new double[individual.m_Genotype.length][]; this.m_Genotype = new double[individual.m_Genotype.length][];
this.m_Range = new double[individual.m_Genotype.length][][]; this.m_Range = new double[individual.m_Genotype.length][][];
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
// if (individual.m_Phenotype != null) { // if (individual.phenotype != null) {
this.m_Genotype[i] = new double[individual.m_Genotype[i].length]; this.m_Genotype[i] = new double[individual.m_Genotype[i].length];
this.m_Range[i] = new double[individual.m_Genotype[i].length][2]; this.m_Range[i] = new double[individual.m_Genotype[i].length][2];
@ -154,7 +154,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
} }
@Override @Override
public void SetPermutationPhenotype(int[][] perm) { public void setPermutationPhenotype(int[][] perm) {
this.m_Phenotype = perm; this.m_Phenotype = perm;
this.m_Range = new double[perm.length][][]; this.m_Range = new double[perm.length][][];
for (int i = 0; i < perm.length; i++) { for (int i = 0; i < perm.length; i++) {
@ -168,8 +168,8 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
} }
@Override @Override
public void SetPermutationGenotype(int[][] perm) { public void setPermutationGenotype(int[][] perm) {
this.SetPermutationPhenotype(perm); this.setPermutationPhenotype(perm);
this.m_Genotype = new double[perm.length][]; this.m_Genotype = new double[perm.length][];
this.m_Range = new double[perm.length][][]; this.m_Range = new double[perm.length][][];
@ -262,7 +262,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
if (bs.length != this.m_Genotype.length) { if (bs.length != this.m_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);
} else { } else {
this.defaultInit(opt); this.defaultInit(opt);
System.out.println("Initial value for ESIndividualPermutationData is not int[]!"); System.out.println("Initial value for ESIndividualPermutationData is not int[]!");

View File

@ -355,8 +355,8 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
* @see InterfaceDataTypeBinary.SetBinaryData() * @see InterfaceDataTypeBinary.SetBinaryData()
*/ */
@Override @Override
public void SetBinaryPhenotype(BitSet binaryData) { public void setBinaryPhenotype(BitSet binaryData) {
this.m_BitSet.SetBinaryPhenotype(binaryData); this.m_BitSet.setBinaryPhenotype(binaryData);
} }
/** /**
@ -364,11 +364,11 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
* memetic algorithms. * memetic algorithms.
* *
* @param binaryData The new binary data. * @param binaryData The new binary data.
* @see InterfaceBinaryData.SetBinaryDataLamarckian() * @see InterfaceBinaryData.setBinaryDataLamarckian()
*/ */
@Override @Override
public void SetBinaryGenotype(BitSet binaryData) { public void setBinaryGenotype(BitSet binaryData) {
this.m_BitSet.SetBinaryGenotype(binaryData); this.m_BitSet.setBinaryGenotype(binaryData);
} }
/********************************************************************************************************************** /**********************************************************************************************************************

View File

@ -124,7 +124,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof BitSet) { if (obj instanceof BitSet) {
BitSet bs = (BitSet) obj; BitSet bs = (BitSet) obj;
this.SetBinaryGenotype(bs); this.setBinaryGenotype(bs);
} else { } else {
this.defaultInit(opt); this.defaultInit(opt);
System.out.println("Initial value for GAIndividualBinaryData is no BitSet!"); System.out.println("Initial value for GAIndividualBinaryData is no BitSet!");
@ -197,7 +197,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
public void SetBGenotype(BitSet binaryData) { public void setBGenotype(BitSet binaryData) {
this.m_Genotype = binaryData; this.m_Genotype = binaryData;
} }
@ -290,7 +290,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
public void SetBinaryPhenotype(BitSet binaryData) { public void setBinaryPhenotype(BitSet binaryData) {
this.m_Phenotype = binaryData; this.m_Phenotype = binaryData;
} }
@ -301,8 +301,8 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@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.m_Genotype = (BitSet) binaryData.clone();
} }

View File

@ -25,8 +25,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
private double[] m_Phenotype; private double[] m_Phenotype;
private double[][] m_Range; private double[][] m_Range;
protected BitSet m_Genotype; protected BitSet genotype;
protected int m_GenotypeLength; protected int genotypeLength;
private int m_Precision = 32; private int m_Precision = 32;
private InterfaceGADoubleCoding m_DoubleCoding = new GAStandardCodingDouble(); private InterfaceGADoubleCoding m_DoubleCoding = new GAStandardCodingDouble();
@ -38,8 +38,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
this.m_Range = new double[1][2]; this.m_Range = new double[1][2];
this.m_Range[0][0] = -10; this.m_Range[0][0] = -10;
this.m_Range[0][1] = 10; this.m_Range[0][1] = 10;
this.m_GenotypeLength = this.m_Precision; this.genotypeLength = this.m_Precision;
this.m_Genotype = new BitSet(); this.genotype = new BitSet();
} }
public GAIndividualDoubleData(GAIndividualDoubleData individual) { public GAIndividualDoubleData(GAIndividualDoubleData individual) {
@ -47,8 +47,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
this.m_Phenotype = new double[individual.m_Phenotype.length]; this.m_Phenotype = new double[individual.m_Phenotype.length];
System.arraycopy(individual.m_Phenotype, 0, this.m_Phenotype, 0, this.m_Phenotype.length); System.arraycopy(individual.m_Phenotype, 0, this.m_Phenotype, 0, this.m_Phenotype.length);
} }
this.m_GenotypeLength = individual.m_GenotypeLength; this.genotypeLength = individual.genotypeLength;
this.m_Genotype = (BitSet) individual.m_Genotype.clone(); this.genotype = (BitSet) individual.genotype.clone();
this.m_Range = new double[individual.m_Range.length][2]; this.m_Range = new double[individual.m_Range.length][2];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.m_Range.length; i++) {
this.m_Range[i][0] = individual.m_Range[i][0]; this.m_Range[i][0] = individual.m_Range[i][0];
@ -90,13 +90,13 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
if (individual instanceof GAIndividualDoubleData) { if (individual instanceof GAIndividualDoubleData) {
GAIndividualDoubleData indy = (GAIndividualDoubleData) individual; GAIndividualDoubleData indy = (GAIndividualDoubleData) individual;
//@todo Eigendlich k<EFBFBD>nnte ich noch das Koding vergleichen //@todo Eigendlich k<EFBFBD>nnte ich noch das Koding vergleichen
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;
} }
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.m_Range.length; i++) {
@ -138,7 +138,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
newRange[i][1] = this.m_Range[this.m_Range.length - 1][1]; newRange[i][1] = this.m_Range[this.m_Range.length - 1][1];
} }
this.m_Range = newRange; this.m_Range = newRange;
this.m_GenotypeLength = length * this.m_Precision; this.genotypeLength = length * this.m_Precision;
// changed 28.08.03 by request of Spieth // changed 28.08.03 by request of Spieth
// this.m_DecisionParameters = new double[length]; // this.m_DecisionParameters = new double[length];
@ -200,7 +200,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.m_Range.length; i++) {
locus[0] = i * this.m_Precision; locus[0] = i * this.m_Precision;
locus[1] = this.m_Precision; locus[1] = this.m_Precision;
this.m_Phenotype[i] = this.m_DoubleCoding.decodeValue(this.m_Genotype, this.m_Range[i], locus, false); this.m_Phenotype[i] = this.m_DoubleCoding.decodeValue(this.genotype, this.m_Range[i], locus, false);
} }
return this.m_Phenotype; return this.m_Phenotype;
} }
@ -218,7 +218,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
/** /**
* This method allows you to set the phenotype data. To change the genotype data, * This method allows you to set the phenotype data. To change the genotype data,
* use SetDoubleDataLamarckian. * use setDoubleDataLamarckian.
* *
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@ -240,7 +240,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
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.m_Precision;
locus[1] = this.m_Precision; locus[1] = this.m_Precision;
this.m_DoubleCoding.codeValue(doubleData[i], this.m_Range[i], this.m_Genotype, locus); this.m_DoubleCoding.codeValue(doubleData[i], this.m_Range[i], this.genotype, locus);
} }
} }
@ -297,8 +297,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
} }
result += "]\n"; result += "]\n";
result += "{"; result += "{";
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 += "1"; result += "1";
} else { } else {
result += "0"; result += "0";
@ -319,7 +319,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
*/ */
@Override @Override
public BitSet getBGenotype() { public BitSet getBGenotype() {
return this.m_Genotype; return this.genotype;
} }
/** /**
@ -329,8 +329,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
public void SetBGenotype(BitSet binaryData) { public void setBGenotype(BitSet binaryData) {
this.m_Genotype = binaryData; this.genotype = binaryData;
} }
/** /**
@ -342,16 +342,16 @@ public class GAIndividualDoubleData 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);
} }
} }
} }
@ -361,11 +361,11 @@ public class GAIndividualDoubleData 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 (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);
} }
} }
/********************************************************************************************************************** /**********************************************************************************************************************

View File

@ -22,37 +22,37 @@ import java.util.BitSet;
*/ */
public class GAIndividualIntegerData extends AbstractEAIndividual implements InterfaceGAIndividual, InterfaceDataTypeInteger, java.io.Serializable { public class GAIndividualIntegerData extends AbstractEAIndividual implements InterfaceGAIndividual, InterfaceDataTypeInteger, java.io.Serializable {
private int[] m_Phenotype; private int[] phenotype;
private int[][] m_Range; private int[][] range;
protected BitSet m_Genotype; protected BitSet genotype;
protected int[] m_CodingLenghts; protected int[] codingLengths;
private InterfaceGAIntegerCoding m_IntegerCoding = new GAStandardCodingInteger(); private InterfaceGAIntegerCoding intergerCoding = new GAStandardCodingInteger();
public GAIndividualIntegerData() { public GAIndividualIntegerData() {
this.mutationProbability = 0.2; this.mutationProbability = 0.2;
this.mutationOperator = new MutateGANBit(); this.mutationOperator = new MutateGANBit();
this.crossoverProbability = 0.7; this.crossoverProbability = 0.7;
this.crossoverOperator = new CrossoverGAGINPoint(); this.crossoverOperator = new CrossoverGAGINPoint();
this.m_Range = new int[1][2]; this.range = new int[1][2];
this.m_CodingLenghts = new int[1]; this.codingLengths = new int[1];
this.m_CodingLenghts[0] = 3; this.codingLengths[0] = 3;
this.m_Range[0][0] = 0; this.range[0][0] = 0;
this.m_Range[0][1] = 7; this.range[0][1] = 7;
this.m_Genotype = new BitSet(); this.genotype = new BitSet();
} }
public GAIndividualIntegerData(GAIndividualIntegerData individual) { public GAIndividualIntegerData(GAIndividualIntegerData 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);
} }
this.m_Genotype = (BitSet) individual.m_Genotype.clone(); this.genotype = (BitSet) individual.genotype.clone();
this.m_Range = new int[individual.m_Range.length][2]; this.range = new int[individual.range.length][2];
this.m_CodingLenghts = new int[individual.m_CodingLenghts.length]; this.codingLengths = new int[individual.codingLengths.length];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.range.length; i++) {
this.m_CodingLenghts[i] = individual.m_CodingLenghts[i]; this.codingLengths[i] = individual.codingLengths[i];
this.m_Range[i][0] = individual.m_Range[i][0]; this.range[i][0] = individual.range[i][0];
this.m_Range[i][1] = individual.m_Range[i][1]; this.range[i][1] = individual.range[i][1];
} }
// cloning the members of AbstractEAIndividual // cloning the members of AbstractEAIndividual
@ -65,7 +65,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
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_IntegerCoding = individual.m_IntegerCoding; this.intergerCoding = individual.intergerCoding;
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];
@ -90,20 +90,20 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
if (individual instanceof GAIndividualIntegerData) { if (individual instanceof GAIndividualIntegerData) {
GAIndividualIntegerData indy = (GAIndividualIntegerData) individual; GAIndividualIntegerData indy = (GAIndividualIntegerData) individual;
//@todo Eigendlich k<EFBFBD>nnte ich noch das Koding vergleichen //@todo Eigendlich k<EFBFBD>nnte ich noch das Koding vergleichen
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;
} }
if (this.m_Range.length != indy.m_Range.length) { if (this.range.length != indy.range.length) {
return false; return false;
} }
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.range.length; i++) {
if (this.m_Range[i][0] != indy.m_Range[i][0]) { if (this.range[i][0] != indy.range[i][0]) {
return false; return false;
} }
if (this.m_Range[i][1] != indy.m_Range[i][1]) { if (this.range[i][1] != indy.range[i][1]) {
return false; return false;
} }
} }
@ -127,20 +127,20 @@ public class GAIndividualIntegerData 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_Range.length)); i++) { for (int i = 0; ((i < newDesPa.length) && (i < this.range.length)); i++) {
newRange[i][0] = this.m_Range[i][0]; newRange[i][0] = this.range[i][0];
newRange[i][1] = this.m_Range[i][1]; newRange[i][1] = this.range[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.range.length; (i < newDesPa.length); i++) {
newRange[i][0] = this.m_Range[this.m_Range.length - 1][0]; newRange[i][0] = this.range[this.range.length - 1][0];
newRange[i][1] = this.m_Range[this.m_Range.length - 1][1]; newRange[i][1] = this.range[this.range.length - 1][1];
} }
this.m_Range = newRange; this.range = newRange;
this.m_CodingLenghts = new int[this.m_Range.length]; this.codingLengths = new int[this.range.length];
for (int i = 0; i < this.m_Range.length; i++) { for (int i = 0; i < this.range.length; i++) {
this.m_CodingLenghts[i] = this.m_IntegerCoding.calculateNecessaryBits(this.m_Range[i]); this.codingLengths[i] = this.intergerCoding.calculateNecessaryBits(this.range[i]);
} }
} }
@ -151,7 +151,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int size() { public int size() {
return this.m_Range.length; return this.range.length;
} }
/** /**
@ -162,14 +162,14 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
public void SetIntRange(int[][] range) { public void setIntRange(int[][] range) {
if (range.length != this.m_Range.length) { if (range.length != this.range.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.range.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.range.length) && (i < range.length)); i++) {
this.m_Range[i][0] = range[i][0]; this.range[i][0] = range[i][0];
this.m_Range[i][1] = range[i][1]; this.range[i][1] = range[i][1];
} }
this.setIntegerDataLength(range.length); this.setIntegerDataLength(range.length);
} }
@ -181,9 +181,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
* @param upper * @param upper
*/ */
public void SetIntRange(int lower, int upper) { public void SetIntRange(int lower, int upper) {
for (int i = 0; i < m_Range.length; i++) { for (int i = 0; i < range.length; i++) {
SetIntRange(i, lower, upper); setIntRange(i, lower, upper);
m_CodingLenghts[i] = m_IntegerCoding.calculateNecessaryBits(m_Range[i]); codingLengths[i] = intergerCoding.calculateNecessaryBits(range[i]);
} }
} }
@ -194,10 +194,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
* @param lower * @param lower
* @param upper * @param upper
*/ */
public void SetIntRange(int index, int lower, int upper) { public void setIntRange(int index, int lower, int upper) {
m_Range[index][0] = lower; range[index][0] = lower;
m_Range[index][1] = upper; range[index][1] = upper;
m_CodingLenghts[index] = m_IntegerCoding.calculateNecessaryBits(m_Range[index]); codingLengths[index] = intergerCoding.calculateNecessaryBits(range[index]);
} }
/** /**
@ -207,7 +207,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int[][] getIntRange() { public int[][] getIntRange() {
return this.m_Range; return this.range;
} }
/** /**
@ -220,13 +220,13 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
int[] locus = new int[2]; int[] locus = new int[2];
locus[0] = 0; locus[0] = 0;
locus[1] = 0; locus[1] = 0;
this.m_Phenotype = new int[this.m_Range.length]; this.phenotype = new int[this.range.length];
for (int i = 0; i < this.m_Phenotype.length; i++) { for (int i = 0; i < this.phenotype.length; i++) {
locus[0] += locus[1]; locus[0] += locus[1];
locus[1] = this.m_CodingLenghts[i]; locus[1] = this.codingLengths[i];
this.m_Phenotype[i] = this.m_IntegerCoding.decodeValue(this.m_Genotype, this.m_Range[i], locus, false); this.phenotype[i] = this.intergerCoding.decodeValue(this.genotype, this.range[i], locus, false);
} }
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -237,7 +237,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public int[] getIntegerDataWithoutUpdate() { public int[] getIntegerDataWithoutUpdate() {
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -246,8 +246,8 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
public void SetIntPhenotype(int[] doubleData) { public void setIntPhenotype(int[] doubleData) {
this.m_Phenotype = doubleData; this.phenotype = doubleData;
} }
/** /**
@ -257,16 +257,16 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
public void SetIntGenotype(int[] doubleData) { public void setIntGenotype(int[] doubleData) {
this.SetIntPhenotype(doubleData); this.setIntPhenotype(doubleData);
if (doubleData != null) { if (doubleData != null) {
int[] locus = new int[2]; int[] locus = new int[2];
locus[0] = 0; locus[0] = 0;
locus[1] = 0; locus[1] = 0;
for (int i = 0; i < doubleData.length; i++) { for (int i = 0; i < doubleData.length; i++) {
locus[0] += locus[1]; locus[0] += locus[1];
locus[1] = this.m_CodingLenghts[i]; locus[1] = this.codingLengths[i];
this.m_IntegerCoding.codeValue(doubleData[i], this.m_Range[i], this.m_Genotype, locus); this.intergerCoding.codeValue(doubleData[i], this.range[i], this.genotype, locus);
} }
} }
} }
@ -285,10 +285,10 @@ public class GAIndividualIntegerData 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.range.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);
} else { } else {
this.defaultInit(opt); this.defaultInit(opt);
System.out.println("Initial value for GAIndividualDoubleData is not double[]!"); System.out.println("Initial value for GAIndividualDoubleData is not double[]!");
@ -323,22 +323,22 @@ public class GAIndividualIntegerData 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.range.length; i++) {
result += "(" + this.m_Range[i][0] + "; " + this.m_Range[i][1] + "); "; result += "(" + this.range[i][0] + "; " + this.range[i][1] + "); ";
} }
result += "]\n"; result += "]\n";
result += "CodingLength: ["; result += "CodingLength: [";
for (int i = 0; i < this.m_CodingLenghts.length; i++) { for (int i = 0; i < this.codingLengths.length; i++) {
result += this.m_CodingLenghts[i] + "; "; result += this.codingLengths[i] + "; ";
} }
result += "]\n"; result += "]\n";
result += "{"; result += "{";
int overallLength = 0; int overallLength = 0;
for (int i = 0; i < this.m_CodingLenghts.length; i++) { for (int i = 0; i < this.codingLengths.length; i++) {
overallLength += this.m_CodingLenghts[i]; overallLength += this.codingLengths[i];
} }
for (int i = 0; i < overallLength; i++) { for (int i = 0; i < overallLength; i++) {
if (this.m_Genotype.get(i)) { if (this.genotype.get(i)) {
result += "1"; result += "1";
} else { } else {
result += "0"; result += "0";
@ -359,7 +359,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
*/ */
@Override @Override
public BitSet getBGenotype() { public BitSet getBGenotype() {
return this.m_Genotype; return this.genotype;
} }
/** /**
@ -369,22 +369,22 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
public void SetBGenotype(BitSet binaryData) { public void setBGenotype(BitSet binaryData) {
this.m_Genotype = binaryData; this.genotype = binaryData;
} }
/** /**
* This method allows the user to read the length of the genotype. * This method allows the user to read the length of the genotype.
* This may be necessary since BitSet.lenght only returns the index * This may be necessary since BitSet.lentgh only returns the index
* of the last significat bit. * of the last significant bit.
* *
* @return The length of the genotype. * @return The length of the genotype.
*/ */
@Override @Override
public int getGenotypeLength() { public int getGenotypeLength() {
int overallLength = 0; int overallLength = 0;
for (int i = 0; i < this.m_CodingLenghts.length; i++) { for (int codingLength : this.codingLengths) {
overallLength += this.m_CodingLenghts[i]; overallLength += codingLength;
} }
return overallLength; return overallLength;
} }
@ -392,14 +392,14 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
int overallLength = 0; int overallLength = 0;
for (int i = 0; i < this.m_CodingLenghts.length; i++) { for (int codingLength : this.codingLengths) {
overallLength += this.m_CodingLenghts[i]; overallLength += codingLength;
} }
for (int i = 0; i < overallLength; i++) { for (int i = 0; i < overallLength; 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);
} }
} }
} }
@ -410,14 +410,14 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
@Override @Override
public void defaultMutate() { public void defaultMutate() {
int overallLength = 0; int overallLength = 0;
for (int i = 0; i < this.m_CodingLenghts.length; i++) { for (int codingLength : this.codingLengths) {
overallLength += this.m_CodingLenghts[i]; overallLength += codingLength;
} }
int mutationIndex = RNG.randomInt(0, overallLength); int mutationIndex = RNG.randomInt(0, overallLength);
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);
} }
} }
@ -431,14 +431,14 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
range[i][1] = i + 1; range[i][1] = i + 1;
} }
indy.setIntegerDataLength(dimension); indy.setIntegerDataLength(dimension);
indy.SetIntRange(range); indy.setIntRange(range);
indy.defaultInit(null); indy.defaultInit(null);
System.out.println("" + indy.getStringRepresentation()); System.out.println("" + indy.getStringRepresentation());
System.out.println("System.exit(0)"); System.out.println("System.exit(0)");
int[] data = indy.getIntegerData(); int[] data = indy.getIntegerData();
String tmp = "Before {"; String tmp = "Before {";
for (int i = 0; i < data.length; i++) { for (int aData : data) {
tmp += data[i] + "; "; tmp += aData + "; ";
} }
System.out.println(tmp + "}"); System.out.println(tmp + "}");
tmp = "Setting {"; tmp = "Setting {";
@ -447,7 +447,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
tmp += data[i] + "; "; tmp += data[i] + "; ";
} }
System.out.println(tmp + "}"); System.out.println(tmp + "}");
indy.SetIntGenotype(data); indy.setIntGenotype(data);
System.out.println("" + indy.getStringRepresentation()); System.out.println("" + indy.getStringRepresentation());
data = indy.getIntegerData(); data = indy.getIntegerData();
tmp = "After {"; tmp = "After {";
@ -486,11 +486,11 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
* @param coding The used genotype coding method * @param coding The used genotype coding method
*/ */
public void setGACoding(InterfaceGAIntegerCoding coding) { public void setGACoding(InterfaceGAIntegerCoding coding) {
this.m_IntegerCoding = coding; this.intergerCoding = coding;
} }
public InterfaceGAIntegerCoding getGACoding() { public InterfaceGAIntegerCoding getGACoding() {
return this.m_IntegerCoding; return this.intergerCoding;
} }
public String gAIntegerCodingTipText() { public String gAIntegerCodingTipText() {

View File

@ -419,7 +419,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
/** /**
* This method will fetch the next int value from the BitSet. If necessary the * This method will fetch the next int value from the BitSet. If necessary the
* method will continue at the beginning of the BitSet if m_Genotype length is * method will continue at the beginning of the BitSet if genotype length is
* exceeded. * exceeded.
* Note: You need to set the current ReadingIndx = 0 before starting to decode * Note: You need to set the current ReadingIndx = 0 before starting to decode
* the BitSet * the BitSet
@ -653,7 +653,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
@Override @Override
public void SetBGenotype(BitSet binaryData) { public void setBGenotype(BitSet binaryData) {
this.m_Genotype = binaryData; this.m_Genotype = binaryData;
} }

View File

@ -36,7 +36,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
public GIIndividualIntegerData(int[][] theRange) { public GIIndividualIntegerData(int[][] theRange) {
this(); this();
SetIntRange(theRange); setIntRange(theRange);
} }
public GIIndividualIntegerData(GIIndividualIntegerData individual) { public GIIndividualIntegerData(GIIndividualIntegerData individual) {
@ -159,7 +159,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
public void SetIntRange(int[][] range) { public void setIntRange(int[][] range) {
if (range.length != this.m_Range.length) { if (range.length != this.m_Range.length) {
this.setIntegerDataLength(range.length); this.setIntegerDataLength(range.length);
} }
@ -210,7 +210,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
public void SetIntPhenotype(int[] doubleData) { public void setIntPhenotype(int[] doubleData) {
this.m_Phenotype = doubleData; this.m_Phenotype = doubleData;
} }
@ -221,8 +221,8 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@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.m_Genotype = new int[this.m_Range.length];
for (int i = 0; i < doubleData.length; i++) { for (int i = 0; i < doubleData.length; i++) {
this.m_Genotype[i] = doubleData[i]; this.m_Genotype[i] = doubleData[i];
@ -246,7 +246,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
if (bs.length != this.m_Range.length) { if (bs.length != this.m_Range.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);
} else { } else {
this.defaultInit(opt); this.defaultInit(opt);
System.out.println("Initial value for GAIndividualDoubleData is not double[]!"); System.out.println("Initial value for GAIndividualDoubleData is not double[]!");
@ -311,7 +311,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
@Override @Override
public void SetIGenotype(int[] b) { public void setIGenotype(int[] b) {
this.m_Genotype = b; this.m_Genotype = b;
} }

View File

@ -242,8 +242,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
* @param range The new range for the int data. * @param range The new range for the int data.
*/ */
@Override @Override
public void SetIntRange(int[][] range) { public void setIntRange(int[][] range) {
this.m_Integer.SetIntRange(range); this.m_Integer.setIntRange(range);
} }
/** /**
@ -283,8 +283,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
* @param intData The new int data. * @param intData The new int data.
*/ */
@Override @Override
public void SetIntPhenotype(int[] intData) { public void setIntPhenotype(int[] intData) {
this.m_Integer.SetIntPhenotype(intData); this.m_Integer.setIntPhenotype(intData);
} }
/** /**
@ -294,8 +294,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
* @param intData The new int data. * @param intData The new int data.
*/ */
@Override @Override
public void SetIntGenotype(int[] intData) { public void setIntGenotype(int[] intData) {
this.m_Integer.SetIntGenotype(intData); this.m_Integer.setIntGenotype(intData);
} }
/********************************************************************************************************************** /**********************************************************************************************************************
@ -349,8 +349,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
* @param perm The new permutation data. * @param perm The new permutation data.
*/ */
@Override @Override
public void SetPermutationPhenotype(int[][] perm) { public void setPermutationPhenotype(int[][] perm) {
this.SetPermutationPhenotype(perm); this.setPermutationPhenotype(perm);
} }
/** /**
@ -360,8 +360,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
* @param perm The new permutation data. * @param perm The new permutation data.
*/ */
@Override @Override
public void SetPermutationGenotype(int[][] perm) { public void setPermutationGenotype(int[][] perm) {
this.SetPermutationGenotype(perm); this.setPermutationGenotype(perm);
} }
@Override @Override

View File

@ -149,8 +149,8 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
this.m_Phenotype = new AbstractGPNode[this.m_Genotype.length]; this.m_Phenotype = new AbstractGPNode[this.m_Genotype.length];
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
this.m_Phenotype[i] = (AbstractGPNode) this.m_Genotype[i].clone(); this.m_Phenotype[i] = (AbstractGPNode) this.m_Genotype[i].clone();
// if (!m_Phenotype[0].checkDepth(0)) { // if (!phenotype[0].checkDepth(0)) {
// System.err.println("error... " + m_Genotype[0].checkDepth(0)); // System.err.println("error... " + genotype[0].checkDepth(0));
// } // }
if ((this.m_CheckMaxDepth) && (this.m_Phenotype[i].isMaxDepthViolated(this.m_maxAllowedDepth))) { if ((this.m_CheckMaxDepth) && (this.m_Phenotype[i].isMaxDepthViolated(this.m_maxAllowedDepth))) {
@ -300,7 +300,7 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
* @param b The new programgenotype of the Individual * @param b The new programgenotype of the Individual
*/ */
@Override @Override
public void SetPGenotype(AbstractGPNode[] b) { public void setPGenotype(AbstractGPNode[] b) {
this.m_Genotype = b; this.m_Genotype = b;
this.m_Phenotype = null; this.m_Phenotype = null;
} }
@ -312,7 +312,7 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
* @param i The index where to insert the new program * @param i The index where to insert the new program
*/ */
@Override @Override
public void SetPGenotype(AbstractGPNode b, int i) { public void setPGenotype(AbstractGPNode b, int i) {
this.m_Genotype[i] = b; this.m_Genotype[i] = b;
m_Genotype[i].updateDepth(0); m_Genotype[i].updateDepth(0);
// System.out.println("Setting pheno of depth " + b.getMaxDepth() + " " + b.getStringRepresentation()); // System.out.println("Setting pheno of depth " + b.getMaxDepth() + " " + b.getStringRepresentation());
@ -340,7 +340,7 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
newNode.initGrow(this.m_Area[i], this.m_maxAllowedDepth); newNode.initGrow(this.m_Area[i], this.m_maxAllowedDepth);
parent.setNode(newNode, nodeToMutate); parent.setNode(newNode, nodeToMutate);
} }
//if (!m_Genotype[i].checkDepth(0) || (m_Genotype[i].isMaxDepthViolated(m_maxAllowedDepth))) { //if (!genotype[i].checkDepth(0) || (genotype[i].isMaxDepthViolated(m_maxAllowedDepth))) {
// System.err.println("Error in GPIndividualProgramData.defaultMutate!"); // System.err.println("Error in GPIndividualProgramData.defaultMutate!");
//} //}
} }

View File

@ -48,7 +48,7 @@ public interface InterfaceDataTypeBinary {
* *
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
public void SetBinaryPhenotype(BitSet binaryData); public void setBinaryPhenotype(BitSet binaryData);
/** /**
* This method allows you to set the binary data, this can be used for * This method allows you to set the binary data, this can be used for
@ -56,5 +56,5 @@ public interface InterfaceDataTypeBinary {
* *
* @param binaryData The new binary data. * @param binaryData The new binary data.
*/ */
public void SetBinaryGenotype(BitSet binaryData); public void setBinaryGenotype(BitSet binaryData);
} }

View File

@ -33,7 +33,7 @@ public interface InterfaceDataTypeInteger {
* *
* @param range The new range for the int data. * @param range The new range for the int data.
*/ */
public void SetIntRange(int[][] range); public void setIntRange(int[][] range);
/** /**
* This method will return the range for all int attributes. * This method will return the range for all int attributes.
@ -62,7 +62,7 @@ public interface InterfaceDataTypeInteger {
* *
* @param intData The new int data. * @param intData The new int data.
*/ */
public void SetIntPhenotype(int[] intData); public void setIntPhenotype(int[] intData);
/** /**
* This method allows you to set the int data, this can be used for * This method allows you to set the int data, this can be used for
@ -70,5 +70,5 @@ public interface InterfaceDataTypeInteger {
* *
* @param intData The new int data. * @param intData The new int data.
*/ */
public void SetIntGenotype(int[] intData); public void setIntGenotype(int[] intData);
} }

View File

@ -55,7 +55,7 @@ public interface InterfaceDataTypePermutation {
* *
* @param perm The new permutation data. * @param perm The new permutation data.
*/ */
void SetPermutationPhenotype(int[][] perm); void setPermutationPhenotype(int[][] perm);
/** /**
* This method allows you to set the permutation data, this can be used for * This method allows you to set the permutation data, this can be used for
@ -63,7 +63,7 @@ public interface InterfaceDataTypePermutation {
* *
* @param perm The new permutation data. * @param perm The new permutation data.
*/ */
void SetPermutationGenotype(int[][] perm); void setPermutationGenotype(int[][] perm);
public void setFirstindex(int[] firstindex); public void setFirstindex(int[] firstindex);
} }

View File

@ -29,7 +29,7 @@ public interface InterfaceGAIndividual {
* *
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
public void SetBGenotype(BitSet b); public void setBGenotype(BitSet b);
/** /**
* This method allows the user to read the length of the genotype. * This method allows the user to read the length of the genotype.

View File

@ -33,7 +33,7 @@ public interface InterfaceGIIndividual {
* *
* @param range The new range for the int data. * @param range The new range for the int data.
*/ */
public void SetIntRange(int[][] range); public void setIntRange(int[][] range);
/** /**
* This method will allow the user to read the GI genotype * This method will allow the user to read the GI genotype
@ -50,7 +50,7 @@ public interface InterfaceGIIndividual {
* *
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
public void SetIGenotype(int[] b); public void setIGenotype(int[] b);
/** /**
* This method allows the user to read the length of the genotype. * This method allows the user to read the length of the genotype.

View File

@ -25,7 +25,7 @@ public interface InterfaceGPIndividual {
* *
* @param b The new program genotype of the Individual * @param b The new program genotype of the Individual
*/ */
public void SetPGenotype(AbstractGPNode[] b); public void setPGenotype(AbstractGPNode[] b);
/** /**
* This method will allow the user to set the current program 'genotype'. * This method will allow the user to set the current program 'genotype'.
@ -33,7 +33,7 @@ public interface InterfaceGPIndividual {
* @param b The new program genotype of the Individual * @param b The new program genotype of the Individual
* @param i The index where to insert the new program * @param i The index where to insert the new program
*/ */
public void SetPGenotype(AbstractGPNode b, int i); public void setPGenotype(AbstractGPNode b, int i);
/** /**
* This method allows you to get the function area * This method allows you to get the function area

View File

@ -24,9 +24,9 @@ public interface InterfaceOBGAIndividual {
/** /**
* SetOBGenotype sets the genotype of the individual. * setOBGenotype sets the genotype of the individual.
* *
* @param b int[] new genotype * @param b int[] new genotype
*/ */
public void SetOBGenotype(int[][] b); public void setOBGenotype(int[][] b);
} }

View File

@ -23,8 +23,8 @@ import java.util.ArrayList;
public class OBGAIndividualPermutationData extends AbstractEAIndividual implements InterfaceDataTypePermutation, InterfaceOBGAIndividual, java.io.Serializable { public class OBGAIndividualPermutationData extends AbstractEAIndividual implements InterfaceDataTypePermutation, InterfaceOBGAIndividual, java.io.Serializable {
int[][] m_Phenotype; int[][] phenotype;
int[][] m_Genotype; int[][] genotype;
int[] firstindex; int[] firstindex;
public OBGAIndividualPermutationData() { public OBGAIndividualPermutationData() {
@ -37,20 +37,20 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
} }
public OBGAIndividualPermutationData(OBGAIndividualPermutationData individual) { public OBGAIndividualPermutationData(OBGAIndividualPermutationData 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.m_Genotype = new int[individual.m_Genotype.length][]; this.genotype = new int[individual.genotype.length][];
for (int i = 0; i < m_Genotype.length; i++) { for (int i = 0; i < genotype.length; i++) {
this.m_Genotype[i] = new int[individual.m_Genotype[i].length]; this.genotype[i] = new int[individual.genotype[i].length];
System.arraycopy(individual.m_Genotype[i], 0, this.m_Genotype[i], 0, this.m_Genotype[i].length); System.arraycopy(individual.genotype[i], 0, this.genotype[i], 0, this.genotype[i].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.firstindex = individual.firstindex; this.firstindex = individual.firstindex;
this.age = individual.age; this.age = individual.age;
this.crossoverOperator = individual.crossoverOperator; this.crossoverOperator = individual.crossoverOperator;
@ -78,16 +78,16 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
public boolean equalGenotypes(AbstractEAIndividual individual) { public boolean equalGenotypes(AbstractEAIndividual individual) {
if (individual instanceof OBGAIndividualPermutationData) { if (individual instanceof OBGAIndividualPermutationData) {
OBGAIndividualPermutationData indy = (OBGAIndividualPermutationData) individual; OBGAIndividualPermutationData indy = (OBGAIndividualPermutationData) individual;
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) { if ((this.genotype == null) || (indy.genotype == null)) {
return false; return false;
} }
if (m_Genotype.length != indy.m_Genotype.length) { if (genotype.length != indy.genotype.length) {
return false; return false;
} }
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
if (this.m_Genotype[i].length != indy.m_Genotype[i].length) { if (this.genotype[i].length != indy.genotype[i].length) {
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] != indy.m_Genotype[i][j]) { if (this.genotype[i][j] != indy.genotype[i][j]) {
return false; return false;
} }
} }
@ -114,7 +114,7 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
@Override @Override
public void initByValue(Object obj, InterfaceOptimizationProblem opt) { public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
if (obj instanceof int[]) { if (obj instanceof int[]) {
this.SetPermutationGenotype((int[][]) obj); this.setPermutationGenotype((int[][]) obj);
} else { } else {
this.defaultInit(opt); this.defaultInit(opt);
System.out.println("Initial value for OBGAIndividualBinaryData is no Permutation!"); System.out.println("Initial value for OBGAIndividualBinaryData is no Permutation!");
@ -182,12 +182,12 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
@Override @Override
public int[][] getOBGenotype() { public int[][] getOBGenotype() {
return this.m_Genotype; return this.genotype;
} }
@Override @Override
public void SetOBGenotype(int[][] g) { public void setOBGenotype(int[][] g) {
this.m_Genotype = g; this.genotype = g;
} }
@Override @Override
@ -202,15 +202,15 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
perm[p2] = temp; perm[p2] = temp;
} }
this.SetPermutationGenotype(permmatrix); this.setPermutationGenotype(permmatrix);
} }
@Override @Override
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
//System.out.println("Default Init!"); //System.out.println("Default Init!");
int[][] perm = new int[this.m_Genotype.length][]; int[][] perm = new int[this.genotype.length][];
for (int p = 0; p < perm.length; p++) { for (int p = 0; p < perm.length; p++) {
perm[p] = new int[this.m_Genotype[p].length]; perm[p] = new int[this.genotype[p].length];
ArrayList pot = new ArrayList(); ArrayList pot = new ArrayList();
for (int i = 0; i < this.sizePermutation()[p]; i++) { for (int i = 0; i < this.sizePermutation()[p]; i++) {
pot.add(new Integer(firstindex[p] + i)); pot.add(new Integer(firstindex[p] + i));
@ -221,7 +221,7 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
i++; i++;
} }
} }
this.SetPermutationGenotype(perm); this.setPermutationGenotype(perm);
// System.out.println(getStringRepresentation()); // System.out.println(getStringRepresentation());
} }
@ -234,46 +234,46 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
@Override @Override
public void setPermutationDataLength(int[] length) { public void setPermutationDataLength(int[] length) {
this.m_Genotype = new int[length.length][]; this.genotype = new int[length.length][];
for (int i = 0; i < length.length; i++) { for (int i = 0; i < length.length; i++) {
this.m_Genotype[i] = new int[length[i]]; this.genotype[i] = new int[length[i]];
} }
} }
@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;
} }
@Override @Override
public void SetPermutationGenotype(int[][] perm) { public void setPermutationGenotype(int[][] perm) {
this.SetPermutationPhenotype(perm); this.setPermutationPhenotype(perm);
this.m_Genotype = new int[perm.length][]; this.genotype = new int[perm.length][];
for (int i = 0; i < perm.length; i++) { for (int i = 0; i < perm.length; i++) {
this.m_Genotype[i] = new int[perm[i].length]; this.genotype[i] = new int[perm[i].length];
System.arraycopy(perm[i], 0, this.m_Genotype[i], 0, perm[i].length); System.arraycopy(perm[i], 0, this.genotype[i], 0, perm[i].length);
} }
} }
@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 i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.genotype.length; i++) {
this.m_Phenotype[i] = new int[this.m_Genotype[i].length]; this.phenotype[i] = new int[this.genotype[i].length];
System.arraycopy(this.m_Genotype[i], 0, this.m_Phenotype[i], 0, this.m_Genotype[i].length); System.arraycopy(this.genotype[i], 0, this.phenotype[i], 0, this.genotype[i].length);
} }
return this.m_Phenotype; return this.phenotype;
} }
/** /**
@ -284,7 +284,7 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
*/ */
@Override @Override
public int[][] getPermutationDataWithoutUpdate() { public int[][] getPermutationDataWithoutUpdate() {
return this.m_Phenotype; return this.phenotype;
} }
public int[] getFirstindex() { public int[] getFirstindex() {

View File

@ -84,7 +84,7 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S
switch (handling) { switch (handling) {
case penaltyAdditive: case penaltyAdditive:
if (v > 0) { if (v > 0) {
indy.SetMarkPenalized(true); indy.setMarkPenalized(true);
for (int i = 0; i < indy.getFitness().length; i++) { for (int i = 0; i < indy.getFitness().length; i++) {
indy.SetFitness(i, indy.getFitness(i) + v + penaltyFactor); indy.SetFitness(i, indy.getFitness(i) + v + penaltyFactor);
} }
@ -92,7 +92,7 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S
break; break;
case penaltyMultiplicative: case penaltyMultiplicative:
if (v > 0) { if (v > 0) {
indy.SetMarkPenalized(true); indy.setMarkPenalized(true);
for (int i = 0; i < indy.getFitness().length; i++) { for (int i = 0; i < indy.getFitness().length; i++) {
indy.SetFitness(i, indy.getFitness(i) * (v + penaltyFactor)); indy.SetFitness(i, indy.getFitness(i) * (v + penaltyFactor));
} }

View File

@ -49,7 +49,7 @@ public class CM1 implements InterfaceCrossover, java.io.Serializable {
data.set(i, false); data.set(i, false);
} }
} }
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
} }
result[0] = indy1; result[0] = indy1;
return result; return result;

View File

@ -49,7 +49,7 @@ public class CM2 implements InterfaceCrossover, java.io.Serializable {
data.set(i, false); data.set(i, false);
} }
} }
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
} }
result[0] = indy1; result[0] = indy1;
return result; return result;

View File

@ -60,7 +60,7 @@ public class CM3 implements InterfaceCrossover, java.io.Serializable {
data.set(j, false); data.set(j, false);
} }
} }
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
} }
result[0] = indy1; result[0] = indy1;
return result; return result;

View File

@ -62,7 +62,7 @@ public class CM4 implements InterfaceCrossover, java.io.Serializable {
data.set(i, true); data.set(i, true);
} }
} }
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
} }
result[0] = indy1; result[0] = indy1;
return result; return result;

View File

@ -45,7 +45,7 @@ public class CM5 implements InterfaceCrossover, java.io.Serializable {
data.set(i, true); data.set(i, true);
} }
} }
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
} }
result[0] = indy1; result[0] = indy1;
return result; return result;

View File

@ -51,7 +51,7 @@ public class CM6 implements InterfaceCrossover, java.io.Serializable {
data.set(i, false); data.set(i, false);
} }
} }
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
} }
result[0] = indy1; result[0] = indy1;
return result; return result;

View File

@ -50,7 +50,7 @@ public class CM7 implements InterfaceCrossover, java.io.Serializable, InterfaceE
if (data.get(i) != data2.get(i)) { if (data.get(i) != data2.get(i)) {
different++; different++;
data.flip(i); data.flip(i);
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
this.m_OptimizationProblem.evaluate(indy1); this.m_OptimizationProblem.evaluate(indy1);
this.evaluations++; this.evaluations++;
if (indy1.getFitness(0) < min) { if (indy1.getFitness(0) < min) {
@ -66,7 +66,7 @@ public class CM7 implements InterfaceCrossover, java.io.Serializable, InterfaceE
} }
} }
} }
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
} }
result[0] = indy1; result[0] = indy1;
return result; return result;

View File

@ -87,7 +87,7 @@ public class CrossoverGABitSimulated implements InterfaceCrossover, java.io.Seri
} }
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceGAIndividual) result[i]).SetBGenotype(tmpBitSet[1][i]); ((InterfaceGAIndividual) result[i]).setBGenotype(tmpBitSet[1][i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -86,8 +86,8 @@ public class CrossoverGADefault implements InterfaceCrossover,
tmpBitSets[1].clear(i); tmpBitSets[1].clear(i);
} }
} }
((InterfaceGAIndividual) result[0]).SetBGenotype(tmpBitSets[0]); ((InterfaceGAIndividual) result[0]).setBGenotype(tmpBitSets[0]);
((InterfaceGAIndividual) result[1]).SetBGenotype(tmpBitSets[1]); ((InterfaceGAIndividual) result[1]).setBGenotype(tmpBitSets[1]);
} }
// in case the crossover was successfull lets give the mutation operators a // in case the crossover was successfull lets give the mutation operators a
// chance to mate the strategy parameters // chance to mate the strategy parameters

View File

@ -118,9 +118,9 @@ public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializ
private void writeBack(AbstractEAIndividual indy, private void writeBack(AbstractEAIndividual indy,
Object newGenotype) { Object newGenotype) {
if (indy instanceof InterfaceGAIndividual) { if (indy instanceof InterfaceGAIndividual) {
((InterfaceGAIndividual) indy).SetBGenotype((BitSet) newGenotype); ((InterfaceGAIndividual) indy).setBGenotype((BitSet) newGenotype);
} else { } else {
((InterfaceGIIndividual) indy).SetIGenotype((int[]) newGenotype); ((InterfaceGIIndividual) indy).setIGenotype((int[]) newGenotype);
} }
} }
@ -197,7 +197,7 @@ public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializ
// } // }
// } // }
// //
// for (int i = 0; i < result.length; i++) ((InterfaceGAIndividual)result[i]).SetBGenotype(tmpBitSet[1][i]); // for (int i = 0; i < result.length; i++) ((InterfaceGAIndividual)result[i]).setBGenotype(tmpBitSet[1][i]);
// } // }
// //in case the crossover was successful lets give the mutation operators a chance to mate the strategy parameters // //in case the crossover was successful lets give the mutation operators a chance to mate the strategy parameters
// for (int i = 0; i < result.length; i++) result[i].getMutationOperator().crossoverOnStrategyParameters(indy1, partners); // for (int i = 0; i < result.length; i++) result[i].getMutationOperator().crossoverOnStrategyParameters(indy1, partners);

View File

@ -81,7 +81,7 @@ public class CrossoverGAUniform implements InterfaceCrossover, java.io.Serializa
} }
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceGAIndividual) result[i]).SetBGenotype(tmpBitSet[1][i]); ((InterfaceGAIndividual) result[i]).setBGenotype(tmpBitSet[1][i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -88,7 +88,7 @@ public class CrossoverGIDefault implements InterfaceCrossover, java.io.Serializa
} }
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceGIIndividual) result[i]).SetIGenotype(children[i]); ((InterfaceGIIndividual) result[i]).setIGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -89,7 +89,7 @@ public class CrossoverGINPoint implements InterfaceCrossover, java.io.Serializab
} }
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceGIIndividual) result[i]).SetIGenotype(tmpInts[1][i]); ((InterfaceGIIndividual) result[i]).setIGenotype(tmpInts[1][i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -93,7 +93,7 @@ public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializ
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceGIIndividual) result[i]).setIntegerDataLength(offsprings[i].length); ((InterfaceGIIndividual) result[i]).setIntegerDataLength(offsprings[i].length);
((InterfaceGIIndividual) result[i]).SetIGenotype(offsprings[i]); ((InterfaceGIIndividual) result[i]).setIGenotype(offsprings[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -80,7 +80,7 @@ public class CrossoverGIUniform implements InterfaceCrossover, java.io.Serializa
} }
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceGIIndividual) result[i]).SetIGenotype(tmpInts[1][i]); ((InterfaceGIIndividual) result[i]).setIGenotype(tmpInts[1][i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -105,13 +105,13 @@ public class CrossoverGPDefault implements InterfaceCrossover, java.io.Serializa
// actually switch individuals! // actually switch individuals!
if (selNodeThisParent == null) { if (selNodeThisParent == null) {
((InterfaceGPIndividual) result[0]).SetPGenotype((AbstractGPNode) selNodeOther.clone(), t); ((InterfaceGPIndividual) result[0]).setPGenotype((AbstractGPNode) selNodeOther.clone(), t);
} else { } else {
selNodeThisParent.setNode((AbstractGPNode) selNodeOther.clone(), selNodeThis); selNodeThisParent.setNode((AbstractGPNode) selNodeOther.clone(), selNodeThis);
} }
// for (int i = 0; i < result.length; i++) System.out.println("-- Betw Crossover: " +result[i].getStringRepresentation()); // for (int i = 0; i < result.length; i++) System.out.println("-- Betw Crossover: " +result[i].getStringRepresentation());
if (selNodeOtherParent == null) { if (selNodeOtherParent == null) {
((InterfaceGPIndividual) result[1]).SetPGenotype((AbstractGPNode) selNodeThis.clone(), t); ((InterfaceGPIndividual) result[1]).setPGenotype((AbstractGPNode) selNodeThis.clone(), t);
} else { } else {
selNodeOtherParent.setNode((AbstractGPNode) selNodeThis.clone(), selNodeOther); selNodeOtherParent.setNode((AbstractGPNode) selNodeThis.clone(), selNodeOther);
} }

View File

@ -71,8 +71,8 @@ public class CrossoverOBGAPMX implements InterfaceCrossover, java.io.Serializabl
pperm2[i] = perm2; pperm2[i] = perm2;
} }
((InterfaceOBGAIndividual) result[0]).SetOBGenotype(pperm1); ((InterfaceOBGAIndividual) result[0]).setOBGenotype(pperm1);
((InterfaceOBGAIndividual) result[1]).SetOBGenotype(pperm2); ((InterfaceOBGAIndividual) result[1]).setOBGenotype(pperm2);
//((InterfaceDataTypePermutation) result[0]).SetPermutationDataLamarckian(pperm1); //((InterfaceDataTypePermutation) result[0]).SetPermutationDataLamarckian(pperm1);
//((InterfaceDataTypePermutation) result[1]).SetPermutationDataLamarckian(pperm2); //((InterfaceDataTypePermutation) result[1]).SetPermutationDataLamarckian(pperm2);
} }

View File

@ -71,8 +71,8 @@ public class CrossoverOBGAPMXUniform implements InterfaceCrossover, java.io.Seri
pperm1[i] = perm1; pperm1[i] = perm1;
pperm2[i] = perm2; pperm2[i] = perm2;
} }
((InterfaceOBGAIndividual) result[0]).SetOBGenotype(pperm1); ((InterfaceOBGAIndividual) result[0]).setOBGenotype(pperm1);
((InterfaceOBGAIndividual) result[1]).SetOBGenotype(pperm2); ((InterfaceOBGAIndividual) result[1]).setOBGenotype(pperm2);
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {

View File

@ -147,9 +147,9 @@ public class GAGIInitializeSegmentwise implements InterfaceInitialization, java.
// write back the genotype (it may have been cloned, who knows...) // write back the genotype (it may have been cloned, who knows...)
if (indy instanceof InterfaceGAIndividual) { if (indy instanceof InterfaceGAIndividual) {
((InterfaceGAIndividual) indy).SetBGenotype((BitSet) genotype); ((InterfaceGAIndividual) indy).setBGenotype((BitSet) genotype);
} else { } else {
((InterfaceGIIndividual) indy).SetIGenotype((int[]) genotype); ((InterfaceGIIndividual) indy).setIGenotype((int[]) genotype);
} }
// System.out.println(BeanInspector.toString(genotype)); // System.out.println(BeanInspector.toString(genotype));
} else { } else {

View File

@ -101,7 +101,7 @@ public class MutateGAAdaptive implements InterfaceMutation, java.io.Serializable
tmpBitSet.flip(i); tmpBitSet.flip(i);
} }
} }
((InterfaceGAIndividual) individual).SetBGenotype(tmpBitSet); ((InterfaceGAIndividual) individual).setBGenotype(tmpBitSet);
} }
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());
} }

View File

@ -127,9 +127,9 @@ public class MutateGAGISwapBits implements InterfaceMutation, java.io.Serializab
// tmpBitSet.set(mutationIndices[i][0], tmpBit); // tmpBitSet.set(mutationIndices[i][0], tmpBit);
} }
if (genotype instanceof BitSet) { if (genotype instanceof BitSet) {
((InterfaceGAIndividual) individual).SetBGenotype((BitSet) genotype); ((InterfaceGAIndividual) individual).setBGenotype((BitSet) genotype);
} else { } else {
((InterfaceGIIndividual) individual).SetIGenotype((int[]) genotype); ((InterfaceGIIndividual) individual).setIGenotype((int[]) genotype);
} }
} }
// System.err.println("After Mutate: " +(individual.getStringRepresentation())); // System.err.println("After Mutate: " +(individual.getStringRepresentation()));

View File

@ -90,7 +90,7 @@ public class MutateGAInvertBits implements InterfaceMutation, java.io.Serializab
tmpBitSet.flip(0, (mutationIndices[i][0] + mutationIndices[i][1]) - ((InterfaceGAIndividual) individual).getGenotypeLength()); tmpBitSet.flip(0, (mutationIndices[i][0] + mutationIndices[i][1]) - ((InterfaceGAIndividual) individual).getGenotypeLength());
} }
} }
((InterfaceGAIndividual) individual).SetBGenotype(tmpBitSet); ((InterfaceGAIndividual) individual).setBGenotype(tmpBitSet);
} }
} }

View File

@ -81,7 +81,7 @@ public class MutateGANBit implements InterfaceMutation, java.io.Serializable {
for (int i = 0; i < mutationIndices.length; i++) { for (int i = 0; i < mutationIndices.length; i++) {
tmpBitSet.flip(mutationIndices[i]); tmpBitSet.flip(mutationIndices[i]);
} }
((InterfaceGAIndividual) individual).SetBGenotype(tmpBitSet); ((InterfaceGAIndividual) individual).setBGenotype(tmpBitSet);
} }
} }

View File

@ -100,7 +100,7 @@ public class MutateGAShiftSubstring implements InterfaceMutation, java.io.Serial
tmpBitSet.set((len + b - d + i + 1) % len, origBitSet.get((len + a - d + i) % len)); tmpBitSet.set((len + b - d + i + 1) % len, origBitSet.get((len + a - d + i) % len));
} }
// System.out.println(tmpBitSet.cardinality()); // System.out.println(tmpBitSet.cardinality());
((InterfaceGAIndividual) individual).SetBGenotype(tmpBitSet); ((InterfaceGAIndividual) individual).setBGenotype(tmpBitSet);
} }
// System.out.println("After Mutate: " +(individual.getStringRepresentation())); // System.out.println("After Mutate: " +(individual.getStringRepresentation()));
} }

View File

@ -146,7 +146,7 @@ public class MutateGASwapBitsSegmentwise implements InterfaceMutation, java.io.S
} while (multiplesPerSegment && cntMutes < segmentLength && RNG.flipCoin(mutationProbPerSegment)); } while (multiplesPerSegment && cntMutes < segmentLength && RNG.flipCoin(mutationProbPerSegment));
} }
} }
((InterfaceGAIndividual) individual).SetBGenotype(tmpBitSet); // write back the genotype ((InterfaceGAIndividual) individual).setBGenotype(tmpBitSet); // write back the genotype
} }
// System.out.println("After Mutate: " +(individual).getStringRepresentation()); // System.out.println("After Mutate: " +(individual).getStringRepresentation());
} }

View File

@ -136,8 +136,8 @@ public class MutateGIInsertDelete implements InterfaceMutation, java.io.Serializ
System.out.println("newX " + newX.length); System.out.println("newX " + newX.length);
} }
((InterfaceGIIndividual) individual).setIntegerDataLength(newX.length); ((InterfaceGIIndividual) individual).setIntegerDataLength(newX.length);
((InterfaceGIIndividual) individual).SetIGenotype(newX); ((InterfaceGIIndividual) individual).setIGenotype(newX);
((InterfaceGIIndividual) individual).SetIntRange(newRange); ((InterfaceGIIndividual) individual).setIntRange(newRange);
newX = ((InterfaceGIIndividual) individual).getIGenotype(); newX = ((InterfaceGIIndividual) individual).getIGenotype();
if (newX.length <= 1) { if (newX.length <= 1) {
System.out.println("newX " + newX.length); System.out.println("newX " + newX.length);

View File

@ -91,7 +91,7 @@ public class MutateGIInvert implements InterfaceMutation, java.io.Serializable {
} }
//this.pintInt("After ", tmp); //this.pintInt("After ", tmp);
//this.pintInt("After ", x); //this.pintInt("After ", x);
((InterfaceGIIndividual) individual).SetIGenotype(x); ((InterfaceGIIndividual) individual).setIGenotype(x);
} }
} }

View File

@ -85,7 +85,7 @@ public class MutateGINominal implements InterfaceMutation, java.io.Serializable
} }
x[mutInd] = RNG.randomInt(range[mutInd][0], range[mutInd][1]); x[mutInd] = RNG.randomInt(range[mutInd][0], range[mutInd][1]);
} }
((InterfaceGIIndividual) individual).SetIGenotype(x); ((InterfaceGIIndividual) individual).setIGenotype(x);
} }
} }

View File

@ -103,7 +103,7 @@ public class MutateGIOrdinal implements InterfaceMutation, java.io.Serializable
x[mutInd] = range[mutInd][1]; x[mutInd] = range[mutInd][1];
} }
} }
((InterfaceGIIndividual) individual).SetIGenotype(x); ((InterfaceGIIndividual) individual).setIGenotype(x);
} }
} }

View File

@ -127,7 +127,7 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa
} }
// System.out.println(""+from+"/"+to+"/"+length); // System.out.println(""+from+"/"+to+"/"+length);
// this.printInt("After ", tmp); // this.printInt("After ", tmp);
((InterfaceGIIndividual) individual).SetIGenotype(tmp); ((InterfaceGIIndividual) individual).setIGenotype(tmp);
} }
} }

View File

@ -80,7 +80,7 @@ public class MutateGPSingleNode implements InterfaceMutation, java.io.Serializab
if (parent != null) { if (parent != null) {
newNode.setParent(parent); newNode.setParent(parent);
} else { } else {
((InterfaceGPIndividual) individual).SetPGenotype(newNode, i); ((InterfaceGPIndividual) individual).setPGenotype(newNode, i);
} }
// now reconnect the children // now reconnect the children
newNode.initNodeArray(); newNode.initNodeArray();

View File

@ -69,7 +69,7 @@ public class MutateOBGAFlip implements InterfaceMutation, java.io.Serializable {
perm[p][p2] = temp; perm[p][p2] = temp;
} }
} }
((InterfaceOBGAIndividual) individual).SetOBGenotype(perm); ((InterfaceOBGAIndividual) individual).setOBGenotype(perm);
} }
/** /**

View File

@ -66,7 +66,7 @@ public class MutateOBGAInversion implements java.io.Serializable, InterfaceMutat
permnew[p][p1 + i] = perm[p][p2 - i]; permnew[p][p1 + i] = perm[p][p2 - i];
} }
} }
((InterfaceOBGAIndividual) individual).SetOBGenotype(permnew); ((InterfaceOBGAIndividual) individual).setOBGenotype(permnew);
} }
/** This method allows you to perform either crossover on the strategy parameters /** This method allows you to perform either crossover on the strategy parameters

View File

@ -111,7 +111,7 @@ public class SelectParticleWheel implements InterfaceSelection, java.io.Serializ
sum += ((AbstractEAIndividual) population.getIndividual(selIndex)).getSelectionProbability(0); sum += ((AbstractEAIndividual) population.getIndividual(selIndex)).getSelectionProbability(0);
} }
result.add(((AbstractEAIndividual) population.get(selIndex)).clone()); result.add(((AbstractEAIndividual) population.get(selIndex)).clone());
((AbstractEAIndividual) result.getIndividual(i)).SetAge(0); ((AbstractEAIndividual) result.getIndividual(i)).setAge(0);
} }
} }
@ -129,7 +129,7 @@ public class SelectParticleWheel implements InterfaceSelection, java.io.Serializ
selFitSum += ((AbstractEAIndividual) population.getIndividual(selIndex)).getSelectionProbability(0); selFitSum += ((AbstractEAIndividual) population.getIndividual(selIndex)).getSelectionProbability(0);
} }
result.add(((AbstractEAIndividual) population.get(selIndex)).clone()); result.add(((AbstractEAIndividual) population.get(selIndex)).clone());
((AbstractEAIndividual) result.getIndividual(i)).SetAge(0); ((AbstractEAIndividual) result.getIndividual(i)).setAge(0);
selPoint += segment; selPoint += segment;
} }
} }

View File

@ -123,7 +123,7 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i]); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i]);
} }
} }
} else { } else {
@ -174,7 +174,7 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
double[] tmpD = new double[1]; double[] tmpD = new double[1];
tmpD[0] = result[i] / sum; tmpD[0] = result[i] / sum;
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(tmpD); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(tmpD);
} }
} }
} else { } else {
@ -224,7 +224,7 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i]); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i]);
} }
} }
} }

View File

@ -70,7 +70,7 @@ public class SelProbFitnessSharing extends AbstractSelProb implements java.io.Se
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
tmpIndy1 = ((AbstractEAIndividual) population.get(i)); tmpIndy1 = ((AbstractEAIndividual) population.get(i));
tmpIndy1.SetSelectionProbability(0, (selProb[i] / sum)); tmpIndy1.setSelectionProbability(0, (selProb[i] / sum));
} }
} }

View File

@ -72,7 +72,7 @@ public class SelProbInvertByMax extends AbstractSelProb {
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i] / sum); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i] / sum);
} }
} }
} else { } else {
@ -89,7 +89,7 @@ public class SelProbInvertByMax extends AbstractSelProb {
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
double[] tmpD = new double[1]; double[] tmpD = new double[1];
tmpD[0] = result[i] / sum; tmpD[0] = result[i] / sum;
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(tmpD); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(tmpD);
} }
} }
} }

View File

@ -95,7 +95,7 @@ public class SelProbLinearRanking extends AbstractSelProb implements java.io.Ser
// set the selection propability // set the selection propability
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
temp = (1 / (double) size) * (this.nappaPlus - ((this.nappaPlus - this.nappaMinus) * ((double) (i) / (double) (size - 1)))); temp = (1 / (double) size) * (this.nappaPlus - ((this.nappaPlus - this.nappaMinus) * ((double) (i) / (double) (size - 1))));
((AbstractEAIndividual) population.get(rank_index[i])).SetSelectionProbability(x, temp); ((AbstractEAIndividual) population.get(rank_index[i])).setSelectionProbability(x, temp);
} }
} }
} else { } else {
@ -131,7 +131,7 @@ public class SelProbLinearRanking extends AbstractSelProb implements java.io.Ser
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
double[] tmpD = new double[1]; double[] tmpD = new double[1];
tmpD[0] = (1 / (double) size) * (this.nappaPlus - ((this.nappaPlus - this.nappaMinus) * ((double) (i) / (double) (size - 1)))); tmpD[0] = (1 / (double) size) * (this.nappaPlus - ((this.nappaPlus - this.nappaMinus) * ((double) (i) / (double) (size - 1))));
((AbstractEAIndividual) population.get(rank_index[i])).SetSelectionProbability(tmpD); ((AbstractEAIndividual) population.get(rank_index[i])).setSelectionProbability(tmpD);
} }
} }
} else { } else {
@ -166,7 +166,7 @@ public class SelProbLinearRanking extends AbstractSelProb implements java.io.Ser
// set the selection propability // set the selection propability
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
temp = (1 / (double) size) * (this.nappaPlus - ((this.nappaPlus - this.nappaMinus) * ((double) (i) / (double) (size - 1)))); temp = (1 / (double) size) * (this.nappaPlus - ((this.nappaPlus - this.nappaMinus) * ((double) (i) / (double) (size - 1))));
((AbstractEAIndividual) population.get(rank_index[i])).SetSelectionProbability(x, temp); ((AbstractEAIndividual) population.get(rank_index[i])).setSelectionProbability(x, temp);
} }
} }
} }

View File

@ -102,7 +102,7 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
sum += result[i]; sum += result[i];
} }
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
((AbstractEAIndividual) population.get(rank_index[i])).SetSelectionProbability(x, result[i] / sum); ((AbstractEAIndividual) population.get(rank_index[i])).setSelectionProbability(x, result[i] / sum);
} }
} }
} else { } else {
@ -143,7 +143,7 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
double[] tmpD = new double[1]; double[] tmpD = new double[1];
tmpD[0] = result[i] / sum; tmpD[0] = result[i] / sum;
((AbstractEAIndividual) population.get(rank_index[i])).SetSelectionProbability(tmpD); ((AbstractEAIndividual) population.get(rank_index[i])).setSelectionProbability(tmpD);
} }
} }
} else { } else {
@ -182,7 +182,7 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
sum += result[i]; sum += result[i];
} }
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
((AbstractEAIndividual) population.get(rank_index[i])).SetSelectionProbability(x, result[i] / sum); ((AbstractEAIndividual) population.get(rank_index[i])).setSelectionProbability(x, result[i] / sum);
} }
} }
} }

View File

@ -72,7 +72,7 @@ public class SelProbRanking extends AbstractSelProb implements java.io.Serializa
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i] / sum); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i] / sum);
} }
} }
} else { } else {
@ -99,7 +99,7 @@ public class SelProbRanking extends AbstractSelProb implements java.io.Serializa
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i] / sum); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i] / sum);
} }
} }
} }

View File

@ -65,7 +65,7 @@ public class SelProbStandard extends AbstractSelProb implements java.io.Serializ
sum += result[i]; sum += result[i];
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i] / sum); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i] / sum);
} }
} }
} else { } else {
@ -81,7 +81,7 @@ public class SelProbStandard extends AbstractSelProb implements java.io.Serializ
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
double[] tmpD = new double[1]; double[] tmpD = new double[1];
tmpD[0] = result[i] / sum; tmpD[0] = result[i] / sum;
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(tmpD); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(tmpD);
} }
} }
} else { } else {
@ -96,7 +96,7 @@ public class SelProbStandard extends AbstractSelProb implements java.io.Serializ
sum += result[i]; sum += result[i];
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i] / sum); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i] / sum);
} }
} }
} }

View File

@ -94,7 +94,7 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i] / sum); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i] / sum);
} }
} }
} else { } else {
@ -125,7 +125,7 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
double[] tmpD = new double[1]; double[] tmpD = new double[1];
tmpD[0] = result[i] / sum; tmpD[0] = result[i] / sum;
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(tmpD); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(tmpD);
} }
} }
} else { } else {
@ -155,7 +155,7 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
} }
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i] / sum); ((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i] / sum);
} }
} }
} }

View File

@ -101,7 +101,7 @@ public class PBILPopulation extends Population implements Cloneable, java.io.Ser
tmpBitSet.clear(j); tmpBitSet.clear(j);
} }
} }
tmpIndy.SetBGenotype(tmpBitSet); tmpIndy.setBGenotype(tmpBitSet);
super.add(tmpIndy); super.add(tmpIndy);
} }
} }

View File

@ -554,7 +554,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
curCard += (int) Math.round(RNG.gaussianDouble((double) stdDev)); curCard += (int) Math.round(RNG.gaussianDouble((double) stdDev));
} }
curCard = Math.max(0, Math.min(curCard, gaIndy.getGenotypeLength())); curCard = Math.max(0, Math.min(curCard, gaIndy.getGenotypeLength()));
gaIndy.SetBGenotype(RNG.randomBitSet(curCard, gaIndy.getGenotypeLength())); gaIndy.setBGenotype(RNG.randomBitSet(curCard, gaIndy.getGenotypeLength()));
} }
} else { } else {
System.err.println("Error: InterfaceGAIndividual required for binary cardinality initialization!"); System.err.println("Error: InterfaceGAIndividual required for binary cardinality initialization!");

View File

@ -140,7 +140,7 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz
} }
getProblem().initializePopulation(population); getProblem().initializePopulation(population);
for (int i = 0; i < population.size(); i++) { for (int i = 0; i < population.size(); i++) {
((AbstractEAIndividual) population.get(i)).SetAge(0); ((AbstractEAIndividual) population.get(i)).setAge(0);
} }
} }

View File

@ -170,7 +170,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
while (eval(tmpSet)[1] > 0) { while (eval(tmpSet)[1] > 0) {
tmpSet.set(RNG.randomInt(0, items.length - 1)); tmpSet.set(RNG.randomInt(0, items.length - 1));
} }
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(tmpSet); ((InterfaceDataTypeBinary) indy).setBinaryGenotype(tmpSet);
} }
} }
@ -252,7 +252,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
} }
if (this.m_Lamarckism) { if (this.m_Lamarckism) {
((InterfaceDataTypeBinary) individual).SetBinaryGenotype(tmpBitSet); ((InterfaceDataTypeBinary) individual).setBinaryGenotype(tmpBitSet);
} }
} }
result[0] += 5100; result[0] += 5100;

View File

@ -333,10 +333,10 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
((InterfaceDataTypeDouble) indy).setDoubleGenotype(ds); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(ds);
break; break;
case typeBinary: case typeBinary:
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(toBinary(ds)); ((InterfaceDataTypeBinary) indy).setBinaryGenotype(toBinary(ds));
break; break;
case typeInteger: case typeInteger:
((InterfaceDataTypeInteger) indy).SetIntGenotype(toInteger(ds)); ((InterfaceDataTypeInteger) indy).setIntGenotype(toInteger(ds));
break; break;
} }
} }

View File

@ -733,7 +733,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
AbstractGPNode node = AbstractGPNode.parseFromString(nodeStr); AbstractGPNode node = AbstractGPNode.parseFromString(nodeStr);
PSymbolicRegression regrProb = new PSymbolicRegression(); PSymbolicRegression regrProb = new PSymbolicRegression();
GPIndividualProgramData indy = new GPIndividualProgramData(); GPIndividualProgramData indy = new GPIndividualProgramData();
indy.SetPGenotype(node, 0); indy.setPGenotype(node, 0);
regrProb.evaluate(indy); regrProb.evaluate(indy);
System.out.println("Evaluated individual: " + indy); System.out.println("Evaluated individual: " + indy);
return indy.getFitness(); return indy.getFitness();

View File

@ -233,7 +233,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
} }
probDim = (Integer) dim; probDim = (Integer) dim;
((InterfaceDataTypeBinary) this.template) ((InterfaceDataTypeBinary) this.template)
.SetBinaryGenotype(new BitSet(probDim)); .setBinaryGenotype(new BitSet(probDim));
} }
this.network = new BayNet(this.probDim, upperProbLimit, lowerProbLimit); this.network = new BayNet(this.probDim, upperProbLimit, lowerProbLimit);
this.network.setScoringMethod(this.scoringMethod); this.network.setScoringMethod(this.scoringMethod);
@ -354,7 +354,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
AbstractEAIndividual indy = (AbstractEAIndividual) this.template AbstractEAIndividual indy = (AbstractEAIndividual) this.template
.clone(); .clone();
BitSet data = this.network.sample(getBinaryData(indy)); BitSet data = this.network.sample(getBinaryData(indy));
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy).setBinaryGenotype(data);
evaluate(indy); evaluate(indy);
pop.add(indy); pop.add(indy);
} }
@ -941,11 +941,11 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
// data5.set(0, true); // data5.set(0, true);
// data5.set(1, true); // data5.set(1, true);
// data5.set(2, true); // data5.set(2, true);
indy1.SetBinaryGenotype(data1); indy1.setBinaryGenotype(data1);
indy2.SetBinaryGenotype(data2); indy2.setBinaryGenotype(data2);
indy3.SetBinaryGenotype(data3); indy3.setBinaryGenotype(data3);
indy4.SetBinaryGenotype(data4); indy4.setBinaryGenotype(data4);
indy5.SetBinaryGenotype(data5); indy5.setBinaryGenotype(data5);
pop.add(indy1); pop.add(indy1);
pop.add(indy2); pop.add(indy2);
pop.add(indy3); pop.add(indy3);

View File

@ -204,7 +204,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
System.err.println("Couldnt get problem dimension!"); System.err.println("Couldnt get problem dimension!");
} }
probDim = (Integer) dim; probDim = (Integer) dim;
((InterfaceDataTypeBinary) this.template).SetBinaryGenotype(new BitSet(probDim)); ((InterfaceDataTypeBinary) this.template).setBinaryGenotype(new BitSet(probDim));
} }
this.firstTime = true; this.firstTime = true;
this.cross.init(this.template, problem, refSet, Double.MAX_VALUE); this.cross.init(this.template, problem, refSet, Double.MAX_VALUE);
@ -294,7 +294,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
for (int j = 0; j < data.size(); j += i) { for (int j = 0; j < data.size(); j += i) {
data.flip(j); data.flip(j);
} }
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy).setBinaryGenotype(data);
if (i == 1) { if (i == 1) {
i++; i++;
method1 = !method1; method1 = !method1;
@ -306,7 +306,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
for (int j = 0; j < data.size(); j += i) { for (int j = 0; j < data.size(); j += i) {
data.flip(j); data.flip(j);
} }
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) indy).setBinaryGenotype(data);
} }
i++; i++;
} }
@ -334,7 +334,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
data.set(i, true); data.set(i, true);
} }
} }
dblIndy.SetBinaryGenotype(data); dblIndy.setBinaryGenotype(data);
if (!contains(dblIndy, pop)) { if (!contains(dblIndy, pop)) {
pop.add(dblIndy); pop.add(dblIndy);
evaluate(indy); evaluate(indy);
@ -362,7 +362,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
data.set(i, false); data.set(i, false);
} }
} }
dblIndy.SetBinaryGenotype(data); dblIndy.setBinaryGenotype(data);
if (!contains(dblIndy, pop)) { if (!contains(dblIndy, pop)) {
pop.add(dblIndy); pop.add(dblIndy);
evaluate(indy); evaluate(indy);
@ -610,7 +610,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
improvement = false; improvement = false;
for (int i : cl) { for (int i : cl) {
data.flip(i); data.flip(i);
((InterfaceDataTypeBinary) tmpIndy).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) tmpIndy).setBinaryGenotype(data);
evaluate(tmpIndy); evaluate(tmpIndy);
if (tmpIndy.getFitness(0) < indy.getFitness(0)) { if (tmpIndy.getFitness(0) < indy.getFitness(0)) {
improvement = true; improvement = true;
@ -628,7 +628,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
if (valJ != valI) { if (valJ != valI) {
data.set(i, valJ); data.set(i, valJ);
data.set(j, valI); data.set(j, valI);
((InterfaceDataTypeBinary) tmpIndy).SetBinaryGenotype(data); ((InterfaceDataTypeBinary) tmpIndy).setBinaryGenotype(data);
evaluate(tmpIndy); evaluate(tmpIndy);
if (tmpIndy.getFitness(0) < indy.getFitness(0)) { if (tmpIndy.getFitness(0) < indy.getFitness(0)) {
improvement = true; improvement = true;

View File

@ -201,7 +201,7 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
} }
} }
} }
mutant.SetBGenotype(tmpBitSet); mutant.setBGenotype(tmpBitSet);
this.population.add(mutant); this.population.add(mutant);
} }
if (best instanceof InterfaceGAIndividual) { if (best instanceof InterfaceGAIndividual) {

View File

@ -427,7 +427,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
Mathematics.projectToRange(nX, esIndy.getDoubleRange()); Mathematics.projectToRange(nX, esIndy.getDoubleRange());
} // why did this never happen before? } // why did this never happen before?
esIndy.setDoubleGenotype(nX); esIndy.setDoubleGenotype(nX);
indy.SetAge(0); indy.setAge(0);
indy.resetConstraintViolation(); indy.resetConstraintViolation();
double[] fit = new double[1]; double[] fit = new double[1];
fit[0] = 0; fit[0] = 0;
@ -530,7 +530,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
if (((AbstractEAIndividual) population.get(i)).getAge() >= maximumAge) { if (((AbstractEAIndividual) population.get(i)).getAge() >= maximumAge) {
this.optimizationProblem.evaluate(((AbstractEAIndividual) population.get(i))); this.optimizationProblem.evaluate(((AbstractEAIndividual) population.get(i)));
((AbstractEAIndividual) population.get(i)).SetAge(0); ((AbstractEAIndividual) population.get(i)).setAge(0);
population.incrFunctionCalls(); population.incrFunctionCalls();
} }
} }
@ -588,7 +588,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
if (((AbstractEAIndividual) population.get(i)).getAge() >= maximumAge) { if (((AbstractEAIndividual) population.get(i)).getAge() >= maximumAge) {
this.optimizationProblem.evaluate(((AbstractEAIndividual) population.get(i))); this.optimizationProblem.evaluate(((AbstractEAIndividual) population.get(i)));
((AbstractEAIndividual) population.get(i)).SetAge(0); ((AbstractEAIndividual) population.get(i)).setAge(0);
population.incrFunctionCalls(); population.incrFunctionCalls();
} }
} }

View File

@ -96,7 +96,7 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interface
LOGGER.log(Level.WARNING, "Couldn't get problem dimension!"); LOGGER.log(Level.WARNING, "Couldn't get problem dimension!");
} }
probDim = (Integer) dim; probDim = (Integer) dim;
((InterfaceDataTypeBinary) this.template).SetBinaryGenotype(new BitSet(probDim)); ((InterfaceDataTypeBinary) this.template).setBinaryGenotype(new BitSet(probDim));
} }
this.population.addPopulationChangedEventListener(this); this.population.addPopulationChangedEventListener(this);
this.population.setNotifyEvalInterval(this.generationCycle); this.population.setNotifyEvalInterval(this.generationCycle);
@ -288,8 +288,8 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interface
if (!same) { if (!same) {
AbstractEAIndividual newIndy1 = (AbstractEAIndividual) this.template.clone(); AbstractEAIndividual newIndy1 = (AbstractEAIndividual) this.template.clone();
AbstractEAIndividual newIndy2 = (AbstractEAIndividual) this.template.clone(); AbstractEAIndividual newIndy2 = (AbstractEAIndividual) this.template.clone();
((InterfaceDataTypeBinary) newIndy1).SetBinaryGenotype(newGene1); ((InterfaceDataTypeBinary) newIndy1).setBinaryGenotype(newGene1);
((InterfaceDataTypeBinary) newIndy2).SetBinaryGenotype(newGene2); ((InterfaceDataTypeBinary) newIndy2).setBinaryGenotype(newGene2);
evaluate(newIndy1); evaluate(newIndy1);
evaluate(newIndy2); evaluate(newIndy2);
if (Math.min(newIndy1.getFitness(0), newIndy2.getFitness(0)) < Math.min(indy1.getFitness(0), indy2.getFitness(0))) { if (Math.min(newIndy1.getFitness(0), newIndy2.getFitness(0)) < Math.min(indy1.getFitness(0), indy2.getFitness(0))) {

View File

@ -96,7 +96,7 @@ public class MLTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
LOGGER.log(Level.WARNING, "Couldn't get problem dimension!"); LOGGER.log(Level.WARNING, "Couldn't get problem dimension!");
} }
probDim = (Integer) dim; probDim = (Integer) dim;
((InterfaceDataTypeBinary) this.template).SetBinaryGenotype(new BitSet(probDim)); ((InterfaceDataTypeBinary) this.template).setBinaryGenotype(new BitSet(probDim));
} }
this.population.addPopulationChangedEventListener(this); this.population.addPopulationChangedEventListener(this);
this.population.setNotifyEvalInterval(this.generationCycle); this.population.setNotifyEvalInterval(this.generationCycle);
@ -274,7 +274,7 @@ public class MLTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
newGene.flip(flipID); newGene.flip(flipID);
} }
AbstractEAIndividual newIndy = (AbstractEAIndividual) this.template.clone(); AbstractEAIndividual newIndy = (AbstractEAIndividual) this.template.clone();
((InterfaceDataTypeBinary) newIndy).SetBinaryGenotype(newGene); ((InterfaceDataTypeBinary) newIndy).setBinaryGenotype(newGene);
evaluate(newIndy); evaluate(newIndy);
if (newIndy.getFitness(0) < indy.getFitness(0)) { if (newIndy.getFitness(0) < indy.getFitness(0)) {
indy = newIndy; indy = newIndy;

View File

@ -415,7 +415,7 @@ public class PDDifferentialEvolution implements InterfaceOptimizer, java.io.Seri
Mathematics.projectToRange(nX, esIndy.getDoubleRange()); Mathematics.projectToRange(nX, esIndy.getDoubleRange());
} // why did this never happen before? } // why did this never happen before?
esIndy.setDoubleGenotype(nX); esIndy.setDoubleGenotype(nX);
indy.SetAge(0); indy.setAge(0);
indy.resetConstraintViolation(); indy.resetConstraintViolation();
double[] fit = new double[1]; double[] fit = new double[1];
fit[0] = 0; fit[0] = 0;
@ -519,7 +519,7 @@ public class PDDifferentialEvolution implements InterfaceOptimizer, java.io.Seri
if (((AbstractEAIndividual) m_Population.get(i)).getAge() >= maximumAge) { if (((AbstractEAIndividual) m_Population.get(i)).getAge() >= maximumAge) {
this.m_Problem.evaluate(((AbstractEAIndividual) m_Population.get(i))); this.m_Problem.evaluate(((AbstractEAIndividual) m_Population.get(i)));
((AbstractEAIndividual) m_Population.get(i)).SetAge(0); ((AbstractEAIndividual) m_Population.get(i)).setAge(0);
m_Population.incrFunctionCalls(); m_Population.incrFunctionCalls();
} }
} }
@ -576,7 +576,7 @@ public class PDDifferentialEvolution implements InterfaceOptimizer, java.io.Seri
if (((AbstractEAIndividual) m_Population.get(i)).getAge() >= maximumAge) { if (((AbstractEAIndividual) m_Population.get(i)).getAge() >= maximumAge) {
this.m_Problem.evaluate(((AbstractEAIndividual) m_Population.get(i))); this.m_Problem.evaluate(((AbstractEAIndividual) m_Population.get(i)));
((AbstractEAIndividual) m_Population.get(i)).SetAge(0); ((AbstractEAIndividual) m_Population.get(i)).setAge(0);
m_Population.incrFunctionCalls(); m_Population.incrFunctionCalls();
} }
} }

View File

@ -501,7 +501,7 @@ public class ParticleSubSwarmOptimization extends ParticleSwarmOptimizationGCPSO
if (particleIndices != null) { // use given indices if (particleIndices != null) { // use given indices
for (int i = 0; i < tmpopt.getPopulation().size(); ++i) { for (int i = 0; i < tmpopt.getPopulation().size(); ++i) {
AbstractEAIndividual indy = tmpopt.getPopulation().getEAIndividual(i); AbstractEAIndividual indy = tmpopt.getPopulation().getEAIndividual(i);
indy.SetIndividualIndex(particleIndices[i]);//SetData("particleIndex", new Integer(particleIndices[i])); indy.setIndividualIndex(particleIndices[i]);//SetData("particleIndex", new Integer(particleIndices[i]));
indy.putData("newParticleFlag", new Boolean(true)); // for plotting indy.putData("newParticleFlag", new Boolean(true)); // for plotting
} }
} }

View File

@ -517,7 +517,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
} }
} }
indy.putData(indexKey, i); indy.putData(indexKey, i);
indy.SetIndividualIndex(i); indy.setIndividualIndex(i);
} }
} }
@ -1773,7 +1773,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
initIndividualDefaults(indy, m_InitialVelocity); initIndividualDefaults(indy, m_InitialVelocity);
initIndividualMemory(indy); initIndividualMemory(indy);
indy.putData(indexKey, i); indy.putData(indexKey, i);
indy.SetIndividualIndex(i); indy.setIndividualIndex(i);
if (TRACE) { if (TRACE) {
System.err.println("init indy " + i + " " + AbstractEAIndividual.getDefaultDataString(indy)); System.err.println("init indy " + i + " " + AbstractEAIndividual.getDefaultDataString(indy));
} }

View File

@ -1110,11 +1110,11 @@ public class BayNet {
// data5.set(0, true); // data5.set(0, true);
// data5.set(1, true); // data5.set(1, true);
// data5.set(2, true); // data5.set(2, true);
// indy1.SetBinaryGenotype(data1); // indy1.setBinaryGenotype(data1);
// indy2.SetBinaryGenotype(data2); // indy2.setBinaryGenotype(data2);
// indy3.SetBinaryGenotype(data3); // indy3.setBinaryGenotype(data3);
// indy4.SetBinaryGenotype(data4); // indy4.setBinaryGenotype(data4);
// indy5.SetBinaryGenotype(data5); // indy5.setBinaryGenotype(data5);
// pop.add(indy1); // pop.add(indy1);
// pop.add(indy2); // pop.add(indy2);
// pop.add(indy3); // pop.add(indy3);