More refactoring.

This commit is contained in:
Fabian Becker 2013-09-11 16:40:56 +02:00
parent 2f99e23676
commit c3dce7ac1b
61 changed files with 130 additions and 139 deletions

View File

@ -1262,10 +1262,10 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
*/ */
public static boolean setDoublePosition(AbstractEAIndividual indy, double[] pos) { public static boolean setDoublePosition(AbstractEAIndividual indy, double[] pos) {
if (indy instanceof InterfaceESIndividual) { if (indy instanceof InterfaceESIndividual) {
((InterfaceESIndividual) indy).SetDGenotype(pos); ((InterfaceESIndividual) indy).setDGenotype(pos);
return true; return true;
} else if (indy instanceof InterfaceDataTypeDouble) { } else if (indy instanceof InterfaceDataTypeDouble) {
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(pos); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(pos);
return true; return true;
} else if (indy instanceof InterfaceDataTypeInteger) { } else if (indy instanceof InterfaceDataTypeInteger) {
EVAERROR.errorMsgOnce("Warning, double position truncated to integer! (AbstractEAIndividual.setDoublePosition)"); EVAERROR.errorMsgOnce("Warning, double position truncated to integer! (AbstractEAIndividual.setDoublePosition)");

View File

@ -279,7 +279,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
@Override @Override
public void SetDGenotype(double[] b) { public void setDGenotype(double[] b) {
this.m_Genotype = b; this.m_Genotype = b;
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
if (this.m_Genotype[i] < this.m_Range[i][0]) { if (this.m_Genotype[i] < this.m_Range[i][0]) {
@ -296,7 +296,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
// * ranges. // * ranges.
// * @param range The new range for the double data. // * @param range The new range for the double data.
// */ // */
// public void SetDoubleRange(double[][] range) { // public void setDoubleRange(double[][] range) {
// this.m_Range = range; // this.m_Range = range;
// } // }

View File

@ -168,10 +168,10 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
public void SetDoubleRange(double[][] range) { public void setDoubleRange(double[][] range) {
if (range.length != this.m_Range.length) { if (range.length != this.m_Range.length) {
System.out.println("Warning: Trying to set a range of length " + range.length + " to a vector of length " System.out.println("Warning: Trying to set a range of length " + range.length + " to a vector of length "
+ this.m_Range.length + "!\n Use method setDoubleDataLength first! (ESIndividualDoubleData:SetDoubleRange)"); + this.m_Range.length + "!\n Use method setDoubleDataLength first! (ESIndividualDoubleData:setDoubleRange)");
} }
for (int i = 0; ((i < this.m_Range.length) && (i < range.length)); i++) { 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][0] = range[i][0];
@ -230,7 +230,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
public void SetDoublePhenotype(double[] doubleData) { public void setDoublePhenotype(double[] doubleData) {
this.m_Phenotype = doubleData; this.m_Phenotype = doubleData;
} }
@ -241,9 +241,9 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
public void SetDoubleGenotype(double[] doubleData) { public void setDoubleGenotype(double[] doubleData) {
// this.SetDoublePhenotype(doubleData); // this.setDoublePhenotype(doubleData);
this.SetDoublePhenotype(null); // tag it as invalid this.setDoublePhenotype(null); // tag it as invalid
this.m_Genotype = new double[doubleData.length]; this.m_Genotype = new double[doubleData.length];
System.arraycopy(doubleData, 0, this.m_Genotype, 0, doubleData.length); System.arraycopy(doubleData, 0, this.m_Genotype, 0, doubleData.length);
} }
@ -279,7 +279,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
if (bs.length != this.m_Genotype.length) { if (bs.length != this.m_Genotype.length) {
System.out.println("Init value and requested length doesn't match!"); System.out.println("Init value and requested length doesn't match!");
} }
this.SetDoubleGenotype(bs); this.setDoubleGenotype(bs);
} else { } else {
this.defaultInit(opt); this.defaultInit(opt);
System.out.println("Initial value for ESIndividualDoubleData is not double[]!"); System.out.println("Initial value for ESIndividualDoubleData is not double[]!");
@ -336,7 +336,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
@Override @Override
public void SetDGenotype(double[] b) { public void setDGenotype(double[] b) {
this.m_Genotype = b; this.m_Genotype = b;
this.m_Phenotype = null; // mark it as invalid this.m_Phenotype = null; // mark it as invalid
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
@ -354,7 +354,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
* *
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
public void SetDGenotypeNocheck(double[] b) { public void setDGenotypeNocheck(double[] b) {
this.m_Phenotype = null; // mark it as invalid this.m_Phenotype = null; // mark it as invalid
this.m_Genotype = b; this.m_Genotype = b;
} }
@ -432,12 +432,4 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
public static String globalInfo() { public static String globalInfo() {
return "This is an ES individual suited to optimize double values."; return "This is an ES individual suited to optimize double values.";
} }
// public String toString() {
// String str = "Ind " + m_Genotype[0];
// for (int i=1; i<this.m_Genotype.length; i++) str += "/" + m_Genotype[i];
// str += "~" + fitness[0];
// for (int i=1; i<this.fitness.length; i++) str += "/" + fitness[i];
// return str;
// }
} }

View File

@ -297,7 +297,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
@Override @Override
public void SetDGenotype(double[] b) { public void setDGenotype(double[] b) {
this.m_Genotype = b; this.m_Genotype = b;
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
if (this.m_Genotype[i] < this.m_Range[i][0]) { if (this.m_Genotype[i] < this.m_Range[i][0]) {

View File

@ -348,7 +348,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
@Override @Override
public void SetDGenotype(double[] b) { public void setDGenotype(double[] b) {
this.m_Genotype = mapVectorToMatrix(b, this.sizePermutation()); this.m_Genotype = mapVectorToMatrix(b, this.sizePermutation());
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
for (int j = 0; j < this.m_Genotype[i].length; j++) { for (int j = 0; j < this.m_Genotype[i].length; j++) {

View File

@ -246,8 +246,8 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
public void SetDoubleRange(double[][] range) { public void setDoubleRange(double[][] range) {
this.m_Numbers.SetDoubleRange(range); this.m_Numbers.setDoubleRange(range);
} }
/** /**
@ -288,8 +288,8 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
* @see InterfaceDataTypeDouble.SetDoubleData() * @see InterfaceDataTypeDouble.SetDoubleData()
*/ */
@Override @Override
public void SetDoublePhenotype(double[] doubleData) { public void setDoublePhenotype(double[] doubleData) {
this.m_Numbers.SetDoublePhenotype(doubleData); this.m_Numbers.setDoublePhenotype(doubleData);
} }
/** /**
@ -300,8 +300,8 @@ public class GAESIndividualBinaryDoubleData extends AbstractEAIndividual impleme
* @see InterfaceDataTypeDouble.SetDoubleDataLamarckian() * @see InterfaceDataTypeDouble.SetDoubleDataLamarckian()
*/ */
@Override @Override
public void SetDoubleGenotype(double[] doubleData) { public void setDoubleGenotype(double[] doubleData) {
this.m_Numbers.SetDoubleGenotype(doubleData); this.m_Numbers.setDoubleGenotype(doubleData);
} }
/** /**

View File

@ -167,7 +167,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
public void SetDoubleRange(double[][] range) { public void setDoubleRange(double[][] range) {
if (range.length != this.m_Range.length) { if (range.length != this.m_Range.length) {
System.out.println("Warning: Trying to set a range of length " + range.length + " to a vector of length " System.out.println("Warning: Trying to set a range of length " + range.length + " to a vector of length "
+ this.m_Range.length + "!\n Use method setDoubleDataLength first!"); + this.m_Range.length + "!\n Use method setDoubleDataLength first!");
@ -223,7 +223,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
public void SetDoublePhenotype(double[] doubleData) { public void setDoublePhenotype(double[] doubleData) {
this.m_Phenotype = doubleData; this.m_Phenotype = doubleData;
} }
@ -234,8 +234,8 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
public void SetDoubleGenotype(double[] doubleData) { public void setDoubleGenotype(double[] doubleData) {
this.SetDoublePhenotype(doubleData); this.setDoublePhenotype(doubleData);
int[] locus = new int[2]; int[] locus = new int[2];
for (int i = 0; i < doubleData.length; i++) { for (int i = 0; i < doubleData.length; i++) {
locus[0] = i * this.m_Precision; locus[0] = i * this.m_Precision;
@ -262,7 +262,7 @@ public class GAIndividualDoubleData extends AbstractEAIndividual implements Inte
if (bs.length != this.m_Range.length) { if (bs.length != this.m_Range.length) {
System.out.println("Init value and requested length doesn't match!"); System.out.println("Init value and requested length doesn't match!");
} }
this.SetDoubleGenotype(bs); this.setDoubleGenotype(bs);
} else { } else {
this.defaultInit(opt); this.defaultInit(opt);
System.out.println("Initial value for GAIndividualDoubleData is not double[]!"); System.out.println("Initial value for GAIndividualDoubleData is not double[]!");

View File

@ -229,8 +229,8 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
@Override @Override
public void SetDoubleRange(double[][] range) { public void setDoubleRange(double[][] range) {
this.m_Numbers.SetDoubleRange(range); this.m_Numbers.setDoubleRange(range);
} }
/** /**
@ -271,8 +271,8 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
public void SetDoublePhenotype(double[] doubleData) { public void setDoublePhenotype(double[] doubleData) {
this.m_Numbers.SetDoublePhenotype(doubleData); this.m_Numbers.setDoublePhenotype(doubleData);
} }
/** /**
@ -282,8 +282,8 @@ public class GAPIndividualProgramData extends AbstractEAIndividual implements In
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
@Override @Override
public void SetDoubleGenotype(double[] doubleData) { public void setDoubleGenotype(double[] doubleData) {
this.m_Numbers.SetDoubleGenotype(doubleData); this.m_Numbers.setDoubleGenotype(doubleData);
} }
/************************************************************************************ /************************************************************************************

View File

@ -33,7 +33,7 @@ public interface InterfaceDataTypeDouble {
* *
* @param range The new range for the double data. * @param range The new range for the double data.
*/ */
public void SetDoubleRange(double[][] range); public void setDoubleRange(double[][] range);
/** /**
* This method will return the range for all double attributes. * This method will return the range for all double attributes.
@ -63,7 +63,7 @@ public interface InterfaceDataTypeDouble {
* *
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
public void SetDoublePhenotype(double[] doubleData); public void setDoublePhenotype(double[] doubleData);
/** /**
* This method allows you to set the double data, this can be used for * This method allows you to set the double data, this can be used for
@ -71,5 +71,5 @@ public interface InterfaceDataTypeDouble {
* *
* @param doubleData The new double data. * @param doubleData The new double data.
*/ */
public void SetDoubleGenotype(double[] doubleData); public void setDoubleGenotype(double[] doubleData);
} }

View File

@ -24,14 +24,14 @@ public interface InterfaceESIndividual {
* *
* @param b The new genotype of the Individual * @param b The new genotype of the Individual
*/ */
public void SetDGenotype(double[] b); public void setDGenotype(double[] b);
// //
// /** This method will set the range of the double attributes. // /** This method will set the range of the double attributes.
// * Note: range[d][0] gives the lower bound and range[d] gives the upper bound // * Note: range[d][0] gives the lower bound and range[d] gives the upper bound
// * for dimension d. // * for dimension d.
// * @param range The new range for the double data. // * @param range The new range for the double data.
// */ // */
// public void SetDoubleRange(double[][] range); // public void setDoubleRange(double[][] range);
/** /**
* This method will return the range for all double attributes. * This method will return the range for all double attributes.

View File

@ -316,7 +316,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
*/ */
private double distance(AbstractEAIndividual indy, double[] p) { private double distance(AbstractEAIndividual indy, double[] p) {
if (m_UseSearchSpace) { if (m_UseSearchSpace) {
((InterfaceDataTypeDouble) tmpIndy).SetDoubleGenotype(p); ((InterfaceDataTypeDouble) tmpIndy).setDoubleGenotype(p);
} else { } else {
tmpIndy.setFitness(p); tmpIndy.setFitness(p);
} }

View File

@ -356,7 +356,7 @@ public class ClusteringXMeans implements InterfaceClustering, java.io.Serializab
x[0] = 10; x[0] = 10;
x[1] = 10; x[1] = 10;
} }
((InterfaceDataTypeDouble) pop.get(i)).SetDoubleGenotype(x); ((InterfaceDataTypeDouble) pop.get(i)).setDoubleGenotype(x);
} }
} else { } else {
f1.initializePopulation(pop); f1.initializePopulation(pop);

View File

@ -15,7 +15,7 @@ public interface InterfaceDoubleConstraint {
/** /**
* Returns the boolean information whether the constraint is satisfied. * Returns the boolean information whether the constraint is satisfied.
* *
* @param indy * @param indyX
* @return * @return
*/ */
public boolean isSatisfied(double[] indyX); public boolean isSatisfied(double[] indyX);
@ -24,7 +24,6 @@ public interface InterfaceDoubleConstraint {
* Return the absolute (positive) degree of violation or zero if the constraint * Return the absolute (positive) degree of violation or zero if the constraint
* is fulfilled. * is fulfilled.
* *
* @param indy The individual to check.
* @param indyX possibly the decoded individual position * @param indyX possibly the decoded individual position
* @return true if valid false else. * @return true if valid false else.
*/ */

View File

@ -89,7 +89,7 @@ public class CrossoverESArithmetical implements InterfaceCrossover, java.io.Seri
} }
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successful lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successful lets give the mutation operators a chance to mate the strategy parameters

View File

@ -84,7 +84,7 @@ public class CrossoverESBLXAlpha implements InterfaceCrossover, java.io.Serializ
} }
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -84,7 +84,7 @@ public class CrossoverESDefault implements InterfaceCrossover, java.io.Serializa
} }
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successful lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successful lets give the mutation operators a chance to mate the strategy parameters

View File

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

View File

@ -75,7 +75,7 @@ public class CrossoverESIntermediate implements InterfaceCrossover, java.io.Seri
} }
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -84,7 +84,7 @@ public class CrossoverESNPointDiscrete implements InterfaceCrossover, java.io.Se
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -99,7 +99,7 @@ public class CrossoverESNPointDiscreteDislocation implements InterfaceCrossover,
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -118,7 +118,7 @@ public class CrossoverESPCX implements InterfaceCrossover, java.io.Serializable
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters
@ -238,7 +238,7 @@ public class CrossoverESPCX implements InterfaceCrossover, java.io.Serializable
range[i][1] = 2; range[i][1] = 2;
} }
indy1.setDoubleDataLength(n); indy1.setDoubleDataLength(n);
indy1.SetDoubleRange(range); indy1.setDoubleRange(range);
// init values // init values
indy2 = (ESIndividualDoubleData) indy1.clone(); indy2 = (ESIndividualDoubleData) indy1.clone();
indy3 = (ESIndividualDoubleData) indy1.clone(); indy3 = (ESIndividualDoubleData) indy1.clone();

View File

@ -86,7 +86,7 @@ public class CrossoverESSBX implements InterfaceCrossover, java.io.Serializable
} }
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters
@ -144,7 +144,7 @@ public class CrossoverESSBX implements InterfaceCrossover, java.io.Serializable
range[1][0] = -2.0; range[1][0] = -2.0;
range[1][1] = 2.0; range[1][1] = 2.0;
indy1.setDoubleDataLength(2); indy1.setDoubleDataLength(2);
indy1.SetDoubleRange(range); indy1.setDoubleRange(range);
// init values // init values
indy2 = (ESIndividualDoubleData) indy1.clone(); indy2 = (ESIndividualDoubleData) indy1.clone();
indy3 = (ESIndividualDoubleData) indy1.clone(); indy3 = (ESIndividualDoubleData) indy1.clone();

View File

@ -97,7 +97,7 @@ public class CrossoverESSPX implements InterfaceCrossover, java.io.Serializable
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters
@ -156,7 +156,7 @@ public class CrossoverESSPX implements InterfaceCrossover, java.io.Serializable
range[i][1] = 2.0; range[i][1] = 2.0;
} }
indy1.setDoubleDataLength(n); indy1.setDoubleDataLength(n);
indy1.SetDoubleRange(range); indy1.setDoubleRange(range);
// init values // init values
indy2 = (ESIndividualDoubleData) indy1.clone(); indy2 = (ESIndividualDoubleData) indy1.clone();
indy3 = (ESIndividualDoubleData) indy1.clone(); indy3 = (ESIndividualDoubleData) indy1.clone();

View File

@ -122,7 +122,7 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters
@ -240,7 +240,7 @@ public class CrossoverESUNDX implements InterfaceCrossover, java.io.Serializable
range[i][1] = 2.0; range[i][1] = 2.0;
} }
indy1.setDoubleDataLength(n); indy1.setDoubleDataLength(n);
indy1.SetDoubleRange(range); indy1.setDoubleRange(range);
// init values // init values
indy2 = (ESIndividualDoubleData) indy1.clone(); indy2 = (ESIndividualDoubleData) indy1.clone();
indy3 = (ESIndividualDoubleData) indy1.clone(); indy3 = (ESIndividualDoubleData) indy1.clone();

View File

@ -76,7 +76,7 @@ public class CrossoverESUniformDiscrete implements InterfaceCrossover, java.io.S
// write the result back // write the result back
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
((InterfaceESIndividual) result[i]).SetDGenotype(children[i]); ((InterfaceESIndividual) result[i]).setDGenotype(children[i]);
} }
} }
//in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters //in case the crossover was successfull lets give the mutation operators a chance to mate the strategy parameters

