VehicleRoutingProblem vrp = vrpBuilder.build();
/*
* Create ComputationalLaboratory
*/
ComputationalLaboratory computationalLab = new ComputationalLaboratory();
/*
* add benchmarking instance
*/
computationalLab.addInstance("SolomonR101", vrp);
/*
* add algorithms through factories
*
*
*
*/
computationalLab.addAlgorithmFactory("schrimpfAcceptance_1", getAlgorithmFactory(1));
computationalLab.addAlgorithmFactory("schrimpfAcceptance_100", getAlgorithmFactory(100));
computationalLab.addAlgorithmFactory("schrimpfAcceptance_500", getAlgorithmFactory(500));
computationalLab.addAlgorithmFactory("schrimpfAcceptance_1000", getAlgorithmFactory(1000));
computationalLab.addAlgorithmFactory("schrimpfAcceptance_2000", getAlgorithmFactory(2000));
computationalLab.addAlgorithmFactory("schrimpfAcceptance_4000", getAlgorithmFactory(4000));
computationalLab.addAlgorithmFactory("schrimpfAcceptance_8000", getAlgorithmFactory(8000));
computationalLab.addAlgorithmFactory("schrimpfAcceptance_12000", getAlgorithmFactory(12000));
/*
* run schrimpfAcceptance 5 times (and thus each with another seed of random number generator)
*/
computationalLab.setNuOfRuns(5);
/*
* plot search progress of different algorithms
*/
final DataCollector dataCollector = new DataCollector();
computationalLab.addListener(new CalculationListener() {
@Override
public void calculationStarts(BenchmarkInstance p, final String algorithmName,VehicleRoutingAlgorithm algorithm, final int run) {}
@Override
public void calculationEnds(BenchmarkInstance p, String algorithmName,VehicleRoutingAlgorithm algorithm, int run,Collection<VehicleRoutingProblemSolution> solutions) {
dataCollector.addDate("R101", algorithmName, run, "costs", Solutions.bestOf(solutions).getCost());
}
});
computationalLab.setThreads(2);
/*
* run the experiments
*/
computationalLab.run();
/*
* plot min, avg and max
*/
XYLineChartBuilder chartBuilder = XYLineChartBuilder.newInstance("variations with iterations", "iterations", "costs");
for(String algorithmName : computationalLab.getAlgorithmNames()){
String[] nameTokens = algorithmName.split("_");
int iteration = Integer.parseInt(nameTokens[1]);
chartBuilder.addData("min", iteration, min(dataCollector.getData("R101", algorithmName, "costs")));
chartBuilder.addData("max", iteration, max(dataCollector.getData("R101", algorithmName, "costs")));
chartBuilder.addData("avg", iteration, avg(dataCollector.getData("R101", algorithmName, "costs")));