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

add editorconfig - #174

This commit is contained in:
oblonski 2015-09-11 12:49:01 +02:00
parent b9c7dc3324
commit 25e5c096f2
43 changed files with 625 additions and 645 deletions

View file

@ -18,13 +18,6 @@
package jsprit.core.algorithm;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import java.util.List;
import jsprit.core.algorithm.box.GreedySchrimpfFactory;
import jsprit.core.algorithm.box.Jsprit;
import jsprit.core.algorithm.box.Jsprit.Builder;
@ -53,9 +46,13 @@ import jsprit.core.problem.vehicle.VehicleTypeImpl;
import jsprit.core.reporting.SolutionPrinter;
import jsprit.core.util.Coordinate;
import jsprit.core.util.Solutions;
import org.junit.Test;
import java.util.Collection;
import java.util.List;
import static org.junit.Assert.*;
public class InitialRoutesTest {
@Test
@ -396,9 +393,9 @@ public class InitialRoutesTest {
}
@Test
public void whenAllJobsInInitialRoute_itShouldWork(){
Service s = Service.Builder.newInstance("s").setLocation(Location.newInstance(0,10)).build();
VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0,0)).build();
public void whenAllJobsInInitialRoute_itShouldWork() {
Service s = Service.Builder.newInstance("s").setLocation(Location.newInstance(0, 10)).build();
VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build();
VehicleRoute iniRoute = VehicleRoute.Builder.newInstance(v).addService(s).build();
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addInitialVehicleRoute(iniRoute).build();
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
@ -406,18 +403,18 @@ public class InitialRoutesTest {
vra.searchSolutions();
assertTrue(true);
}
@Test
public void buildWithoutTimeConstraints() {
Service s1 = Service.Builder.newInstance("s1").setLocation(Location.newInstance(0,10)).addSizeDimension(0, 10).build();
Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(10,20)).addSizeDimension(0, 12).build();
Service s1 = Service.Builder.newInstance("s1").setLocation(Location.newInstance(0, 10)).addSizeDimension(0, 10).build();
Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(10, 20)).addSizeDimension(0, 12).build();
VehicleTypeImpl vt = VehicleTypeImpl.Builder.newInstance("vt").addCapacityDimension(0, 15).build();
VehicleImpl v = VehicleImpl.Builder.newInstance("v").setType(vt).setStartLocation(Location.newInstance(0,0)).build();
VehicleImpl v = VehicleImpl.Builder.newInstance("v").setType(vt).setStartLocation(Location.newInstance(0, 0)).build();
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(s1).addJob(s2).addVehicle(v).build();
Builder algBuilder = Jsprit.Builder.newInstance(vrp).addCoreStateAndConstraintStuff(false);
// only required constraints
StateManager stateManager = new StateManager(vrp);
ConstraintManager constraintManager = new ConstraintManager(vrp, stateManager);
@ -426,16 +423,16 @@ public class InitialRoutesTest {
stateManager.updateLoadStates();
stateManager.addStateUpdater(new UpdateEndLocationIfRouteIsOpen());
stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager));
algBuilder.setStateAndConstraintManager(stateManager, constraintManager);
VehicleRoutingAlgorithm vra = algBuilder.buildAlgorithm();
vra.setMaxIterations(20);
Collection<VehicleRoutingProblemSolution> searchSolutions = vra.searchSolutions();
VehicleRoutingProblemSolution bestOf = Solutions.bestOf(searchSolutions);
//ensure 2 routes
assertEquals(2, bestOf.getRoutes().size());
//ensure no time information in first service of first route
assertEquals(0, bestOf.getRoutes().iterator().next().getActivities().iterator().next().getArrTime(), 0.001);
}

View file

@ -118,14 +118,14 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_IT {
Vehicle bigVehicle = vehicleBuilder.build();
/*
* start building the problem
* start building the problem
*/
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.setFleetSize(FleetSize.INFINITE);
vrpBuilder.addVehicle(bigVehicle);
/*
* create cost-matrix
* create cost-matrix
*/
VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
/*

View file

@ -118,14 +118,14 @@ public class RefuseCollectionWithCostsHigherThanTimesAndFiniteFleet_withTimeAndD
Vehicle bigVehicle = vehicleBuilder.build();
/*
* start building the problem
* start building the problem
*/
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
vrpBuilder.setFleetSize(FleetSize.INFINITE);
vrpBuilder.addVehicle(bigVehicle);
/*
* create cost-matrix
* create cost-matrix
*/
VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
/*

View file

@ -67,10 +67,10 @@ public class RefuseCollection_IT {
vrpBuilder.addVehicle(bigVehicle);
/*
* create cost-matrix
* create cost-matrix
*/
VehicleRoutingTransportCostsMatrix.Builder matrixBuilder = VehicleRoutingTransportCostsMatrix.Builder.newInstance(true);
/*
/*
* read demand quantities
*/
readDemandQuantitiesAsServices(vrpBuilder);

View file

@ -44,7 +44,7 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
VehicleType vehicleType = vehicleTypeBuilder.build();
/*
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
* get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType"
*/
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
vehicleBuilder.setStartLocation(Location.newInstance(10, 10));
@ -52,7 +52,7 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
VehicleImpl vehicle = vehicleBuilder.build();
/*
* build shipments at the required locations, each with a capacity-demand of 1.
* build shipments at the required locations, each with a capacity-demand of 1.
* 4 shipments
* 1: (5,7)->(6,9)
* 2: (5,13)->(6,11)

View file

@ -1,256 +1,255 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>FINITE</fleetSize>
</problemType>
<vehicles>
<vehicle>
<id>v3</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v2</id>
<typeId>vehType2</typeId>
<startLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>false</returnToDepot>
</vehicle>
<vehicle>
<id>v4</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v5</id>
<typeId>vehType3</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v1</id>
<typeId>vehType</typeId>
<startLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<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>0.0</distance>
<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="3">0</dimension>
<dimension index="4">0</dimension>
<dimension index="5">0</dimension>
<dimension index="6">0</dimension>
<dimension index="7">0</dimension>
<dimension index="8">0</dimension>
<dimension index="9">0</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>
<service id="1" type="service">
<location>
<id>j(1,5)</id>
<coord x="10.0" y="10.0"/>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>10.0</duration>
<timeWindows>
<timeWindow>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
<problemType>
<fleetSize>FINITE</fleetSize>
</problemType>
<vehicles>
<vehicle>
<id>v3</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</service>
<service id="2" type="service">
<location>
<id>i(3,9)</id>
<coord x="10.0" y="10.0"/>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>0.0</duration>
<timeWindows>
<timeWindow>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v2</id>
<typeId>vehType2</typeId>
<startLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc</id>
<coord x="10.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</service>
</services>
<shipments>
<shipment id="3">
<pickup>
<location>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>false</returnToDepot>
</vehicle>
<vehicle>
<id>v4</id>
<typeId>vehType2</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v5</id>
<typeId>vehType3</typeId>
<startLocation>
<id>startLoc</id>
<coord x="10.0" y="100.0"/>
</startLocation>
<endLocation>
<id>endLoc</id>
<coord x="1000.0" y="2000.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
<vehicle>
<id>v1</id>
<typeId>vehType</typeId>
<startLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</startLocation>
<endLocation>
<id>depotLoc2</id>
<coord x="100.0" y="100.0"/>
</endLocation>
<timeSchedule>
<start>0.0</start>
<end>1000.0</end>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</dimension>
</capacity-dimensions>
<costs>
<fixed>0.0</fixed>
<distance>0.0</distance>
<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>0.0</distance>
<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="3">0</dimension>
<dimension index="4">0</dimension>
<dimension index="5">0</dimension>
<dimension index="6">0</dimension>
<dimension index="7">0</dimension>
<dimension index="8">0</dimension>
<dimension index="9">0</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>
<service id="1" type="service">
<location>
<id>j(1,5)</id>
<coord x="10.0" y="10.0"/>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>10.0</duration>
<timeWindows>
<timeWindow>
<start>0.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</service>
<service id="2" type="service">
<location>
<id>i(3,9)</id>
<coord x="10.0" y="10.0"/>
</location>
<duration>10.0</duration>
<timeWindows>
</location>
<capacity-dimensions>
<dimension index="0">1</dimension>
</capacity-dimensions>
<duration>0.0</duration>
<timeWindows>
<timeWindow>
<start>1000.0</start>
<end>4000.0</end>
<start>0.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</pickup>
<delivery>
<location>
<id>i(9,9)</id>
<coord x="10.0" y="0.0"/>
</location>
<duration>100.0</duration>
<timeWindows>
<timeWindow>
<start>6000.0</start>
<end>10000.0</end>
</timeWindow>
</timeWindows>
</delivery>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
<shipment id="4">
<pickup>
<location>
<id>[x=10.0][y=10.0]</id>
<coord x="10.0" y="10.0"/>
</location>
<duration>0.0</duration>
<timeWindows>
<timeWindow>
<start>1000.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</pickup>
<delivery>
<location>
<id>[x=10.0][y=0.0]</id>
<coord x="10.0" y="0.0"/>
</location>
<duration>100.0</duration>
<timeWindows>
<timeWindow>
<start>6000.0</start>
<end>10000.0</end>
</timeWindow>
</timeWindows>
</delivery>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
</shipments>
<initialRoutes>
<route>
<driverId>noDriver</driverId>
<vehicleId>v1</vehicleId>
<start>10.0</start>
<act type="pickupShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<act type="deliverShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<end>0.0</end>
</route>
</initialRoutes>
</timeWindows>
</service>
</services>
<shipments>
<shipment id="3">
<pickup>
<location>
<id>i(3,9)</id>
<coord x="10.0" y="10.0"/>
</location>
<duration>10.0</duration>
<timeWindows>
<timeWindow>
<start>1000.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</pickup>
<delivery>
<location>
<id>i(9,9)</id>
<coord x="10.0" y="0.0"/>
</location>
<duration>100.0</duration>
<timeWindows>
<timeWindow>
<start>6000.0</start>
<end>10000.0</end>
</timeWindow>
</timeWindows>
</delivery>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
<shipment id="4">
<pickup>
<location>
<id>[x=10.0][y=10.0]</id>
<coord x="10.0" y="10.0"/>
</location>
<duration>0.0</duration>
<timeWindows>
<timeWindow>
<start>1000.0</start>
<end>4000.0</end>
</timeWindow>
</timeWindows>
</pickup>
<delivery>
<location>
<id>[x=10.0][y=0.0]</id>
<coord x="10.0" y="0.0"/>
</location>
<duration>100.0</duration>
<timeWindows>
<timeWindow>
<start>6000.0</start>
<end>10000.0</end>
</timeWindow>
</timeWindows>
</delivery>
<capacity-dimensions>
<dimension index="0">10</dimension>
</capacity-dimensions>
</shipment>
</shipments>
<initialRoutes>
<route>
<driverId>noDriver</driverId>
<vehicleId>v1</vehicleId>
<start>10.0</start>
<act type="pickupShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<act type="deliverShipment">
<shipmentId>4</shipmentId>
<arrTime>0.0</arrTime>
<endTime>0.0</endTime>
</act>
<end>0.0</end>
</route>
</initialRoutes>
</problem>

View file

@ -1,91 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
</problemType>
<vehicles>
<vehicle>
<id>v1</id>
<typeId>vehType</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>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</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>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
<problemType>
<fleetSize>INFINITE</fleetSize>
</problemType>
<vehicles>
<vehicle>
<id>v1</id>
<typeId>vehType</typeId>
<startLocation>
<id>loc</id>
</startLocation>
<endLocation>
<id>loc</id>
</endLocation>
<timeSchedule>
<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>
</timeSchedule>
<returnToDepot>true</returnToDepot>
</vehicle>
</vehicles>
<vehicleTypes>
<type>
<id>vehType</id>
<capacity-dimensions>
<dimension index="0">20</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>