View File

@ -107,7 +107,7 @@ public class TestESCrossover implements java.io.Serializable {
newRange[i][1] = 2; newRange[i][1] = 2;
} }
tmpIndyD.setDoubleDataLength(m_Dimension); tmpIndyD.setDoubleDataLength(m_Dimension);
tmpIndyD.SetDoubleRange(newRange); tmpIndyD.setDoubleRange(newRange);
for (int i = 0; i < m_Partners.getTargetSize(); i++) { for (int i = 0; i < m_Partners.getTargetSize(); i++) {
tmpIndyEA = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone(); tmpIndyEA = (AbstractEAIndividual) ((AbstractEAIndividual) tmpIndyD).clone();
tmpIndyEA.init(m_Problem); tmpIndyEA.init(m_Problem);
@ -146,7 +146,7 @@ public class TestESCrossover implements java.io.Serializable {
newRange[i][1] = 2; newRange[i][1] = 2;
} }
tmpIndyD.setDoubleDataLength(m_Dimension); tmpIndyD.setDoubleDataLength(m_Dimension);
tmpIndyD.SetDoubleRange(newRange); tmpIndyD.setDoubleRange(newRange);
double[] tmpD = new double[2]; double[] tmpD = new double[2];
tmpD[0] = 1; tmpD[0] = 1;
@ -190,7 +190,7 @@ public class TestESCrossover implements java.io.Serializable {
newRange[i][1] = 2; newRange[i][1] = 2;
} }
tmpIndyD.setDoubleDataLength(m_Dimension); tmpIndyD.setDoubleDataLength(m_Dimension);
tmpIndyD.SetDoubleRange(newRange); tmpIndyD.setDoubleRange(newRange);
double[] tmpD = new double[2]; double[] tmpD = new double[2];
tmpD[0] = 0.5; tmpD[0] = 0.5;

View File

@ -178,7 +178,7 @@ public class MutateESCorrVector implements InterfaceMutation, java.io.Serializab
} }
// write genotype back // write genotype back
((InterfaceESIndividual) individual).SetDGenotype(genes); ((InterfaceESIndividual) individual).setDGenotype(genes);
} }
// if (TRACE) System.out.println("After Mutate: " + AbstractEAIndividual.getDefaultDataString(individual)); // if (TRACE) System.out.println("After Mutate: " + AbstractEAIndividual.getDefaultDataString(individual));

View File

@ -181,7 +181,7 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab
// if (range[i][1] < x[i]) x[i] = range[i][1]; // if (range[i][1] < x[i]) x[i] = range[i][1];
// } // }
// //
// ((InterfaceESIndividual)individual).SetDGenotype(x); // ((InterfaceESIndividual)individual).setDGenotype(x);
// //
// //turn mutationvector with alphas // //turn mutationvector with alphas
//// for (int i = 0; i < x.length-1; i++) { //// for (int i = 0; i < x.length-1; i++) {
@ -250,7 +250,7 @@ public class MutateESCorrolated implements InterfaceMutation, java.io.Serializab
} }
} }
((InterfaceESIndividual) individual).SetDGenotype(x); ((InterfaceESIndividual) individual).setDGenotype(x);
} }
} }

