@Test public void testFindAmplitudes() { Set<Individual> indis = getIndividualSet(); EpsilonMappingAdditive epsilonMapping = new EpsilonMappingAdditive(); Map<Objective, Double> amplitudeMap = epsilonMapping.findObjectiveAmplitudes(indis); assertTrue(amplitudeMap.containsKey(first)); assertTrue(amplitudeMap.containsKey(second)); assertEquals(3.0, amplitudeMap.get(first), 0.0); assertEquals(2.0, amplitudeMap.get(second), 0.0); }
@Override public Map<Objective, Double> findObjectiveAmplitudes(Set<Individual> individuals) { Map<Objective, Double> maximumMap = new HashMap<>(); Map<Objective, Double> minimumMap = new HashMap<>(); Map<Objective, Double> amplitudeMap = new HashMap<>(); for (Individual indi : individuals) { Objectives objectives = indi.getObjectives(); Iterator<Objective> iterator = objectives.getKeys().iterator(); double[] values = objectives.array(); for (int i = 0; i < objectives.size(); i++) { Objective obj = iterator.next(); if (objectives.get(obj).getValue() == Objective.INFEASIBLE) { continue; } double value = values[i]; if (!maximumMap.containsKey(obj) || maximumMap.get(obj) < value) { maximumMap.put(obj, value); } if (!minimumMap.containsKey(obj) || minimumMap.get(obj) > value) { minimumMap.put(obj, value); } } } for (Entry<Objective, Double> maxEntry : maximumMap.entrySet()) { Objective obj = maxEntry.getKey(); Double maximum = maxEntry.getValue(); Double minimum = minimumMap.get(obj); amplitudeMap.put(obj, maximum - minimum); } return amplitudeMap; }
EpsilonMappingAdditive implements EpsilonMapping { @Override public Map<Objective, Double> findObjectiveAmplitudes(Set<Individual> individuals) { Map<Objective, Double> maximumMap = new HashMap<>(); Map<Objective, Double> minimumMap = new HashMap<>(); Map<Objective, Double> amplitudeMap = new HashMap<>(); for (Individual indi : individuals) { Objectives objectives = indi.getObjectives(); Iterator<Objective> iterator = objectives.getKeys().iterator(); double[] values = objectives.array(); for (int i = 0; i < objectives.size(); i++) { Objective obj = iterator.next(); if (objectives.get(obj).getValue() == Objective.INFEASIBLE) { continue; } double value = values[i]; if (!maximumMap.containsKey(obj) || maximumMap.get(obj) < value) { maximumMap.put(obj, value); } if (!minimumMap.containsKey(obj) || minimumMap.get(obj) > value) { minimumMap.put(obj, value); } } } for (Entry<Objective, Double> maxEntry : maximumMap.entrySet()) { Objective obj = maxEntry.getKey(); Double maximum = maxEntry.getValue(); Double minimum = minimumMap.get(obj); amplitudeMap.put(obj, maximum - minimum); } return amplitudeMap; } }
EpsilonMappingAdditive implements EpsilonMapping { @Override public Map<Objective, Double> findObjectiveAmplitudes(Set<Individual> individuals) { Map<Objective, Double> maximumMap = new HashMap<>(); Map<Objective, Double> minimumMap = new HashMap<>(); Map<Objective, Double> amplitudeMap = new HashMap<>(); for (Individual indi : individuals) { Objectives objectives = indi.getObjectives(); Iterator<Objective> iterator = objectives.getKeys().iterator(); double[] values = objectives.array(); for (int i = 0; i < objectives.size(); i++) { Objective obj = iterator.next(); if (objectives.get(obj).getValue() == Objective.INFEASIBLE) { continue; } double value = values[i]; if (!maximumMap.containsKey(obj) || maximumMap.get(obj) < value) { maximumMap.put(obj, value); } if (!minimumMap.containsKey(obj) || minimumMap.get(obj) > value) { minimumMap.put(obj, value); } } } for (Entry<Objective, Double> maxEntry : maximumMap.entrySet()) { Objective obj = maxEntry.getKey(); Double maximum = maxEntry.getValue(); Double minimum = minimumMap.get(obj); amplitudeMap.put(obj, maximum - minimum); } return amplitudeMap; }  }
EpsilonMappingAdditive implements EpsilonMapping { @Override public Map<Objective, Double> findObjectiveAmplitudes(Set<Individual> individuals) { Map<Objective, Double> maximumMap = new HashMap<>(); Map<Objective, Double> minimumMap = new HashMap<>(); Map<Objective, Double> amplitudeMap = new HashMap<>(); for (Individual indi : individuals) { Objectives objectives = indi.getObjectives(); Iterator<Objective> iterator = objectives.getKeys().iterator(); double[] values = objectives.array(); for (int i = 0; i < objectives.size(); i++) { Objective obj = iterator.next(); if (objectives.get(obj).getValue() == Objective.INFEASIBLE) { continue; } double value = values[i]; if (!maximumMap.containsKey(obj) || maximumMap.get(obj) < value) { maximumMap.put(obj, value); } if (!minimumMap.containsKey(obj) || minimumMap.get(obj) > value) { minimumMap.put(obj, value); } } } for (Entry<Objective, Double> maxEntry : maximumMap.entrySet()) { Objective obj = maxEntry.getKey(); Double maximum = maxEntry.getValue(); Double minimum = minimumMap.get(obj); amplitudeMap.put(obj, maximum - minimum); } return amplitudeMap; }  @Override Objectives mapObjectives(Objectives original, double epsilon, Map<Objective, Double> objectiveAmplitudes); @Override Map<Objective, Double> findObjectiveAmplitudes(Set<Individual> individuals); }
EpsilonMappingAdditive implements EpsilonMapping { @Override public Map<Objective, Double> findObjectiveAmplitudes(Set<Individual> individuals) { Map<Objective, Double> maximumMap = new HashMap<>(); Map<Objective, Double> minimumMap = new HashMap<>(); Map<Objective, Double> amplitudeMap = new HashMap<>(); for (Individual indi : individuals) { Objectives objectives = indi.getObjectives(); Iterator<Objective> iterator = objectives.getKeys().iterator(); double[] values = objectives.array(); for (int i = 0; i < objectives.size(); i++) { Objective obj = iterator.next(); if (objectives.get(obj).getValue() == Objective.INFEASIBLE) { continue; } double value = values[i]; if (!maximumMap.containsKey(obj) || maximumMap.get(obj) < value) { maximumMap.put(obj, value); } if (!minimumMap.containsKey(obj) || minimumMap.get(obj) > value) { minimumMap.put(obj, value); } } } for (Entry<Objective, Double> maxEntry : maximumMap.entrySet()) { Objective obj = maxEntry.getKey(); Double maximum = maxEntry.getValue(); Double minimum = minimumMap.get(obj); amplitudeMap.put(obj, maximum - minimum); } return amplitudeMap; }  @Override Objectives mapObjectives(Objectives original, double epsilon, Map<Objective, Double> objectiveAmplitudes); @Override Map<Objective, Double> findObjectiveAmplitudes(Set<Individual> individuals);  }