Typo/Code cleanup
This commit is contained in:
parent
fbf6617dda
commit
5a5606fdd5
@ -158,23 +158,6 @@ public abstract class AbstractArchiving implements InterfaceArchiving, java.io.S
|
|||||||
p++;
|
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
|
* Toggle the use of obeying the constraint violation principle
|
||||||
* of Deb
|
* of Deb
|
||||||
|
@ -9,7 +9,7 @@ import java.util.Arrays;
|
|||||||
public class ArchivingNSGAIISMeasure extends ArchivingNSGAII {
|
public class ArchivingNSGAIISMeasure extends ArchivingNSGAII {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will cacluated the NSGAII crowding distance
|
* This method will calculated the NSGAII crowding distance
|
||||||
* for all individuals
|
* for all individuals
|
||||||
*
|
*
|
||||||
* @param fronts The pareto fronts
|
* @param fronts The pareto fronts
|
||||||
@ -18,14 +18,14 @@ public class ArchivingNSGAIISMeasure extends ArchivingNSGAII {
|
|||||||
public void calculateCrowdingDistance(Population[] fronts) {
|
public void calculateCrowdingDistance(Population[] fronts) {
|
||||||
//TODO Dimension der Zielfunktion checken
|
//TODO Dimension der Zielfunktion checken
|
||||||
|
|
||||||
for (int rank = 0; rank < fronts.length; rank++) {
|
for (Population front : fronts) {
|
||||||
calculateCrowdingDistance(fronts[rank]);
|
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
|
* a given population
|
||||||
*
|
*
|
||||||
* @param indy The individual that is to be tested.
|
* @param indy The individual that is to be tested.
|
||||||
@ -68,7 +68,7 @@ public class ArchivingNSGAIISMeasure extends ArchivingNSGAII {
|
|||||||
Arrays.sort(frontArray, new EAIndividualComparator(0));
|
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);
|
((AbstractEAIndividual) frontArray[frontArray.length - 1]).putData("HyperCube", Double.MAX_VALUE);
|
||||||
v[0] = Double.MAX_VALUE;
|
v[0] = Double.MAX_VALUE;
|
||||||
v[frontArray.length - 1] = Double.MAX_VALUE;
|
v[frontArray.length - 1] = Double.MAX_VALUE;
|
||||||
|
@ -8,7 +8,7 @@ import eva2.util.annotation.Description;
|
|||||||
import java.util.ArrayList;
|
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.
|
* the so called squeeze factor.
|
||||||
*/
|
*/
|
||||||
@Description("Pareto Envelope-based Selection Algorithm revision 2.0.")
|
@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[][] bounds;
|
||||||
double[] tmpFit;
|
double[] tmpFit;
|
||||||
AbstractEAIndividual tmpIndy;
|
AbstractEAIndividual tmpIndy;
|
||||||
// boolean debug = true;
|
|
||||||
|
|
||||||
// first calculate the bounds of the search space
|
// first calculate the bounds of the search space
|
||||||
bounds = new double[pop.get(0).getFitness().length][2];
|
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][0] = Double.POSITIVE_INFINITY;
|
||||||
bounds[i][1] = Double.NEGATIVE_INFINITY;
|
bounds[i][1] = Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
// if (debug) System.out.println("The individuals:");
|
|
||||||
for (int i = 0; i < pop.size(); i++) {
|
for (int i = 0; i < pop.size(); i++) {
|
||||||
tmpFit = pop.get(i).getFitness();
|
tmpFit = pop.get(i).getFitness();
|
||||||
// if (debug) System.out.println("Individual "+i+": "+tmpFit[0] +"/"+tmpFit[1]);
|
|
||||||
result[i] = 0;
|
result[i] = 0;
|
||||||
for (int j = 0; j < tmpFit.length; j++) {
|
for (int j = 0; j < tmpFit.length; j++) {
|
||||||
if (tmpFit[j] < bounds[j][0]) {
|
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
|
// 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];
|
double[] grid = new double[bounds.length];
|
||||||
ArrayList coll;
|
ArrayList<Integer> coll;
|
||||||
boolean sameGrid;
|
boolean sameGrid;
|
||||||
for (int i = 0; i < pop.size(); i++) {
|
for (int i = 0; i < pop.size(); i++) {
|
||||||
if (result[i] == 0) {
|
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
|
// haven't calculated the squeeze factor for this guy yet
|
||||||
// first i'll calculate the grid position this guy is in
|
// first i'll calculate the grid position this guy is in
|
||||||
tmpFit = pop.get(i).getFitness();
|
tmpFit = pop.get(i).getFitness();
|
||||||
coll = new ArrayList();
|
coll = new ArrayList<>();
|
||||||
for (int j = 0; j < tmpFit.length; j++) {
|
for (int j = 0; j < tmpFit.length; j++) {
|
||||||
grid[j] = (bounds[j][1] - bounds[j][0]) / this.gridSize;
|
grid[j] = (bounds[j][1] - bounds[j][0]) / this.gridSize;
|
||||||
curGrid[j] = (int) ((tmpFit[j] - bounds[j][0]) / grid[j]);
|
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);
|
coll.add(i);
|
||||||
for (int j = i + 1; j < pop.size(); j++) {
|
for (int j = i + 1; j < pop.size(); j++) {
|
||||||
if (result[j] == 0) {
|
if (result[j] == 0) {
|
||||||
@ -147,16 +136,13 @@ public class ArchivingPESAII extends AbstractArchiving implements java.io.Serial
|
|||||||
if (sameGrid) {
|
if (sameGrid) {
|
||||||
coll.add(j);
|
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
|
// now i got all the boogies of the same grid element
|
||||||
// lets assign them their squeeze factor
|
// lets assign them their squeeze factor
|
||||||
for (int j = 0; j < coll.size(); j++) {
|
for (int j = 0; j < coll.size(); j++) {
|
||||||
result[coll.get(j)] = coll.size();
|
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("SqueezeFactor", coll.size());
|
||||||
tmpIndy.putData("GridBox", curGrid);
|
tmpIndy.putData("GridBox", curGrid);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user