View File

@ -202,7 +202,7 @@ public class MutateESCovarianceMatrixAdaption implements InterfaceMutation, java
x[i] = ranges[i][1]; x[i] = ranges[i][1];
} }
} }
((InterfaceESIndividual) individual).SetDGenotype(x); ((InterfaceESIndividual) individual).setDGenotype(x);
} }
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());
} }

View File

@ -88,7 +88,7 @@ public class MutateESFixedStepSize implements InterfaceMutation, java.io.Seriali
x[i] = range[i][1]; x[i] = range[i][1];
} }
} }
((InterfaceESIndividual) individual).SetDGenotype(x); ((InterfaceESIndividual) individual).setDGenotype(x);
} }
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());

View File

@ -125,7 +125,7 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable,
x[i] = range[i][1]; x[i] = range[i][1];
} }
} }
((InterfaceESIndividual) individual).SetDGenotype(x); ((InterfaceESIndividual) individual).setDGenotype(x);
} }
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());

View File

@ -144,7 +144,7 @@ public class MutateESLocal implements InterfaceMutation, InterfaceAdditionalPopu
x[i] = range[i][1]; x[i] = range[i][1];
} }
} }
((InterfaceESIndividual) individual).SetDGenotype(x); ((InterfaceESIndividual) individual).setDGenotype(x);
} }
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());
} }

View File

@ -157,7 +157,7 @@ public class MutateESMainVectorAdaption implements InterfaceMutation, java.io.Se
Z1 = RNG.gaussianDouble(1.0); Z1 = RNG.gaussianDouble(1.0);
evaluateNewObjectX(x, ranges); evaluateNewObjectX(x, ranges);
((InterfaceESIndividual) individual).SetDGenotype(x); ((InterfaceESIndividual) individual).setDGenotype(x);
} }
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());
} }

View File

@ -126,7 +126,7 @@ public class MutateESMutativeStepSizeControl implements InterfaceMutation, java.
x[i] = range[i][1]; x[i] = range[i][1];
} }
} }
((InterfaceESIndividual) individual).SetDGenotype(x); ((InterfaceESIndividual) individual).setDGenotype(x);
// System.out.println("new step size: " + mutationStepSize); // System.out.println("new step size: " + mutationStepSize);
} }
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());

View File

@ -150,7 +150,7 @@ public class MutateESPathLengthAdaption implements InterfaceMutation, java.io.Se
this.mutateX(x, ranges, true); // this performs new mutation this.mutateX(x, ranges, true); // this performs new mutation
((InterfaceESIndividual) individual).SetDGenotype(x); ((InterfaceESIndividual) individual).setDGenotype(x);
} }
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());
} }

View File

@ -97,7 +97,7 @@ public class MutateESPolynomial implements InterfaceMutation, java.io.Serializab
x[i] = range[i][1]; x[i] = range[i][1];
} }
} }
((InterfaceESIndividual) individual).SetDGenotype(x); ((InterfaceESIndividual) individual).setDGenotype(x);
} }
//System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());

View File

