Package jsprit.analysis.toolbox.ComputationalLaboratory

Examples of jsprit.analysis.toolbox.ComputationalLaboratory.DataCollector


    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")));
    }
   
    XYLineChartBuilder.saveChartAsPNG(chartBuilder.build(), "output/computationalStudies_min_max_avg.png");
   
   
View Full Code Here


     
    });
    /*
     * define dataCollector to collect an arbitrary number of indicators as well as solutions
     */
    final DataCollector dataCollector = new DataCollector();
    computationalLab.addListener(new CalculationListener() {
     
      @Override
      public void calculationStarts(BenchmarkInstance p, String algorithmName,VehicleRoutingAlgorithm algorithm, int run) {}
     
      @Override
      public void calculationEnds(BenchmarkInstance p, String algorithmName,VehicleRoutingAlgorithm algorithm, int run,Collection<VehicleRoutingProblemSolution> solutions) {
        //memorize solution
        dataCollector.addSolution(p.name, algorithmName, run, Solutions.bestOf(solutions));
      }
     
    });
    /*
     * determine number of threads to be used
     */
    computationalLab.setThreads(2);
    /*
     * run the experiments
     */
    computationalLab.run();
   
    /*
     * plot the lineChart
     */
    XYLineChartBuilder.saveChartAsPNG(chartBuilder.build(), "output/computationalStudies_alphaSensitivity.png");
   
    /*
     * print best solution
     */
    SolutionPrinter.print(vrp, Solutions.bestOf(dataCollector.getSolutions()), Print.VERBOSE);
   
    /*
     * plot best
     */
    Plotter plotter = new Plotter(vrp,Solutions.bestOf(dataCollector.getSolutions()));
    plotter.plot("output/bestOf.png", "bestOfR101");
   
  }
View Full Code Here

TOP

Related Classes of jsprit.analysis.toolbox.ComputationalLaboratory.DataCollector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.