Commit e9af3216 authored by Fabian Becker's avatar Fabian Becker

Rename SetFitness to setFitnessAt

parent 9fa92280
......@@ -546,7 +546,7 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
* @param index The index of the fitness value to set.
* @param fitness The new fitness value.
*/
public void SetFitness(int index, double fitness) {
public void setFitnessAt(int index, double fitness) {
if (this.fitness.length > index) {
this.fitness[index] = fitness;
} else {
......
......@@ -81,7 +81,7 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S
if (v > 0) {
indy.setMarkPenalized(true);
for (int i = 0; i < indy.getFitness().length; i++) {
indy.SetFitness(i, indy.getFitness(i) + v + penaltyFactor);
indy.setFitnessAt(i, indy.getFitness(i) + v + penaltyFactor);
}
}
break;
......@@ -89,7 +89,7 @@ public abstract class AbstractConstraint implements InterfaceDoubleConstraint, S
if (v > 0) {
indy.setMarkPenalized(true);
for (int i = 0; i < indy.getFitness().length; i++) {
indy.SetFitness(i, indy.getFitness(i) * (v + penaltyFactor));
indy.setFitnessAt(i, indy.getFitness(i) * (v + penaltyFactor));
}
}
case specificTag:
......
......@@ -57,7 +57,7 @@ public class FitnessAdaptiveClustering implements java.io.Serializable, Interfac
}
for (int i = 0; i < population.size(); i++) {
population.get(i).SetFitness(x, result[i]);
population.get(i).setFitnessAt(x, result[i]);
}
}
}
......
......@@ -62,7 +62,7 @@ public class FitnessSharing implements java.io.Serializable, InterfaceFitnessMod
}
for (int i = 0; i < population.size(); i++) {
population.get(i).SetFitness(x, result[i]);
population.get(i).setFitnessAt(x, result[i]);
}
}
}
......
......@@ -86,7 +86,7 @@ public class SteadyStateGA extends AbstractOptimizer implements java.io.Serializ
GAIndividualBinaryData tmpIndy;
for (int i = 0; i < population.size(); i++) {
tmpIndy = (GAIndividualBinaryData) population.get(i);
tmpIndy.SetFitness(0, tmpIndy.defaultEvaulateAsMiniBits());
tmpIndy.setFitnessAt(0, tmpIndy.defaultEvaulateAsMiniBits());
population.incrFunctionCalls();
}
population.incrGeneration();
......
......@@ -108,8 +108,8 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
* by reducing the fitness (in the first dimension).
*/
@Override
public void SetFitness(int index, double fitness) {
super.SetFitness(index, fitness);
public void setFitnessAt(int index, double fitness) {
super.setFitnessAt(index, fitness);
if (index > position.fitness.length) {
double[] newFit = new double[index + 1];
System.arraycopy(position.fitness, 0, newFit, 0, position.fitness.length);
......@@ -447,7 +447,7 @@ public class TribesExplorer extends AbstractEAIndividual implements InterfaceDat
// pb.fitnessSize, evaluate);
} else { // Artificial fitness by using penalties
for (n = 0; n < position.fitness.length; n++) {
SetFitness(n, swarm.tribes[fromTribe].memory[
setFitnessAt(n, swarm.tribes[fromTribe].memory[
contact].
getPos().
fitness[n] +
......
......@@ -62,7 +62,7 @@ public abstract class AbstractProblemInteger extends AbstractOptimizationProblem
fitness = this.evaluate(x);
for (int i = 0; i < fitness.length; i++) {
// set the fitness of the individual
individual.SetFitness(i, fitness[i]);
individual.setFitnessAt(i, fitness[i]);
}
if ((this.bestIndividuum == null) || (this.bestIndividuum.getFitness(0) > individual.getFitness(0))) {
this.bestIndividuum = (AbstractEAIndividual) individual.clone();
......
......@@ -254,7 +254,7 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
}
}
result[0] += 5100;
individual.SetFitness(0, result[0]);
individual.setFitnessAt(0, result[0]);
}
/**
......
......@@ -13,7 +13,6 @@ import eva2.tools.math.RNG;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
class MyLensViewer extends JPanel implements InterfaceSolutionViewer {
......@@ -317,7 +316,7 @@ public class FLensProblem extends AbstractOptimizationProblem
fitness[i] += RNG.gaussianDouble(this.noise);
fitness[i] += this.yOffset;
// set the fitness of the individual
individual.SetFitness(i, fitness[i]);
individual.setFitnessAt(i, fitness[i]);
}
if ((this.overallBest == null) || (this.overallBest.getFitness(0) > individual.getFitness(0))) {
this.overallBest = (AbstractEAIndividual) individual.clone();
......
......@@ -196,21 +196,21 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
AbstractEAIndividual tmpBestConst = (AbstractEAIndividual) ((GAPIndividualProgramData) tmpIndy).getNumbers();
AbstractEAIndividual tmpConst;
this.evaluate(tmpIndy);
tmpBestConst.SetFitness(0, tmpIndy.getFitness(0));
tmpBestConst.setFitnessAt(0, tmpIndy.getFitness(0));
population.incrFunctionCalls();
for (int j = 0; j < 10; j++) {
tmpConst = (AbstractEAIndividual) tmpBestConst.clone();
tmpConst.mutate();
((GAPIndividualProgramData) tmpIndy).setNumbers((InterfaceDataTypeDouble) tmpConst);
this.evaluate(tmpIndy);
tmpConst.SetFitness(0, tmpIndy.getFitness(0));
tmpConst.setFitnessAt(0, tmpIndy.getFitness(0));
population.incrFunctionCalls();
if (tmpBestConst.getFitness(0) > tmpConst.getFitness(0)) {
tmpBestConst = (AbstractEAIndividual) tmpConst.clone();
}
}
((GAPIndividualProgramData) tmpIndy).setNumbers((InterfaceDataTypeDouble) tmpBestConst);
tmpIndy.SetFitness(0, tmpBestConst.getFitness(0));
tmpIndy.setFitnessAt(0, tmpBestConst.getFitness(0));
} else {
if (useLocalHillClimbing) {
EVAERROR.errorMsgOnce("Error: local hill climbing only works on GAPIndividualProgramData individuals!");
......@@ -251,7 +251,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
// add noise to the fitness
fitness += RNG.gaussianDouble(this.noise);
// set the fitness of the individual
individual.SetFitness(0, fitness);
individual.setFitnessAt(0, fitness);
if ((this.plot != null) && (this.plot.getFunctionArea().getContainerSize() == 0)) {
this.overallBestIndividuum = null;
}
......
......@@ -132,7 +132,7 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
fitness[i] += RNG.gaussianDouble(this.noise);
fitness[i] += this.yOffset;
// set the fitness of the individual
individual.SetFitness(i, fitness[i]);
individual.setFitnessAt(i, fitness[i]);
}
if (this.applyConstraints) {
if (fitness[0] > 0.5) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment