Skip to content

Commit

Permalink
Revert un-inline by using ProblemBenchmarkResult<Object> to deal with…
Browse files Browse the repository at this point in the history
… generics (this avoids having to rename results to resultList for style consistency)
  • Loading branch information
ge0ffrey committed Mar 24, 2016
1 parent c710466 commit 125e25a
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 49 deletions.
Expand Up @@ -246,9 +246,8 @@ private void warmUp(Map<Future<SubSingleBenchmarkRunner>, SubSingleBenchmarkRunn


protected void runSingleBenchmarks() { protected void runSingleBenchmarks() {
Map<SubSingleBenchmarkRunner, Future<SubSingleBenchmarkRunner>> futureMap = new HashMap<>(); Map<SubSingleBenchmarkRunner, Future<SubSingleBenchmarkRunner>> futureMap = new HashMap<>();
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) { for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) { for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) {
SubSingleBenchmarkRunner subSingleBenchmarkRunner = new SubSingleBenchmarkRunner( SubSingleBenchmarkRunner subSingleBenchmarkRunner = new SubSingleBenchmarkRunner(
subSingleBenchmarkResult, solverConfigContext); subSingleBenchmarkResult, solverConfigContext);
Expand All @@ -258,7 +257,7 @@ protected void runSingleBenchmarks() {
} }
} }
// Wait for the benchmarks to complete // Wait for the benchmarks to complete
futureMap.entrySet().forEach(futureEntry -> { for (Map.Entry<SubSingleBenchmarkRunner, Future<SubSingleBenchmarkRunner>> futureEntry : futureMap.entrySet()) {
SubSingleBenchmarkRunner subSingleBenchmarkRunner = futureEntry.getKey(); SubSingleBenchmarkRunner subSingleBenchmarkRunner = futureEntry.getKey();
Future<SubSingleBenchmarkRunner> future = futureEntry.getValue(); Future<SubSingleBenchmarkRunner> future = futureEntry.getValue();
Throwable failureThrowable = null; Throwable failureThrowable = null;
Expand Down Expand Up @@ -294,7 +293,7 @@ protected void runSingleBenchmarks() {
firstFailureSubSingleBenchmarkRunner = subSingleBenchmarkRunner; firstFailureSubSingleBenchmarkRunner = subSingleBenchmarkRunner;
} }
} }
}); };
} }


public void benchmarkingEnded() { public void benchmarkingEnded() {
Expand Down Expand Up @@ -384,15 +383,7 @@ private static Map<SolverBenchmarkResult, WarmUpConfigBackup> backupBenchmarkCon
} }
} }
ProblemBenchmarkResult problemBenchmarkResult = singleBenchmarkResult.getProblemBenchmarkResult(); ProblemBenchmarkResult problemBenchmarkResult = singleBenchmarkResult.getProblemBenchmarkResult();
List<ProblemStatistic> originalProblemStatisticList = problemBenchmarkResult.getProblemStatisticList(); originalProblemStatisticMap.putIfAbsent(problemBenchmarkResult, problemBenchmarkResult.getProblemStatisticList());
if (!originalProblemStatisticMap.containsKey(problemBenchmarkResult)) { // TODO: After Java 8, do Map#putIfAbsent
List<ProblemStatistic> problemStatisticPutResult = originalProblemStatisticMap.put(problemBenchmarkResult, originalProblemStatisticList);
if (problemStatisticPutResult != null) {
throw new IllegalStateException("OriginalProblemStatisticMap already contained key ("
+ problemBenchmarkResult + ") with value ("
+ problemStatisticPutResult + ").");
}
}
singleBenchmarkResult.getProblemBenchmarkResult().setProblemStatisticList(Collections.<ProblemStatistic>emptyList()); singleBenchmarkResult.getProblemBenchmarkResult().setProblemStatisticList(Collections.<ProblemStatistic>emptyList());
for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) { // needs to happen after all problem stats for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) { // needs to happen after all problem stats
subSingleBenchmarkResult.setPureSubSingleStatisticList(Collections.<PureSubSingleStatistic>emptyList()); subSingleBenchmarkResult.setPureSubSingleStatisticList(Collections.<PureSubSingleStatistic>emptyList());
Expand Down
Expand Up @@ -88,9 +88,11 @@ public File aggregate(List<SingleBenchmarkResult> singleBenchmarkResultList,
// Handle renamed solver benchmarks after statistics have been read (they're resolved by // Handle renamed solver benchmarks after statistics have been read (they're resolved by
// original solver benchmarks' names) // original solver benchmarks' names)
if (solverBenchmarkResultNameMap != null) { if (solverBenchmarkResultNameMap != null) {
for (Entry<SolverBenchmarkResult, String> results : solverBenchmarkResultNameMap.entrySet()) { for (Entry<SolverBenchmarkResult, String> entry : solverBenchmarkResultNameMap.entrySet()) {
if (!results.getKey().getName().equals(results.getValue())) { SolverBenchmarkResult result = entry.getKey();
results.getKey().setName(results.getValue()); String newName = entry.getValue();
if (!result.getName().equals(newName)) {
result.setName(newName);
} }
} }
} }
Expand Down
Expand Up @@ -217,9 +217,8 @@ public void writeReport() {
writeTimeSpentSummaryChart(); writeTimeSpentSummaryChart();
writeTimeSpentScalabilitySummaryChart(); writeTimeSpentScalabilitySummaryChart();
writeBestScorePerTimeSpentSummaryChart(); writeBestScorePerTimeSpentSummaryChart();
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) { for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) { for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) {
if (!subSingleBenchmarkResult.hasAllSuccess()) { if (!subSingleBenchmarkResult.hasAllSuccess()) {
continue; continue;
Expand All @@ -239,14 +238,12 @@ public void writeReport() {
} }
} }
} }
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) { for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
if (problemBenchmarkResult.hasAnySuccess()) { if (problemBenchmarkResult.hasAnySuccess()) {
List<ProblemStatistic> statistics = problemBenchmarkResult.getProblemStatisticList(); for (ProblemStatistic problemStatistic : problemBenchmarkResult.getProblemStatisticList()) {
for (ProblemStatistic problemStatistic : statistics) {
problemStatistic.writeGraphFiles(this); problemStatistic.writeGraphFiles(this);
} }
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
if (singleBenchmarkResult.hasAllSuccess()) { if (singleBenchmarkResult.hasAllSuccess()) {
for (PureSubSingleStatistic pureSubSingleStatistic : singleBenchmarkResult.getMedian().getPureSubSingleStatisticList()) { for (PureSubSingleStatistic pureSubSingleStatistic : singleBenchmarkResult.getMedian().getPureSubSingleStatisticList()) {
pureSubSingleStatistic.writeGraphFiles(this); pureSubSingleStatistic.writeGraphFiles(this);
Expand All @@ -255,9 +252,8 @@ public void writeReport() {
} }
} }
} }
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) { for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) { for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) {
if (!subSingleBenchmarkResult.hasAllSuccess()) { if (!subSingleBenchmarkResult.hasAllSuccess()) {
continue; continue;
Expand Down Expand Up @@ -690,16 +686,15 @@ private File writeChartToImageFile(JFreeChart chart, String fileNameBase) {


private void determineDefaultShownScoreLevelIndex() { private void determineDefaultShownScoreLevelIndex() {
defaultShownScoreLevelIndex = Integer.MAX_VALUE; defaultShownScoreLevelIndex = Integer.MAX_VALUE;
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) { for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
if (problemBenchmarkResult.hasAnySuccess()) { if (problemBenchmarkResult.hasAnySuccess()) {
double[] winningScoreLevels = ScoreUtils.extractLevelDoubles( double[] winningScoreLevels = ScoreUtils.extractLevelDoubles(
problemBenchmarkResult.getWinningSingleBenchmarkResult().getAverageScore()); problemBenchmarkResult.getWinningSingleBenchmarkResult().getAverageScore());
int[] differenceCount = new int[winningScoreLevels.length]; int[] differenceCount = new int[winningScoreLevels.length];
for (int i = 0; i < differenceCount.length; i++) { for (int i = 0; i < differenceCount.length; i++) {
differenceCount[i] = 0; differenceCount[i] = 0;
} }
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
if (singleBenchmarkResult.hasAllSuccess()) { if (singleBenchmarkResult.hasAllSuccess()) {
double[] scoreLevels = ScoreUtils.extractLevelDoubles(singleBenchmarkResult.getAverageScore()); double[] scoreLevels = ScoreUtils.extractLevelDoubles(singleBenchmarkResult.getAverageScore());
for (int i = 0; i < scoreLevels.length; i++) { for (int i = 0; i < scoreLevels.length; i++) {
Expand Down
Expand Up @@ -123,15 +123,17 @@ protected PlannerBenchmarkResult readPlannerBenchmarkResult(File plannerBenchmar
} }


private void restoreOmittedBidirectionalFields(PlannerBenchmarkResult plannerBenchmarkResult) { private void restoreOmittedBidirectionalFields(PlannerBenchmarkResult plannerBenchmarkResult) {
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) { for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
problemBenchmarkResult.setPlannerBenchmarkResult(plannerBenchmarkResult); problemBenchmarkResult.setPlannerBenchmarkResult(plannerBenchmarkResult);
if (problemBenchmarkResult.getProblemStatisticList() == null) { if (problemBenchmarkResult.getProblemStatisticList() == null) {
problemBenchmarkResult.setProblemStatisticList(new ArrayList<ProblemStatistic>(0)); problemBenchmarkResult.setProblemStatisticList(new ArrayList<ProblemStatistic>(0));
} }
List<ProblemStatistic> statistics = problemBenchmarkResult.getProblemStatisticList(); for (ProblemStatistic problemStatistic : problemBenchmarkResult.getProblemStatisticList()) {
statistics.forEach(statistic -> statistic.setProblemBenchmarkResult(problemBenchmarkResult)); problemStatistic.setProblemBenchmarkResult(problemBenchmarkResult);
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); }
results.forEach(result -> result.setProblemBenchmarkResult(problemBenchmarkResult)); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
singleBenchmarkResult.setProblemBenchmarkResult(problemBenchmarkResult);
}
} }
for (SolverBenchmarkResult solverBenchmarkResult : plannerBenchmarkResult.getSolverBenchmarkResultList()) { for (SolverBenchmarkResult solverBenchmarkResult : plannerBenchmarkResult.getSolverBenchmarkResultList()) {
solverBenchmarkResult.setPlannerBenchmarkResult(plannerBenchmarkResult); solverBenchmarkResult.setPlannerBenchmarkResult(plannerBenchmarkResult);
Expand Down
Expand Up @@ -55,7 +55,7 @@ public abstract class ProblemStatistic {
protected final transient Logger logger = LoggerFactory.getLogger(getClass()); protected final transient Logger logger = LoggerFactory.getLogger(getClass());


@XStreamOmitField // Bi-directional relationship restored through BenchmarkResultIO @XStreamOmitField // Bi-directional relationship restored through BenchmarkResultIO
protected ProblemBenchmarkResult problemBenchmarkResult; protected ProblemBenchmarkResult<Object> problemBenchmarkResult;


protected final ProblemStatisticType problemStatisticType; protected final ProblemStatisticType problemStatisticType;


Expand Down
Expand Up @@ -71,8 +71,7 @@ public List<File> getGraphFileList() {
public void writeGraphFiles(BenchmarkReport benchmarkReport) { public void writeGraphFiles(BenchmarkReport benchmarkReport) {
XYPlot plot = createPlot(benchmarkReport); XYPlot plot = createPlot(benchmarkReport);
int seriesIndex = 0; int seriesIndex = 0;
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
XYIntervalSeries series = new XYIntervalSeries(singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix()); XYIntervalSeries series = new XYIntervalSeries(singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix());
XYItemRenderer renderer = new YIntervalRenderer(); XYItemRenderer renderer = new YIntervalRenderer();
if (singleBenchmarkResult.hasAllSuccess()) { if (singleBenchmarkResult.hasAllSuccess()) {
Expand Down
Expand Up @@ -78,8 +78,7 @@ public void writeGraphFiles(BenchmarkReport benchmarkReport) {
XYPlot plot = new XYPlot(null, xAxis, yAxis, null); XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
plot.setOrientation(PlotOrientation.VERTICAL); plot.setOrientation(PlotOrientation.VERTICAL);
int seriesIndex = 0; int seriesIndex = 0;
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
XYSeries series = new XYSeries(singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix()); XYSeries series = new XYSeries(singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix());
XYItemRenderer renderer = new XYLineAndShapeRenderer(); XYItemRenderer renderer = new XYLineAndShapeRenderer();
if (singleBenchmarkResult.hasAllSuccess()) { if (singleBenchmarkResult.hasAllSuccess()) {
Expand Down
Expand Up @@ -77,8 +77,7 @@ public void writeGraphFiles(BenchmarkReport benchmarkReport) {
XYPlot plot = new XYPlot(null, xAxis, yAxis, null); XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
plot.setOrientation(PlotOrientation.VERTICAL); plot.setOrientation(PlotOrientation.VERTICAL);
int seriesIndex = 0; int seriesIndex = 0;
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
XYSeries usedSeries = new XYSeries( XYSeries usedSeries = new XYSeries(
singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " used"); singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " used");
// TODO enable max memory, but in the same color as used memory, but with a dotted line instead // TODO enable max memory, but in the same color as used memory, but with a dotted line instead
Expand Down
Expand Up @@ -81,8 +81,7 @@ public void writeGraphFiles(BenchmarkReport benchmarkReport) {
plot.setOrientation(PlotOrientation.VERTICAL); plot.setOrientation(PlotOrientation.VERTICAL);


int seriesIndex = 0; int seriesIndex = 0;
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
XYSeries acceptedSeries = new XYSeries( XYSeries acceptedSeries = new XYSeries(
singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " accepted"); singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " accepted");
XYSeries selectedSeries = new XYSeries( XYSeries selectedSeries = new XYSeries(
Expand Down
Expand Up @@ -73,8 +73,7 @@ public List<File> getGraphFileList() {
public void writeGraphFiles(BenchmarkReport benchmarkReport) { public void writeGraphFiles(BenchmarkReport benchmarkReport) {
List<XYPlot> plotList = new ArrayList<XYPlot>(BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); List<XYPlot> plotList = new ArrayList<XYPlot>(BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE);
int seriesIndex = 0; int seriesIndex = 0;
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList(); for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : results) {
List<XYSeries> seriesList = new ArrayList<XYSeries>(BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); List<XYSeries> seriesList = new ArrayList<XYSeries>(BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE);
// No direct ascending lines between 2 points, but a stepping line instead // No direct ascending lines between 2 points, but a stepping line instead
XYItemRenderer renderer = new XYStepRenderer(); XYItemRenderer renderer = new XYStepRenderer();
Expand Down
Expand Up @@ -415,14 +415,14 @@ public void afterAnnotationsProcessed(DescriptorPolicy descriptorPolicy) {
determineGlobalShadowOrder(); determineGlobalShadowOrder();
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace(" Model annotations parsed for Solution {}:", solutionClass.getSimpleName()); logger.trace(" Model annotations parsed for Solution {}:", solutionClass.getSimpleName());
entityDescriptorMap.entrySet().forEach(entry -> { for (Map.Entry<Class<?>, EntityDescriptor<Solution_>> entry : entityDescriptorMap.entrySet()) {
EntityDescriptor<Solution_> entityDescriptor = entry.getValue(); EntityDescriptor<Solution_> entityDescriptor = entry.getValue();
logger.trace(" Entity {}:", entityDescriptor.getEntityClass().getSimpleName()); logger.trace(" Entity {}:", entityDescriptor.getEntityClass().getSimpleName());
for (VariableDescriptor variableDescriptor : entityDescriptor.getDeclaredVariableDescriptors()) { for (VariableDescriptor variableDescriptor : entityDescriptor.getDeclaredVariableDescriptors()) {
logger.trace(" Variable {} ({})", variableDescriptor.getVariableName(), logger.trace(" Variable {} ({})", variableDescriptor.getVariableName(),
variableDescriptor instanceof GenuineVariableDescriptor ? "genuine" : "shadow"); variableDescriptor instanceof GenuineVariableDescriptor ? "genuine" : "shadow");
} }
}); };
} }
} }


Expand Down

0 comments on commit 125e25a

Please sign in to comment.