1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

prepare for release v0.1.0

This commit is contained in:
Stefan Schroeder 2013-11-22 16:54:15 +01:00
parent 77d38de461
commit a85b0fc395
304 changed files with 4035 additions and 64795 deletions

View file

@ -1,90 +0,0 @@
/*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package analysis;
import basics.VehicleRoutingProblemSolution;
import basics.route.DefaultVehicleRouteCostCalculator;
import basics.route.VehicleRoute;
/**
* Printer to print the details of a vehicle-routing-problem solution.
*
* @author stefan schroeder
*
*/
public class SolutionPrinter {
/**
* Enum to indicate verbose-level.
*
* <p> Print.CONCISE and Print.VERBOSE are available.
*
* @author stefan schroeder
*
*/
public enum Print {
CONCISE,VERBOSE
}
/**
* Prints costs and #vehicles to stdout (System.out.println).
*
* @param solution
*/
public static void print(VehicleRoutingProblemSolution solution){
System.out.println("[costs="+solution.getCost() + "]");
System.out.println("[#vehicles="+solution.getRoutes().size() + "]");
}
/**
* Prints the details of the solution according to a print-level, i.e. Print.CONCISE or PRINT.VERBOSE.
*
* <p>CONCISE prints total-costs and #vehicles.
* <p>VERBOSE prints the route-details additionally. If the DefaultVehicleRouteCostCalculator (which is the standard-calculator)
* is used in VehicleRoute, then route-costs are differentiated further between transport, activity, vehicle, driver and other-costs.
*
* @param solution
* @param level
*
* @deprecated is not going to work anymore
*/
@Deprecated
public static void print(VehicleRoutingProblemSolution solution, Print level){
if(level.equals(Print.CONCISE)){
print(solution);
}
else{
print(solution);
System.out.println("routes");
int routeCount = 1;
for(VehicleRoute route : solution.getRoutes()){
System.out.println("[route="+routeCount+"][departureTime="+route.getStart().getEndTime()+"[total=" + route.getCost() + "]");
if(route.getVehicleRouteCostCalculator() instanceof DefaultVehicleRouteCostCalculator){
DefaultVehicleRouteCostCalculator defaultCalc = (DefaultVehicleRouteCostCalculator) route.getVehicleRouteCostCalculator();
System.out.println("[transport=" + defaultCalc.getTpCosts() + "][activity=" + defaultCalc.getActCosts() +
"][vehicle=" + defaultCalc.getVehicleCosts() + "][driver=" + defaultCalc.getDriverCosts() + "][other=" + defaultCalc.getOther() + "]");
}
routeCount++;
}
}
}
}

View file

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package analysis;
package jsprit.analysis.toolbox;
import java.io.File;
import java.io.IOException;
@ -22,24 +22,24 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.listener.AlgorithmEndsListener;
import jsprit.core.algorithm.listener.AlgorithmStartsListener;
import jsprit.core.algorithm.listener.IterationEndsListener;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import org.apache.log4j.Logger;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.NumberTickUnit;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.Range;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import basics.VehicleRoutingAlgorithm;
import basics.VehicleRoutingProblem;
import basics.VehicleRoutingProblemSolution;
import basics.algo.AlgorithmEndsListener;
import basics.algo.AlgorithmStartsListener;
import basics.algo.IterationEndsListener;
/**
@ -77,6 +77,9 @@ public class AlgorithmSearchProgressChartListener implements IterationEndsListen
public AlgorithmSearchProgressChartListener(String pngFileName) {
super();
this.filename = pngFileName;
if(!this.filename.endsWith("png")){
this.filename += ".png";
}
}

View file

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package analysis;
package jsprit.analysis.toolbox;
import java.util.ArrayList;
import java.util.Collection;
@ -25,20 +25,21 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import jsprit.analysis.util.BenchmarkWriter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.VehicleRoutingAlgorithmFactory;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.util.BenchmarkInstance;
import jsprit.core.util.BenchmarkResult;
import jsprit.core.util.Solutions;
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import util.BenchmarkInstance;
import util.BenchmarkResult;
import util.BenchmarkWriter;
import util.Solutions;
import algorithms.VehicleRoutingAlgorithms;
import basics.VehicleRoutingAlgorithm;
import basics.VehicleRoutingProblem;
import basics.VehicleRoutingProblemSolution;
import basics.algo.VehicleRoutingAlgorithmFactory;
import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
public class ConcurrentBenchmarker {

View file

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package analysis;
package jsprit.analysis.toolbox;
import java.awt.BasicStroke;
import java.awt.Color;
@ -25,6 +25,19 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.job.Delivery;
import jsprit.core.problem.job.Job;
import jsprit.core.problem.job.Pickup;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.job.Shipment;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.solution.route.activity.TourActivity;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.util.Coordinate;
import jsprit.core.util.Locations;
import org.apache.log4j.Logger;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
@ -43,18 +56,6 @@ import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.RectangleEdge;
import util.Coordinate;
import util.Locations;
import basics.Delivery;
import basics.Job;
import basics.Pickup;
import basics.Service;
import basics.Shipment;
import basics.VehicleRoutingProblem;
import basics.VehicleRoutingProblemSolution;
import basics.route.TourActivity;
import basics.route.Vehicle;
import basics.route.VehicleRoute;
public class Plotter {
@ -80,8 +81,6 @@ public class Plotter {
private VehicleRoutingProblem vrp;
private VehicleRoutingProblemSolution solution;
private boolean plotSolutionAsWell = false;
private boolean plotShipments = true;
@ -116,11 +115,13 @@ public class Plotter {
}
public void plot(String pngFileName, String plotTitle){
String filename = pngFileName;
if(!pngFileName.endsWith(".png")) filename += ".png";
if(plotSolutionAsWell){
plotSolutionAsPNG(vrp, routes, pngFileName, plotTitle);
plotSolutionAsPNG(vrp, routes, filename, plotTitle);
}
else{
plotVrpAsPNG(vrp, pngFileName, plotTitle);
plotVrpAsPNG(vrp, filename, plotTitle);
}
}

View file

@ -14,11 +14,9 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package analysis;
package jsprit.analysis.toolbox;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.geom.Ellipse2D;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@ -27,31 +25,29 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.job.Delivery;
import jsprit.core.problem.job.Job;
import jsprit.core.problem.job.Pickup;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.solution.route.activity.TourActivity;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.util.Coordinate;
import jsprit.core.util.Locations;
import org.apache.log4j.Logger;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.annotations.XYShapeAnnotation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.XYItemLabelGenerator;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.XYDataItem;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import util.Coordinate;
import util.Locations;
import basics.Delivery;
import basics.Job;
import basics.Pickup;
import basics.Service;
import basics.VehicleRoutingProblem;
import basics.VehicleRoutingProblemSolution;
import basics.route.TourActivity;
import basics.route.Vehicle;
import basics.route.VehicleRoute;
/**
@ -82,7 +78,9 @@ public class SolutionPlotter {
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
*/
public static void plotVrpAsPNG(VehicleRoutingProblem vrp, String pngFile, String title){
log.info("plot routes to " + pngFile);
String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png";
log.info("plot routes to " + filename);
XYSeriesCollection problem;
Map<XYDataItem,String> labels = new HashMap<XYDataItem, String>();
try {
@ -93,7 +91,7 @@ public class SolutionPlotter {
}
XYPlot plot = createPlot(problem, labels);
JFreeChart chart = new JFreeChart(title, plot);
save(chart,pngFile);
save(chart,filename);
}
/**
@ -106,7 +104,9 @@ public class SolutionPlotter {
* @see VehicleRoute
*/
public static void plotRoutesAsPNG(Collection<VehicleRoute> routes, Locations locations, String pngFile, String title) {
log.info("plot routes to " + pngFile);
String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png";
log.info("plot routes to " + filename);
XYSeriesCollection problem;
Map<XYDataItem,String> labels = new HashMap<XYDataItem, String>();
try {
@ -118,7 +118,7 @@ public class SolutionPlotter {
XYSeriesCollection solutionColl = makeSolutionSeries(routes,locations);
XYPlot plot = createPlot(problem, solutionColl, labels);
JFreeChart chart = new JFreeChart(title, plot);
save(chart,pngFile);
save(chart,filename);
}
/**
@ -133,7 +133,9 @@ public class SolutionPlotter {
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
*/
public static void plotSolutionAsPNG(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, String pngFile, String title){
log.info("plot solution to " + pngFile);
String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png";
log.info("plot solution to " + filename);
XYSeriesCollection problem;
XYSeriesCollection solutionColl;
Map<XYDataItem,String> labels = new HashMap<XYDataItem, String>();
@ -146,7 +148,7 @@ public class SolutionPlotter {
}
XYPlot plot = createPlot(problem, solutionColl, labels);
JFreeChart chart = new JFreeChart(title, plot);
save(chart,pngFile);
save(chart,filename);
}

View file

@ -0,0 +1,88 @@
/*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package jsprit.analysis.toolbox;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
/**
* Printer to print the details of a vehicle-routing-problem solution.
*
* @author stefan schroeder
*
*/
public class SolutionPrinter {
/**
* Enum to indicate verbose-level.
*
* <p> Print.CONCISE and Print.VERBOSE are available.
*
* @author stefan schroeder
*
*/
public enum Print {
CONCISE,VERBOSE
}
/**
* Prints costs and #vehicles to stdout (System.out.println).
*
* @param solution
*/
public static void print(VehicleRoutingProblemSolution solution){
System.out.println("[costs="+solution.getCost() + "]");
System.out.println("[#vehicles="+solution.getRoutes().size() + "]");
}
// /**
// * Prints the details of the solution according to a print-level, i.e. Print.CONCISE or PRINT.VERBOSE.
// *
// * <p>CONCISE prints total-costs and #vehicles.
// * <p>VERBOSE prints the route-details additionally. If the DefaultVehicleRouteCostCalculator (which is the standard-calculator)
// * is used in VehicleRoute, then route-costs are differentiated further between transport, activity, vehicle, driver and other-costs.
// *
// * @param solution
// * @param level
// *
// * @deprecated is not going to work anymore
// */
// @Deprecated
// public static void print(VehicleRoutingProblemSolution solution, Print level){
// if(level.equals(Print.CONCISE)){
// print(solution);
// }
// else{
// print(solution);
// System.out.println("routes");
// int routeCount = 1;
// for(VehicleRoute route : solution.getRoutes()){
// System.out.println("[route="+routeCount+"][departureTime="+route.getStart().getEndTime()+"[total=" + route.getCost() + "]");
// if(route.getVehicleRouteCostCalculator() instanceof DefaultVehicleRouteCostCalculator){
// DefaultVehicleRouteCostCalculator defaultCalc = (DefaultVehicleRouteCostCalculator) route.getVehicleRouteCostCalculator();
// System.out.println("[transport=" + defaultCalc.getTpCosts() + "][activity=" + defaultCalc.getActCosts() +
// "][vehicle=" + defaultCalc.getVehicleCosts() + "][driver=" + defaultCalc.getDriverCosts() + "][other=" + defaultCalc.getOther() + "]");
// }
// routeCount++;
// }
// }
//
//
// }
}

View file

@ -14,17 +14,18 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package analysis;
package jsprit.analysis.toolbox;
import java.util.Collection;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.listener.AlgorithmEndsListener;
import jsprit.core.algorithm.listener.AlgorithmStartsListener;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import org.apache.log4j.Logger;
import basics.VehicleRoutingAlgorithm;
import basics.VehicleRoutingProblem;
import basics.VehicleRoutingProblemSolution;
import basics.algo.AlgorithmEndsListener;
import basics.algo.AlgorithmStartsListener;
public class StopWatch implements AlgorithmStartsListener, AlgorithmEndsListener{

View file

@ -14,10 +14,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package util;
package jsprit.analysis.util;
import java.util.Collection;
import jsprit.core.util.BenchmarkResult;
public interface BenchmarkWriter {
public void write(Collection<BenchmarkResult> results);
}

View file

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package util;
package jsprit.analysis.util;
import java.io.BufferedWriter;
import java.io.File;
@ -22,6 +22,8 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.Collection;
import jsprit.core.util.BenchmarkResult;
import org.jfree.chart.renderer.xy.DeviationRenderer;
public class HtmlBenchmarkTableWriter implements BenchmarkWriter{