@Test public void testGetSortedParetoFront2() { final boolean[] maximize = new boolean[] { true, true, true, true }; final ArrayList<Individual> expResult = new ArrayList<Individual>() {{ add(createIndForPoint(new double[] { 1, 4, 5, 10}, maximize)); add(createIndForPoint(new double[] { 10, 4, 1, 40}, maximize)); add(createIndForPoint(new double[] { 15, 3, 0.5, 49}, maximize)); add(createIndForPoint(new double[] { 15, 4, 0.5, 30}, maximize)); }}; final ArrayList<Individual> inds = new ArrayList<Individual>() {{ add(expResult.get(1)); add(expResult.get(2)); add(expResult.get(3)); add(expResult.get(0)); }}; final ArrayList<Individual> result = MultiObjectiveFitness.getSortedParetoFront(inds); assertEquals(expResult, result); }
public static ArrayList<Individual> getSortedParetoFront(ArrayList<Individual> inds) { ArrayList<Individual> front = partitionIntoParetoFront(inds, null, null); Object[] sortedFront = front.toArray(); QuickSort.qsort(sortedFront, new SortComparator() { public boolean lt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) < fb.getObjective(i)) return true; else if (fa.getObjective(i) > fb.getObjective(i)) return false; } return false; } public boolean gt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) > fb.getObjective(i)) return true; else if (fa.getObjective(i) < fb.getObjective(i)) return false; } return false; } }); final ArrayList<Individual> sorted = new ArrayList<Individual>(sortedFront.length); for (final Object ind : sortedFront) sorted.add((Individual)ind); return sorted; }
MultiObjectiveFitness extends Fitness { public static ArrayList<Individual> getSortedParetoFront(ArrayList<Individual> inds) { ArrayList<Individual> front = partitionIntoParetoFront(inds, null, null); Object[] sortedFront = front.toArray(); QuickSort.qsort(sortedFront, new SortComparator() { public boolean lt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) < fb.getObjective(i)) return true; else if (fa.getObjective(i) > fb.getObjective(i)) return false; } return false; } public boolean gt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) > fb.getObjective(i)) return true; else if (fa.getObjective(i) < fb.getObjective(i)) return false; } return false; } }); final ArrayList<Individual> sorted = new ArrayList<Individual>(sortedFront.length); for (final Object ind : sortedFront) sorted.add((Individual)ind); return sorted; } }
MultiObjectiveFitness extends Fitness { public static ArrayList<Individual> getSortedParetoFront(ArrayList<Individual> inds) { ArrayList<Individual> front = partitionIntoParetoFront(inds, null, null); Object[] sortedFront = front.toArray(); QuickSort.qsort(sortedFront, new SortComparator() { public boolean lt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) < fb.getObjective(i)) return true; else if (fa.getObjective(i) > fb.getObjective(i)) return false; } return false; } public boolean gt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) > fb.getObjective(i)) return true; else if (fa.getObjective(i) < fb.getObjective(i)) return false; } return false; } }); final ArrayList<Individual> sorted = new ArrayList<Individual>(sortedFront.length); for (final Object ind : sortedFront) sorted.add((Individual)ind); return sorted; }  }
MultiObjectiveFitness extends Fitness { public static ArrayList<Individual> getSortedParetoFront(ArrayList<Individual> inds) { ArrayList<Individual> front = partitionIntoParetoFront(inds, null, null); Object[] sortedFront = front.toArray(); QuickSort.qsort(sortedFront, new SortComparator() { public boolean lt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) < fb.getObjective(i)) return true; else if (fa.getObjective(i) > fb.getObjective(i)) return false; } return false; } public boolean gt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) > fb.getObjective(i)) return true; else if (fa.getObjective(i) < fb.getObjective(i)) return false; } return false; } }); final ArrayList<Individual> sorted = new ArrayList<Individual>(sortedFront.length); for (final Object ind : sortedFront) sorted.add((Individual)ind); return sorted; }  String[] getAuxilliaryFitnessNames(); double[] getAuxilliaryFitnessValues(); boolean isMaximizing(); boolean isMaximizing(int objective); int getNumObjectives(); double[] getObjectives(); double getObjective(int i); void setObjectives(final EvolutionState state, double[] newObjectives); Parameter defaultBase(); Object clone(); double fitness(); void setup(EvolutionState state, Parameter base); boolean isIdealFitness(); boolean equivalentTo(Fitness _fitness); boolean betterThan(Fitness fitness); boolean paretoDominates(MultiObjectiveFitness other); static ArrayList<Individual> partitionIntoParetoFront(ArrayList<Individual> inds, ArrayList<Individual> front, ArrayList<Individual> nonFront); static ArrayList<Individual> getSortedParetoFront(ArrayList<Individual> inds); static ArrayList<ArrayList<Individual>> partitionIntoRanks(ArrayList<Individual> inds); static int[] getRankings(ArrayList<Individual> inds); double sumSquaredObjectiveDistance(MultiObjectiveFitness other, boolean normalize); double manhattanObjectiveDistance(MultiObjectiveFitness other); String fitnessToString(); String fitnessToStringForHumans(); void readFitness(final EvolutionState state, final LineNumberReader reader); void writeFitness(final EvolutionState state, final DataOutput dataOutput); void readFitness(final EvolutionState state, final DataInput dataInput); void setToBestOf(EvolutionState state, Fitness[] fitnesses); void setToMeanOf(EvolutionState state, Fitness[] fitnesses); void setToMedianOf(EvolutionState state, Fitness[] fitnesses); }
MultiObjectiveFitness extends Fitness { public static ArrayList<Individual> getSortedParetoFront(ArrayList<Individual> inds) { ArrayList<Individual> front = partitionIntoParetoFront(inds, null, null); Object[] sortedFront = front.toArray(); QuickSort.qsort(sortedFront, new SortComparator() { public boolean lt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) < fb.getObjective(i)) return true; else if (fa.getObjective(i) > fb.getObjective(i)) return false; } return false; } public boolean gt(Object a, Object b) { MultiObjectiveFitness fa = ((MultiObjectiveFitness) (((Individual) a).fitness)); MultiObjectiveFitness fb = ((MultiObjectiveFitness) (((Individual) b).fitness)); int objs = fa.getNumObjectives(); for(int i = 0; i < objs; i++) { if (fa.getObjective(i) > fb.getObjective(i)) return true; else if (fa.getObjective(i) < fb.getObjective(i)) return false; } return false; } }); final ArrayList<Individual> sorted = new ArrayList<Individual>(sortedFront.length); for (final Object ind : sortedFront) sorted.add((Individual)ind); return sorted; }  String[] getAuxilliaryFitnessNames(); double[] getAuxilliaryFitnessValues(); boolean isMaximizing(); boolean isMaximizing(int objective); int getNumObjectives(); double[] getObjectives(); double getObjective(int i); void setObjectives(final EvolutionState state, double[] newObjectives); Parameter defaultBase(); Object clone(); double fitness(); void setup(EvolutionState state, Parameter base); boolean isIdealFitness(); boolean equivalentTo(Fitness _fitness); boolean betterThan(Fitness fitness); boolean paretoDominates(MultiObjectiveFitness other); static ArrayList<Individual> partitionIntoParetoFront(ArrayList<Individual> inds, ArrayList<Individual> front, ArrayList<Individual> nonFront); static ArrayList<Individual> getSortedParetoFront(ArrayList<Individual> inds); static ArrayList<ArrayList<Individual>> partitionIntoRanks(ArrayList<Individual> inds); static int[] getRankings(ArrayList<Individual> inds); double sumSquaredObjectiveDistance(MultiObjectiveFitness other, boolean normalize); double manhattanObjectiveDistance(MultiObjectiveFitness other); String fitnessToString(); String fitnessToStringForHumans(); void readFitness(final EvolutionState state, final LineNumberReader reader); void writeFitness(final EvolutionState state, final DataOutput dataOutput); void readFitness(final EvolutionState state, final DataInput dataInput); void setToBestOf(EvolutionState state, Fitness[] fitnesses); void setToMeanOf(EvolutionState state, Fitness[] fitnesses); void setToMedianOf(EvolutionState state, Fitness[] fitnesses); static final String MULTI_FITNESS_POSTAMBLE; static final String FITNESS_POSTAMBLE; static final String P_NUMOBJECTIVES; static final String P_MAXOBJECTIVE; static final String P_MINOBJECTIVE; static final String P_MAXIMIZE; public double[] maxObjective; public double[] minObjective; public boolean[] maximize; }