mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
remove penalty vehicle stuff
This commit is contained in:
parent
a0419ab3fd
commit
657f85e896
13 changed files with 64 additions and 260 deletions
|
|
@ -119,7 +119,8 @@ public class TestCalculatesServiceInsertion {
|
|||
jobs.add(third);
|
||||
jobs.add(second);
|
||||
|
||||
vrp = VehicleRoutingProblem.Builder.newInstance().addAllJobs(jobs).addVehicle(vehicle).setRoutingCost(costs).build();
|
||||
vrp = VehicleRoutingProblem.Builder.newInstance().addAllJobs(jobs)
|
||||
.addVehicle(vehicle).setRoutingCost(costs).build();
|
||||
|
||||
states = new StateManager(vrp);
|
||||
states.updateLoadStates();
|
||||
|
|
|
|||
|
|
@ -109,47 +109,7 @@ public class TestVehicleFleetManagerImpl {
|
|||
assertEquals(2, availableVehicles.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithPenalty_whenHavingTwoRegularVehicleAvailablePlusOnePenaltyVehicle_andOneIsLocked_returnTheOtherRegularVehicle(){
|
||||
VehicleTypeImpl penaltyType = VehicleTypeImpl.Builder.newInstance("standard").build();
|
||||
PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType);
|
||||
|
||||
Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setStartLocationId("loc").
|
||||
setType(penaltyVehicleType).build();
|
||||
|
||||
Vehicle v3 = VehicleImpl.Builder.newInstance("standard_v3").setStartLocationId("loc").
|
||||
setType(penaltyType).build();
|
||||
|
||||
List<Vehicle> vehicles = new ArrayList<Vehicle>();
|
||||
vehicles.add(v1);
|
||||
vehicles.add(v2);
|
||||
vehicles.add(penalty4standard);
|
||||
vehicles.add(v3);
|
||||
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(vehicles).createFleetManager();
|
||||
fleetManager.lock(v1);
|
||||
fleetManager.lock(v2);
|
||||
Collection<Vehicle> availableVehicles = fleetManager.getAvailableVehicles();
|
||||
assertEquals(1, availableVehicles.size());
|
||||
assertEquals(v3, availableVehicles.iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithPenalty_whenHavingNoRegularVehicleAvailable_penaltyVehicleIsReturned(){
|
||||
VehicleTypeImpl penaltyType = VehicleTypeImpl.Builder.newInstance("standard").build();
|
||||
|
||||
Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setStartLocationId("loc").
|
||||
setType(penaltyType).build();
|
||||
|
||||
List<Vehicle> vehicles = new ArrayList<Vehicle>();
|
||||
vehicles.add(v1);
|
||||
vehicles.add(v2);
|
||||
vehicles.add(penalty4standard);
|
||||
VehicleFleetManager fleetManager = new FiniteFleetManagerFactory(vehicles).createFleetManager();
|
||||
fleetManager.lock(v1);
|
||||
fleetManager.lock(v2);
|
||||
Collection<Vehicle> availableVehicles = fleetManager.getAvailableVehicles();
|
||||
assertEquals(penalty4standard, availableVehicles.iterator().next());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenAddingTwoVehiclesWithSameTypeIdAndLocation_getAvailableVehicleShouldReturnOnlyOneOfThem(){
|
||||
|
|
|
|||
|
|
@ -194,15 +194,7 @@ public class VehicleImplTest {
|
|||
assertTrue(v.equals(v2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenTwoVehiclesHaveTheSameIdButDiffType_theyShouldNotBeEqual(){
|
||||
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build();
|
||||
Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setType(type1).setEndLocationId("start").setReturnToDepot(false).build();
|
||||
PenaltyVehicleType penType = new PenaltyVehicleType(type1);
|
||||
Vehicle v2 = VehicleImpl.Builder.newInstance("v").setType(penType).setStartLocationId("start").setEndLocationId("start").setReturnToDepot(false).build();
|
||||
assertTrue(!v.equals(v2));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenAddingSkills_theyShouldBeAddedCorrectly(){
|
||||
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build();
|
||||
|
|
|
|||
|
|
@ -146,13 +146,7 @@ public class VehicleTypeImplTest {
|
|||
assertTrue(type.equals(type2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenHavingTwoTypesWithTheSameIdButDiffClass_theyShouldNotBeEqual(){
|
||||
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("type").setCostPerTime(10).build();
|
||||
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("type").setCostPerTime(10).build();
|
||||
PenaltyVehicleType penType = new PenaltyVehicleType(type2);
|
||||
assertTrue(!type.equals(penType));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,24 @@
|
|||
<problem xmlns="http://www.w3schools.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
||||
<problemType>
|
||||
<fleetSize>INFINITE</fleetSize>
|
||||
<fleetSize>FINITE</fleetSize>
|
||||
</problemType>
|
||||
<vehicles>
|
||||
<vehicle>
|
||||
<id>v2</id>
|
||||
<typeId>vehType2</typeId>
|
||||
<startLocation>
|
||||
<id>loc</id>
|
||||
</startLocation>
|
||||
<endLocation>
|
||||
<id>loc</id>
|
||||
</endLocation>
|
||||
<timeSchedule>
|
||||
<start>0.0</start>
|
||||
<end>1.7976931348623157E308</end>
|
||||
</timeSchedule>
|
||||
<returnToDepot>true</returnToDepot>
|
||||
</vehicle>
|
||||
<vehicle>
|
||||
<id>v1</id>
|
||||
<typeId>vehType</typeId>
|
||||
|
|
@ -33,58 +48,16 @@
|
|||
<time>0.0</time>
|
||||
</costs>
|
||||
</type>
|
||||
<type>
|
||||
<id>vehType2</id>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">200</dimension>
|
||||
</capacity-dimensions>
|
||||
<costs>
|
||||
<fixed>0.0</fixed>
|
||||
<distance>1.0</distance>
|
||||
<time>0.0</time>
|
||||
</costs>
|
||||
</type>
|
||||
</vehicleTypes>
|
||||
<services>
|
||||
<service id="1" type="service">
|
||||
<location>
|
||||
<id>loc</id>
|
||||
</location>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">1</dimension>
|
||||
</capacity-dimensions>
|
||||
<duration>2.0</duration>
|
||||
<timeWindows>
|
||||
<timeWindow>
|
||||
<start>0.0</start>
|
||||
<end>1.7976931348623157E308</end>
|
||||
</timeWindow>
|
||||
</timeWindows>
|
||||
</service>
|
||||
<service id="2" type="service">
|
||||
<location>
|
||||
<id>loc2</id>
|
||||
</location>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">1</dimension>
|
||||
</capacity-dimensions>
|
||||
<duration>4.0</duration>
|
||||
<timeWindows>
|
||||
<timeWindow>
|
||||
<start>0.0</start>
|
||||
<end>1.7976931348623157E308</end>
|
||||
</timeWindow>
|
||||
</timeWindows>
|
||||
</service>
|
||||
</services>
|
||||
<solutions>
|
||||
<solution>
|
||||
<cost>10.0</cost>
|
||||
<routes>
|
||||
<route>
|
||||
<driverId>noDriver</driverId>
|
||||
<vehicleId>v1</vehicleId>
|
||||
<start>0.0</start>
|
||||
<act type="service">
|
||||
<serviceId>1</serviceId>
|
||||
<arrTime>0.0</arrTime>
|
||||
<endTime>0.0</endTime>
|
||||
</act>
|
||||
<end>0.0</end>
|
||||
</route>
|
||||
</routes>
|
||||
<unassignedJobs>
|
||||
<job id="2"/>
|
||||
</unassignedJobs>
|
||||
</solution>
|
||||
</solutions>
|
||||
</problem>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue