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:
parent
be00d30fde
commit
439ee29895
8 changed files with 209 additions and 172 deletions
|
|
@ -21,16 +21,17 @@ public class GraphStreamViewer {
|
||||||
protected static String styleSheet =
|
protected static String styleSheet =
|
||||||
"node {" +
|
"node {" +
|
||||||
" size: 7px, 7px;" +
|
" size: 7px, 7px;" +
|
||||||
" fill-color: orange;" +
|
" fill-color: rgb(255,204,0);" +
|
||||||
" text-alignment: at-right;" +
|
" text-alignment: at-right;" +
|
||||||
" stroke-mode: plain;" +
|
" stroke-mode: plain;" +
|
||||||
" stroke-color: black;" +
|
" stroke-color: black;" +
|
||||||
|
" stroke-width: 1.0;" +
|
||||||
"}" +
|
"}" +
|
||||||
"node.pickup {" +
|
"node.pickup {" +
|
||||||
" fill-color: green;" +
|
" fill-color: rgb(255,204,0);" +
|
||||||
"}" +
|
"}" +
|
||||||
"node.delivery {" +
|
"node.delivery {" +
|
||||||
" fill-color: blue;" +
|
" fill-color: rgb(0,102,153);" +
|
||||||
"}" +
|
"}" +
|
||||||
"node.depot {" +
|
"node.depot {" +
|
||||||
" fill-color: red;" +
|
" fill-color: red;" +
|
||||||
|
|
@ -93,154 +94,36 @@ public class GraphStreamViewer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void display(View view){
|
|
||||||
System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
|
|
||||||
Graph g = new MultiGraph("g");
|
|
||||||
g.addAttribute("ui.quality");
|
|
||||||
g.addAttribute("ui.antialias");
|
|
||||||
g.addAttribute("ui.stylesheet", styleSheet);
|
|
||||||
|
|
||||||
Viewer viewer = g.display();
|
|
||||||
if(!view.enableAutoDisplay) viewer.disableAutoLayout();
|
|
||||||
|
|
||||||
|
|
||||||
for(Vehicle vehicle : view.vrp.getVehicles()){
|
// public static void display(VehicleRoutingProblem vrp, int renderDelay_in_ms) {
|
||||||
renderVehicle(g,vehicle,view.label);
|
// View builder = new View(vrp);
|
||||||
sleep(view.renderDelay);
|
// builder.setRenderDelay(renderDelay_in_ms);
|
||||||
}
|
// display();
|
||||||
|
// }
|
||||||
|
|
||||||
for(Job j : view.vrp.getJobs().values()){
|
|
||||||
if(j instanceof Service){
|
|
||||||
renderService(g,(Service)j,view.label);
|
|
||||||
}
|
|
||||||
else if(j instanceof Shipment){
|
|
||||||
renderShipment(g,(Shipment)j,view.label,view.renderShipments);
|
|
||||||
}
|
|
||||||
sleep(view.renderDelay);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(view.solution != null){
|
|
||||||
int routeId = 1;
|
|
||||||
for(VehicleRoute route : view.solution.getRoutes()){
|
|
||||||
renderRoute(g,route,routeId,view.renderDelay);
|
|
||||||
sleep(view.renderDelay);
|
|
||||||
routeId++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(view.boundingBox != null){
|
// public static void display(VehicleRoutingProblem vrp) {
|
||||||
//// viewer.getDefaultView().getCamera().setViewPercent(0.5);
|
// display();
|
||||||
// System.out.println("metric="+viewer.getDefaultView().getCamera().getMetrics());
|
// }
|
||||||
//// viewer.getDefaultView().getCamera().setViewCenter(15000, 50000, 0);
|
|
||||||
//// viewer.getDefaultView().getCamera().setViewPercent(0.5);
|
// public static void display(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, int renderDelay_in_ms, boolean enableAutoLayout) {
|
||||||
// viewer.getDefaultView().getCamera().setBounds(10000,40000, 0, 20000, 60000, 0);
|
// View view = new View(vrp,solution);
|
||||||
// System.out.println("metric="+viewer.getDefaultView().getCamera().getMetrics());
|
// view.setEnableAutoDisplay(enableAutoLayout);
|
||||||
//// viewer.getDefaultView().se
|
// view.setRenderDelay(renderDelay_in_ms);
|
||||||
// viewer.getDefaultView().display(viewer.getGraphicGraph(), true);
|
// display();
|
||||||
//// viewer.getDefaultView().getCamera().setViewPercent(0.5);
|
// }
|
||||||
//
|
//
|
||||||
}
|
// public static void display(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, int renderDelay_in_ms) {
|
||||||
|
// View view = new View(vrp,solution);
|
||||||
}
|
// view.setRenderDelay(renderDelay_in_ms);
|
||||||
|
// display();
|
||||||
public static void display(VehicleRoutingProblem vrp, int renderDelay_in_ms) {
|
// }
|
||||||
View builder = new View(vrp);
|
//
|
||||||
builder.setRenderDelay(renderDelay_in_ms);
|
// public static void display(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) {
|
||||||
display(builder);
|
// display();
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static void renderShipment(Graph g, Shipment shipment, Label label, boolean renderShipments) {
|
|
||||||
|
|
||||||
Node n1 = g.addNode(makeId(shipment.getId(),shipment.getPickupLocation()));
|
|
||||||
if(label.equals(Label.ID)) n1.addAttribute("ui.label", shipment.getId());
|
|
||||||
n1.addAttribute("x", shipment.getPickupCoord().getX());
|
|
||||||
n1.addAttribute("y", shipment.getPickupCoord().getY());
|
|
||||||
n1.setAttribute("ui.class", "pickup");
|
|
||||||
|
|
||||||
Node n2 = g.addNode(makeId(shipment.getId(),shipment.getDeliveryLocation()));
|
|
||||||
if(label.equals(Label.ID)) n2.addAttribute("ui.label", shipment.getId());
|
|
||||||
n2.addAttribute("x", shipment.getDeliveryCoord().getX());
|
|
||||||
n2.addAttribute("y", shipment.getDeliveryCoord().getY());
|
|
||||||
n2.setAttribute("ui.class", "delivery");
|
|
||||||
|
|
||||||
if(renderShipments){
|
|
||||||
Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(),shipment.getPickupLocation()),
|
|
||||||
makeId(shipment.getId(),shipment.getDeliveryLocation()), true);
|
|
||||||
s.addAttribute("ui.class", "shipment");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void sleep(long renderDelay_in_ms2) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(renderDelay_in_ms2);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void renderService(Graph g, Service service, Label label) {
|
|
||||||
Node n = g.addNode(makeId(service.getId(),service.getLocationId()));
|
|
||||||
if(label.equals(Label.ID)) n.addAttribute("ui.label", service.getId());
|
|
||||||
n.addAttribute("x", service.getCoord().getX());
|
|
||||||
n.addAttribute("y", service.getCoord().getY());
|
|
||||||
if(service.getType().equals("pickup")) n.setAttribute("ui.class", "pickup");
|
|
||||||
if(service.getType().equals("delivery")) n.setAttribute("ui.class", "delivery");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String makeId(String id, String locationId) {
|
|
||||||
return new StringBuffer().append(id).append("_").append(locationId).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void renderVehicle(Graph g, Vehicle vehicle, Label label) {
|
|
||||||
Node n = g.addNode(makeId(vehicle.getId(),vehicle.getLocationId()));
|
|
||||||
if(label.equals(Label.ID)) n.addAttribute("ui.label", "depot");
|
|
||||||
n.addAttribute("x", vehicle.getCoord().getX());
|
|
||||||
n.addAttribute("y", vehicle.getCoord().getY());
|
|
||||||
n.setAttribute("ui.class", "depot");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void display(VehicleRoutingProblem vrp) {
|
|
||||||
display(new View(vrp));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void display(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, int renderDelay_in_ms, boolean enableAutoLayout) {
|
|
||||||
View view = new View(vrp,solution);
|
|
||||||
view.setEnableAutoDisplay(enableAutoLayout);
|
|
||||||
view.setRenderDelay(renderDelay_in_ms);
|
|
||||||
display(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void display(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, int renderDelay_in_ms) {
|
|
||||||
View view = new View(vrp,solution);
|
|
||||||
view.setRenderDelay(renderDelay_in_ms);
|
|
||||||
display(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void display(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) {
|
|
||||||
display(new View(vrp,solution));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void renderRoute(Graph g, VehicleRoute route, int routeId, long renderDelay_in_ms) {
|
|
||||||
int vehicle_edgeId = 1;
|
|
||||||
String prevIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getLocationId());
|
|
||||||
for(TourActivity act : route.getActivities()){
|
|
||||||
String currIdentifier = makeId(((JobActivity)act).getJob().getId(),act.getLocationId());
|
|
||||||
g.addEdge(makeEdgeId(routeId,vehicle_edgeId), prevIdentifier, currIdentifier, true);
|
|
||||||
prevIdentifier = currIdentifier;
|
|
||||||
vehicle_edgeId++;
|
|
||||||
sleep(renderDelay_in_ms);
|
|
||||||
}
|
|
||||||
if(route.getVehicle().isReturnToDepot()){
|
|
||||||
g.addEdge(makeEdgeId(routeId,vehicle_edgeId), prevIdentifier, makeId(route.getVehicle().getId(),route.getVehicle().getLocationId()), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String makeEdgeId(int routeId, int vehicle_edgeId) {
|
|
||||||
return Integer.valueOf(routeId).toString() + "." + Integer.valueOf(vehicle_edgeId).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum Label {
|
public static enum Label {
|
||||||
NO_LABEL, ID
|
NO_LABEL, ID
|
||||||
|
|
@ -310,16 +193,166 @@ public class GraphStreamViewer {
|
||||||
// public GraphStreamViewer setBoundingBox(double minX, double minY, double maxX, double maxY){
|
// public GraphStreamViewer setBoundingBox(double minX, double minY, double maxX, double maxY){
|
||||||
// boundingBox = new BoundingBox(minX,minY,maxX,maxY);
|
// boundingBox = new BoundingBox(minX,minY,maxX,maxY);
|
||||||
// return this;
|
// return this;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public void display(){
|
||||||
|
// display();
|
||||||
|
//// View view = new View(vrp,solution);
|
||||||
|
//// view.setEnableAutoDisplay(enableAutoLayout);
|
||||||
|
//// view.setLabel(label);
|
||||||
|
//// view.setRenderDelay(renderDelay_in_ms);
|
||||||
|
//// view.setRenderShipments(renderShipments);
|
||||||
|
//// view.setBoundingBox(boundingBox);
|
||||||
|
//// display(view);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void display(){
|
public void display(){
|
||||||
View view = new View(vrp,solution);
|
System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
|
||||||
view.setEnableAutoDisplay(enableAutoLayout);
|
Graph g = new MultiGraph("g");
|
||||||
view.setLabel(label);
|
g.addAttribute("ui.quality");
|
||||||
view.setRenderDelay(renderDelay_in_ms);
|
g.addAttribute("ui.antialias");
|
||||||
view.setRenderShipments(renderShipments);
|
g.addAttribute("ui.stylesheet", styleSheet);
|
||||||
view.setBoundingBox(boundingBox);
|
|
||||||
display(view);
|
Viewer viewer = g.display();
|
||||||
|
if(!enableAutoLayout) viewer.disableAutoLayout();
|
||||||
|
|
||||||
|
|
||||||
|
for(Vehicle vehicle : vrp.getVehicles()){
|
||||||
|
renderVehicle(g,vehicle,label);
|
||||||
|
sleep(renderDelay_in_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Job j : vrp.getJobs().values()){
|
||||||
|
if(j instanceof Service){
|
||||||
|
renderService(g,(Service)j,label);
|
||||||
|
}
|
||||||
|
else if(j instanceof Shipment){
|
||||||
|
renderShipment(g,(Shipment)j,label,renderShipments);
|
||||||
|
}
|
||||||
|
sleep(renderDelay_in_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(solution != null){
|
||||||
|
int routeId = 1;
|
||||||
|
for(VehicleRoute route : solution.getRoutes()){
|
||||||
|
renderRoute(g,route,routeId,renderDelay_in_ms);
|
||||||
|
sleep(renderDelay_in_ms);
|
||||||
|
routeId++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(view.boundingBox != null){
|
||||||
|
//// viewer.getDefaultView().getCamera().setViewPercent(0.5);
|
||||||
|
// System.out.println("metric="+viewer.getDefaultView().getCamera().getMetrics());
|
||||||
|
//// viewer.getDefaultView().getCamera().setViewCenter(15000, 50000, 0);
|
||||||
|
//// viewer.getDefaultView().getCamera().setViewPercent(0.5);
|
||||||
|
// viewer.getDefaultView().getCamera().setBounds(10000,40000, 0, 20000, 60000, 0);
|
||||||
|
// System.out.println("metric="+viewer.getDefaultView().getCamera().getMetrics());
|
||||||
|
//// viewer.getDefaultView().se
|
||||||
|
// viewer.getDefaultView().display(viewer.getGraphicGraph(), true);
|
||||||
|
//// viewer.getDefaultView().getCamera().setViewPercent(0.5);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static void display(VehicleRoutingProblem vrp, int renderDelay_in_ms) {
|
||||||
|
// View builder = new View(vrp);
|
||||||
|
// builder.setRenderDelay(renderDelay_in_ms);
|
||||||
|
// display();
|
||||||
|
// }
|
||||||
|
|
||||||
|
private void renderShipment(Graph g, Shipment shipment, Label label, boolean renderShipments) {
|
||||||
|
|
||||||
|
Node n1 = g.addNode(makeId(shipment.getId(),shipment.getPickupLocation()));
|
||||||
|
if(label.equals(Label.ID)) n1.addAttribute("ui.label", shipment.getId());
|
||||||
|
n1.addAttribute("x", shipment.getPickupCoord().getX());
|
||||||
|
n1.addAttribute("y", shipment.getPickupCoord().getY());
|
||||||
|
n1.setAttribute("ui.class", "pickup");
|
||||||
|
|
||||||
|
Node n2 = g.addNode(makeId(shipment.getId(),shipment.getDeliveryLocation()));
|
||||||
|
if(label.equals(Label.ID)) n2.addAttribute("ui.label", shipment.getId());
|
||||||
|
n2.addAttribute("x", shipment.getDeliveryCoord().getX());
|
||||||
|
n2.addAttribute("y", shipment.getDeliveryCoord().getY());
|
||||||
|
n2.setAttribute("ui.class", "delivery");
|
||||||
|
|
||||||
|
if(renderShipments){
|
||||||
|
Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(),shipment.getPickupLocation()),
|
||||||
|
makeId(shipment.getId(),shipment.getDeliveryLocation()), true);
|
||||||
|
s.addAttribute("ui.class", "shipment");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sleep(long renderDelay_in_ms2) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(renderDelay_in_ms2);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderService(Graph g, Service service, Label label) {
|
||||||
|
Node n = g.addNode(makeId(service.getId(),service.getLocationId()));
|
||||||
|
if(label.equals(Label.ID)) n.addAttribute("ui.label", service.getId());
|
||||||
|
n.addAttribute("x", service.getCoord().getX());
|
||||||
|
n.addAttribute("y", service.getCoord().getY());
|
||||||
|
if(service.getType().equals("pickup")) n.setAttribute("ui.class", "pickup");
|
||||||
|
if(service.getType().equals("delivery")) n.setAttribute("ui.class", "delivery");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String makeId(String id, String locationId) {
|
||||||
|
return new StringBuffer().append(id).append("_").append(locationId).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderVehicle(Graph g, Vehicle vehicle, Label label) {
|
||||||
|
Node n = g.addNode(makeId(vehicle.getId(),vehicle.getLocationId()));
|
||||||
|
if(label.equals(Label.ID)) n.addAttribute("ui.label", "depot");
|
||||||
|
n.addAttribute("x", vehicle.getCoord().getX());
|
||||||
|
n.addAttribute("y", vehicle.getCoord().getY());
|
||||||
|
n.setAttribute("ui.class", "depot");
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static void display(VehicleRoutingProblem vrp) {
|
||||||
|
// display();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public static void display(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, int renderDelay_in_ms, boolean enableAutoLayout) {
|
||||||
|
// View view = new View(vrp,solution);
|
||||||
|
// view.setEnableAutoDisplay(enableAutoLayout);
|
||||||
|
// view.setRenderDelay(renderDelay_in_ms);
|
||||||
|
// display();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static void display(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, int renderDelay_in_ms) {
|
||||||
|
// View view = new View(vrp,solution);
|
||||||
|
// view.setRenderDelay(renderDelay_in_ms);
|
||||||
|
// display();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static void display(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) {
|
||||||
|
// display();
|
||||||
|
// }
|
||||||
|
|
||||||
|
private void renderRoute(Graph g, VehicleRoute route, int routeId, long renderDelay_in_ms) {
|
||||||
|
int vehicle_edgeId = 1;
|
||||||
|
String prevIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getLocationId());
|
||||||
|
for(TourActivity act : route.getActivities()){
|
||||||
|
String currIdentifier = makeId(((JobActivity)act).getJob().getId(),act.getLocationId());
|
||||||
|
g.addEdge(makeEdgeId(routeId,vehicle_edgeId), prevIdentifier, currIdentifier, true);
|
||||||
|
prevIdentifier = currIdentifier;
|
||||||
|
vehicle_edgeId++;
|
||||||
|
sleep(renderDelay_in_ms);
|
||||||
|
}
|
||||||
|
if(route.getVehicle().isReturnToDepot()){
|
||||||
|
g.addEdge(makeEdgeId(routeId,vehicle_edgeId), prevIdentifier, makeId(route.getVehicle().getId(),route.getVehicle().getLocationId()), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String makeEdgeId(int routeId, int vehicle_edgeId) {
|
||||||
|
return Integer.valueOf(routeId).toString() + "." + Integer.valueOf(vehicle_edgeId).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void saveAsPNG(String filename){
|
// public void saveAsPNG(String filename){
|
||||||
|
|
|
||||||
|
|
@ -240,25 +240,25 @@ public class BicycleMessenger {
|
||||||
//if you want, terminate it after 1000 iterations with no change
|
//if you want, terminate it after 1000 iterations with no change
|
||||||
// algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(1000));
|
// algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(1000));
|
||||||
algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||||
algorithm.setNuOfIterations(200);
|
algorithm.setNuOfIterations(2000);
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
||||||
|
|
||||||
//this is just to ensure that solution meet the above constraints
|
//this is just to ensure that solution meet the above constraints
|
||||||
validateSolution(Solutions.bestOf(solutions), bicycleMessengerProblem, nearestMessengers);
|
validateSolution(Solutions.bestOf(solutions), bicycleMessengerProblem, nearestMessengers);
|
||||||
|
|
||||||
|
|
||||||
// //you may want to plot the problem
|
//you may want to plot the problem
|
||||||
// Plotter plotter = new Plotter(bicycleMessengerProblem);
|
Plotter plotter = new Plotter(bicycleMessengerProblem);
|
||||||
//// plotter.setBoundingBox(10000, 47500, 20000, 67500);
|
// plotter.setBoundingBox(10000, 47500, 20000, 67500);
|
||||||
// plotter.plotShipments(true);
|
plotter.plotShipments(true);
|
||||||
// plotter.plot("output/bicycleMessengerProblem.png", "bicycleMessenger");
|
plotter.plot("output/bicycleMessengerProblem.png", "bicycleMessenger");
|
||||||
//
|
|
||||||
// //and the problem as well as the solution
|
//and the problem as well as the solution
|
||||||
// Plotter plotter1 = new Plotter(bicycleMessengerProblem, Solutions.bestOf(solutions));
|
Plotter plotter1 = new Plotter(bicycleMessengerProblem, Solutions.bestOf(solutions));
|
||||||
// plotter1.plotShipments(true);
|
plotter1.plotShipments(true);
|
||||||
// plotter1.setShowFirstActivity(true);
|
plotter1.setShowFirstActivity(true);
|
||||||
//// plotter1.setBoundingBox(5000, 45500, 25000, 66500);
|
// plotter1.setBoundingBox(5000, 45500, 25000, 66500);
|
||||||
// plotter1.plot("output/bicycleMessengerSolution.png", "bicycleMessenger");
|
plotter1.plot("output/bicycleMessengerSolution.png", "bicycleMessenger");
|
||||||
|
|
||||||
//and write out your solution in xml
|
//and write out your solution in xml
|
||||||
new VrpXMLWriter(bicycleMessengerProblem, solutions).write("output/bicycleMessenger.xml");
|
new VrpXMLWriter(bicycleMessengerProblem, solutions).write("output/bicycleMessenger.xml");
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
||||||
|
import jsprit.analysis.toolbox.GraphStreamViewer;
|
||||||
import jsprit.analysis.toolbox.SolutionPlotter;
|
import jsprit.analysis.toolbox.SolutionPlotter;
|
||||||
import jsprit.analysis.toolbox.SolutionPrinter;
|
import jsprit.analysis.toolbox.SolutionPrinter;
|
||||||
import jsprit.analysis.toolbox.StopWatch;
|
import jsprit.analysis.toolbox.StopWatch;
|
||||||
|
|
@ -113,6 +114,8 @@ public class MultipleDepotExample {
|
||||||
SolutionPrinter.print(Solutions.bestOf(solutions));
|
SolutionPrinter.print(Solutions.bestOf(solutions));
|
||||||
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.bestOf(solutions), "output/p01_solution.png", "p01");
|
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.bestOf(solutions), "output/p01_solution.png", "p01");
|
||||||
|
|
||||||
|
new GraphStreamViewer(vrp, Solutions.bestOf(solutions)).setRenderDelay(100).display();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,8 @@ public class PickupAndDeliveryExample2 {
|
||||||
plotter.setShowFirstActivity(true);
|
plotter.setShowFirstActivity(true);
|
||||||
plotter.plot("output/pd_christophides_vrpnc1_solution.png","pd_vrpnc1");
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ public class SimpleEnRoutePickupAndDeliveryOpenRoutesExample {
|
||||||
solutionPlotter.plotShipments(true);
|
solutionPlotter.plotShipments(true);
|
||||||
solutionPlotter.plot("output/simpleEnRoutePickupAndDeliveryExample_solution.png", "en-route pickup and delivery");
|
solutionPlotter.plot("output/simpleEnRoutePickupAndDeliveryExample_solution.png", "en-route pickup and delivery");
|
||||||
|
|
||||||
GraphStreamViewer.display(problem, bestSolution, 100);
|
new GraphStreamViewer(problem, bestSolution).setRenderDelay(100).display();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ public class SolomonExample {
|
||||||
|
|
||||||
// GraphStream.display(vrp,100);
|
// GraphStream.display(vrp,100);
|
||||||
|
|
||||||
GraphStreamViewer.display(vrp,solution);
|
new GraphStreamViewer(vrp,solution).display();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public class SolomonOpenExample {
|
||||||
SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/solomon_C101_open_solution.png","C101");
|
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();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ public class VRPWithBackhaulsExample {
|
||||||
// plotter.setShowFirstActivity(true);
|
// plotter.setShowFirstActivity(true);
|
||||||
// plotter.plot("output/vrpwbh_solomon_r101_solution.png","vrpwbh_r101");
|
// plotter.plot("output/vrpwbh_solomon_r101_solution.png","vrpwbh_r101");
|
||||||
|
|
||||||
GraphStreamViewer.display(vrp, solution, 100);
|
new GraphStreamViewer(vrp, solution).setRenderDelay(100).setEnableAutoLayout(false).display();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue