optaplanner-benchmark/src/main/java/org/optaplanner/benchmark/impl/result/ProblemBenchmarkResult.java
protected static <Solution_> Map<ProblemBenchmarkResult, ProblemBenchmarkResult> createMergeMap(
            PlannerBenchmarkResult newPlannerBenchmarkResult, List<SingleBenchmarkResult> singleBenchmarkResultList) {
        // IdentityHashMap but despite that different ProblemBenchmarkResult instances are merged
        Map<ProblemBenchmarkResult, ProblemBenchmarkResult> mergeMap
                = new IdentityHashMap<>();
        Map<ProblemProvider<Solution_>, ProblemBenchmarkResult> problemProviderToNewResultMap = new HashMap<>();
        for (SingleBenchmarkResult singleBenchmarkResult : singleBenchmarkResultList) {
            ProblemBenchmarkResult<Solution_> oldResult = singleBenchmarkResult.getProblemBenchmarkResult();
            if (!mergeMap.containsKey(oldResult)) {
                ProblemBenchmarkResult<Solution_> newResult;
                if (!problemProviderToNewResultMap.containsKey(oldResult.problemProvider)) {
                    newResult = new ProblemBenchmarkResult<>(newPlannerBenchmarkResult);
                    newResult.name = oldResult.name;
                    newResult.problemProvider = oldResult.problemProvider;
                    // Skip oldResult.problemReportDirectory
                    newResult.problemStatisticList = new ArrayList<>(oldResult.problemStatisticList.size());
                    for (ProblemStatistic oldProblemStatistic : oldResult.problemStatisticList) {
                        newResult.problemStatisticList.add(
                                oldProblemStatistic.getProblemStatisticType().buildProblemStatistic(newResult));
                    }
                    newResult.singleBenchmarkResultList = new ArrayList<>(
                            oldResult.singleBenchmarkResultList.size());
                    newResult.entityCount = oldResult.entityCount;
                    newResult.variableCount = oldResult.variableCount;
                    newResult.maximumValueCount = oldResult.maximumValueCount;
                    newResult.problemScale = oldResult.problemScale;
                    problemProviderToNewResultMap.put(oldResult.problemProvider, newResult);
                    newPlannerBenchmarkResult.getUnifiedProblemBenchmarkResultList().add(newResult);
                } else {
                    newResult = problemProviderToNewResultMap.get(oldResult.problemProvider);
                    if (!Objects.equals(oldResult.name, newResult.name)) {
                        throw new IllegalStateException(
                                "The oldResult (" + oldResult + ") and newResult (" + newResult
                                + ") should have the same name, because they have the same problemProvider ("
                                + oldResult.problemProvider + ").");
                    }
                    newResult.problemStatisticList.removeIf(
                            newStatistic -> !oldResult.hasProblemStatisticType(newStatistic.getProblemStatisticType()));
                    newResult.entityCount = ConfigUtils.meldProperty(oldResult.entityCount, newResult.entityCount);
                    newResult.variableCount = ConfigUtils.meldProperty(oldResult.variableCount, newResult.variableCount);
                    newResult.maximumValueCount = ConfigUtils.meldProperty(oldResult.maximumValueCount, newResult.maximumValueCount);
                    newResult.problemScale = ConfigUtils.meldProperty(oldResult.problemScale, newResult.problemScale);
                }
                mergeMap.put(oldResult, newResult);
            }
        }
        return mergeMap;
    }
