diff --git a/jsprit-core/src/test/java/jsprit/core/problem/constraint/VehicleDependentTimeWindowWithStartTimeAndMaxOperationTimeTest.java b/jsprit-core/src/test/java/jsprit/core/problem/constraint/VehicleDependentTimeWindowWithStartTimeAndMaxOperationTimeTest.java
new file mode 100644
index 00000000..6c8e2cfb
--- /dev/null
+++ b/jsprit-core/src/test/java/jsprit/core/problem/constraint/VehicleDependentTimeWindowWithStartTimeAndMaxOperationTimeTest.java
@@ -0,0 +1,348 @@
+/*******************************************************************************
+ * Copyright (C) 2014 Stefan Schroeder
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see .
+ ******************************************************************************/
+
+package jsprit.core.problem.constraint;
+
+import jsprit.core.algorithm.state.InternalStates;
+import jsprit.core.algorithm.state.StateManager;
+import jsprit.core.algorithm.state.UpdateActivityTimes;
+import jsprit.core.algorithm.state.UpdateVehicleDependentPracticalTimeWindows;
+import jsprit.core.problem.AbstractActivity;
+import jsprit.core.problem.AbstractVehicle;
+import jsprit.core.problem.JobActivityFactory;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.misc.JobInsertionContext;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.PickupService;
+import jsprit.core.problem.vehicle.*;
+import jsprit.core.util.CostFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.*;
+
+import static org.junit.Assert.*;
+
+/**
+ * unit tests to test vehicle dependent time-windows
+ */
+public class VehicleDependentTimeWindowWithStartTimeAndMaxOperationTimeTest {
+
+ private StateManager stateManager;
+
+ private VehicleRoute route;
+
+ private AbstractVehicle vehicle;
+
+ private AbstractVehicle v2;
+
+ private VehicleRoutingTransportCosts routingCosts;
+
+ private VehicleRoutingProblem vrp;
+
+ private VehicleImpl v3;
+ private VehicleImpl v4;
+ private VehicleImpl v5;
+ private VehicleImpl v6;
+
+ @Before
+ public void doBefore(){
+ VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
+ routingCosts = CostFactory.createEuclideanCosts();
+ vrpBuilder.setRoutingCost(routingCosts);
+
+ VehicleType type = VehicleTypeImpl.Builder.newInstance("type").build();
+ vehicle = VehicleImpl.Builder.newInstance("v").setType(type).setStartLocationId("0,0")
+ .setEarliestStart(0.).setLatestArrival(100.).build();
+
+ v2 = VehicleImpl.Builder.newInstance("v2").setType(type).setStartLocationId("0,0")
+ .setEarliestStart(0.).setLatestArrival(60.).build();
+
+ v3 = VehicleImpl.Builder.newInstance("v3").setType(type).setStartLocationId("0,0")
+ .setEarliestStart(0.).setLatestArrival(50.).build();
+
+ v4 = VehicleImpl.Builder.newInstance("v4").setType(type).setStartLocationId("0,0")
+ .setEarliestStart(0.).setLatestArrival(10.).build();
+
+ v5 = VehicleImpl.Builder.newInstance("v5").setType(type).setStartLocationId("0,0")
+ .setEarliestStart(60.).setLatestArrival(100.).build();
+
+ v6 = VehicleImpl.Builder.newInstance("v6").setType(type).setStartLocationId("0,0")
+ .setEndLocationId("40,0").setEarliestStart(0.).setLatestArrival(40.).build();
+
+ vrpBuilder.addVehicle(vehicle).addVehicle(v2).addVehicle(v3).addVehicle(v4).addVehicle(v5).addVehicle(v6);
+
+ Service service = Service.Builder.newInstance("s1").setLocationId("10,0").build();
+ Service service2 = Service.Builder.newInstance("s2").setLocationId("20,0").build();
+ Service service3 = Service.Builder.newInstance("s3").setLocationId("30,0").build();
+
+ vrpBuilder.addJob(service).addJob(service2).addJob(service3);
+ final VehicleRoutingProblem vrp = vrpBuilder.build();
+
+ route = VehicleRoute.Builder.newInstance(vehicle).setJobActivityFactory(new JobActivityFactory() {
+
+ @Override
+ public List createActivities(Job job) {
+ return vrp.copyAndGetActivities(job);
+ }
+
+ }).addService(service).addService(service2).addService(service3).build();
+
+ stateManager = new StateManager(vrp);
+
+ Collection vehicles = new ArrayList();
+ vehicles.add(vehicle);
+ vehicles.add(v2);
+ vehicles.add(v3);
+ vehicles.add(v4);
+ vehicles.add(v5);
+ vehicles.add(v6);
+
+ final VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(vehicles).createFleetManager();
+// stateManager.updateTimeWindowStates();
+ UpdateVehicleDependentPracticalTimeWindows timeWindow_updater = new UpdateVehicleDependentPracticalTimeWindows(stateManager, routingCosts);
+ timeWindow_updater.setVehiclesToUpdate(new UpdateVehicleDependentPracticalTimeWindows.VehiclesToUpdate() {
+
+ @Override
+ public Collection get(VehicleRoute route) {
+ List vehicles = new ArrayList();
+ vehicles.add(route.getVehicle());
+ vehicles.addAll(fleetManager.getAvailableVehicles(route.getVehicle()));
+ return vehicles;
+ }
+
+ });
+ stateManager.addStateUpdater(timeWindow_updater);
+ stateManager.addStateUpdater(new UpdateActivityTimes(routingCosts));
+ stateManager.informInsertionStarts(Arrays.asList(route), Collections.emptyList());
+ }
+
+ @Test
+ public void stateManagerShouldHaveMemorizedCorrectLatestEndOfAct3(){
+ assertEquals(70.,stateManager.getActivityState(route.getActivities().get(2),
+ vehicle, InternalStates.LATEST_OPERATION_START_TIME, Double.class),0.01);
+ }
+
+ @Test
+ public void stateManagerShouldHaveMemorizedCorrectLatestEndOfAct2(){
+ assertEquals(60.,stateManager.getActivityState(route.getActivities().get(1),
+ vehicle, InternalStates.LATEST_OPERATION_START_TIME, Double.class),0.01);
+ }
+
+ @Test
+ public void stateManagerShouldHaveMemorizedCorrectLatestEndOfAct1(){
+ assertEquals(50.,stateManager.getActivityState(route.getActivities().get(0),
+ vehicle, InternalStates.LATEST_OPERATION_START_TIME, Double.class),0.01);
+ }
+
+ @Test
+ public void whenNewJobIsInsertedWithOldVeh_itJustShouldReturnTrue(){
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("50,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,vehicle,route.getDriver(),0.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
+ assertTrue(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+ @Test
+ public void whenNewJobIsInsertedWithOldVeh_itJustShouldReturnFalse(){
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("1000,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,vehicle,route.getDriver(),0.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
+ assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+ @Test
+ public void whenNewJobIsInsertedInBetweenAct1And2WithOldVeh_itJustShouldReturnTrue(){
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("50,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,vehicle,route.getDriver(),0.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+ /*
+ driverTime = 10 + 10 + 30 + 20 + 30 = 100
+ */
+// System.out.println("latest act1 " + stateManager.getActivityState());
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(1), serviceAct, route.getActivities().get(2), 20.);
+ assertTrue(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+ @Test
+ public void whenNewJobIsInsertedInBetweenAct1And2WithOldVeh_itJustShouldReturnFalse(){
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("51,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,vehicle,route.getDriver(),0.);
+
+ /*
+ driverTime = 10 + 10 + 31 + 21 + 30 = 102
+ */
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(1), serviceAct, route.getActivities().get(2), 20.);
+ assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+ @Test
+ public void whenJobIsInsertedAlongWithNewVehicleThatNeedsToBeHomeAt60_itShouldReturnFalse(){
+
+ System.out.println("actualEndTime " + route.getEnd().getArrTime());
+ assertEquals(60.,route.getEnd().getArrTime(),0.01);
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("40,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v2,route.getDriver(),0.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
+
+ assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+ @Test
+ public void whenJobIsInsertedAlongWithNewVehicleThatNeedsToBeHomeAt50_itShouldReturnFalse(){
+
+ System.out.println("actualEndTime " + route.getEnd().getArrTime());
+ assertEquals(60.,route.getEnd().getArrTime(),0.01);
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("40,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v3,route.getDriver(),0.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
+ assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+ @Test
+ public void whenJobIsInsertedAlongWithNewVehicleThatNeedsToBeHomeAt10_itShouldReturnFalse(){
+
+ System.out.println("actualEndTime " + route.getEnd().getArrTime());
+ assertEquals(60.,route.getEnd().getArrTime(),0.01);
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("40,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v4,route.getDriver(),0.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
+ assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+ @Test
+ public void whenJobIsInsertedAlongWithV6BetweenS2AndS3_itShouldReturnFalse(){
+
+ System.out.println("actualEndTime " + route.getEnd().getArrTime());
+ assertEquals(60.,route.getEnd().getArrTime(),0.01);
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("40,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v6,route.getDriver(),0.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(1), serviceAct, route.getActivities().get(2), 30.);
+ assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+ @Test
+ public void whenJobIsInsertedAlongWithV6BetweenS1AndS2_itShouldReturnFalse(){
+
+ System.out.println("actualEndTime " + route.getEnd().getArrTime());
+ assertEquals(60.,route.getEnd().getArrTime(),0.01);
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("40,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v6,route.getDriver(),0.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(0), serviceAct, route.getActivities().get(1), 10.);
+ assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+ @Test
+ public void whenJobIsInsertedAlongWithV6AtTheEndOfRoute_itShouldReturnTrue(){
+
+ System.out.println("actualEndTime " + route.getEnd().getArrTime());
+ assertEquals(60.,route.getEnd().getArrTime(),0.01);
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("40,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v6,route.getDriver(),0.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 30.);
+ assertTrue(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+ }
+
+ @Test
+ public void whenJobIsInsertedAlongWithNewVehicleThatCanOnlyStartAt60_itShouldReturnFalse(){
+ System.out.println("actualEndTime " + route.getEnd().getArrTime());
+ assertEquals(60.,route.getEnd().getArrTime(),0.01);
+
+ Service s4 = Service.Builder.newInstance("s4").setLocationId("40,0").build();
+ PickupService serviceAct = new PickupService(s4);
+
+ JobInsertionContext insertionContext = new JobInsertionContext(route,s4,v5,route.getDriver(),60.);
+
+ HardActivityConstraint twConstraint = new VehicleDependentTimeWindowConstraints(stateManager,routingCosts);
+
+ HardActivityConstraint.ConstraintsStatus status = twConstraint.fulfilled(insertionContext, route.getActivities().get(2), serviceAct, route.getEnd(), 90.);
+ assertFalse(status.equals(HardActivityConstraint.ConstraintsStatus.FULFILLED));
+
+ }
+
+
+}
diff --git a/jsprit-instances/src/test/java/jsprit/instance/reader/FigliozziTest.java b/jsprit-instances/src/test/java/jsprit/instance/reader/FigliozziTest.java
index 366ac0ff..0352130b 100644
--- a/jsprit-instances/src/test/java/jsprit/instance/reader/FigliozziTest.java
+++ b/jsprit-instances/src/test/java/jsprit/instance/reader/FigliozziTest.java
@@ -262,4 +262,211 @@ public class FigliozziTest {
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.CLASSIC,100);
Assert.assertEquals(100.,tdCosts.getBackwardTransportTime("from","to",100.,null,null),0.01);
}
+
+ @Test
+ public void whenTD1a_distanceShouldBe25PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(125.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1a,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD1b_distanceShouldBe25PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(125.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1b,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD1c_distanceShouldBe25PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(125.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1c,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD1d_distanceShouldBe25PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(125.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1d,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD2a_distanceShouldBe50PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(150.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2a,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD2b_distanceShouldBe50PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(150.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2b,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD2c_distanceShouldBe50PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(150.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2c,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD2d_distanceShouldBe50PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(150.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2d,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD3a_distanceShouldBe75PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(175.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3a,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD3b_distanceShouldBe75PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(175.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3b,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD3c_distanceShouldBe75PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(175.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3c,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
+
+ @Test
+ public void whenTD3d_distanceShouldBe75PercentMore(){
+ Locations locations = new Locations() {
+
+ @Override
+ public Coordinate getCoord(String id) {
+ if(id.equals("from")) return Coordinate.newInstance(0,0);
+ if(id.equals("to")) return Coordinate.newInstance(175.,0);
+ return null;
+ }
+
+ };
+ Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3d,100);
+ double time = tdCosts.getTransportTime("from","to",0.,null,null);
+ Assert.assertEquals(100.,time,0.01);
+ }
}
+
+
+