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

shift from vehicle.getLocation() to vehicle.getStartLocation() and

vehicle.getCoord() to vehicle.getStartLocationCoordinate()
This commit is contained in:
Stefan Schroeder 2014-01-28 17:40:13 +01:00
parent e5dabbdf64
commit a234bb54c9
36 changed files with 195 additions and 137 deletions

View file

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

View file

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

View file

@ -76,7 +76,9 @@ public class SolutionPlotter {
* @param vrp * @param vrp
* @param pngFile target path with filename. * @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){ public static void plotVrpAsPNG(VehicleRoutingProblem vrp, String pngFile, String title){
String filename = pngFile; String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png"; if(!pngFile.endsWith(".png")) filename += ".png";
@ -102,7 +104,9 @@ public class SolutionPlotter {
* @param pngFile target path with filename. * @param pngFile target path with filename.
* @param plotTitle * @param plotTitle
* @see VehicleRoute * @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) { public static void plotRoutesAsPNG(Collection<VehicleRoute> routes, Locations locations, String pngFile, String title) {
String filename = pngFile; String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png"; if(!pngFile.endsWith(".png")) filename += ".png";
@ -131,7 +135,9 @@ public class SolutionPlotter {
* @param solution * @param solution
* @param pngFile target path with filename. * @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){ public static void plotSolutionAsPNG(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, String pngFile, String title){
String filename = pngFile; String filename = pngFile;
if(!pngFile.endsWith(".png")) filename += ".png"; if(!pngFile.endsWith(".png")) filename += ".png";
@ -294,7 +300,7 @@ public class SolutionPlotter {
XYSeriesCollection coll = new XYSeriesCollection(); XYSeriesCollection coll = new XYSeriesCollection();
XYSeries vehicleSeries = new XYSeries("depot", false, true); XYSeries vehicleSeries = new XYSeries("depot", false, true);
for(Vehicle v : vehicles){ for(Vehicle v : vehicles){
Coordinate coord = v.getCoord(); Coordinate coord = v.getStartLocationCoordinate();
if(coord == null) throw new NoLocationFoundException(); if(coord == null) throw new NoLocationFoundException();
vehicleSeries.add(coord.getX(),coord.getY()); vehicleSeries.add(coord.getX(),coord.getY());
} }
@ -353,11 +359,11 @@ public class SolutionPlotter {
private static Locations retrieveLocations(VehicleRoutingProblem vrp) throws NoLocationFoundException { private static Locations retrieveLocations(VehicleRoutingProblem vrp) throws NoLocationFoundException {
final Map<String, Coordinate> locs = new HashMap<String, Coordinate>(); final Map<String, Coordinate> locs = new HashMap<String, Coordinate>();
for(Vehicle v : vrp.getVehicles()){ for(Vehicle v : vrp.getVehicles()){
String locationId = v.getLocationId(); String startLocationId = v.getStartLocationId();
if(locationId == null) throw new NoLocationFoundException(); if(startLocationId == null) throw new NoLocationFoundException();
Coordinate coord = v.getCoord(); Coordinate coord = v.getStartLocationCoordinate();
if(coord == null) throw new NoLocationFoundException(); if(coord == null) throw new NoLocationFoundException();
locs.put(locationId, coord); locs.put(startLocationId, coord);
} }
for(Job j : vrp.getJobs().values()){ for(Job j : vrp.getJobs().values()){
if(j instanceof Service){ if(j instanceof Service){

View file

@ -86,9 +86,15 @@ class InsertionFactory {
String weight = config.getString("considerFixedCosts[@weight]"); String weight = config.getString("considerFixedCosts[@weight]");
if(weight == null) weight = config.getString("considerFixedCost[@weight]"); if(weight == null) weight = config.getString("considerFixedCost[@weight]");
if(weight != null) fixedCostWeight = Double.parseDouble(weight); if(weight != null) fixedCostWeight = Double.parseDouble(weight);
else log.warn("parameter considerFixedCosts[@weight] is missing. by default, it is 0.5."); else throw new IllegalStateException("fixedCostsParameter 'weight' must be set, e.g. <considerFixedCosts weight=1.0>true</considerFixedCosts>.\n" +
"this has to be changed in algorithm-config-xml-file.");
iBuilder.considerFixedCosts(fixedCostWeight); iBuilder.considerFixedCosts(fixedCostWeight);
} }
else if(val.equals("false")){
}
else throw new IllegalStateException("considerFixedCosts must either be true or false, i.e. <considerFixedCosts weight=1.0>true</considerFixedCosts> or \n<considerFixedCosts weight=1.0>false</considerFixedCosts>. " +
"if latter, you can also omit the tag. this has to be changed in algorithm-config-xml-file");
} }
String timeSliceString = config.getString("experimental[@timeSlice]"); String timeSliceString = config.getString("experimental[@timeSlice]");
String neighbors = config.getString("experimental[@neighboringSlices]"); String neighbors = config.getString("experimental[@neighboringSlices]");

View file

@ -481,9 +481,6 @@ public class VehicleRoutingAlgorithms {
@Override @Override
public void finish() { public void finish() {
if(firstAct){
assert vehicle.getLocationId() == end.getLocationId() : "route end and last activity are not equal even route is open. this should not be.";
}
firstAct = true; firstAct = true;
} }

View file

@ -106,9 +106,9 @@ final class ServiceInsertionCalculator implements JobInsertionCostsCalculator{
TourActivity deliveryAct2Insert = activityFactory.createActivity(service); TourActivity deliveryAct2Insert = activityFactory.createActivity(service);
Start start = Start.newInstance(newVehicle.getLocationId(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival()); Start start = Start.newInstance(newVehicle.getStartLocationId(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
start.setEndTime(newVehicleDepartureTime); start.setEndTime(newVehicleDepartureTime);
End end = End.newInstance(newVehicle.getLocationId(), 0.0, newVehicle.getLatestArrival()); End end = End.newInstance(newVehicle.getEndLocationId(), 0.0, newVehicle.getLatestArrival());
TourActivity prevAct = start; TourActivity prevAct = start;
double prevActStartTime = newVehicleDepartureTime; double prevActStartTime = newVehicleDepartureTime;

View file

@ -314,22 +314,22 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
*/ */
private void initialiseStartAndEnd(final Vehicle newVehicle, double newVehicleDepartureTime) { private void initialiseStartAndEnd(final Vehicle newVehicle, double newVehicleDepartureTime) {
if(start == null){ if(start == null){
start = Start.newInstance(newVehicle.getLocationId(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival()); start = Start.newInstance(newVehicle.getStartLocationId(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
start.setEndTime(newVehicleDepartureTime); start.setEndTime(newVehicleDepartureTime);
} }
else{ else{
start.setLocationId(newVehicle.getLocationId()); start.setLocationId(newVehicle.getStartLocationId());
start.setTheoreticalEarliestOperationStartTime(newVehicle.getEarliestDeparture()); start.setTheoreticalEarliestOperationStartTime(newVehicle.getEarliestDeparture());
start.setTheoreticalLatestOperationStartTime(newVehicle.getLatestArrival()); start.setTheoreticalLatestOperationStartTime(Double.MAX_VALUE);
start.setEndTime(newVehicleDepartureTime); start.setEndTime(newVehicleDepartureTime);
} }
if(end == null){ if(end == null){
end = End.newInstance(newVehicle.getLocationId(), 0.0, newVehicle.getLatestArrival()); end = End.newInstance(newVehicle.getEndLocationId(), 0.0, newVehicle.getLatestArrival());
} }
else{ else{
end.setLocationId(newVehicle.getLocationId()); end.setLocationId(newVehicle.getEndLocationId());
end.setTheoreticalEarliestOperationStartTime(newVehicleDepartureTime); end.setTheoreticalEarliestOperationStartTime(0.0);
end.setTheoreticalLatestOperationStartTime(newVehicle.getLatestArrival()); end.setTheoreticalLatestOperationStartTime(newVehicle.getLatestArrival());
} }
} }

View file

@ -100,10 +100,10 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator{
int pickupInsertionIndex = InsertionData.NO_INDEX; int pickupInsertionIndex = InsertionData.NO_INDEX;
int deliveryInsertionIndex = InsertionData.NO_INDEX; int deliveryInsertionIndex = InsertionData.NO_INDEX;
Start start = Start.newInstance(newVehicle.getLocationId(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival()); Start start = Start.newInstance(newVehicle.getStartLocationId(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival());
start.setEndTime(newVehicleDepartureTime); start.setEndTime(newVehicleDepartureTime);
End end = End.newInstance(newVehicle.getLocationId(), 0.0, newVehicle.getLatestArrival()); End end = End.newInstance(newVehicle.getEndLocationId(), 0.0, newVehicle.getLatestArrival());
TourActivity prevAct = start; TourActivity prevAct = start;
double prevActEndTime = newVehicleDepartureTime; double prevActEndTime = newVehicleDepartureTime;

View file

@ -327,7 +327,11 @@ public class VehicleRoutingProblem {
if(!vehicleTypes.contains(vehicle.getType())){ if(!vehicleTypes.contains(vehicle.getType())){
vehicleTypes.add(vehicle.getType()); vehicleTypes.add(vehicle.getType());
} }
coordinates.put(vehicle.getLocationId(), vehicle.getCoord()); String startLocationId = vehicle.getStartLocationId();
coordinates.put(startLocationId, vehicle.getStartLocationCoordinate());
if(!vehicle.getEndLocationId().equals(startLocationId)){
coordinates.put(vehicle.getEndLocationId(), vehicle.getEndLocationCoordinate());
}
return this; return this;
} }
@ -373,7 +377,7 @@ public class VehicleRoutingProblem {
Set<LocTypeKey> locTypeKeys = new HashSet<LocTypeKey>(); Set<LocTypeKey> locTypeKeys = new HashSet<LocTypeKey>();
List<Vehicle> uniqueVehicles = new ArrayList<Vehicle>(); List<Vehicle> uniqueVehicles = new ArrayList<Vehicle>();
for(Vehicle v : vehicles){ for(Vehicle v : vehicles){
LocTypeKey key = new LocTypeKey(v.getLocationId(),v.getType().getTypeId()); LocTypeKey key = new LocTypeKey(v.getStartLocationId(),v.getType().getTypeId());
if(!locTypeKeys.contains(key)){ if(!locTypeKeys.contains(key)){
uniqueVehicles.add(v); uniqueVehicles.add(v);
locTypeKeys.add(key); locTypeKeys.add(key);
@ -390,9 +394,10 @@ public class VehicleRoutingProblem {
.setFixedCost(fixed) .setFixedCost(fixed)
.build(); .build();
PenaltyVehicleType penType = new PenaltyVehicleType(t,penaltyFactor); PenaltyVehicleType penType = new PenaltyVehicleType(t,penaltyFactor);
String vehicleId = "penaltyVehicle_" + v.getLocationId() + "_" + t.getTypeId(); String vehicleId = "penaltyVehicle_" + v.getStartLocationId() + "_" + t.getTypeId();
Vehicle penVehicle = VehicleImpl.Builder.newInstance(vehicleId).setEarliestStart(v.getEarliestDeparture()) Vehicle penVehicle = VehicleImpl.Builder.newInstance(vehicleId).setEarliestStart(v.getEarliestDeparture())
.setLatestArrival(v.getLatestArrival()).setLocationCoord(v.getCoord()).setLocationId(v.getLocationId()) .setLatestArrival(v.getLatestArrival()).setStartLocationCoordinate(v.getStartLocationCoordinate()).setLocationId(v.getStartLocationId())
.setEndLocationId(v.getEndLocationId()).setEndLocationCoordinate(v.getEndLocationCoordinate())
.setReturnToDepot(v.isReturnToDepot()).setType(penType).build(); .setReturnToDepot(v.isReturnToDepot()).setType(penType).build();
addVehicle(penVehicle); addVehicle(penVehicle);
} }

View file

@ -165,7 +165,7 @@ public class VehicleRoute {
this.driver = driver; this.driver = driver;
start = Start.newInstance(vehicle.getStartLocationId(), vehicle.getEarliestDeparture(), Double.MAX_VALUE); start = Start.newInstance(vehicle.getStartLocationId(), vehicle.getEarliestDeparture(), Double.MAX_VALUE);
start.setEndTime(vehicle.getEarliestDeparture()); start.setEndTime(vehicle.getEarliestDeparture());
end = End.newInstance(vehicle.getLocationId(), 0.0, vehicle.getLatestArrival()); end = End.newInstance(vehicle.getEndLocationId(), 0.0, vehicle.getLatestArrival());
} }
/** /**

View file

@ -47,7 +47,9 @@ public interface Vehicle {
* <p> Consequently, it should be the end-location of this vehicle, if returnToDepot is true. * <p> Consequently, it should be the end-location of this vehicle, if returnToDepot is true.
* *
* @return location-id of this vehicle * @return location-id of this vehicle
* @deprecated use getStartLocationId() instead
*/ */
@Deprecated
public abstract String getLocationId(); public abstract String getLocationId();
/** /**
@ -56,7 +58,9 @@ public interface Vehicle {
* <p> Consequently, it should be the coordinate of the end-location, if returnToDepot is true. * <p> Consequently, it should be the coordinate of the end-location, if returnToDepot is true.
* *
* @return coordinate of this vehicle * @return coordinate of this vehicle
* @deprecated use getStartLocationCoordinate() instead
*/ */
@Deprecated
public abstract Coordinate getCoord(); public abstract Coordinate getCoord();
/** /**

View file

@ -176,10 +176,8 @@ public class VehicleImpl implements Vehicle {
* *
* @param coord * @param coord
* @return this builder * @return this builder
* @throws IllegalArgumentException if start-coordinate is null
*/ */
public Builder setStartLocationCoordinate(Coordinate coord){ public Builder setStartLocationCoordinate(Coordinate coord){
if(coord == null) throw new IllegalArgumentException("start-coordinate must not be null");
this.startLocationCoord = coord; this.startLocationCoord = coord;
this.locationCoord = coord; this.locationCoord = coord;
return this; return this;
@ -190,10 +188,8 @@ public class VehicleImpl implements Vehicle {
* *
* @param endLocationId * @param endLocationId
* @return this builder * @return this builder
* @throws IllegalArgumentException if endLocation is null
*/ */
public Builder setEndLocationId(String endLocationId){ public Builder setEndLocationId(String endLocationId){
if(endLocationId == null) throw new IllegalArgumentException("end-locationId must not be null");
this.endLocationId = endLocationId; this.endLocationId = endLocationId;
return this; return this;
} }
@ -203,10 +199,8 @@ public class VehicleImpl implements Vehicle {
* *
* @param coord * @param coord
* @return this builder * @return this builder
* @throws IllegalArgumentException if coord is null
*/ */
public Builder setEndLocationCoordinate(Coordinate coord){ public Builder setEndLocationCoordinate(Coordinate coord){
if(coord == null) throw new IllegalArgumentException("end-coordinate must not be null");
this.endLocationCoord = coord; this.endLocationCoord = coord;
return this; return this;
} }
@ -336,6 +330,10 @@ public class VehicleImpl implements Vehicle {
return "[id="+id+"][type="+type+"][locationId="+locationId+"][coord=" + coord + "][isReturnToDepot=" + isReturnToDepot() + "]"; return "[id="+id+"][type="+type+"][locationId="+locationId+"][coord=" + coord + "][isReturnToDepot=" + isReturnToDepot() + "]";
} }
/**
* @deprecated use getStartLocationCoordinate() instead
*/
@Deprecated
public Coordinate getCoord() { public Coordinate getCoord() {
return coord; return coord;
} }
@ -350,6 +348,10 @@ public class VehicleImpl implements Vehicle {
return latestArrival; return latestArrival;
} }
/**
* @deprecated use getStartLocationId() instead
*/
@Deprecated
@Override @Override
public String getLocationId() { public String getLocationId() {
return locationId; return locationId;

View file

@ -227,6 +227,7 @@
<xs:attribute name="weight" type="xs:double"/> <xs:attribute name="weight" type="xs:double"/>
</xs:extension> </xs:extension>
</xs:simpleContent> </xs:simpleContent>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="allowVehicleSwitch" type="xs:boolean" minOccurs="0" maxOccurs="1"/> <xs:element name="allowVehicleSwitch" type="xs:boolean" minOccurs="0" maxOccurs="1"/>

View file

@ -53,8 +53,8 @@ public class CalcVehicleTypeDependentServiceInsertionTest {
veh2 = mock(Vehicle.class); veh2 = mock(Vehicle.class);
when(veh1.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type1", 0).build()); when(veh1.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type1", 0).build());
when(veh2.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type2", 0).build()); when(veh2.getType()).thenReturn(VehicleTypeImpl.Builder.newInstance("type2", 0).build());
when(veh1.getLocationId()).thenReturn("loc1"); when(veh1.getStartLocationId()).thenReturn("loc1");
when(veh2.getLocationId()).thenReturn("loc2"); when(veh2.getStartLocationId()).thenReturn("loc2");
fleetManager = mock(VehicleFleetManager.class); fleetManager = mock(VehicleFleetManager.class);
service = mock(Service.class); service = mock(Service.class);
vehicleRoute = mock(VehicleRoute.class); vehicleRoute = mock(VehicleRoute.class);

View file

@ -75,14 +75,16 @@ public class TestCalculatesServiceInsertion {
costs = mock(VehicleRoutingTransportCosts.class); costs = mock(VehicleRoutingTransportCosts.class);
vehicle = mock(Vehicle.class); vehicle = mock(Vehicle.class);
when(vehicle.getCapacity()).thenReturn(1000); when(vehicle.getCapacity()).thenReturn(1000);
when(vehicle.getLocationId()).thenReturn("depot"); when(vehicle.getStartLocationId()).thenReturn("depot");
when(vehicle.getEndLocationId()).thenReturn("depot");
when(vehicle.getEarliestDeparture()).thenReturn(0.0); when(vehicle.getEarliestDeparture()).thenReturn(0.0);
when(vehicle.getLatestArrival()).thenReturn(100.0); when(vehicle.getLatestArrival()).thenReturn(100.0);
when(vehicle.isReturnToDepot()).thenReturn(true); when(vehicle.isReturnToDepot()).thenReturn(true);
newVehicle = mock(Vehicle.class); newVehicle = mock(Vehicle.class);
when(newVehicle.getCapacity()).thenReturn(1000); when(newVehicle.getCapacity()).thenReturn(1000);
when(newVehicle.getLocationId()).thenReturn("depot"); when(newVehicle.getStartLocationId()).thenReturn("depot");
when(newVehicle.getEndLocationId()).thenReturn("depot");
when(newVehicle.getEarliestDeparture()).thenReturn(0.0); when(newVehicle.getEarliestDeparture()).thenReturn(0.0);
when(newVehicle.getLatestArrival()).thenReturn(100.0); when(newVehicle.getLatestArrival()).thenReturn(100.0);
when(newVehicle.isReturnToDepot()).thenReturn(true); when(newVehicle.isReturnToDepot()).thenReturn(true);

View file

@ -79,7 +79,6 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
costs = mock(VehicleRoutingTransportCosts.class); costs = mock(VehicleRoutingTransportCosts.class);
vehicle = mock(Vehicle.class); vehicle = mock(Vehicle.class);
when(vehicle.getCapacity()).thenReturn(1000); when(vehicle.getCapacity()).thenReturn(1000);
when(vehicle.getLocationId()).thenReturn("0,0");
when(vehicle.getStartLocationId()).thenReturn("0,0"); when(vehicle.getStartLocationId()).thenReturn("0,0");
when(vehicle.getEndLocationId()).thenReturn("0,0"); when(vehicle.getEndLocationId()).thenReturn("0,0");
when(vehicle.getEarliestDeparture()).thenReturn(0.0); when(vehicle.getEarliestDeparture()).thenReturn(0.0);
@ -88,7 +87,6 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
newVehicle = mock(Vehicle.class); newVehicle = mock(Vehicle.class);
when(newVehicle.getCapacity()).thenReturn(1000); when(newVehicle.getCapacity()).thenReturn(1000);
when(newVehicle.getLocationId()).thenReturn("0,0");
when(newVehicle.getStartLocationId()).thenReturn("0,0"); when(newVehicle.getStartLocationId()).thenReturn("0,0");
when(newVehicle.getEndLocationId()).thenReturn("0,0"); when(newVehicle.getEndLocationId()).thenReturn("0,0");
when(newVehicle.getEarliestDeparture()).thenReturn(0.0); when(newVehicle.getEarliestDeparture()).thenReturn(0.0);

View file

@ -22,7 +22,6 @@ public class TestInserter {
public void whenInsertingServiceAndRouteIsClosed_itInsertsCorrectly(){ public void whenInsertingServiceAndRouteIsClosed_itInsertsCorrectly(){
Service service = mock(Service.class); Service service = mock(Service.class);
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.getLocationId()).thenReturn("vehLoc");
when(vehicle.getStartLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");
when(vehicle.getEndLocationId()).thenReturn("vehLoc"); when(vehicle.getEndLocationId()).thenReturn("vehLoc");
when(vehicle.isReturnToDepot()).thenReturn(true); when(vehicle.isReturnToDepot()).thenReturn(true);
@ -42,14 +41,13 @@ public class TestInserter {
assertEquals(2,route.getTourActivities().getActivities().size()); assertEquals(2,route.getTourActivities().getActivities().size());
assertEquals(route.getTourActivities().getActivities().get(1).getLocationId(),serviceToInsert.getLocationId()); assertEquals(route.getTourActivities().getActivities().get(1).getLocationId(),serviceToInsert.getLocationId());
assertEquals(route.getEnd().getLocationId(),vehicle.getLocationId()); assertEquals(route.getEnd().getLocationId(),vehicle.getEndLocationId());
} }
@Test @Test
public void whenInsertingServiceAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){ public void whenInsertingServiceAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){
Service service = mock(Service.class); Service service = mock(Service.class);
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.getLocationId()).thenReturn("vehLoc");
when(vehicle.getStartLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");
when(vehicle.getEndLocationId()).thenReturn("vehLoc"); when(vehicle.getEndLocationId()).thenReturn("vehLoc");
when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.isReturnToDepot()).thenReturn(false);
@ -76,7 +74,6 @@ public class TestInserter {
public void whenInsertingShipmentAndRouteIsClosed_itInsertsCorrectly(){ public void whenInsertingShipmentAndRouteIsClosed_itInsertsCorrectly(){
Shipment shipment = mock(Shipment.class); Shipment shipment = mock(Shipment.class);
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.getLocationId()).thenReturn("vehLoc");
when(vehicle.getStartLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");
when(vehicle.getEndLocationId()).thenReturn("vehLoc"); when(vehicle.getEndLocationId()).thenReturn("vehLoc");
when(vehicle.isReturnToDepot()).thenReturn(true); when(vehicle.isReturnToDepot()).thenReturn(true);
@ -98,14 +95,13 @@ public class TestInserter {
assertEquals(4,route.getTourActivities().getActivities().size()); assertEquals(4,route.getTourActivities().getActivities().size());
assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocation()); assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocation());
assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocation()); assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocation());
assertEquals(route.getEnd().getLocationId(),vehicle.getLocationId()); assertEquals(route.getEnd().getLocationId(),vehicle.getEndLocationId());
} }
@Test @Test
public void whenInsertingShipmentAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){ public void whenInsertingShipmentAndRouteIsOpen_itInsertsCorrectlyAndSwitchesEndLocation(){
Shipment shipment = mock(Shipment.class); Shipment shipment = mock(Shipment.class);
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.getLocationId()).thenReturn("vehLoc");
when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.isReturnToDepot()).thenReturn(false);
when(vehicle.getId()).thenReturn("vehId"); when(vehicle.getId()).thenReturn("vehId");
@ -148,7 +144,7 @@ public class TestInserter {
Inserter inserter = new Inserter(mock(InsertionListeners.class)); Inserter inserter = new Inserter(mock(InsertionListeners.class));
inserter.insertJob(shipmentToInsert, iData, route); inserter.insertJob(shipmentToInsert, iData, route);
assertEquals(newVehicle.getLocationId(),route.getEnd().getLocationId()); assertEquals(route.getEnd().getLocationId(),newVehicle.getEndLocationId());
} }
@Test @Test

View file

@ -138,7 +138,7 @@ public class TestTourStateUpdaterWithService {
public void testStatesOfAct0(){ public void testStatesOfAct0(){
states.informInsertionStarts(Arrays.asList(vehicleRoute), null); states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
assertEquals(0.0, vehicleRoute.getStart().getEndTime(),0.05); assertEquals(0.0, vehicleRoute.getStart().getEndTime(),0.05);
assertEquals(vehicleRoute.getVehicle().getLocationId(), vehicleRoute.getStart().getLocationId()); assertEquals(vehicleRoute.getVehicle().getStartLocationId(), vehicleRoute.getStart().getLocationId());
assertEquals(vehicleRoute.getVehicle().getEarliestDeparture(), vehicleRoute.getStart().getTheoreticalEarliestOperationStartTime(),0.05); assertEquals(vehicleRoute.getVehicle().getEarliestDeparture(), vehicleRoute.getStart().getTheoreticalEarliestOperationStartTime(),0.05);
assertEquals(Double.MAX_VALUE, vehicleRoute.getStart().getTheoreticalLatestOperationStartTime(),0.05); assertEquals(Double.MAX_VALUE, vehicleRoute.getStart().getTheoreticalLatestOperationStartTime(),0.05);

View file

@ -66,10 +66,10 @@ public class VehicleRoutingProblemTest {
public void whenBuildingWithFourVehicles_vrpShouldContainTheCorrectNuOfVehicles(){ public void whenBuildingWithFourVehicles_vrpShouldContainTheCorrectNuOfVehicles(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
Vehicle v1 = mock(VehicleImpl.class); Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("start").build();
Vehicle v2 = mock(VehicleImpl.class); Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("start").build();
Vehicle v3 = mock(VehicleImpl.class); Vehicle v3 = VehicleImpl.Builder.newInstance("v3").setStartLocationId("start").build();
Vehicle v4 = mock(VehicleImpl.class); Vehicle v4 = VehicleImpl.Builder.newInstance("v4").setStartLocationId("start").build();
builder.addVehicle(v1).addVehicle(v2).addVehicle(v3).addVehicle(v4); builder.addVehicle(v1).addVehicle(v2).addVehicle(v3).addVehicle(v4);
@ -82,10 +82,10 @@ public class VehicleRoutingProblemTest {
public void whenAddingFourVehiclesAllAtOnce_vrpShouldContainTheCorrectNuOfVehicles(){ public void whenAddingFourVehiclesAllAtOnce_vrpShouldContainTheCorrectNuOfVehicles(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
Vehicle v1 = mock(VehicleImpl.class); Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("start").build();
Vehicle v2 = mock(VehicleImpl.class); Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("start").build();
Vehicle v3 = mock(VehicleImpl.class); Vehicle v3 = VehicleImpl.Builder.newInstance("v3").setStartLocationId("start").build();
Vehicle v4 = mock(VehicleImpl.class); Vehicle v4 = VehicleImpl.Builder.newInstance("v4").setStartLocationId("start").build();
builder.addAllVehicles(Arrays.asList(v1,v2,v3,v4)); builder.addAllVehicles(Arrays.asList(v1,v2,v3,v4));
@ -471,4 +471,22 @@ public class VehicleRoutingProblemTest {
assertTrue(anotherPenVehInCollection); assertTrue(anotherPenVehInCollection);
} }
@Test
public void whenAddingVehicleWithDiffStartAndEnd_startLocationMustBeRegisteredInLocationMap(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("end").build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addVehicle(vehicle);
assertTrue(vrpBuilder.getLocationMap().containsKey("start"));
}
@Test
public void whenAddingVehicleWithDiffStartAndEnd_endLocationMustBeRegisteredInLocationMap(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("end").build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addVehicle(vehicle);
assertTrue(vrpBuilder.getLocationMap().containsKey("end"));
}
} }

View file

@ -70,9 +70,9 @@ public class VrpReaderV2Test {
VehicleRoutingProblem vrp = builder.build(); VehicleRoutingProblem vrp = builder.build();
Vehicle v1 = getVehicle("v1",vrp.getVehicles()); Vehicle v1 = getVehicle("v1",vrp.getVehicles());
assertEquals(20,v1.getCapacity()); assertEquals(20,v1.getCapacity());
assertEquals(100.0,v1.getCoord().getX(),0.01); assertEquals(100.0,v1.getStartLocationCoordinate().getX(),0.01);
assertEquals(0.0,v1.getEarliestDeparture(),0.01); assertEquals(0.0,v1.getEarliestDeparture(),0.01);
assertEquals("depotLoc2",v1.getLocationId()); assertEquals("depotLoc2",v1.getStartLocationId());
assertNotNull(v1.getType()); assertNotNull(v1.getType());
assertEquals("vehType", v1.getType().getTypeId()); assertEquals("vehType", v1.getType().getTypeId());
assertEquals(1000.0,v1.getLatestArrival(),0.01); assertEquals(1000.0,v1.getLatestArrival(),0.01);
@ -229,8 +229,8 @@ public class VrpReaderV2Test {
new VrpXMLReader(builder, null).read(inFileName); new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build(); VehicleRoutingProblem vrp = builder.build();
Vehicle v3 = getVehicle("v3",vrp.getVehicles()); Vehicle v3 = getVehicle("v3",vrp.getVehicles());
assertEquals(10.0,v3.getCoord().getX(),0.01); assertEquals(10.0,v3.getStartLocationCoordinate().getX(),0.01);
assertEquals(100.0,v3.getCoord().getY(),0.01); assertEquals(100.0,v3.getStartLocationCoordinate().getY(),0.01);
} }
@Test @Test
@ -239,7 +239,7 @@ public class VrpReaderV2Test {
new VrpXMLReader(builder, null).read(inFileName); new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build(); VehicleRoutingProblem vrp = builder.build();
Vehicle v3 = getVehicle("v3",vrp.getVehicles()); Vehicle v3 = getVehicle("v3",vrp.getVehicles());
assertEquals("startLoc",v3.getLocationId()); assertEquals("startLoc",v3.getStartLocationId());
} }
@Test @Test
@ -286,8 +286,8 @@ public class VrpReaderV2Test {
new VrpXMLReader(builder, null).read(inFileName); new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build(); VehicleRoutingProblem vrp = builder.build();
Vehicle v = getVehicle("v4",vrp.getVehicles()); Vehicle v = getVehicle("v4",vrp.getVehicles());
assertEquals(10.0,v.getCoord().getX(),0.01); assertEquals(10.0,v.getStartLocationCoordinate().getX(),0.01);
assertEquals(100.0,v.getCoord().getY(),0.01); assertEquals(100.0,v.getStartLocationCoordinate().getY(),0.01);
} }
@Test @Test

View file

@ -164,42 +164,49 @@ public class TestVehicleRoute {
} }
} }
@Test
public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectStartLocation(){ public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectStartLocation(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
assertTrue(vRoute.getStart().getLocationId().equals("start")); assertTrue(vRoute.getStart().getLocationId().equals("start"));
} }
@Test
public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectEndLocation(){ public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectEndLocation(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
assertTrue(vRoute.getEnd().getLocationId().equals("end")); assertTrue(vRoute.getEnd().getLocationId().equals("end"));
} }
@Test
public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectStartLocation(){ public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectStartLocation(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
assertTrue(vRoute.getStart().getLocationId().equals("start")); assertTrue(vRoute.getStart().getLocationId().equals("start"));
} }
@Test
public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectEndLocation(){ public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectEndLocation(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
assertTrue(vRoute.getEnd().getLocationId().equals("start")); assertTrue(vRoute.getEnd().getLocationId().equals("start"));
} }
@Test
public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectStartLocationV2(){ public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectStartLocationV2(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("start").setEndLocationId("start").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("start").setEndLocationId("start").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
assertTrue(vRoute.getStart().getLocationId().equals("start")); assertTrue(vRoute.getStart().getLocationId().equals("start"));
} }
@Test
public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectEndLocationV2(){ public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectEndLocationV2(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("start").setEndLocationId("start").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("start").setEndLocationId("start").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
assertTrue(vRoute.getEnd().getLocationId().equals("start")); assertTrue(vRoute.getEnd().getLocationId().equals("start"));
} }
@Test
public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectDepartureTime(){ public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectDepartureTime(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setStartLocationId("start").setEndLocationId("end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
@ -207,13 +214,14 @@ public class TestVehicleRoute {
assertEquals(vRoute.getStart().getEndTime(),100.0,0.01); assertEquals(vRoute.getStart().getEndTime(),100.0,0.01);
} }
@Test
public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectEndTime(){ public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectEndTime(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
assertEquals(vRoute.getEnd().getArrTime(),100.0,0.01); assertEquals(200.0,vRoute.getEnd().getTheoreticalLatestOperationStartTime(),0.01);
assertEquals(vRoute.getEnd().getTheoreticalLatestOperationStartTime(),100.0,0.01);
} }
@Test
public void whenSettingDepartureTimeInBetweenEarliestStartAndLatestArr_routeMustHaveCorrectDepartureTime(){ public void whenSettingDepartureTimeInBetweenEarliestStartAndLatestArr_routeMustHaveCorrectDepartureTime(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
@ -222,6 +230,7 @@ public class TestVehicleRoute {
assertEquals(vRoute.getDepartureTime(),150.0,0.01); assertEquals(vRoute.getDepartureTime(),150.0,0.01);
} }
@Test
public void whenSettingDepartureEarlierThanEarliestStart_routeMustHaveEarliestDepTimeAsDepTime(){ public void whenSettingDepartureEarlierThanEarliestStart_routeMustHaveEarliestDepTimeAsDepTime(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
@ -230,6 +239,7 @@ public class TestVehicleRoute {
assertEquals(vRoute.getDepartureTime(),100.0,0.01); assertEquals(vRoute.getDepartureTime(),100.0,0.01);
} }
@Test
public void whenSettingDepartureTimeLaterThanLatestArrival_routeMustHaveThisDepTime(){ public void whenSettingDepartureTimeLaterThanLatestArrival_routeMustHaveThisDepTime(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
@ -238,12 +248,14 @@ public class TestVehicleRoute {
assertEquals(vRoute.getDepartureTime(),100.0,0.01); assertEquals(vRoute.getDepartureTime(),100.0,0.01);
} }
@Test
public void whenCreatingEmptyRoute_itMustReturnEmptyRoute(){ public void whenCreatingEmptyRoute_itMustReturnEmptyRoute(){
@SuppressWarnings("unused") @SuppressWarnings("unused")
VehicleRoute route = VehicleRoute.emptyRoute(); VehicleRoute route = VehicleRoute.emptyRoute();
assertTrue(true); assertTrue(true);
} }
@Test
public void whenIniRouteWithNewVehicle_startLocationMustBeCorrect(){ public void whenIniRouteWithNewVehicle_startLocationMustBeCorrect(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build();
Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build(); Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build();
@ -252,14 +264,16 @@ public class TestVehicleRoute {
assertEquals("new_start",vRoute.getStart().getLocationId()); assertEquals("new_start",vRoute.getStart().getLocationId());
} }
@Test
public void whenIniRouteWithNewVehicle_endLocationMustBeCorrect(){ public void whenIniRouteWithNewVehicle_endLocationMustBeCorrect(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build();
Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build(); Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
vRoute.setVehicleAndDepartureTime(new_vehicle, 50.0); vRoute.setVehicleAndDepartureTime(new_vehicle, 50.0);
assertEquals("new_end",vRoute.getStart().getLocationId()); assertEquals("new_end",vRoute.getEnd().getLocationId());
} }
@Test
public void whenIniRouteWithNewVehicle_depTimeMustBeEarliestDepTimeOfNewVehicle(){ public void whenIniRouteWithNewVehicle_depTimeMustBeEarliestDepTimeOfNewVehicle(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build();
Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build(); Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build();
@ -268,6 +282,7 @@ public class TestVehicleRoute {
assertEquals(1000.0,vRoute.getDepartureTime(),0.01); assertEquals(1000.0,vRoute.getDepartureTime(),0.01);
} }
@Test
public void whenIniRouteWithNewVehicle_depTimeMustBeSetDepTime(){ public void whenIniRouteWithNewVehicle_depTimeMustBeSetDepTime(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build(); Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setEarliestStart(100).setLatestArrival(200).setStartLocationId("start").setEndLocationId("end").build();
Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build(); Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build();

View file

@ -65,14 +65,15 @@ public class VehicleRouteBuilderTest {
Shipment s2 = mock(Shipment.class); Shipment s2 = mock(Shipment.class);
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.isReturnToDepot()).thenReturn(true); when(vehicle.isReturnToDepot()).thenReturn(true);
when(vehicle.getLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");
when(vehicle.getEndLocationId()).thenReturn("vehLoc");
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)); VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class));
builder.addPickup(s); builder.addPickup(s);
builder.addPickup(s2); builder.addPickup(s2);
builder.addDelivery(s); builder.addDelivery(s);
builder.addDelivery(s2); builder.addDelivery(s2);
VehicleRoute route = builder.build(); VehicleRoute route = builder.build();
assertEquals(route.getEnd().getLocationId(), vehicle.getLocationId()); assertEquals("vehLoc",route.getEnd().getLocationId());
} }
@Test @Test
@ -82,7 +83,7 @@ public class VehicleRouteBuilderTest {
when(s2.getDeliveryLocation()).thenReturn("delLoc"); when(s2.getDeliveryLocation()).thenReturn("delLoc");
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.isReturnToDepot()).thenReturn(false);
when(vehicle.getLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)); VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class));
builder.addPickup(s); builder.addPickup(s);
builder.addPickup(s2); builder.addPickup(s2);
@ -99,7 +100,7 @@ public class VehicleRouteBuilderTest {
when(s2.getDeliveryLocation()).thenReturn("delLoc"); when(s2.getDeliveryLocation()).thenReturn("delLoc");
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.isReturnToDepot()).thenReturn(false);
when(vehicle.getLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)); VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class));
builder.addPickup(s); builder.addPickup(s);
builder.addPickup(s2); builder.addPickup(s2);
@ -119,7 +120,7 @@ public class VehicleRouteBuilderTest {
when(s2.getDeliveryLocation()).thenReturn("delLoc"); when(s2.getDeliveryLocation()).thenReturn("delLoc");
Vehicle vehicle = mock(Vehicle.class); Vehicle vehicle = mock(Vehicle.class);
when(vehicle.isReturnToDepot()).thenReturn(false); when(vehicle.isReturnToDepot()).thenReturn(false);
when(vehicle.getLocationId()).thenReturn("vehLoc"); when(vehicle.getStartLocationId()).thenReturn("vehLoc");
when(vehicle.getLatestArrival()).thenReturn(200.0); when(vehicle.getLatestArrival()).thenReturn(200.0);
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)); VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class));
builder.addPickup(s); builder.addPickup(s);

View file

@ -121,12 +121,6 @@ public class VehicleImplTest {
assertEquals(2.0, v.getCoord().getY(),0.01); assertEquals(2.0, v.getCoord().getY(),0.01);
} }
@Test(expected=IllegalArgumentException.class)
public void whenStartLocationCoordIsNull_itThrowsException(){
@SuppressWarnings("unused")
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(null).build();
}
@Test @Test
public void whenEndLocationIsSet_itIsDoneCorrectly(){ public void whenEndLocationIsSet_itIsDoneCorrectly(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").setEndLocationId("endLoc").build(); Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").setEndLocationId("endLoc").build();
@ -134,12 +128,6 @@ public class VehicleImplTest {
assertEquals("endLoc", v.getEndLocationId()); assertEquals("endLoc", v.getEndLocationId());
} }
@Test(expected=IllegalArgumentException.class)
public void whenEndLocationIsNull_itThrowsException(){
@SuppressWarnings("unused")
Vehicle v = VehicleImpl.Builder.newInstance("v").setEndLocationId(null).build();
}
@Test @Test
public void whenEndLocationCoordIsSet_itIsDoneCorrectly(){ public void whenEndLocationCoordIsSet_itIsDoneCorrectly(){
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").setEndLocationCoordinate(Coordinate.newInstance(1, 2)).build(); Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("startLoc").setEndLocationCoordinate(Coordinate.newInstance(1, 2)).build();
@ -147,11 +135,6 @@ public class VehicleImplTest {
assertEquals(2.0, v.getEndLocationCoordinate().getY(),0.01); assertEquals(2.0, v.getEndLocationCoordinate().getY(),0.01);
} }
@Test(expected=IllegalArgumentException.class)
public void whenEndLocationCoordIsNull_itThrowsException(){
@SuppressWarnings("unused")
Vehicle v = VehicleImpl.Builder.newInstance("v").setEndLocationCoordinate(null).build();
}
@Test @Test
public void whenNeitherEndLocationIdNorEndLocationCoordAreSet_endLocationIdMustBeEqualToStartLocationId(){ public void whenNeitherEndLocationIdNorEndLocationCoordAreSet_endLocationIdMustBeEqualToStartLocationId(){

View file

@ -7,7 +7,7 @@
<construction> <construction>
<insertion name="bestInsertion"> <insertion name="bestInsertion">
<considerFixedCosts>1.0</considerFixedCosts> <considerFixedCosts weight="1.0">true</considerFixedCosts>
</insertion> </insertion>
</construction> </construction>

View file

@ -318,7 +318,7 @@ public class BicycleMessenger {
static double getTimeOfDirectRoute(Job job, Vehicle v, VehicleRoutingTransportCosts routingCosts) { static double getTimeOfDirectRoute(Job job, Vehicle v, VehicleRoutingTransportCosts routingCosts) {
Shipment envelope = (Shipment) job; Shipment envelope = (Shipment) job;
double direct = routingCosts.getTransportTime(v.getLocationId(), envelope.getPickupLocation(), 0.0, DriverImpl.noDriver(), v) + double direct = routingCosts.getTransportTime(v.getStartLocationId(), envelope.getPickupLocation(), 0.0, DriverImpl.noDriver(), v) +
routingCosts.getTransportTime(envelope.getPickupLocation(), envelope.getDeliveryLocation(), 0.0, DriverImpl.noDriver(), v); routingCosts.getTransportTime(envelope.getPickupLocation(), envelope.getDeliveryLocation(), 0.0, DriverImpl.noDriver(), v);
return direct; return direct;
} }

View file

@ -19,7 +19,7 @@ package jsprit.examples;
import java.io.File; import java.io.File;
import java.util.Collection; import java.util.Collection;
import jsprit.analysis.toolbox.SolutionPlotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.AlgorithmConfig; import jsprit.core.algorithm.io.AlgorithmConfig;
@ -106,7 +106,7 @@ public class ConfigureAlgorithmInCodeInsteadOfPerXml {
/* /*
* plot * plot
*/ */
SolutionPlotter.plotSolutionAsPNG(problem, bestSolution, "output/solution.png", "solution"); new Plotter(problem,bestSolution).plot("output/solution.png", "solution");
} }
private static AlgorithmConfig getAlgorithmConfig() { private static AlgorithmConfig getAlgorithmConfig() {

View file

@ -19,7 +19,7 @@ package jsprit.examples;
import java.io.File; import java.io.File;
import java.util.Collection; import java.util.Collection;
import jsprit.analysis.toolbox.SolutionPlotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
@ -111,7 +111,7 @@ public class CostMatrixExample {
SolutionPrinter.print(Solutions.bestOf(solutions)); SolutionPrinter.print(Solutions.bestOf(solutions));
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.bestOf(solutions), "output/yo.png", "po"); new Plotter(vrp, Solutions.bestOf(solutions)).plot("output/yo.png", "po");
} }

View file

@ -22,7 +22,7 @@ import java.util.Collection;
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener; import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
import jsprit.analysis.toolbox.GraphStreamViewer; import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.SolutionPlotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.analysis.toolbox.StopWatch; import jsprit.analysis.toolbox.StopWatch;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
@ -112,7 +112,8 @@ public class MultipleDepotExample {
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
SolutionPrinter.print(Solutions.bestOf(solutions)); SolutionPrinter.print(Solutions.bestOf(solutions));
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.bestOf(solutions), "output/p01_solution.png", "p01");
new Plotter(vrp, Solutions.bestOf(solutions)).plot("output/p01_solution.png", "p01");
new GraphStreamViewer(vrp, Solutions.bestOf(solutions)).setRenderDelay(100).display(); new GraphStreamViewer(vrp, Solutions.bestOf(solutions)).setRenderDelay(100).display();

View file

@ -22,10 +22,10 @@ import java.util.Collection;
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener; import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
import jsprit.analysis.toolbox.GraphStreamViewer; import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.SolutionPlotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.analysis.toolbox.StopWatch;
import jsprit.analysis.toolbox.SolutionPrinter.Print; import jsprit.analysis.toolbox.SolutionPrinter.Print;
import jsprit.analysis.toolbox.StopWatch;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority; import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
@ -140,7 +140,8 @@ public class MultipleDepotExampleWithPenaltyVehicles {
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
SolutionPrinter.print(vrp,Solutions.bestOf(solutions),Print.VERBOSE); SolutionPrinter.print(vrp,Solutions.bestOf(solutions),Print.VERBOSE);
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.bestOf(solutions), "output/p08_solution.png", "p08");
new Plotter(vrp, Solutions.bestOf(solutions)).plot("output/p08_solution.png", "p08");
new GraphStreamViewer(vrp,Solutions.bestOf(solutions)).setRenderDelay(50).display(); new GraphStreamViewer(vrp,Solutions.bestOf(solutions)).setRenderDelay(50).display();
} }

View file

@ -22,7 +22,6 @@ import java.util.Collection;
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener; import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.Plotter.Label; import jsprit.analysis.toolbox.Plotter.Label;
import jsprit.analysis.toolbox.SolutionPlotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
@ -65,7 +64,8 @@ public class PickupAndDeliveryExample {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
SolutionPlotter.plotVrpAsPNG(vrp, "output/pd_solomon_r101.png", "pd_r101"); new Plotter(vrp).plot("output/pd_solomon_r101.png", "pd_r101");
/* /*
* Define the required vehicle-routing algorithms to solve the above problem. * Define the required vehicle-routing algorithms to solve the above problem.

View file

@ -23,7 +23,6 @@ import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
import jsprit.analysis.toolbox.GraphStreamViewer; import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.Plotter.Label; import jsprit.analysis.toolbox.Plotter.Label;
import jsprit.analysis.toolbox.SolutionPlotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
@ -71,7 +70,8 @@ public class PickupAndDeliveryExample2 {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
SolutionPlotter.plotVrpAsPNG(vrp, "output/pd_christophides_vrpnc1.png", "pd_vrpnc1"); new Plotter(vrp).plot("output/pd_christophides_vrpnc1.png", "pd_vrpnc1");
/* /*
* Define the required vehicle-routing algorithms to solve the above problem. * Define the required vehicle-routing algorithms to solve the above problem.

View file

@ -19,7 +19,7 @@ package jsprit.examples;
import java.io.File; import java.io.File;
import java.util.Collection; import java.util.Collection;
import jsprit.analysis.toolbox.SolutionPlotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
@ -105,7 +105,9 @@ public class SimpleExampleOpenRoutes {
/* /*
* plot * plot
*/ */
SolutionPlotter.plotSolutionAsPNG(problem, bestSolution, "output/solution.png", "solution");
new Plotter(problem, bestSolution).plot("output/solution.png", "solution");
} }
} }

View file

@ -20,10 +20,9 @@ import java.io.File;
import java.util.Collection; import java.util.Collection;
import jsprit.analysis.toolbox.GraphStreamViewer; import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPlotter;
import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.analysis.toolbox.GraphStreamViewer.Label; import jsprit.analysis.toolbox.GraphStreamViewer.Label;
import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.analysis.toolbox.SolutionPrinter.Print; import jsprit.analysis.toolbox.SolutionPrinter.Print;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
@ -64,7 +63,7 @@ public class SolomonExample {
*/ */
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
SolutionPlotter.plotVrpAsPNG(vrp, "output/solomon_C101.png", "C101"); new Plotter(vrp).plot("output/solomon_C101.png", "C101");
/* /*
* Define the required vehicle-routing algorithms to solve the above problem. * Define the required vehicle-routing algorithms to solve the above problem.

View file

@ -20,9 +20,9 @@ import java.io.File;
import java.util.Collection; import java.util.Collection;
import jsprit.analysis.toolbox.GraphStreamViewer; import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.SolutionPlotter;
import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.analysis.toolbox.GraphStreamViewer.Label; import jsprit.analysis.toolbox.GraphStreamViewer.Label;
import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.algorithm.selector.SelectBest; import jsprit.core.algorithm.selector.SelectBest;
@ -62,7 +62,7 @@ public class SolomonOpenExample {
*/ */
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
SolutionPlotter.plotVrpAsPNG(vrp, "output/solomon_C101_open.png", "C101"); new Plotter(vrp).plot("output/solomon_C101_open.png", "C101");
/* /*
* Define the required vehicle-routing algorithms to solve the above problem. * Define the required vehicle-routing algorithms to solve the above problem.

View file

@ -19,7 +19,7 @@ package jsprit.examples;
import java.io.File; import java.io.File;
import java.util.Collection; import java.util.Collection;
import jsprit.analysis.toolbox.SolutionPlotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
@ -60,7 +60,7 @@ public class SolomonR101Example {
*/ */
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
SolutionPlotter.plotVrpAsPNG(vrp, "output/solomon_R101.png", "R101"); new Plotter(vrp).plot("output/solomon_R101.png", "R101");
/* /*
* Define the required vehicle-routing algorithms to solve the above problem. * Define the required vehicle-routing algorithms to solve the above problem.
@ -91,9 +91,7 @@ public class SolomonR101Example {
/* /*
* Plot solution. * Plot solution.
*/ */
SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/solomon_R101_solution.png","R101"); new Plotter(vrp,solution).plot( "output/solomon_R101_solution.png","R101");
} }

View file

@ -21,7 +21,6 @@ import java.util.Collection;
import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.Plotter.Label; import jsprit.analysis.toolbox.Plotter.Label;
import jsprit.analysis.toolbox.SolutionPlotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
@ -69,7 +68,8 @@ public class VRPWithBackhaulsExample2 {
*/ */
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
SolutionPlotter.plotVrpAsPNG(vrp, "output/vrpwbh_christophides_vrpnc1.png", "pd_vrpnc1"); new Plotter(vrp).plot("output/vrpwbh_christophides_vrpnc1.png", "pd_vrpnc1");
/* /*
* Define the required vehicle-routing algorithms to solve the above problem. * Define the required vehicle-routing algorithms to solve the above problem.