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

play with graphstream-rendering

This commit is contained in:
Stefan Schroeder 2013-12-11 14:15:14 +01:00
parent be00d30fde
commit 439ee29895
8 changed files with 209 additions and 172 deletions

View file

@ -240,25 +240,25 @@ public class BicycleMessenger {
//if you want, terminate it after 1000 iterations with no change
// algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(1000));
algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
algorithm.setNuOfIterations(200);
algorithm.setNuOfIterations(2000);
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
//this is just to ensure that solution meet the above constraints
validateSolution(Solutions.bestOf(solutions), bicycleMessengerProblem, nearestMessengers);
// //you may want to plot the problem
// Plotter plotter = new Plotter(bicycleMessengerProblem);
//// plotter.setBoundingBox(10000, 47500, 20000, 67500);
// plotter.plotShipments(true);
// plotter.plot("output/bicycleMessengerProblem.png", "bicycleMessenger");
//
// //and the problem as well as the solution
// Plotter plotter1 = new Plotter(bicycleMessengerProblem, Solutions.bestOf(solutions));
// plotter1.plotShipments(true);
// plotter1.setShowFirstActivity(true);
//// plotter1.setBoundingBox(5000, 45500, 25000, 66500);
// plotter1.plot("output/bicycleMessengerSolution.png", "bicycleMessenger");
//you may want to plot the problem
Plotter plotter = new Plotter(bicycleMessengerProblem);
// plotter.setBoundingBox(10000, 47500, 20000, 67500);
plotter.plotShipments(true);
plotter.plot("output/bicycleMessengerProblem.png", "bicycleMessenger");
//and the problem as well as the solution
Plotter plotter1 = new Plotter(bicycleMessengerProblem, Solutions.bestOf(solutions));
plotter1.plotShipments(true);
plotter1.setShowFirstActivity(true);
// plotter1.setBoundingBox(5000, 45500, 25000, 66500);
plotter1.plot("output/bicycleMessengerSolution.png", "bicycleMessenger");
//and write out your solution in xml
new VrpXMLWriter(bicycleMessengerProblem, solutions).write("output/bicycleMessenger.xml");

View file

@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.Collection;
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.SolutionPlotter;
import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.analysis.toolbox.StopWatch;
@ -113,6 +114,8 @@ public class MultipleDepotExample {
SolutionPrinter.print(Solutions.bestOf(solutions));
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.bestOf(solutions), "output/p01_solution.png", "p01");
new GraphStreamViewer(vrp, Solutions.bestOf(solutions)).setRenderDelay(100).display();
}
}

View file

@ -107,7 +107,8 @@ public class PickupAndDeliveryExample2 {
plotter.setShowFirstActivity(true);
plotter.plot("output/pd_christophides_vrpnc1_solution.png","pd_vrpnc1");
GraphStreamViewer.display(vrp, solution, 100);
new GraphStreamViewer(vrp, solution).setRenderDelay(100).labelWith(jsprit.analysis.toolbox.GraphStreamViewer.Label.ID).display();
}

View file

@ -129,7 +129,7 @@ public class SimpleEnRoutePickupAndDeliveryOpenRoutesExample {
solutionPlotter.plotShipments(true);
solutionPlotter.plot("output/simpleEnRoutePickupAndDeliveryExample_solution.png", "en-route pickup and delivery");
GraphStreamViewer.display(problem, bestSolution, 100);
new GraphStreamViewer(problem, bestSolution).setRenderDelay(100).display();
}
}

View file

@ -101,7 +101,7 @@ public class SolomonExample {
// GraphStream.display(vrp,100);
GraphStreamViewer.display(vrp,solution);
new GraphStreamViewer(vrp,solution).display();
}

View file

@ -95,7 +95,7 @@ public class SolomonOpenExample {
SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/solomon_C101_open_solution.png","C101");
GraphStreamViewer.display(vrp, solution, 50, false);
new GraphStreamViewer(vrp, solution).setRenderDelay(50).setEnableAutoLayout(true).display();
}

View file

@ -102,7 +102,7 @@ public class VRPWithBackhaulsExample {
// plotter.setShowFirstActivity(true);
// plotter.plot("output/vrpwbh_solomon_r101_solution.png","vrpwbh_r101");
GraphStreamViewer.display(vrp, solution, 100);
new GraphStreamViewer(vrp, solution).setRenderDelay(100).setEnableAutoLayout(false).display();
}