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

Merge branch 'routes-with-specified-start-and-end' into

access-egress-costs-merged-with-routes-with-spec-start-end

Conflicts:
	jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestCalculatesServiceInsertion.java
	jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExampleWithPenaltyVehicles.java
	jsprit-examples/src/main/java/jsprit/examples/SolomonExample.java
	jsprit-examples/src/main/java/jsprit/examples/SolomonOpenExample.java
This commit is contained in:
oblonski 2014-02-11 05:39:06 +01:00
commit 6dbcd7431a
75 changed files with 4281 additions and 525 deletions

View file

@ -384,17 +384,27 @@ public class GraphStreamViewer {
}
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");
Node vehicleStart = g.addNode(makeId(vehicle.getId(),vehicle.getStartLocationId()));
if(label.equals(Label.ID)) vehicleStart.addAttribute("ui.label", "depot");
// if(label.equals(Label.ACTIVITY)) n.addAttribute("ui.label", "start");
n.addAttribute("x", vehicle.getCoord().getX());
n.addAttribute("y", vehicle.getCoord().getY());
n.setAttribute("ui.class", "depot");
vehicleStart.addAttribute("x", vehicle.getStartLocationCoordinate().getX());
vehicleStart.addAttribute("y", vehicle.getStartLocationCoordinate().getY());
vehicleStart.setAttribute("ui.class", "depot");
if(!vehicle.getStartLocationId().equals(vehicle.getEndLocationId())){
Node vehicleEnd = g.addNode(makeId(vehicle.getId(),vehicle.getEndLocationId()));
if(label.equals(Label.ID)) vehicleEnd.addAttribute("ui.label", "depot");
// if(label.equals(Label.ACTIVITY)) n.addAttribute("ui.label", "start");
vehicleEnd.addAttribute("x", vehicle.getEndLocationCoordinate().getX());
vehicleEnd.addAttribute("y", vehicle.getEndLocationCoordinate().getY());
vehicleEnd.setAttribute("ui.class", "depot");
}
}
private void renderRoute(Graph g, VehicleRoute route, int routeId, long renderDelay_in_ms, Label label) {
int vehicle_edgeId = 1;
String prevIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getLocationId());
String prevIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getStartLocationId());
if(label.equals(Label.ACTIVITY)){
Node n = g.getNode(prevIdentifier);
n.addAttribute("ui.label", "start");
@ -413,7 +423,7 @@ public class GraphStreamViewer {
sleep(renderDelay_in_ms);
}
if(route.getVehicle().isReturnToDepot()){
String lastIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getLocationId());
String lastIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getEndLocationId());
g.addEdge(makeEdgeId(routeId,vehicle_edgeId), prevIdentifier, lastIdentifier, true);
}
}

View file

@ -404,9 +404,15 @@ public class Plotter {
XYSeriesCollection coll = new XYSeriesCollection();
XYSeries vehicleSeries = new XYSeries("depot", false, true);
for(Vehicle v : vehicles){
Coordinate coord = v.getCoord();
if(coord == null) throw new NoLocationFoundException();
vehicleSeries.add(coord.getX(),coord.getY());
Coordinate startCoord = v.getStartLocationCoordinate();
if(startCoord == null) throw new NoLocationFoundException();
vehicleSeries.add(startCoord.getX(),startCoord.getY());
if(!v.getStartLocationId().equals(v.getEndLocationId())){
Coordinate endCoord = v.getEndLocationCoordinate();
if(endCoord == null) throw new NoLocationFoundException();
vehicleSeries.add(endCoord.getX(),endCoord.getY());
}
}
coll.addSeries(vehicleSeries);
@ -473,11 +479,18 @@ public class Plotter {
private Locations retrieveLocations(VehicleRoutingProblem vrp) throws NoLocationFoundException {
final Map<String, Coordinate> locs = new HashMap<String, Coordinate>();
for(Vehicle v : vrp.getVehicles()){
String locationId = v.getLocationId();
if(locationId == null) throw new NoLocationFoundException();
Coordinate coord = v.getCoord();
if(coord == null) throw new NoLocationFoundException();
locs.put(locationId, coord);
String startLocationId = v.getStartLocationId();
if(startLocationId == null) throw new NoLocationFoundException();
Coordinate startCoord = v.getStartLocationCoordinate();
if(startCoord == null) throw new NoLocationFoundException();
locs.put(startLocationId, startCoord);
String endLocationId = v.getEndLocationId();
if(!startLocationId.equals(endLocationId)){
Coordinate endCoord = v.getEndLocationCoordinate();
if(endCoord == null) throw new NoLocationFoundException();
locs.put(endLocationId, endCoord);
}
}
for(Job j : vrp.getJobs().values()){
if(j instanceof Service){

View file

@ -75,8 +75,10 @@ public class SolutionPlotter {
* @param vrp
* @param pngFile target path with filename.
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
* @deprecated use Plotter.java instead (this plotter is not maintained anymore and might plot incorrectly)
*/
@Deprecated
public static void plotVrpAsPNG(VehicleRoutingProblem vrp, String pngFile, String title){
String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png";
@ -102,7 +104,9 @@ public class SolutionPlotter {
* @param pngFile target path with filename.
* @param plotTitle
* @see VehicleRoute
* @deprecated use Plotter.java instead (this plotter is not maintained anymore and might plot incorrectly)
*/
@Deprecated
public static void plotRoutesAsPNG(Collection<VehicleRoute> routes, Locations locations, String pngFile, String title) {
String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png";
@ -130,8 +134,10 @@ public class SolutionPlotter {
* @param vrp
* @param solution
* @param pngFile target path with filename.
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
* @deprecated use Plotter.java instead (this plotter is not maintained anymore and might plot incorrectly)
*/
@Deprecated
public static void plotSolutionAsPNG(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, String pngFile, String title){
String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png";
@ -294,7 +300,7 @@ public class SolutionPlotter {
XYSeriesCollection coll = new XYSeriesCollection();
XYSeries vehicleSeries = new XYSeries("depot", false, true);
for(Vehicle v : vehicles){
Coordinate coord = v.getCoord();
Coordinate coord = v.getStartLocationCoordinate();
if(coord == null) throw new NoLocationFoundException();
vehicleSeries.add(coord.getX(),coord.getY());
}
@ -353,11 +359,11 @@ public class SolutionPlotter {
private static Locations retrieveLocations(VehicleRoutingProblem vrp) throws NoLocationFoundException {
final Map<String, Coordinate> locs = new HashMap<String, Coordinate>();
for(Vehicle v : vrp.getVehicles()){
String locationId = v.getLocationId();
if(locationId == null) throw new NoLocationFoundException();
Coordinate coord = v.getCoord();
String startLocationId = v.getStartLocationId();
if(startLocationId == null) throw new NoLocationFoundException();
Coordinate coord = v.getStartLocationCoordinate();
if(coord == null) throw new NoLocationFoundException();
locs.put(locationId, coord);
locs.put(startLocationId, coord);
}
for(Job j : vrp.getJobs().values()){
if(j instanceof Service){