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

public void benchmarkingEnded() {
Expand Down Expand Up @@ -384,15 +383,7 @@ private static Map<SolverBenchmarkResult, WarmUpConfigBackup> backupBenchmarkCon
}
}
ProblemBenchmarkResult problemBenchmarkResult = singleBenchmarkResult.getProblemBenchmarkResult();
List<ProblemStatistic> originalProblemStatisticList = 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 + ").");
}
}
originalProblemStatisticMap.putIfAbsent(problemBenchmarkResult, problemBenchmarkResult.getProblemStatisticList());
singleBenchmarkResult.getProblemBenchmarkResult().setProblemStatisticList(Collections.<ProblemStatistic>emptyList());
for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) { // needs to happen after all problem stats
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
// original solver benchmarks' names)
if (solverBenchmarkResultNameMap != null) {
for (Entry<SolverBenchmarkResult, String> results : solverBenchmarkResultNameMap.entrySet()) {
if (!results.getKey().getName().equals(results.getValue())) {
results.getKey().setName(results.getValue());
for (Entry<SolverBenchmarkResult, String> entry : solverBenchmarkResultNameMap.entrySet()) {
SolverBenchmarkResult result = entry.getKey();
String newName = entry.getValue();
if (!result.getName().equals(newName)) {
result.setName(newName);
}
}
}
Expand Down
Expand Up @@ -217,9 +217,8 @@ public void writeReport() {
writeTimeSpentSummaryChart();
writeTimeSpentScalabilitySummaryChart();
writeBestScorePerTimeSpentSummaryChart();
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList();
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) {
if (!subSingleBenchmarkResult.hasAllSuccess()) {
continue;
Expand All @@ -239,14 +238,12 @@ public void writeReport() {
}
}
}
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
if (problemBenchmarkResult.hasAnySuccess()) {
List<ProblemStatistic> statistics = problemBenchmarkResult.getProblemStatisticList();
for (ProblemStatistic problemStatistic : statistics) {
for (ProblemStatistic problemStatistic : problemBenchmarkResult.getProblemStatisticList()) {
problemStatistic.writeGraphFiles(this);
}
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList();
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
if (singleBenchmarkResult.hasAllSuccess()) {
for (PureSubSingleStatistic pureSubSingleStatistic : singleBenchmarkResult.getMedian().getPureSubSingleStatisticList()) {
pureSubSingleStatistic.writeGraphFiles(this);
Expand All @@ -255,9 +252,8 @@ public void writeReport() {
}
}
}
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList();
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
for (SubSingleBenchmarkResult subSingleBenchmarkResult : singleBenchmarkResult.getSubSingleBenchmarkResultList()) {
if (!subSingleBenchmarkResult.hasAllSuccess()) {
continue;
Expand Down Expand Up @@ -690,16 +686,15 @@ private File writeChartToImageFile(JFreeChart chart, String fileNameBase) {

private void determineDefaultShownScoreLevelIndex() {
defaultShownScoreLevelIndex = Integer.MAX_VALUE;
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
if (problemBenchmarkResult.hasAnySuccess()) {
double[] winningScoreLevels = ScoreUtils.extractLevelDoubles(
problemBenchmarkResult.getWinningSingleBenchmarkResult().getAverageScore());
int[] differenceCount = new int[winningScoreLevels.length];
for (int i = 0; i < differenceCount.length; i++) {
differenceCount[i] = 0;
}
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList();
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
if (singleBenchmarkResult.hasAllSuccess()) {
double[] scoreLevels = ScoreUtils.extractLevelDoubles(singleBenchmarkResult.getAverageScore());
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) {
for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
for (ProblemBenchmarkResult<Object> problemBenchmarkResult : plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList()) {
problemBenchmarkResult.setPlannerBenchmarkResult(plannerBenchmarkResult);
if (problemBenchmarkResult.getProblemStatisticList() == null) {
problemBenchmarkResult.setProblemStatisticList(new ArrayList<ProblemStatistic>(0));
}
List<ProblemStatistic> statistics = problemBenchmarkResult.getProblemStatisticList();
statistics.forEach(statistic -> statistic.setProblemBenchmarkResult(problemBenchmarkResult));
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList();
results.forEach(result -> result.setProblemBenchmarkResult(problemBenchmarkResult));
for (ProblemStatistic problemStatistic : problemBenchmarkResult.getProblemStatisticList()) {
problemStatistic.setProblemBenchmarkResult(problemBenchmarkResult);
}
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
singleBenchmarkResult.setProblemBenchmarkResult(problemBenchmarkResult);
}
}
for (SolverBenchmarkResult solverBenchmarkResult : plannerBenchmarkResult.getSolverBenchmarkResultList()) {
solverBenchmarkResult.setPlannerBenchmarkResult(plannerBenchmarkResult);
Expand Down
Expand Up @@ -55,7 +55,7 @@ public abstract class ProblemStatistic {
protected final transient Logger logger = LoggerFactory.getLogger(getClass());

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

protected final ProblemStatisticType problemStatisticType;

Expand Down
Expand Up @@ -71,8 +71,7 @@ public List<File> getGraphFileList() {
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
XYPlot plot = createPlot(benchmarkReport);
int seriesIndex = 0;
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList();
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
XYIntervalSeries series = new XYIntervalSeries(singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix());
XYItemRenderer renderer = new YIntervalRenderer();
if (singleBenchmarkResult.hasAllSuccess()) {
Expand Down
Expand Up @@ -78,8 +78,7 @@ public void writeGraphFiles(BenchmarkReport benchmarkReport) {
XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
plot.setOrientation(PlotOrientation.VERTICAL);
int seriesIndex = 0;
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList();
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
XYSeries series = new XYSeries(singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix());
XYItemRenderer renderer = new XYLineAndShapeRenderer();
if (singleBenchmarkResult.hasAllSuccess()) {
Expand Down
Expand Up @@ -77,8 +77,7 @@ public void writeGraphFiles(BenchmarkReport benchmarkReport) {
XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
plot.setOrientation(PlotOrientation.VERTICAL);
int seriesIndex = 0;
List<SingleBenchmarkResult> results = problemBenchmarkResult.getSingleBenchmarkResultList();
for (SingleBenchmarkResult singleBenchmarkResult : results) {
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
XYSeries usedSeries = new XYSeries(
singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " used");
// 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);

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

Expand Down

0 comments on commit 125e25a

Please sign in to comment.