mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
ini
This commit is contained in:
commit
3581d6e097
435 changed files with 46952 additions and 0 deletions
|
|
@ -0,0 +1,101 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package readers;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.route.Vehicle;
|
||||
|
||||
public class ChristophidesReaderTest {
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_nuOfCustomersIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristophidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(50,vrp.getJobs().values().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_fleetSizeIsInfinite(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristophidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(FleetSize.INFINITE,vrp.getFleetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleCapacitiesAreCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristophidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(160,v.getCapacity());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristophidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(30.0,v.getCoord().getX(),0.01);
|
||||
assertEquals(40.0,v.getCoord().getY(),0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleDurationsAreCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristophidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc13.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(0.0,v.getEarliestDeparture(),0.01);
|
||||
assertEquals(720.0,v.getLatestArrival()-v.getEarliestDeparture(),0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_demandOfCustomerOneIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristophidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc1.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(7,vrp.getJobs().get("1").getCapacityDemand());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_serviceDurationOfCustomerTwoIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristophidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc13.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(50.0,((Service)vrp.getJobs().get("2")).getServiceDuration(),0.1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
148
jsprit-instances/src/test/java/readers/CordeauReaderTest.java
Normal file
148
jsprit-instances/src/test/java/readers/CordeauReaderTest.java
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package readers;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.route.Vehicle;
|
||||
|
||||
public class CordeauReaderTest {
|
||||
|
||||
@Test
|
||||
public void testCordeauReader(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
vrpBuilder.build();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_fleetSizeIsFinite(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(FleetSize.FINITE, vrp.getFleetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNuOfVehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(16,vrp.getVehicles().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectCapacity(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(80, v.getCapacity());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectDuration(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p08").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(0.0,v.getEarliestDeparture(),0.1);
|
||||
assertEquals(310.0, v.getLatestArrival()-v.getEarliestDeparture(),0.1);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCustomersCordeauInstance_customerOneShouldHaveCorrectCoordinates(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("1");
|
||||
assertEquals(37.0, service.getCoord().getX(), 0.1);
|
||||
assertEquals(52.0, service.getCoord().getY(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCustomersCordeauInstance_customerTwoShouldHaveCorrectServiceDuration(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("2");
|
||||
assertEquals(0.0, service.getServiceDuration(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCustomersCordeauInstance_customerThreeShouldHaveCorrectDemand(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("3");
|
||||
assertEquals(16.0, service.getCapacityDemand(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCustomersCordeauInstance_customerFortySevenShouldHaveCorrectDemand(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("47");
|
||||
assertEquals(25.0, service.getCapacityDemand(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocationsAndCapOfVehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
boolean capacityOk = true;
|
||||
boolean loc1ok = false;
|
||||
boolean loc2ok = false;
|
||||
boolean loc3ok = false;
|
||||
boolean loc4ok = false;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getCapacity() != 80) capacityOk = false;
|
||||
if(v.getCoord().getX() == 20.0 && v.getCoord().getY() == 20.0) loc1ok = true;
|
||||
if(v.getCoord().getX() == 30.0 && v.getCoord().getY() == 40.0) loc2ok = true;
|
||||
if(v.getCoord().getX() == 50.0 && v.getCoord().getY() == 30.0) loc3ok = true;
|
||||
if(v.getCoord().getX() == 60.0 && v.getCoord().getY() == 50.0) loc4ok = true;
|
||||
}
|
||||
assertTrue(capacityOk);
|
||||
assertTrue(loc1ok);
|
||||
assertTrue(loc2ok);
|
||||
assertTrue(loc3ok);
|
||||
assertTrue(loc4ok);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNuOfCustomers(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.newBuilderInstance();
|
||||
new CordeauReader(vrpBuilder).read(this.getClass().getClassLoader().getResource("p01").getPath());
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(50,vrp.getJobs().values().size());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package readers;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetComposition;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
|
||||
public class LuiShenReaderTest {
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
|
||||
@Before
|
||||
public void doBefore(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new LuiShenReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath(),
|
||||
this.getClass().getClassLoader().getResource("C1_LuiShenVehicles.txt").getPath(), "a");
|
||||
vrp = builder.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFleetCompostion(){
|
||||
assertEquals(FleetComposition.HETEROGENEOUS,vrp.getFleetComposition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFleetSize(){
|
||||
assertEquals(FleetSize.INFINITE,vrp.getFleetSize());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNuOfTypes(){
|
||||
assertEquals(3, vrp.getTypes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNuOfRepresentativeVehicles(){
|
||||
assertEquals(3, vrp.getVehicles().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNuOfJobs(){
|
||||
assertEquals(100,vrp.getJobs().values().size());
|
||||
}
|
||||
}
|
||||
104
jsprit-instances/src/test/java/readers/SolomonReaderTest.java
Normal file
104
jsprit-instances/src/test/java/readers/SolomonReaderTest.java
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package readers;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.route.Vehicle;
|
||||
|
||||
public class SolomonReaderTest {
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_nuOfCustomersIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(100,vrp.getJobs().values().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_fleetSizeIsInfinite(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(FleetSize.INFINITE,vrp.getFleetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_vehicleCapacitiesAreCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(200,v.getCapacity());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(40.0,v.getCoord().getX(),0.01);
|
||||
assertEquals(50.0,v.getCoord().getY(),0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_demandOfCustomerOneIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(10,vrp.getJobs().get("1").getCapacityDemand());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_serviceDurationOfCustomerTwoIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(90,((Service)vrp.getJobs().get("2")).getServiceDuration(),0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_earliestServiceStartTimeOfCustomerSixtyTwoIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(262.0,((Service)vrp.getJobs().get("62")).getTimeWindow().getStart(),0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_latestServiceStartTimeOfCustomerEightySevenIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(this.getClass().getClassLoader().getResource("C101_solomon.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(144.0,((Service)vrp.getJobs().get("87")).getTimeWindow().getEnd(),0.1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue