mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
comply with .editorconfig
This commit is contained in:
parent
58afc3590d
commit
33075b479f
416 changed files with 29653 additions and 29979 deletions
|
|
@ -1,17 +1,17 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package jsprit.instance.reader;
|
||||
|
|
@ -28,78 +28,76 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
|
||||
public class ChristophidesReaderTest {
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_nuOfCustomersIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(50,vrp.getJobs().values().size());
|
||||
}
|
||||
|
||||
private String getPath(String string) {
|
||||
URL resource = this.getClass().getClassLoader().getResource(string);
|
||||
if(resource == null) throw new IllegalStateException("resource " + string + " does not exist");
|
||||
return resource.getPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_fleetSizeIsInfinite(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(FleetSize.INFINITE,vrp.getFleetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleCapacitiesAreCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(160,v.getType().getCapacityDimensions().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(30.0,v.getStartLocation().getCoordinate().getX(),0.01);
|
||||
assertEquals(40.0,v.getStartLocation().getCoordinate().getY(),0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleDurationsAreCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc13.txt"));
|
||||
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 ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(7,vrp.getJobs().get("1").getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_serviceDurationOfCustomerTwoIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc13.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(50.0,((Service)vrp.getJobs().get("2")).getServiceDuration(),0.1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_nuOfCustomersIsCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(50, vrp.getJobs().values().size());
|
||||
}
|
||||
|
||||
private String getPath(String string) {
|
||||
URL resource = this.getClass().getClassLoader().getResource(string);
|
||||
if (resource == null) throw new IllegalStateException("resource " + string + " does not exist");
|
||||
return resource.getPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_fleetSizeIsInfinite() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(FleetSize.INFINITE, vrp.getFleetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleCapacitiesAreCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
assertEquals(160, v.getType().getCapacityDimensions().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
assertEquals(30.0, v.getStartLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(40.0, v.getStartLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleDurationsAreCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc13.txt"));
|
||||
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 ChristofidesReader(builder).read(getPath("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(7, vrp.getJobs().get("1").getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_serviceDurationOfCustomerTwoIsCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new ChristofidesReader(builder).read(getPath("vrpnc13.txt"));
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(50.0, ((Service) vrp.getJobs().get("2")).getServiceDuration(), 0.1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package jsprit.instance.reader;
|
||||
|
|
@ -29,125 +29,129 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
|
||||
public class CordeauReaderTest {
|
||||
|
||||
@Test
|
||||
public void testCordeauReader(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
vrpBuilder.build();
|
||||
|
||||
}
|
||||
|
||||
private String getPath(String string) {
|
||||
URL resource = this.getClass().getClassLoader().getResource(string);
|
||||
if(resource == null) throw new IllegalStateException("resource " + string + " does not exist");
|
||||
return resource.getPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_fleetSizeIsFinite(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(FleetSize.FINITE, vrp.getFleetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNuOfVehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
assertEquals(16,vrp.getVehicles().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectCapacity(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(80, v.getType().getCapacityDimensions().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectDuration(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p08"));
|
||||
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.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("1");
|
||||
assertEquals(37.0, service.getLocation().getCoordinate().getX(), 0.1);
|
||||
assertEquals(52.0, service.getLocation().getCoordinate().getY(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCustomersCordeauInstance_customerTwoShouldHaveCorrectServiceDuration(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
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.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("3");
|
||||
assertEquals(16.0, service.getSize().get(0), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCustomersCordeauInstance_customerFortySevenShouldHaveCorrectDemand(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("47");
|
||||
assertEquals(25.0, service.getSize().get(0), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocationsAndCapOfVehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
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.getType().getCapacityDimensions().get(0) != 80) capacityOk = false;
|
||||
if(v.getStartLocation().getCoordinate().getX() == 20.0 && v.getStartLocation().getCoordinate().getY() == 20.0) loc1ok = true;
|
||||
if(v.getStartLocation().getCoordinate().getX() == 30.0 && v.getStartLocation().getCoordinate().getY() == 40.0) loc2ok = true;
|
||||
if(v.getStartLocation().getCoordinate().getX() == 50.0 && v.getStartLocation().getCoordinate().getY() == 30.0) loc3ok = true;
|
||||
if(v.getStartLocation().getCoordinate().getX() == 60.0 && v.getStartLocation().getCoordinate().getY() == 50.0) loc4ok = true;
|
||||
}
|
||||
assertTrue(capacityOk);
|
||||
assertTrue(loc1ok);
|
||||
assertTrue(loc2ok);
|
||||
assertTrue(loc3ok);
|
||||
assertTrue(loc4ok);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNuOfCustomers(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(50,vrp.getJobs().values().size());
|
||||
}
|
||||
@Test
|
||||
public void testCordeauReader() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
vrpBuilder.build();
|
||||
|
||||
}
|
||||
|
||||
private String getPath(String string) {
|
||||
URL resource = this.getClass().getClassLoader().getResource(string);
|
||||
if (resource == null) throw new IllegalStateException("resource " + string + " does not exist");
|
||||
return resource.getPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_fleetSizeIsFinite() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(FleetSize.FINITE, vrp.getFleetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNuOfVehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
assertEquals(16, vrp.getVehicles().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectCapacity() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
assertEquals(80, v.getType().getCapacityDimensions().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCordeauInstance_vehiclesHaveTheCorrectDuration() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p08"));
|
||||
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.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("1");
|
||||
assertEquals(37.0, service.getLocation().getCoordinate().getX(), 0.1);
|
||||
assertEquals(52.0, service.getLocation().getCoordinate().getY(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCustomersCordeauInstance_customerTwoShouldHaveCorrectServiceDuration() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
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.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("3");
|
||||
assertEquals(16.0, service.getSize().get(0), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingCustomersCordeauInstance_customerFortySevenShouldHaveCorrectDemand() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Service service = (Service) vrp.getJobs().get("47");
|
||||
assertEquals(25.0, service.getSize().get(0), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocationsAndCapOfVehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
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.getType().getCapacityDimensions().get(0) != 80) capacityOk = false;
|
||||
if (v.getStartLocation().getCoordinate().getX() == 20.0 && v.getStartLocation().getCoordinate().getY() == 20.0)
|
||||
loc1ok = true;
|
||||
if (v.getStartLocation().getCoordinate().getX() == 30.0 && v.getStartLocation().getCoordinate().getY() == 40.0)
|
||||
loc2ok = true;
|
||||
if (v.getStartLocation().getCoordinate().getX() == 50.0 && v.getStartLocation().getCoordinate().getY() == 30.0)
|
||||
loc3ok = true;
|
||||
if (v.getStartLocation().getCoordinate().getX() == 60.0 && v.getStartLocation().getCoordinate().getY() == 50.0)
|
||||
loc4ok = true;
|
||||
}
|
||||
assertTrue(capacityOk);
|
||||
assertTrue(loc1ok);
|
||||
assertTrue(loc2ok);
|
||||
assertTrue(loc3ok);
|
||||
assertTrue(loc4ok);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNuOfCustomers() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new CordeauReader(vrpBuilder).read(getPath("p01"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(50, vrp.getJobs().values().size());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,297 +30,296 @@ import java.net.URL;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
public class GoldenReaderTest {
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfVehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(17,vrp.getVehicles().size());
|
||||
}
|
||||
|
||||
private String getPath(String string) {
|
||||
URL resource = this.getClass().getClassLoader().getResource(string);
|
||||
if(resource == null) throw new IllegalStateException("resource " + string + " does not exist");
|
||||
return resource.getPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType1Vehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_1")){
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(4,nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType1VehicleShouldHvTheCorrectCapacity(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_1")){
|
||||
sumOfType1Cap+=v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(80,sumOfType1Cap);
|
||||
}
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfVehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(17, vrp.getVehicles().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType2Vehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_2")){
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(2,nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType2VehicleShouldHvTheCorrectCapacity(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_2") ){
|
||||
sumOfType1Cap+=v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(60,sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType3Vehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_3")){
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(4,nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType3VehicleShouldHvTheCorrectCapacity(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_3")){
|
||||
sumOfType1Cap+=v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(160,sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType4Vehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_4")){
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(4,nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType4VehicleShouldHvTheCorrectCapacity(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_4")){
|
||||
sumOfType1Cap+=v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(280,sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType5Vehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_5") ){
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(2,nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType5VehicleShouldHvTheCorrectCapacity(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_5")){
|
||||
sumOfType1Cap+=v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(240,sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType6Vehicles(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_6")){
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(1,nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType6VehicleShouldHvTheCorrectCapacity(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getType().getTypeId().equals("type_6") ){
|
||||
sumOfType1Cap+=v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(200,sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleShouldHvTheCorrectCoord(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
if(v.getStartLocation().getCoordinate().getX() != 40.0){
|
||||
assertFalse(true);
|
||||
}
|
||||
if(v.getStartLocation().getCoordinate().getY() != 40.0){
|
||||
assertFalse(true);
|
||||
}
|
||||
}
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service1MustHaveCorrectDemand(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Job job = getJob("1",vrp);
|
||||
assertEquals(18,job.getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service1MustHaveCorrectCoordinate(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Coordinate coord = getCoord("1",vrp);
|
||||
assertEquals(22.0,coord.getX(),0.01);
|
||||
assertEquals(22.0,coord.getY(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service15MustHaveCorrectCoordinate(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Coordinate coord = getCoord("15",vrp);
|
||||
assertEquals(62.0,coord.getX(),0.01);
|
||||
assertEquals(24.0,coord.getY(),0.01);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service50MustHaveCorrectCoordinate(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Coordinate coord = getCoord("50",vrp);
|
||||
assertEquals(15.0,coord.getX(),0.01);
|
||||
assertEquals(56.0,coord.getY(),0.01);
|
||||
}
|
||||
|
||||
private Coordinate getCoord(String string, VehicleRoutingProblem vrp) {
|
||||
Job j = getJob(string,vrp);
|
||||
return ((Service)j).getLocation().getCoordinate();
|
||||
}
|
||||
private String getPath(String string) {
|
||||
URL resource = this.getClass().getClassLoader().getResource(string);
|
||||
if (resource == null) throw new IllegalStateException("resource " + string + " does not exist");
|
||||
return resource.getPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType1Vehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_1")) {
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(4, nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType1VehicleShouldHvTheCorrectCapacity() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_1")) {
|
||||
sumOfType1Cap += v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(80, sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType2Vehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_2")) {
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(2, nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType2VehicleShouldHvTheCorrectCapacity() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_2")) {
|
||||
sumOfType1Cap += v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(60, sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType3Vehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_3")) {
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(4, nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType3VehicleShouldHvTheCorrectCapacity() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_3")) {
|
||||
sumOfType1Cap += v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(160, sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType4Vehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_4")) {
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(4, nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType4VehicleShouldHvTheCorrectCapacity() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_4")) {
|
||||
sumOfType1Cap += v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(280, sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType5Vehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_5")) {
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(2, nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType5VehicleShouldHvTheCorrectCapacity() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_5")) {
|
||||
sumOfType1Cap += v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(240, sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_itShouldReadCorrectNuOfType6Vehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int nuOfType1Vehicles = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_6")) {
|
||||
nuOfType1Vehicles++;
|
||||
}
|
||||
}
|
||||
assertEquals(1, nuOfType1Vehicles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_theSumOfType6VehicleShouldHvTheCorrectCapacity() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
int sumOfType1Cap = 0;
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getType().getTypeId().equals("type_6")) {
|
||||
sumOfType1Cap += v.getType().getCapacityDimensions().get(0);
|
||||
}
|
||||
}
|
||||
assertEquals(200, sumOfType1Cap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_vehicleShouldHvTheCorrectCoord() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
if (v.getStartLocation().getCoordinate().getX() != 40.0) {
|
||||
assertFalse(true);
|
||||
}
|
||||
if (v.getStartLocation().getCoordinate().getY() != 40.0) {
|
||||
assertFalse(true);
|
||||
}
|
||||
}
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service1MustHaveCorrectDemand() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Job job = getJob("1", vrp);
|
||||
assertEquals(18, job.getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service1MustHaveCorrectCoordinate() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Coordinate coord = getCoord("1", vrp);
|
||||
assertEquals(22.0, coord.getX(), 0.01);
|
||||
assertEquals(22.0, coord.getY(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service15MustHaveCorrectCoordinate() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Coordinate coord = getCoord("15", vrp);
|
||||
assertEquals(62.0, coord.getX(), 0.01);
|
||||
assertEquals(24.0, coord.getY(), 0.01);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service50MustHaveCorrectCoordinate() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Coordinate coord = getCoord("50", vrp);
|
||||
assertEquals(15.0, coord.getX(), 0.01);
|
||||
assertEquals(56.0, coord.getY(), 0.01);
|
||||
}
|
||||
|
||||
private Coordinate getCoord(String string, VehicleRoutingProblem vrp) {
|
||||
Job j = getJob(string, vrp);
|
||||
return ((Service) j).getLocation().getCoordinate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service4MustHaveCorrectDemand() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Job job = getJob("4", vrp);
|
||||
assertEquals(30, job.getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service50MustHaveCorrectDemand() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Job job = getJob("50", vrp);
|
||||
assertEquals(22, job.getSize().get(0));
|
||||
}
|
||||
|
||||
private Job getJob(String string, VehicleRoutingProblem vrp) {
|
||||
for (Job j : vrp.getJobs().values()) {
|
||||
if (j.getId().equals(string)) {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service4MustHaveCorrectDemand(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Job job = getJob("4",vrp);
|
||||
assertEquals(30,job.getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInstance_service50MustHaveCorrectDemand(){
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPD)
|
||||
.read(getPath("cn_13mix.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
Job job = getJob("50",vrp);
|
||||
assertEquals(22,job.getSize().get(0));
|
||||
}
|
||||
|
||||
private Job getJob(String string, VehicleRoutingProblem vrp) {
|
||||
for(Job j : vrp.getJobs().values()){
|
||||
if(j.getId().equals(string)){
|
||||
return j;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,60 +1,60 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package jsprit.instance.reader;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
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 testFleetSize(){
|
||||
assertEquals(FleetSize.INFINITE,vrp.getFleetSize());
|
||||
}
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
@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 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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package jsprit.instance.reader;
|
||||
|
|
@ -28,81 +28,81 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
|
||||
public class SolomonReaderTest {
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_nuOfCustomersIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(100,vrp.getJobs().values().size());
|
||||
}
|
||||
|
||||
private String getPath() {
|
||||
URL resource = getClass().getClassLoader().getResource("C101_solomon.txt");
|
||||
if(resource == null) throw new IllegalStateException("file C101_solomon.txt does not exist");
|
||||
return resource.getPath();
|
||||
}
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_nuOfCustomersIsCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(100, vrp.getJobs().values().size());
|
||||
}
|
||||
|
||||
private String getPath() {
|
||||
URL resource = getClass().getClassLoader().getResource("C101_solomon.txt");
|
||||
if (resource == null) throw new IllegalStateException("file C101_solomon.txt does not exist");
|
||||
return resource.getPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_fleetSizeIsInfinite() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(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(getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
assertEquals(200, v.getType().getCapacityDimensions().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for (Vehicle v : vrp.getVehicles()) {
|
||||
assertEquals(40.0, v.getStartLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(50.0, v.getStartLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_demandOfCustomerOneIsCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(10, vrp.getJobs().get("1").getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_serviceDurationOfCustomerTwoIsCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(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(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(getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(144.0, ((Service) vrp.getJobs().get("87")).getTimeWindow().getEnd(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_fleetSizeIsInfinite(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(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(getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(200,v.getType().getCapacityDimensions().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_vehicleLocationsAreCorrect_and_correspondToDepotLocation(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
assertEquals(40.0,v.getStartLocation().getCoordinate().getX(),0.01);
|
||||
assertEquals(50.0,v.getStartLocation().getCoordinate().getY(),0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_demandOfCustomerOneIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(10,vrp.getJobs().get("1").getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingSolomonInstance_serviceDurationOfCustomerTwoIsCorrect(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(builder).read(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(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(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