Map<Long, Map<Configuration, List<Double>>> map = new HashMap<>();
Map<Long, Map<Configuration, ProblemPerformanceTuple>> resultTupleMap =
new HashMap<>();
for (ProblemPerformanceTuple tuple : instances) {
Long problemID = tuple.getProblemDefinitionID();
Configuration config = tuple.getConfiguration();
Map<Configuration, List<Double>> configPerformanceMap =
map.get(problemID);
Map<Configuration, ProblemPerformanceTuple> configTupleMap =
resultTupleMap.get(problemID);
if (configTupleMap == null) {
configPerformanceMap = new HashMap<>();
configTupleMap = new HashMap<>();
map.put(problemID, configPerformanceMap);
resultTupleMap.put(problemID, configTupleMap);
}
List<Double> performanceList = configPerformanceMap.get(config);
if (performanceList == null) {
performanceList = new ArrayList<>();
ProblemPerformanceTuple resultTuple =
new ProblemPerformanceTuple(tuple.getProblemSchemeURI(),
tuple.getProblemSchemeParameters(),
tuple.getProblemDefinitionID(),
tuple.getProblemDefinitionParameters(), tuple.getFeatures(),
config, perfMeasureFactory, 0.0);
configTupleMap.put(config, resultTuple);
configPerformanceMap.put(config, performanceList);
}
performanceList.add(tuple.getPerformance());
}
for (Map.Entry<Long, Map<Configuration, List<Double>>> entry : map
.entrySet()) {
Long problemId = entry.getKey();
for (Map.Entry<Configuration, List<Double>> entry2 : entry.getValue()
.entrySet()) {
Configuration config = entry2.getKey();
List<Double> performances = entry2.getValue();
Double performance = getAggregatedPerformance(performances);
ProblemPerformanceTuple resultTuple =
resultTupleMap.get(problemId).get(config);
resultTuple.setPerformance(performance);