protected static <Solution_> Map<ProblemBenchmarkResult, ProblemBenchmarkResult> createMergeMap(
            PlannerBenchmarkResult newPlannerBenchmarkResult, List<SingleBenchmarkResult> singleBenchmarkResultList) {
        // IdentityHashMap but despite that different ProblemBenchmarkResult instances are merged
        Map<ProblemBenchmarkResult, ProblemBenchmarkResult> mergeMap
                = new IdentityHashMap<>();
        Map<ProblemProvider<Solution_>, ProblemBenchmarkResult> problemProviderToNewResultMap = new HashMap<>();
        for (SingleBenchmarkResult singleBenchmarkResult : singleBenchmarkResultList) {
            ProblemBenchmarkResult<Solution_> oldResult = singleBenchmarkResult.getProblemBenchmarkResult();
            if (!mergeMap.containsKey(oldResult)) {
                ProblemBenchmarkResult<Solution_> newResult;
                if (!problemProviderToNewResultMap.containsKey(oldResult.problemProvider)) {
                    newResult = new ProblemBenchmarkResult<>(newPlannerBenchmarkResult);
                    newResult.name = oldResult.name;
                    newResult.problemProvider = oldResult.problemProvider;
                    // Skip oldResult.problemReportDirectory
                    newResult.problemStatisticList = new ArrayList<>(oldResult.problemStatisticList.size());
                    for (ProblemStatistic oldProblemStatistic : oldResult.problemStatisticList) {
                        newResult.problemStatisticList.add(
                                oldProblemStatistic.getProblemStatisticType().buildProblemStatistic(newResult));
                    }
                    newResult.singleBenchmarkResultList = new ArrayList<>(
                            oldResult.singleBenchmarkResultList.size());
                    newResult.entityCount = oldResult.entityCount;
                    newResult.variableCount = oldResult.variableCount;
                    newResult.maximumValueCount = oldResult.maximumValueCount;
                    newResult.problemScale = oldResult.problemScale;
                    problemProviderToNewResultMap.put(oldResult.problemProvider, newResult);
                    newPlannerBenchmarkResult.getUnifiedProblemBenchmarkResultList().add(newResult);
                } else {
                    newResult = problemProviderToNewResultMap.get(oldResult.problemProvider);
                    if (!Objects.equals(oldResult.name, newResult.name)) {
                        throw new IllegalStateException(
                                "The oldResult (" + oldResult + ") and newResult (" + newResult
                                + ") should have the same name, because they have the same problemProvider ("
                                + oldResult.problemProvider + ").");
                    }
                    newResult.problemStatisticList.removeIf(
                            newStatistic -> !oldResult.hasProblemStatisticType(newStatistic.getProblemStatisticType()));
                    newResult.entityCount = ConfigUtils.meldProperty(oldResult.entityCount, newResult.entityCount);
                    newResult.variableCount = ConfigUtils.meldProperty(oldResult.variableCount, newResult.variableCount);
                    newResult.maximumValueCount = ConfigUtils.meldProperty(oldResult.maximumValueCount, newResult.maximumValueCount);
                    newResult.problemScale = ConfigUtils.meldProperty(oldResult.problemScale, newResult.problemScale);
                }
                mergeMap.put(oldResult, newResult);
            }
        }
        return mergeMap;
    }
protected static < Solution_ > Map < ProblemBenchmarkResult , ProblemBenchmarkResult > createMergeMap ( PlannerBenchmarkResult newPlannerBenchmarkResult , List < SingleBenchmarkResult > singleBenchmarkResultList ) { // IdentityHashMap but despite that different ProblemBenchmarkResult instances are merged Map < ProblemBenchmarkResult , ProblemBenchmarkResult > mergeMap = new IdentityHashMap <> ( ) ; Map < ProblemProvider < Solution_ > , ProblemBenchmarkResult > problemProviderToNewResultMap = new HashMap <> ( ) ; for ( SingleBenchmarkResult singleBenchmarkResult : singleBenchmarkResultList ) { ProblemBenchmarkResult < Solution_ > oldResult = singleBenchmarkResult . getProblemBenchmarkResult ( ) ; if ( ! mergeMap . containsKey ( oldResult ) ) { ProblemBenchmarkResult < Solution_ > newResult ; if ( ! problemProviderToNewResultMap . containsKey ( oldResult . problemProvider ) ) { newResult = new ProblemBenchmarkResult <> ( newPlannerBenchmarkResult ) ; newResult . name = oldResult . name ; newResult . problemProvider = oldResult . problemProvider ; // Skip oldResult.problemReportDirectory newResult . problemStatisticList = new ArrayList <> ( oldResult . problemStatisticList . size ( ) ) ; for ( ProblemStatistic oldProblemStatistic : oldResult . problemStatisticList ) { newResult . problemStatisticList . add ( oldProblemStatistic . getProblemStatisticType ( ) . buildProblemStatistic ( newResult ) ) ; } newResult . singleBenchmarkResultList = new ArrayList <> ( oldResult . singleBenchmarkResultList . size ( ) ) ; newResult . entityCount = oldResult . entityCount ; newResult . variableCount = oldResult . variableCount ; newResult . maximumValueCount = oldResult . maximumValueCount ; newResult . problemScale = oldResult . problemScale ; problemProviderToNewResultMap . put ( oldResult . problemProvider , newResult ) ; newPlannerBenchmarkResult . getUnifiedProblemBenchmarkResultList ( ) . add ( newResult ) ; } else { newResult = problemProviderToNewResultMap . get ( oldResult . problemProvider ) ; if ( ! Objects . equals ( oldResult . name , newResult . name ) ) { throw new IllegalStateException ( "The oldResult (" + oldResult + ") and newResult (" + newResult + ") should have the same name, because they have the same problemProvider (" + oldResult . problemProvider + ")." ) ; } newResult . problemStatisticList . removeIf ( newStatistic -> ! oldResult . hasProblemStatisticType ( newStatistic . getProblemStatisticType ( ) ) ) ; newResult . entityCount = ConfigUtils . meldProperty ( oldResult . entityCount , newResult . entityCount ) ; newResult . variableCount = ConfigUtils . meldProperty ( oldResult . variableCount , newResult . variableCount ) ; newResult . maximumValueCount = ConfigUtils . meldProperty ( oldResult . maximumValueCount , newResult . maximumValueCount ) ; newResult . problemScale = ConfigUtils . meldProperty ( oldResult . problemScale , newResult . problemScale ) ; } mergeMap . put ( oldResult , newResult ) ; } } return mergeMap ; }
************************************************************************
************************************************************************