From 5a5606fdd5fc83988ce9fd54ac517cc768a965d2 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Mon, 30 Nov 2015 13:06:34 +0100 Subject: [PATCH] Typo/Code cleanup --- .../operator/archiving/AbstractArchiving.java | 17 ------------ .../archiving/ArchivingNSGAIISMeasure.java | 10 +++---- .../operator/archiving/ArchivingPESAII.java | 26 +++++-------------- 3 files changed, 11 insertions(+), 42 deletions(-) diff --git a/src/eva2/optimization/operator/archiving/AbstractArchiving.java b/src/eva2/optimization/operator/archiving/AbstractArchiving.java index 2f694da0..2ba03fce 100644 --- a/src/eva2/optimization/operator/archiving/AbstractArchiving.java +++ b/src/eva2/optimization/operator/archiving/AbstractArchiving.java @@ -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 diff --git a/src/eva2/optimization/operator/archiving/ArchivingNSGAIISMeasure.java b/src/eva2/optimization/operator/archiving/ArchivingNSGAIISMeasure.java index ebbabb1c..59d0e1ad 100644 --- a/src/eva2/optimization/operator/archiving/ArchivingNSGAIISMeasure.java +++ b/src/eva2/optimization/operator/archiving/ArchivingNSGAIISMeasure.java @@ -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; diff --git a/src/eva2/optimization/operator/archiving/ArchivingPESAII.java b/src/eva2/optimization/operator/archiving/ArchivingPESAII.java index 63088ec0..7c611802 100644 --- a/src/eva2/optimization/operator/archiving/ArchivingPESAII.java +++ b/src/eva2/optimization/operator/archiving/ArchivingPESAII.java @@ -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 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); }