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

added multiple caps

This commit is contained in:
oblonski 2014-02-14 15:40:46 +01:00
parent cec4e4235e
commit 8da2d1e1c5
13 changed files with 147 additions and 40 deletions

View file

@ -59,10 +59,11 @@ public class VrpReaderV2Test {
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
assertEquals(4,vrp.getVehicles().size());
assertEquals(5,vrp.getVehicles().size());
assertTrue(idsInCollection(Arrays.asList("v1","v2"),vrp.getVehicles()));
}
@SuppressWarnings("deprecation")
@Test
public void whenReadingVrp_vehiclesAreReadCorrectly2(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
@ -70,6 +71,7 @@ public class VrpReaderV2Test {
VehicleRoutingProblem vrp = builder.build();
Vehicle v1 = getVehicle("v1",vrp.getVehicles());
assertEquals(20,v1.getCapacity());
assertEquals(20,v1.getType().getCapacityDimensions().get(0));
assertEquals(100.0,v1.getStartLocationCoordinate().getX(),0.01);
assertEquals(0.0,v1.getEarliestDeparture(),0.01);
assertEquals("depotLoc2",v1.getStartLocationId());
@ -96,7 +98,7 @@ public class VrpReaderV2Test {
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
assertEquals(2,vrp.getTypes().size());
assertEquals(3,vrp.getTypes().size());
}
@Test
@ -139,6 +141,7 @@ public class VrpReaderV2Test {
assertEquals(2,shipCounter);
}
@SuppressWarnings("deprecation")
@Test
public void whenReadingServices_capOfService1IsReadCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
@ -146,6 +149,7 @@ public class VrpReaderV2Test {
VehicleRoutingProblem vrp = builder.build();
Service s1 = (Service) vrp.getJobs().get("1");
assertEquals(1,s1.getCapacityDemand());
assertEquals(1,s1.getCapacity().get(0));
}
@Test
@ -299,6 +303,7 @@ public class VrpReaderV2Test {
assertEquals("startLoc",v.getStartLocationId());
}
@SuppressWarnings("deprecation")
@Test
public void whenReadingJobs_capOfShipment3IsReadCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
@ -306,6 +311,7 @@ public class VrpReaderV2Test {
VehicleRoutingProblem vrp = builder.build();
Shipment s = (Shipment) vrp.getJobs().get("3");
assertEquals(10,s.getCapacityDemand());
assertEquals(10,s.getCapacity().get(0));
}
@Test
@ -419,5 +425,20 @@ public class VrpReaderV2Test {
Shipment s = (Shipment) vrp.getJobs().get("4");
assertEquals(100.0,s.getDeliveryServiceTime(),0.01);
}
@Test
public void whenReadingFile_v5AndItsTypeHasTheCorrectCapacityDimensionValues(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
Vehicle v = getVehicle("v5",vrp.getVehicles());
// assertEquals(100, v.getType().getCapacityDimensions().get(0));
assertEquals(1000, v.getType().getCapacityDimensions().get(1));
// assertEquals(10000, v.getType().getCapacityDimensions().get(2));
// assertEquals(0, v.getType().getCapacityDimensions().get(3));
// assertEquals(0, v.getType().getCapacityDimensions().get(5));
// assertEquals(100000, v.getType().getCapacityDimensions().get(10));
}
}

View file

@ -35,7 +35,7 @@ import jsprit.core.util.Coordinate;
import org.junit.Before;
import org.junit.Test;
@SuppressWarnings("deprecation")
public class VrpWriterV2Test {
private String infileName;
@ -100,6 +100,7 @@ public class VrpWriterV2Test {
builder.addVehicle(v1);
builder.addVehicle(v2);
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();

View file

@ -85,12 +85,28 @@
<end>1000.0</end>
</timeSchedule>
</vehicle>
<vehicle>
<id>v5</id>
<location>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</location>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<typeId>vehType3</typeId>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="1">20</dimension>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
@ -107,6 +123,20 @@
<time>0.0</time>
</costs>
</type>
<type>
<id>vehType3</id>
<capacity-dimensions>
<dimension index="0">100</dimension>
<dimension index="1">1000</dimension>
<dimension index="2">10000</dimension>
<dimension index="10">100000</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
</costs>
</type>
</vehicleTypes>
<services>
@ -114,7 +144,7 @@
<locationId>j(1,5)</locationId>
<coord x="10.0" y="10.0"/>
<capacity-dimensions>
<dimension index="1">1</dimension>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>10.0</duration>
<timeWindows>
@ -187,7 +217,9 @@
</timeWindow>
</timeWindows>
</delivery>
<capacity-demand>10</capacity-demand>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
</shipments>

View file

@ -42,7 +42,9 @@
<vehicleTypes>
<type>
<id>vehType</id>
<capacity>20</capacity>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>1.0</distance>
@ -51,7 +53,9 @@
</type>
<type>
<id>vehType2</id>
<capacity>200</capacity>
<capacity-dimensions>
<dimension index="0">200</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>1.0</distance>
@ -62,7 +66,9 @@
<services>
<service id="2" type="service">
<locationId>loc2</locationId>
<capacity-demand>1</capacity-demand>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>4.0</duration>
<timeWindows>
<timeWindow>
@ -73,7 +79,9 @@
</service>
<service id="1" type="service">
<locationId>loc</locationId>
<capacity-demand>1</capacity-demand>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>2.0</duration>
<timeWindows>
<timeWindow>