mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
prepare for release v0.1.0
This commit is contained in:
parent
77d38de461
commit
a85b0fc395
304 changed files with 4035 additions and 64795 deletions
|
|
@ -1,97 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
* 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
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
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 ChristofidesReader(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 ChristofidesReader(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 ChristofidesReader(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 ChristofidesReader(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 ChristofidesReader(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 ChristofidesReader(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 ChristofidesReader(builder).read(this.getClass().getClassLoader().getResource("vrpnc13.txt").getPath());
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(50.0,((Service)vrp.getJobs().get("2")).getServiceDuration(),0.1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue