Refactored "SetFitness" function to "setFitness". Coding Standards for the win.
This commit is contained in:
parent
0f553039e4
commit
cb357417a2
@ -36,7 +36,7 @@ public interface IndividualInterface {
|
|||||||
*
|
*
|
||||||
* @param fit new fitness of the individual
|
* @param fit new fitness of the individual
|
||||||
*/
|
*/
|
||||||
void SetFitness (double[] fit);
|
void setFitness (double[] fit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the instance is dominating the given other individual and return
|
* Check whether the instance is dominating the given other individual and return
|
||||||
|
@ -618,7 +618,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
|
|||||||
* @param fitness The new fitness array
|
* @param fitness The new fitness array
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public void SetFitness(double[] fitness) {
|
public void setFitness(double[] fitness) {
|
||||||
this.m_Fitness = fitness;
|
this.m_Fitness = fitness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class ArchivingMaxiMin implements InterfaceArchiving, java.io.Serializabl
|
|||||||
// now unconvert from SO to MO
|
// now unconvert from SO to MO
|
||||||
for (int i = 0; i < archive.size(); i++) {
|
for (int i = 0; i < archive.size(); i++) {
|
||||||
tmpD = (double[])((AbstractEAIndividual)archive.get(i)).getData("MOFitness");
|
tmpD = (double[])((AbstractEAIndividual)archive.get(i)).getData("MOFitness");
|
||||||
((AbstractEAIndividual)archive.get(i)).SetFitness(tmpD);
|
((AbstractEAIndividual)archive.get(i)).setFitness(tmpD);
|
||||||
}
|
}
|
||||||
|
|
||||||
pop.SetArchive(archive);
|
pop.SetArchive(archive);
|
||||||
|
@ -280,7 +280,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) ((InterfaceDataTypeDouble)tmpIndy).SetDoubleGenotype(p);
|
if (m_UseSearchSpace) ((InterfaceDataTypeDouble)tmpIndy).SetDoubleGenotype(p);
|
||||||
else tmpIndy.SetFitness(p);
|
else tmpIndy.setFitness(p);
|
||||||
|
|
||||||
return metric.distance(indy, tmpIndy);
|
return metric.distance(indy, tmpIndy);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class MOSODynamicallyWeightedFitness implements InterfaceMOSOConverter, j
|
|||||||
|
|
||||||
for (int i = 0; (i <2) && (i < tmpFit.length); i++)
|
for (int i = 0; (i <2) && (i < tmpFit.length); i++)
|
||||||
resultFit[0] += tmpFit[i]*weights[i];
|
resultFit[0] += tmpFit[i]*weights[i];
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -59,7 +59,7 @@ public class MOSOEpsilonConstraint implements InterfaceMOSOConverter, java.io.Se
|
|||||||
indy.addConstraintViolation(Math.max(0, tmpFit[i] - this.m_EpsilonConstraint.m_TargetValue[i]));
|
indy.addConstraintViolation(Math.max(0, tmpFit[i] - this.m_EpsilonConstraint.m_TargetValue[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -78,7 +78,7 @@ public class MOSOEpsilonThreshold implements InterfaceMOSOConverter, java.io.Ser
|
|||||||
if (new Double(tmpFit[i]).isNaN()) System.out.println("-Fitness is NaN");
|
if (new Double(tmpFit[i]).isNaN()) System.out.println("-Fitness is NaN");
|
||||||
if (new Double(tmpFit[i]).isInfinite()) System.out.println("-Fitness is Infinite");
|
if (new Double(tmpFit[i]).isInfinite()) System.out.println("-Fitness is Infinite");
|
||||||
}
|
}
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -54,7 +54,7 @@ public class MOSOGoalProgramming implements InterfaceMOSOConverter, java.io.Seri
|
|||||||
resultFit[0] = 0;
|
resultFit[0] = 0;
|
||||||
for (int i = 0; (i < this.m_Goals.getNumRows()) && (i < tmpFit.length) ; i++)
|
for (int i = 0; (i < this.m_Goals.getNumRows()) && (i < tmpFit.length) ; i++)
|
||||||
resultFit[0] += tmpFit[i]-this.m_Goals.getValue(i, 0);
|
resultFit[0] += tmpFit[i]-this.m_Goals.getValue(i, 0);
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -68,7 +68,7 @@ public class MOSOLpMetric implements InterfaceMOSOConverter, java.io.Serializabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -57,7 +57,7 @@ public class MOSOMOGARankBased implements InterfaceMOSOConverter, java.io.Serial
|
|||||||
tmpFit = indy.getFitness();
|
tmpFit = indy.getFitness();
|
||||||
indy.putData("MOFitness", tmpFit);
|
indy.putData("MOFitness", tmpFit);
|
||||||
resultFit[0] = ((Integer)indy.getData("MOGARank")).doubleValue();
|
resultFit[0] = ((Integer)indy.getData("MOGARank")).doubleValue();
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -65,7 +65,7 @@ public class MOSOMaxiMin implements InterfaceMOSOConverter, java.io.Serializable
|
|||||||
tmpIndy.putData("MOFitness", tmpFit);
|
tmpIndy.putData("MOFitness", tmpFit);
|
||||||
resultFit = new double[1];
|
resultFit = new double[1];
|
||||||
resultFit[0] = result[i];
|
resultFit[0] = result[i];
|
||||||
tmpIndy.SetFitness(resultFit);
|
tmpIndy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
// if (false) {
|
// if (false) {
|
||||||
@ -106,7 +106,7 @@ public class MOSOMaxiMin implements InterfaceMOSOConverter, java.io.Serializable
|
|||||||
indy.putData("MOFitness", tmpFit);
|
indy.putData("MOFitness", tmpFit);
|
||||||
System.err.println("The MaxiMin MOSO can not be applied to single individuals! I default to random criterion.");
|
System.err.println("The MaxiMin MOSO can not be applied to single individuals! I default to random criterion.");
|
||||||
resultFit[0] = tmpFit[RNG.randomInt(0, tmpFit.length)];
|
resultFit[0] = tmpFit[RNG.randomInt(0, tmpFit.length)];
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -47,7 +47,7 @@ public class MOSORandomChoice implements InterfaceMOSOConverter, java.io.Serial
|
|||||||
tmpFit = indy.getFitness();
|
tmpFit = indy.getFitness();
|
||||||
indy.putData("MOFitness", tmpFit);
|
indy.putData("MOFitness", tmpFit);
|
||||||
resultFit[0] = tmpFit[RNG.randomInt(0, tmpFit.length-1)];
|
resultFit[0] = tmpFit[RNG.randomInt(0, tmpFit.length-1)];
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -57,7 +57,7 @@ public class MOSORandomWeight implements InterfaceMOSOConverter, java.io.Seriali
|
|||||||
}
|
}
|
||||||
for (int i = 0; (i < tmpWeight.length) && (i < tmpFit.length) ; i++)
|
for (int i = 0; (i < tmpWeight.length) && (i < tmpFit.length) ; i++)
|
||||||
resultFit[0] += tmpFit[i]*tmpWeight[i];
|
resultFit[0] += tmpFit[i]*tmpWeight[i];
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -46,7 +46,7 @@ public class MOSORankbased implements InterfaceMOSOConverter, java.io.Serializab
|
|||||||
tmpFit = indy.getFitness();
|
tmpFit = indy.getFitness();
|
||||||
indy.putData("MOFitness", tmpFit);
|
indy.putData("MOFitness", tmpFit);
|
||||||
resultFit[0] = ((Integer)indy.getData("ParetoLevel")).doubleValue();
|
resultFit[0] = ((Integer)indy.getData("ParetoLevel")).doubleValue();
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -59,7 +59,7 @@ public class MOSOUtilityFunction implements InterfaceMOSOConverter, java.io.Seri
|
|||||||
/**********************************************************************************************
|
/**********************************************************************************************
|
||||||
* and don't forget to set the reduced fitness to the individual
|
* and don't forget to set the reduced fitness to the individual
|
||||||
*/
|
*/
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -61,7 +61,7 @@ public class MOSOWeightedFitness implements InterfaceMOSOConverter, java.io.Seri
|
|||||||
indy.putData("MOFitness", tmpFit);
|
indy.putData("MOFitness", tmpFit);
|
||||||
for (int i = 0; (i < this.m_Weights.getNumRows()) && (i < tmpFit.length) ; i++)
|
for (int i = 0; (i < this.m_Weights.getNumRows()) && (i < tmpFit.length) ; i++)
|
||||||
resultFit[0] += tmpFit[i]*this.m_Weights.getValue(i,0);
|
resultFit[0] += tmpFit[i]*this.m_Weights.getValue(i,0);
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkingWeights() {
|
private void checkingWeights() {
|
||||||
|
@ -65,7 +65,7 @@ public class MOSOWeightedLPTchebycheff implements InterfaceMOSOConverter, java.i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.m_WLPT.m_P > 0) resultFit[0] = Math.pow(resultFit[0], 1/((double)this.m_WLPT.m_P));
|
if (this.m_WLPT.m_P > 0) resultFit[0] = Math.pow(resultFit[0], 1/((double)this.m_WLPT.m_P));
|
||||||
indy.SetFitness(resultFit);
|
indy.setFitness(resultFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method allows the problem to set the current output size of
|
/** This method allows the problem to set the current output size of
|
||||||
|
@ -115,7 +115,7 @@ public class MetricS implements InterfaceParetoFrontMetric, java.io.Serializable
|
|||||||
redF = new double[tmpF.length -1];
|
redF = new double[tmpF.length -1];
|
||||||
for (int j = 0; j < redF.length; j++) redF[j] = tmpF[j];
|
for (int j = 0; j < redF.length; j++) redF[j] = tmpF[j];
|
||||||
tmpIndy = new ESIndividualDoubleData();
|
tmpIndy = new ESIndividualDoubleData();
|
||||||
tmpIndy.SetFitness(redF);
|
tmpIndy.setFitness(redF);
|
||||||
smPop.add(i, tmpIndy);
|
smPop.add(i, tmpIndy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
|
|||||||
tmpPop.clear();
|
tmpPop.clear();
|
||||||
for (int i = 0; i < this.m_Reference.length; i++) {
|
for (int i = 0; i < this.m_Reference.length; i++) {
|
||||||
tmpIndy = new ESIndividualDoubleData();
|
tmpIndy = new ESIndividualDoubleData();
|
||||||
tmpIndy.SetFitness(this.m_Reference[i]);
|
tmpIndy.setFitness(this.m_Reference[i]);
|
||||||
tmpPop.addIndividual(tmpIndy);
|
tmpPop.addIndividual(tmpIndy);
|
||||||
}
|
}
|
||||||
this.m_ReferenceSMetric = this.calculateSMetric(tmpPop, this.m_ObjectiveSpaceRange, this.m_ObjectiveSpaceRange.length);
|
this.m_ReferenceSMetric = this.calculateSMetric(tmpPop, this.m_ObjectiveSpaceRange, this.m_ObjectiveSpaceRange.length);
|
||||||
@ -149,7 +149,7 @@ public class MetricSWithReference implements InterfaceParetoFrontMetric, java.io
|
|||||||
redF = new double[tmpF.length -1];
|
redF = new double[tmpF.length -1];
|
||||||
for (int j = 0; j < redF.length; j++) redF[j] = tmpF[j];
|
for (int j = 0; j < redF.length; j++) redF[j] = tmpF[j];
|
||||||
tmpIndy = new ESIndividualDoubleData();
|
tmpIndy = new ESIndividualDoubleData();
|
||||||
tmpIndy.SetFitness(redF);
|
tmpIndy.setFitness(redF);
|
||||||
smPop.add(i, tmpIndy);
|
smPop.add(i, tmpIndy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,11 +77,11 @@ public class SelectMOMAIIDominanceCounter implements InterfaceSelection, java.io
|
|||||||
malta.m_SizeDominantSolutions = domCount;
|
malta.m_SizeDominantSolutions = domCount;
|
||||||
double[] fitness = new double[1];
|
double[] fitness = new double[1];
|
||||||
fitness[0] = 1/((double)(domCount+1));
|
fitness[0] = 1/((double)(domCount+1));
|
||||||
tmpIndy1.SetFitness(fitness);
|
tmpIndy1.setFitness(fitness);
|
||||||
} else {
|
} else {
|
||||||
double[] fitness = new double[1];
|
double[] fitness = new double[1];
|
||||||
fitness[0] = 2;
|
fitness[0] = 2;
|
||||||
tmpIndy1.SetFitness(fitness);
|
tmpIndy1.setFitness(fitness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class SelectMOMaxiMin implements InterfaceSelection, java.io.Serializable
|
|||||||
// now unconvert from SO to MO
|
// now unconvert from SO to MO
|
||||||
for (int i = 0; i < result.size(); i++) {
|
for (int i = 0; i < result.size(); i++) {
|
||||||
tmpD = (double[])((AbstractEAIndividual)result.get(i)).getData("MOFitness");
|
tmpD = (double[])((AbstractEAIndividual)result.get(i)).getData("MOFitness");
|
||||||
((AbstractEAIndividual)result.get(i)).SetFitness(tmpD);
|
((AbstractEAIndividual)result.get(i)).setFitness(tmpD);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class SelectMOSPEAII implements InterfaceSelection, java.io.Serializable
|
|||||||
orgFit[i] = ((AbstractEAIndividual)population.get(i)).getFitness();
|
orgFit[i] = ((AbstractEAIndividual)population.get(i)).getFitness();
|
||||||
newFit = new double[1];
|
newFit = new double[1];
|
||||||
newFit[0] = this.m_SPEAFitness[i];
|
newFit[0] = this.m_SPEAFitness[i];
|
||||||
((AbstractEAIndividual)population.get(i)).SetFitness(newFit);
|
((AbstractEAIndividual)population.get(i)).setFitness(newFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// then select
|
// then select
|
||||||
@ -72,7 +72,7 @@ public class SelectMOSPEAII implements InterfaceSelection, java.io.Serializable
|
|||||||
|
|
||||||
// finally replace the fitness with the original
|
// finally replace the fitness with the original
|
||||||
for (int i = 0; i < population.size(); i++) {
|
for (int i = 0; i < population.size(); i++) {
|
||||||
((AbstractEAIndividual)population.get(i)).SetFitness(orgFit[i]);
|
((AbstractEAIndividual)population.get(i)).setFitness(orgFit[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
|
@ -680,7 +680,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
AbstractEAIndividual indy;
|
AbstractEAIndividual indy;
|
||||||
for (int i = 0; i < size(); i++) {
|
for (int i = 0; i < size(); i++) {
|
||||||
indy = getEAIndividual(i);
|
indy = getEAIndividual(i);
|
||||||
indy.SetFitness(f.clone());
|
indy.setFitness(f.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,7 +882,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
public void resetFitness(IndividualInterface indy) {
|
public void resetFitness(IndividualInterface indy) {
|
||||||
double[] tmpFit = indy.getFitness();
|
double[] tmpFit = indy.getFitness();
|
||||||
java.util.Arrays.fill(tmpFit, Double.MAX_VALUE);
|
java.util.Arrays.fill(tmpFit, Double.MAX_VALUE);
|
||||||
indy.SetFitness(tmpFit);
|
indy.setFitness(tmpFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2150,7 +2150,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
AbstractEAIndividual indy = (AbstractEAIndividual) getEAIndividual(0).clone();
|
AbstractEAIndividual indy = (AbstractEAIndividual) getEAIndividual(0).clone();
|
||||||
double[] center = getCenter();
|
double[] center = getCenter();
|
||||||
AbstractEAIndividual.setDoublePosition(indy, center);
|
AbstractEAIndividual.setDoublePosition(indy, center);
|
||||||
indy.SetFitness(null);
|
indy.setFitness(null);
|
||||||
return indy;
|
return indy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz
|
|||||||
AbstractEAIndividual tussy = (AbstractEAIndividual)individual.clone();
|
AbstractEAIndividual tussy = (AbstractEAIndividual)individual.clone();
|
||||||
transform(tussy, time);
|
transform(tussy, time);
|
||||||
getProblem().evaluate(tussy);
|
getProblem().evaluate(tussy);
|
||||||
individual.SetFitness(tussy.getFitness());
|
individual.setFitness(tussy.getFitness());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,7 +180,7 @@ implements Interface2DBorderProblem, InterfaceMultimodalProblemKnown {
|
|||||||
InterfaceDataTypeDouble tmpIndy;
|
InterfaceDataTypeDouble tmpIndy;
|
||||||
tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.m_Template).clone();
|
tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.m_Template).clone();
|
||||||
tmpIndy.SetDoubleGenotype(point);
|
tmpIndy.SetDoubleGenotype(point);
|
||||||
((AbstractEAIndividual)tmpIndy).SetFitness(evalUnnormalized(point));
|
((AbstractEAIndividual)tmpIndy).setFitness(evalUnnormalized(point));
|
||||||
if (((AbstractEAIndividual)tmpIndy).getFitness(0)>=m_GlobalOpt) {
|
if (((AbstractEAIndividual)tmpIndy).getFitness(0)>=m_GlobalOpt) {
|
||||||
m_GlobalOpt = ((AbstractEAIndividual)tmpIndy).getFitness(0);
|
m_GlobalOpt = ((AbstractEAIndividual)tmpIndy).getFitness(0);
|
||||||
if (makeGlobalOptUnreachable) {
|
if (makeGlobalOptUnreachable) {
|
||||||
|
@ -41,7 +41,7 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
|
|||||||
// evaluate the fitness
|
// evaluate the fitness
|
||||||
result = eval(tmpBitSet);
|
result = eval(tmpBitSet);
|
||||||
// set the fitness
|
// set the fitness
|
||||||
individual.SetFitness(result);
|
individual.setFitness(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,7 +204,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
*/
|
*/
|
||||||
protected void setEvalFitness(AbstractEAIndividual individual, double[] x,
|
protected void setEvalFitness(AbstractEAIndividual individual, double[] x,
|
||||||
double[] fit) {
|
double[] fit) {
|
||||||
individual.SetFitness(fit);
|
individual.setFitness(fit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -441,7 +441,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
// 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())) {
|
||||||
System.err.println("Warning, add optimum which is out of range!");
|
System.err.println("Warning, add optimum which is out of range!");
|
||||||
}
|
}
|
||||||
@ -462,7 +462,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
|
|||||||
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(
|
||||||
1e-25, 10, StagnationTypeEnum.generationBased,
|
1e-25, 10, StagnationTypeEnum.generationBased,
|
||||||
|
@ -180,7 +180,7 @@ implements Interface2DBorderProblem, InterfaceProblemDouble, InterfaceHasInitRan
|
|||||||
x = getXVector(individual);
|
x = getXVector(individual);
|
||||||
|
|
||||||
double[] fit = eval(x);
|
double[] fit = eval(x);
|
||||||
individual.SetFitness(fit);
|
individual.setFitness(fit);
|
||||||
|
|
||||||
// if (this.m_UseTestConstraint) {
|
// if (this.m_UseTestConstraint) {
|
||||||
// if (x[0] < 1) individual.addConstraintViolation(1-x[0]);
|
// if (x[0] < 1) individual.addConstraintViolation(1-x[0]);
|
||||||
|
@ -56,7 +56,7 @@ class MyLensViewer extends JPanel implements InterfaceSolutionViewer {
|
|||||||
// this.m_BestFitness = Double.POSITIVE_INFINITY;
|
// this.m_BestFitness = Double.POSITIVE_INFINITY;
|
||||||
// this.m_BestVariables = new double[10];
|
// this.m_BestVariables = new double[10];
|
||||||
ESIndividualDoubleData dummy = new ESIndividualDoubleData();
|
ESIndividualDoubleData dummy = new ESIndividualDoubleData();
|
||||||
dummy.SetFitness(new double[]{Double.POSITIVE_INFINITY});
|
dummy.setFitness(new double[]{Double.POSITIVE_INFINITY});
|
||||||
indiesToPaint = new Population();
|
indiesToPaint = new Population();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
|||||||
for (int i=0; i<seedData.length; i++) {
|
for (int i=0; i<seedData.length; i++) {
|
||||||
AbstractEAIndividual indy = (AbstractEAIndividual)m_Template.clone();
|
AbstractEAIndividual indy = (AbstractEAIndividual)m_Template.clone();
|
||||||
setIndyGenotype(indy, seedData[i]);
|
setIndyGenotype(indy, seedData[i]);
|
||||||
indy.SetFitness(seedDataFit[i]);
|
indy.setFitness(seedDataFit[i]);
|
||||||
seedPopulation.add(indy);
|
seedPopulation.add(indy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -620,7 +620,7 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
|
|||||||
double[] res = handler.requestEval(this, AbstractEAIndividual.getIndyData(indy));
|
double[] res = handler.requestEval(this, AbstractEAIndividual.getIndyData(indy));
|
||||||
log("evaluated to " + BeanInspector.toString(res) + "\n");
|
log("evaluated to " + BeanInspector.toString(res) + "\n");
|
||||||
log("Free mem is " + Runtime.getRuntime().freeMemory() + ", time is " + System.currentTimeMillis() + "\n");
|
log("Free mem is " + Runtime.getRuntime().freeMemory() + ", time is " + System.currentTimeMillis() + "\n");
|
||||||
indy.SetFitness(res);
|
indy.setFitness(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,7 +60,7 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
|||||||
// if indicated, add Gaussian noise
|
// if indicated, add Gaussian noise
|
||||||
if (m_Noise != 0) RNG.addNoise(fitness, m_Noise);
|
if (m_Noise != 0) RNG.addNoise(fitness, m_Noise);
|
||||||
// set the fitness
|
// set the fitness
|
||||||
individual.SetFitness(fitness);
|
individual.setFitness(fitness);
|
||||||
} else if (simProb instanceof SimpleProblemBinary) {
|
} else if (simProb instanceof SimpleProblemBinary) {
|
||||||
BitSet tmpBitSet;
|
BitSet tmpBitSet;
|
||||||
double[] result;
|
double[] result;
|
||||||
@ -69,7 +69,7 @@ public class SimpleProblemWrapper extends AbstractOptimizationProblem {
|
|||||||
// evaluate the fitness
|
// evaluate the fitness
|
||||||
result = ((SimpleProblemBinary)simProb).eval(tmpBitSet);
|
result = ((SimpleProblemBinary)simProb).eval(tmpBitSet);
|
||||||
// set the fitness
|
// set the fitness
|
||||||
individual.SetFitness(result);
|
individual.setFitness(result);
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Error in SimpleProblemWrapper: " + simProb.getClass().getName() + " is unknown type!");
|
System.err.println("Error in SimpleProblemWrapper: " + simProb.getClass().getName() + " is unknown type!");
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
|
|||||||
indy.resetConstraintViolation();
|
indy.resetConstraintViolation();
|
||||||
double[] fit = new double[1];
|
double[] fit = new double[1];
|
||||||
fit[0] = 0;
|
fit[0] = 0;
|
||||||
indy.SetFitness(fit);
|
indy.setFitness(fit);
|
||||||
if (parents != null) indy.setParents(parents);
|
if (parents != null) indy.setParents(parents);
|
||||||
return indy;
|
return indy;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ public class MemeticAlgorithm implements InterfaceOptimizer,
|
|||||||
try {
|
try {
|
||||||
AbstractEAIndividual newindy = (AbstractEAIndividual) antilamarckismcache
|
AbstractEAIndividual newindy = (AbstractEAIndividual) antilamarckismcache
|
||||||
.get(indy);
|
.get(indy);
|
||||||
indy.SetFitness(newindy.getFitness());
|
indy.setFitness(newindy.getFitness());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.err.println("individual not found in antilamarckismcache");
|
System.err.println("individual not found in antilamarckismcache");
|
||||||
}
|
}
|
||||||
|
@ -2228,7 +2228,7 @@ public class ParticleSwarmOptimization implements InterfaceOptimizer, java.io.Se
|
|||||||
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());
|
||||||
}
|
}
|
||||||
return bests;
|
return bests;
|
||||||
|
@ -253,7 +253,7 @@ public class Tribes implements InterfaceOptimizer, java.io.Serializable {
|
|||||||
AbstractEAIndividual bestExp = population.getBestEAIndividual();
|
AbstractEAIndividual bestExp = population.getBestEAIndividual();
|
||||||
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 return bestExp;
|
} else return bestExp;
|
||||||
@ -688,7 +688,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,9 +94,9 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
|
|||||||
* Be aware that for a TribesExplorer, an objective value might be taken into account
|
* Be aware that for a TribesExplorer, an objective value might be taken into account
|
||||||
* by reducing the fitness (in the first dimension).
|
* by reducing the fitness (in the first dimension).
|
||||||
*/
|
*/
|
||||||
public void SetFitness(double[] fitness) {
|
public void setFitness(double[] fitness) {
|
||||||
position.fitness = fitness;
|
position.fitness = fitness;
|
||||||
super.SetFitness(fitness);
|
super.setFitness(fitness);
|
||||||
fitness[0] -= objectiveValueFirstDim;
|
fitness[0] -= objectiveValueFirstDim;
|
||||||
position.setTotalError();
|
position.setTotalError();
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class DeNovofilter {
|
|||||||
tmpD[i-2] = new Double(tmpS[i]).doubleValue();
|
tmpD[i-2] = new Double(tmpS[i]).doubleValue();
|
||||||
}
|
}
|
||||||
indy = new ESIndividualDoubleData();
|
indy = new ESIndividualDoubleData();
|
||||||
indy.SetFitness(tmpD);
|
indy.setFitness(tmpD);
|
||||||
pop.add(indy);
|
pop.add(indy);
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
|
@ -124,7 +124,7 @@ public class ImpactOfDimensionOnMOEAs {
|
|||||||
if (j < x.length) fitness[j] =1/((double)fitness[j]) + x[j];
|
if (j < x.length) fitness[j] =1/((double)fitness[j]) + x[j];
|
||||||
else fitness[j] =1/((double)fitness[j]) + x[j%objectives] + x[(j+1)%objectives];
|
else fitness[j] =1/((double)fitness[j]) + x[j%objectives] + x[(j+1)%objectives];
|
||||||
}
|
}
|
||||||
((AbstractEAIndividual)pop.get(i)).SetFitness(fitness);
|
((AbstractEAIndividual)pop.get(i)).setFitness(fitness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user