From 600087fd33e55e38175513696e5724c2dd170c6a Mon Sep 17 00:00:00 2001
From: oblonski <4sschroeder@gmail.com>
Date: Thu, 18 Dec 2014 16:21:18 +0100
Subject: [PATCH] issue #144 - replace deprecated methods
---
.../toolbox/AlgorithmEventsRecorder.java | 6 +-
.../analysis/toolbox/GraphStreamViewer.java | 24 ++---
.../java/jsprit/analysis/toolbox/Plotter.java | 30 +++----
.../io/VehicleRoutingAlgorithms.java | 2 +-
.../core/algorithm/recreate/Inserter.java | 4 +-
.../distance/EuclideanServiceDistance.java | 14 +--
.../state/UpdateEndLocationIfRouteIsOpen.java | 20 ++---
.../core/problem/VehicleRoutingProblem.java | 18 ++--
.../route/activity/DeliverService.java | 2 +-
.../route/activity/DeliverShipment.java | 2 +-
.../problem/solution/route/activity/End.java | 2 +-
.../route/activity/PickupService.java | 2 +-
.../route/activity/PickupShipment.java | 2 +-
.../route/activity/ServiceActivity.java | 2 +-
.../jsprit/core/util/NeighborhoodImpl.java | 20 ++---
.../core/algorithm/InitialRoutesTest.java | 20 +++--
.../recreate/RegretInsertionTest.java | 14 ++-
.../ShipmentInsertionCalculatorTest.java | 33 +++----
.../core/algorithm/recreate/TestInserter.java | 34 +++----
.../ruin/distance/AverageJobDistanceTest.java | 9 +-
...eliveryShipmentActivityConstraintTest.java | 3 +-
.../core/algorithm/state/LoadStateTest.java | 9 +-
.../algorithm/state/SolomonSkills_IT.java | 4 +-
.../problem/VehicleRoutingProblemTest.java | 18 +++-
.../constraint/LoadConstraintTest.java | 9 +-
.../core/problem/io/VrpXMLReaderTest.java | 16 ++--
.../core/problem/io/VrpXMLWriterTest.java | 38 ++++----
.../jsprit/core/problem/job/ServiceTest.java | 8 +-
.../jsprit/core/problem/job/ShipmentTest.java | 88 +++++++++----------
.../solution/route/TestVehicleRoute.java | 20 ++---
.../route/VehicleRouteBuilderTest.java | 12 +--
.../DefaultShipmentActivityFactoryTest.java | 5 +-
.../route/activity/DeliverServiceTest.java | 28 +++---
.../route/activity/DeliverShipmentTest.java | 19 ++--
.../solution/route/activity/EndTest.java | 26 +++---
.../route/activity/PickupServiceTest.java | 28 +++---
.../route/activity/PickupShipmentTest.java | 19 ++--
.../route/activity/ServiceActivityTest.java | 21 ++---
.../solution/route/activity/StartTest.java | 27 +++---
.../solution/route/activity/TestRefs.java | 20 ++---
.../route/activity/TestTourActivities.java | 15 ++--
.../AdditionalDistanceConstraintExample.java | 4 +-
...ndSpecifiedVehicleEndLocationsExample.java | 4 +-
.../examples/SolomonWithSkillsExample.java | 6 +-
.../examples/TransportOfDisabledPeople.java | 2 +-
.../examples/VRPWithBackhaulsExample2.java | 22 ++---
.../instance/reader/CordeauReaderTest.java | 21 +++--
.../instance/reader/GoldenReaderTest.java | 25 ++++--
48 files changed, 398 insertions(+), 379 deletions(-)
diff --git a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/AlgorithmEventsRecorder.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/AlgorithmEventsRecorder.java
index 69aa8928..266ce38a 100644
--- a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/AlgorithmEventsRecorder.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/AlgorithmEventsRecorder.java
@@ -310,15 +310,15 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis
private void addJob(Job job) {
if(job instanceof Service){
Service service = (Service)job;
- addNode(service.getId(), service.getCoord());
+ addNode(service.getId(), service.getLocation().getCoordinate());
markService(service);
}
else if(job instanceof Shipment){
Shipment shipment = (Shipment)job;
String fromNodeId = getFromNodeId(shipment);
- addNode(fromNodeId, shipment.getPickupCoord());
+ addNode(fromNodeId, shipment.getPickupLocation().getCoordinate());
String toNodeId = getToNodeId(shipment);
- addNode(toNodeId,shipment.getDeliveryCoord());
+ addNode(toNodeId,shipment.getDeliveryLocation().getCoordinate());
markShipment(shipment);
if(renderShipments) {
Edge e = graph.addEdge("shipment_" + fromNodeId + "_" + toNodeId, fromNodeId, toNodeId, true);
diff --git a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/GraphStreamViewer.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/GraphStreamViewer.java
index 91242288..513bdb4b 100644
--- a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/GraphStreamViewer.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/GraphStreamViewer.java
@@ -505,21 +505,21 @@ public class GraphStreamViewer {
private void renderShipment(Graph g, Shipment shipment, Label label, boolean renderShipments) {
- Node n1 = g.addNode(makeId(shipment.getId(),shipment.getPickupLocationId()));
+ Node n1 = g.addNode(makeId(shipment.getId(),shipment.getPickupLocation().getId()));
if(label.equals(Label.ID)) n1.addAttribute("ui.label", shipment.getId());
- n1.addAttribute("x", shipment.getPickupCoord().getX());
- n1.addAttribute("y", shipment.getPickupCoord().getY());
+ n1.addAttribute("x", shipment.getPickupLocation().getCoordinate().getX());
+ n1.addAttribute("y", shipment.getPickupLocation().getCoordinate().getY());
n1.setAttribute("ui.class", "pickup");
- Node n2 = g.addNode(makeId(shipment.getId(),shipment.getDeliveryLocationId()));
+ Node n2 = g.addNode(makeId(shipment.getId(),shipment.getDeliveryLocation().getId()));
if(label.equals(Label.ID)) n2.addAttribute("ui.label", shipment.getId());
- n2.addAttribute("x", shipment.getDeliveryCoord().getX());
- n2.addAttribute("y", shipment.getDeliveryCoord().getY());
+ n2.addAttribute("x", shipment.getDeliveryLocation().getCoordinate().getX());
+ n2.addAttribute("y", shipment.getDeliveryLocation().getCoordinate().getY());
n2.setAttribute("ui.class", "delivery");
if(renderShipments){
- Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(),shipment.getPickupLocationId()),
- makeId(shipment.getId(),shipment.getDeliveryLocationId()), true);
+ Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(),shipment.getPickupLocation().getId()),
+ makeId(shipment.getId(),shipment.getDeliveryLocation().getId()), true);
s.addAttribute("ui.class", "shipment");
}
@@ -535,10 +535,10 @@ public class GraphStreamViewer {
}
private void renderService(Graph g, Service service, Label label) {
- Node n = g.addNode(makeId(service.getId(),service.getLocationId()));
+ Node n = g.addNode(makeId(service.getId(),service.getLocation().getId()));
if(label.equals(Label.ID)) n.addAttribute("ui.label", service.getId());
- n.addAttribute("x", service.getCoord().getX());
- n.addAttribute("y", service.getCoord().getY());
+ n.addAttribute("x", service.getLocation().getCoordinate().getX());
+ n.addAttribute("y", service.getLocation().getCoordinate().getY());
if(service.getType().equals("pickup")) n.setAttribute("ui.class", "pickup");
if(service.getType().equals("delivery")) n.setAttribute("ui.class", "delivery");
}
@@ -576,7 +576,7 @@ public class GraphStreamViewer {
}
for(TourActivity act : route.getActivities()){
Job job = ((JobActivity) act).getJob();
- String currIdentifier = makeId(job.getId(),act.getLocationId());
+ String currIdentifier = makeId(job.getId(),act.getLocation().getId());
if(label.equals(Label.ACTIVITY)){
Node actNode = g.getNode(currIdentifier);
actNode.addAttribute("ui.label", act.getName());
diff --git a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/Plotter.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/Plotter.java
index 45bbcd03..4e34bc4e 100644
--- a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/Plotter.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/Plotter.java
@@ -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
* 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.
- *
+ *
* 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 .
******************************************************************************/
@@ -470,15 +470,15 @@ public class Plotter {
if(route.isEmpty()) continue;
XYSeries series = new XYSeries(counter, false, true);
- Coordinate startCoord = locations.getCoord(route.getStart().getLocationId());
+ Coordinate startCoord = locations.getCoord(route.getStart().getLocation().getId());
series.add(startCoord.getX()*scalingFactor, startCoord.getY()*scalingFactor);
for(TourActivity act : route.getTourActivities().getActivities()){
- Coordinate coord = locations.getCoord(act.getLocationId());
+ Coordinate coord = locations.getCoord(act.getLocation().getId());
series.add(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
}
- Coordinate endCoord = locations.getCoord(route.getEnd().getLocationId());
+ Coordinate endCoord = locations.getCoord(route.getEnd().getLocation().getId());
series.add(endCoord.getX()*scalingFactor, endCoord.getY()*scalingFactor);
coll.addSeries(series);
@@ -507,8 +507,8 @@ public class Plotter {
shipmentSeries = new XYSeries(sCounter, false, true);
sCounter++;
}
- shipmentSeries.add(shipment.getPickupCoord().getX()*scalingFactor, shipment.getPickupCoord().getY()*scalingFactor);
- shipmentSeries.add(shipment.getDeliveryCoord().getX()*scalingFactor, shipment.getDeliveryCoord().getY()*scalingFactor);
+ shipmentSeries.add(shipment.getPickupLocation().getCoordinate().getX()*scalingFactor, shipment.getPickupLocation().getCoordinate().getY()*scalingFactor);
+ shipmentSeries.add(shipment.getDeliveryLocation().getCoordinate().getX()*scalingFactor, shipment.getDeliveryLocation().getCoordinate().getY()*scalingFactor);
coll.addSeries(shipmentSeries);
}
return coll;
@@ -517,13 +517,13 @@ public class Plotter {
private void addJob(XYSeries activities, Job job) {
if(job instanceof Shipment){
Shipment s = (Shipment)job;
- XYDataItem dataItem = new XYDataItem(s.getPickupCoord().getX()*scalingFactor, s.getPickupCoord().getY()*scalingFactor);
+ XYDataItem dataItem = new XYDataItem(s.getPickupLocation().getCoordinate().getX()*scalingFactor, s.getPickupLocation().getCoordinate().getY()*scalingFactor);
activities.add(dataItem);
addLabel(s, dataItem);
markItem(dataItem,Activity.PICKUP, job);
containsPickupAct = true;
- XYDataItem dataItem2 = new XYDataItem(s.getDeliveryCoord().getX()*scalingFactor, s.getDeliveryCoord().getY()*scalingFactor);
+ XYDataItem dataItem2 = new XYDataItem(s.getDeliveryLocation().getCoordinate().getX()*scalingFactor, s.getDeliveryLocation().getCoordinate().getY()*scalingFactor);
activities.add(dataItem2);
addLabel(s, dataItem2);
markItem(dataItem2,Activity.DELIVERY, job);
@@ -531,7 +531,7 @@ public class Plotter {
}
else if(job instanceof Pickup){
Pickup service = (Pickup)job;
- Coordinate coord = service.getCoord();
+ Coordinate coord = service.getLocation().getCoordinate();
XYDataItem dataItem = new XYDataItem(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
activities.add(dataItem);
addLabel(service, dataItem);
@@ -540,7 +540,7 @@ public class Plotter {
}
else if(job instanceof Delivery){
Delivery service = (Delivery)job;
- Coordinate coord = service.getCoord();
+ Coordinate coord = service.getLocation().getCoordinate();
XYDataItem dataItem = new XYDataItem(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
activities.add(dataItem);
addLabel(service, dataItem);
@@ -549,7 +549,7 @@ public class Plotter {
}
else if(job instanceof Service){
Service service = (Service)job;
- Coordinate coord = service.getCoord();
+ Coordinate coord = service.getLocation().getCoordinate();
XYDataItem dataItem = new XYDataItem(coord.getX()*scalingFactor, coord.getY()*scalingFactor);
activities.add(dataItem);
addLabel(service, dataItem);
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java b/jsprit-core/src/main/java/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java
index bfb43c1b..f215f8bc 100644
--- a/jsprit-core/src/main/java/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java
@@ -444,7 +444,7 @@ public class VehicleRoutingAlgorithms {
if(firstAct){
firstAct=false;
if(!vehicle.isReturnToDepot()){
- assert activity.getLocationId().equals(end.getLocationId()) : "route end and last activity are not equal even route is open. this should not be.";
+ assert activity.getLocation().getId().equals(end.getLocation().getId()) : "route end and last activity are not equal even route is open. this should not be.";
}
}
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java
index cd052dc5..a0f94045 100644
--- a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java
@@ -81,7 +81,7 @@ class Inserter {
}
private void setEndLocation(VehicleRoute route, Service service) {
- route.getEnd().setLocationId(service.getLocationId());
+ route.getEnd().setLocationId(service.getLocation().getId());
}
public void setNextHandler(JobInsertionHandler jobInsertionHandler){
@@ -121,7 +121,7 @@ class Inserter {
}
private void setEndLocation(VehicleRoute route, Shipment shipment) {
- route.getEnd().setLocationId(shipment.getDeliveryLocationId());
+ route.getEnd().setLocationId(shipment.getDeliveryLocation().getId());
}
public void setNextHandler(JobInsertionHandler jobInsertionHandler){
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/EuclideanServiceDistance.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/EuclideanServiceDistance.java
index 2369e8d6..659b8d10 100644
--- a/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/EuclideanServiceDistance.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/EuclideanServiceDistance.java
@@ -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
* 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.
- *
+ *
* 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 .
******************************************************************************/
@@ -35,8 +35,8 @@ public class EuclideanServiceDistance implements JobDistance {
} else {
Service s_i = (Service) i;
Service s_j = (Service) j;
- if(s_i.getCoord() == null || s_j.getCoord() == null) throw new IllegalStateException("cannot calculate euclidean distance. since service coords are missing");
- avgCost = EuclideanDistanceCalculator.calculateDistance(s_i.getCoord(), s_j.getCoord());
+ if(s_i.getLocation().getCoordinate() == null || s_j.getLocation().getCoordinate() == null) throw new IllegalStateException("cannot calculate euclidean distance. since service coords are missing");
+ avgCost = EuclideanDistanceCalculator.calculateDistance(s_i.getLocation().getCoordinate(), s_j.getLocation().getCoordinate());
}
} else {
throw new UnsupportedOperationException(
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateEndLocationIfRouteIsOpen.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateEndLocationIfRouteIsOpen.java
index dec4dc0c..da0aed80 100644
--- a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateEndLocationIfRouteIsOpen.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateEndLocationIfRouteIsOpen.java
@@ -1,20 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * 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
+ * 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
+ * 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 .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.algorithm.state;
@@ -36,7 +34,7 @@ public class UpdateEndLocationIfRouteIsOpen implements StateUpdater, RouteVisito
private void setRouteEndToLastActivity(VehicleRoute route) {
if(!route.getActivities().isEmpty()){
TourActivity lastAct = route.getActivities().get(route.getActivities().size()-1);
- route.getEnd().setLocationId(lastAct.getLocationId());
+ route.getEnd().setLocationId(lastAct.getLocation().getId());
}
}
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java b/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java
index 29095b3a..818f5c92 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java
@@ -239,12 +239,12 @@ public class VehicleRoutingProblem {
private void addLocationToTentativeLocations(Job job) {
if(job instanceof Service) {
- tentative_coordinates.put(((Service)job).getLocationId(), ((Service)job).getCoord());
+ tentative_coordinates.put(((Service)job).getLocation().getId(), ((Service)job).getLocation().getCoordinate());
}
else if(job instanceof Shipment){
Shipment shipment = (Shipment)job;
- tentative_coordinates.put(shipment.getPickupLocationId(), shipment.getPickupCoord());
- tentative_coordinates.put(shipment.getDeliveryLocationId(), shipment.getDeliveryCoord());
+ tentative_coordinates.put(shipment.getPickupLocation().getId(), shipment.getPickupLocation().getCoordinate());
+ tentative_coordinates.put(shipment.getDeliveryLocation().getId(), shipment.getDeliveryLocation().getCoordinate());
}
}
@@ -290,11 +290,11 @@ public class VehicleRoutingProblem {
}
private void registerLocation(Job job) {
- if (job instanceof Service) tentative_coordinates.put(((Service) job).getLocationId(), ((Service) job).getCoord());
+ if (job instanceof Service) tentative_coordinates.put(((Service) job).getLocation().getId(), ((Service) job).getLocation().getCoordinate());
if (job instanceof Shipment) {
Shipment shipment = (Shipment) job;
- tentative_coordinates.put(shipment.getPickupLocationId(), shipment.getPickupCoord());
- tentative_coordinates.put(shipment.getDeliveryLocationId(), shipment.getDeliveryCoord());
+ tentative_coordinates.put(shipment.getPickupLocation().getId(), shipment.getPickupLocation().getCoordinate());
+ tentative_coordinates.put(shipment.getDeliveryLocation().getId(), shipment.getDeliveryLocation().getCoordinate());
}
}
@@ -322,8 +322,8 @@ public class VehicleRoutingProblem {
private void addShipment(Shipment job) {
if(jobs.containsKey(job.getId())){ logger.warn("job " + job + " already in job list. overrides existing job."); }
- tentative_coordinates.put(job.getPickupLocationId(), job.getPickupCoord());
- tentative_coordinates.put(job.getDeliveryLocationId(), job.getDeliveryCoord());
+ tentative_coordinates.put(job.getPickupLocation().getId(), job.getPickupLocation().getCoordinate());
+ tentative_coordinates.put(job.getDeliveryLocation().getId(), job.getDeliveryLocation().getCoordinate());
jobs.put(job.getId(),job);
}
@@ -473,7 +473,7 @@ public class VehicleRoutingProblem {
}
private Builder addService(Service service){
- tentative_coordinates.put(service.getLocationId(), service.getCoord());
+ tentative_coordinates.put(service.getLocation().getId(), service.getLocation().getCoordinate());
if(jobs.containsKey(service.getId())){ logger.warn("service " + service + " already in job list. overrides existing job."); }
jobs.put(service.getId(),service);
return this;
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverService.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverService.java
index 5a416d20..3d133291 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverService.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverService.java
@@ -52,7 +52,7 @@ public final class DeliverService extends AbstractActivity implements DeliveryAc
@Override
public String getLocationId() {
- return delivery.getLocationId();
+ return delivery.getLocation().getId();
}
@Override
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverShipment.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverShipment.java
index 9e5079c8..bcf5c290 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverShipment.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/DeliverShipment.java
@@ -59,7 +59,7 @@ public final class DeliverShipment extends AbstractActivity implements DeliveryA
@Override
public String getLocationId() {
- return shipment.getDeliveryLocationId();
+ return shipment.getDeliveryLocation().getId();
}
@Override
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/End.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/End.java
index 4b5dc022..5d35cc2b 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/End.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/End.java
@@ -88,7 +88,7 @@ public final class End extends AbstractActivity implements TourActivity {
public End(End end) {
this.location = end.getLocation();
-// this.locationId = end.getLocationId();
+// this.locationId = end.getLocation().getId();
theoretical_earliestOperationStartTime = end.getTheoreticalEarliestOperationStartTime();
theoretical_latestOperationStartTime = end.getTheoreticalLatestOperationStartTime();
arrTime = end.getArrTime();
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupService.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupService.java
index 3bef105c..8c02211a 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupService.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupService.java
@@ -53,7 +53,7 @@ public final class PickupService extends AbstractActivity implements PickupActiv
@Override
public String getLocationId() {
- return pickup.getLocationId();
+ return pickup.getLocation().getId();
}
@Override
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupShipment.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupShipment.java
index ddf1401b..b5628f7b 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupShipment.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/PickupShipment.java
@@ -55,7 +55,7 @@ public final class PickupShipment extends AbstractActivity implements PickupActi
@Override
public String getLocationId() {
- return shipment.getPickupLocationId();
+ return shipment.getPickupLocation().getId();
}
@Override
diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/ServiceActivity.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/ServiceActivity.java
index 3a5f5c5a..c917f20b 100644
--- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/ServiceActivity.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/ServiceActivity.java
@@ -129,7 +129,7 @@ public class ServiceActivity extends AbstractActivity implements JobActivity{
@Override
public String getLocationId() {
- return service.getLocationId();
+ return service.getLocation().getId();
}
@Override
diff --git a/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java b/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java
index a3ed48ca..20169fd3 100644
--- a/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java
+++ b/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java
@@ -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
* 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.
- *
+ *
* 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 .
******************************************************************************/
@@ -56,18 +56,18 @@ public class NeighborhoodImpl implements Neighborhood{
for(Service i : services){
Set neigh = new HashSet();
for(Vehicle v : vehicles){
- double dist2depot = EuclideanDistanceCalculator.calculateDistance(v.getStartLocationCoordinate(), i.getCoord());
+ double dist2depot = EuclideanDistanceCalculator.calculateDistance(v.getStartLocationCoordinate(), i.getLocation().getCoordinate());
if(dist2depot <= threshold){
- neighborsToAll.add(((Service)i).getLocationId());
+ neighborsToAll.add(((Service)i).getLocation().getId());
}
}
for(Service j : services){
- double crowFlyDistance = EuclideanDistanceCalculator.calculateDistance(i.getCoord(), j.getCoord());
+ double crowFlyDistance = EuclideanDistanceCalculator.calculateDistance(i.getLocation().getCoordinate(), j.getLocation().getCoordinate());
if(crowFlyDistance <= threshold) {
- neigh.add(((Service)j).getLocationId());
+ neigh.add(((Service)j).getLocation().getId());
}
}
- neighbors.put(((Service)i).getLocationId(), neigh);
+ neighbors.put(((Service)i).getLocation().getId(), neigh);
}
}
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/InitialRoutesTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/InitialRoutesTest.java
index 913d09da..cfeabc69 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/InitialRoutesTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/InitialRoutesTest.java
@@ -21,6 +21,7 @@ package jsprit.core.algorithm;
import jsprit.core.algorithm.box.GreedySchrimpfFactory;
import jsprit.core.algorithm.box.SchrimpfFactory;
import jsprit.core.problem.AbstractActivity;
+import jsprit.core.problem.Location;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.io.VrpXMLReader;
import jsprit.core.problem.job.Job;
@@ -267,13 +268,22 @@ public class InitialRoutesTest {
@Test
public void maxCapacityShouldNotBeExceeded(){
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0, 100).build();
- VehicleImpl vehicle = VehicleImpl.Builder.newInstance("veh").setStartLocationCoordinate(Coordinate.newInstance(0, 0)).setType(type).setStartLocationId("start").build();
+ VehicleImpl vehicle = VehicleImpl.Builder.newInstance("veh")
+ .setStartLocation(Location.Builder.newInstance().setId("start").setCoordinate(Coordinate.newInstance(0, 0)).build())
+ .setType(type)
+ .build();
- Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocationId("pick").setDeliveryLocationId("del").setPickupCoord(Coordinate.newInstance(10, 0))
- .setDeliveryCoord(Coordinate.newInstance(0, 10)).addSizeDimension(0, 100).build();
+ Shipment shipment = Shipment.Builder.newInstance("s")
+ .setPickupLocation(Location.Builder.newInstance().setCoordinate(Coordinate.newInstance(10, 0)).setId("pick").build())
+ .setDeliveryLocation(Location.Builder.newInstance().setId("del").setCoordinate(Coordinate.newInstance(0, 10)).build())
+ .addSizeDimension(0, 100)
+ .build();
- Shipment another_shipment = Shipment.Builder.newInstance("another_s").setPickupLocationId("pick").setDeliveryLocationId("del").setPickupCoord(Coordinate.newInstance(10, 0))
- .setDeliveryCoord(Coordinate.newInstance(0, 10)).addSizeDimension(0, 50).build();
+ Shipment another_shipment = Shipment.Builder.newInstance("another_s")
+ .setPickupLocation(Location.Builder.newInstance().setCoordinate(Coordinate.newInstance(10, 0)).setId("pick").build())
+ .setDeliveryLocation(Location.Builder.newInstance().setId("del").setCoordinate(Coordinate.newInstance(0, 10)).build())
+ .addSizeDimension(0, 50)
+ .build();
VehicleRoute iniRoute = VehicleRoute.Builder.newInstance(vehicle).addPickup(shipment).addDelivery(shipment).build();
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/RegretInsertionTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/RegretInsertionTest.java
index dd0f19c1..224147b3 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/RegretInsertionTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/RegretInsertionTest.java
@@ -90,20 +90,16 @@ public class RegretInsertionTest {
@Test
public void shipment1ShouldBeAddedFirst(){
Shipment s1 = Shipment.Builder.newInstance("s1")
- .setPickupLocationId("pick1")
- .setPickupCoord(Coordinate.newInstance(-1, 10))
- .setDeliveryCoord(Coordinate.newInstance(1, 10))
- .setDeliveryLocationId("del1")
+ .setPickupLocation(Location.Builder.newInstance().setId("pick1").setCoordinate(Coordinate.newInstance(-1, 10)).build())
+ .setDeliveryLocation(Location.Builder.newInstance().setId("del1").setCoordinate(Coordinate.newInstance(1, 10)).build())
.build();
Shipment s2 = Shipment.Builder.newInstance("s2")
- .setPickupCoord(Coordinate.newInstance(-1,20))
- .setDeliveryCoord(Coordinate.newInstance(1, 20))
- .setPickupLocationId("pick2")
- .setDeliveryLocationId("del2")
+ .setPickupLocation(Location.Builder.newInstance().setId("pick2").setCoordinate(Coordinate.newInstance(-1, 20)).build())
+ .setDeliveryLocation(Location.Builder.newInstance().setId("del2").setCoordinate(Coordinate.newInstance(1, 20)).build())
.build();
- VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(0,0)).build();
+ VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.Builder.newInstance().setCoordinate(Coordinate.newInstance(0, 0)).build()).build();
final VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s1).addJob(s2).addVehicle(v).build();
JobInsertionCostsCalculator calculator = getShipmentCalculator(vrp);
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java
index 4b697b7f..47a8d389 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java
@@ -20,6 +20,7 @@ import jsprit.core.algorithm.recreate.listener.InsertionListeners;
import jsprit.core.algorithm.state.StateManager;
import jsprit.core.problem.AbstractActivity;
import jsprit.core.problem.JobActivityFactory;
+import jsprit.core.problem.Location;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.constraint.*;
import jsprit.core.problem.constraint.ConstraintManager.Priority;
@@ -111,7 +112,7 @@ public class ShipmentInsertionCalculatorTest {
@Test
public void whenCalculatingInsertionCostsOfShipment_itShouldReturnCorrectCostValue(){
- Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build();
+ Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
VehicleRoute route = VehicleRoute.emptyRoute();
JobActivityFactory activityFactory = mock(JobActivityFactory.class);
List activities = new ArrayList();
@@ -125,8 +126,8 @@ public class ShipmentInsertionCalculatorTest {
@Test
public void whenCalculatingInsertionIntoExistingRoute_itShouldReturnCorrectCosts(){
- Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build();
- Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build();
+ Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
+ Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
VehicleRoute route = VehicleRoute.emptyRoute();
when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment));
new Inserter(new InsertionListeners(), vehicleRoutingProblem).insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route);
@@ -155,8 +156,8 @@ public class ShipmentInsertionCalculatorTest {
@Test
public void whenInsertingShipmentInRouteWithNotEnoughCapacity_itShouldReturnNoInsertion(){
- Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build();
- Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build();
+ Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
+ Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
VehicleRoute route = VehicleRoute.emptyRoute();
when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment));
new Inserter(new InsertionListeners(), vehicleRoutingProblem).insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route);
@@ -184,9 +185,9 @@ public class ShipmentInsertionCalculatorTest {
@Test
public void whenInsertingThirdShipment_itShouldCalcCorrectVal(){
- Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build();
- Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build();
- Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("9,10").build();
+ Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
+ Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
+ Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId("9,10").build();
VehicleRoute route = VehicleRoute.emptyRoute();
when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment));
@@ -210,9 +211,9 @@ public class ShipmentInsertionCalculatorTest {
@Test
public void whenInsertingThirdShipment_itShouldCalcCorrectVal2(){
- Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build();
- Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build();
- Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("9,9").build();
+ Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
+ Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
+ Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId("9,9").build();
when(vehicleRoutingProblem.copyAndGetActivities(shipment)).thenReturn(getTourActivities(shipment));
when(vehicleRoutingProblem.copyAndGetActivities(shipment2)).thenReturn(getTourActivities(shipment2));
VehicleRoute route = VehicleRoute.emptyRoute();
@@ -236,9 +237,9 @@ public class ShipmentInsertionCalculatorTest {
@Test
public void whenInstertingShipmentWithLoadConstraintWhereCapIsNotSufficient_capConstraintsAreFulfilled(){
- Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("10,0").build();
- Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build();
- Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("9,9").build();
+ Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("10,0").build();
+ Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
+ Shipment shipment3 = Shipment.Builder.newInstance("s3").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId("9,9").build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
VehicleRoutingProblem vrp = vrpBuilder.addJob(shipment).addJob(shipment2).addJob(shipment3).build();
@@ -269,8 +270,8 @@ public class ShipmentInsertionCalculatorTest {
@Test
public void whenInsertingServiceWhileNoCapIsAvailable_itMustReturnNoInsertionData(){
- Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("0,10").setDeliveryLocationId("0,0").build();
- Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("10,10").setDeliveryLocationId("0,0").build();
+ Shipment shipment = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,10").build()).setDeliveryLocationId("0,0").build();
+ Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("10,10").build()).setDeliveryLocationId("0,0").build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
VehicleRoutingProblem vrp = vrpBuilder.addJob(shipment).addJob(shipment2).build();
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java
index 885ef274..4d36bc99 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java
@@ -91,7 +91,7 @@ public class TestInserter {
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addService(service).build();
Service serviceToInsert = mock(Service.class);
- when(serviceToInsert.getLocationId()).thenReturn("delLoc");
+ when(serviceToInsert.getLocation()).thenReturn(Location.Builder.newInstance().setId("delLoc").build());
InsertionData iData = mock(InsertionData.class);
when(iData.getDeliveryInsertionIndex()).thenReturn(1);
@@ -104,8 +104,8 @@ public class TestInserter {
inserter.insertJob(serviceToInsert, iData, route);
assertEquals(2,route.getTourActivities().getActivities().size());
- assertEquals(route.getTourActivities().getActivities().get(1).getLocationId(),serviceToInsert.getLocationId());
- assertEquals(route.getEnd().getLocationId(),serviceToInsert.getLocationId());
+ assertEquals(route.getTourActivities().getActivities().get(1).getLocation().getId(),serviceToInsert.getLocation().getId());
+ assertEquals(route.getEnd().getLocation().getId(),serviceToInsert.getLocation().getId());
}
private List getTourActivities(Service serviceToInsert) {
@@ -128,7 +128,7 @@ public class TestInserter {
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end
- Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(2);
@@ -164,7 +164,7 @@ public class TestInserter {
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end
- Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(2);
when(iData.getDeliveryInsertionIndex()).thenReturn(2);
@@ -176,9 +176,9 @@ public class TestInserter {
inserter.insertJob(shipmentToInsert, iData, route);
assertEquals(4,route.getTourActivities().getActivities().size());
- assertEquals(route.getTourActivities().getActivities().get(2).getLocationId(),shipmentToInsert.getPickupLocationId());
- assertEquals(route.getTourActivities().getActivities().get(3).getLocationId(),shipmentToInsert.getDeliveryLocationId());
- assertEquals(route.getEnd().getLocationId(),shipmentToInsert.getDeliveryLocationId());
+ assertEquals(route.getTourActivities().getActivities().get(2).getLocation().getId(),shipmentToInsert.getPickupLocation().getId());
+ assertEquals(route.getTourActivities().getActivities().get(3).getLocation().getId(),shipmentToInsert.getDeliveryLocation().getId());
+ assertEquals(route.getEnd().getLocation().getId(),shipmentToInsert.getDeliveryLocation().getId());
}
@Test
@@ -191,7 +191,7 @@ public class TestInserter {
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end
- Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").build();
+ Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").build();
InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(2);
@@ -203,7 +203,7 @@ public class TestInserter {
Inserter inserter = new Inserter(mock(InsertionListeners.class), vehicleRoutingProblem);
inserter.insertJob(shipmentToInsert, iData, route);
- assertEquals(route.getEnd().getLocationId(),newVehicle.getEndLocationId());
+ assertEquals(route.getEnd().getLocation().getId(),newVehicle.getEndLocationId());
}
@Test
@@ -216,7 +216,7 @@ public class TestInserter {
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end
- Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").build();
+ Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").build();
InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(2);
@@ -228,7 +228,7 @@ public class TestInserter {
Inserter inserter = new Inserter(mock(InsertionListeners.class),vehicleRoutingProblem );
inserter.insertJob(shipmentToInsert, iData, route);
- assertEquals("delLoc",route.getEnd().getLocationId());
+ assertEquals("delLoc",route.getEnd().getLocation().getId());
}
@Test
@@ -236,13 +236,13 @@ public class TestInserter {
Shipment shipment = mock(Shipment.class);
Capacity capacity = Capacity.Builder.newInstance().build();
when(shipment.getSize()).thenReturn(capacity);
- when(shipment.getDeliveryLocationId()).thenReturn("oldShipmentDelLoc");
- Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build();
- Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build();
+ when(shipment.getDeliveryLocation()).thenReturn(Location.Builder.newInstance().setId("oldShipmentDelLoc").build());
+ Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocation(Location.Builder.newInstance().setId("vehLoc").build()).setType(mock(VehicleType.class)).build();
+ Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocation(Location.Builder.newInstance().setId("newVehLoc").build()).setType(mock(VehicleType.class)).build();
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build();
//start - pick(shipment) - del(shipment) - end
- Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").build();
+ Shipment shipmentToInsert = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").build();
InsertionData iData = mock(InsertionData.class);
when(iData.getPickupInsertionIndex()).thenReturn(0);
@@ -257,7 +257,7 @@ public class TestInserter {
UpdateEndLocationIfRouteIsOpen updateEnd = new UpdateEndLocationIfRouteIsOpen();
updateEnd.visit(route);
- assertEquals("oldShipmentDelLoc",route.getEnd().getLocationId());
+ assertEquals("oldShipmentDelLoc",route.getEnd().getLocation().getId());
}
}
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/ruin/distance/AverageJobDistanceTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/ruin/distance/AverageJobDistanceTest.java
index 5fd0cbcd..35ab246b 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/ruin/distance/AverageJobDistanceTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/ruin/distance/AverageJobDistanceTest.java
@@ -16,6 +16,7 @@
******************************************************************************/
package jsprit.core.algorithm.ruin.distance;
+import jsprit.core.problem.Location;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.job.Shipment;
import jsprit.core.util.Coordinate;
@@ -52,15 +53,15 @@ public class AverageJobDistanceTest {
@Test
public void distanceOfTwoEqualShipmentsShouldBeSmallerThanAnyOtherDistance(){
- Shipment s1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("10,10").build();
- Shipment s2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("10,10").build();
+ Shipment s1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId("10,10").build();
+ Shipment s2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId("10,10").build();
double dist = new AvgServiceAndShipmentDistance(routingCosts).getDistance(s1, s2);
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
- Shipment other1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId(i + "," + j).build();
- Shipment other2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocationId("0,0").setDeliveryLocationId("10,10").build();
+ Shipment other1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId(i + "," + j).build();
+ Shipment other2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("0,0").build()).setDeliveryLocationId("10,10").build();
double dist2 = new AvgServiceAndShipmentDistance(routingCosts).getDistance(other1, other2);
System.out.println("("+i+","+j+"), dist=" + dist + ", dist2=" + dist2);
assertTrue(dist<=dist2+dist2*0.001);
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/HardPickupAndDeliveryShipmentActivityConstraintTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/state/HardPickupAndDeliveryShipmentActivityConstraintTest.java
index 01943bb6..949f1381 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/HardPickupAndDeliveryShipmentActivityConstraintTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/state/HardPickupAndDeliveryShipmentActivityConstraintTest.java
@@ -17,6 +17,7 @@
package jsprit.core.algorithm.state;
import jsprit.core.problem.Capacity;
+import jsprit.core.problem.Location;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.constraint.HardActivityConstraint.ConstraintsStatus;
import jsprit.core.problem.constraint.PickupAndDeliverShipmentLoadActivityLevelConstraint;
@@ -58,7 +59,7 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest {
public void doBefore(){
s1 = Service.Builder.newInstance("s1").setLocationId("loc").build();
s2 = Service.Builder.newInstance("s2").setLocationId("loc").build();
- shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").addSizeDimension(0,1).build();
+ shipment = Shipment.Builder.newInstance("shipment").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").addSizeDimension(0, 1).build();
// when(vehicle.getCapacity()).thenReturn(2);
diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/LoadStateTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/state/LoadStateTest.java
index 61de41b9..b95201af 100644
--- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/LoadStateTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/algorithm/state/LoadStateTest.java
@@ -17,10 +17,7 @@
package jsprit.core.algorithm.state;
-import jsprit.core.problem.AbstractActivity;
-import jsprit.core.problem.Capacity;
-import jsprit.core.problem.JobActivityFactory;
-import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.*;
import jsprit.core.problem.job.*;
import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.vehicle.Vehicle;
@@ -69,8 +66,8 @@ public class LoadStateTest {
final VehicleRoutingProblem pdProblem = pdProblemBuilder.build();
final VehicleRoutingProblem.Builder shipmentProblemBuilder = VehicleRoutingProblem.Builder.newInstance();
- Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0,10).setPickupLocationId("pick").setDeliveryLocationId("del").build();
- Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0,5).setPickupLocationId("pick").setDeliveryLocationId("del").build();
+ Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("pick").build()).setDeliveryLocationId("del").build();
+ Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 5).setPickupLocation(Location.Builder.newInstance().setId("pick").build()).setDeliveryLocationId("del").build();
shipmentProblemBuilder.addJob(shipment1).addJob(shipment2).build();
final VehicleRoutingProblem shipmentProblem = shipmentProblemBuilder.build();
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 3714687c..717d8373 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
@@ -68,9 +68,9 @@ public class SolomonSkills_IT {
for(Job job : vrp.getJobs().values()){
Service service = (Service) job;
Service.Builder skillServiceBuilder = Service.Builder.newInstance(service.getId()).setServiceTime(service.getServiceDuration())
- .setCoord(service.getCoord()).setLocationId(service.getLocationId()).setTimeWindow(service.getTimeWindow())
+ .setCoord(service.getLocation().getCoordinate()).setLocationId(service.getLocation().getId()).setTimeWindow(service.getTimeWindow())
.addSizeDimension(0,service.getSize().get(0));
- if(service.getCoord().getY()<50) skillServiceBuilder.addRequiredSkill("skill2");
+ if(service.getLocation().getCoordinate().getY()<50) skillServiceBuilder.addRequiredSkill("skill2");
else skillServiceBuilder.addRequiredSkill("skill1");
skillProblemBuilder.addJob(skillServiceBuilder.build());
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java b/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java
index 76162d30..7f9b5fd8 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java
@@ -114,8 +114,8 @@ public class VehicleRoutingProblemTest {
@Test
public void whenShipmentsAreAdded_vrpShouldContainThem(){
- Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foofoo").setDeliveryLocationId("foo").build();
- Shipment s2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 100).setPickupLocationId("foofoo").setDeliveryLocationId("foo").build();
+ Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("foofoo").build()).setDeliveryLocationId("foo").build();
+ Shipment s2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 100).setPickupLocation(Location.Builder.newInstance().setId("foofoo").build()).setDeliveryLocationId("foo").build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addJob(s);
vrpBuilder.addJob(s2);
@@ -130,8 +130,10 @@ public class VehicleRoutingProblemTest {
public void whenServicesAreAdded_vrpShouldContainThem(){
Service s1 = mock(Service.class);
when(s1.getId()).thenReturn("s1");
+ when(s1.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
Service s2 = mock(Service.class);
when(s2.getId()).thenReturn("s2");
+ when(s2.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addJob(s1).addJob(s2);
@@ -148,8 +150,10 @@ public class VehicleRoutingProblemTest {
public void whenPickupsAreAdded_vrpShouldContainThem(){
Pickup s1 = mock(Pickup.class);
when(s1.getId()).thenReturn("s1");
+ when(s1.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
Pickup s2 = mock(Pickup.class);
when(s2.getId()).thenReturn("s2");
+ when(s2.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addJob(s1).addJob(s2);
@@ -165,8 +169,10 @@ public class VehicleRoutingProblemTest {
public void whenPickupsAreAddedAllAtOnce_vrpShouldContainThem(){
Pickup s1 = mock(Pickup.class);
when(s1.getId()).thenReturn("s1");
+ when(s1.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
Pickup s2 = mock(Pickup.class);
when(s2.getId()).thenReturn("s2");
+ when(s2.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addAllJobs(Arrays.asList(s1,s2));
@@ -183,9 +189,11 @@ public class VehicleRoutingProblemTest {
Delivery s1 = mock(Delivery.class);
when(s1.getId()).thenReturn("s1");
when(s1.getSize()).thenReturn(Capacity.Builder.newInstance().build());
+ when(s1.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
Delivery s2 = mock(Delivery.class);
when(s2.getId()).thenReturn("s2");
when(s2.getSize()).thenReturn(Capacity.Builder.newInstance().build());
+ when(s2.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addJob(s1).addJob(s2);
@@ -202,9 +210,11 @@ public class VehicleRoutingProblemTest {
Delivery s1 = mock(Delivery.class);
when(s1.getId()).thenReturn("s1");
when(s1.getSize()).thenReturn(Capacity.Builder.newInstance().build());
+ when(s1.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
Delivery s2 = mock(Delivery.class);
when(s2.getId()).thenReturn("s2");
when(s2.getSize()).thenReturn(Capacity.Builder.newInstance().build());
+ when(s2.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addAllJobs(Arrays.asList(s1,s2));
@@ -220,8 +230,10 @@ public class VehicleRoutingProblemTest {
public void whenServicesAreAddedAllAtOnce_vrpShouldContainThem(){
Service s1 = mock(Service.class);
when(s1.getId()).thenReturn("s1");
+ when(s1.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
Service s2 = mock(Service.class);
when(s2.getId()).thenReturn("s2");
+ when(s2.getLocation()).thenReturn(Location.Builder.newInstance().setIndex(1).build());
Collection services = new ArrayList();
services.add(s1);
@@ -394,7 +406,7 @@ public class VehicleRoutingProblemTest {
@Test
public void whenAddingTwoJobs_theyShouldHaveProperIndeces(){
Service service = Service.Builder.newInstance("myService").setLocationId("loc").build();
- Shipment shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pick").setDeliveryLocationId("del").build();
+ Shipment shipment = Shipment.Builder.newInstance("shipment").setPickupLocation(Location.Builder.newInstance().setId("pick").build()).setDeliveryLocationId("del").build();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.addJob(service);
vrpBuilder.addJob(shipment);
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/constraint/LoadConstraintTest.java b/jsprit-core/src/test/java/jsprit/core/problem/constraint/LoadConstraintTest.java
index 80e32d2a..dfbde427 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/constraint/LoadConstraintTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/constraint/LoadConstraintTest.java
@@ -18,10 +18,7 @@
package jsprit.core.problem.constraint;
import jsprit.core.algorithm.state.StateManager;
-import jsprit.core.problem.AbstractActivity;
-import jsprit.core.problem.Capacity;
-import jsprit.core.problem.JobActivityFactory;
-import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.*;
import jsprit.core.problem.job.*;
import jsprit.core.problem.misc.JobInsertionContext;
import jsprit.core.problem.solution.route.VehicleRoute;
@@ -72,8 +69,8 @@ public class LoadConstraintTest {
final VehicleRoutingProblem pdProblem = pdProblemBuilder.build();
final VehicleRoutingProblem.Builder shipmentProblemBuilder = VehicleRoutingProblem.Builder.newInstance();
- Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0,10).setPickupLocationId("pick").setDeliveryLocationId("del").build();
- Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0,5).setPickupLocationId("pick").setDeliveryLocationId("del").build();
+ Shipment shipment1 = Shipment.Builder.newInstance("s1").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("pick").build()).setDeliveryLocationId("del").build();
+ Shipment shipment2 = Shipment.Builder.newInstance("s2").addSizeDimension(0, 5).setPickupLocation(Location.Builder.newInstance().setId("pick").build()).setDeliveryLocationId("del").build();
shipmentProblemBuilder.addJob(shipment1).addJob(shipment2).build();
final VehicleRoutingProblem shipmentProblem = shipmentProblemBuilder.build();
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLReaderTest.java b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLReaderTest.java
index 8f309677..1e3c0593 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLReaderTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLReaderTest.java
@@ -484,8 +484,8 @@ public class VrpXMLReaderTest {
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("3");
- assertEquals(10.0,s.getDeliveryCoord().getX(),0.01);
- assertEquals(0.0,s.getDeliveryCoord().getY(),0.01);
+ assertEquals(10.0,s.getDeliveryLocation().getCoordinate().getX(),0.01);
+ assertEquals(0.0,s.getDeliveryLocation().getCoordinate().getY(),0.01);
}
@Test
@@ -494,8 +494,8 @@ public class VrpXMLReaderTest {
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("3");
- assertEquals(10.0,s.getPickupCoord().getX(),0.01);
- assertEquals(10.0,s.getPickupCoord().getY(),0.01);
+ assertEquals(10.0,s.getPickupLocation().getCoordinate().getX(),0.01);
+ assertEquals(10.0,s.getPickupLocation().getCoordinate().getY(),0.01);
}
@Test
@@ -504,7 +504,7 @@ public class VrpXMLReaderTest {
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("3");
- assertEquals("i(9,9)",s.getDeliveryLocationId());
+ assertEquals("i(9,9)",s.getDeliveryLocation().getId());
}
@Test
@@ -513,7 +513,7 @@ public class VrpXMLReaderTest {
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("3");
- assertEquals("i(3,9)",s.getPickupLocationId());
+ assertEquals("i(3,9)",s.getPickupLocation().getId());
}
@Test
@@ -522,7 +522,7 @@ public class VrpXMLReaderTest {
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("4");
- assertEquals("[x=10.0][y=10.0]",s.getPickupLocationId());
+ assertEquals("[x=10.0][y=10.0]",s.getPickupLocation().getId());
}
@Test
@@ -531,7 +531,7 @@ public class VrpXMLReaderTest {
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("4");
- assertEquals("[x=10.0][y=0.0]",s.getDeliveryLocationId());
+ assertEquals("[x=10.0][y=0.0]",s.getDeliveryLocation().getId());
}
@Test
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLWriterTest.java b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLWriterTest.java
index 934d412d..6fc4b325 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLWriterTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpXMLWriterTest.java
@@ -116,7 +116,7 @@ public class VrpXMLWriterTest {
Service s1_read = (Service) vrp.getJobs().get("1");
assertEquals("1", s1_read.getId());
- assertEquals("loc", s1_read.getLocationId());
+ assertEquals("loc", s1_read.getLocation().getId());
assertEquals("service", s1_read.getType());
assertEquals(2.0,s1_read.getServiceDuration(),0.01);
}
@@ -193,9 +193,9 @@ public class VrpXMLWriterTest {
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation(Location.Builder.newInstance().setId("pickLocation").build()).setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -207,8 +207,8 @@ public class VrpXMLWriterTest {
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
assertEquals(2,readVrp.getJobs().size());
- assertEquals("pickLoc",((Shipment)readVrp.getJobs().get("1")).getPickupLocationId());
- assertEquals("delLoc",((Shipment)readVrp.getJobs().get("1")).getDeliveryLocationId());
+ assertEquals("pickLoc",((Shipment)readVrp.getJobs().get("1")).getPickupLocation().getId());
+ assertEquals("delLoc",((Shipment)readVrp.getJobs().get("1")).getDeliveryLocation().getId());
}
@@ -224,9 +224,9 @@ public class VrpXMLWriterTest {
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation(Location.Builder.newInstance().setId("pickLocation").build()).setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -256,9 +256,9 @@ public class VrpXMLWriterTest {
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation(Location.Builder.newInstance().setId("pickLocation").build()).setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -287,9 +287,9 @@ public class VrpXMLWriterTest {
builder.addVehicle(v1);
builder.addVehicle(v2);
- Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
+ Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation(Location.Builder.newInstance().setId("pickLocation").build()).setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -320,7 +320,7 @@ public class VrpXMLWriterTest {
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation(Location.Builder.newInstance().setId("pickLocation").build()).setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -332,7 +332,7 @@ public class VrpXMLWriterTest {
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
assertEquals(2,readVrp.getJobs().size());
- assertEquals("[x=1.0][y=2.0]",((Shipment)readVrp.getJobs().get("1")).getPickupLocationId());
+ assertEquals("[x=1.0][y=2.0]",((Shipment)readVrp.getJobs().get("1")).getPickupLocation().getId());
}
@Test
@@ -518,7 +518,7 @@ public class VrpXMLWriterTest {
Shipment s1 = Shipment.Builder.newInstance("1").addSizeDimension(0, 10).setPickupCoord(Coordinate.newInstance(1, 2)).setDeliveryCoord(Coordinate.newInstance(5, 6)).setDeliveryLocationId("delLoc").setPickupTimeWindow(TimeWindow.newInstance(1, 2))
.setDeliveryTimeWindow(TimeWindow.newInstance(3, 4)).setPickupServiceTime(100).setDeliveryServiceTime(50).build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation(Location.Builder.newInstance().setId("pickLocation").build()).setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
@@ -530,11 +530,11 @@ public class VrpXMLWriterTest {
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
assertEquals(2,readVrp.getJobs().size());
- assertEquals(1.0,((Shipment)readVrp.getJobs().get("1")).getPickupCoord().getX(),0.01);
- assertEquals(2.0,((Shipment)readVrp.getJobs().get("1")).getPickupCoord().getY(),0.01);
+ assertEquals(1.0,((Shipment)readVrp.getJobs().get("1")).getPickupLocation().getCoordinate().getX(),0.01);
+ assertEquals(2.0,((Shipment)readVrp.getJobs().get("1")).getPickupLocation().getCoordinate().getY(),0.01);
- assertEquals(5.0,((Shipment)readVrp.getJobs().get("1")).getDeliveryCoord().getX(),0.01);
- assertEquals(6.0,((Shipment)readVrp.getJobs().get("1")).getDeliveryCoord().getY(),0.01);
+ assertEquals(5.0,((Shipment)readVrp.getJobs().get("1")).getDeliveryLocation().getCoordinate().getX(),0.01);
+ assertEquals(6.0,((Shipment)readVrp.getJobs().get("1")).getDeliveryLocation().getCoordinate().getY(),0.01);
}
@Test
@@ -548,7 +548,7 @@ public class VrpXMLWriterTest {
.addSizeDimension(2, 100)
.build();
- Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocationId("pickLocation").setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
+ Shipment s2 = Shipment.Builder.newInstance("2").addSizeDimension(0, 20).setPickupLocation(Location.Builder.newInstance().setId("pickLocation").build()).setDeliveryLocationId("delLocation").setPickupTimeWindow(TimeWindow.newInstance(5, 6))
.setDeliveryTimeWindow(TimeWindow.newInstance(7, 8)).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/job/ServiceTest.java b/jsprit-core/src/test/java/jsprit/core/problem/job/ServiceTest.java
index 7e17913d..3c08c373 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/job/ServiceTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/job/ServiceTest.java
@@ -102,14 +102,14 @@ public class ServiceTest {
@Test
public void whenSettingLocation_itShouldBeSetCorrectly(){
Service s = Service.Builder.newInstance("s").setLocationId("loc").build();
- assertEquals("loc",s.getLocationId());
+ assertEquals("loc",s.getLocation().getId());
assertEquals("loc",s.getLocation().getId());
}
@Test
public void whenSettingLocation_itShouldWork(){
Service s = Service.Builder.newInstance("s").setLocation(Location.Builder.newInstance().setId("loc").build()).build();
- assertEquals("loc",s.getLocationId());
+ assertEquals("loc",s.getLocation().getId());
assertEquals("loc",s.getLocation().getId());
}
@@ -117,8 +117,8 @@ public class ServiceTest {
@Test
public void whenSettingLocationCoord_itShouldBeSetCorrectly(){
Service s = Service.Builder.newInstance("s").setCoord(Coordinate.newInstance(1, 2)).build();
- assertEquals(1.0,s.getCoord().getX(),0.01);
- assertEquals(2.0,s.getCoord().getY(),0.01);
+ assertEquals(1.0,s.getLocation().getCoordinate().getX(),0.01);
+ assertEquals(2.0,s.getLocation().getCoordinate().getY(),0.01);
assertEquals(1.0,s.getLocation().getCoordinate().getX(),0.01);
assertEquals(2.0,s.getLocation().getCoordinate().getY(),0.01);
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/job/ShipmentTest.java b/jsprit-core/src/test/java/jsprit/core/problem/job/ShipmentTest.java
index 4dff6e49..4ed9a11f 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/job/ShipmentTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/job/ShipmentTest.java
@@ -27,9 +27,9 @@ public class ShipmentTest {
@Test
public void whenTwoShipmentsHaveTheSameId_theyReferencesShouldBeUnEqual(){
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("foo").build()).
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
- Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("foo").build()).
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
assertTrue(one != two);
@@ -37,9 +37,9 @@ public class ShipmentTest {
@Test
public void whenTwoShipmentsHaveTheSameId_theyShouldBeEqual(){
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("foo").build()).
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
- Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ Shipment two = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("foo").build()).
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
assertTrue(one.equals(two));
@@ -47,7 +47,7 @@ public class ShipmentTest {
@Test
public void whenShipmentIsInstantiatedWithASizeOf10_theSizeShouldBe10(){
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocationId("foo").
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("foo").build()).
setDeliveryLocationId("foofoo").setPickupServiceTime(10).setDeliveryServiceTime(20).build();
assertEquals(10,one.getSize().get(0));
}
@@ -55,19 +55,19 @@ public class ShipmentTest {
@Test(expected=IllegalArgumentException.class)
public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocationId("foo").setDeliveryLocationId("foofoo").build();
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocation(Location.Builder.newInstance().setId("foo").build()).setDeliveryLocationId("foofoo").build();
}
@Test(expected=IllegalArgumentException.class)
public void whenShipmentIsBuiltWithNegativeDemand_itShouldThrowException_v2(){
@SuppressWarnings("unused")
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocationId("foo").setDeliveryLocationId("foofoo").build();
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, -10).setPickupLocation(Location.Builder.newInstance().setId("foo").build()).setDeliveryLocationId("foofoo").build();
}
@Test(expected=IllegalArgumentException.class)
public void whenIdIsNull_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment one = Shipment.Builder.newInstance(null).addSizeDimension(0, 10).setPickupLocationId("foo").setDeliveryLocationId("foofoo").build();
+ Shipment one = Shipment.Builder.newInstance(null).addSizeDimension(0, 10).setPickupLocation(Location.Builder.newInstance().setId("foo").build()).setDeliveryLocationId("foofoo").build();
}
@Test
@@ -85,27 +85,27 @@ public class ShipmentTest {
@Test(expected=IllegalStateException.class)
public void whenNeitherDeliveryLocationIdNorDeliveryCoord_itThrowsException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
}
@Test
public void whenPickupLocationIdIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
- assertEquals("pickLoc",s.getPickupLocationId());
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
+ assertEquals("pickLoc",s.getPickupLocation().getId());
assertEquals("pickLoc",s.getPickupLocation().getId());
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected=IllegalStateException.class)
public void whenPickupLocationIsNull_itThrowsException(){
@SuppressWarnings("unused")
- Shipment.Builder builder = Shipment.Builder.newInstance("s").setPickupLocationId(null);
+ Shipment.Builder builder = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId(null).build());
}
@Test
public void whenPickupCoordIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").setPickupCoord(Coordinate.newInstance(1, 2)).build();
- assertEquals(1.0,s.getPickupCoord().getX(),0.01);
- assertEquals(2.0,s.getPickupCoord().getY(),0.01);
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").setCoordinate(Coordinate.newInstance(1, 2)).build()).build();
+ assertEquals(1.0,s.getPickupLocation().getCoordinate().getX(),0.01);
+ assertEquals(2.0,s.getPickupLocation().getCoordinate().getY(),0.01);
assertEquals(1.0,s.getPickupLocation().getCoordinate().getX(),0.01);
assertEquals(2.0,s.getPickupLocation().getCoordinate().getY(),0.01);
}
@@ -118,8 +118,8 @@ public class ShipmentTest {
@Test
public void whenDeliveryLocationIdIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
- assertEquals("delLoc",s.getDeliveryLocationId());
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
+ assertEquals("delLoc",s.getDeliveryLocation().getId());
assertEquals("delLoc",s.getDeliveryLocation().getId());
}
@@ -131,9 +131,9 @@ public class ShipmentTest {
@Test
public void whenDeliveryCoordIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").setDeliveryCoord(Coordinate.newInstance(1, 2)).build();
- assertEquals(1.0,s.getDeliveryCoord().getX(),0.01);
- assertEquals(2.0,s.getDeliveryCoord().getY(),0.01);
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryCoord(Coordinate.newInstance(1, 2)).build();
+ assertEquals(1.0,s.getDeliveryLocation().getCoordinate().getX(),0.01);
+ assertEquals(2.0,s.getDeliveryLocation().getCoordinate().getY(),0.01);
assertEquals(1.0,s.getDeliveryLocation().getCoordinate().getX(),0.01);
assertEquals(2.0,s.getDeliveryLocation().getCoordinate().getY(),0.01);
}
@@ -146,43 +146,43 @@ public class ShipmentTest {
@Test
public void whenPickupServiceTimeIsNotSet_itShouldBeZero(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
assertEquals(0.0,s.getPickupServiceTime(),0.01);
}
@Test
public void whenDeliveryServiceTimeIsNotSet_itShouldBeZero(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
assertEquals(0.0,s.getDeliveryServiceTime(),0.01);
}
@Test
public void whenPickupServiceTimeIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(2.0).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
assertEquals(2.0,s.getPickupServiceTime(),0.01);
}
@Test(expected=IllegalArgumentException.class)
public void whenPickupServiceIsSmallerThanZero_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(-2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupServiceTime(-2.0).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
}
@Test
public void whenDeliveryServiceTimeIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(2.0).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
assertEquals(2.0,s.getDeliveryServiceTime(),0.01);
}
@Test(expected=IllegalArgumentException.class)
public void whenDeliveryServiceIsSmallerThanZero_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(-2.0).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryServiceTime(-2.0).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
}
@Test
public void whenPickupTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
assertEquals(0.0,s.getPickupTimeWindow().getStart(),0.01);
assertEquals(Double.MAX_VALUE,s.getPickupTimeWindow().getEnd(),0.01);
}
@@ -190,19 +190,19 @@ public class ShipmentTest {
@Test(expected=IllegalArgumentException.class)
public void whenPickupTimeWindowIsNull_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(null).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(null).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
}
@Test
public void whenPickupTimeWindowIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setPickupTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
assertEquals(1.0,s.getPickupTimeWindow().getStart(),0.01);
assertEquals(2.0,s.getPickupTimeWindow().getEnd(),0.01);
}
@Test
public void whenDeliveryTimeWindowIsNotSet_itShouldBeTheDefaultOne(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
assertEquals(0.0,s.getDeliveryTimeWindow().getStart(),0.01);
assertEquals(Double.MAX_VALUE,s.getDeliveryTimeWindow().getEnd(),0.01);
}
@@ -210,12 +210,12 @@ public class ShipmentTest {
@Test(expected=IllegalArgumentException.class)
public void whenDeliveryTimeWindowIsNull_itShouldThrowException(){
@SuppressWarnings("unused")
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(null).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(null).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
}
@Test
public void whenDeliveryTimeWindowIsSet_itShouldBeDoneCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").setDeliveryTimeWindow(TimeWindow.newInstance(1, 2)).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
assertEquals(1.0,s.getDeliveryTimeWindow().getStart(),0.01);
assertEquals(2.0,s.getDeliveryTimeWindow().getEnd(),0.01);
}
@@ -223,23 +223,23 @@ public class ShipmentTest {
@Test(expected=IllegalArgumentException.class)
public void whenShipmentHasNegativeCapacityVal_throwIllegalStateExpception(){
@SuppressWarnings("unused")
- Shipment one = Shipment.Builder.newInstance("s").setPickupLocationId("foo").setDeliveryLocationId("foofoo")
+ Shipment one = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("foo").build()).setDeliveryLocationId("foofoo")
.addSizeDimension(0, -2)
.build();
}
@Test
public void whenAddingTwoCapDimension_nuOfDimsShouldBeTwo(){
- Shipment one = Shipment.Builder.newInstance("s").setPickupLocationId("foo").setDeliveryLocationId("foofoo")
+ Shipment one = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("foo").build()).setDeliveryLocationId("foofoo")
.addSizeDimension(0,2)
- .addSizeDimension(1,4)
+ .addSizeDimension(1, 4)
.build();
assertEquals(2,one.getSize().getNuOfDimensions());
}
@Test
public void whenShipmentIsBuiltWithoutSpecifyingCapacity_itShouldHvCapWithOneDimAndDimValOfZero(){
- Shipment one = Shipment.Builder.newInstance("s").setPickupLocationId("foo").setPickupCoord(Coordinate.newInstance(0, 0))
+ Shipment one = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("foo").build()).setPickupCoord(Coordinate.newInstance(0, 0))
.setDeliveryLocationId("foofoo").build();
assertEquals(1,one.getSize().getNuOfDimensions());
assertEquals(0,one.getSize().get(0));
@@ -247,7 +247,7 @@ public class ShipmentTest {
@Test
public void whenShipmentIsBuiltWithConstructorWhereSizeIsSpecified_capacityShouldBeSetCorrectly(){
- Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocationId("foo").setPickupCoord(Coordinate.newInstance(0, 0))
+ Shipment one = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setPickupLocation(Location.Builder.newInstance().setId("foo").build()).setPickupCoord(Coordinate.newInstance(0, 0))
.setDeliveryLocationId("foofoo").build();
assertEquals(1,one.getSize().getNuOfDimensions());
assertEquals(1,one.getSize().get(0));
@@ -255,7 +255,7 @@ public class ShipmentTest {
@Test
public void whenAddingSkills_theyShouldBeAddedCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("loc").setDeliveryLocationId("delLoc")
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("loc").build()).setDeliveryLocationId("delLoc")
.addRequiredSkill("drill").addRequiredSkill("screwdriver").build();
assertTrue(s.getRequiredSkills().containsSkill("drill"));
assertTrue(s.getRequiredSkills().containsSkill("drill"));
@@ -264,7 +264,7 @@ public class ShipmentTest {
@Test
public void whenAddingSkillsCaseSens_theyShouldBeAddedCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("pick").setDeliveryLocationId("del")
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pick").build()).setDeliveryLocationId("del")
.addRequiredSkill("DriLl").addRequiredSkill("screwDriver").build();
assertTrue(s.getRequiredSkills().containsSkill("drill"));
assertTrue(s.getRequiredSkills().containsSkill("drilL"));
@@ -272,7 +272,7 @@ public class ShipmentTest {
@Test
public void whenAddingSkillsCaseSensV2_theyShouldBeAddedCorrectly(){
- Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("loc").setDeliveryLocationId("del")
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("loc").build()).setDeliveryLocationId("del")
.addRequiredSkill("screwDriver").build();
assertFalse(s.getRequiredSkills().containsSkill("drill"));
assertFalse(s.getRequiredSkills().containsSkill("drilL"));
@@ -280,7 +280,7 @@ public class ShipmentTest {
@Test
public void nameShouldBeAssigned(){
- Shipment s = Shipment.Builder.newInstance("s").setPickupLocationId("loc").setDeliveryLocationId("del")
+ Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("loc").build()).setDeliveryLocationId("del")
.setName("name").build();
assertEquals("name",s.getName());
}
@@ -289,9 +289,9 @@ public class ShipmentTest {
public void whenSettingLocation_itShouldWork(){
Shipment s = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("loc").build())
.setDeliveryLocation(Location.Builder.newInstance().setId("del").build()).build();
- assertEquals("loc", s.getPickupLocationId());
+ assertEquals("loc", s.getPickupLocation().getId());
assertEquals("loc", s.getPickupLocation().getId());
assertEquals("del",s.getDeliveryLocation().getId());
- assertEquals("del",s.getDeliveryLocationId());
+ assertEquals("del",s.getDeliveryLocation().getId());
}
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java
index 3b0c9c70..4e3f1f44 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java
@@ -147,7 +147,7 @@ public class TestVehicleRoute {
while(iter.hasNext()){
TourActivity act = iter.next();
if(count==0) {
- assertEquals("2",act.getLocationId());
+ assertEquals("2",act.getLocation().getId());
}
count++;
}
@@ -159,7 +159,7 @@ public class TestVehicleRoute {
while(secondIter.hasNext()){
TourActivity act = secondIter.next();
if(count==0) {
- assertEquals("2",act.getLocationId());
+ assertEquals("2",act.getLocation().getId());
}
count++;
}
@@ -171,42 +171,42 @@ public class TestVehicleRoute {
public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectStartLocation(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
- assertTrue(vRoute.getStart().getLocationId().equals("start"));
+ assertTrue(vRoute.getStart().getLocation().getId().equals("start"));
}
@Test
public void whenBuildingRouteWithVehicleThatHasDifferentStartAndEndLocation_routeMustHaveCorrectEndLocation(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
- assertTrue(vRoute.getEnd().getLocationId().equals("end"));
+ assertTrue(vRoute.getEnd().getLocation().getId().equals("end"));
}
@Test
public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectStartLocation(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
- assertTrue(vRoute.getStart().getLocationId().equals("start"));
+ assertTrue(vRoute.getStart().getLocation().getId().equals("start"));
}
@Test
public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectEndLocation(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
- assertTrue(vRoute.getEnd().getLocationId().equals("start"));
+ assertTrue(vRoute.getEnd().getLocation().getId().equals("start"));
}
@Test
public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectStartLocationV2(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
- assertTrue(vRoute.getStart().getLocationId().equals("start"));
+ assertTrue(vRoute.getStart().getLocation().getId().equals("start"));
}
@Test
public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectEndLocationV2(){
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
- assertTrue(vRoute.getEnd().getLocationId().equals("start"));
+ assertTrue(vRoute.getEnd().getLocation().getId().equals("start"));
}
@Test
@@ -264,7 +264,7 @@ public class TestVehicleRoute {
Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
vRoute.setVehicleAndDepartureTime(new_vehicle, 50.0);
- assertEquals("new_start",vRoute.getStart().getLocationId());
+ assertEquals("new_start",vRoute.getStart().getLocation().getId());
}
@Test
@@ -273,7 +273,7 @@ public class TestVehicleRoute {
Vehicle new_vehicle = VehicleImpl.Builder.newInstance("new_v").setEarliestStart(1000).setLatestArrival(2000).setStartLocationId("new_start").setEndLocationId("new_end").build();
VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build();
vRoute.setVehicleAndDepartureTime(new_vehicle, 50.0);
- assertEquals("new_end",vRoute.getEnd().getLocationId());
+ assertEquals("new_end",vRoute.getEnd().getLocation().getId());
}
@Test
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 563463a7..1b14086a 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
@@ -104,7 +104,7 @@ public class VehicleRouteBuilderTest {
builder.addDelivery(s);
builder.addDelivery(s2);
VehicleRoute route = builder.build();
- assertEquals("vehLoc",route.getEnd().getLocationId());
+ assertEquals("vehLoc",route.getEnd().getLocation().getId());
}
@Test
@@ -124,7 +124,7 @@ public class VehicleRouteBuilderTest {
builder.addDelivery(s);
builder.addDelivery(s2);
VehicleRoute route = builder.build();
- assertEquals(route.getEnd().getLocationId(), s2.getDeliveryLocation().getId());
+ assertEquals(route.getEnd().getLocation().getId(), s2.getDeliveryLocation().getId());
}
private Location loc(String delLoc) {
@@ -138,10 +138,10 @@ public class VehicleRouteBuilderTest {
Capacity capacity = Capacity.Builder.newInstance().build();
when(s.getSize()).thenReturn(capacity);
when(s2.getSize()).thenReturn(capacity);
- when(s2.getDeliveryLocationId()).thenReturn("delLoc");
+ when(s2.getDeliveryLocation()).thenReturn(Location.Builder.newInstance().setId("delLoc").build());
Vehicle vehicle = mock(Vehicle.class);
when(vehicle.isReturnToDepot()).thenReturn(false);
- when(vehicle.getStartLocationId()).thenReturn("vehLoc");
+ when(vehicle.getStartLocation()).thenReturn(Location.Builder.newInstance().setId("vehLoc").build());
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class));
builder.addPickup(s);
builder.addPickup(s2);
@@ -161,10 +161,10 @@ public class VehicleRouteBuilderTest {
Capacity capacity = Capacity.Builder.newInstance().build();
when(s.getSize()).thenReturn(capacity);
when(s2.getSize()).thenReturn(capacity);
- when(s2.getDeliveryLocationId()).thenReturn("delLoc");
+ when(s2.getDeliveryLocation()).thenReturn(Location.Builder.newInstance().setId("delLoc").build());
Vehicle vehicle = mock(Vehicle.class);
when(vehicle.isReturnToDepot()).thenReturn(false);
- when(vehicle.getStartLocationId()).thenReturn("vehLoc");
+ when(vehicle.getStartLocation()).thenReturn(Location.Builder.newInstance().setId("vehLoc").build());
when(vehicle.getLatestArrival()).thenReturn(200.0);
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class));
builder.addPickup(s);
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DefaultShipmentActivityFactoryTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DefaultShipmentActivityFactoryTest.java
index 5e1a26db..630a370f 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DefaultShipmentActivityFactoryTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DefaultShipmentActivityFactoryTest.java
@@ -16,6 +16,7 @@
******************************************************************************/
package jsprit.core.problem.solution.route.activity;
+import jsprit.core.problem.Location;
import jsprit.core.problem.job.Shipment;
import org.junit.Test;
@@ -28,7 +29,7 @@ public class DefaultShipmentActivityFactoryTest {
public void whenCreatingPickupActivityWithShipment_itShouldReturnPickupShipment(){
DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory();
Shipment shipment = Shipment.Builder.newInstance("s")
- .setPickupLocationId("pLoc").setDeliveryLocationId("dLoc").build();
+ .setPickupLocation(Location.Builder.newInstance().setId("pLoc").build()).setDeliveryLocationId("dLoc").build();
TourActivity act = factory.createPickup(shipment);
assertNotNull(act);
assertTrue(act instanceof PickupShipment);
@@ -38,7 +39,7 @@ public class DefaultShipmentActivityFactoryTest {
public void whenCreatingDeliverActivityWithShipment_itShouldReturnDeliverShipment(){
DefaultShipmentActivityFactory factory = new DefaultShipmentActivityFactory();
Shipment shipment = Shipment.Builder.newInstance("s")
- .setPickupLocationId("pLoc").setDeliveryLocationId("dLoc").build();
+ .setPickupLocation(Location.Builder.newInstance().setId("pLoc").build()).setDeliveryLocationId("dLoc").build();
TourActivity act = factory.createDelivery(shipment);
assertNotNull(act);
assertTrue(act instanceof DeliverShipment);
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverServiceTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverServiceTest.java
index 4af06826..59457f3d 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverServiceTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverServiceTest.java
@@ -1,30 +1,28 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * 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
+ * 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
+ * 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 .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.problem.solution.route.activity;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import jsprit.core.problem.job.Delivery;
-
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class DeliverServiceTest {
private Delivery service;
@@ -70,7 +68,7 @@ public class DeliverServiceTest {
@Test
public void whenIniLocationId_itShouldBeSetCorrectly(){
- assertEquals("loc",deliver.getLocationId());
+ assertEquals("loc",deliver.getLocation().getId());
}
@Test
@@ -78,7 +76,7 @@ public class DeliverServiceTest {
DeliverService copy = (DeliverService) deliver.duplicate();
assertEquals(1.,copy.getTheoreticalEarliestOperationStartTime(),0.01);
assertEquals(2.,copy.getTheoreticalLatestOperationStartTime(),0.01);
- assertEquals("loc",copy.getLocationId());
+ assertEquals("loc",copy.getLocation().getId());
assertEquals(-10,copy.getSize().get(0));
assertEquals(-100,copy.getSize().get(1));
assertEquals(-1000,copy.getSize().get(2));
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverShipmentTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverShipmentTest.java
index d0b58f81..c5ab5d79 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverShipmentTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/DeliverShipmentTest.java
@@ -16,6 +16,7 @@
******************************************************************************/
package jsprit.core.problem.solution.route.activity;
+import jsprit.core.problem.Location;
import jsprit.core.problem.job.Shipment;
import org.junit.Before;
import org.junit.Test;
@@ -31,11 +32,11 @@ public class DeliverShipmentTest {
@Before
public void doBefore(){
- shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pickupLoc")
- .setDeliveryLocationId("deliveryLoc")
- .setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
- .setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
- .addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
+ shipment = Shipment.Builder.newInstance("shipment").setPickupLocation(Location.Builder.newInstance().setId("pickupLoc").build())
+ .setDeliveryLocationId("deliveryLoc")
+ .setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
+ .setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
+ .addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
deliver = new DeliverShipment(shipment);
}
@@ -70,7 +71,7 @@ public class DeliverShipmentTest {
@Test
public void whenIniLocationId_itShouldBeSetCorrectly(){
- assertEquals("deliveryLoc",deliver.getLocationId());
+ assertEquals("deliveryLoc",deliver.getLocation().getId());
}
@Test
@@ -78,7 +79,7 @@ public class DeliverShipmentTest {
DeliverShipment copy = (DeliverShipment) deliver.duplicate();
assertEquals(3.,copy.getTheoreticalEarliestOperationStartTime(),0.01);
assertEquals(4.,copy.getTheoreticalLatestOperationStartTime(),0.01);
- assertEquals("deliveryLoc",copy.getLocationId());
+ assertEquals("deliveryLoc",copy.getLocation().getId());
assertEquals(-10,copy.getSize().get(0));
assertEquals(-100,copy.getSize().get(1));
assertEquals(-1000,copy.getSize().get(2));
@@ -88,8 +89,8 @@ public class DeliverShipmentTest {
@Test
public void whenGettingCapacity_itShouldReturnItCorrectly(){
- Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc")
- .addSizeDimension(0, 10).addSizeDimension(1, 100).build();
+ Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc")
+ .addSizeDimension(0, 10).addSizeDimension(1, 100).build();
PickupShipment pick = new PickupShipment(shipment);
assertEquals(10,pick.getSize().get(0));
assertEquals(100,pick.getSize().get(1));
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/EndTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/EndTest.java
index 4b5c7263..717002f8 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/EndTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/EndTest.java
@@ -1,28 +1,26 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * 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
+ * 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
+ * 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 .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.problem.solution.route.activity;
+import org.junit.Test;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-
public class EndTest {
@Test
@@ -54,7 +52,7 @@ public class EndTest {
public void whenSettingLocationId_itShouldBeSetCorrectly(){
End end = End.newInstance("loc", 1., 2.);
end.setLocationId("newLoc");
- assertEquals("newLoc",end.getLocationId());
+ assertEquals("newLoc",end.getLocation().getId());
}
@Test
@@ -80,7 +78,7 @@ public class EndTest {
End copy = End.copyOf(end);
assertEquals(3.,copy.getTheoreticalEarliestOperationStartTime(),0.01);
assertEquals(5.,copy.getTheoreticalLatestOperationStartTime(),0.01);
- assertEquals("loc",copy.getLocationId());
+ assertEquals("loc",copy.getLocation().getId());
assertTrue(copy!=end);
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupServiceTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupServiceTest.java
index a89c09a9..d39de756 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupServiceTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupServiceTest.java
@@ -1,30 +1,28 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * 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
+ * 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
+ * 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 .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.problem.solution.route.activity;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import jsprit.core.problem.job.Service;
-
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class PickupServiceTest {
private Service service;
@@ -71,7 +69,7 @@ public class PickupServiceTest {
@Test
public void whenIniLocationId_itShouldBeSetCorrectly(){
- assertEquals("loc",pickup.getLocationId());
+ assertEquals("loc",pickup.getLocation().getId());
}
@Test
@@ -79,7 +77,7 @@ public class PickupServiceTest {
PickupService copy = (PickupService) pickup.duplicate();
assertEquals(1.,copy.getTheoreticalEarliestOperationStartTime(),0.01);
assertEquals(2.,copy.getTheoreticalLatestOperationStartTime(),0.01);
- assertEquals("loc",copy.getLocationId());
+ assertEquals("loc",copy.getLocation().getId());
assertEquals(10,copy.getSize().get(0));
assertEquals(100,copy.getSize().get(1));
assertEquals(1000,copy.getSize().get(2));
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupShipmentTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupShipmentTest.java
index 318b1eb0..46d12a6e 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupShipmentTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/PickupShipmentTest.java
@@ -16,6 +16,7 @@
******************************************************************************/
package jsprit.core.problem.solution.route.activity;
+import jsprit.core.problem.Location;
import jsprit.core.problem.job.Shipment;
import org.junit.Before;
import org.junit.Test;
@@ -31,11 +32,11 @@ public class PickupShipmentTest {
@Before
public void doBefore(){
- shipment = Shipment.Builder.newInstance("shipment").setPickupLocationId("pickupLoc")
- .setDeliveryLocationId("deliveryLoc")
- .setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
- .setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
- .addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
+ shipment = Shipment.Builder.newInstance("shipment").setPickupLocation(Location.Builder.newInstance().setId("pickupLoc").build())
+ .setDeliveryLocationId("deliveryLoc")
+ .setPickupTimeWindow(TimeWindow.newInstance(1., 2.))
+ .setDeliveryTimeWindow(TimeWindow.newInstance(3., 4.))
+ .addSizeDimension(0, 10).addSizeDimension(1, 100).addSizeDimension(2, 1000).build();
pickup = new PickupShipment(shipment);
}
@@ -70,7 +71,7 @@ public class PickupShipmentTest {
@Test
public void whenIniLocationId_itShouldBeSetCorrectly(){
- assertEquals("pickupLoc",pickup.getLocationId());
+ assertEquals("pickupLoc",pickup.getLocation().getId());
}
@Test
@@ -78,7 +79,7 @@ public class PickupShipmentTest {
PickupShipment copy = (PickupShipment) pickup.duplicate();
assertEquals(1.,copy.getTheoreticalEarliestOperationStartTime(),0.01);
assertEquals(2.,copy.getTheoreticalLatestOperationStartTime(),0.01);
- assertEquals("pickupLoc",copy.getLocationId());
+ assertEquals("pickupLoc",copy.getLocation().getId());
assertEquals(10,copy.getSize().get(0));
assertEquals(100,copy.getSize().get(1));
assertEquals(1000,copy.getSize().get(2));
@@ -88,8 +89,8 @@ public class PickupShipmentTest {
@Test
public void whenGettingCapacity_itShouldReturnItCorrectly(){
- Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocationId("pickLoc").setDeliveryLocationId("delLoc")
- .addSizeDimension(0, 10).addSizeDimension(1, 100).build();
+ Shipment shipment = Shipment.Builder.newInstance("s").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).setDeliveryLocationId("delLoc")
+ .addSizeDimension(0, 10).addSizeDimension(1, 100).build();
PickupShipment pick = new PickupShipment(shipment);
assertEquals(10,pick.getSize().get(0));
assertEquals(100,pick.getSize().get(1));
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/ServiceActivityTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/ServiceActivityTest.java
index 84e7c6c2..ea4c206a 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/ServiceActivityTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/ServiceActivityTest.java
@@ -1,30 +1,27 @@
/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
+ * 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
+ * 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.problem.solution.route.activity;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import jsprit.core.problem.job.Service;
-import jsprit.core.problem.solution.route.activity.ServiceActivity;
-
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class ServiceActivityTest {
@@ -72,7 +69,7 @@ public class ServiceActivityTest {
@Test
public void whenIniLocationId_itShouldBeSetCorrectly(){
- assertEquals("loc",serviceActivity.getLocationId());
+ assertEquals("loc",serviceActivity.getLocation().getId());
}
@Test
@@ -80,7 +77,7 @@ public class ServiceActivityTest {
ServiceActivity copy = (ServiceActivity) serviceActivity.duplicate();
assertEquals(1.,copy.getTheoreticalEarliestOperationStartTime(),0.01);
assertEquals(2.,copy.getTheoreticalLatestOperationStartTime(),0.01);
- assertEquals("loc",copy.getLocationId());
+ assertEquals("loc",copy.getLocation().getId());
assertTrue(copy!=serviceActivity);
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/StartTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/StartTest.java
index eea9e492..ceb92e12 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/StartTest.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/StartTest.java
@@ -1,27 +1,26 @@
/*******************************************************************************
- * Copyright (c) 2014 Stefan Schroeder.
- *
+ * 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
+ * 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
+ * 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 .
- *
- * Contributors:
- * Stefan Schroeder - initial API and implementation
******************************************************************************/
package jsprit.core.problem.solution.route.activity;
-import static org.junit.Assert.*;
-
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class StartTest {
@Test
@@ -53,7 +52,7 @@ public class StartTest {
public void whenSettingLocationId_itShouldBeSetCorrectly(){
Start start = Start.newInstance("loc", 1., 2.);
start.setLocationId("newLoc");
- assertEquals("newLoc",start.getLocationId());
+ assertEquals("newLoc",start.getLocation().getId());
}
@Test
@@ -79,7 +78,7 @@ public class StartTest {
Start copy = Start.copyOf(start);
assertEquals(3.,copy.getTheoreticalEarliestOperationStartTime(),0.01);
assertEquals(5.,copy.getTheoreticalLatestOperationStartTime(),0.01);
- assertEquals("loc",copy.getLocationId());
+ assertEquals("loc",copy.getLocation().getId());
assertTrue(copy!=start);
}
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestRefs.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestRefs.java
index 2da47c4f..92c17f6d 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestRefs.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestRefs.java
@@ -1,29 +1,27 @@
/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
+ * 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
+ * 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.problem.solution.route.activity;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-import jsprit.core.problem.solution.route.activity.Start;
-
-import org.junit.Test;
+import static org.junit.Assert.assertTrue;
public class TestRefs {
@@ -36,8 +34,8 @@ public class TestRefs {
doSmth(starts);
- assertTrue(starts.get(0).getLocationId().startsWith("foo"));
- assertTrue(starts.get(1).getLocationId().startsWith("foo"));
+ assertTrue(starts.get(0).getLocation().getId().startsWith("foo"));
+ assertTrue(starts.get(1).getLocation().getId().startsWith("foo"));
}
private void doSmth(List starts) {
diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestTourActivities.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestTourActivities.java
index e8bfad99..567ab157 100644
--- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestTourActivities.java
+++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/activity/TestTourActivities.java
@@ -16,6 +16,7 @@
******************************************************************************/
package jsprit.core.problem.solution.route.activity;
+import jsprit.core.problem.Location;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.job.Shipment;
import org.junit.Before;
@@ -75,7 +76,7 @@ public class TestTourActivities {
@Test
public void whenAddingAShipmentActivity_tourShouldServeShipment(){
- Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s);
@@ -89,7 +90,7 @@ public class TestTourActivities {
@Test
public void whenRemovingShipment_tourShouldNotServiceItAnymore(){
- Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s);
@@ -103,7 +104,7 @@ public class TestTourActivities {
@Test
public void whenRemovingShipment_theirCorrespondingActivitiesShouldBeRemoved(){
- Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s);
@@ -144,7 +145,7 @@ public class TestTourActivities {
@Test
public void removingShipmentActivityShouldWork(){
- Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s);
@@ -169,7 +170,7 @@ public class TestTourActivities {
@Test
public void whenCopyingShipmentActivitySeq_jobSizeShouldBeCorrect(){
- Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s);
@@ -189,7 +190,7 @@ public class TestTourActivities {
@Test
public void whenCopyingShipmentActivitySeq_noActivitiesShouldBeCorrect(){
- Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s);
@@ -209,7 +210,7 @@ public class TestTourActivities {
@Test
public void whenCopyingShipmentActivitySeq_itShouldContaintPickupAct(){
- Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocationId("pickLoc").build();
+ Shipment s = Shipment.Builder.newInstance("s").addSizeDimension(0, 1).setDeliveryLocationId("delLoc").setPickupLocation(Location.Builder.newInstance().setId("pickLoc").build()).build();
TourShipmentActivityFactory fac = new DefaultShipmentActivityFactory();
TourActivity pickupShipment = fac.createPickup(s);
TourActivity deliverShipment = fac.createDelivery(s);
diff --git a/jsprit-examples/src/main/java/jsprit/examples/AdditionalDistanceConstraintExample.java b/jsprit-examples/src/main/java/jsprit/examples/AdditionalDistanceConstraintExample.java
index 51335206..6571f30f 100644
--- a/jsprit-examples/src/main/java/jsprit/examples/AdditionalDistanceConstraintExample.java
+++ b/jsprit-examples/src/main/java/jsprit/examples/AdditionalDistanceConstraintExample.java
@@ -89,7 +89,7 @@ public class AdditionalDistanceConstraintExample {
}
double getDistance(TourActivity from, TourActivity to){
- return costMatrix.getDistance(from.getLocationId(), to.getLocationId());
+ return costMatrix.getDistance(from.getLocation().getId(), to.getLocation().getId());
}
}
@@ -125,7 +125,7 @@ public class AdditionalDistanceConstraintExample {
}
double getDistance(TourActivity from, TourActivity to){
- return costsMatrix.getDistance(from.getLocationId(), to.getLocationId());
+ return costsMatrix.getDistance(from.getLocation().getId(), to.getLocation().getId());
}
}
diff --git a/jsprit-examples/src/main/java/jsprit/examples/EnRoutePickupAndDeliveryWithMultipleDepotsAndVehicleAccessConstraintAndSpecifiedVehicleEndLocationsExample.java b/jsprit-examples/src/main/java/jsprit/examples/EnRoutePickupAndDeliveryWithMultipleDepotsAndVehicleAccessConstraintAndSpecifiedVehicleEndLocationsExample.java
index 73e16c59..291c76ed 100644
--- a/jsprit-examples/src/main/java/jsprit/examples/EnRoutePickupAndDeliveryWithMultipleDepotsAndVehicleAccessConstraintAndSpecifiedVehicleEndLocationsExample.java
+++ b/jsprit-examples/src/main/java/jsprit/examples/EnRoutePickupAndDeliveryWithMultipleDepotsAndVehicleAccessConstraintAndSpecifiedVehicleEndLocationsExample.java
@@ -136,12 +136,12 @@ public class EnRoutePickupAndDeliveryWithMultipleDepotsAndVehicleAccessConstrain
public boolean fulfilled(JobInsertionContext insertionContext) {
Shipment shipment2insert = ((Shipment)insertionContext.getJob());
if(insertionContext.getNewVehicle().getId().equals("v1")){
- if(shipment2insert.getPickupCoord().getX() > 15. || shipment2insert.getDeliveryCoord().getX() > 15.){
+ if(shipment2insert.getPickupLocation().getCoordinate().getX() > 15. || shipment2insert.getDeliveryLocation().getCoordinate().getX() > 15.){
return false;
}
}
if(insertionContext.getNewVehicle().getId().equals("v2")){
- if(shipment2insert.getPickupCoord().getX() < 15. || shipment2insert.getDeliveryCoord().getX() < 15.){
+ if(shipment2insert.getPickupLocation().getCoordinate().getX() < 15. || shipment2insert.getDeliveryLocation().getCoordinate().getX() < 15.){
return false;
}
}
diff --git a/jsprit-examples/src/main/java/jsprit/examples/SolomonWithSkillsExample.java b/jsprit-examples/src/main/java/jsprit/examples/SolomonWithSkillsExample.java
index 7cada476..0c72e8a8 100644
--- a/jsprit-examples/src/main/java/jsprit/examples/SolomonWithSkillsExample.java
+++ b/jsprit-examples/src/main/java/jsprit/examples/SolomonWithSkillsExample.java
@@ -63,15 +63,15 @@ public class SolomonWithSkillsExample {
for(Job job : vrp.getJobs().values()){
Service service = (Service) job;
Service.Builder skillServiceBuilder;
- if(service.getCoord().getY()<50.){
+ if(service.getLocation().getCoordinate().getY()<50.){
skillServiceBuilder = Service.Builder.newInstance(service.getId()+"_skill2").setServiceTime(service.getServiceDuration())
- .setCoord(service.getCoord()).setLocationId(service.getLocationId()).setTimeWindow(service.getTimeWindow())
+ .setCoord(service.getLocation().getCoordinate()).setLocationId(service.getLocation().getId()).setTimeWindow(service.getTimeWindow())
.addSizeDimension(0,service.getSize().get(0));
skillServiceBuilder.addRequiredSkill("skill2");
}
else {
skillServiceBuilder = Service.Builder.newInstance(service.getId()+"_skill1").setServiceTime(service.getServiceDuration())
- .setCoord(service.getCoord()).setLocationId(service.getLocationId()).setTimeWindow(service.getTimeWindow())
+ .setCoord(service.getLocation().getCoordinate()).setLocationId(service.getLocation().getId()).setTimeWindow(service.getTimeWindow())
.addSizeDimension(0,service.getSize().get(0));
skillServiceBuilder.addRequiredSkill("skill1");
}
diff --git a/jsprit-examples/src/main/java/jsprit/examples/TransportOfDisabledPeople.java b/jsprit-examples/src/main/java/jsprit/examples/TransportOfDisabledPeople.java
index d112622c..2cd5373e 100644
--- a/jsprit-examples/src/main/java/jsprit/examples/TransportOfDisabledPeople.java
+++ b/jsprit-examples/src/main/java/jsprit/examples/TransportOfDisabledPeople.java
@@ -150,7 +150,7 @@ public class TransportOfDisabledPeople {
Shipment shipment2insert = ((Shipment)insertionContext.getJob());
if(insertionContext.getNewVehicle().getId().equals("wheelchair_bus")){
if(shipment2insert.getSize().get(PASSENGERSEATS_INDEX)>0){
- if(shipment2insert.getPickupCoord().getX() > 15. || shipment2insert.getDeliveryCoord().getX() > 15.){
+ if(shipment2insert.getPickupLocation().getCoordinate().getX() > 15. || shipment2insert.getDeliveryLocation().getCoordinate().getX() > 15.){
return false;
}
}
diff --git a/jsprit-examples/src/main/java/jsprit/examples/VRPWithBackhaulsExample2.java b/jsprit-examples/src/main/java/jsprit/examples/VRPWithBackhaulsExample2.java
index f928320e..82ca4426 100644
--- a/jsprit-examples/src/main/java/jsprit/examples/VRPWithBackhaulsExample2.java
+++ b/jsprit-examples/src/main/java/jsprit/examples/VRPWithBackhaulsExample2.java
@@ -139,22 +139,22 @@ public class VRPWithBackhaulsExample2 {
System.out.println("timeWindowViolationOnRoute: " + analyser.getTimeWindowViolation(route));
System.out.println("skillConstraintViolatedOnRoute: " + analyser.hasSkillConstraintViolation(route));
- System.out.println("dist@" + route.getStart().getLocationId() + ": " + analyser.getDistanceAtActivity(route.getStart(),route));
- System.out.println("timeWindowViolation@" + route.getStart().getLocationId() + ": " + analyser.getTimeWindowViolationAtActivity(route.getStart(), route));
+ System.out.println("dist@" + route.getStart().getLocation().getId() + ": " + analyser.getDistanceAtActivity(route.getStart(),route));
+ System.out.println("timeWindowViolation@" + route.getStart().getLocation().getId() + ": " + analyser.getTimeWindowViolationAtActivity(route.getStart(), route));
for(TourActivity act : route.getActivities()){
System.out.println("--");
System.out.println("actType: " + act.getName() + " demand: " + act.getSize());
- System.out.println("dist@" + act.getLocationId() + ": " + analyser.getDistanceAtActivity(act,route));
- System.out.println("load(before)@" + act.getLocationId() + ": " + analyser.getLoadJustBeforeActivity(act,route));
- System.out.println("load(after)@" + act.getLocationId() + ": " + analyser.getLoadRightAfterActivity(act, route));
- System.out.println("transportCosts@" + act.getLocationId() + ": " + analyser.getVariableTransportCostsAtActivity(act,route));
- System.out.println("capViolation(after)@" + act.getLocationId() + ": " + analyser.getCapacityViolationAfterActivity(act,route));
- System.out.println("timeWindowViolation@" + act.getLocationId() + ": " + analyser.getTimeWindowViolationAtActivity(act,route));
- System.out.println("skillConstraintViolated@" + act.getLocationId() + ": " + analyser.hasSkillConstraintViolationAtActivity(act, route));
+ System.out.println("dist@" + act.getLocation().getId() + ": " + analyser.getDistanceAtActivity(act,route));
+ System.out.println("load(before)@" + act.getLocation().getId() + ": " + analyser.getLoadJustBeforeActivity(act,route));
+ System.out.println("load(after)@" + act.getLocation().getId() + ": " + analyser.getLoadRightAfterActivity(act, route));
+ System.out.println("transportCosts@" + act.getLocation().getId() + ": " + analyser.getVariableTransportCostsAtActivity(act,route));
+ System.out.println("capViolation(after)@" + act.getLocation().getId() + ": " + analyser.getCapacityViolationAfterActivity(act,route));
+ System.out.println("timeWindowViolation@" + act.getLocation().getId() + ": " + analyser.getTimeWindowViolationAtActivity(act,route));
+ System.out.println("skillConstraintViolated@" + act.getLocation().getId() + ": " + analyser.hasSkillConstraintViolationAtActivity(act, route));
}
System.out.println("--");
- System.out.println("dist@" + route.getEnd().getLocationId() + ": " + analyser.getDistanceAtActivity(route.getEnd(),route));
- System.out.println("timeWindowViolation@" + route.getEnd().getLocationId() + ": " + analyser.getTimeWindowViolationAtActivity(route.getEnd(),route));
+ System.out.println("dist@" + route.getEnd().getLocation().getId() + ": " + analyser.getDistanceAtActivity(route.getEnd(),route));
+ System.out.println("timeWindowViolation@" + route.getEnd().getLocation().getId() + ": " + analyser.getTimeWindowViolationAtActivity(route.getEnd(),route));
}
System.out.println("-----");
diff --git a/jsprit-instances/src/test/java/jsprit/instance/reader/CordeauReaderTest.java b/jsprit-instances/src/test/java/jsprit/instance/reader/CordeauReaderTest.java
index 18c63e11..1498554d 100644
--- a/jsprit-instances/src/test/java/jsprit/instance/reader/CordeauReaderTest.java
+++ b/jsprit-instances/src/test/java/jsprit/instance/reader/CordeauReaderTest.java
@@ -1,31 +1,30 @@
/*******************************************************************************
- * Copyright (C) 2013 Stefan Schroeder
- *
+ * 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
+ * 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.instance.reader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.vehicle.Vehicle;
-import jsprit.instance.reader.CordeauReader;
-
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class CordeauReaderTest {
@@ -81,8 +80,8 @@ public class CordeauReaderTest {
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
VehicleRoutingProblem vrp = vrpBuilder.build();
Service service = (Service) vrp.getJobs().get("1");
- assertEquals(37.0, service.getCoord().getX(), 0.1);
- assertEquals(52.0, service.getCoord().getY(), 0.1);
+ assertEquals(37.0, service.getLocation().getCoordinate().getX(), 0.1);
+ assertEquals(52.0, service.getLocation().getCoordinate().getY(), 0.1);
}
@Test
diff --git a/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java b/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java
index ab185f12..fcf2dd43 100644
--- a/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java
+++ b/jsprit-instances/src/test/java/jsprit/instance/reader/GoldenReaderTest.java
@@ -1,8 +1,22 @@
+/*******************************************************************************
+ * 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.instance.reader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.job.Job;
import jsprit.core.problem.job.Service;
@@ -10,9 +24,10 @@ import jsprit.core.problem.vehicle.PenaltyVehicleType;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.util.Coordinate;
import jsprit.instance.reader.VrphGoldenReader.VrphType;
-
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class GoldenReaderTest {
@Test
@@ -274,7 +289,7 @@ public class GoldenReaderTest {
private Coordinate getCoord(String string, VehicleRoutingProblem vrp) {
Job j = getJob(string,vrp);
- return ((Service)j).getCoord();
+ return ((Service)j).getLocation().getCoordinate();
}
@Test