@ -612,7 +612,7 @@ public class MutateESRankMuCMA implements InterfaceAdaptOperatorGenerational, In
// this is a critical point: where do the CMA parameters for this individual's mutation come from? // this is a critical point: where do the CMA parameters for this individual's mutation come from?
// for GA and ES we can expect that selection occured directly before the mutation cycle, // for GA and ES we can expect that selection occured directly before the mutation cycle,
// so we take the parameter set from the last adpation step. // so we take the parameter set from the last adpation step.
((InterfaceDataTypeDouble) individual).SetDoubleGenotype(mutate(lastParams, x, range, 0)); ((InterfaceDataTypeDouble) individual).setDoubleGenotype(mutate(lastParams, x, range, 0));
// if (TRACE) System.out.println("WCMA mutate, aft: " + BeanInspector.toString(x)); // if (TRACE) System.out.println("WCMA mutate, aft: " + BeanInspector.toString(x));
} else { } else {

View File

@ -66,7 +66,7 @@ package eva2.optimization.operator.mutation;
// if (range[i][0] > x[i]) x[i] = range[i][0]; // if (range[i][0] > x[i]) x[i] = range[i][0];
// if (range[i][1] < x[i]) x[i] = range[i][1]; // if (range[i][1] < x[i]) x[i] = range[i][1];
// } // }
// ((InterfaceESIndividual)individual).SetDGenotype(x); // ((InterfaceESIndividual)individual).setDGenotype(x);
// //
// } // }
// //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor()); // //System.out.println("After Mutate: " +((GAIndividual)individual).getSolutionRepresentationFor());

View File

@ -797,9 +797,9 @@ public class PostProcess {
public static void setDoubleData(AbstractEAIndividual indy, double[] data) { public static void setDoubleData(AbstractEAIndividual indy, double[] data) {
if (indy instanceof InterfaceDataTypeDouble || (indy instanceof InterfaceESIndividual)) { if (indy instanceof InterfaceDataTypeDouble || (indy instanceof InterfaceESIndividual)) {
if (indy instanceof InterfaceESIndividual) { if (indy instanceof InterfaceESIndividual) {
((InterfaceESIndividual) indy).SetDGenotype(data); ((InterfaceESIndividual) indy).setDGenotype(data);
} else { } else {
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(data); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(data);
} }
} else { } else {
throw new RuntimeException("Error, unable to set double data to individual instance " + indy.getClass() + " in PostProcess.setDoubleData"); throw new RuntimeException("Error, unable to set double data to individual instance " + indy.getClass() + " in PostProcess.setDoubleData");

View File

@ -515,7 +515,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
Matrix rlhM = StatisticUtils.rlh(pop.size(), range, true); Matrix rlhM = StatisticUtils.rlh(pop.size(), range, true);
for (int i = 0; i < pop.size(); i++) { for (int i = 0; i < pop.size(); i++) {
AbstractEAIndividual tmpIndy = pop.getEAIndividual(i); AbstractEAIndividual tmpIndy = pop.getEAIndividual(i);
((InterfaceDataTypeDouble) tmpIndy).SetDoubleGenotype(rlhM.getRowShallow(i)); ((InterfaceDataTypeDouble) tmpIndy).setDoubleGenotype(rlhM.getRowShallow(i));
} }
} else { } else {
System.err.println("Error: data type double required for Population.createUniformSampling"); System.err.println("Error: data type double required for Population.createUniformSampling");
@ -2383,11 +2383,11 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
*/ */
public void updateRange(double[][] range, boolean forceRange) { public void updateRange(double[][] range, boolean forceRange) {
for (int i = 0; i < size(); i++) { for (int i = 0; i < size(); i++) {
((InterfaceDataTypeDouble) getEAIndividual(i)).SetDoubleRange(range); ((InterfaceDataTypeDouble) getEAIndividual(i)).setDoubleRange(range);
double[] pos = ((InterfaceDataTypeDouble) getEAIndividual(i)).getDoubleData(); double[] pos = ((InterfaceDataTypeDouble) getEAIndividual(i)).getDoubleData();
if (!Mathematics.isInRange(pos, range)) { if (!Mathematics.isInRange(pos, range)) {
Mathematics.projectToRange(pos, range); Mathematics.projectToRange(pos, range);
((InterfaceDataTypeDouble) getEAIndividual(i)).SetDoubleGenotype(pos); ((InterfaceDataTypeDouble) getEAIndividual(i)).setDoubleGenotype(pos);
} }
} }
} }

View File

@ -103,7 +103,7 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz
/* individuum moves towords untranslated problem */ /* individuum moves towords untranslated problem */
indyData[i] -= getTranslation(i, time); indyData[i] -= getTranslation(i, time);
} }
((InterfaceDataTypeDouble) individual).SetDoubleGenotype(indyData); ((InterfaceDataTypeDouble) individual).setDoubleGenotype(indyData);
} }
/* /*

View File

@ -55,7 +55,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
population.clear(); population.clear();
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.problemDimension); ((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.problemDimension);
((InterfaceDataTypeDouble) this.template).SetDoubleRange(makeRange()); ((InterfaceDataTypeDouble) this.template).setDoubleRange(makeRange());
for (int i = 0; i < population.getTargetSize(); i++) { for (int i = 0; i < population.getTargetSize(); i++) {
tmpIndy = (AbstractEAIndividual) ((AbstractEAIndividual) this.template).clone(); tmpIndy = (AbstractEAIndividual) ((AbstractEAIndividual) this.template).clone();
tmpIndy.init(this); tmpIndy.init(this);
@ -148,7 +148,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
protected void addOptimum(double[] point) { protected void addOptimum(double[] point) {
InterfaceDataTypeDouble tmpIndy; InterfaceDataTypeDouble tmpIndy;
tmpIndy = (InterfaceDataTypeDouble) ((AbstractEAIndividual) this.template).clone(); tmpIndy = (InterfaceDataTypeDouble) ((AbstractEAIndividual) this.template).clone();
tmpIndy.SetDoubleGenotype(point); tmpIndy.setDoubleGenotype(point);
((AbstractEAIndividual) tmpIndy).setFitness(evalUnnormalized(point)); ((AbstractEAIndividual) tmpIndy).setFitness(evalUnnormalized(point));
if (((AbstractEAIndividual) tmpIndy).getFitness(0) >= globalOptimum) { if (((AbstractEAIndividual) tmpIndy).getFitness(0) >= globalOptimum) {
globalOptimum = ((AbstractEAIndividual) tmpIndy).getFitness(0); globalOptimum = ((AbstractEAIndividual) tmpIndy).getFitness(0);
@ -166,7 +166,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
} }
if (isDoRotation()) { if (isDoRotation()) {
point = inverseRotateMaybe(point); // theres an inverse rotation required point = inverseRotateMaybe(point); // theres an inverse rotation required
tmpIndy.SetDoubleGenotype(point); tmpIndy.setDoubleGenotype(point);
} }
this.listOfOptima.add(tmpIndy); this.listOfOptima.add(tmpIndy);
} }

View File

@ -80,7 +80,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
((InterfaceDataTypeDouble) this.template) ((InterfaceDataTypeDouble) this.template)
.setDoubleDataLength(getProblemDimension()); .setDoubleDataLength(getProblemDimension());
((InterfaceDataTypeDouble) this.template) ((InterfaceDataTypeDouble) this.template)
.SetDoubleRange(makeRange()); .setDoubleRange(makeRange());
} }
} }
@ -136,7 +136,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
double[] fitness; double[] fitness;
x = getEvalArray(individual); x = getEvalArray(individual);
((InterfaceDataTypeDouble) individual).SetDoublePhenotype(x); ((InterfaceDataTypeDouble) individual).setDoublePhenotype(x);
// evaluate the vector // evaluate the vector
fitness = this.eval(x); fitness = this.eval(x);
// if indicated, add Gaussian noise // if indicated, add Gaussian noise
@ -427,11 +427,11 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
InterfaceDataTypeDouble tmpIndy; InterfaceDataTypeDouble tmpIndy;
tmpIndy = (InterfaceDataTypeDouble) prob.getIndividualTemplate() tmpIndy = (InterfaceDataTypeDouble) prob.getIndividualTemplate()
.clone(); .clone();
tmpIndy.SetDoubleGenotype(pos); tmpIndy.setDoubleGenotype(pos);
if (prob.isDoRotation()) { if (prob.isDoRotation()) {
pos = prob.inverseRotateMaybe(pos); // theres an inverse rotation pos = prob.inverseRotateMaybe(pos); // theres an inverse rotation
// required // required
tmpIndy.SetDoubleGenotype(pos); tmpIndy.setDoubleGenotype(pos);
} }
((AbstractEAIndividual) tmpIndy).setFitness(prob.eval(pos)); ((AbstractEAIndividual) tmpIndy).setFitness(prob.eval(pos));
if (!Mathematics.isInRange(pos, prob.makeRange())) { if (!Mathematics.isInRange(pos, prob.makeRange())) {
@ -453,7 +453,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
InterfaceDataTypeDouble tmpIndy; InterfaceDataTypeDouble tmpIndy;
tmpIndy = (InterfaceDataTypeDouble) prob.getIndividualTemplate() tmpIndy = (InterfaceDataTypeDouble) prob.getIndividualTemplate()
.clone(); .clone();
tmpIndy.SetDoubleGenotype(pos); tmpIndy.setDoubleGenotype(pos);
((AbstractEAIndividual) tmpIndy).setFitness(prob.eval(pos)); ((AbstractEAIndividual) tmpIndy).setFitness(prob.eval(pos));
pop.add(tmpIndy); pop.add(tmpIndy);
FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator( FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(

View File

@ -77,7 +77,7 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
public ExternalRuntimeProblem() { public ExternalRuntimeProblem() {
this.template = new ESIndividualDoubleData(); this.template = new ESIndividualDoubleData();
((ESIndividualDoubleData) this.template).setDoubleDataLength(m_ProblemDimension); ((ESIndividualDoubleData) this.template).setDoubleDataLength(m_ProblemDimension);
((ESIndividualDoubleData) this.template).SetDoubleRange(makeRange()); ((ESIndividualDoubleData) this.template).setDoubleRange(makeRange());
} }
public ExternalRuntimeProblem(ExternalRuntimeProblem b) { public ExternalRuntimeProblem(ExternalRuntimeProblem b) {
@ -153,7 +153,7 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
this.m_OverallBest = null; this.m_OverallBest = null;
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.m_ProblemDimension); ((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.m_ProblemDimension);
((InterfaceDataTypeDouble) this.template).SetDoubleRange(makeRange()); ((InterfaceDataTypeDouble) this.template).setDoubleRange(makeRange());
AbstractOptimizationProblem.defaultInitPopulation(population, template, this); AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
} }

View File

@ -315,7 +315,7 @@ public class F8Problem extends AbstractProblemDoubleOffset
// Population population = new Population(); // Population population = new Population();
// InterfaceDataTypeDouble tmpIndy; // InterfaceDataTypeDouble tmpIndy;
// tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.template).clone(); // tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.template).clone();
// tmpIndy.SetDoubleGenotype(pos); // tmpIndy.setDoubleGenotype(pos);
// ((AbstractEAIndividual)tmpIndy).SetFitness(eval(pos)); // ((AbstractEAIndividual)tmpIndy).SetFitness(eval(pos));
// population.add(tmpIndy); // population.add(tmpIndy);
// FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(1e-15, 10, false, true); // FitnessConvergenceTerminator convTerm = new FitnessConvergenceTerminator(1e-15, 10, false, true);

View File

@ -329,7 +329,7 @@ public class FLensProblem extends AbstractOptimizationProblem
range[i][0] = 0.1; range[i][0] = 0.1;
range[i][1] = 5.0; range[i][1] = 5.0;
} }
((InterfaceDataTypeDouble) this.template).SetDoubleRange(range); ((InterfaceDataTypeDouble) this.template).setDoubleRange(range);
AbstractOptimizationProblem.defaultInitPopulation(population, template, this); AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
if (this.m_Show) { if (this.m_Show) {

View File

@ -17,11 +17,11 @@ public class FM0Problem extends AbstractMultiModalProblemKnown implements Interf
this.problemDimension = 2; this.problemDimension = 2;
this.template = new ESIndividualDoubleData(); this.template = new ESIndividualDoubleData();
// this.m_Extrema = new double[2]; // this.m_Extrema = new double[2];
// this.m_Range = new double [this.problemDimension][2]; // this.range = new double [this.problemDimension][2];
// this.m_Range[0][0] = -2.0; // this.range[0][0] = -2.0;
// this.m_Range[0][1] = 2.0; // this.range[0][1] = 2.0;
// this.m_Range[1][0] = -2.8; // this.range[1][0] = -2.8;
// this.m_Range[1][1] = 2.8; // this.range[1][1] = 2.8;
// this.m_Extrema[0] = -2; // this.m_Extrema[0] = -2;
// this.m_Extrema[1] = 6; // this.m_Extrema[1] = 6;
} }

View File

@ -142,7 +142,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
} }
if (getProblemDimension() > 0) { // avoid evil case setting dim to 0 during object init if (getProblemDimension() > 0) { // avoid evil case setting dim to 0 during object init
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(getProblemDimension()); ((InterfaceDataTypeDouble) this.template).setDoubleDataLength(getProblemDimension());
((InterfaceDataTypeDouble) this.template).SetDoubleRange(range); ((InterfaceDataTypeDouble) this.template).setDoubleRange(range);
} }
break; break;
case typeBinary: case typeBinary:
@ -330,7 +330,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
private void setIndyGenotype(AbstractEAIndividual indy, double[] ds) { private void setIndyGenotype(AbstractEAIndividual indy, double[] ds) {
switch (dataType) { switch (dataType) {
case typeDouble: case typeDouble:
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(ds); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(ds);
break; break;
case typeBinary: case typeBinary:
((InterfaceDataTypeBinary) indy).SetBinaryGenotype(toBinary(ds)); ((InterfaceDataTypeBinary) indy).SetBinaryGenotype(toBinary(ds));

View File

@ -129,7 +129,7 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
} }
if (template instanceof InterfaceDataTypeDouble) { if (template instanceof InterfaceDataTypeDouble) {
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(simProb.getProblemDimension()); ((InterfaceDataTypeDouble) this.template).setDoubleDataLength(simProb.getProblemDimension());
((InterfaceDataTypeDouble) this.template).SetDoubleRange(makeRange()); ((InterfaceDataTypeDouble) this.template).setDoubleRange(makeRange());
} else if (template instanceof InterfaceDataTypeBinary) { } else if (template instanceof InterfaceDataTypeBinary) {
((InterfaceDataTypeBinary) this.template).setBinaryDataLength(simProb.getProblemDimension()); ((InterfaceDataTypeBinary) this.template).setBinaryDataLength(simProb.getProblemDimension());
} else { } else {

View File

@ -99,7 +99,7 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
double[][] newRange = makeRange(); double[][] newRange = makeRange();
((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.m_ProblemDimension); ((InterfaceDataTypeDouble) this.template).setDoubleDataLength(this.m_ProblemDimension);
((InterfaceDataTypeDouble) this.template).SetDoubleRange(newRange); ((InterfaceDataTypeDouble) this.template).setDoubleRange(newRange);
AbstractOptimizationProblem.defaultInitPopulation(population, template, this); AbstractOptimizationProblem.defaultInitPopulation(population, template, this);
} }

View File

@ -448,7 +448,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
if (forceRange) { if (forceRange) {
Mathematics.projectToRange(nX, esIndy.getDoubleRange()); Mathematics.projectToRange(nX, esIndy.getDoubleRange());
} // why did this never happen before? } // why did this never happen before?
esIndy.SetDoubleGenotype(nX); esIndy.setDoubleGenotype(nX);
indy.SetAge(0); indy.SetAge(0);
indy.resetConstraintViolation(); indy.resetConstraintViolation();
double[] fit = new double[1]; double[] fit = new double[1];

View File

@ -158,9 +158,9 @@ public class DynamicParticleSwarmOptimization extends ParticleSwarmOptimization
} }
if (indy instanceof InterfaceDataTypeDouble) { if (indy instanceof InterfaceDataTypeDouble) {
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(newPos); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(newPos);
} else { } else {
endy.SetDoubleGenotype(newPos); endy.setDoubleGenotype(newPos);
} }
resetFitness(indy); resetFitness(indy);

View File

@ -229,7 +229,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
} // end loop iterations } // end loop iterations
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(params); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(params);
} // end if ((this.problem instanceof InterfaceFirstOrderDerivableProblem) && (indy instanceof InterfaceDataTypeDouble)) { } // end if ((this.problem instanceof InterfaceFirstOrderDerivableProblem) && (indy instanceof InterfaceDataTypeDouble)) {
else { else {
@ -256,7 +256,7 @@ public class GradientDescentAlgorithm implements InterfaceOptimizer, java.io.Ser
if (TRACE) { if (TRACE) {
System.out.println("Gradient Descent: Fitness critical:" + indy.getFitness()[0]); System.out.println("Gradient Descent: Fitness critical:" + indy.getFitness()[0]);
} }
((InterfaceDataTypeDouble) indy).SetDoublePhenotype((double[]) indy.getData(oldParamsKey)); ((InterfaceDataTypeDouble) indy).setDoublePhenotype((double[]) indy.getData(oldParamsKey));
double[] changes = (double[]) indy.getData(changesKey); double[] changes = (double[]) indy.getData(changesKey);
int[] lock = (int[]) indy.getData(lockKey); int[] lock = (int[]) indy.getData(lockKey);

View File

@ -163,7 +163,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
} }
} }
// AbstractEAIndividual reflectedInd = (AbstractEAIndividual)((AbstractEAIndividual)bestpop.getIndividual(1)).clone(); // AbstractEAIndividual reflectedInd = (AbstractEAIndividual)((AbstractEAIndividual)bestpop.getIndividual(1)).clone();
// ((InterfaceDataTypeDouble)reflectedInd).SetDoubleGenotype(r); // ((InterfaceDataTypeDouble)reflectedInd).setDoubleGenotype(r);
// //
// problem.evaluate(reflectedInd); // problem.evaluate(reflectedInd);
AbstractEAIndividual reflectedInd = createEvalIndy(bestpop, r); AbstractEAIndividual reflectedInd = createEvalIndy(bestpop, r);
@ -199,7 +199,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
} }
// AbstractEAIndividual c_ind = (AbstractEAIndividual)((AbstractEAIndividual)bestpop.getIndividual(1)).clone(); // AbstractEAIndividual c_ind = (AbstractEAIndividual)((AbstractEAIndividual)bestpop.getIndividual(1)).clone();
// ((InterfaceDataTypeDouble)c_ind).SetDoubleGenotype(c); // ((InterfaceDataTypeDouble)c_ind).setDoubleGenotype(c);
// problem.evaluate(c_ind); // problem.evaluate(c_ind);
AbstractEAIndividual c_ind = createEvalIndy(bestpop, c); AbstractEAIndividual c_ind = createEvalIndy(bestpop, c);
this.m_Population.incrFunctionCalls(); this.m_Population.incrFunctionCalls();
@ -212,7 +212,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
private AbstractEAIndividual createEvalIndy(Population pop, double[] newGenotype) { private AbstractEAIndividual createEvalIndy(Population pop, double[] newGenotype) {
AbstractEAIndividual e_ind = (AbstractEAIndividual) ((AbstractEAIndividual) pop.getIndividual(1)).clone(); AbstractEAIndividual e_ind = (AbstractEAIndividual) ((AbstractEAIndividual) pop.getIndividual(1)).clone();
((InterfaceDataTypeDouble) e_ind).SetDoubleGenotype(newGenotype); ((InterfaceDataTypeDouble) e_ind).setDoubleGenotype(newGenotype);
e_ind.resetConstraintViolation(); e_ind.resetConstraintViolation();
m_Problem.evaluate(e_ind); m_Problem.evaluate(e_ind);
if (e_ind.getFitness(0) < 6000) { if (e_ind.getFitness(0) < 6000) {
@ -294,7 +294,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
if (!Mathematics.isInRange(x, range)) { if (!Mathematics.isInRange(x, range)) {
System.err.println("WARNING: nelder mead step produced indy out of range!"); System.err.println("WARNING: nelder mead step produced indy out of range!");
// Mathematics.projectToRange(x, range); // Mathematics.projectToRange(x, range);
// ((InterfaceDataTypeDouble)ind).SetDoubleGenotype(x); // ((InterfaceDataTypeDouble)ind).setDoubleGenotype(x);
// problem.evaluate(ind); // problem.evaluate(ind);
// this.m_Population.incrFunctionCalls(); // this.m_Population.incrFunctionCalls();
} }
@ -308,7 +308,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
for (int i = 0; i < c.length; i++) { for (int i = 0; i < c.length; i++) {
c[i] = 0.5 * c[i] + 0.5 * u_1[i]; c[i] = 0.5 * c[i] + 0.5 * u_1[i];
} }
((InterfaceDataTypeDouble) m_Population.getEAIndividual(j)).SetDoubleGenotype(c); ((InterfaceDataTypeDouble) m_Population.getEAIndividual(j)).setDoubleGenotype(c);
// m_Population.getEAIndividual(j).resetConstraintViolation(); // not a good idea because during evaluation, a stats update may be performed which mustnt see indies which are evaluated, but possible constraints have been reset. // m_Population.getEAIndividual(j).resetConstraintViolation(); // not a good idea because during evaluation, a stats update may be performed which mustnt see indies which are evaluated, but possible constraints have been reset.
} }
m_Problem.evaluate(m_Population); m_Problem.evaluate(m_Population);
@ -470,7 +470,7 @@ public class NelderMeadSimplex implements InterfaceOptimizer, Serializable, Inte
} else { } else {
dat[i] = Math.min(dat[i] + curPerturb, range[i][1]); dat[i] = Math.min(dat[i] + curPerturb, range[i][1]);
} }
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(dat); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(dat);
indy.resetConstraintViolation(); indy.resetConstraintViolation();
initialPop.add((AbstractEAIndividual) indy.clone()); initialPop.add((AbstractEAIndividual) indy.clone());
} }

View File

@ -414,7 +414,7 @@ public class PDDifferentialEvolution implements InterfaceOptimizer, java.io.Seri
if (forceRange) { if (forceRange) {
Mathematics.projectToRange(nX, esIndy.getDoubleRange()); Mathematics.projectToRange(nX, esIndy.getDoubleRange());
} // why did this never happen before? } // why did this never happen before?
esIndy.SetDoubleGenotype(nX); esIndy.setDoubleGenotype(nX);
indy.SetAge(0); indy.SetAge(0);
indy.resetConstraintViolation(); indy.resetConstraintViolation();
double[] fit = new double[1]; double[] fit = new double[1];

View File

@ -373,8 +373,8 @@ public class ParticleSubSwarmOptimization extends ParticleSwarmOptimizationGCPSO
minValInDim[i] = range[i][0]; // get lower boarder for dimension i minValInDim[i] = range[i][0]; // get lower boarder for dimension i
maxValInDim[i] = range[i][1]; // get upper boarder for dimension i maxValInDim[i] = range[i][1]; // get upper boarder for dimension i
} }
// min.SetDoubleGenotype(minValInDim); // set all dimensions to min // min.setDoubleGenotype(minValInDim); // set all dimensions to min
// max.SetDoubleGenotype(maxValInDim); // set all dimensions to max // max.setDoubleGenotype(maxValInDim); // set all dimensions to max
this.maxPosDist = Mathematics.euclidianDist(minValInDim, maxValInDim); this.maxPosDist = Mathematics.euclidianDist(minValInDim, maxValInDim);
} }

View File

@ -1253,16 +1253,16 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
// finally set the new position and the current velocity // finally set the new position and the current velocity
if (indy instanceof InterfaceDataTypeDouble) { if (indy instanceof InterfaceDataTypeDouble) {
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(newPosition); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(newPosition);
} else { } else {
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(newPosition); // WARNING, this does a checkBounds in any case! ((InterfaceDataTypeDouble) indy).setDoubleGenotype(newPosition); // WARNING, this does a checkBounds in any case!
if (!m_CheckRange) { if (!m_CheckRange) {
System.err.println("warning, checkbounds will be forced by InterfaceESIndividual!"); System.err.println("warning, checkbounds will be forced by InterfaceESIndividual!");
} }
} }
indy.putData(partVelKey, curVelocity); indy.putData(partVelKey, curVelocity);
// ((InterfaceESIndividual) indy).SetDGenotype(newPosition); // ((InterfaceESIndividual) indy).setDGenotype(newPosition);
} }
/** /**
@ -2228,7 +2228,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
System.err.println("partInfo: " + i + " - " + getParticleInfo(population.getEAIndividual(i))); System.err.println("partInfo: " + i + " - " + getParticleInfo(population.getEAIndividual(i)));
throw new RuntimeException("Mismatching best fitness!! " + personalBestfit[0] + " vs. " + ((InterfaceProblemDouble) m_Problem).eval(personalBestPos)[0]); throw new RuntimeException("Mismatching best fitness!! " + personalBestfit[0] + " vs. " + ((InterfaceProblemDouble) m_Problem).eval(personalBestPos)[0]);
} }
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(personalBestPos); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(personalBestPos);
indy.setFitness(personalBestfit); indy.setFitness(personalBestfit);
bests.add((AbstractEAIndividual) indy.clone()); bests.add((AbstractEAIndividual) indy.clone());
} }

View File

@ -187,7 +187,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
// public double eval(double[] x) { // public double eval(double[] x) {
// AbstractEAIndividual indy = (AbstractEAIndividual)template.clone(); // AbstractEAIndividual indy = (AbstractEAIndividual)template.clone();
// ((InterfaceDataTypeDouble)indy).SetDoubleGenotype(x); // ((InterfaceDataTypeDouble)indy).setDoubleGenotype(x);
// problem.evaluate(indy); // problem.evaluate(indy);
// return indy.getFitness(0); // return indy.getFitness(0);
// } // }
@ -554,7 +554,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
if (checkRange) { if (checkRange) {
Mathematics.projectToRange(combi, range); Mathematics.projectToRange(combi, range);
} }
((InterfaceDataTypeDouble) resIndy).SetDoubleGenotype(combi); ((InterfaceDataTypeDouble) resIndy).setDoubleGenotype(combi);
problem.evaluate(resIndy); problem.evaluate(resIndy);
refSet.incrFunctionCalls(); refSet.incrFunctionCalls();
return resIndy; return resIndy;
@ -673,7 +673,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
freq[i][interv]++; freq[i][interv]++;
} }
dblIndy.SetDoubleGenotype(genes); dblIndy.setDoubleGenotype(genes);
return indy; return indy;
} }
@ -717,7 +717,7 @@ public class ScatterSearch implements InterfaceOptimizer, java.io.Serializable,
for (int i = 0; i < probDim; i++) { for (int i = 0; i < probDim; i++) {
genes[i] = randInRangeInterval(i, interval); genes[i] = randInRangeInterval(i, interval);
} }
dblIndy.SetDoubleGenotype(genes); dblIndy.setDoubleGenotype(genes);
return indy; return indy;
} }

View File

@ -253,7 +253,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
if (bestMemPos.firstIsBetter(bestMemPos.getFitness(), bestExp.getFitness())) { if (bestMemPos.firstIsBetter(bestMemPos.getFitness(), bestExp.getFitness())) {
AbstractEAIndividual indy = (AbstractEAIndividual) bestExp.clone(); AbstractEAIndividual indy = (AbstractEAIndividual) bestExp.clone();
indy.setFitness(bestMemPos.getFitness()); indy.setFitness(bestMemPos.getFitness());
((InterfaceDataTypeDouble) indy).SetDoubleGenotype(bestMemPos.getPos()); ((InterfaceDataTypeDouble) indy).setDoubleGenotype(bestMemPos.getPos());
return indy; return indy;
} else { } else {
return bestExp; return bestExp;
@ -609,7 +609,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
} }
TribesExplorer indy = tmp.clone(); TribesExplorer indy = tmp.clone();
indy.clearPosVel(); indy.clearPosVel();
indy.SetDoubleGenotype(pos.getPos()); indy.setDoubleGenotype(pos.getPos());
indy.setFitness(pos.getFitness()); indy.setFitness(pos.getFitness());
return indy; return indy;
} }

View File

@ -41,7 +41,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
public TribesExplorer(double[][] range, double objFirstDim) { public TribesExplorer(double[][] range, double objFirstDim) {
init(range.length, Tribes.maxTribeNb); init(range.length, Tribes.maxTribeNb);
SetDoubleRange(range); setDoubleRange(range);
objectiveValueFirstDim = objFirstDim; objectiveValueFirstDim = objFirstDim;
} }
@ -981,7 +981,7 @@ v[d] = cmin * v[d];
if (x.length != position.x.length) { if (x.length != position.x.length) {
System.err.println("Init value and requested length doesn't match!"); System.err.println("Init value and requested length doesn't match!");
} }
this.SetDoubleGenotype(x); this.setDoubleGenotype(x);
} else { } else {
this.init(opt); this.init(opt);
System.err.println("Initial value for ESIndividualDoubleData is not double[]!"); System.err.println("Initial value for ESIndividualDoubleData is not double[]!");
@ -1000,17 +1000,17 @@ v[d] = cmin * v[d];
} }
@Override @Override
public void SetDoublePhenotype(double[] doubleData) { public void setDoublePhenotype(double[] doubleData) {
position.setDoubleArray(doubleData); position.setDoubleArray(doubleData);
} }
@Override @Override
public void SetDoubleGenotype(double[] doubleData) { public void setDoubleGenotype(double[] doubleData) {
position.setDoubleArray(doubleData); position.setDoubleArray(doubleData);
} }
@Override @Override
public void SetDoubleRange(double[][] range) { public void setDoubleRange(double[][] range) {
if (position.x.length != range.length) { // we will need to fully reinit the particle if (position.x.length != range.length) { // we will need to fully reinit the particle
initPositions(range.length); initPositions(range.length);
} }
@ -1048,7 +1048,7 @@ v[d] = cmin * v[d];
return position.x.length; return position.x.length;
} }
// public void SetDGenotype(double[] b) { // public void setDGenotype(double[] b) {
// position.setDoubleArray(b); // position.setDoubleArray(b);
// } // }
// //

View File

@ -599,7 +599,7 @@ public class TribesSwarm implements java.io.Serializable {
*/ */
TribesExplorer expl = new TribesExplorer(range, masterTribe.getObjectiveFirstDim()); TribesExplorer expl = new TribesExplorer(range, masterTribe.getObjectiveFirstDim());
expl.SetDoubleRange(range); expl.setDoubleRange(range);
// System.out.println("generating expl, option " + option + ", init " + initType + ", from tribe " + fromTribe); // System.out.println("generating expl, option " + option + ", init " + initType + ", from tribe " + fromTribe);