More refactoring on public methods
This commit is contained in:
parent
bbaead0515
commit
288bdbdd36
@ -1,14 +1,19 @@
|
||||
package eva2.cli;
|
||||
|
||||
import eva2.optimization.strategies.DifferentialEvolution;
|
||||
import eva2.optimization.strategies.InterfaceOptimizer;
|
||||
import eva2.util.annotation.Parameter;
|
||||
import org.apache.commons.cli.*;
|
||||
import eva2.optimization.OptimizationStateListener;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Main implements OptimizationStateListener {
|
||||
|
||||
|
||||
|
||||
private Options createCommandLineOptions() {
|
||||
Options opt = new Options();
|
||||
OptionGroup optGroup = new OptionGroup();
|
||||
@ -54,6 +59,13 @@ public class Main implements OptimizationStateListener {
|
||||
|
||||
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();
|
||||
|
||||
for(Field field : de.getClass().getDeclaredFields()) {
|
||||
|
@ -72,7 +72,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
return individualIndex;
|
||||
}
|
||||
|
||||
public void SetIndividualIndex(int index) {
|
||||
public void setIndividualIndex(int index) {
|
||||
this.individualIndex = index;
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
*
|
||||
* @param age The new age.
|
||||
*/
|
||||
public void SetAge(int age) {
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@ -543,11 +543,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
* @return True if constraints are violated
|
||||
*/
|
||||
public boolean violatesConstraint() {
|
||||
if (this.constraintViolation > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.constraintViolation > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -560,7 +556,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
return this.isMarked;
|
||||
}
|
||||
|
||||
public void SetMarked(boolean t) {
|
||||
public void setMarked(boolean t) {
|
||||
this.isMarked = t;
|
||||
}
|
||||
|
||||
@ -590,7 +586,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void SetMarkPenalized(boolean p) {
|
||||
public void setMarkPenalized(boolean p) {
|
||||
isPenalized = p;
|
||||
}
|
||||
|
||||
@ -695,11 +691,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
return true;
|
||||
}
|
||||
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) {
|
||||
if (Double.isNaN(a) || Double.isInfinite(a)) {
|
||||
return false;
|
||||
} else {
|
||||
return (a >= b);
|
||||
}
|
||||
return !(Double.isNaN(a) || Double.isInfinite(a)) && (a >= b);
|
||||
}
|
||||
|
||||
private static boolean firstIsFiniteAndLargerNonEqual(double a, double b) {
|
||||
if (Double.isNaN(a) || Double.isInfinite(a)) {
|
||||
return false;
|
||||
} else {
|
||||
return (a > b);
|
||||
}
|
||||
return !(Double.isNaN(a) || Double.isInfinite(a)) && (a > b);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -805,11 +788,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
} else {
|
||||
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
|
||||
*/
|
||||
public void SetSelectionProbability(double[] sel) {
|
||||
public void setSelectionProbability(double[] 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 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) {
|
||||
this.selectionProbability[index] = sel;
|
||||
} else {
|
||||
@ -1020,22 +998,13 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
* @return Object The associated object or null if none is found
|
||||
*/
|
||||
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);
|
||||
if (data == null) { // Fitness is actually in use... so lets have a minor special treatment
|
||||
// try {
|
||||
if (name.compareToIgnoreCase("Fitness") == 0) {
|
||||
data = getFitness();
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
@ -1273,7 +1242,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
||||
for (int i = 0; i < intData.length; i++) {
|
||||
intData[i] = (int) pos[i];
|
||||
}
|
||||
((InterfaceDataTypeInteger) indy).SetIntGenotype(intData);
|
||||
((InterfaceDataTypeInteger) indy).setIntGenotype(intData);
|
||||
return true;
|
||||
} // TODO check some more types here?
|
||||
EVAERROR.errorMsgOnce("Unhandled case in AbstractEAIndividual.setDoublePosition()!");
|
||||
|
@ -179,7 +179,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
@Override
|
||||
public void SetBinaryPhenotype(BitSet binaryData) {
|
||||
public void setBinaryPhenotype(BitSet binaryData) {
|
||||
this.m_Phenotype = binaryData;
|
||||
}
|
||||
|
||||
@ -190,8 +190,8 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
@Override
|
||||
public void SetBinaryGenotype(BitSet binaryData) {
|
||||
this.SetBinaryPhenotype(binaryData);
|
||||
public void setBinaryGenotype(BitSet binaryData) {
|
||||
this.setBinaryPhenotype(binaryData);
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_UseHardSwitch) {
|
||||
if (binaryData.get(i)) {
|
||||
@ -223,7 +223,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof BitSet) {
|
||||
BitSet bs = (BitSet) obj;
|
||||
this.SetBinaryGenotype(bs);
|
||||
this.setBinaryGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
System.out.println("Initial value for ESIndividualBinaryData is no BitSet!");
|
||||
|
@ -17,32 +17,32 @@ import eva2.tools.math.RNG;
|
||||
*/
|
||||
public class ESIndividualIntegerData extends AbstractEAIndividual implements InterfaceESIndividual, InterfaceDataTypeInteger, java.io.Serializable {
|
||||
|
||||
private double[] m_Genotype;
|
||||
private int[] m_Phenotype;
|
||||
private int[][] m_Range;
|
||||
private double[] genotype;
|
||||
private int[] phenotype;
|
||||
private int[][] range;
|
||||
|
||||
public ESIndividualIntegerData() {
|
||||
this.mutationProbability = 1.0;
|
||||
this.mutationOperator = new MutateESGlobal();
|
||||
this.crossoverProbability = 0.5;
|
||||
this.crossoverOperator = new CrossoverESDefault();
|
||||
this.m_Genotype = new double[1];
|
||||
this.m_Range = new int[1][2];
|
||||
this.m_Range[0][0] = -10;
|
||||
this.m_Range[0][1] = 10;
|
||||
this.genotype = new double[1];
|
||||
this.range = new int[1][2];
|
||||
this.range[0][0] = -10;
|
||||
this.range[0][1] = 10;
|
||||
}
|
||||
|
||||
public ESIndividualIntegerData(ESIndividualIntegerData individual) {
|
||||
if (individual.m_Phenotype != null) {
|
||||
this.m_Phenotype = new int[individual.m_Phenotype.length];
|
||||
System.arraycopy(individual.m_Phenotype, 0, this.m_Phenotype, 0, this.m_Phenotype.length);
|
||||
if (individual.phenotype != null) {
|
||||
this.phenotype = new int[individual.phenotype.length];
|
||||
System.arraycopy(individual.phenotype, 0, this.phenotype, 0, this.phenotype.length);
|
||||
}
|
||||
this.m_Genotype = new double[individual.m_Genotype.length];
|
||||
this.m_Range = new int[individual.m_Genotype.length][2];
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
this.m_Genotype[i] = individual.m_Genotype[i];
|
||||
this.m_Range[i][0] = individual.m_Range[i][0];
|
||||
this.m_Range[i][1] = individual.m_Range[i][1];
|
||||
this.genotype = new double[individual.genotype.length];
|
||||
this.range = new int[individual.genotype.length][2];
|
||||
for (int i = 0; i < this.genotype.length; i++) {
|
||||
this.genotype[i] = individual.genotype[i];
|
||||
this.range[i][0] = individual.range[i][0];
|
||||
this.range[i][1] = individual.range[i][1];
|
||||
}
|
||||
|
||||
// cloning the members of AbstractEAIndividual
|
||||
@ -77,20 +77,20 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof ESIndividualIntegerData) {
|
||||
ESIndividualIntegerData indy = (ESIndividualIntegerData) individual;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
if ((this.genotype == null) || (indy.genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_Range == null) || (indy.m_Range == null)) {
|
||||
if ((this.range == null) || (indy.range == null)) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
if (this.m_Genotype[i] != indy.m_Genotype[i]) {
|
||||
for (int i = 0; i < this.range.length; i++) {
|
||||
if (this.genotype[i] != indy.genotype[i]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) {
|
||||
if (this.range[i][0] != indy.range[i][0]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) {
|
||||
if (this.range[i][1] != indy.range[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -114,20 +114,20 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
int[][] newRange = new int[length][2];
|
||||
|
||||
// copy the old values for the decision parameters and the range
|
||||
for (int i = 0; ((i < newDesPa.length) && (i < this.m_Genotype.length)); i++) {
|
||||
newDesPa[i] = this.m_Genotype[i];
|
||||
newRange[i][0] = this.m_Range[i][0];
|
||||
newRange[i][1] = this.m_Range[i][1];
|
||||
for (int i = 0; ((i < newDesPa.length) && (i < this.genotype.length)); i++) {
|
||||
newDesPa[i] = this.genotype[i];
|
||||
newRange[i][0] = this.range[i][0];
|
||||
newRange[i][1] = this.range[i][1];
|
||||
}
|
||||
|
||||
// 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++) {
|
||||
newDesPa[i] = this.m_Genotype[this.m_Genotype.length - 1];
|
||||
newRange[i][0] = this.m_Range[this.m_Genotype.length - 1][0];
|
||||
newRange[i][1] = this.m_Range[this.m_Genotype.length - 1][1];
|
||||
for (int i = this.genotype.length; (i < newDesPa.length); i++) {
|
||||
newDesPa[i] = this.genotype[this.genotype.length - 1];
|
||||
newRange[i][0] = this.range[this.genotype.length - 1][0];
|
||||
newRange[i][1] = this.range[this.genotype.length - 1][1];
|
||||
}
|
||||
this.m_Genotype = newDesPa;
|
||||
this.m_Range = newRange;
|
||||
this.genotype = newDesPa;
|
||||
this.range = newRange;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +137,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntRange(int[][] range) {
|
||||
if (range.length != this.m_Range.length) {
|
||||
public void setIntRange(int[][] range) {
|
||||
if (range.length != this.range.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++) {
|
||||
this.m_Range[i][0] = range[i][0];
|
||||
this.m_Range[i][1] = range[i][1];
|
||||
for (int i = 0; ((i < this.range.length) && (i < range.length)); i++) {
|
||||
this.range[i][0] = range[i][0];
|
||||
this.range[i][1] = range[i][1];
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
public int[][] getIntRange() {
|
||||
return this.m_Range;
|
||||
return this.range;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,17 +176,17 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
public int[] getIntegerData() {
|
||||
this.m_Phenotype = new int[this.m_Genotype.length];
|
||||
for (int i = 0; i < this.m_Phenotype.length; i++) {
|
||||
this.m_Phenotype[i] = (int) this.m_Genotype[i];
|
||||
if (this.m_Phenotype[i] < this.m_Range[i][0]) {
|
||||
this.m_Phenotype[i] = this.m_Range[i][0];
|
||||
this.phenotype = new int[this.genotype.length];
|
||||
for (int i = 0; i < this.phenotype.length; i++) {
|
||||
this.phenotype[i] = (int) this.genotype[i];
|
||||
if (this.phenotype[i] < this.range[i][0]) {
|
||||
this.phenotype[i] = this.range[i][0];
|
||||
}
|
||||
if (this.m_Phenotype[i] > this.m_Range[i][1]) {
|
||||
this.m_Phenotype[i] = this.m_Range[i][1];
|
||||
if (this.phenotype[i] > this.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
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntPhenotype(int[] intData) {
|
||||
this.m_Phenotype = intData;
|
||||
public void setIntPhenotype(int[] intData) {
|
||||
this.phenotype = intData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,9 +217,9 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* @param intData The new int data.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntGenotype(int[] intData) {
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
m_Genotype[i] = (double) intData[i];
|
||||
public void setIntGenotype(int[] intData) {
|
||||
for (int i = 0; i < this.genotype.length; i++) {
|
||||
genotype[i] = (double) intData[i];
|
||||
}
|
||||
getIntegerData();
|
||||
}
|
||||
@ -239,10 +239,10 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof int[]) {
|
||||
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!");
|
||||
}
|
||||
this.SetIntGenotype(bs);
|
||||
this.setIntGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
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 += "[";
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
result += this.m_Genotype[i] + "; ";
|
||||
for (int i = 0; i < this.genotype.length; i++) {
|
||||
result += this.genotype[i] + "; ";
|
||||
}
|
||||
result += "]";
|
||||
return result;
|
||||
@ -288,7 +288,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
public double[] getDGenotype() {
|
||||
return this.m_Genotype;
|
||||
return this.genotype;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,13 +298,13 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
public void setDGenotype(double[] b) {
|
||||
this.m_Genotype = b;
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_Genotype[i] < this.m_Range[i][0]) {
|
||||
this.m_Genotype[i] = this.m_Range[i][0];
|
||||
this.genotype = b;
|
||||
for (int i = 0; i < this.genotype.length; i++) {
|
||||
if (this.genotype[i] < this.range[i][0]) {
|
||||
this.genotype[i] = this.range[i][0];
|
||||
}
|
||||
if (this.m_Genotype[i] > this.m_Range[i][1]) {
|
||||
this.m_Genotype[i] = this.m_Range[i][1];
|
||||
if (this.genotype[i] > this.range[i][1]) {
|
||||
this.genotype[i] = this.range[i][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -314,13 +314,13 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
public void defaultMutate() {
|
||||
int mutationIndex = RNG.randomInt(0, this.m_Genotype.length - 1);
|
||||
this.m_Genotype[mutationIndex] += ((this.m_Range[mutationIndex][1] - this.m_Range[mutationIndex][0]) / 2) * RNG.gaussianDouble(0.05f);
|
||||
if (this.m_Genotype[mutationIndex] < this.m_Range[mutationIndex][0]) {
|
||||
this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][0];
|
||||
int mutationIndex = RNG.randomInt(0, this.genotype.length - 1);
|
||||
this.genotype[mutationIndex] += ((this.range[mutationIndex][1] - this.range[mutationIndex][0]) / 2) * RNG.gaussianDouble(0.05f);
|
||||
if (this.genotype[mutationIndex] < this.range[mutationIndex][0]) {
|
||||
this.genotype[mutationIndex] = this.range[mutationIndex][0];
|
||||
}
|
||||
if (this.m_Genotype[mutationIndex] > this.m_Range[mutationIndex][1]) {
|
||||
this.m_Genotype[mutationIndex] = this.m_Range[mutationIndex][1];
|
||||
if (this.genotype[mutationIndex] > this.range[mutationIndex][1]) {
|
||||
this.genotype[mutationIndex] = this.range[mutationIndex][1];
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,22 +331,22 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
public double[][] getDoubleRange() {
|
||||
double[][] result = new double[this.m_Range.length][2];
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
result[i][0] = this.m_Range[i][0];
|
||||
result[i][1] = this.m_Range[i][1];
|
||||
double[][] result = new double[this.range.length][2];
|
||||
for (int i = 0; i < this.range.length; i++) {
|
||||
result[i][0] = this.range[i][0];
|
||||
result[i][1] = this.range[i][1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
int[][] range = m_Range;
|
||||
int[][] range = this.range;
|
||||
if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange) prob).getInitRange() != null)) {
|
||||
range = (int[][]) ((InterfaceHasInitRange) prob).getInitRange();
|
||||
}
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
this.m_Genotype[i] = RNG.randomInt(range[i][0], range[i][1]);
|
||||
for (int i = 0; i < this.genotype.length; i++) {
|
||||
this.genotype[i] = RNG.randomInt(range[i][0], range[i][1]);
|
||||
}
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
|
@ -49,7 +49,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
this.m_Genotype = 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++) {
|
||||
// if (individual.m_Phenotype != null) {
|
||||
// if (individual.phenotype != null) {
|
||||
|
||||
this.m_Genotype[i] = new double[individual.m_Genotype[i].length];
|
||||
this.m_Range[i] = new double[individual.m_Genotype[i].length][2];
|
||||
@ -154,7 +154,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetPermutationPhenotype(int[][] perm) {
|
||||
public void setPermutationPhenotype(int[][] perm) {
|
||||
this.m_Phenotype = perm;
|
||||
this.m_Range = new double[perm.length][][];
|
||||
for (int i = 0; i < perm.length; i++) {
|
||||
@ -168,8 +168,8 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetPermutationGenotype(int[][] perm) {
|
||||
this.SetPermutationPhenotype(perm);
|
||||
public void setPermutationGenotype(int[][] perm) {
|
||||
this.setPermutationPhenotype(perm);
|
||||
|
||||
this.m_Genotype = 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) {
|
||||
System.out.println("Init value and requested length doesn't match!");
|
||||
}
|
||||
this.SetPermutationGenotype(bs);
|
||||
this.setPermutationGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
System.out.println("Initial value for ESIndividualPermutationData is not int[]!");
|
||||
|
@ -355,8 +355,8 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
* @see InterfaceDataTypeBinary.SetBinaryData()
|
||||
*/
|
||||
@Override
|
||||
public void SetBinaryPhenotype(BitSet binaryData) {
|
||||
this.m_BitSet.SetBinaryPhenotype(binaryData);
|
||||
public void setBinaryPhenotype(BitSet binaryData) {
|
||||
this.m_BitSet.setBinaryPhenotype(binaryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,11 +364,11 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
|
||||
* memetic algorithms.
|
||||
*
|
||||
* @param binaryData The new binary data.
|
||||
* @see InterfaceBinaryData.SetBinaryDataLamarckian()
|
||||
* @see InterfaceBinaryData.setBinaryDataLamarckian()
|
||||
*/
|
||||
@Override
|
||||
public void SetBinaryGenotype(BitSet binaryData) {
|
||||
this.m_BitSet.SetBinaryGenotype(binaryData);
|
||||
public void setBinaryGenotype(BitSet binaryData) {
|
||||
this.m_BitSet.setBinaryGenotype(binaryData);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
|
@ -124,7 +124,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof BitSet) {
|
||||
BitSet bs = (BitSet) obj;
|
||||
this.SetBinaryGenotype(bs);
|
||||
this.setBinaryGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void SetBGenotype(BitSet binaryData) {
|
||||
public void setBGenotype(BitSet binaryData) {
|
||||
this.m_Genotype = binaryData;
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
@Override
|
||||
public void SetBinaryPhenotype(BitSet binaryData) {
|
||||
public void setBinaryPhenotype(BitSet binaryData) {
|
||||
this.m_Phenotype = binaryData;
|
||||
}
|
||||
|
||||
@ -301,8 +301,8 @@ public class GAIndividualBinaryData extends AbstractEAIndividual implements Inte
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
@Override
|
||||
public void SetBinaryGenotype(BitSet binaryData) {
|
||||
this.SetBinaryPhenotype(binaryData);
|
||||
public void setBinaryGenotype(BitSet binaryData) {
|
||||
this.setBinaryPhenotype(binaryData);
|
||||
this.m_Genotype = (BitSet) binaryData.clone();
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
|
||||
private double[] m_Phenotype;
|
||||
private double[][] m_Range;
|
||||
protected BitSet m_Genotype;
|
||||
protected int m_GenotypeLength;
|
||||
protected BitSet genotype;
|
||||
protected int genotypeLength;
|
||||
private int m_Precision = 32;
|
||||
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[0][0] = -10;
|
||||
this.m_Range[0][1] = 10;
|
||||
this.m_GenotypeLength = this.m_Precision;
|
||||
this.m_Genotype = new BitSet();
|
||||
this.genotypeLength = this.m_Precision;
|
||||
this.genotype = new BitSet();
|
||||
}
|
||||
|
||||
public GAIndividualDoubleData(GAIndividualDoubleData individual) {
|
||||
@ -47,8 +47,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
this.m_Phenotype = new double[individual.m_Phenotype.length];
|
||||
System.arraycopy(individual.m_Phenotype, 0, this.m_Phenotype, 0, this.m_Phenotype.length);
|
||||
}
|
||||
this.m_GenotypeLength = individual.m_GenotypeLength;
|
||||
this.m_Genotype = (BitSet) individual.m_Genotype.clone();
|
||||
this.genotypeLength = individual.genotypeLength;
|
||||
this.genotype = (BitSet) individual.genotype.clone();
|
||||
this.m_Range = new double[individual.m_Range.length][2];
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
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) {
|
||||
GAIndividualDoubleData indy = (GAIndividualDoubleData) individual;
|
||||
//@todo Eigendlich k<EFBFBD>nnte ich noch das Koding vergleichen
|
||||
if (this.m_GenotypeLength != indy.m_GenotypeLength) {
|
||||
if (this.genotypeLength != indy.genotypeLength) {
|
||||
return false;
|
||||
}
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
if ((this.genotype == null) || (indy.genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) {
|
||||
if (!this.genotype.equals(indy.genotype)) {
|
||||
return false;
|
||||
}
|
||||
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];
|
||||
}
|
||||
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
|
||||
// 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++) {
|
||||
locus[0] = i * 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;
|
||||
}
|
||||
@ -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,
|
||||
* use SetDoubleDataLamarckian.
|
||||
* use setDoubleDataLamarckian.
|
||||
*
|
||||
* @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++) {
|
||||
locus[0] = i * 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 += "{";
|
||||
for (int i = 0; i < this.m_GenotypeLength; i++) {
|
||||
if (this.m_Genotype.get(i)) {
|
||||
for (int i = 0; i < this.genotypeLength; i++) {
|
||||
if (this.genotype.get(i)) {
|
||||
result += "1";
|
||||
} else {
|
||||
result += "0";
|
||||
@ -319,7 +319,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void SetBGenotype(BitSet binaryData) {
|
||||
this.m_Genotype = binaryData;
|
||||
public void setBGenotype(BitSet binaryData) {
|
||||
this.genotype = binaryData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -342,16 +342,16 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
*/
|
||||
@Override
|
||||
public int getGenotypeLength() {
|
||||
return this.m_GenotypeLength;
|
||||
return this.genotypeLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
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)) {
|
||||
this.m_Genotype.set(i);
|
||||
this.genotype.set(i);
|
||||
} else {
|
||||
this.m_Genotype.clear(i);
|
||||
this.genotype.clear(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -361,11 +361,11 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
|
||||
*/
|
||||
@Override
|
||||
public void defaultMutate() {
|
||||
int mutationIndex = RNG.randomInt(0, this.m_GenotypeLength);
|
||||
if (this.m_Genotype.get(mutationIndex)) {
|
||||
this.m_Genotype.clear(mutationIndex);
|
||||
int mutationIndex = RNG.randomInt(0, this.genotypeLength);
|
||||
if (this.genotype.get(mutationIndex)) {
|
||||
this.genotype.clear(mutationIndex);
|
||||
} else {
|
||||
this.m_Genotype.set(mutationIndex);
|
||||
this.genotype.set(mutationIndex);
|
||||
}
|
||||
}
|
||||
/**********************************************************************************************************************
|
||||
|
@ -22,37 +22,37 @@ import java.util.BitSet;
|
||||
*/
|
||||
public class GAIndividualIntegerData extends AbstractEAIndividual implements InterfaceGAIndividual, InterfaceDataTypeInteger, java.io.Serializable {
|
||||
|
||||
private int[] m_Phenotype;
|
||||
private int[][] m_Range;
|
||||
protected BitSet m_Genotype;
|
||||
protected int[] m_CodingLenghts;
|
||||
private InterfaceGAIntegerCoding m_IntegerCoding = new GAStandardCodingInteger();
|
||||
private int[] phenotype;
|
||||
private int[][] range;
|
||||
protected BitSet genotype;
|
||||
protected int[] codingLengths;
|
||||
private InterfaceGAIntegerCoding intergerCoding = new GAStandardCodingInteger();
|
||||
|
||||
public GAIndividualIntegerData() {
|
||||
this.mutationProbability = 0.2;
|
||||
this.mutationOperator = new MutateGANBit();
|
||||
this.crossoverProbability = 0.7;
|
||||
this.crossoverOperator = new CrossoverGAGINPoint();
|
||||
this.m_Range = new int[1][2];
|
||||
this.m_CodingLenghts = new int[1];
|
||||
this.m_CodingLenghts[0] = 3;
|
||||
this.m_Range[0][0] = 0;
|
||||
this.m_Range[0][1] = 7;
|
||||
this.m_Genotype = new BitSet();
|
||||
this.range = new int[1][2];
|
||||
this.codingLengths = new int[1];
|
||||
this.codingLengths[0] = 3;
|
||||
this.range[0][0] = 0;
|
||||
this.range[0][1] = 7;
|
||||
this.genotype = new BitSet();
|
||||
}
|
||||
|
||||
public GAIndividualIntegerData(GAIndividualIntegerData individual) {
|
||||
if (individual.m_Phenotype != null) {
|
||||
this.m_Phenotype = new int[individual.m_Phenotype.length];
|
||||
System.arraycopy(individual.m_Phenotype, 0, this.m_Phenotype, 0, this.m_Phenotype.length);
|
||||
if (individual.phenotype != null) {
|
||||
this.phenotype = new int[individual.phenotype.length];
|
||||
System.arraycopy(individual.phenotype, 0, this.phenotype, 0, this.phenotype.length);
|
||||
}
|
||||
this.m_Genotype = (BitSet) individual.m_Genotype.clone();
|
||||
this.m_Range = new int[individual.m_Range.length][2];
|
||||
this.m_CodingLenghts = new int[individual.m_CodingLenghts.length];
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
this.m_CodingLenghts[i] = individual.m_CodingLenghts[i];
|
||||
this.m_Range[i][0] = individual.m_Range[i][0];
|
||||
this.m_Range[i][1] = individual.m_Range[i][1];
|
||||
this.genotype = (BitSet) individual.genotype.clone();
|
||||
this.range = new int[individual.range.length][2];
|
||||
this.codingLengths = new int[individual.codingLengths.length];
|
||||
for (int i = 0; i < this.range.length; i++) {
|
||||
this.codingLengths[i] = individual.codingLengths[i];
|
||||
this.range[i][0] = individual.range[i][0];
|
||||
this.range[i][1] = individual.range[i][1];
|
||||
}
|
||||
|
||||
// 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++) {
|
||||
this.selectionProbability[i] = individual.selectionProbability[i];
|
||||
}
|
||||
this.m_IntegerCoding = individual.m_IntegerCoding;
|
||||
this.intergerCoding = individual.intergerCoding;
|
||||
this.fitness = new double[individual.fitness.length];
|
||||
for (int i = 0; i < this.fitness.length; i++) {
|
||||
this.fitness[i] = individual.fitness[i];
|
||||
@ -90,20 +90,20 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
if (individual instanceof GAIndividualIntegerData) {
|
||||
GAIndividualIntegerData indy = (GAIndividualIntegerData) individual;
|
||||
//@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;
|
||||
}
|
||||
if (!this.m_Genotype.equals(indy.m_Genotype)) {
|
||||
if (!this.genotype.equals(indy.genotype)) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range.length != indy.m_Range.length) {
|
||||
if (this.range.length != indy.range.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
if (this.m_Range[i][0] != indy.m_Range[i][0]) {
|
||||
for (int i = 0; i < this.range.length; i++) {
|
||||
if (this.range[i][0] != indy.range[i][0]) {
|
||||
return false;
|
||||
}
|
||||
if (this.m_Range[i][1] != indy.m_Range[i][1]) {
|
||||
if (this.range[i][1] != indy.range[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -127,20 +127,20 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
int[][] newRange = new int[length][2];
|
||||
|
||||
// copy the old values for the decision parameters and the range
|
||||
for (int i = 0; ((i < newDesPa.length) && (i < this.m_Range.length)); i++) {
|
||||
newRange[i][0] = this.m_Range[i][0];
|
||||
newRange[i][1] = this.m_Range[i][1];
|
||||
for (int i = 0; ((i < newDesPa.length) && (i < this.range.length)); i++) {
|
||||
newRange[i][0] = this.range[i][0];
|
||||
newRange[i][1] = this.range[i][1];
|
||||
}
|
||||
|
||||
// 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++) {
|
||||
newRange[i][0] = this.m_Range[this.m_Range.length - 1][0];
|
||||
newRange[i][1] = this.m_Range[this.m_Range.length - 1][1];
|
||||
for (int i = this.range.length; (i < newDesPa.length); i++) {
|
||||
newRange[i][0] = this.range[this.range.length - 1][0];
|
||||
newRange[i][1] = this.range[this.range.length - 1][1];
|
||||
}
|
||||
this.m_Range = newRange;
|
||||
this.m_CodingLenghts = new int[this.m_Range.length];
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
this.m_CodingLenghts[i] = this.m_IntegerCoding.calculateNecessaryBits(this.m_Range[i]);
|
||||
this.range = newRange;
|
||||
this.codingLengths = new int[this.range.length];
|
||||
for (int i = 0; i < this.range.length; i++) {
|
||||
this.codingLengths[i] = this.intergerCoding.calculateNecessaryBits(this.range[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntRange(int[][] range) {
|
||||
if (range.length != this.m_Range.length) {
|
||||
public void setIntRange(int[][] range) {
|
||||
if (range.length != this.range.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++) {
|
||||
this.m_Range[i][0] = range[i][0];
|
||||
this.m_Range[i][1] = range[i][1];
|
||||
for (int i = 0; ((i < this.range.length) && (i < range.length)); i++) {
|
||||
this.range[i][0] = range[i][0];
|
||||
this.range[i][1] = range[i][1];
|
||||
}
|
||||
this.setIntegerDataLength(range.length);
|
||||
}
|
||||
@ -181,9 +181,9 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* @param upper
|
||||
*/
|
||||
public void SetIntRange(int lower, int upper) {
|
||||
for (int i = 0; i < m_Range.length; i++) {
|
||||
SetIntRange(i, lower, upper);
|
||||
m_CodingLenghts[i] = m_IntegerCoding.calculateNecessaryBits(m_Range[i]);
|
||||
for (int i = 0; i < range.length; i++) {
|
||||
setIntRange(i, lower, upper);
|
||||
codingLengths[i] = intergerCoding.calculateNecessaryBits(range[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,10 +194,10 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* @param lower
|
||||
* @param upper
|
||||
*/
|
||||
public void SetIntRange(int index, int lower, int upper) {
|
||||
m_Range[index][0] = lower;
|
||||
m_Range[index][1] = upper;
|
||||
m_CodingLenghts[index] = m_IntegerCoding.calculateNecessaryBits(m_Range[index]);
|
||||
public void setIntRange(int index, int lower, int upper) {
|
||||
range[index][0] = lower;
|
||||
range[index][1] = upper;
|
||||
codingLengths[index] = intergerCoding.calculateNecessaryBits(range[index]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,7 +207,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
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];
|
||||
locus[0] = 0;
|
||||
locus[1] = 0;
|
||||
this.m_Phenotype = new int[this.m_Range.length];
|
||||
for (int i = 0; i < this.m_Phenotype.length; i++) {
|
||||
this.phenotype = new int[this.range.length];
|
||||
for (int i = 0; i < this.phenotype.length; i++) {
|
||||
locus[0] += locus[1];
|
||||
locus[1] = this.m_CodingLenghts[i];
|
||||
this.m_Phenotype[i] = this.m_IntegerCoding.decodeValue(this.m_Genotype, this.m_Range[i], locus, false);
|
||||
locus[1] = this.codingLengths[i];
|
||||
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
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntPhenotype(int[] doubleData) {
|
||||
this.m_Phenotype = doubleData;
|
||||
public void setIntPhenotype(int[] doubleData) {
|
||||
this.phenotype = doubleData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,16 +257,16 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* @param doubleData The new double data.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntGenotype(int[] doubleData) {
|
||||
this.SetIntPhenotype(doubleData);
|
||||
public void setIntGenotype(int[] doubleData) {
|
||||
this.setIntPhenotype(doubleData);
|
||||
if (doubleData != null) {
|
||||
int[] locus = new int[2];
|
||||
locus[0] = 0;
|
||||
locus[1] = 0;
|
||||
for (int i = 0; i < doubleData.length; i++) {
|
||||
locus[0] += locus[1];
|
||||
locus[1] = this.m_CodingLenghts[i];
|
||||
this.m_IntegerCoding.codeValue(doubleData[i], this.m_Range[i], this.m_Genotype, locus);
|
||||
locus[1] = this.codingLengths[i];
|
||||
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) {
|
||||
if (obj instanceof int[]) {
|
||||
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!");
|
||||
}
|
||||
this.SetIntGenotype(bs);
|
||||
this.setIntGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
System.out.println("Initial value for GAIndividualDoubleData is not double[]!");
|
||||
@ -323,22 +323,22 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
}
|
||||
result += "]\n";
|
||||
result += "CodingRange: [";
|
||||
for (int i = 0; i < this.m_Range.length; i++) {
|
||||
result += "(" + this.m_Range[i][0] + "; " + this.m_Range[i][1] + "); ";
|
||||
for (int i = 0; i < this.range.length; i++) {
|
||||
result += "(" + this.range[i][0] + "; " + this.range[i][1] + "); ";
|
||||
}
|
||||
result += "]\n";
|
||||
result += "CodingLength: [";
|
||||
for (int i = 0; i < this.m_CodingLenghts.length; i++) {
|
||||
result += this.m_CodingLenghts[i] + "; ";
|
||||
for (int i = 0; i < this.codingLengths.length; i++) {
|
||||
result += this.codingLengths[i] + "; ";
|
||||
}
|
||||
result += "]\n";
|
||||
result += "{";
|
||||
int overallLength = 0;
|
||||
for (int i = 0; i < this.m_CodingLenghts.length; i++) {
|
||||
overallLength += this.m_CodingLenghts[i];
|
||||
for (int i = 0; i < this.codingLengths.length; i++) {
|
||||
overallLength += this.codingLengths[i];
|
||||
}
|
||||
for (int i = 0; i < overallLength; i++) {
|
||||
if (this.m_Genotype.get(i)) {
|
||||
if (this.genotype.get(i)) {
|
||||
result += "1";
|
||||
} else {
|
||||
result += "0";
|
||||
@ -359,7 +359,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public void SetBGenotype(BitSet binaryData) {
|
||||
this.m_Genotype = binaryData;
|
||||
public void setBGenotype(BitSet binaryData) {
|
||||
this.genotype = binaryData;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows the user to read the length of the genotype.
|
||||
* This may be necessary since BitSet.lenght only returns the index
|
||||
* of the last significat bit.
|
||||
* This may be necessary since BitSet.lentgh only returns the index
|
||||
* of the last significant bit.
|
||||
*
|
||||
* @return The length of the genotype.
|
||||
*/
|
||||
@Override
|
||||
public int getGenotypeLength() {
|
||||
int overallLength = 0;
|
||||
for (int i = 0; i < this.m_CodingLenghts.length; i++) {
|
||||
overallLength += this.m_CodingLenghts[i];
|
||||
for (int codingLength : this.codingLengths) {
|
||||
overallLength += codingLength;
|
||||
}
|
||||
return overallLength;
|
||||
}
|
||||
@ -392,14 +392,14 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
int overallLength = 0;
|
||||
for (int i = 0; i < this.m_CodingLenghts.length; i++) {
|
||||
overallLength += this.m_CodingLenghts[i];
|
||||
for (int codingLength : this.codingLengths) {
|
||||
overallLength += codingLength;
|
||||
}
|
||||
for (int i = 0; i < overallLength; i++) {
|
||||
if (RNG.flipCoin(0.5)) {
|
||||
this.m_Genotype.set(i);
|
||||
this.genotype.set(i);
|
||||
} else {
|
||||
this.m_Genotype.clear(i);
|
||||
this.genotype.clear(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -410,14 +410,14 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
@Override
|
||||
public void defaultMutate() {
|
||||
int overallLength = 0;
|
||||
for (int i = 0; i < this.m_CodingLenghts.length; i++) {
|
||||
overallLength += this.m_CodingLenghts[i];
|
||||
for (int codingLength : this.codingLengths) {
|
||||
overallLength += codingLength;
|
||||
}
|
||||
int mutationIndex = RNG.randomInt(0, overallLength);
|
||||
if (this.m_Genotype.get(mutationIndex)) {
|
||||
this.m_Genotype.clear(mutationIndex);
|
||||
if (this.genotype.get(mutationIndex)) {
|
||||
this.genotype.clear(mutationIndex);
|
||||
} 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;
|
||||
}
|
||||
indy.setIntegerDataLength(dimension);
|
||||
indy.SetIntRange(range);
|
||||
indy.setIntRange(range);
|
||||
indy.defaultInit(null);
|
||||
System.out.println("" + indy.getStringRepresentation());
|
||||
System.out.println("System.exit(0)");
|
||||
int[] data = indy.getIntegerData();
|
||||
String tmp = "Before {";
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
tmp += data[i] + "; ";
|
||||
for (int aData : data) {
|
||||
tmp += aData + "; ";
|
||||
}
|
||||
System.out.println(tmp + "}");
|
||||
tmp = "Setting {";
|
||||
@ -447,7 +447,7 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
tmp += data[i] + "; ";
|
||||
}
|
||||
System.out.println(tmp + "}");
|
||||
indy.SetIntGenotype(data);
|
||||
indy.setIntGenotype(data);
|
||||
System.out.println("" + indy.getStringRepresentation());
|
||||
data = indy.getIntegerData();
|
||||
tmp = "After {";
|
||||
@ -486,11 +486,11 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* @param coding The used genotype coding method
|
||||
*/
|
||||
public void setGACoding(InterfaceGAIntegerCoding coding) {
|
||||
this.m_IntegerCoding = coding;
|
||||
this.intergerCoding = coding;
|
||||
}
|
||||
|
||||
public InterfaceGAIntegerCoding getGACoding() {
|
||||
return this.m_IntegerCoding;
|
||||
return this.intergerCoding;
|
||||
}
|
||||
|
||||
public String gAIntegerCodingTipText() {
|
||||
|
@ -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
|
||||
* 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.
|
||||
* Note: You need to set the current ReadingIndx = 0 before starting to decode
|
||||
* the BitSet
|
||||
@ -653,7 +653,7 @@ public class GEIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
@Override
|
||||
public void SetBGenotype(BitSet binaryData) {
|
||||
public void setBGenotype(BitSet binaryData) {
|
||||
this.m_Genotype = binaryData;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
|
||||
public GIIndividualIntegerData(int[][] theRange) {
|
||||
this();
|
||||
SetIntRange(theRange);
|
||||
setIntRange(theRange);
|
||||
}
|
||||
|
||||
public GIIndividualIntegerData(GIIndividualIntegerData individual) {
|
||||
@ -159,7 +159,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* @param range The new range for the double data.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntRange(int[][] range) {
|
||||
public void setIntRange(int[][] range) {
|
||||
if (range.length != this.m_Range.length) {
|
||||
this.setIntegerDataLength(range.length);
|
||||
}
|
||||
@ -210,7 +210,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* @param doubleData The new double data.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntPhenotype(int[] doubleData) {
|
||||
public void setIntPhenotype(int[] doubleData) {
|
||||
this.m_Phenotype = doubleData;
|
||||
}
|
||||
|
||||
@ -221,8 +221,8 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
|
||||
* @param doubleData The new double data.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntGenotype(int[] doubleData) {
|
||||
this.SetIntPhenotype(doubleData);
|
||||
public void setIntGenotype(int[] doubleData) {
|
||||
this.setIntPhenotype(doubleData);
|
||||
this.m_Genotype = new int[this.m_Range.length];
|
||||
for (int i = 0; i < doubleData.length; 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) {
|
||||
System.out.println("Init value and requested length doesn't match!");
|
||||
}
|
||||
this.SetIntGenotype(bs);
|
||||
this.setIntGenotype(bs);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public void SetIGenotype(int[] b) {
|
||||
public void setIGenotype(int[] b) {
|
||||
this.m_Genotype = b;
|
||||
}
|
||||
|
||||
|
@ -242,8 +242,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
|
||||
* @param range The new range for the int data.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntRange(int[][] range) {
|
||||
this.m_Integer.SetIntRange(range);
|
||||
public void setIntRange(int[][] range) {
|
||||
this.m_Integer.setIntRange(range);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,8 +283,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
|
||||
* @param intData The new int data.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntPhenotype(int[] intData) {
|
||||
this.m_Integer.SetIntPhenotype(intData);
|
||||
public void setIntPhenotype(int[] intData) {
|
||||
this.m_Integer.setIntPhenotype(intData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,8 +294,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
|
||||
* @param intData The new int data.
|
||||
*/
|
||||
@Override
|
||||
public void SetIntGenotype(int[] intData) {
|
||||
this.m_Integer.SetIntGenotype(intData);
|
||||
public void setIntGenotype(int[] intData) {
|
||||
this.m_Integer.setIntGenotype(intData);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************
|
||||
@ -349,8 +349,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
|
||||
* @param perm The new permutation data.
|
||||
*/
|
||||
@Override
|
||||
public void SetPermutationPhenotype(int[][] perm) {
|
||||
this.SetPermutationPhenotype(perm);
|
||||
public void setPermutationPhenotype(int[][] perm) {
|
||||
this.setPermutationPhenotype(perm);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,8 +360,8 @@ public class GIOBGAIndividualIntegerPermutationData extends AbstractEAIndividual
|
||||
* @param perm The new permutation data.
|
||||
*/
|
||||
@Override
|
||||
public void SetPermutationGenotype(int[][] perm) {
|
||||
this.SetPermutationGenotype(perm);
|
||||
public void setPermutationGenotype(int[][] perm) {
|
||||
this.setPermutationGenotype(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -149,8 +149,8 @@ public class GPIndividualProgramData extends AbstractEAIndividual implements Int
|
||||
this.m_Phenotype = new AbstractGPNode[this.m_Genotype.length];
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
this.m_Phenotype[i] = (AbstractGPNode) this.m_Genotype[i].clone();
|
||||
// if (!m_Phenotype[0].checkDepth(0)) {
|
||||
// System.err.println("error... " + m_Genotype[0].checkDepth(0));
|
||||
// if (!phenotype[0].checkDepth(0)) {
|
||||
// System.err.println("error... " + genotype[0].checkDepth(0));
|
||||
// }
|
||||
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public void SetPGenotype(AbstractGPNode[] b) {
|
||||
public void setPGenotype(AbstractGPNode[] b) {
|
||||
this.m_Genotype = b;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public void SetPGenotype(AbstractGPNode b, int i) {
|
||||
public void setPGenotype(AbstractGPNode b, int i) {
|
||||
this.m_Genotype[i] = b;
|
||||
m_Genotype[i].updateDepth(0);
|
||||
// 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);
|
||||
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!");
|
||||
//}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public interface InterfaceDataTypeBinary {
|
||||
*
|
||||
* @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
|
||||
@ -56,5 +56,5 @@ public interface InterfaceDataTypeBinary {
|
||||
*
|
||||
* @param binaryData The new binary data.
|
||||
*/
|
||||
public void SetBinaryGenotype(BitSet binaryData);
|
||||
public void setBinaryGenotype(BitSet binaryData);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public interface InterfaceDataTypeInteger {
|
||||
*
|
||||
* @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.
|
||||
@ -62,7 +62,7 @@ public interface InterfaceDataTypeInteger {
|
||||
*
|
||||
* @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
|
||||
@ -70,5 +70,5 @@ public interface InterfaceDataTypeInteger {
|
||||
*
|
||||
* @param intData The new int data.
|
||||
*/
|
||||
public void SetIntGenotype(int[] intData);
|
||||
public void setIntGenotype(int[] intData);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public interface InterfaceDataTypePermutation {
|
||||
*
|
||||
* @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
|
||||
@ -63,7 +63,7 @@ public interface InterfaceDataTypePermutation {
|
||||
*
|
||||
* @param perm The new permutation data.
|
||||
*/
|
||||
void SetPermutationGenotype(int[][] perm);
|
||||
void setPermutationGenotype(int[][] perm);
|
||||
|
||||
public void setFirstindex(int[] firstindex);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public interface InterfaceGAIndividual {
|
||||
*
|
||||
* @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.
|
||||
|
@ -33,7 +33,7 @@ public interface InterfaceGIIndividual {
|
||||
*
|
||||
* @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
|
||||
@ -50,7 +50,7 @@ public interface InterfaceGIIndividual {
|
||||
*
|
||||
* @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.
|
||||
|
@ -25,7 +25,7 @@ public interface InterfaceGPIndividual {
|
||||
*
|
||||
* @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'.
|
||||
@ -33,7 +33,7 @@ public interface InterfaceGPIndividual {
|
||||
* @param b The new program genotype of the Individual
|
||||
* @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
|
||||
|
@ -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
|
||||
*/
|
||||
public void SetOBGenotype(int[][] b);
|
||||
public void setOBGenotype(int[][] b);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ import java.util.ArrayList;
|
||||
|
||||
public class OBGAIndividualPermutationData extends AbstractEAIndividual implements InterfaceDataTypePermutation, InterfaceOBGAIndividual, java.io.Serializable {
|
||||
|
||||
int[][] m_Phenotype;
|
||||
int[][] m_Genotype;
|
||||
int[][] phenotype;
|
||||
int[][] genotype;
|
||||
int[] firstindex;
|
||||
|
||||
public OBGAIndividualPermutationData() {
|
||||
@ -37,20 +37,20 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
|
||||
}
|
||||
|
||||
public OBGAIndividualPermutationData(OBGAIndividualPermutationData individual) {
|
||||
if (individual.m_Phenotype != null) {
|
||||
this.m_Phenotype = new int[individual.m_Phenotype.length][];
|
||||
for (int i = 0; i < m_Phenotype.length; i++) {
|
||||
this.m_Phenotype[i] = new int[individual.m_Phenotype[i].length];
|
||||
System.arraycopy(individual.m_Phenotype[i], 0, this.m_Phenotype[i], 0, this.m_Phenotype[i].length);
|
||||
if (individual.phenotype != null) {
|
||||
this.phenotype = new int[individual.phenotype.length][];
|
||||
for (int i = 0; i < phenotype.length; i++) {
|
||||
this.phenotype[i] = new int[individual.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][];
|
||||
for (int i = 0; i < m_Genotype.length; i++) {
|
||||
this.m_Genotype[i] = new int[individual.m_Genotype[i].length];
|
||||
System.arraycopy(individual.m_Genotype[i], 0, this.m_Genotype[i], 0, this.m_Genotype[i].length);
|
||||
this.genotype = new int[individual.genotype.length][];
|
||||
for (int i = 0; i < genotype.length; i++) {
|
||||
this.genotype[i] = new int[individual.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.age = individual.age;
|
||||
this.crossoverOperator = individual.crossoverOperator;
|
||||
@ -78,16 +78,16 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
|
||||
public boolean equalGenotypes(AbstractEAIndividual individual) {
|
||||
if (individual instanceof OBGAIndividualPermutationData) {
|
||||
OBGAIndividualPermutationData indy = (OBGAIndividualPermutationData) individual;
|
||||
if ((this.m_Genotype == null) || (indy.m_Genotype == null)) {
|
||||
if ((this.genotype == null) || (indy.genotype == null)) {
|
||||
return false;
|
||||
}
|
||||
if (m_Genotype.length != indy.m_Genotype.length) {
|
||||
if (genotype.length != indy.genotype.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
if (this.m_Genotype[i].length != indy.m_Genotype[i].length) {
|
||||
for (int j = 0; j < this.m_Genotype[i].length; j++) {
|
||||
if (this.m_Genotype[i][j] != indy.m_Genotype[i][j]) {
|
||||
for (int i = 0; i < this.genotype.length; i++) {
|
||||
if (this.genotype[i].length != indy.genotype[i].length) {
|
||||
for (int j = 0; j < this.genotype[i].length; j++) {
|
||||
if (this.genotype[i][j] != indy.genotype[i][j]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -114,7 +114,7 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
|
||||
@Override
|
||||
public void initByValue(Object obj, InterfaceOptimizationProblem opt) {
|
||||
if (obj instanceof int[]) {
|
||||
this.SetPermutationGenotype((int[][]) obj);
|
||||
this.setPermutationGenotype((int[][]) obj);
|
||||
} else {
|
||||
this.defaultInit(opt);
|
||||
System.out.println("Initial value for OBGAIndividualBinaryData is no Permutation!");
|
||||
@ -182,12 +182,12 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
|
||||
|
||||
@Override
|
||||
public int[][] getOBGenotype() {
|
||||
return this.m_Genotype;
|
||||
return this.genotype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetOBGenotype(int[][] g) {
|
||||
this.m_Genotype = g;
|
||||
public void setOBGenotype(int[][] g) {
|
||||
this.genotype = g;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -202,15 +202,15 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
|
||||
perm[p2] = temp;
|
||||
}
|
||||
|
||||
this.SetPermutationGenotype(permmatrix);
|
||||
this.setPermutationGenotype(permmatrix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultInit(InterfaceOptimizationProblem prob) {
|
||||
//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++) {
|
||||
perm[p] = new int[this.m_Genotype[p].length];
|
||||
perm[p] = new int[this.genotype[p].length];
|
||||
ArrayList pot = new ArrayList();
|
||||
for (int i = 0; i < this.sizePermutation()[p]; i++) {
|
||||
pot.add(new Integer(firstindex[p] + i));
|
||||
@ -221,7 +221,7 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
|
||||
i++;
|
||||
}
|
||||
}
|
||||
this.SetPermutationGenotype(perm);
|
||||
this.setPermutationGenotype(perm);
|
||||
// System.out.println(getStringRepresentation());
|
||||
}
|
||||
|
||||
@ -234,46 +234,46 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
|
||||
|
||||
@Override
|
||||
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++) {
|
||||
this.m_Genotype[i] = new int[length[i]];
|
||||
this.genotype[i] = new int[length[i]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] sizePermutation() {
|
||||
int[] res = new int[m_Genotype.length];
|
||||
for (int i = 0; i < m_Genotype.length; i++) {
|
||||
res[i] = m_Genotype[i].length;
|
||||
int[] res = new int[genotype.length];
|
||||
for (int i = 0; i < genotype.length; i++) {
|
||||
res[i] = genotype[i].length;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetPermutationPhenotype(int[][] perm) {
|
||||
this.m_Phenotype = perm;
|
||||
public void setPermutationPhenotype(int[][] perm) {
|
||||
this.phenotype = perm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetPermutationGenotype(int[][] perm) {
|
||||
this.SetPermutationPhenotype(perm);
|
||||
this.m_Genotype = new int[perm.length][];
|
||||
public void setPermutationGenotype(int[][] perm) {
|
||||
this.setPermutationPhenotype(perm);
|
||||
this.genotype = new int[perm.length][];
|
||||
for (int i = 0; i < perm.length; i++) {
|
||||
this.m_Genotype[i] = new int[perm[i].length];
|
||||
System.arraycopy(perm[i], 0, this.m_Genotype[i], 0, perm[i].length);
|
||||
this.genotype[i] = new int[perm[i].length];
|
||||
System.arraycopy(perm[i], 0, this.genotype[i], 0, perm[i].length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[][] getPermutationData() {
|
||||
this.m_Phenotype = new int[this.m_Genotype.length][];
|
||||
for (int i = 0; i < this.m_Genotype.length; i++) {
|
||||
this.m_Phenotype[i] = new int[this.m_Genotype[i].length];
|
||||
System.arraycopy(this.m_Genotype[i], 0, this.m_Phenotype[i], 0, this.m_Genotype[i].length);
|
||||
this.phenotype = new int[this.genotype.length][];
|
||||
for (int i = 0; i < this.genotype.length; i++) {
|
||||
this.phenotype[i] = new int[this.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
|
||||
public int[][] getPermutationDataWithoutUpdate() {
|
||||
return this.m_Phenotype;
|
||||
return this.phenotype;
|
||||
}
|
||||
|
||||
public int[] getFirstindex() {
|
||||
|
@ -84,7 +84,7 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S
|
||||
switch (handling) {
|
||||
case penaltyAdditive:
|
||||
if (v > 0) {
|
||||
indy.SetMarkPenalized(true);
|
||||
indy.setMarkPenalized(true);
|
||||
for (int i = 0; i < indy.getFitness().length; i++) {
|
||||
indy.SetFitness(i, indy.getFitness(i) + v + penaltyFactor);
|
||||
}
|
||||
@ -92,7 +92,7 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S
|
||||
break;
|
||||
case penaltyMultiplicative:
|
||||
if (v > 0) {
|
||||
indy.SetMarkPenalized(true);
|
||||
indy.setMarkPenalized(true);
|
||||
for (int i = 0; i < indy.getFitness().length; i++) {
|
||||
indy.SetFitness(i, indy.getFitness(i) * (v + penaltyFactor));
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class CM1 implements InterfaceCrossover, java.io.Serializable {
|
||||
data.set(i, false);
|
||||
}
|
||||
}
|
||||
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
|
||||
}
|
||||
result[0] = indy1;
|
||||
return result;
|
||||
|
@ -49,7 +49,7 @@ public class CM2 implements InterfaceCrossover, java.io.Serializable {
|
||||
data.set(i, false);
|
||||
}
|
||||
}
|
||||
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
|
||||
}
|
||||
result[0] = indy1;
|
||||
return result;
|
||||
|
@ -60,7 +60,7 @@ public class CM3 implements InterfaceCrossover, java.io.Serializable {
|
||||
data.set(j, false);
|
||||
}
|
||||
}
|
||||
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
|
||||
}
|
||||
result[0] = indy1;
|
||||
return result;
|
||||
|
@ -62,7 +62,7 @@ public class CM4 implements InterfaceCrossover, java.io.Serializable {
|
||||
data.set(i, true);
|
||||
}
|
||||
}
|
||||
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
|
||||
}
|
||||
result[0] = indy1;
|
||||
return result;
|
||||
|
@ -45,7 +45,7 @@ public class CM5 implements InterfaceCrossover, java.io.Serializable {
|
||||
data.set(i, true);
|
||||
}
|
||||
}
|
||||
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
|
||||
}
|
||||
result[0] = indy1;
|
||||
return result;
|
||||
|
@ -51,7 +51,7 @@ public class CM6 implements InterfaceCrossover, java.io.Serializable {
|
||||
data.set(i, false);
|
||||
}
|
||||
}
|
||||
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
|
||||
}
|
||||
result[0] = indy1;
|
||||
return result;
|
||||
|
@ -50,7 +50,7 @@ public class CM7 implements InterfaceCrossover, java.io.Serializable, InterfaceE
|
||||
if (data.get(i) != data2.get(i)) {
|
||||
different++;
|
||||
data.flip(i);
|
||||
((InterfaceDataTypeBinary) indy1).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy1).setBinaryGenotype(data);
|
||||
this.m_OptimizationProblem.evaluate(indy1);
|
||||
this.evaluations++;
|
||||
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;
|
||||
return result;
|
||||
|
@ -87,7 +87,7 @@ public class CrossoverGABitSimulated implements InterfaceCrossover, java.io.Seri
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -86,8 +86,8 @@ public class CrossoverGADefault implements InterfaceCrossover,
|
||||
tmpBitSets[1].clear(i);
|
||||
}
|
||||
}
|
||||
((InterfaceGAIndividual) result[0]).SetBGenotype(tmpBitSets[0]);
|
||||
((InterfaceGAIndividual) result[1]).SetBGenotype(tmpBitSets[1]);
|
||||
((InterfaceGAIndividual) result[0]).setBGenotype(tmpBitSets[0]);
|
||||
((InterfaceGAIndividual) result[1]).setBGenotype(tmpBitSets[1]);
|
||||
}
|
||||
// in case the crossover was successfull lets give the mutation operators a
|
||||
// chance to mate the strategy parameters
|
||||
|
@ -118,9 +118,9 @@ public class CrossoverGAGINPoint implements InterfaceCrossover, java.io.Serializ
|
||||
private void writeBack(AbstractEAIndividual indy,
|
||||
Object newGenotype) {
|
||||
if (indy instanceof InterfaceGAIndividual) {
|
||||
((InterfaceGAIndividual) indy).SetBGenotype((BitSet) newGenotype);
|
||||
((InterfaceGAIndividual) indy).setBGenotype((BitSet) newGenotype);
|
||||
} 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
|
||||
// for (int i = 0; i < result.length; i++) result[i].getMutationOperator().crossoverOnStrategyParameters(indy1, partners);
|
||||
|
@ -81,7 +81,7 @@ public class CrossoverGAUniform implements InterfaceCrossover, java.io.Serializa
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -88,7 +88,7 @@ public class CrossoverGIDefault implements InterfaceCrossover, java.io.Serializa
|
||||
}
|
||||
// write the result back
|
||||
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
|
||||
|
@ -89,7 +89,7 @@ public class CrossoverGINPoint implements InterfaceCrossover, java.io.Serializab
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -93,7 +93,7 @@ public class CrossoverGINPointVL implements InterfaceCrossover, java.io.Serializ
|
||||
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
((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
|
||||
|
@ -80,7 +80,7 @@ public class CrossoverGIUniform implements InterfaceCrossover, java.io.Serializa
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -105,13 +105,13 @@ public class CrossoverGPDefault implements InterfaceCrossover, java.io.Serializa
|
||||
|
||||
// actually switch individuals!
|
||||
if (selNodeThisParent == null) {
|
||||
((InterfaceGPIndividual) result[0]).SetPGenotype((AbstractGPNode) selNodeOther.clone(), t);
|
||||
((InterfaceGPIndividual) result[0]).setPGenotype((AbstractGPNode) selNodeOther.clone(), t);
|
||||
} else {
|
||||
selNodeThisParent.setNode((AbstractGPNode) selNodeOther.clone(), selNodeThis);
|
||||
}
|
||||
// for (int i = 0; i < result.length; i++) System.out.println("-- Betw Crossover: " +result[i].getStringRepresentation());
|
||||
if (selNodeOtherParent == null) {
|
||||
((InterfaceGPIndividual) result[1]).SetPGenotype((AbstractGPNode) selNodeThis.clone(), t);
|
||||
((InterfaceGPIndividual) result[1]).setPGenotype((AbstractGPNode) selNodeThis.clone(), t);
|
||||
} else {
|
||||
selNodeOtherParent.setNode((AbstractGPNode) selNodeThis.clone(), selNodeOther);
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ public class CrossoverOBGAPMX implements InterfaceCrossover, java.io.Serializabl
|
||||
pperm2[i] = perm2;
|
||||
}
|
||||
|
||||
((InterfaceOBGAIndividual) result[0]).SetOBGenotype(pperm1);
|
||||
((InterfaceOBGAIndividual) result[1]).SetOBGenotype(pperm2);
|
||||
((InterfaceOBGAIndividual) result[0]).setOBGenotype(pperm1);
|
||||
((InterfaceOBGAIndividual) result[1]).setOBGenotype(pperm2);
|
||||
//((InterfaceDataTypePermutation) result[0]).SetPermutationDataLamarckian(pperm1);
|
||||
//((InterfaceDataTypePermutation) result[1]).SetPermutationDataLamarckian(pperm2);
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ public class CrossoverOBGAPMXUniform implements InterfaceCrossover, java.io.Seri
|
||||
pperm1[i] = perm1;
|
||||
pperm2[i] = perm2;
|
||||
}
|
||||
((InterfaceOBGAIndividual) result[0]).SetOBGenotype(pperm1);
|
||||
((InterfaceOBGAIndividual) result[1]).SetOBGenotype(pperm2);
|
||||
((InterfaceOBGAIndividual) result[0]).setOBGenotype(pperm1);
|
||||
((InterfaceOBGAIndividual) result[1]).setOBGenotype(pperm2);
|
||||
}
|
||||
//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++) {
|
||||
|
@ -147,9 +147,9 @@ public class GAGIInitializeSegmentwise implements InterfaceInitialization, java.
|
||||
|
||||
// write back the genotype (it may have been cloned, who knows...)
|
||||
if (indy instanceof InterfaceGAIndividual) {
|
||||
((InterfaceGAIndividual) indy).SetBGenotype((BitSet) genotype);
|
||||
((InterfaceGAIndividual) indy).setBGenotype((BitSet) genotype);
|
||||
} else {
|
||||
((InterfaceGIIndividual) indy).SetIGenotype((int[]) genotype);
|
||||
((InterfaceGIIndividual) indy).setIGenotype((int[]) genotype);
|
||||
}
|
||||
// System.out.println(BeanInspector.toString(genotype));
|
||||
} else {
|
||||
|
@ -101,7 +101,7 @@ public class MutateGAAdaptive implements InterfaceMutation, java.io.Serializable
|
||||
tmpBitSet.flip(i);
|
||||
}
|
||||
}
|
||||
((InterfaceGAIndividual) individual).SetBGenotype(tmpBitSet);
|
||||
((InterfaceGAIndividual) individual).setBGenotype(tmpBitSet);
|
||||
}
|
||||
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());
|
||||
}
|
||||
|
@ -127,9 +127,9 @@ public class MutateGAGISwapBits implements InterfaceMutation, java.io.Serializab
|
||||
// tmpBitSet.set(mutationIndices[i][0], tmpBit);
|
||||
}
|
||||
if (genotype instanceof BitSet) {
|
||||
((InterfaceGAIndividual) individual).SetBGenotype((BitSet) genotype);
|
||||
((InterfaceGAIndividual) individual).setBGenotype((BitSet) genotype);
|
||||
} else {
|
||||
((InterfaceGIIndividual) individual).SetIGenotype((int[]) genotype);
|
||||
((InterfaceGIIndividual) individual).setIGenotype((int[]) genotype);
|
||||
}
|
||||
}
|
||||
// System.err.println("After Mutate: " +(individual.getStringRepresentation()));
|
||||
|
@ -90,7 +90,7 @@ public class MutateGAInvertBits implements InterfaceMutation, java.io.Serializab
|
||||
tmpBitSet.flip(0, (mutationIndices[i][0] + mutationIndices[i][1]) - ((InterfaceGAIndividual) individual).getGenotypeLength());
|
||||
}
|
||||
}
|
||||
((InterfaceGAIndividual) individual).SetBGenotype(tmpBitSet);
|
||||
((InterfaceGAIndividual) individual).setBGenotype(tmpBitSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class MutateGANBit implements InterfaceMutation, java.io.Serializable {
|
||||
for (int i = 0; i < mutationIndices.length; i++) {
|
||||
tmpBitSet.flip(mutationIndices[i]);
|
||||
}
|
||||
((InterfaceGAIndividual) individual).SetBGenotype(tmpBitSet);
|
||||
((InterfaceGAIndividual) individual).setBGenotype(tmpBitSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
// System.out.println(tmpBitSet.cardinality());
|
||||
((InterfaceGAIndividual) individual).SetBGenotype(tmpBitSet);
|
||||
((InterfaceGAIndividual) individual).setBGenotype(tmpBitSet);
|
||||
}
|
||||
// System.out.println("After Mutate: " +(individual.getStringRepresentation()));
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public class MutateGASwapBitsSegmentwise implements InterfaceMutation, java.io.S
|
||||
} 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());
|
||||
}
|
||||
|
@ -136,8 +136,8 @@ public class MutateGIInsertDelete implements InterfaceMutation, java.io.Serializ
|
||||
System.out.println("newX " + newX.length);
|
||||
}
|
||||
((InterfaceGIIndividual) individual).setIntegerDataLength(newX.length);
|
||||
((InterfaceGIIndividual) individual).SetIGenotype(newX);
|
||||
((InterfaceGIIndividual) individual).SetIntRange(newRange);
|
||||
((InterfaceGIIndividual) individual).setIGenotype(newX);
|
||||
((InterfaceGIIndividual) individual).setIntRange(newRange);
|
||||
newX = ((InterfaceGIIndividual) individual).getIGenotype();
|
||||
if (newX.length <= 1) {
|
||||
System.out.println("newX " + newX.length);
|
||||
|
@ -91,7 +91,7 @@ public class MutateGIInvert implements InterfaceMutation, java.io.Serializable {
|
||||
}
|
||||
//this.pintInt("After ", tmp);
|
||||
//this.pintInt("After ", x);
|
||||
((InterfaceGIIndividual) individual).SetIGenotype(x);
|
||||
((InterfaceGIIndividual) individual).setIGenotype(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class MutateGINominal implements InterfaceMutation, java.io.Serializable
|
||||
}
|
||||
x[mutInd] = RNG.randomInt(range[mutInd][0], range[mutInd][1]);
|
||||
}
|
||||
((InterfaceGIIndividual) individual).SetIGenotype(x);
|
||||
((InterfaceGIIndividual) individual).setIGenotype(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class MutateGIOrdinal implements InterfaceMutation, java.io.Serializable
|
||||
x[mutInd] = range[mutInd][1];
|
||||
}
|
||||
}
|
||||
((InterfaceGIIndividual) individual).SetIGenotype(x);
|
||||
((InterfaceGIIndividual) individual).setIGenotype(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class MutateGITranslocate implements InterfaceMutation, java.io.Serializa
|
||||
}
|
||||
// System.out.println(""+from+"/"+to+"/"+length);
|
||||
// this.printInt("After ", tmp);
|
||||
((InterfaceGIIndividual) individual).SetIGenotype(tmp);
|
||||
((InterfaceGIIndividual) individual).setIGenotype(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class MutateGPSingleNode implements InterfaceMutation, java.io.Serializab
|
||||
if (parent != null) {
|
||||
newNode.setParent(parent);
|
||||
} else {
|
||||
((InterfaceGPIndividual) individual).SetPGenotype(newNode, i);
|
||||
((InterfaceGPIndividual) individual).setPGenotype(newNode, i);
|
||||
}
|
||||
// now reconnect the children
|
||||
newNode.initNodeArray();
|
||||
|
@ -69,7 +69,7 @@ public class MutateOBGAFlip implements InterfaceMutation, java.io.Serializable {
|
||||
perm[p][p2] = temp;
|
||||
}
|
||||
}
|
||||
((InterfaceOBGAIndividual) individual).SetOBGenotype(perm);
|
||||
((InterfaceOBGAIndividual) individual).setOBGenotype(perm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ public class MutateOBGAInversion implements java.io.Serializable, InterfaceMutat
|
||||
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
|
||||
|
@ -111,7 +111,7 @@ public class SelectParticleWheel implements InterfaceSelection, java.io.Serializ
|
||||
sum += ((AbstractEAIndividual) population.getIndividual(selIndex)).getSelectionProbability(0);
|
||||
}
|
||||
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);
|
||||
}
|
||||
result.add(((AbstractEAIndividual) population.get(selIndex)).clone());
|
||||
((AbstractEAIndividual) result.getIndividual(i)).SetAge(0);
|
||||
((AbstractEAIndividual) result.getIndividual(i)).setAge(0);
|
||||
selPoint += segment;
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -174,7 +174,7 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
double[] tmpD = new double[1];
|
||||
tmpD[0] = result[i] / sum;
|
||||
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(tmpD);
|
||||
((AbstractEAIndividual) population.get(i)).setSelectionProbability(tmpD);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -224,7 +224,7 @@ public class SelProbBoltzman extends AbstractSelProb implements java.io.Serializ
|
||||
}
|
||||
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(x, result[i]);
|
||||
((AbstractEAIndividual) population.get(i)).setSelectionProbability(x, result[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class SelProbFitnessSharing extends AbstractSelProb implements java.io.Se
|
||||
}
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
tmpIndy1 = ((AbstractEAIndividual) population.get(i));
|
||||
tmpIndy1.SetSelectionProbability(0, (selProb[i] / sum));
|
||||
tmpIndy1.setSelectionProbability(0, (selProb[i] / sum));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class SelProbInvertByMax extends AbstractSelProb {
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -89,7 +89,7 @@ public class SelProbInvertByMax extends AbstractSelProb {
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
double[] tmpD = new double[1];
|
||||
tmpD[0] = result[i] / sum;
|
||||
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(tmpD);
|
||||
((AbstractEAIndividual) population.get(i)).setSelectionProbability(tmpD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class SelProbLinearRanking extends AbstractSelProb implements java.io.Ser
|
||||
// set the selection propability
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
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 {
|
||||
@ -131,7 +131,7 @@ public class SelProbLinearRanking extends AbstractSelProb implements java.io.Ser
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
double[] tmpD = new double[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 {
|
||||
@ -166,7 +166,7 @@ public class SelProbLinearRanking extends AbstractSelProb implements java.io.Ser
|
||||
// set the selection propability
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
|
||||
sum += result[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 {
|
||||
@ -143,7 +143,7 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
double[] tmpD = new double[1];
|
||||
tmpD[0] = result[i] / sum;
|
||||
((AbstractEAIndividual) population.get(rank_index[i])).SetSelectionProbability(tmpD);
|
||||
((AbstractEAIndividual) population.get(rank_index[i])).setSelectionProbability(tmpD);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -182,7 +182,7 @@ public class SelProbNonLinearRanking extends AbstractSelProb implements java.io.
|
||||
sum += result[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class SelProbRanking extends AbstractSelProb implements java.io.Serializa
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -99,7 +99,7 @@ public class SelProbRanking extends AbstractSelProb implements java.io.Serializa
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class SelProbStandard extends AbstractSelProb implements java.io.Serializ
|
||||
sum += result[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 {
|
||||
@ -81,7 +81,7 @@ public class SelProbStandard extends AbstractSelProb implements java.io.Serializ
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
double[] tmpD = new double[1];
|
||||
tmpD[0] = result[i] / sum;
|
||||
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(tmpD);
|
||||
((AbstractEAIndividual) population.get(i)).setSelectionProbability(tmpD);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -96,7 +96,7 @@ public class SelProbStandard extends AbstractSelProb implements java.io.Serializ
|
||||
sum += result[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -125,7 +125,7 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
double[] tmpD = new double[1];
|
||||
tmpD[0] = result[i] / sum;
|
||||
((AbstractEAIndividual) population.get(i)).SetSelectionProbability(tmpD);
|
||||
((AbstractEAIndividual) population.get(i)).setSelectionProbability(tmpD);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -155,7 +155,7 @@ public class SelProbStandardScaling extends AbstractSelProb implements java.io.S
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class PBILPopulation extends Population implements Cloneable, java.io.Ser
|
||||
tmpBitSet.clear(j);
|
||||
}
|
||||
}
|
||||
tmpIndy.SetBGenotype(tmpBitSet);
|
||||
tmpIndy.setBGenotype(tmpBitSet);
|
||||
super.add(tmpIndy);
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
||||
curCard += (int) Math.round(RNG.gaussianDouble((double) stdDev));
|
||||
}
|
||||
curCard = Math.max(0, Math.min(curCard, gaIndy.getGenotypeLength()));
|
||||
gaIndy.SetBGenotype(RNG.randomBitSet(curCard, gaIndy.getGenotypeLength()));
|
||||
gaIndy.setBGenotype(RNG.randomBitSet(curCard, gaIndy.getGenotypeLength()));
|
||||
}
|
||||
} else {
|
||||
System.err.println("Error: InterfaceGAIndividual required for binary cardinality initialization!");
|
||||
|
@ -140,7 +140,7 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz
|
||||
}
|
||||
getProblem().initializePopulation(population);
|
||||
for (int i = 0; i < population.size(); i++) {
|
||||
((AbstractEAIndividual) population.get(i)).SetAge(0);
|
||||
((AbstractEAIndividual) population.get(i)).setAge(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
|
||||
while (eval(tmpSet)[1] > 0) {
|
||||
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) {
|
||||
((InterfaceDataTypeBinary) individual).SetBinaryGenotype(tmpBitSet);
|
||||
((InterfaceDataTypeBinary) individual).setBinaryGenotype(tmpBitSet);
|
||||
}
|
||||
}
|
||||
result[0] += 5100;
|
||||
|
@ -333,10 +333,10 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
||||
((InterfaceDataTypeDouble) indy).setDoubleGenotype(ds);
|
||||
break;
|
||||
case typeBinary:
|
||||
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(toBinary(ds));
|
||||
((InterfaceDataTypeBinary) indy).setBinaryGenotype(toBinary(ds));
|
||||
break;
|
||||
case typeInteger:
|
||||
((InterfaceDataTypeInteger) indy).SetIntGenotype(toInteger(ds));
|
||||
((InterfaceDataTypeInteger) indy).setIntGenotype(toInteger(ds));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -733,7 +733,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
|
||||
AbstractGPNode node = AbstractGPNode.parseFromString(nodeStr);
|
||||
PSymbolicRegression regrProb = new PSymbolicRegression();
|
||||
GPIndividualProgramData indy = new GPIndividualProgramData();
|
||||
indy.SetPGenotype(node, 0);
|
||||
indy.setPGenotype(node, 0);
|
||||
regrProb.evaluate(indy);
|
||||
System.out.println("Evaluated individual: " + indy);
|
||||
return indy.getFitness();
|
||||
|
@ -233,7 +233,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
}
|
||||
probDim = (Integer) dim;
|
||||
((InterfaceDataTypeBinary) this.template)
|
||||
.SetBinaryGenotype(new BitSet(probDim));
|
||||
.setBinaryGenotype(new BitSet(probDim));
|
||||
}
|
||||
this.network = new BayNet(this.probDim, upperProbLimit, lowerProbLimit);
|
||||
this.network.setScoringMethod(this.scoringMethod);
|
||||
@ -354,7 +354,7 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
AbstractEAIndividual indy = (AbstractEAIndividual) this.template
|
||||
.clone();
|
||||
BitSet data = this.network.sample(getBinaryData(indy));
|
||||
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy).setBinaryGenotype(data);
|
||||
evaluate(indy);
|
||||
pop.add(indy);
|
||||
}
|
||||
@ -941,11 +941,11 @@ public class BOA implements InterfaceOptimizer, java.io.Serializable {
|
||||
// data5.set(0, true);
|
||||
// data5.set(1, true);
|
||||
// data5.set(2, true);
|
||||
indy1.SetBinaryGenotype(data1);
|
||||
indy2.SetBinaryGenotype(data2);
|
||||
indy3.SetBinaryGenotype(data3);
|
||||
indy4.SetBinaryGenotype(data4);
|
||||
indy5.SetBinaryGenotype(data5);
|
||||
indy1.setBinaryGenotype(data1);
|
||||
indy2.setBinaryGenotype(data2);
|
||||
indy3.setBinaryGenotype(data3);
|
||||
indy4.setBinaryGenotype(data4);
|
||||
indy5.setBinaryGenotype(data5);
|
||||
pop.add(indy1);
|
||||
pop.add(indy2);
|
||||
pop.add(indy3);
|
||||
|
@ -204,7 +204,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
System.err.println("Couldnt get problem dimension!");
|
||||
}
|
||||
probDim = (Integer) dim;
|
||||
((InterfaceDataTypeBinary) this.template).SetBinaryGenotype(new BitSet(probDim));
|
||||
((InterfaceDataTypeBinary) this.template).setBinaryGenotype(new BitSet(probDim));
|
||||
}
|
||||
this.firstTime = true;
|
||||
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) {
|
||||
data.flip(j);
|
||||
}
|
||||
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy).setBinaryGenotype(data);
|
||||
if (i == 1) {
|
||||
i++;
|
||||
method1 = !method1;
|
||||
@ -306,7 +306,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
for (int j = 0; j < data.size(); j += i) {
|
||||
data.flip(j);
|
||||
}
|
||||
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) indy).setBinaryGenotype(data);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@ -334,7 +334,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
data.set(i, true);
|
||||
}
|
||||
}
|
||||
dblIndy.SetBinaryGenotype(data);
|
||||
dblIndy.setBinaryGenotype(data);
|
||||
if (!contains(dblIndy, pop)) {
|
||||
pop.add(dblIndy);
|
||||
evaluate(indy);
|
||||
@ -362,7 +362,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
data.set(i, false);
|
||||
}
|
||||
}
|
||||
dblIndy.SetBinaryGenotype(data);
|
||||
dblIndy.setBinaryGenotype(data);
|
||||
if (!contains(dblIndy, pop)) {
|
||||
pop.add(dblIndy);
|
||||
evaluate(indy);
|
||||
@ -610,7 +610,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
improvement = false;
|
||||
for (int i : cl) {
|
||||
data.flip(i);
|
||||
((InterfaceDataTypeBinary) tmpIndy).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) tmpIndy).setBinaryGenotype(data);
|
||||
evaluate(tmpIndy);
|
||||
if (tmpIndy.getFitness(0) < indy.getFitness(0)) {
|
||||
improvement = true;
|
||||
@ -628,7 +628,7 @@ public class BinaryScatterSearch implements InterfaceOptimizer, java.io.Serializ
|
||||
if (valJ != valI) {
|
||||
data.set(i, valJ);
|
||||
data.set(j, valI);
|
||||
((InterfaceDataTypeBinary) tmpIndy).SetBinaryGenotype(data);
|
||||
((InterfaceDataTypeBinary) tmpIndy).setBinaryGenotype(data);
|
||||
evaluate(tmpIndy);
|
||||
if (tmpIndy.getFitness(0) < indy.getFitness(0)) {
|
||||
improvement = true;
|
||||
|
@ -201,7 +201,7 @@ public class CHCAdaptiveSearchAlgorithm implements InterfaceOptimizer, java.io.S
|
||||
}
|
||||
}
|
||||
}
|
||||
mutant.SetBGenotype(tmpBitSet);
|
||||
mutant.setBGenotype(tmpBitSet);
|
||||
this.population.add(mutant);
|
||||
}
|
||||
if (best instanceof InterfaceGAIndividual) {
|
||||
|
@ -427,7 +427,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
Mathematics.projectToRange(nX, esIndy.getDoubleRange());
|
||||
} // why did this never happen before?
|
||||
esIndy.setDoubleGenotype(nX);
|
||||
indy.SetAge(0);
|
||||
indy.setAge(0);
|
||||
indy.resetConstraintViolation();
|
||||
double[] fit = new double[1];
|
||||
fit[0] = 0;
|
||||
@ -530,7 +530,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
|
||||
if (((AbstractEAIndividual) population.get(i)).getAge() >= maximumAge) {
|
||||
this.optimizationProblem.evaluate(((AbstractEAIndividual) population.get(i)));
|
||||
((AbstractEAIndividual) population.get(i)).SetAge(0);
|
||||
((AbstractEAIndividual) population.get(i)).setAge(0);
|
||||
population.incrFunctionCalls();
|
||||
}
|
||||
}
|
||||
@ -588,7 +588,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
||||
|
||||
if (((AbstractEAIndividual) population.get(i)).getAge() >= maximumAge) {
|
||||
this.optimizationProblem.evaluate(((AbstractEAIndividual) population.get(i)));
|
||||
((AbstractEAIndividual) population.get(i)).SetAge(0);
|
||||
((AbstractEAIndividual) population.get(i)).setAge(0);
|
||||
population.incrFunctionCalls();
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interface
|
||||
LOGGER.log(Level.WARNING, "Couldn't get problem dimension!");
|
||||
}
|
||||
probDim = (Integer) dim;
|
||||
((InterfaceDataTypeBinary) this.template).SetBinaryGenotype(new BitSet(probDim));
|
||||
((InterfaceDataTypeBinary) this.template).setBinaryGenotype(new BitSet(probDim));
|
||||
}
|
||||
this.population.addPopulationChangedEventListener(this);
|
||||
this.population.setNotifyEvalInterval(this.generationCycle);
|
||||
@ -288,8 +288,8 @@ public class LTGA implements InterfaceOptimizer, java.io.Serializable, Interface
|
||||
if (!same) {
|
||||
AbstractEAIndividual newIndy1 = (AbstractEAIndividual) this.template.clone();
|
||||
AbstractEAIndividual newIndy2 = (AbstractEAIndividual) this.template.clone();
|
||||
((InterfaceDataTypeBinary) newIndy1).SetBinaryGenotype(newGene1);
|
||||
((InterfaceDataTypeBinary) newIndy2).SetBinaryGenotype(newGene2);
|
||||
((InterfaceDataTypeBinary) newIndy1).setBinaryGenotype(newGene1);
|
||||
((InterfaceDataTypeBinary) newIndy2).setBinaryGenotype(newGene2);
|
||||
evaluate(newIndy1);
|
||||
evaluate(newIndy2);
|
||||
if (Math.min(newIndy1.getFitness(0), newIndy2.getFitness(0)) < Math.min(indy1.getFitness(0), indy2.getFitness(0))) {
|
||||
|
@ -96,7 +96,7 @@ public class MLTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
|
||||
LOGGER.log(Level.WARNING, "Couldn't get problem dimension!");
|
||||
}
|
||||
probDim = (Integer) dim;
|
||||
((InterfaceDataTypeBinary) this.template).SetBinaryGenotype(new BitSet(probDim));
|
||||
((InterfaceDataTypeBinary) this.template).setBinaryGenotype(new BitSet(probDim));
|
||||
}
|
||||
this.population.addPopulationChangedEventListener(this);
|
||||
this.population.setNotifyEvalInterval(this.generationCycle);
|
||||
@ -274,7 +274,7 @@ public class MLTGA implements InterfaceOptimizer, java.io.Serializable, Interfac
|
||||
newGene.flip(flipID);
|
||||
}
|
||||
AbstractEAIndividual newIndy = (AbstractEAIndividual) this.template.clone();
|
||||
((InterfaceDataTypeBinary) newIndy).SetBinaryGenotype(newGene);
|
||||
((InterfaceDataTypeBinary) newIndy).setBinaryGenotype(newGene);
|
||||
evaluate(newIndy);
|
||||
if (newIndy.getFitness(0) < indy.getFitness(0)) {
|
||||
indy = newIndy;
|
||||
|
@ -415,7 +415,7 @@ public class PDDifferentialEvolution implements InterfaceOptimizer, java.io.Seri
|
||||
Mathematics.projectToRange(nX, esIndy.getDoubleRange());
|
||||
} // why did this never happen before?
|
||||
esIndy.setDoubleGenotype(nX);
|
||||
indy.SetAge(0);
|
||||
indy.setAge(0);
|
||||
indy.resetConstraintViolation();
|
||||
double[] fit = new double[1];
|
||||
fit[0] = 0;
|
||||
@ -519,7 +519,7 @@ public class PDDifferentialEvolution implements InterfaceOptimizer, java.io.Seri
|
||||
|
||||
if (((AbstractEAIndividual) m_Population.get(i)).getAge() >= maximumAge) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -576,7 +576,7 @@ public class PDDifferentialEvolution implements InterfaceOptimizer, java.io.Seri
|
||||
|
||||
if (((AbstractEAIndividual) m_Population.get(i)).getAge() >= maximumAge) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ public class ParticleSubSwarmOptimization extends ParticleSwarmOptimizationGCPSO
|
||||
if (particleIndices != null) { // use given indices
|
||||
for (int i = 0; i < tmpopt.getPopulation().size(); ++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
|
||||
}
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
||||
}
|
||||
}
|
||||
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);
|
||||
initIndividualMemory(indy);
|
||||
indy.putData(indexKey, i);
|
||||
indy.SetIndividualIndex(i);
|
||||
indy.setIndividualIndex(i);
|
||||
if (TRACE) {
|
||||
System.err.println("init indy " + i + " " + AbstractEAIndividual.getDefaultDataString(indy));
|
||||
}
|
||||
|
@ -1110,11 +1110,11 @@ public class BayNet {
|
||||
// data5.set(0, true);
|
||||
// data5.set(1, true);
|
||||
// data5.set(2, true);
|
||||
// indy1.SetBinaryGenotype(data1);
|
||||
// indy2.SetBinaryGenotype(data2);
|
||||
// indy3.SetBinaryGenotype(data3);
|
||||
// indy4.SetBinaryGenotype(data4);
|
||||
// indy5.SetBinaryGenotype(data5);
|
||||
// indy1.setBinaryGenotype(data1);
|
||||
// indy2.setBinaryGenotype(data2);
|
||||
// indy3.setBinaryGenotype(data3);
|
||||
// indy4.setBinaryGenotype(data4);
|
||||
// indy5.setBinaryGenotype(data5);
|
||||
// pop.add(indy1);
|
||||
// pop.add(indy2);
|
||||
// pop.add(indy3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user