mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
issue #144 - replace deprecated methods
This commit is contained in:
parent
c083b74ea7
commit
600087fd33
48 changed files with 398 additions and 379 deletions
|
|
@ -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.";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public final class DeliverService extends AbstractActivity implements DeliveryAc
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return delivery.getLocationId();
|
||||
return delivery.getLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public final class DeliverShipment extends AbstractActivity implements DeliveryA
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return shipment.getDeliveryLocationId();
|
||||
return shipment.getDeliveryLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public final class PickupService extends AbstractActivity implements PickupActiv
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return pickup.getLocationId();
|
||||
return pickup.getLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public final class PickupShipment extends AbstractActivity implements PickupActi
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return shipment.getPickupLocationId();
|
||||
return shipment.getPickupLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public class ServiceActivity extends AbstractActivity implements JobActivity{
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return service.getLocationId();
|
||||
return service.getLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
|
@ -56,18 +56,18 @@ public class NeighborhoodImpl implements Neighborhood{
|
|||
for(Service i : services){
|
||||
Set<String> neigh = new HashSet<String>();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<AbstractActivity> activities = new ArrayList<AbstractActivity>();
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<AbstractActivity> 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Service> services = new ArrayList<Service>();
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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));
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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));
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
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<Start> starts) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue