Typo/Code cleanup

This commit is contained in:
Fabian Becker 2015-11-30 13:06:34 +01:00
parent fbf6617dda
commit 5a5606fdd5
3 changed files with 11 additions and 42 deletions

View File

@ -158,23 +158,6 @@ public abstract class AbstractArchiving implements InterfaceArchiving, java.io.S
p++;
}
/**********************************************************************************************************************
* These are for GUI
*/
// /** This method allows you to toggle the debug mode.
// * @param b True in case of the debug mode.
// */
// public void setDebugFront(boolean b) {
// this.debug = b;
// }
// public boolean getDebugFront() {
// return this.debug;
// }
// public String debugFrontTipText() {
// return "Toggles the debug mode.";
// }
/**
* Toggle the use of obeying the constraint violation principle
* of Deb

View File

@ -9,7 +9,7 @@ import java.util.Arrays;
public class ArchivingNSGAIISMeasure extends ArchivingNSGAII {
/**
* This method will cacluated the NSGAII crowding distance
* This method will calculated the NSGAII crowding distance
* for all individuals
*
* @param fronts The pareto fronts
@ -18,14 +18,14 @@ public class ArchivingNSGAIISMeasure extends ArchivingNSGAII {
public void calculateCrowdingDistance(Population[] fronts) {
//TODO Dimension der Zielfunktion checken
for (int rank = 0; rank < fronts.length; rank++) {
calculateCrowdingDistance(fronts[rank]);
for (Population front : fronts) {
calculateCrowdingDistance(front);
}
}
/**
* This mehtod will test if a given individual is dominant within
* This method will test if a given individual is dominant within
* a given population
*
* @param indy The individual that is to be tested.
@ -68,7 +68,7 @@ public class ArchivingNSGAIISMeasure extends ArchivingNSGAII {
Arrays.sort(frontArray, new EAIndividualComparator(0));
((AbstractEAIndividual) frontArray[0]).putData("HyperCube", Double.MAX_VALUE); //die beiden aussen bekommen maximal wert als smeasure
((AbstractEAIndividual) frontArray[0]).putData("HyperCube", Double.MAX_VALUE); //die beiden aussen bekommen maximal wert als measure
((AbstractEAIndividual) frontArray[frontArray.length - 1]).putData("HyperCube", Double.MAX_VALUE);
v[0] = Double.MAX_VALUE;
v[frontArray.length - 1] = Double.MAX_VALUE;

View File

@ -8,7 +8,7 @@ import eva2.util.annotation.Description;
import java.util.ArrayList;
/**
* The Pareto envelope sorting algorithm using a hybergrid and
* The Pareto envelope sorting algorithm using a hypergrid and
* the so called squeeze factor.
*/
@Description("Pareto Envelope-based Selection Algorithm revision 2.0.")
@ -85,7 +85,6 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
double[][] bounds;
double[] tmpFit;
AbstractEAIndividual tmpIndy;
// boolean debug = true;
// first calculate the bounds of the search space
bounds = new double[pop.get(0).getFitness().length][2];
@ -93,10 +92,9 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
bounds[i][0] = Double.POSITIVE_INFINITY;
bounds[i][1] = Double.NEGATIVE_INFINITY;
}
// if (debug) System.out.println("The individuals:");
for (int i = 0; i < pop.size(); i++) {
tmpFit = pop.get(i).getFitness();
// if (debug) System.out.println("Individual "+i+": "+tmpFit[0] +"/"+tmpFit[1]);
result[i] = 0;
for (int j = 0; j < tmpFit.length; j++) {
if (tmpFit[j] < bounds[j][0]) {
@ -107,15 +105,11 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
}
}
}
// if (debug) {
// System.out.println("The bounds are ("+bounds[0][0]+"/"+bounds[0][1]+")("+bounds[1][0]+"/"+bounds[1][1]+")");
// System.out.println("Gridwidth is "+((bounds[0][1] - bounds[0][0])/this.gridSize)+"/"+((bounds[1][1] - bounds[1][0])/this.gridSize));
// }
// now that i got the bounds i can calculate the squeeze grid
int[] curGrid = new int[bounds.length], tmpGrid = new int[bounds.length];
int[] curGrid, tmpGrid = new int[bounds.length];
double[] grid = new double[bounds.length];
ArrayList coll;
ArrayList<Integer> coll;
boolean sameGrid;
for (int i = 0; i < pop.size(); i++) {
if (result[i] == 0) {
@ -123,16 +117,11 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
// haven't calculated the squeeze factor for this guy yet
// first i'll calculate the grid position this guy is in
tmpFit = pop.get(i).getFitness();
coll = new ArrayList();
coll = new ArrayList<>();
for (int j = 0; j < tmpFit.length; j++) {
grid[j] = (bounds[j][1] - bounds[j][0]) / this.gridSize;
curGrid[j] = (int) ((tmpFit[j] - bounds[j][0]) / grid[j]);
}
// if (debug) {
// System.out.println("Indy "+i+" ("+tmpFit[0] +"/"+tmpFit[1]+") unassigned is in grid ["+curGrid[0]+"/"+curGrid[1]+"]");
// System.out.println("");
// System.out.println("Checking for individuals in the same grid");
// }
coll.add(i);
for (int j = i + 1; j < pop.size(); j++) {
if (result[j] == 0) {
@ -147,16 +136,13 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
if (sameGrid) {
coll.add(j);
}
// if (debug) {
// System.out.println("Checking indy "+j+" ("+tmpFit[0] +"/"+tmpFit[1]+") in grid ["+tmpGrid[0]+"/"+tmpGrid[1]+"]");
// }
}
}
// now i got all the boogies of the same grid element
// lets assign them their squeeze factor
for (int j = 0; j < coll.size(); j++) {
result[coll.get(j)] = coll.size();
tmpIndy = pop.get(((Integer) coll.get(j)).intValue());
tmpIndy = pop.get(coll.get(j).intValue());
tmpIndy.putData("SqueezeFactor", coll.size());
tmpIndy.putData("GridBox", curGrid);
}