mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
make plotter plot shipments
This commit is contained in:
parent
71a3cbe9a8
commit
6099a315ee
1 changed files with 15 additions and 6 deletions
|
|
@ -86,6 +86,8 @@ public class Plotter {
|
||||||
|
|
||||||
private boolean plotShipments = true;
|
private boolean plotShipments = true;
|
||||||
|
|
||||||
|
private Collection<VehicleRoute> routes;
|
||||||
|
|
||||||
public void setShowFirstActivity(boolean show){
|
public void setShowFirstActivity(boolean show){
|
||||||
showFirstActivity = show;
|
showFirstActivity = show;
|
||||||
}
|
}
|
||||||
|
|
@ -102,13 +104,20 @@ public class Plotter {
|
||||||
public Plotter(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) {
|
public Plotter(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) {
|
||||||
super();
|
super();
|
||||||
this.vrp = vrp;
|
this.vrp = vrp;
|
||||||
this.solution = solution;
|
this.routes = solution.getRoutes();
|
||||||
|
plotSolutionAsWell = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plotter(VehicleRoutingProblem vrp, Collection<VehicleRoute> routes) {
|
||||||
|
super();
|
||||||
|
this.vrp = vrp;
|
||||||
|
this.routes = routes;
|
||||||
plotSolutionAsWell = true;
|
plotSolutionAsWell = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void plot(String pngFileName, String plotTitle){
|
public void plot(String pngFileName, String plotTitle){
|
||||||
if(plotSolutionAsWell){
|
if(plotSolutionAsWell){
|
||||||
plotSolutionAsPNG(vrp, solution, pngFileName, plotTitle);
|
plotSolutionAsPNG(vrp, routes, pngFileName, plotTitle);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
plotVrpAsPNG(vrp, pngFileName, plotTitle);
|
plotVrpAsPNG(vrp, pngFileName, plotTitle);
|
||||||
|
|
@ -149,7 +158,7 @@ public class Plotter {
|
||||||
save(chart,pngFile);
|
save(chart,pngFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void plotSolutionAsPNG(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, String pngFile, String title){
|
private void plotSolutionAsPNG(VehicleRoutingProblem vrp, Collection<VehicleRoute> routes, String pngFile, String title){
|
||||||
log.info("plot solution to " + pngFile);
|
log.info("plot solution to " + pngFile);
|
||||||
XYSeriesCollection problem;
|
XYSeriesCollection problem;
|
||||||
XYSeriesCollection solutionColl;
|
XYSeriesCollection solutionColl;
|
||||||
|
|
@ -158,7 +167,7 @@ public class Plotter {
|
||||||
try {
|
try {
|
||||||
problem = makeVrpSeries(vrp, labels);
|
problem = makeVrpSeries(vrp, labels);
|
||||||
shipments = makeShipmentSeries(vrp.getJobs().values(), null);
|
shipments = makeShipmentSeries(vrp.getJobs().values(), null);
|
||||||
solutionColl = makeSolutionSeries(vrp, solution);
|
solutionColl = makeSolutionSeries(vrp, routes);
|
||||||
} catch (NoLocationFoundException e) {
|
} catch (NoLocationFoundException e) {
|
||||||
log.warn("cannot plot vrp, since coord is missing");
|
log.warn("cannot plot vrp, since coord is missing");
|
||||||
return;
|
return;
|
||||||
|
|
@ -305,11 +314,11 @@ public class Plotter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private XYSeriesCollection makeSolutionSeries(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) throws NoLocationFoundException{
|
private XYSeriesCollection makeSolutionSeries(VehicleRoutingProblem vrp, Collection<VehicleRoute> routes) throws NoLocationFoundException{
|
||||||
Locations locations = retrieveLocations(vrp);
|
Locations locations = retrieveLocations(vrp);
|
||||||
XYSeriesCollection coll = new XYSeriesCollection();
|
XYSeriesCollection coll = new XYSeriesCollection();
|
||||||
int counter = 1;
|
int counter = 1;
|
||||||
for(VehicleRoute route : solution.getRoutes()){
|
for(VehicleRoute route : routes){
|
||||||
if(route.isEmpty()) continue;
|
if(route.isEmpty()) continue;
|
||||||
XYSeries series = new XYSeries(counter, false, true);
|
XYSeries series = new XYSeries(counter, false, true);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue