diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java
index 387d7db8..e98b043b 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Delivery.java
@@ -17,8 +17,6 @@
package jsprit.core.problem.job;
-import jsprit.core.problem.Location;
-
/**
* Delivery extends Service and is intended to model a Service where smth is UNLOADED (i.e. delivered) from a transport unit.
*
@@ -50,9 +48,7 @@ public class Delivery extends Service{
* @throws IllegalStateException if neither locationId nor coord is set
*/
public Delivery build(){
- if(location == null) {
- location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
- }
+ if(location == null) throw new IllegalStateException("location is missing");
this.setType("delivery");
super.capacity = super.capacityBuilder.build();
super.skills = super.skillBuilder.build();
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java
index 9860d9ff..862a1f7d 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Pickup.java
@@ -17,8 +17,6 @@
package jsprit.core.problem.job;
-import jsprit.core.problem.Location;
-
/**
* Pickup extends Service and is intended to model a Service where smth is LOADED (i.e. picked up) to a transport unit.
*
@@ -52,9 +50,7 @@ public class Pickup extends Service {
* @throws IllegalStateException if neither locationId nor coordinate has been set
*/
public Pickup build(){
- if(location == null) {
- location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
- }
+ if(location == null) throw new IllegalStateException("location is missing");
this.setType("pickup");
super.capacity = super.capacityBuilder.build();
super.skills = super.skillBuilder.build();
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Service.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Service.java
index e27bfb8f..30b1ba7b 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/job/Service.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Service.java
@@ -99,19 +99,6 @@ public class Service extends AbstractJob {
this.type = name;
return this;
}
-
- /**
- * Sets the location-id of this service.
- *
- * @param locationId the location id of the service
- * @return builder
- * @deprecated use .setLocation(..) instead
- */
- @Deprecated
- public Builder setLocationId(String locationId){
- this.locationId = locationId;
- return this;
- }
/**
* Sets location
@@ -123,20 +110,7 @@ public class Service extends AbstractJob {
this.location = location;
return this;
}
-
- /**
- * Sets the coordinate of this service.
- *
- * @param coord the coordinate of service
- * @return builder
- * @deprecated use .setLocation(..) instead and add coordinate ot Location obj
- */
- @Deprecated
- public Builder setCoord(Coordinate coord){
- this.coord = coord;
- return this;
- }
-
+
/**
* Sets the serviceTime of this service.
*
@@ -189,9 +163,7 @@ public class Service extends AbstractJob {
* @throws IllegalStateException if neither locationId nor coordinate is set.
*/
public Service build(){
- if(location == null) {
- location = Location.Builder.newInstance().setCoordinate(coord).setId(locationId).build();
- }
+ if(location == null) throw new IllegalStateException("location is missing");
this.setType("service");
capacity = capacityBuilder.build();
skills = skillBuilder.build();
@@ -243,28 +215,6 @@ public class Service extends AbstractJob {
}
/**
- * Returns the location-id of this service.
- *
- * @return String that indicates the location
- * @deprecated use .getLocation().getId() instead
- */
- @Deprecated
- public String getLocationId() {
- return location.getId();
- }
-
-// public AbstractLocation getLocation()
-
- /**
- * Returns the coordinate of this service.
- *
- * @return {@link Coordinate}
- * @deprecated use .getLocation().getCoordinate() instead
- */
- @Deprecated
- public Coordinate getCoord(){ return location.getCoordinate(); }
-
- /**
* Returns location.
*
* @return location
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/job/Shipment.java b/jsprit-core/src/main/java/jsprit/core/problem/job/Shipment.java
index e7a4f1d8..6a826ffc 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/job/Shipment.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/job/Shipment.java
@@ -21,7 +21,7 @@ import jsprit.core.problem.Capacity;
import jsprit.core.problem.Location;
import jsprit.core.problem.Skills;
import jsprit.core.problem.solution.route.activity.TimeWindow;
-import jsprit.core.util.Coordinate;
+
/**
* Shipment is an implementation of Job and consists of a pickup and a delivery of something.
@@ -53,16 +53,8 @@ public class Shipment extends AbstractJob{
public static class Builder {
private String id;
-
- private String pickupLocation;
-
- private Coordinate pickupCoord;
-
+
private double pickupServiceTime = 0.0;
-
- private String deliveryLocation;
-
- private Coordinate deliveryCoord;
private double deliveryServiceTime = 0.0;
@@ -99,22 +91,7 @@ public class Shipment extends AbstractJob{
this.id = id;
}
- /**
- * Sets pickup-location id.
- *
- * @param pickupLocationId the location id of shipment's pickup
- * @return builder
- * @throws IllegalArgumentException if location is null
- * @deprecated use .setLocation(..) instead
- */
- @Deprecated
- public Builder setPickupLocationId(String pickupLocationId){
- if(pickupLocationId == null) throw new IllegalArgumentException("location must not be null");
- this.pickupLocation = pickupLocationId;
- return this;
- }
-
- /**
+ /**
* Sets pickup location.
*
* @param pickupLocation pickup location
@@ -125,36 +102,6 @@ public class Shipment extends AbstractJob{
return this;
}
- /**
- * Sets pickup-location id.
- *
- * @param pickupLocationId the location id of shipment's pickup
- * @return builder
- * @throws IllegalArgumentException if location is null
- * @deprecated use .setPickupLocationId(locationId) instead
- */
- @Deprecated
- public Builder setPickupLocation(String pickupLocationId){
- if(pickupLocationId == null) throw new IllegalArgumentException("location must not be null");
- this.pickupLocation = pickupLocationId;
- return this;
- }
-
- /**
- * Sets pickup-coordinate.
- *
- * @param pickupCoord the coordinate of shipment's pickup location
- * @return builder
- * @throws IllegalArgumentException if pickupCoord is null
- * @deprecated use .setLocation(..) instead and add coordinate to location obj.
- */
- @Deprecated
- public Builder setPickupCoord(Coordinate pickupCoord){
- if(pickupCoord == null) throw new IllegalArgumentException("coord must not be null");
- this.pickupCoord = pickupCoord;
- return this;
- }
-
/**
* Sets pickupServiceTime.
*
@@ -186,21 +133,6 @@ public class Shipment extends AbstractJob{
return this;
}
- /**
- * Sets the delivery-location.
- *
- * @param deliveryLocationId the delivery location id
- * @return builder
- * @throws IllegalArgumentException if location is null
- * @deprecated use .setDeliveryLocation instead
- */
- @Deprecated
- public Builder setDeliveryLocationId(String deliveryLocationId){
- if(deliveryLocationId == null) throw new IllegalArgumentException("delivery location must not be null");
- this.deliveryLocation = deliveryLocationId;
- return this;
- }
-
/**
* Sets delivery location.
*
@@ -212,37 +144,6 @@ public class Shipment extends AbstractJob{
return this;
}
- /**
- * Sets the delivery-location.
- *
- * @param deliveryLocation the delivery location id
- * @return builder
- * @throws IllegalArgumentException if location is null
- * @deprecated use .setDeliveryLocationId(deliveryLocationId)
- *
- */
- @Deprecated
- public Builder setDeliveryLocation(String deliveryLocation){
- if(deliveryLocation == null) throw new IllegalArgumentException("delivery location must not be null");
- this.deliveryLocation = deliveryLocation;
- return this;
- }
-
- /**
- * Sets delivery-coord.
- *
- * @param deliveryCoord the coordinate of shipment's delivery location
- * @return builder
- * @throws IllegalArgumentException if coord is null;
- * @deprecated use .setDeliveryLocation(..) instead and add coordinate to location obj
- */
- @Deprecated
- public Builder setDeliveryCoord(Coordinate deliveryCoord){
- if(deliveryCoord == null) throw new IllegalArgumentException("coord must not be null");
- this.deliveryCoord = deliveryCoord;
- return this;
- }
-
/**
* Sets the delivery service-time.
*
@@ -297,12 +198,8 @@ public class Shipment extends AbstractJob{
* is set
*/
public Shipment build(){
- if(pickupLocation_ == null) {
- this.pickupLocation_ = Location.Builder.newInstance().setCoordinate(pickupCoord).setId(pickupLocation).build();
- }
- if(deliveryLocation_ == null) {
- this.deliveryLocation_ = Location.Builder.newInstance().setCoordinate(deliveryCoord).setId(deliveryLocation).build();
- }
+ if(pickupLocation_ == null) throw new IllegalStateException("pickup location is missing");
+ if(deliveryLocation_ == null) throw new IllegalStateException("delivery location is missing");
capacity = capacityBuilder.build();
skills = skillBuilder.build();
return new Shipment(this);
@@ -358,28 +255,6 @@ public class Shipment extends AbstractJob{
return id;
}
- /**
- * Returns the pickup-location.
- *
- * @return pickup-location
- * @deprecated use .getLocation().getId() instead
- */
- @Deprecated
- public String getPickupLocationId() {
- return pickupLocation_.getId();
- }
-
- /**
- * Returns the pickup-coordinate.
- *
- * @return coordinate of the pickup
- * @deprecated use .getLocation(..).getCoordinate() instead
- */
- @Deprecated
- public Coordinate getPickupCoord() {
- return pickupLocation_.getCoordinate();
- }
-
public Location getPickupLocation(){ return pickupLocation_; }
/**
@@ -393,28 +268,6 @@ public class Shipment extends AbstractJob{
return pickupServiceTime;
}
- /**
- * Returns delivery-location.
- *
- * @return delivery-location
- * @deprecated use .getLocation().getId() instead
- */
- @Deprecated
- public String getDeliveryLocationId() {
- return deliveryLocation_.getId();
- }
-
- /**
- * Returns coordinate of the delivery.
- *
- * @return coordinate of delivery
- * @deprecated use .getLocation().getCoordinate() instead
- */
- @Deprecated
- public Coordinate getDeliveryCoord() {
- return deliveryLocation_.getCoordinate();
- }
-
public Location getDeliveryLocation() { return deliveryLocation_; }
/**
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/Vehicle.java b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/Vehicle.java
index ac7da47c..b29391d1 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/Vehicle.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/Vehicle.java
@@ -20,7 +20,6 @@ import jsprit.core.problem.HasId;
import jsprit.core.problem.HasIndex;
import jsprit.core.problem.Location;
import jsprit.core.problem.Skills;
-import jsprit.core.util.Coordinate;
/**
* Basic interface for vehicle-data.
@@ -65,37 +64,12 @@ public interface Vehicle extends HasId, HasIndex {
* @return true if isReturnToDepot
*/
public abstract boolean isReturnToDepot();
-
- /**
- * Returns the start-locationId of this vehicle.
- */
- @Deprecated
- public abstract String getStartLocationId();
-
- /**
- * Returns the start-locationCoord of this vehicle.
- */
- @Deprecated
- public abstract Coordinate getStartLocationCoordinate();
public abstract Location getStartLocation();
- /**
- * Returns the end-locationId of this vehicle.
- *
- */
- @Deprecated
- public abstract String getEndLocationId();
-
- public abstract Location getEndLocation();
+ public abstract Location getEndLocation();
- /**
- * Returns the end-locationCoord of this vehicle.
- */
- @Deprecated
- public abstract Coordinate getEndLocationCoordinate();
-
- public abstract VehicleTypeKey getVehicleTypeIdentifier();
+ public abstract VehicleTypeKey getVehicleTypeIdentifier();
public abstract Skills getSkills();
}
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java
index 66bb14d9..bfcf00a1 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java
@@ -19,7 +19,6 @@ package jsprit.core.problem.vehicle;
import jsprit.core.problem.AbstractVehicle;
import jsprit.core.problem.Location;
import jsprit.core.problem.Skills;
-import jsprit.core.util.Coordinate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -78,36 +77,16 @@ public class VehicleImpl extends AbstractVehicle{
return false;
}
- @Override
- public String getStartLocationId() {
- return null;
- }
-
- @Override
- public Coordinate getStartLocationCoordinate() {
- return null;
- }
-
@Override
public Location getStartLocation() {
return null;
}
- @Override
- public String getEndLocationId() {
- return null;
- }
-
@Override
public Location getEndLocation() {
return null;
}
- @Override
- public Coordinate getEndLocationCoordinate() {
- return null;
- }
-
@Override
public Skills getSkills() {
return null;
@@ -129,23 +108,11 @@ public class VehicleImpl extends AbstractVehicle{
static final Logger log = LogManager.getLogger(Builder.class.getName());
private String id;
-
- private String locationId;
-
- private Coordinate locationCoord;
private double earliestStart = 0.0;
private double latestArrival = Double.MAX_VALUE;
-
- private String startLocationId;
- private Coordinate startLocationCoord;
-
- private String endLocationId;
-
- private Coordinate endLocationCoord;
-
private boolean returnToDepot = true;
private VehicleType type = VehicleTypeImpl.Builder.newInstance("default").build();
@@ -192,36 +159,6 @@ public class VehicleImpl extends AbstractVehicle{
this.returnToDepot = returnToDepot;
return this;
}
-
- /**
- * Sets the start-location of this vehicle.
- *
- * @param startLocationId the location id of vehicle's start
- * @return this builder
- * @throws IllegalArgumentException if startLocationId is null
- * @deprecated use .setStartLocation(..) instead
- */
- @Deprecated
- public Builder setStartLocationId(String startLocationId){
- if(startLocationId == null) throw new IllegalArgumentException("startLocationId cannot be null");
- this.startLocationId = startLocationId;
- this.locationId = startLocationId;
- return this;
- }
-
- /**
- * Sets the start-coordinate of this vehicle.
- *
- * @param coord the coordinate of vehicle's start location
- * @return this builder
- * @deprecated use .setStartLocation(..) instead
- */
- @Deprecated
- public Builder setStartLocationCoordinate(Coordinate coord){
- this.startLocationCoord = coord;
- this.locationCoord = coord;
- return this;
- }
/**
* Sets start location.
@@ -232,32 +169,6 @@ public class VehicleImpl extends AbstractVehicle{
this.startLocation = startLocation;
return this;
}
-
- /**
- * Sets the end-locationId of this vehicle.
- *
- * @param endLocationId the location id of vehicle's end
- * @return this builder
- * @deprecated use .setEndLocation(..) instead
- */
- @Deprecated
- public Builder setEndLocationId(String endLocationId){
- this.endLocationId = endLocationId;
- return this;
- }
-
- /**
- * Sets the end-coordinate of this vehicle.
- *
- * @param coord the coordinate of vehicle's end location
- * @return this builder
- * @deprecated use .setEndLocation(..) instead
- */
- @Deprecated
- public Builder setEndLocationCoordinate(Coordinate coord){
- this.endLocationCoord = coord;
- return this;
- }
public Builder setEndLocation(Location endLocation){
this.endLocation = endLocation;
@@ -312,30 +223,12 @@ public class VehicleImpl extends AbstractVehicle{
if( !startLocation.getId().equals(endLocation.getId()) && !returnToDepot) throw new IllegalStateException("this must not be. you specified both endLocationId and open-routes. this is contradictory.
" +
"if you set endLocation, returnToDepot must be true. if returnToDepot is false, endLocationCoord must not be specified.");
}
- if (startLocation != null && endLocation == null && endLocationId == null && endLocationCoord == null) {
+ if (startLocation != null && endLocation == null) {
endLocation = startLocation;
}
if(startLocation == null && endLocation == null) {
- if ((locationId == null && locationCoord == null) && (startLocationId == null && startLocationCoord == null)) {
- throw new IllegalStateException("vehicle requires startLocation. but neither locationId nor locationCoord nor startLocationId nor startLocationCoord has been set");
- }
- if(locationId == null && locationCoord == null) throw new IllegalStateException("locationId and locationCoord is missing.");
- if(locationCoord == null) log.warn("locationCoord for vehicle " + id + " is missing.");
- if (locationId == null && locationCoord != null) {
- locationId = locationCoord.toString();
- startLocationId = locationCoord.toString();
- }
- startLocation = Location.Builder.newInstance().setCoordinate(locationCoord).setId(locationId).build();
-
- if (endLocationId == null && endLocationCoord != null) endLocationId = endLocationCoord.toString();
- if (endLocationId == null && endLocationCoord == null) {
- endLocationId = startLocationId;
- endLocationCoord = startLocationCoord;
- }
- endLocation = Location.Builder.newInstance().setCoordinate(endLocationCoord).setId(endLocationId).build();
- if( !startLocationId.equals(endLocationId) && !returnToDepot) throw new IllegalStateException("this must not be. you specified both endLocationId and open-routes. this is contradictory.
" +
- "if you set endLocation, returnToDepot must be true. if returnToDepot is false, endLocationCoord must not be specified.");
- }
+ throw new IllegalStateException("vehicle requires startLocation. but neither locationId nor locationCoord nor startLocationId nor startLocationCoord has been set");
+ }
skills = skillBuilder.build();
return new VehicleImpl(this);
}
@@ -433,36 +326,16 @@ public class VehicleImpl extends AbstractVehicle{
return returnToDepot;
}
- @Override
- public String getStartLocationId() {
- return this.startLocation.getId();
- }
-
- @Override
- public Coordinate getStartLocationCoordinate() {
- return this.startLocation.getCoordinate();
- }
-
@Override
public Location getStartLocation() {
return startLocation;
}
- @Override
- public String getEndLocationId() {
- return this.endLocation.getId();
- }
-
@Override
public Location getEndLocation() {
return endLocation;
}
- @Override
- public Coordinate getEndLocationCoordinate() {
- return this.endLocation.getCoordinate();
- }
-
@Override
public Skills getSkills() {
return skills;
diff --git a/jsprit-core/src/main/java/jsprit/core/util/Neighborhood.java b/jsprit-core/src/main/java/jsprit/core/util/Neighborhood.java
deleted file mode 100644
index 1ed8fb7f..00000000
--- a/jsprit-core/src/main/java/jsprit/core/util/Neighborhood.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * 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,
- * 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.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see .
- ******************************************************************************/
-package jsprit.core.util;
-
-@Deprecated
-public interface Neighborhood {
-
- public boolean areNeighbors(String location1, String location2);
-
-}
diff --git a/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java b/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java
deleted file mode 100644
index a2a094bf..00000000
--- a/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2014 Stefan Schroeder
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * 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,
- * 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.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see .
- ******************************************************************************/
-package jsprit.core.util;
-
-import jsprit.core.problem.job.Service;
-import jsprit.core.problem.vehicle.Vehicle;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.util.*;
-
-@Deprecated
-public class NeighborhoodImpl implements Neighborhood{
-
- private static Logger log = LogManager.getLogger(NeighborhoodImpl.class);
-
- private Set neighborsToAll;
-
- private double threshold = Double.MAX_VALUE;
-
- private boolean initialised = false;
-
- public void setThreshold(double threshold) {
- this.threshold = threshold;
- log.info("set threshold to " + threshold);
- }
-
- private Map> neighbors;
-
- private Collection vehicles;
-
- private Collection services;
-
- public NeighborhoodImpl(Collection vehicles, Collection services) {
- neighborsToAll = new HashSet();
- this.vehicles = vehicles;
- this.services = services;
- neighbors = new HashMap>();
- }
-
- private void makeNeighbors() {
- for(Service i : services){
- Set neigh = new HashSet();
- for(Vehicle v : vehicles){
- double dist2depot = EuclideanDistanceCalculator.calculateDistance(v.getStartLocationCoordinate(), i.getLocation().getCoordinate());
- if(dist2depot <= threshold){
- neighborsToAll.add(((Service)i).getLocation().getId());
- }
- }
- for(Service j : services){
- double crowFlyDistance = EuclideanDistanceCalculator.calculateDistance(i.getLocation().getCoordinate(), j.getLocation().getCoordinate());
- if(crowFlyDistance <= threshold) {
- neigh.add(((Service)j).getLocation().getId());
- }
- }
- neighbors.put(((Service)i).getLocation().getId(), neigh);
- }
-
- }
-
- private void makeNeighborsToAll(Collection vehicles) {
- for(Vehicle v : vehicles){
- neighborsToAll.add(v.getStartLocationId());
- }
- }
-
- public void initialise(){
- log.info("initialise neighboorhood [threshold="+ this.threshold + "]");
- makeNeighborsToAll(vehicles);
- makeNeighbors();
- initialised = true;
- }
-
- public boolean areNeighbors(String location1, String location2){
- if(!initialised) {
-// initialise();
- return true;
- }
- if(neighborsToAll.contains(location1) || neighborsToAll.contains(location2)){
- return true;
- }
- if(neighbors.get(location1).contains(location2)){
- return true;
- }
- return false;
- }
-
- @Override
- public String toString() {
- return "[name=euclideanNeighborhood][threshold="+threshold+"]";
- }
-
-}
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithMatrix_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithMatrix_IT.java
new file mode 100644
index 00000000..ccf33482
--- /dev/null
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/CVRPwithMatrix_IT.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (C) 2014 Stefan Schroeder
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * 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,
+ * 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see .
+ ******************************************************************************/
+package jsprit.core.algorithm;
+
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
+import jsprit.core.analysis.SolutionAnalyser;
+import jsprit.core.problem.Location;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.cost.TransportDistance;
+import jsprit.core.problem.io.VrpXMLReader;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.problem.vehicle.VehicleImpl;
+import jsprit.core.util.EuclideanDistanceCalculator;
+import jsprit.core.util.FastVehicleRoutingTransportCostsMatrix;
+import jsprit.core.util.Solutions;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class CVRPwithMatrix_IT {
+
+ private int index = 0;
+
+
+ @Test
+ public void whenReturnToDepot_itShouldWorkWithMatrix(){
+ VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
+ new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
+ VehicleRoutingProblem vrp_ = vrpBuilder.build();
+ VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_, true);
+ VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
+ Collection solutions = vra.searchSolutions();
+ assertEquals(530.0, Solutions.bestOf(solutions).getCost(),50.0);
+ assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
+ }
+
+ @Test
+ public void whenNotReturnToDepot_itShouldWorkWithMatrix(){
+ VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
+ new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
+ VehicleRoutingProblem vrp_ = vrpBuilder.build();
+ VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_,false);
+ VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
+ try {
+ Collection solutions = vra.searchSolutions();
+ assertTrue(true);
+ }
+ catch (Exception e){
+ assertFalse(true);
+ }
+ }
+
+ @Test
+ public void whenCalcTimeWithSolutionAnalyser_itShouldWork(){
+ VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
+ new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
+ VehicleRoutingProblem vrp_ = vrpBuilder.build();
+ final VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_,false);
+ VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
+ Collection solutions = vra.searchSolutions();
+ SolutionAnalyser sa = new SolutionAnalyser(vrp, Solutions.bestOf(solutions), new TransportDistance() {
+ @Override
+ public double getDistance(Location from, Location to) {
+ return vrp.getTransportCosts().getTransportCost(from,to,0.,null,null);
+ }
+ });
+ System.out.println(sa.getDistance());
+ System.out.println(sa.getTransportTime());
+ }
+
+
+
+ private VehicleRoutingProblem createVrpWithLocationIndecesAndMatrix(VehicleRoutingProblem vrp_, boolean return_to_depot) {
+ VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
+ List locations = new ArrayList();
+ for (Vehicle v : vrp_.getVehicles()) {
+ Location l = Location.Builder.newInstance().setIndex(getIndex()).setId(v.getStartLocation().getId())
+ .setCoordinate(v.getStartLocation().getCoordinate()).build();
+ VehicleImpl.Builder newVehicleBuilder = VehicleImpl.Builder.newInstance(v.getId()).setType(v.getType())
+ .setEarliestStart(v.getEarliestDeparture()).setLatestArrival(v.getLatestArrival())
+ .setStartLocation(l).setReturnToDepot(return_to_depot);
+ VehicleImpl newVehicle = newVehicleBuilder.build();
+ vrpBuilder.addVehicle(newVehicle);
+ locations.add(l);
+ }
+ for (Job j : vrp_.getJobs().values()){
+ Service s = (Service) j;
+ Location l = Location.Builder.newInstance().setIndex(getIndex())
+ .setId(s.getLocation().getId()).setCoordinate(s.getLocation().getCoordinate()).build();
+ Service newService = Service.Builder.newInstance(s.getId()).setServiceTime(s.getServiceDuration())
+ .addSizeDimension(0,s.getSize().get(0))
+ .setLocation(l).build();
+ vrpBuilder.addJob(newService);
+ locations.add(l);
+ }
+ FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(locations.size(),true);
+ for(Location from : locations){
+ for(Location to : locations){
+ double distance = EuclideanDistanceCalculator.calculateDistance(from.getCoordinate(), to.getCoordinate());
+ matrixBuilder.addTransportDistance(from.getIndex(),to.getIndex(), distance);
+ matrixBuilder.addTransportTime(from.getIndex(),to.getIndex(),distance);
+ }
+ }
+ vrpBuilder.setRoutingCost(matrixBuilder.build());
+ return vrpBuilder.build();
+ }
+
+
+ public int getIndex() {
+ int i = index;
+ index++;
+ return i;
+ }
+}
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java
index 70929dd3..1505cd25 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT.java
@@ -114,7 +114,7 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT {
VehicleTypeImpl bigType = typeBuilder.build();
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
- vehicleBuilder.setStartLocationId("1");
+ vehicleBuilder.setStartLocation(Location.newInstance("1"));
vehicleBuilder.setType(bigType);
vehicleBuilder.setLatestArrival(220);
Vehicle bigVehicle = vehicleBuilder.build();
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndDistanceCosts_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndDistanceCosts_IT.java
index 8da0978d..30b9d34b 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndDistanceCosts_IT.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndDistanceCosts_IT.java
@@ -114,7 +114,7 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndD
VehicleTypeImpl bigType = typeBuilder.build();
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
- vehicleBuilder.setStartLocationId("1");
+ vehicleBuilder.setStartLocation(Location.newInstance("1"));
vehicleBuilder.setType(bigType);
vehicleBuilder.setLatestArrival(220);
Vehicle bigVehicle = vehicleBuilder.build();
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ServiceInsertionAndLoadConstraintsTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ServiceInsertionAndLoadConstraintsTest.java
index 6863c279..3d9bfaad 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ServiceInsertionAndLoadConstraintsTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ServiceInsertionAndLoadConstraintsTest.java
@@ -94,7 +94,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
public void doBefore(){
routingCosts = CostFactory.createManhattanCosts();
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").addCapacityDimension(0, 2).setCostPerDistance(1).build();
- vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("0,0").setType(type).build();
+ vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("0,0")).setType(type).build();
activityInsertionCostsCalculator = new LocalActivityInsertionCostsCalculator(routingCosts, activityCosts);
createInsertionCalculator(hardRouteLevelConstraint);
vehicleRoutingProblem = mock(VehicleRoutingProblem.class);
@@ -112,7 +112,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick").addSizeDimension(0, 15).setLocation(Location.newInstance("0,10")).build();
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").addCapacityDimension(0, 50).setCostPerDistance(1).build();
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("0,0").setType(type).build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("0,0")).setType(type).build();
final VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(delivery).addJob(pickup).addVehicle(vehicle).build();
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestCalculatesServiceInsertion.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestCalculatesServiceInsertion.java
index 874aa14f..3527e5bc 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestCalculatesServiceInsertion.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestCalculatesServiceInsertion.java
@@ -78,10 +78,10 @@ public class TestCalculatesServiceInsertion {
public void setup(){
VehicleType t1 = VehicleTypeImpl.Builder.newInstance("t1").addCapacityDimension(0, 1000).setCostPerDistance(1.0).build();
- vehicle = VehicleImpl.Builder.newInstance("vehicle").setLatestArrival(100.0).setStartLocationId("0,0").setType(t1).build();
+ vehicle = VehicleImpl.Builder.newInstance("vehicle").setLatestArrival(100.0).setStartLocation(Location.newInstance("0,0")).setType(t1).build();
VehicleType t2 = VehicleTypeImpl.Builder.newInstance("t2").addCapacityDimension(0, 1000).setCostPerDistance(2.0).build();
- newVehicle = VehicleImpl.Builder.newInstance("newVehicle").setLatestArrival(100.0).setStartLocationId("0,0").setType(t2).build();
+ newVehicle = VehicleImpl.Builder.newInstance("newVehicle").setLatestArrival(100.0).setStartLocation(Location.newInstance("0,0")).setType(t2).build();
driver = DriverImpl.noDriver();
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestCalculatesServiceInsertionOnRouteLevel.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestCalculatesServiceInsertionOnRouteLevel.java
index c7d87d44..a17c9017 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestCalculatesServiceInsertionOnRouteLevel.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestCalculatesServiceInsertionOnRouteLevel.java
@@ -78,8 +78,8 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
costs = mock(VehicleRoutingTransportCosts.class);
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").addCapacityDimension(0,1000).build();
- vehicle = VehicleImpl.Builder.newInstance("v1").setType(type).setStartLocationId("0,0").setLatestArrival(100.).build();
- newVehicle = VehicleImpl.Builder.newInstance("v2").setType(type).setStartLocationId("0,0").setLatestArrival(100.).build();
+ vehicle = VehicleImpl.Builder.newInstance("v1").setType(type).setStartLocation(Location.newInstance("0,0")).setLatestArrival(100.).build();
+ newVehicle = VehicleImpl.Builder.newInstance("v2").setType(type).setStartLocation(Location.newInstance("0,0")).setLatestArrival(100.).build();
driver = DriverImpl.noDriver();
costs = new AbstractForwardVehicleRoutingTransportCosts() {
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestDepartureTimeOpt.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestDepartureTimeOpt.java
index 2a4ce0bb..a1eaa3c3 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestDepartureTimeOpt.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestDepartureTimeOpt.java
@@ -18,6 +18,7 @@ package jsprit.core.algorithm.recreate;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
+import jsprit.core.problem.Location;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.Builder;
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
@@ -74,7 +75,7 @@ public class TestDepartureTimeOpt {
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
Service service = Service.Builder.newInstance("s")
.setLocation(TestUtils.loc("servLoc",Coordinate.newInstance(0, 10))).setTimeWindow(timeWindow).build();
- Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0))
+ Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.Builder.newInstance().setId("vehLoc").setCoordinate(Coordinate.newInstance(0, 0)).build())
.setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/SolomonSkills_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/state/SolomonSkills_IT.java
index 7a7c34ee..b0b661ba 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/SolomonSkills_IT.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/state/SolomonSkills_IT.java
@@ -89,7 +89,7 @@ public class SolomonSkills_IT {
constraintManager.addSkillsConstraint();
VehicleRoutingAlgorithm vra = vraBuilder.build();
- vra.setMaxIterations(500);
+ vra.setMaxIterations(2000);
try {
Collection solutions = vra.searchSolutions();
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/StateManagerTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/state/StateManagerTest.java
index ddada4ae..dbeef1be 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/StateManagerTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/state/StateManagerTest.java
@@ -74,7 +74,7 @@ public class StateManagerTest {
@Test
public void whenVehicleDependentInternalRouteStateIsSet_itMustBeSetCorrectly(){
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
@@ -87,7 +87,7 @@ public class StateManagerTest {
@Test
public void whenVehicleDependentInternalRouteStateIsNotSet_itMustBeSetCorrectly(){
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
@@ -221,7 +221,7 @@ public class StateManagerTest {
@Test
public void whenCreatingAVehicleDependentRouteState_itShouldBeMemorized(){
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
VehicleRoute route = getRoute(vehicle);
@@ -235,7 +235,7 @@ public class StateManagerTest {
@Test
public void whenCreatingAVehicleDependentActivityState_itShouldBeMemorized(){
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
StateManager stateManager = new StateManager(mock(VehicleRoutingProblem.class));
@@ -250,7 +250,7 @@ public class StateManagerTest {
@Test
public void whenMemorizingVehicleInfo_itShouldBeMemorized(){
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
//noinspection UnusedDeclaration
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle).build();
VehicleRoute route = getRoute(vehicle);
@@ -264,8 +264,8 @@ public class StateManagerTest {
@Test
public void whenMemorizingTwoVehicleInfoForRoute_itShouldBeMemorized(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").setCostPerDistance(4.).build();
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
- VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
+ VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).setType(type).build();
VehicleRoute route = getRoute(vehicle);
//getting the indices created in vrpBuilder
@@ -284,8 +284,8 @@ public class StateManagerTest {
@Test
public void whenMemorizingTwoVehicleInfoForAct_itShouldBeMemorized(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").setCostPerDistance(4.).build();
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
- VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
+ VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).setType(type).build();
//getting the indices created in vrpBuilder
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
@@ -306,8 +306,8 @@ public class StateManagerTest {
@Test
public void whenClearing_arrElementsShouldBeNull(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("t").setCostPerDistance(4.).build();
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").build();
- VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).build();
+ VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("loc")).setType(type).build();
//getting the indices created in vrpBuilder
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java
index 1b14086a..2337077a 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java
@@ -95,7 +95,7 @@ public class VehicleRouteBuilderTest {
Capacity capacity = Capacity.Builder.newInstance().build();
when(s.getSize()).thenReturn(capacity);
when(s2.getSize()).thenReturn(capacity);
- Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setEndLocationId("vehLoc")
+ Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("vehLoc")).setEndLocation(Location.newInstance("vehLoc"))
.build();
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class));
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/vehicle/TestVehicleFleetManagerImpl.java b/jsprit-core/src/test/java/jsprit/core/problem/vehicle/TestVehicleFleetManagerImpl.java
index 723a00f1..ea78129a 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/vehicle/TestVehicleFleetManagerImpl.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/vehicle/TestVehicleFleetManagerImpl.java
@@ -16,6 +16,7 @@
******************************************************************************/
package jsprit.core.problem.vehicle;
+import jsprit.core.problem.Location;
import org.junit.Before;
import org.junit.Test;
@@ -38,8 +39,8 @@ public class TestVehicleFleetManagerImpl {
public void setUp(){
List vehicles = new ArrayList();
- v1 = VehicleImpl.Builder.newInstance("standard").setStartLocationId("loc").setType(VehicleTypeImpl.Builder.newInstance("standard").build()).build();
- v2 = VehicleImpl.Builder.newInstance("foo").setStartLocationId("fooLoc").setType(VehicleTypeImpl.Builder.newInstance("foo").build()).build();
+ v1 = VehicleImpl.Builder.newInstance("standard").setStartLocation(Location.newInstance("loc")).setType(VehicleTypeImpl.Builder.newInstance("standard").build()).build();
+ v2 = VehicleImpl.Builder.newInstance("foo").setStartLocation(Location.newInstance("fooLoc")).setType(VehicleTypeImpl.Builder.newInstance("foo").build()).build();
// v1.
vehicles.add(v1);
@@ -96,7 +97,7 @@ public class TestVehicleFleetManagerImpl {
@Test
public void testWithPenalty_whenHavingOneRegularVehicleAvailable_noPenaltyVehicleIsReturn(){
- Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setStartLocationId("loc").
+ Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setStartLocation(Location.newInstance("loc")).
setType(VehicleTypeImpl.Builder.newInstance("standard").build()).build();
List vehicles = new ArrayList();
@@ -114,8 +115,8 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithSameTypeIdAndLocation_getAvailableVehicleShouldReturnOnlyOneOfThem(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
- Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type).build();
- Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type).build();
+ Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setType(type).build();
+ Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setType(type).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection vehicles = fleetManager.getAvailableVehicles();
assertEquals(1,vehicles.size());
@@ -124,9 +125,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithSameTypeIdStartAndEndLocationAndWorkingShift_getAvailableVehicleShouldReturnOnlyOneOfThem(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
- Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
- Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection vehicles = fleetManager.getAvailableVehicles();
@@ -137,9 +138,9 @@ public class TestVehicleFleetManagerImpl {
public void whenAddingTwoVehiclesWithDifferentType_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("type2").build();
- Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
- Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type2).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection vehicles = fleetManager.getAvailableVehicles();
@@ -151,9 +152,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithDifferentStartLocation_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
- Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("startloc").setEndLocationId("endLoc")
+ Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("startLoc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
- Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection vehicles = fleetManager.getAvailableVehicles();
@@ -165,9 +166,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithDifferentEndLocation_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
- Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLocation")
+ Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLocation"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
- Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection vehicles = fleetManager.getAvailableVehicles();
@@ -179,9 +180,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithDifferentEarliestStart_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
- Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(5.).setLatestArrival(10.).build();
- Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection vehicles = fleetManager.getAvailableVehicles();
@@ -193,9 +194,9 @@ public class TestVehicleFleetManagerImpl {
@Test
public void whenAddingTwoVehiclesWithDifferentLatestArr_getAvailableVehicleShouldReturnBoth(){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("standard").build();
- Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(20.).build();
- Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setEndLocationId("endLoc")
+ Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("loc")).setEndLocation(Location.newInstance("endLoc"))
.setType(type).setEarliestStart(0.).setLatestArrival(10.).build();
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(Arrays.asList(v1,v2)).createFleetManager();
Collection vehicles = fleetManager.getAvailableVehicles();
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/vehicle/VehicleTypeKeyTest.java b/jsprit-core/src/test/java/jsprit/core/problem/vehicle/VehicleTypeKeyTest.java
index 5dea8ca3..b8e8632b 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/vehicle/VehicleTypeKeyTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/vehicle/VehicleTypeKeyTest.java
@@ -1,6 +1,7 @@
package jsprit.core.problem.vehicle;
+import jsprit.core.problem.Location;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
@@ -10,18 +11,18 @@ public class VehicleTypeKeyTest {
@Test
public void typeIdentifierShouldBeEqual(){
- Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("start").addSkill("skill1").addSkill("skill2")
+ Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("start")).addSkill("skill1").addSkill("skill2")
.addSkill("skill3").build();
- Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("start").addSkill("skill2").addSkill("skill1")
+ Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("start")).addSkill("skill2").addSkill("skill1")
.addSkill("skill3").build();
assertTrue(v1.getVehicleTypeIdentifier().equals(v2.getVehicleTypeIdentifier()));
}
@Test
public void typeIdentifierShouldNotBeEqual(){
- Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("start").addSkill("skill1").addSkill("skill2")
+ Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocation(Location.newInstance("start")).addSkill("skill1").addSkill("skill2")
.build();
- Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("start").addSkill("skill2").addSkill("skill1")
+ Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance("start")).addSkill("skill2").addSkill("skill1")
.addSkill("skill3").build();
assertFalse(v1.getVehicleTypeIdentifier().equals(v2.getVehicleTypeIdentifier()));
}
diff --git a/jsprit-instances/src/main/java/jsprit/instance/reader/LuiShenReader.java b/jsprit-instances/src/main/java/jsprit/instance/reader/LuiShenReader.java
index 70be4b95..32c1189f 100644
--- a/jsprit-instances/src/main/java/jsprit/instance/reader/LuiShenReader.java
+++ b/jsprit-instances/src/main/java/jsprit/instance/reader/LuiShenReader.java
@@ -22,7 +22,6 @@ import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.solution.route.activity.TimeWindow;
-import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.problem.vehicle.VehicleImpl;
import jsprit.core.problem.vehicle.VehicleTypeImpl;
import jsprit.core.util.Coordinate;
@@ -123,8 +122,9 @@ public class LuiShenReader {
VehicleTypeImpl type = typeBuilder.build();
- Vehicle reprVehicle = VehicleImpl.Builder.newInstance(vehicleId).setEarliestStart(start).setLatestArrival(end).
- setStartLocationId(locationId).setStartLocationCoordinate(coord).setType(type).build();
+ VehicleImpl reprVehicle = VehicleImpl.Builder.newInstance(vehicleId).setEarliestStart(start).setLatestArrival(end).
+ setStartLocation(Location.Builder.newInstance().setId(locationId).setCoordinate(coord).build())
+ .setType(type).build();
vrpBuilder.addVehicle(reprVehicle);
diff --git a/jsprit-instances/src/main/java/jsprit/instance/reader/TSPLIB95Reader.java b/jsprit-instances/src/main/java/jsprit/instance/reader/TSPLIB95Reader.java
index f0346b5a..699af4be 100644
--- a/jsprit-instances/src/main/java/jsprit/instance/reader/TSPLIB95Reader.java
+++ b/jsprit-instances/src/main/java/jsprit/instance/reader/TSPLIB95Reader.java
@@ -159,8 +159,9 @@ public class TSPLIB95Reader {
vrpBuilder.setFleetSize(VehicleRoutingProblem.FleetSize.FINITE);
for(Integer depotId : depotIds){
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0,capacity).build();
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocationId(depotId.toString())
- .setStartLocationCoordinate(coords[depotId - 1]).setType(type).build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle")
+ .setStartLocation(Location.Builder.newInstance().setId(depotId.toString()).setCoordinate(coords[depotId - 1]).build())
+ .setType(type).build();
vrpBuilder.addVehicle(vehicle);
}