mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
switch to Location
This commit is contained in:
parent
e33590b380
commit
7e39d08e3d
23 changed files with 390 additions and 271 deletions
|
|
@ -111,9 +111,10 @@ final class ServiceInsertionCalculator implements JobInsertionCostsCalculator{
|
||||||
/*
|
/*
|
||||||
generate new start and end for new vehicle
|
generate new start and end for new vehicle
|
||||||
*/
|
*/
|
||||||
Start start = Start.newInstance(newVehicle.getStartLocationId(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
|
// Start start = Start.newInstance(newVehicle.getStartLocationId(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
|
||||||
|
Start start = new Start(newVehicle.getStartLocation(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
|
||||||
start.setEndTime(newVehicleDepartureTime);
|
start.setEndTime(newVehicleDepartureTime);
|
||||||
End end = End.newInstance(newVehicle.getEndLocationId(), 0.0, newVehicle.getLatestArrival());
|
End end = new End(newVehicle.getEndLocation(), 0.0, newVehicle.getLatestArrival());
|
||||||
|
|
||||||
TourActivity prevAct = start;
|
TourActivity prevAct = start;
|
||||||
double prevActStartTime = newVehicleDepartureTime;
|
double prevActStartTime = newVehicleDepartureTime;
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,7 @@ 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.getStartLocationId(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
|
start = new Start(newVehicle.getStartLocation(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
|
||||||
start.setEndTime(newVehicleDepartureTime);
|
start.setEndTime(newVehicleDepartureTime);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -304,7 +304,7 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
|
||||||
}
|
}
|
||||||
|
|
||||||
if(end == null){
|
if(end == null){
|
||||||
end = End.newInstance(newVehicle.getEndLocationId(), 0.0, newVehicle.getLatestArrival());
|
end = new End(newVehicle.getEndLocation(), 0.0, newVehicle.getLatestArrival());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
end.setLocationId(newVehicle.getEndLocationId());
|
end.setLocationId(newVehicle.getEndLocationId());
|
||||||
|
|
|
||||||
|
|
@ -111,10 +111,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.getStartLocationId(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival());
|
Start start = new Start(newVehicle.getStartLocation(), newVehicle.getEarliestDeparture(), newVehicle.getLatestArrival());
|
||||||
start.setEndTime(newVehicleDepartureTime);
|
start.setEndTime(newVehicleDepartureTime);
|
||||||
|
|
||||||
End end = End.newInstance(newVehicle.getEndLocationId(), 0.0, newVehicle.getLatestArrival());
|
End end = new End(newVehicle.getEndLocation(), 0.0, newVehicle.getLatestArrival());
|
||||||
|
|
||||||
ActivityContext pickupContext = new ActivityContext();
|
ActivityContext pickupContext = new ActivityContext();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public final class Location implements HasIndex, HasId{
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private int index = -1;
|
private int index = Location.NO_INDEX;
|
||||||
|
|
||||||
private Coordinate coordinate;
|
private Coordinate coordinate;
|
||||||
|
|
||||||
|
|
@ -65,6 +65,8 @@ public final class Location implements HasIndex, HasId{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final static int NO_INDEX = -1;
|
||||||
|
|
||||||
private final int index;
|
private final int index;
|
||||||
|
|
||||||
private final Coordinate coordinate;
|
private final Coordinate coordinate;
|
||||||
|
|
@ -90,4 +92,26 @@ public final class Location implements HasIndex, HasId{
|
||||||
public Coordinate getCoordinate(){
|
public Coordinate getCoordinate(){
|
||||||
return coordinate;
|
return coordinate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof Location)) return false;
|
||||||
|
|
||||||
|
Location location = (Location) o;
|
||||||
|
|
||||||
|
if (index != location.index) return false;
|
||||||
|
if (coordinate != null ? !coordinate.equals(location.coordinate) : location.coordinate != null) return false;
|
||||||
|
if (id != null ? !id.equals(location.id) : location.id != null) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = index;
|
||||||
|
result = 31 * result + (coordinate != null ? coordinate.hashCode() : 0);
|
||||||
|
result = 31 * result + (id != null ? id.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.problem.io;
|
package jsprit.core.problem.io;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||||
import jsprit.core.problem.driver.Driver;
|
import jsprit.core.problem.driver.Driver;
|
||||||
|
|
@ -366,25 +367,27 @@ public class VrpXMLReader{
|
||||||
String name = shipmentConfig.getString("name");
|
String name = shipmentConfig.getString("name");
|
||||||
if(name != null) builder.setName(name);
|
if(name != null) builder.setName(name);
|
||||||
|
|
||||||
|
//pickup location
|
||||||
//pickup-locationId
|
//pickup-locationId
|
||||||
|
Location.Builder pickupLocationBuilder = Location.Builder.newInstance();
|
||||||
String pickupLocationId = shipmentConfig.getString("pickup.locationId");
|
String pickupLocationId = shipmentConfig.getString("pickup.locationId");
|
||||||
if(pickupLocationId != null){
|
if(pickupLocationId == null) pickupLocationId = shipmentConfig.getString("pickup.location.id");
|
||||||
builder.setPickupLocationId(pickupLocationId);
|
if(pickupLocationId != null){
|
||||||
|
pickupLocationBuilder.setId(pickupLocationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//pickup-coord
|
//pickup-coord
|
||||||
Coordinate pickupCoord = getCoord(shipmentConfig,"pickup.");
|
Coordinate pickupCoord = getCoord(shipmentConfig,"pickup.");
|
||||||
if(pickupCoord != null){
|
if(pickupCoord == null) pickupCoord = getCoord(shipmentConfig,"pickup.location.");
|
||||||
builder.setPickupCoord(pickupCoord);
|
if(pickupCoord != null){
|
||||||
if(pickupLocationId != null){
|
pickupLocationBuilder.setCoordinate(pickupCoord);
|
||||||
// vrpBuilder.addLocation(pickupLocationId,pickupCoord);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// vrpBuilder.addLocation(pickupCoord.toString(),pickupCoord);
|
|
||||||
builder.setPickupLocationId(pickupCoord.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//pickup.location.index
|
||||||
|
String pickupLocationIndex = shipmentConfig.getString("pickup.location.index");
|
||||||
|
if(pickupLocationIndex != null) pickupLocationBuilder.setIndex(Integer.parseInt(pickupLocationIndex));
|
||||||
|
builder.setPickupLocation(pickupLocationBuilder.build());
|
||||||
|
|
||||||
//pickup-serviceTime
|
//pickup-serviceTime
|
||||||
String pickupServiceTime = shipmentConfig.getString("pickup.duration");
|
String pickupServiceTime = shipmentConfig.getString("pickup.duration");
|
||||||
if(pickupServiceTime != null) builder.setPickupServiceTime(Double.parseDouble(pickupServiceTime));
|
if(pickupServiceTime != null) builder.setPickupServiceTime(Double.parseDouble(pickupServiceTime));
|
||||||
|
|
@ -397,25 +400,27 @@ public class VrpXMLReader{
|
||||||
builder.setPickupTimeWindow(pickupTW);
|
builder.setPickupTimeWindow(pickupTW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//delivery location
|
||||||
//delivery-locationId
|
//delivery-locationId
|
||||||
|
Location.Builder deliveryLocationBuilder = Location.Builder.newInstance();
|
||||||
String deliveryLocationId = shipmentConfig.getString("delivery.locationId");
|
String deliveryLocationId = shipmentConfig.getString("delivery.locationId");
|
||||||
if(deliveryLocationId != null){
|
if(deliveryLocationId == null) deliveryLocationId = shipmentConfig.getString("delivery.location.id");
|
||||||
builder.setDeliveryLocationId(deliveryLocationId);
|
if(deliveryLocationId != null){
|
||||||
|
deliveryLocationBuilder.setId(deliveryLocationId);
|
||||||
|
// builder.setDeliveryLocationId(deliveryLocationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//delivery-coord
|
//delivery-coord
|
||||||
Coordinate deliveryCoord = getCoord(shipmentConfig,"delivery.");
|
Coordinate deliveryCoord = getCoord(shipmentConfig,"delivery.");
|
||||||
if(deliveryCoord != null){
|
if(deliveryCoord == null) deliveryCoord = getCoord(shipmentConfig,"delivery.location.");
|
||||||
builder.setDeliveryCoord(deliveryCoord);
|
if(deliveryCoord != null){
|
||||||
if(deliveryLocationId != null){
|
deliveryLocationBuilder.setCoordinate(deliveryCoord);
|
||||||
// vrpBuilder.addLocation(deliveryLocationId,deliveryCoord);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// vrpBuilder.addLocation(deliveryCoord.toString(),deliveryCoord);
|
|
||||||
builder.setDeliveryLocationId(deliveryCoord.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String deliveryLocationIndex = shipmentConfig.getString("delivery.location.index");
|
||||||
|
if(deliveryLocationIndex != null) deliveryLocationBuilder.setIndex(Integer.parseInt(deliveryLocationIndex));
|
||||||
|
builder.setDeliveryLocation(deliveryLocationBuilder.build());
|
||||||
|
|
||||||
//delivery-serviceTime
|
//delivery-serviceTime
|
||||||
String deliveryServiceTime = shipmentConfig.getString("delivery.duration");
|
String deliveryServiceTime = shipmentConfig.getString("delivery.duration");
|
||||||
if(deliveryServiceTime != null) builder.setDeliveryServiceTime(Double.parseDouble(deliveryServiceTime));
|
if(deliveryServiceTime != null) builder.setDeliveryServiceTime(Double.parseDouble(deliveryServiceTime));
|
||||||
|
|
@ -488,19 +493,24 @@ public class VrpXMLReader{
|
||||||
String name = serviceConfig.getString("name");
|
String name = serviceConfig.getString("name");
|
||||||
if(name != null) builder.setName(name);
|
if(name != null) builder.setName(name);
|
||||||
|
|
||||||
|
//location
|
||||||
|
Location.Builder locationBuilder = Location.Builder.newInstance();
|
||||||
String serviceLocationId = serviceConfig.getString("locationId");
|
String serviceLocationId = serviceConfig.getString("locationId");
|
||||||
if(serviceLocationId != null) builder.setLocationId(serviceLocationId);
|
if(serviceLocationId == null) {
|
||||||
|
serviceLocationId = serviceConfig.getString("location.id");
|
||||||
|
}
|
||||||
|
if(serviceLocationId != null) locationBuilder.setId(serviceLocationId);
|
||||||
|
|
||||||
Coordinate serviceCoord = getCoord(serviceConfig,"");
|
Coordinate serviceCoord = getCoord(serviceConfig,"");
|
||||||
if(serviceCoord != null){
|
if(serviceCoord == null) serviceCoord = getCoord(serviceConfig,"location.");
|
||||||
builder.setCoord(serviceCoord);
|
if(serviceCoord != null){
|
||||||
if(serviceLocationId != null){
|
locationBuilder.setCoordinate(serviceCoord);
|
||||||
// vrpBuilder.addLocation(serviceLocationId,serviceCoord);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// vrpBuilder.addLocation(serviceCoord.toString(),serviceCoord);
|
|
||||||
builder.setLocationId(serviceCoord.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String locationIndex = serviceConfig.getString("location.index");
|
||||||
|
if(locationIndex != null) locationBuilder.setIndex(Integer.parseInt(locationIndex));
|
||||||
|
builder.setLocation(locationBuilder.build());
|
||||||
|
|
||||||
if(serviceConfig.containsKey("duration")){
|
if(serviceConfig.containsKey("duration")){
|
||||||
builder.setServiceTime(serviceConfig.getDouble("duration"));
|
builder.setServiceTime(serviceConfig.getDouble("duration"));
|
||||||
}
|
}
|
||||||
|
|
@ -602,12 +612,12 @@ public class VrpXMLReader{
|
||||||
builder.setType(type);
|
builder.setType(type);
|
||||||
|
|
||||||
//read startlocation
|
//read startlocation
|
||||||
|
Location.Builder startLocationBuilder = Location.Builder.newInstance();
|
||||||
String locationId = vehicleConfig.getString("location.id");
|
String locationId = vehicleConfig.getString("location.id");
|
||||||
if(locationId == null) {
|
if(locationId == null) {
|
||||||
locationId = vehicleConfig.getString("startLocation.id");
|
locationId = vehicleConfig.getString("startLocation.id");
|
||||||
}
|
}
|
||||||
if(locationId == null) throw new IllegalStateException("location.id is missing.");
|
startLocationBuilder.setId(locationId);
|
||||||
builder.setStartLocationId(locationId);
|
|
||||||
String coordX = vehicleConfig.getString("location.coord[@x]");
|
String coordX = vehicleConfig.getString("location.coord[@x]");
|
||||||
String coordY = vehicleConfig.getString("location.coord[@y]");
|
String coordY = vehicleConfig.getString("location.coord[@y]");
|
||||||
if(coordX == null || coordY == null) {
|
if(coordX == null || coordY == null) {
|
||||||
|
|
@ -622,13 +632,23 @@ public class VrpXMLReader{
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Coordinate coordinate = Coordinate.newInstance(Double.parseDouble(coordX), Double.parseDouble(coordY));
|
Coordinate coordinate = Coordinate.newInstance(Double.parseDouble(coordX), Double.parseDouble(coordY));
|
||||||
builder.setStartLocationCoordinate(coordinate);
|
startLocationBuilder.setCoordinate(coordinate);
|
||||||
|
}
|
||||||
}
|
String index = vehicleConfig.getString("startLocation.index");
|
||||||
|
if(index == null) index = vehicleConfig.getString("location.index");
|
||||||
|
if(index != null){
|
||||||
|
startLocationBuilder.setIndex(Integer.parseInt(index));
|
||||||
|
}
|
||||||
|
builder.setStartLocation(startLocationBuilder.build());
|
||||||
|
|
||||||
//read endlocation
|
//read endlocation
|
||||||
|
Location.Builder endLocationBuilder = Location.Builder.newInstance();
|
||||||
|
boolean hasEndLocation = false;
|
||||||
String endLocationId = vehicleConfig.getString("endLocation.id");
|
String endLocationId = vehicleConfig.getString("endLocation.id");
|
||||||
if(endLocationId != null) builder.setEndLocationId(endLocationId);
|
if(endLocationId != null) {
|
||||||
|
hasEndLocation = true;
|
||||||
|
endLocationBuilder.setId(endLocationId);
|
||||||
|
}
|
||||||
String endCoordX = vehicleConfig.getString("endLocation.coord[@x]");
|
String endCoordX = vehicleConfig.getString("endLocation.coord[@x]");
|
||||||
String endCoordY = vehicleConfig.getString("endLocation.coord[@y]");
|
String endCoordY = vehicleConfig.getString("endLocation.coord[@y]");
|
||||||
if(endCoordX == null || endCoordY == null) {
|
if(endCoordX == null || endCoordY == null) {
|
||||||
|
|
@ -639,8 +659,15 @@ public class VrpXMLReader{
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Coordinate coordinate = Coordinate.newInstance(Double.parseDouble(endCoordX), Double.parseDouble(endCoordY));
|
Coordinate coordinate = Coordinate.newInstance(Double.parseDouble(endCoordX), Double.parseDouble(endCoordY));
|
||||||
builder.setEndLocationCoordinate(coordinate);
|
hasEndLocation = true;
|
||||||
|
endLocationBuilder.setCoordinate(coordinate);
|
||||||
}
|
}
|
||||||
|
String endLocationIndex = vehicleConfig.getString("endLocation.index");
|
||||||
|
if(endLocationIndex != null) {
|
||||||
|
hasEndLocation = true;
|
||||||
|
endLocationBuilder.setIndex(Integer.parseInt(endLocationIndex));
|
||||||
|
}
|
||||||
|
if(hasEndLocation) builder.setEndLocation(endLocationBuilder.build());
|
||||||
|
|
||||||
//read timeSchedule
|
//read timeSchedule
|
||||||
String start = vehicleConfig.getString("timeSchedule.start");
|
String start = vehicleConfig.getString("timeSchedule.start");
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.problem.io;
|
package jsprit.core.problem.io;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.Skills;
|
import jsprit.core.problem.Skills;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.job.Job;
|
import jsprit.core.problem.job.Job;
|
||||||
|
|
@ -220,11 +221,14 @@ public class VrpXMLWriter {
|
||||||
Service service = (Service) j;
|
Service service = (Service) j;
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+")[@id]", service.getId());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+")[@id]", service.getId());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+")[@type]", service.getType());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+")[@type]", service.getType());
|
||||||
if(service.getLocationId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").locationId", service.getLocationId());
|
if(service.getLocation().getId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").location.id", service.getLocation().getId());
|
||||||
if(service.getCoord() != null) {
|
if(service.getLocation().getCoordinate() != null) {
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").coord[@x]", service.getCoord().getX());
|
xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.coord[@x]", service.getLocation().getCoordinate().getX());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").coord[@y]", service.getCoord().getY());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").location.coord[@y]", service.getLocation().getCoordinate().getY());
|
||||||
}
|
}
|
||||||
|
if(service.getLocation().getIndex() != Location.NO_INDEX){
|
||||||
|
xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.index", service.getLocation().getIndex());
|
||||||
|
}
|
||||||
for(int i=0;i<service.getSize().getNuOfDimensions();i++){
|
for(int i=0;i<service.getSize().getNuOfDimensions();i++){
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")[@index]", i);
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")[@index]", i);
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")", service.getSize().get(i));
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").capacity-dimensions.dimension("+i+")", service.getSize().get(i));
|
||||||
|
|
@ -255,22 +259,28 @@ public class VrpXMLWriter {
|
||||||
Shipment shipment = (Shipment) j;
|
Shipment shipment = (Shipment) j;
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+")[@id]", shipment.getId());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+")[@id]", shipment.getId());
|
||||||
// xmlConfig.setProperty(shipmentPathString + "("+counter+")[@type]", service.getType());
|
// xmlConfig.setProperty(shipmentPathString + "("+counter+")[@type]", service.getType());
|
||||||
if(shipment.getPickupLocationId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.locationId", shipment.getPickupLocationId());
|
if(shipment.getPickupLocation().getId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.location.id", shipment.getPickupLocation().getId());
|
||||||
if(shipment.getPickupCoord() != null) {
|
if(shipment.getPickupLocation().getCoordinate() != null) {
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.coord[@x]", shipment.getPickupCoord().getX());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.location.coord[@x]", shipment.getPickupLocation().getCoordinate().getX());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.coord[@y]", shipment.getPickupCoord().getY());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.location.coord[@y]", shipment.getPickupLocation().getCoordinate().getY());
|
||||||
}
|
}
|
||||||
|
if(shipment.getPickupLocation().getIndex() != Location.NO_INDEX){
|
||||||
|
xmlConfig.setProperty(shipmentPathString + "(" + counter + ").pickup.location.index", shipment.getPickupLocation().getIndex());
|
||||||
|
}
|
||||||
|
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.duration", shipment.getPickupServiceTime());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.duration", shipment.getPickupServiceTime());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.timeWindows.timeWindow(0).start", shipment.getPickupTimeWindow().getStart());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.timeWindows.timeWindow(0).start", shipment.getPickupTimeWindow().getStart());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.timeWindows.timeWindow(0).end", shipment.getPickupTimeWindow().getEnd());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").pickup.timeWindows.timeWindow(0).end", shipment.getPickupTimeWindow().getEnd());
|
||||||
|
|
||||||
|
|
||||||
if(shipment.getDeliveryLocationId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.locationId", shipment.getDeliveryLocationId());
|
if(shipment.getDeliveryLocation().getId() != null) xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.location.id", shipment.getDeliveryLocation().getId());
|
||||||
if(shipment.getDeliveryCoord() != null) {
|
if(shipment.getDeliveryLocation().getCoordinate() != null) {
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.coord[@x]", shipment.getDeliveryCoord().getX());
|
xmlConfig.setProperty(shipmentPathString + "(" + counter + ").delivery.location.coord[@x]", shipment.getDeliveryLocation().getCoordinate().getX());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.coord[@y]", shipment.getDeliveryCoord().getY());
|
xmlConfig.setProperty(shipmentPathString + "(" + counter + ").delivery.location.coord[@y]", shipment.getDeliveryLocation().getCoordinate().getY());
|
||||||
}
|
}
|
||||||
|
if(shipment.getDeliveryLocation().getIndex() != Location.NO_INDEX){
|
||||||
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.location.index", shipment.getDeliveryLocation().getIndex());
|
||||||
|
}
|
||||||
|
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.duration", shipment.getDeliveryServiceTime());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.duration", shipment.getDeliveryServiceTime());
|
||||||
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).start", shipment.getDeliveryTimeWindow().getStart());
|
xmlConfig.setProperty(shipmentPathString + "("+counter+").delivery.timeWindows.timeWindow(0).start", shipment.getDeliveryTimeWindow().getStart());
|
||||||
|
|
@ -310,16 +320,23 @@ public class VrpXMLWriter {
|
||||||
}
|
}
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").id", vehicle.getId());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").id", vehicle.getId());
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").typeId", vehicle.getType().getTypeId());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").typeId", vehicle.getType().getTypeId());
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").startLocation.id", vehicle.getStartLocationId());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").startLocation.id", vehicle.getStartLocation().getId());
|
||||||
if(vehicle.getStartLocationCoordinate() != null){
|
if(vehicle.getStartLocation().getCoordinate() != null){
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").startLocation.coord[@x]", vehicle.getStartLocationCoordinate().getX());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").startLocation.coord[@x]", vehicle.getStartLocation().getCoordinate().getX());
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").startLocation.coord[@y]", vehicle.getStartLocationCoordinate().getY());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").startLocation.coord[@y]", vehicle.getStartLocation().getCoordinate().getY());
|
||||||
}
|
}
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").endLocation.id", vehicle.getEndLocationId());
|
if(vehicle.getStartLocation().getIndex() != Location.NO_INDEX){
|
||||||
if(vehicle.getEndLocationCoordinate() != null){
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").startLocation.index", vehicle.getStartLocation().getIndex());
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").endLocation.coord[@x]", vehicle.getEndLocationCoordinate().getX());
|
}
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").endLocation.coord[@y]", vehicle.getEndLocationCoordinate().getY());
|
|
||||||
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").endLocation.id", vehicle.getEndLocation().getId());
|
||||||
|
if(vehicle.getEndLocation().getCoordinate() != null){
|
||||||
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").endLocation.coord[@x]", vehicle.getEndLocation().getCoordinate().getX());
|
||||||
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").endLocation.coord[@y]", vehicle.getEndLocation().getCoordinate().getY());
|
||||||
}
|
}
|
||||||
|
if(vehicle.getEndLocation().getIndex() != Location.NO_INDEX){
|
||||||
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").endLocation.index", vehicle.getEndLocation().getId());
|
||||||
|
}
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").timeSchedule.start", vehicle.getEarliestDeparture());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").timeSchedule.start", vehicle.getEarliestDeparture());
|
||||||
xmlConfig.setProperty(vehiclePathString + "("+counter+").timeSchedule.end", vehicle.getLatestArrival());
|
xmlConfig.setProperty(vehiclePathString + "("+counter+").timeSchedule.end", vehicle.getLatestArrival());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,9 +175,9 @@ public class VehicleRoute {
|
||||||
super();
|
super();
|
||||||
this.vehicle = vehicle;
|
this.vehicle = vehicle;
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
start = Start.newInstance(vehicle.getStartLocationId(), vehicle.getEarliestDeparture(), Double.MAX_VALUE);
|
start = new Start(vehicle.getStartLocation(), vehicle.getEarliestDeparture(), Double.MAX_VALUE);
|
||||||
start.setEndTime(vehicle.getEarliestDeparture());
|
start.setEndTime(vehicle.getEarliestDeparture());
|
||||||
end = End.newInstance(vehicle.getEndLocationId(), 0.0, vehicle.getLatestArrival());
|
end = new End(vehicle.getEndLocation(), 0.0, vehicle.getLatestArrival());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -401,8 +401,8 @@ public class VehicleRoute {
|
||||||
private void setStartAndEnd(Vehicle vehicle, double vehicleDepTime) {
|
private void setStartAndEnd(Vehicle vehicle, double vehicleDepTime) {
|
||||||
if(!(vehicle instanceof NoVehicle)){
|
if(!(vehicle instanceof NoVehicle)){
|
||||||
if(start == null && end == null){
|
if(start == null && end == null){
|
||||||
start = Start.newInstance(vehicle.getStartLocationId(), vehicle.getEarliestDeparture(), vehicle.getLatestArrival());
|
start = new Start(vehicle.getStartLocation(), vehicle.getEarliestDeparture(), vehicle.getLatestArrival());
|
||||||
end = End.newInstance(vehicle.getEndLocationId(), vehicle.getEarliestDeparture(), vehicle.getLatestArrival());
|
end = new End(vehicle.getEndLocation(), vehicle.getEarliestDeparture(), vehicle.getLatestArrival());
|
||||||
}
|
}
|
||||||
start.setEndTime(Math.max(vehicleDepTime, vehicle.getEarliestDeparture()));
|
start.setEndTime(Math.max(vehicleDepTime, vehicle.getEarliestDeparture()));
|
||||||
start.setTheoreticalEarliestOperationStartTime(vehicle.getEarliestDeparture());
|
start.setTheoreticalEarliestOperationStartTime(vehicle.getEarliestDeparture());
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,24 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2014 Stefan Schroeder.
|
* Copyright (C) 2014 Stefan Schroeder
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
* version 3.0 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
*
|
* Lesser General Public License for more details.
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Stefan Schroeder - initial API and implementation
|
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
import jsprit.core.problem.AbstractActivity;
|
import jsprit.core.problem.AbstractActivity;
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.job.Delivery;
|
import jsprit.core.problem.job.Delivery;
|
||||||
|
|
||||||
public final class DeliverService extends AbstractActivity implements DeliveryActivity{
|
public final class DeliverService extends AbstractActivity implements DeliveryActivity{
|
||||||
|
|
@ -56,7 +55,12 @@ public final class DeliverService extends AbstractActivity implements DeliveryAc
|
||||||
return delivery.getLocationId();
|
return delivery.getLocationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return delivery.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getTheoreticalEarliestOperationStartTime() {
|
public double getTheoreticalEarliestOperationStartTime() {
|
||||||
return delivery.getTimeWindow().getStart();
|
return delivery.getTimeWindow().getStart();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
import jsprit.core.problem.AbstractActivity;
|
import jsprit.core.problem.AbstractActivity;
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.job.Job;
|
import jsprit.core.problem.job.Job;
|
||||||
import jsprit.core.problem.job.Shipment;
|
import jsprit.core.problem.job.Shipment;
|
||||||
|
|
||||||
|
|
@ -61,7 +62,12 @@ public final class DeliverShipment extends AbstractActivity implements DeliveryA
|
||||||
return shipment.getDeliveryLocationId();
|
return shipment.getDeliveryLocationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return shipment.getDeliveryLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getTheoreticalEarliestOperationStartTime() {
|
public double getTheoreticalEarliestOperationStartTime() {
|
||||||
return shipment.getDeliveryTimeWindow().getStart();
|
return shipment.getDeliveryTimeWindow().getStart();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (C) 2013 Stefan Schroeder
|
* Copyright (C) 2014 Stefan Schroeder
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
* version 3.0 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
@ -18,6 +18,7 @@ package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
import jsprit.core.problem.AbstractActivity;
|
import jsprit.core.problem.AbstractActivity;
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.util.Coordinate;
|
import jsprit.core.util.Coordinate;
|
||||||
|
|
||||||
public final class End extends AbstractActivity implements TourActivity {
|
public final class End extends AbstractActivity implements TourActivity {
|
||||||
|
|
@ -35,15 +36,15 @@ public final class End extends AbstractActivity implements TourActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Capacity capacity = Capacity.Builder.newInstance().build();
|
private final static Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
|
|
||||||
private String locationId;
|
|
||||||
|
|
||||||
private Coordinate coordinate;
|
private Coordinate coordinate;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
Coordinate getCoordinate() {
|
Coordinate getCoordinate() {
|
||||||
return coordinate;
|
return coordinate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
void setCoordinate(Coordinate coordinate) {
|
void setCoordinate(Coordinate coordinate) {
|
||||||
this.coordinate = coordinate;
|
this.coordinate = coordinate;
|
||||||
}
|
}
|
||||||
|
|
@ -57,6 +58,8 @@ public final class End extends AbstractActivity implements TourActivity {
|
||||||
|
|
||||||
private double arrTime;
|
private double arrTime;
|
||||||
|
|
||||||
|
private Location location;
|
||||||
|
|
||||||
public void setTheoreticalEarliestOperationStartTime(double theoreticalEarliestOperationStartTime) {
|
public void setTheoreticalEarliestOperationStartTime(double theoreticalEarliestOperationStartTime) {
|
||||||
theoretical_earliestOperationStartTime = theoreticalEarliestOperationStartTime;
|
theoretical_earliestOperationStartTime = theoreticalEarliestOperationStartTime;
|
||||||
}
|
}
|
||||||
|
|
@ -65,17 +68,27 @@ public final class End extends AbstractActivity implements TourActivity {
|
||||||
theoretical_latestOperationStartTime = theoreticalLatestOperationStartTime;
|
theoretical_latestOperationStartTime = theoreticalLatestOperationStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public End(String locationId, double theoreticalStart, double theoreticalEnd) {
|
public End(Location location, double theoreticalStart, double theoreticalEnd) {
|
||||||
super();
|
super();
|
||||||
this.locationId = locationId;
|
this.location = location;
|
||||||
theoretical_earliestOperationStartTime = theoreticalStart;
|
theoretical_earliestOperationStartTime = theoreticalStart;
|
||||||
theoretical_latestOperationStartTime = theoreticalEnd;
|
theoretical_latestOperationStartTime = theoreticalEnd;
|
||||||
endTime = theoreticalEnd;
|
endTime = theoreticalEnd;
|
||||||
setIndex(-2);
|
setIndex(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public End(String locationId, double theoreticalStart, double theoreticalEnd) {
|
||||||
|
super();
|
||||||
|
if(locationId != null) this.location = Location.Builder.newInstance().setId(locationId).build();
|
||||||
|
theoretical_earliestOperationStartTime = theoreticalStart;
|
||||||
|
theoretical_latestOperationStartTime = theoreticalEnd;
|
||||||
|
endTime = theoreticalEnd;
|
||||||
|
setIndex(-2);
|
||||||
|
}
|
||||||
|
|
||||||
public End(End end) {
|
public End(End end) {
|
||||||
this.locationId = end.getLocationId();
|
this.location = end.getLocation();
|
||||||
|
// this.locationId = end.getLocationId();
|
||||||
theoretical_earliestOperationStartTime = end.getTheoreticalEarliestOperationStartTime();
|
theoretical_earliestOperationStartTime = end.getTheoreticalEarliestOperationStartTime();
|
||||||
theoretical_latestOperationStartTime = end.getTheoreticalLatestOperationStartTime();
|
theoretical_latestOperationStartTime = end.getTheoreticalLatestOperationStartTime();
|
||||||
arrTime = end.getArrTime();
|
arrTime = end.getArrTime();
|
||||||
|
|
@ -99,16 +112,29 @@ public final class End extends AbstractActivity implements TourActivity {
|
||||||
this.endTime = endTime;
|
this.endTime = endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setLocationId(String locationId) {
|
public void setLocationId(String locationId) {
|
||||||
this.locationId = locationId;
|
if(locationId == null) return;
|
||||||
|
this.location = Location.Builder.newInstance().setId(locationId).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLocation(Location location){
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public String getLocationId() {
|
public String getLocationId() {
|
||||||
return locationId;
|
if(location == null) return null;
|
||||||
|
return location.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getOperationTime() {
|
public double getOperationTime() {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +142,7 @@ public final class End extends AbstractActivity implements TourActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[type="+getName()+"][locationId=" + getLocationId()
|
return "[type="+getName()+"][location=" + location
|
||||||
+ "][twStart=" + Activities.round(theoretical_earliestOperationStartTime)
|
+ "][twStart=" + Activities.round(theoretical_earliestOperationStartTime)
|
||||||
+ "][twEnd=" + Activities.round(theoretical_latestOperationStartTime) + "]";
|
+ "][twEnd=" + Activities.round(theoretical_latestOperationStartTime) + "]";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,24 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2014 Stefan Schroeder.
|
* Copyright (C) 2014 Stefan Schroeder
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
* version 3.0 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
*
|
* Lesser General Public License for more details.
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Stefan Schroeder - initial API and implementation
|
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.problem.solution.route.activity;
|
package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
import jsprit.core.problem.AbstractActivity;
|
import jsprit.core.problem.AbstractActivity;
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.job.Pickup;
|
import jsprit.core.problem.job.Pickup;
|
||||||
import jsprit.core.problem.job.Service;
|
import jsprit.core.problem.job.Service;
|
||||||
|
|
||||||
|
|
@ -57,7 +56,12 @@ public final class PickupService extends AbstractActivity implements PickupActiv
|
||||||
return pickup.getLocationId();
|
return pickup.getLocationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return pickup.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getTheoreticalEarliestOperationStartTime() {
|
public double getTheoreticalEarliestOperationStartTime() {
|
||||||
return pickup.getTimeWindow().getStart();
|
return pickup.getTimeWindow().getStart();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
import jsprit.core.problem.AbstractActivity;
|
import jsprit.core.problem.AbstractActivity;
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.job.Job;
|
import jsprit.core.problem.job.Job;
|
||||||
import jsprit.core.problem.job.Shipment;
|
import jsprit.core.problem.job.Shipment;
|
||||||
|
|
||||||
|
|
@ -57,7 +58,12 @@ public final class PickupShipment extends AbstractActivity implements PickupActi
|
||||||
return shipment.getPickupLocationId();
|
return shipment.getPickupLocationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return shipment.getPickupLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getTheoreticalEarliestOperationStartTime() {
|
public double getTheoreticalEarliestOperationStartTime() {
|
||||||
return shipment.getPickupTimeWindow().getStart();
|
return shipment.getPickupTimeWindow().getStart();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (C) 2013 Stefan Schroeder
|
* Copyright (C) 2014 Stefan Schroeder
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
* version 3.0 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
@ -18,6 +18,7 @@ package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
import jsprit.core.problem.AbstractActivity;
|
import jsprit.core.problem.AbstractActivity;
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.job.Service;
|
import jsprit.core.problem.job.Service;
|
||||||
import jsprit.core.problem.solution.route.activity.TourActivity.JobActivity;
|
import jsprit.core.problem.solution.route.activity.TourActivity.JobActivity;
|
||||||
|
|
||||||
|
|
@ -131,8 +132,13 @@ public class ServiceActivity extends AbstractActivity implements JobActivity{
|
||||||
return service.getLocationId();
|
return service.getLocationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Override
|
public Location getLocation() {
|
||||||
|
return service.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Service getJob() {
|
public Service getJob() {
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (C) 2013 Stefan Schroeder
|
* Copyright (C) 2014 Stefan Schroeder
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
* version 3.0 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
@ -18,6 +18,7 @@ package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
import jsprit.core.problem.AbstractActivity;
|
import jsprit.core.problem.AbstractActivity;
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
|
|
||||||
public final class Start extends AbstractActivity implements TourActivity {
|
public final class Start extends AbstractActivity implements TourActivity {
|
||||||
|
|
||||||
|
|
@ -45,19 +46,31 @@ public final class Start extends AbstractActivity implements TourActivity {
|
||||||
|
|
||||||
private double endTime;
|
private double endTime;
|
||||||
|
|
||||||
private double arrTime;
|
private double arrTime;
|
||||||
|
|
||||||
|
private Location location;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Start(String locationId, double theoreticalStart, double theoreticalEnd) {
|
public Start(String locationId, double theoreticalStart, double theoreticalEnd) {
|
||||||
super();
|
super();
|
||||||
this.locationId = locationId;
|
if(locationId != null) this.location = Location.Builder.newInstance().setId(locationId).build();
|
||||||
this.theoretical_earliestOperationStartTime = theoreticalStart;
|
this.theoretical_earliestOperationStartTime = theoreticalStart;
|
||||||
this.theoretical_latestOperationStartTime = theoreticalEnd;
|
this.theoretical_latestOperationStartTime = theoreticalEnd;
|
||||||
this.endTime = theoreticalStart;
|
this.endTime = theoreticalStart;
|
||||||
setIndex(-1);
|
setIndex(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Start(Location location, double theoreticalStart, double theoreticalEnd) {
|
||||||
|
super();
|
||||||
|
this.location = location;
|
||||||
|
this.theoretical_earliestOperationStartTime = theoreticalStart;
|
||||||
|
this.theoretical_latestOperationStartTime = theoreticalEnd;
|
||||||
|
this.endTime = theoreticalStart;
|
||||||
|
setIndex(-1);
|
||||||
|
}
|
||||||
|
|
||||||
private Start(Start start) {
|
private Start(Start start) {
|
||||||
this.locationId = start.getLocationId();
|
this.location = start.getLocation();
|
||||||
theoretical_earliestOperationStartTime = start.getTheoreticalEarliestOperationStartTime();
|
theoretical_earliestOperationStartTime = start.getTheoreticalEarliestOperationStartTime();
|
||||||
theoretical_latestOperationStartTime = start.getTheoreticalLatestOperationStartTime();
|
theoretical_latestOperationStartTime = start.getTheoreticalLatestOperationStartTime();
|
||||||
endTime = start.getEndTime();
|
endTime = start.getEndTime();
|
||||||
|
|
@ -68,10 +81,14 @@ public final class Start extends AbstractActivity implements TourActivity {
|
||||||
return theoretical_earliestOperationStartTime;
|
return theoretical_earliestOperationStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setLocationId(String locationId) {
|
public void setLocationId(String locationId) {
|
||||||
this.locationId = locationId;
|
if(locationId == null) return;
|
||||||
|
this.location = Location.Builder.newInstance().setId(locationId).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLocation(Location location) { this.location = location; };
|
||||||
|
|
||||||
public double getTheoreticalLatestOperationStartTime() {
|
public double getTheoreticalLatestOperationStartTime() {
|
||||||
return theoretical_latestOperationStartTime;
|
return theoretical_latestOperationStartTime;
|
||||||
}
|
}
|
||||||
|
|
@ -84,19 +101,26 @@ public final class Start extends AbstractActivity implements TourActivity {
|
||||||
this.theoretical_latestOperationStartTime=time;
|
this.theoretical_latestOperationStartTime=time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public String getLocationId() {
|
public String getLocationId() {
|
||||||
return locationId;
|
if(location == null) return null;
|
||||||
|
return location.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getOperationTime() {
|
public double getOperationTime() {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[type="+getName()+"][locationId=" + getLocationId()
|
return "[type="+getName()+"][location=" + location
|
||||||
+ "][twStart=" + Activities.round(theoretical_earliestOperationStartTime)
|
+ "][twStart=" + Activities.round(theoretical_earliestOperationStartTime)
|
||||||
+ "][twEnd=" + Activities.round(theoretical_latestOperationStartTime) + "]";
|
+ "][twEnd=" + Activities.round(theoretical_latestOperationStartTime) + "]";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (C) 2013 Stefan Schroeder
|
* Copyright (C) 2014 Stefan Schroeder
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
* version 3.0 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
@ -18,6 +18,7 @@ package jsprit.core.problem.solution.route.activity;
|
||||||
|
|
||||||
import jsprit.core.problem.Capacity;
|
import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.problem.HasIndex;
|
import jsprit.core.problem.HasIndex;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.job.Job;
|
import jsprit.core.problem.job.Job;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -60,8 +61,17 @@ public interface TourActivity extends HasIndex {
|
||||||
* Returns the activity's locationId.
|
* Returns the activity's locationId.
|
||||||
*
|
*
|
||||||
* @return locationId
|
* @return locationId
|
||||||
|
* @deprecated use location
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public abstract String getLocationId();
|
public abstract String getLocationId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns location.
|
||||||
|
*
|
||||||
|
* @return location
|
||||||
|
*/
|
||||||
|
public abstract Location getLocation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the theoretical earliest operation start time, which is the time that is just allowed
|
* Returns the theoretical earliest operation start time, which is the time that is just allowed
|
||||||
|
|
|
||||||
|
|
@ -54,31 +54,9 @@
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="id" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
<xs:element name="id" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||||
<xs:element name="location" minOccurs="0" maxOccurs="1">
|
<xs:element name="location" type="locationType" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:complexType>
|
<xs:element name="startLocation" type="locationType" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:all>
|
<xs:element name="endLocation" type="locationType" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="id" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
||||||
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
|
||||||
|
|
||||||
</xs:all>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="startLocation" minOccurs="0" maxOccurs="1">
|
|
||||||
<xs:complexType>
|
|
||||||
<xs:all>
|
|
||||||
<xs:element name="id" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
||||||
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
|
||||||
</xs:all>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="endLocation" minOccurs="0" maxOccurs="1">
|
|
||||||
<xs:complexType>
|
|
||||||
<xs:all>
|
|
||||||
<xs:element name="id" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
||||||
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
|
||||||
</xs:all>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="typeId" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
<xs:element name="typeId" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||||
<xs:element name="timeSchedule" type="timeWindowType"/>
|
<xs:element name="timeSchedule" type="timeWindowType"/>
|
||||||
<xs:element name="returnToDepot" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="returnToDepot" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
|
||||||
|
|
@ -139,6 +117,7 @@
|
||||||
<xs:element name="service" minOccurs="0" maxOccurs="unbounded">
|
<xs:element name="service" minOccurs="0" maxOccurs="unbounded">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
|
<xs:element name="location" type="locationType" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="locationId" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="locationId" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||||
|
|
@ -185,6 +164,7 @@
|
||||||
<xs:element name="pickup" minOccurs="1" maxOccurs="1">
|
<xs:element name="pickup" minOccurs="1" maxOccurs="1">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
|
<xs:element name="location" type="locationType" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="locationId" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="locationId" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="duration" type="xs:decimal" minOccurs="0" maxOccurs="1" default="0.0"/>
|
<xs:element name="duration" type="xs:decimal" minOccurs="0" maxOccurs="1" default="0.0"/>
|
||||||
|
|
@ -201,6 +181,7 @@
|
||||||
<xs:element name="delivery" minOccurs="1" maxOccurs="1">
|
<xs:element name="delivery" minOccurs="1" maxOccurs="1">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
|
<xs:element name="location" type="locationType" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="locationId" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="locationId" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="duration" type="xs:decimal" minOccurs="0" maxOccurs="1" default="0.0"/>
|
<xs:element name="duration" type="xs:decimal" minOccurs="0" maxOccurs="1" default="0.0"/>
|
||||||
|
|
@ -350,6 +331,14 @@
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:complexType name="locationType">
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="id" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||||
|
<xs:element name="coord" type="coordType" minOccurs="0" maxOccurs="1"/>
|
||||||
|
<xs:element name="index" type="xs:int" minOccurs="0" maxOccurs="1"/>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
<xs:complexType name="coordType">
|
<xs:complexType name="coordType">
|
||||||
<xs:attribute name="x" type="xs:double" use="required" />
|
<xs:attribute name="x" type="xs:double" use="required" />
|
||||||
<xs:attribute name="y" type="xs:double" use="required" />
|
<xs:attribute name="y" type="xs:double" use="required" />
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,35 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2014 Stefan Schroeder.
|
* Copyright (C) 2014 Stefan Schroeder
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
* version 3.0 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
*
|
* Lesser General Public License for more details.
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Stefan Schroeder - initial API and implementation
|
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.algorithm.recreate;
|
package jsprit.core.algorithm.recreate;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||||
import jsprit.core.problem.solution.route.activity.End;
|
import jsprit.core.problem.solution.route.activity.End;
|
||||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||||
import jsprit.core.problem.vehicle.Vehicle;
|
import jsprit.core.problem.vehicle.Vehicle;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class TestAuxilliaryCostCalculator {
|
public class TestAuxilliaryCostCalculator {
|
||||||
|
|
||||||
private VehicleRoutingTransportCosts routingCosts;
|
private VehicleRoutingTransportCosts routingCosts;
|
||||||
|
|
@ -76,7 +73,7 @@ public class TestAuxilliaryCostCalculator {
|
||||||
public void whenRouteIsClosed_itCalculatesCostUpToEnd_v2(){
|
public void whenRouteIsClosed_itCalculatesCostUpToEnd_v2(){
|
||||||
TourActivity prevAct = mock(TourActivity.class);
|
TourActivity prevAct = mock(TourActivity.class);
|
||||||
when(prevAct.getLocationId()).thenReturn("i");
|
when(prevAct.getLocationId()).thenReturn("i");
|
||||||
End nextAct = End.newInstance("j", 0.0, 0.0);
|
End nextAct = new End("j", 0.0, 0.0);
|
||||||
TourActivity newAct = mock(TourActivity.class);
|
TourActivity newAct = mock(TourActivity.class);
|
||||||
when(newAct.getLocationId()).thenReturn("k");
|
when(newAct.getLocationId()).thenReturn("k");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,8 @@ public class VrpXMLReaderTest {
|
||||||
assertEquals("depotLoc2",v1.getStartLocationId());
|
assertEquals("depotLoc2",v1.getStartLocationId());
|
||||||
assertNotNull(v1.getType());
|
assertNotNull(v1.getType());
|
||||||
assertEquals("vehType", v1.getType().getTypeId());
|
assertEquals("vehType", v1.getType().getTypeId());
|
||||||
|
assertNotNull(v1.getStartLocation());
|
||||||
|
assertEquals(1,v1.getStartLocation().getIndex());
|
||||||
assertEquals(1000.0,v1.getLatestArrival(),0.01);
|
assertEquals(1000.0,v1.getLatestArrival(),0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,6 +322,8 @@ public class VrpXMLReaderTest {
|
||||||
VehicleRoutingProblem vrp = builder.build();
|
VehicleRoutingProblem vrp = builder.build();
|
||||||
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
Vehicle v3 = getVehicle("v3",vrp.getVehicles());
|
||||||
assertEquals("startLoc",v3.getStartLocationId());
|
assertEquals("startLoc",v3.getStartLocationId());
|
||||||
|
assertNotNull(v3.getEndLocation());
|
||||||
|
assertEquals(4,v3.getEndLocation().getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package jsprit.core.problem.io;
|
package jsprit.core.problem.io;
|
||||||
|
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem.Builder;
|
import jsprit.core.problem.VehicleRoutingProblem.Builder;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||||
|
|
@ -138,7 +139,10 @@ public class VrpXMLWriterTest {
|
||||||
@Test
|
@Test
|
||||||
public void shouldWriteNameOfShipment(){
|
public void shouldWriteNameOfShipment(){
|
||||||
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
Shipment s1 = Shipment.Builder.newInstance("1").setName("cleaning").setPickupLocationId("pick").setDeliveryLocationId("del").build();
|
Location pickLocation = Location.Builder.newInstance().setId("pick").setIndex(1).build();
|
||||||
|
Shipment s1 = Shipment.Builder.newInstance("1").setName("cleaning")
|
||||||
|
.setPickupLocation(pickLocation)
|
||||||
|
.setDeliveryLocationId("del").build();
|
||||||
|
|
||||||
VehicleRoutingProblem vrp = builder.addJob(s1).build();
|
VehicleRoutingProblem vrp = builder.addJob(s1).build();
|
||||||
new VrpXMLWriter(vrp, null).write(infileName);
|
new VrpXMLWriter(vrp, null).write(infileName);
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import jsprit.core.problem.Capacity;
|
||||||
import jsprit.core.problem.driver.Driver;
|
import jsprit.core.problem.driver.Driver;
|
||||||
import jsprit.core.problem.job.Shipment;
|
import jsprit.core.problem.job.Shipment;
|
||||||
import jsprit.core.problem.vehicle.Vehicle;
|
import jsprit.core.problem.vehicle.Vehicle;
|
||||||
|
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
@ -93,10 +94,9 @@ public class VehicleRouteBuilderTest {
|
||||||
Capacity capacity = Capacity.Builder.newInstance().build();
|
Capacity capacity = Capacity.Builder.newInstance().build();
|
||||||
when(s.getSize()).thenReturn(capacity);
|
when(s.getSize()).thenReturn(capacity);
|
||||||
when(s2.getSize()).thenReturn(capacity);
|
when(s2.getSize()).thenReturn(capacity);
|
||||||
Vehicle vehicle = mock(Vehicle.class);
|
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setEndLocationId("vehLoc")
|
||||||
when(vehicle.isReturnToDepot()).thenReturn(true);
|
.build();
|
||||||
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);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
<location>
|
<location>
|
||||||
<id>depotLoc2</id>
|
<id>depotLoc2</id>
|
||||||
<coord x="100.0" y="100.0"/>
|
<coord x="100.0" y="100.0"/>
|
||||||
|
<index>1</index>
|
||||||
</location>
|
</location>
|
||||||
<typeId>vehType</typeId>
|
<typeId>vehType</typeId>
|
||||||
<timeSchedule>
|
<timeSchedule>
|
||||||
|
|
@ -44,6 +45,7 @@
|
||||||
<location>
|
<location>
|
||||||
<id>depotLoc</id>
|
<id>depotLoc</id>
|
||||||
<coord x="10.0" y="100.0"/>
|
<coord x="10.0" y="100.0"/>
|
||||||
|
<index>2</index>
|
||||||
</location>
|
</location>
|
||||||
<returnToDepot>false</returnToDepot>
|
<returnToDepot>false</returnToDepot>
|
||||||
<typeId>vehType2</typeId>
|
<typeId>vehType2</typeId>
|
||||||
|
|
@ -57,10 +59,12 @@
|
||||||
<startLocation>
|
<startLocation>
|
||||||
<id>startLoc</id>
|
<id>startLoc</id>
|
||||||
<coord x="10.0" y="100.0"/>
|
<coord x="10.0" y="100.0"/>
|
||||||
|
<index>3</index>
|
||||||
</startLocation>
|
</startLocation>
|
||||||
<endLocation>
|
<endLocation>
|
||||||
<id>endLoc</id>
|
<id>endLoc</id>
|
||||||
<coord x="1000.0" y="2000.0"/>
|
<coord x="1000.0" y="2000.0"/>
|
||||||
|
<index>4</index>
|
||||||
</endLocation>
|
</endLocation>
|
||||||
<typeId>vehType2</typeId>
|
<typeId>vehType2</typeId>
|
||||||
<timeSchedule>
|
<timeSchedule>
|
||||||
|
|
|
||||||
|
|
@ -155,8 +155,10 @@
|
||||||
</vehicleTypes>
|
</vehicleTypes>
|
||||||
<services>
|
<services>
|
||||||
<service id="2" type="service">
|
<service id="2" type="service">
|
||||||
<locationId>i(3,9)</locationId>
|
<location>
|
||||||
<coord x="10.0" y="10.0"/>
|
<id>i(3,9)</id>
|
||||||
|
<coord x="10.0" y="10.0"/>
|
||||||
|
</location>
|
||||||
<capacity-dimensions>
|
<capacity-dimensions>
|
||||||
<dimension index="0">1</dimension>
|
<dimension index="0">1</dimension>
|
||||||
</capacity-dimensions>
|
</capacity-dimensions>
|
||||||
|
|
@ -169,8 +171,10 @@
|
||||||
</timeWindows>
|
</timeWindows>
|
||||||
</service>
|
</service>
|
||||||
<service id="1" type="service">
|
<service id="1" type="service">
|
||||||
<locationId>j(1,5)</locationId>
|
<location>
|
||||||
<coord x="10.0" y="10.0"/>
|
<id>j(1,5)</id>
|
||||||
|
<coord x="10.0" y="10.0"/>
|
||||||
|
</location>
|
||||||
<capacity-dimensions>
|
<capacity-dimensions>
|
||||||
<dimension index="0">1</dimension>
|
<dimension index="0">1</dimension>
|
||||||
</capacity-dimensions>
|
</capacity-dimensions>
|
||||||
|
|
@ -186,8 +190,10 @@
|
||||||
<shipments>
|
<shipments>
|
||||||
<shipment id="3">
|
<shipment id="3">
|
||||||
<pickup>
|
<pickup>
|
||||||
<locationId>i(3,9)</locationId>
|
<location>
|
||||||
<coord x="10.0" y="10.0"/>
|
<id>i(3,9)</id>
|
||||||
|
<coord x="10.0" y="10.0"/>
|
||||||
|
</location>
|
||||||
<duration>10.0</duration>
|
<duration>10.0</duration>
|
||||||
<timeWindows>
|
<timeWindows>
|
||||||
<timeWindow>
|
<timeWindow>
|
||||||
|
|
@ -197,8 +203,10 @@
|
||||||
</timeWindows>
|
</timeWindows>
|
||||||
</pickup>
|
</pickup>
|
||||||
<delivery>
|
<delivery>
|
||||||
<locationId>i(9,9)</locationId>
|
<location>
|
||||||
<coord x="10.0" y="0.0"/>
|
<id>i(9,9)</id>
|
||||||
|
<coord x="10.0" y="0.0"/>
|
||||||
|
</location>
|
||||||
<duration>100.0</duration>
|
<duration>100.0</duration>
|
||||||
<timeWindows>
|
<timeWindows>
|
||||||
<timeWindow>
|
<timeWindow>
|
||||||
|
|
@ -213,8 +221,10 @@
|
||||||
</shipment>
|
</shipment>
|
||||||
<shipment id="4">
|
<shipment id="4">
|
||||||
<pickup>
|
<pickup>
|
||||||
<locationId>[x=10.0][y=10.0]</locationId>
|
<location>
|
||||||
<coord x="10.0" y="10.0"/>
|
<id>[x=10.0][y=10.0]</id>
|
||||||
|
<coord x="10.0" y="10.0"/>
|
||||||
|
</location>
|
||||||
<duration>0.0</duration>
|
<duration>0.0</duration>
|
||||||
<timeWindows>
|
<timeWindows>
|
||||||
<timeWindow>
|
<timeWindow>
|
||||||
|
|
@ -224,8 +234,10 @@
|
||||||
</timeWindows>
|
</timeWindows>
|
||||||
</pickup>
|
</pickup>
|
||||||
<delivery>
|
<delivery>
|
||||||
<locationId>[x=10.0][y=0.0]</locationId>
|
<location>
|
||||||
<coord x="10.0" y="0.0"/>
|
<id>[x=10.0][y=0.0]</id>
|
||||||
|
<coord x="10.0" y="0.0"/>
|
||||||
|
</location>
|
||||||
<duration>100.0</duration>
|
<duration>100.0</duration>
|
||||||
<timeWindows>
|
<timeWindows>
|
||||||
<timeWindow>
|
<timeWindow>
|
||||||
|
|
|
||||||
|
|
@ -21,83 +21,37 @@
|
||||||
<problemType>
|
<problemType>
|
||||||
<fleetSize>INFINITE</fleetSize>
|
<fleetSize>INFINITE</fleetSize>
|
||||||
</problemType>
|
</problemType>
|
||||||
<vehicles>
|
<shipments>
|
||||||
<vehicle>
|
<shipment id="1">
|
||||||
<id>v1</id>
|
<pickup>
|
||||||
<typeId>vehType</typeId>
|
<location>
|
||||||
<startLocation>
|
<id>pick</id>
|
||||||
<id>loc</id>
|
<index>1</index>
|
||||||
</startLocation>
|
</location>
|
||||||
<endLocation>
|
<duration>0.0</duration>
|
||||||
<id>loc</id>
|
<timeWindows>
|
||||||
</endLocation>
|
<timeWindow>
|
||||||
<timeSchedule>
|
<start>0.0</start>
|
||||||
<start>0.0</start>
|
<end>1.7976931348623157E308</end>
|
||||||
<end>1.7976931348623157E308</end>
|
</timeWindow>
|
||||||
</timeSchedule>
|
</timeWindows>
|
||||||
<returnToDepot>true</returnToDepot>
|
</pickup>
|
||||||
</vehicle>
|
<delivery>
|
||||||
</vehicles>
|
<location>
|
||||||
<vehicleTypes>
|
<id>del</id>
|
||||||
<type>
|
</location>
|
||||||
<id>vehType</id>
|
<duration>0.0</duration>
|
||||||
|
<timeWindows>
|
||||||
|
<timeWindow>
|
||||||
|
<start>0.0</start>
|
||||||
|
<end>1.7976931348623157E308</end>
|
||||||
|
</timeWindow>
|
||||||
|
</timeWindows>
|
||||||
|
</delivery>
|
||||||
<capacity-dimensions>
|
<capacity-dimensions>
|
||||||
<dimension index="0">20</dimension>
|
<dimension index="0">0</dimension>
|
||||||
</capacity-dimensions>
|
</capacity-dimensions>
|
||||||
<costs>
|
<name>cleaning</name>
|
||||||
<fixed>0.0</fixed>
|
</shipment>
|
||||||
<distance>1.0</distance>
|
</shipments>
|
||||||
<time>0.0</time>
|
|
||||||
</costs>
|
|
||||||
</type>
|
|
||||||
</vehicleTypes>
|
|
||||||
<services>
|
|
||||||
<service id="2" type="service">
|
|
||||||
<locationId>loc2</locationId>
|
|
||||||
<capacity-dimensions>
|
|
||||||
<dimension index="0">1</dimension>
|
|
||||||
</capacity-dimensions>
|
|
||||||
<duration>4.0</duration>
|
|
||||||
<timeWindows>
|
|
||||||
<timeWindow>
|
|
||||||
<start>0.0</start>
|
|
||||||
<end>1.7976931348623157E308</end>
|
|
||||||
</timeWindow>
|
|
||||||
</timeWindows>
|
|
||||||
</service>
|
|
||||||
<service id="1" type="service">
|
|
||||||
<locationId>loc</locationId>
|
|
||||||
<capacity-dimensions>
|
|
||||||
<dimension index="0">1</dimension>
|
|
||||||
</capacity-dimensions>
|
|
||||||
<duration>2.0</duration>
|
|
||||||
<timeWindows>
|
|
||||||
<timeWindow>
|
|
||||||
<start>0.0</start>
|
|
||||||
<end>1.7976931348623157E308</end>
|
|
||||||
</timeWindow>
|
|
||||||
</timeWindows>
|
|
||||||
</service>
|
|
||||||
</services>
|
|
||||||
<solutions>
|
|
||||||
<solution>
|
|
||||||
<cost>10.0</cost>
|
|
||||||
<routes>
|
|
||||||
<route>
|
|
||||||
<driverId>noDriver</driverId>
|
|
||||||
<vehicleId>v1</vehicleId>
|
|
||||||
<start>0.0</start>
|
|
||||||
<act type="service">
|
|
||||||
<serviceId>1</serviceId>
|
|
||||||
<arrTime>0.0</arrTime>
|
|
||||||
<endTime>0.0</endTime>
|
|
||||||
</act>
|
|
||||||
<end>0.0</end>
|
|
||||||
</route>
|
|
||||||
</routes>
|
|
||||||
<unassignedJobs>
|
|
||||||
<job id="2"/>
|
|
||||||
</unassignedJobs>
|
|
||||||
</solution>
|
|
||||||
</solutions>
|
|
||||||
</problem>
|
</problem>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue