1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

merged master into multiple tw branch

This commit is contained in:
oblonski 2015-12-11 17:40:41 +01:00
parent 0b3b07a7de
commit 02c3c96e9c
523 changed files with 77426 additions and 74576 deletions

View file

@ -32,150 +32,150 @@ public class FigliozziTest {
Locations locations;
@Before
public void doBefore(){
final Coordinate from = Coordinate.newInstance(0,0);
final Coordinate to = Coordinate.newInstance(100,0);
public void doBefore() {
final Coordinate from = Coordinate.newInstance(0, 0);
final Coordinate to = Coordinate.newInstance(100, 0);
locations = new Locations(){
locations = new Locations() {
@Override
public Coordinate getCoord(String id) {
if(id.equals("from")) return from;
if(id.equals("to")) return to;
if (id.equals("from")) return from;
if (id.equals("to")) return to;
return null;
}
};
}
@Test
public void factoryShouldReturnCorrectSpeedDistribution(){
public void factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1a);
Assert.assertEquals(speedValues.get(0),1.,0.01);
Assert.assertEquals(speedValues.get(1),1.6,0.01);
Assert.assertEquals(speedValues.get(2),1.05,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 1., 0.01);
Assert.assertEquals(speedValues.get(1), 1.6, 0.01);
Assert.assertEquals(speedValues.get(2), 1.05, 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD2a_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD2a_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2a);
Assert.assertEquals(speedValues.get(0),1.,0.01);
Assert.assertEquals(speedValues.get(1),2.,0.01);
Assert.assertEquals(speedValues.get(2),1.5,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 1., 0.01);
Assert.assertEquals(speedValues.get(1), 2., 0.01);
Assert.assertEquals(speedValues.get(2), 1.5, 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD3a_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD3a_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3a);
Assert.assertEquals(speedValues.get(0),1.,0.01);
Assert.assertEquals(speedValues.get(1),2.5,0.01);
Assert.assertEquals(speedValues.get(2),1.75,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 1., 0.01);
Assert.assertEquals(speedValues.get(1), 2.5, 0.01);
Assert.assertEquals(speedValues.get(2), 1.75, 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD1b_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD1b_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1b);
Assert.assertEquals(speedValues.get(0),1.6,0.01);
Assert.assertEquals(speedValues.get(1),1.,0.01);
Assert.assertEquals(speedValues.get(2),1.05,0.01);
Assert.assertEquals(speedValues.get(3),1.,0.01);
Assert.assertEquals(speedValues.get(4),1.6,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 1.6, 0.01);
Assert.assertEquals(speedValues.get(1), 1., 0.01);
Assert.assertEquals(speedValues.get(2), 1.05, 0.01);
Assert.assertEquals(speedValues.get(3), 1., 0.01);
Assert.assertEquals(speedValues.get(4), 1.6, 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD2b_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD2b_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2b);
Assert.assertEquals(speedValues.get(0),2.,0.01);
Assert.assertEquals(speedValues.get(1),1.,0.01);
Assert.assertEquals(speedValues.get(2),1.5,0.01);
Assert.assertEquals(speedValues.get(3),1.,0.01);
Assert.assertEquals(speedValues.get(4),2.,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 2., 0.01);
Assert.assertEquals(speedValues.get(1), 1., 0.01);
Assert.assertEquals(speedValues.get(2), 1.5, 0.01);
Assert.assertEquals(speedValues.get(3), 1., 0.01);
Assert.assertEquals(speedValues.get(4), 2., 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD3b_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD3b_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3b);
Assert.assertEquals(speedValues.get(0),2.5,0.01);
Assert.assertEquals(speedValues.get(1),1.,0.01);
Assert.assertEquals(speedValues.get(2),1.75,0.01);
Assert.assertEquals(speedValues.get(3),1.,0.01);
Assert.assertEquals(speedValues.get(4),2.5,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 2.5, 0.01);
Assert.assertEquals(speedValues.get(1), 1., 0.01);
Assert.assertEquals(speedValues.get(2), 1.75, 0.01);
Assert.assertEquals(speedValues.get(3), 1., 0.01);
Assert.assertEquals(speedValues.get(4), 2.5, 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD1c_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD1c_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1c);
Assert.assertEquals(speedValues.get(0),1.6,0.01);
Assert.assertEquals(speedValues.get(1),1.6,0.01);
Assert.assertEquals(speedValues.get(2),1.05,0.01);
Assert.assertEquals(speedValues.get(3),1.,0.01);
Assert.assertEquals(speedValues.get(4),1.,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 1.6, 0.01);
Assert.assertEquals(speedValues.get(1), 1.6, 0.01);
Assert.assertEquals(speedValues.get(2), 1.05, 0.01);
Assert.assertEquals(speedValues.get(3), 1., 0.01);
Assert.assertEquals(speedValues.get(4), 1., 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD2c_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD2c_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2c);
Assert.assertEquals(speedValues.get(0),2.,0.01);
Assert.assertEquals(speedValues.get(1),2.,0.01);
Assert.assertEquals(speedValues.get(2),1.5,0.01);
Assert.assertEquals(speedValues.get(3),1.,0.01);
Assert.assertEquals(speedValues.get(4),1.,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 2., 0.01);
Assert.assertEquals(speedValues.get(1), 2., 0.01);
Assert.assertEquals(speedValues.get(2), 1.5, 0.01);
Assert.assertEquals(speedValues.get(3), 1., 0.01);
Assert.assertEquals(speedValues.get(4), 1., 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD3c_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD3c_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3c);
Assert.assertEquals(speedValues.get(0),2.5,0.01);
Assert.assertEquals(speedValues.get(1),2.5,0.01);
Assert.assertEquals(speedValues.get(2),1.75,0.01);
Assert.assertEquals(speedValues.get(3),1.,0.01);
Assert.assertEquals(speedValues.get(4),1.,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 2.5, 0.01);
Assert.assertEquals(speedValues.get(1), 2.5, 0.01);
Assert.assertEquals(speedValues.get(2), 1.75, 0.01);
Assert.assertEquals(speedValues.get(3), 1., 0.01);
Assert.assertEquals(speedValues.get(4), 1., 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD1d_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD1d_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1d);
Assert.assertEquals(speedValues.get(0),1.,0.01);
Assert.assertEquals(speedValues.get(1),1.,0.01);
Assert.assertEquals(speedValues.get(2),1.05,0.01);
Assert.assertEquals(speedValues.get(3),1.6,0.01);
Assert.assertEquals(speedValues.get(4),1.6,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 1., 0.01);
Assert.assertEquals(speedValues.get(1), 1., 0.01);
Assert.assertEquals(speedValues.get(2), 1.05, 0.01);
Assert.assertEquals(speedValues.get(3), 1.6, 0.01);
Assert.assertEquals(speedValues.get(4), 1.6, 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD2d_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD2d_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2d);
Assert.assertEquals(speedValues.get(0),1.,0.01);
Assert.assertEquals(speedValues.get(1),1.,0.01);
Assert.assertEquals(speedValues.get(2),1.5,0.01);
Assert.assertEquals(speedValues.get(3),2.,0.01);
Assert.assertEquals(speedValues.get(4),2.,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 1., 0.01);
Assert.assertEquals(speedValues.get(1), 1., 0.01);
Assert.assertEquals(speedValues.get(2), 1.5, 0.01);
Assert.assertEquals(speedValues.get(3), 2., 0.01);
Assert.assertEquals(speedValues.get(4), 2., 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenAskingForTD3d_factoryShouldReturnCorrectSpeedDistribution(){
public void whenAskingForTD3d_factoryShouldReturnCorrectSpeedDistribution() {
List<Double> speedValues = Figliozzi.TimeDependentTransportCostsFactory.createSpeedValues(Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3d);
Assert.assertEquals(speedValues.get(0),1.,0.01);
Assert.assertEquals(speedValues.get(1),1.,0.01);
Assert.assertEquals(speedValues.get(2),1.75,0.01);
Assert.assertEquals(speedValues.get(3),2.5,0.01);
Assert.assertEquals(speedValues.get(4),2.5,0.01);
Assert.assertEquals(5,speedValues.size());
Assert.assertEquals(speedValues.get(0), 1., 0.01);
Assert.assertEquals(speedValues.get(1), 1., 0.01);
Assert.assertEquals(speedValues.get(2), 1.75, 0.01);
Assert.assertEquals(speedValues.get(3), 2.5, 0.01);
Assert.assertEquals(speedValues.get(4), 2.5, 0.01);
Assert.assertEquals(5, speedValues.size());
}
@Test
public void whenConstantTimeDistribution_forwardTimeShouldBeCalculate100(){
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.CLASSIC,100);
public void whenConstantTimeDistribution_forwardTimeShouldBeCalculate100() {
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.CLASSIC, 100);
Assert.assertEquals(100., tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null), 0.01);
}
@ -184,8 +184,8 @@ public class FigliozziTest {
}
@Test
public void whenTimeDistributionTD1a_forwardTimeShouldBeCalculate100(){
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1a,100);
public void whenTimeDistributionTD1a_forwardTimeShouldBeCalculate100() {
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1a, 100);
/*
100
(0,20) - 1. --> 20
@ -196,13 +196,13 @@ public class FigliozziTest {
20
*/
Assert.assertEquals(76.875,tdCosts.getTransportTime(loc("from"),loc("to"),0.,null,null),0.01);
Assert.assertEquals(76.875, tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null), 0.01);
}
@Test
public void whenTimeDistributionTD2a_forwardTimeShouldBeCalculate100(){
public void whenTimeDistributionTD2a_forwardTimeShouldBeCalculate100() {
//(1.,2.,1.5,2.,1.)
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2a,100);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2a, 100);
/*
100
(0,20) - 1. --> 20 dist, 20 time
@ -213,26 +213,26 @@ public class FigliozziTest {
20
*/
Assert.assertEquals(65.,tdCosts.getTransportTime(loc("from"),loc("to"),0.,null,null),0.01);
Assert.assertEquals(65., tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null), 0.01);
}
@Test
public void whenTimeDistributionTD3a_forwardTimeShouldBeCalculate100(){
public void whenTimeDistributionTD3a_forwardTimeShouldBeCalculate100() {
//(1.,2.5,1.75,2.5,1.)
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3a,100);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3a, 100);
/*
100
(0,20) - 1. --> 20 dist, 20 time
(20,40) 2.5 = 20 --> 50 dist, 20 time : 70 dist, 40 time
(40,60) 1.75 = 30 dist, 17.1428571429 time : 100 dist, 57.1428571429 time
*/
Assert.assertEquals(57.1428571429,tdCosts.getTransportTime(loc("from"),loc("to"),0.,null,null),0.01);
Assert.assertEquals(57.1428571429, tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null), 0.01);
}
@Test
public void whenTimeDistributionTD2a_backwardTimeShouldBeCalculate100(){
public void whenTimeDistributionTD2a_backwardTimeShouldBeCalculate100() {
//(1.,2.,1.5,2.,1.)
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2a,100);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2a, 100);
/*
100
(0,20) - 1. --> 20 dist, 20 time
@ -243,12 +243,12 @@ public class FigliozziTest {
20
*/
Assert.assertEquals(65.,tdCosts.getBackwardTransportTime(loc("from"),loc("to"), 100., null, null),0.01);
Assert.assertEquals(65., tdCosts.getBackwardTransportTime(loc("from"), loc("to"), 100., null, null), 0.01);
}
@Test
public void whenTimeDistributionTD1a_backwardTimeShouldBeCalculate100(){
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1a,100);
public void whenTimeDistributionTD1a_backwardTimeShouldBeCalculate100() {
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1a, 100);
/*
100
(0,20) - 1. --> 20
@ -259,217 +259,217 @@ public class FigliozziTest {
20
*/
Assert.assertEquals(76.875,tdCosts.getBackwardTransportTime(loc("from"),loc("to"), 100., null, null),0.01);
Assert.assertEquals(76.875, tdCosts.getBackwardTransportTime(loc("from"), loc("to"), 100., null, null), 0.01);
}
@Test
public void backwardTimeShouldBeCalculatedCorrectly(){
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.CLASSIC,100);
Assert.assertEquals(100.,tdCosts.getBackwardTransportTime(loc("from"),loc("to"),100.,null,null),0.01);
public void backwardTimeShouldBeCalculatedCorrectly() {
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.CLASSIC, 100);
Assert.assertEquals(100., tdCosts.getBackwardTransportTime(loc("from"), loc("to"), 100., null, null), 0.01);
}
@Test
public void whenTD1a_distanceShouldBe25PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1a, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD1b_distanceShouldBe25PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1b, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD1c_distanceShouldBe25PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1c, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD1d_distanceShouldBe25PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD1d, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD2a_distanceShouldBe50PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2a, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD2b_distanceShouldBe50PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2b, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD2c_distanceShouldBe50PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2c, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD2d_distanceShouldBe50PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD2d, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD3a_distanceShouldBe75PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3a, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD3b_distanceShouldBe75PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3b, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD3c_distanceShouldBe75PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3c, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
@Test
public void whenTD3d_distanceShouldBe75PercentMore(){
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);
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(loc("from"),loc("to"),0.,null,null);
Assert.assertEquals(100.,time,0.01);
Figliozzi.TDCosts tdCosts = Figliozzi.TimeDependentTransportCostsFactory.createCosts(locations, Figliozzi.TimeDependentTransportCostsFactory.SpeedDistribution.TD3d, 100);
double time = tdCosts.getTransportTime(loc("from"), loc("to"), 0., null, null);
Assert.assertEquals(100., time, 0.01);
}
}