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

inspect and remove warnings

This commit is contained in:
Stefan Schroeder 2013-12-18 17:05:19 +01:00
parent 7ec9786c2b
commit 5ff6d40d63
63 changed files with 86 additions and 283 deletions

View file

@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals;
import java.util.Collection;
import jsprit.core.algorithm.acceptor.GreedyAcceptance;
import jsprit.core.algorithm.listener.IterationStartsListener;
import jsprit.core.algorithm.module.RuinAndRecreateModule;
import jsprit.core.algorithm.recreate.BestInsertionBuilder;
import jsprit.core.algorithm.recreate.InsertionStrategy;

View file

@ -28,6 +28,7 @@ import jsprit.core.algorithm.ruin.RuinStrategy;
import jsprit.core.algorithm.ruin.distance.AvgServiceDistance;
import jsprit.core.algorithm.selector.SelectBest;
import jsprit.core.algorithm.state.StateManager;
import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.constraint.ConstraintManager;
import jsprit.core.problem.io.VrpXMLReader;
@ -106,7 +107,7 @@ public class BuildPDVRPAlgoFromScratch_IT {
vra.addInitialSolution(iniSolution);
vra.setNuOfIterations(1000);
vra.setPrematureBreak(100);
vra.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100));
}

View file

@ -16,6 +16,8 @@
******************************************************************************/
package jsprit.core.algorithm;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import jsprit.core.algorithm.acceptor.GreedyAcceptance;
@ -38,7 +40,6 @@ import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.solution.route.state.StateFactory;
import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
import jsprit.core.problem.vehicle.VehicleFleetManager;
import jsprit.core.util.Solutions;
import org.apache.log4j.Logger;
import org.junit.Before;
@ -119,7 +120,7 @@ public class BuildPDVRPWithShipmentsAlgoFromScratch_IT {
@Test
public void test(){
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
VehicleRoutingProblemSolution best = Solutions.bestOf(solutions);
assertTrue(!solutions.isEmpty());
}
}

View file

@ -27,6 +27,7 @@ import java.util.Collection;
import java.util.Map;
import jsprit.core.algorithm.box.GreedySchrimpfFactory;
import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
@ -184,7 +185,7 @@ public class RefuseCollection_IT {
vrpBuilder.setRoutingCost(matrixBuilder.build());
VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrp);
vra.setPrematureBreak(100);
vra.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100));
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(397.0,Solutions.bestOf(solutions).getCost(),0.01);
@ -209,7 +210,7 @@ public class RefuseCollection_IT {
/*
* and add it to problem
*/
vrpBuilder.addService(service);
vrpBuilder.addJob(service);
}
reader.close();
}

View file

@ -25,8 +25,6 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import jsprit.core.algorithm.acceptor.GreedyAcceptance;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import org.junit.Test;
@ -39,7 +37,6 @@ public class AcceptNewRemoveWorstTest {
@Test
public void whenHavingNewSolAndLimitedMemory_removeWorstAndAddNew(){
VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
VehicleRoutingProblemSolution sol1 = mock(VehicleRoutingProblemSolution.class);
VehicleRoutingProblemSolution sol2 = mock(VehicleRoutingProblemSolution.class);
when(sol1.getCost()).thenReturn(1.0);

View file

@ -16,10 +16,6 @@
******************************************************************************/
package jsprit.core.algorithm.box;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.box.SchrimpfFactory;
import jsprit.core.problem.VehicleRoutingProblem;
import org.junit.Test;
@ -28,8 +24,6 @@ public class TestSchrimpf {
@Test
public void whenUsingSchrimpfFactory_itFindsTheConfig(){
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(VehicleRoutingProblem.Builder.newInstance().build());
}
}

View file

@ -148,9 +148,6 @@ public class TestAlgorithmReader {
String acceptorName = "acceptor";
String acceptorId = "acceptorId";
String moduleName = "acceptor";
String moduleId = "acceptorId";
ModKey key = new ModKey(acceptorName,acceptorId);
RuinStrategyKey accKey = new RuinStrategyKey(key);
RuinStrategy acceptor = new RuinStrategy(){
@ -221,6 +218,7 @@ public class TestAlgorithmReader {
@SuppressWarnings("deprecation")
@Test
public void initialiseConstructionAlgoCorrectly(){
VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, config);
@ -229,18 +227,21 @@ public class TestAlgorithmReader {
@Test
public void whenCreatingAlgorithm_nOfStrategiesIsCorrect(){
@SuppressWarnings("deprecation")
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, config);
assertEquals(3, algo.getSearchStrategyManager().getStrategies().size());
}
@Test
public void whenCreatingAlgorithm_nOfIterationsIsReadCorrectly(){
@SuppressWarnings("deprecation")
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, config);
assertEquals(10, algo.getNuOfIterations());
}
@Test
public void whenCreatingAlgorithm_nOfStrategyModulesIsCorrect(){
@SuppressWarnings("deprecation")
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, config);
int nOfModules = 0;
for(SearchStrategy strat : algo.getSearchStrategyManager().getStrategies()){
@ -248,22 +249,5 @@ public class TestAlgorithmReader {
}
assertEquals(3, nOfModules);
}
// @Test
// public void whenCreatingAlgorithm_regretInsertionIsReadCorrectly(){
// VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/configWithRegretInsertion.xml");
// int nOfModules = 0;
// for(SearchStrategy strat : algo.getSearchStrategyManager().getStrategies()){
// for(SearchStrategyModule module : strat.getSearchStrategyModules()){
// if(module.getName().contains("ruin_and_recreate")){
// nOfModules++;
// }
// }
//
// }
// assertEquals(3, nOfModules);
//
// }
//
}

View file

@ -46,7 +46,7 @@ public class CalcWithTimeSchedulingTest {
setLocationCoord(Coordinate.newInstance(0, 0)).setLocationId("0,0")
.setType(VehicleTypeImpl.Builder.newInstance("myType", 20).setCostPerDistance(1.0).build()).build();
vrpBuilder.addVehicle(vehicle);
vrpBuilder.addService(Service.Builder.newInstance("myService", 2).setLocationId("0,20").setCoord(Coordinate.newInstance(0, 20)).build());
vrpBuilder.addJob(Service.Builder.newInstance("myService", 2).setLocationId("0,20").setCoord(Coordinate.newInstance(0, 20)).build());
vrpBuilder.setFleetSize(FleetSize.INFINITE);
vrpBuilder.setRoutingCost(getTpCosts(new CrowFlyCosts(vrpBuilder.getLocations())));
VehicleRoutingProblem vrp = vrpBuilder.build();
@ -54,7 +54,7 @@ public class CalcWithTimeSchedulingTest {
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/testConfig.xml");
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
VehicleRoutingProblemSolution sol = Solutions.getBest(solutions);
VehicleRoutingProblemSolution sol = Solutions.bestOf(solutions);
assertEquals(40.0,sol.getCost(),0.01);
assertEquals(1, sol.getRoutes().size());
VehicleRoute route = sol.getRoutes().iterator().next();

View file

@ -22,7 +22,6 @@ import jsprit.core.problem.driver.DriverImpl;
import jsprit.core.problem.job.Pickup;
import jsprit.core.problem.job.Shipment;
import jsprit.core.problem.misc.JobInsertionContext;
import jsprit.core.problem.solution.route.RouteActivityVisitor;
import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.solution.route.activity.TourActivity;
import jsprit.core.problem.vehicle.Vehicle;
@ -212,8 +211,6 @@ public class ShipmentInsertionCalculatorTest {
public void whenInsertingServiceWhileNoCapIsAvailable_itMustReturnNoInsertionData(){
Shipment shipment = Shipment.Builder.newInstance("s", 1).setPickupLocation("0,10").setDeliveryLocation("0,0").build();
Shipment shipment2 = Shipment.Builder.newInstance("s2", 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build();
Shipment shipment3 = Shipment.Builder.newInstance("s3", 1).setPickupLocation("10,10").setDeliveryLocation("0,").build();
VehicleRoute route = VehicleRoute.emptyRoute();
route.setVehicle(vehicle, 0.0);

View file

@ -16,7 +16,6 @@
******************************************************************************/
package jsprit.core.algorithm.recreate;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

View file

@ -17,7 +17,6 @@
package jsprit.core.algorithm.recreate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

View file

@ -17,7 +17,6 @@
package jsprit.core.algorithm.recreate;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import java.util.Collection;
@ -33,7 +32,6 @@ import jsprit.core.problem.solution.route.activity.TimeWindow;
import jsprit.core.problem.solution.route.activity.TourActivity;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.problem.vehicle.VehicleImpl;
import jsprit.core.problem.vehicle.VehicleType;
import jsprit.core.problem.vehicle.VehicleTypeImpl;
import jsprit.core.util.Coordinate;
import jsprit.core.util.Solutions;
@ -47,7 +45,6 @@ public class TestDepartureTimeOpt {
public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_totalCostsShouldBe50(){
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
VehicleType type = mock(VehicleTypeImpl.class);
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
.setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build();
@ -62,12 +59,12 @@ public class TestDepartureTimeOpt {
}
});
VehicleRoutingProblem vrp = vrpBuilder.addService(service).addVehicle(vehicle).build();
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addVehicle(vehicle).build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(20.0+30.0,Solutions.getBest(solutions).getCost(),0.1);
assertEquals(20.0+30.0,Solutions.bestOf(solutions).getCost(),0.1);
}
@ -75,7 +72,6 @@ public class TestDepartureTimeOpt {
public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_depTimeShouldBe0(){
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build();
VehicleType type = mock(VehicleTypeImpl.class);
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0))
.setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build();
@ -90,12 +86,12 @@ public class TestDepartureTimeOpt {
}
});
VehicleRoutingProblem vrp = vrpBuilder.addService(service).addVehicle(vehicle).build();
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addVehicle(vehicle).build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(0.0,Solutions.getBest(solutions).getRoutes().iterator().next().getStart().getEndTime(),0.1);
assertEquals(0.0,Solutions.bestOf(solutions).getRoutes().iterator().next().getStart().getEndTime(),0.1);
}
@ -117,13 +113,13 @@ public class TestDepartureTimeOpt {
}
});
VehicleRoutingProblem vrp = vrpBuilder.addService(service).addVehicle(vehicle).build();
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addVehicle(vehicle).build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigWithDepartureTimeChoice.xml");
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(20.0,Solutions.getBest(solutions).getCost(),0.1);
assertEquals(20.0,Solutions.bestOf(solutions).getCost(),0.1);
}
@ -145,13 +141,13 @@ public class TestDepartureTimeOpt {
}
});
VehicleRoutingProblem vrp = vrpBuilder.addService(service).addVehicle(vehicle).build();
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addVehicle(vehicle).build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigWithDepartureTimeChoice.xml");
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(30.0,Solutions.getBest(solutions).getRoutes().iterator().next().getStart().getEndTime(),0.1);
assertEquals(30.0,Solutions.bestOf(solutions).getRoutes().iterator().next().getStart().getEndTime(),0.1);
}
@ -177,13 +173,13 @@ public class TestDepartureTimeOpt {
}
});
VehicleRoutingProblem vrp = vrpBuilder.addService(service).addService(service2).addVehicle(vehicle).build();
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addJob(service2).addVehicle(vehicle).build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigWithDepartureTimeChoice.xml");
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(40.0,Solutions.getBest(solutions).getCost(),0.1);
assertEquals(40.0,Solutions.bestOf(solutions).getCost(),0.1);
}
@ -209,13 +205,13 @@ public class TestDepartureTimeOpt {
}
});
VehicleRoutingProblem vrp = vrpBuilder.addService(service).addService(service2).addVehicle(vehicle).build();
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addJob(service2).addVehicle(vehicle).build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigWithDepartureTimeChoice.xml");
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(10.0,Solutions.getBest(solutions).getRoutes().iterator().next().getStart().getEndTime(),0.1);
assertEquals(10.0,Solutions.bestOf(solutions).getRoutes().iterator().next().getStart().getEndTime(),0.1);
}

View file

@ -1,9 +1,6 @@
package jsprit.core.algorithm.recreate;
import static org.junit.Assert.*;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.recreate.BestInsertionBuilder;
import jsprit.core.algorithm.recreate.InsertionStrategy;
import static org.junit.Assert.assertTrue;
import jsprit.core.algorithm.state.StateManager;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.constraint.ConstraintManager;
@ -13,12 +10,11 @@ import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.problem.vehicle.VehicleFleetManager;
import jsprit.core.problem.vehicle.VehicleImpl;
import jsprit.core.problem.vehicle.VehicleImpl.Builder;
import jsprit.core.problem.vehicle.VehicleType;
import jsprit.core.problem.vehicle.VehicleTypeImpl;
import jsprit.core.problem.vehicle.VehicleImpl.Builder;
import jsprit.core.util.Coordinate;
import org.junit.Before;
import org.junit.Test;
@ -78,8 +74,6 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra;
final StateManager stateManager = new StateManager(vrp);
@ -91,6 +85,7 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
BestInsertionBuilder bestIBuilder = new BestInsertionBuilder(vrp, fleetManager, stateManager,constraintManager);
bestIBuilder.setRouteLevel(2, 2);
@SuppressWarnings("unused")
InsertionStrategy bestInsertion = bestIBuilder.build();
}
@ -144,8 +139,6 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra;
final StateManager stateManager = new StateManager(vrp);
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
@ -156,6 +149,7 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
BestInsertionBuilder bestIBuilder = new BestInsertionBuilder(vrp, fleetManager, stateManager,constraintManager);
bestIBuilder.setRouteLevel(2, 2);
@SuppressWarnings("unused")
InsertionStrategy bestInsertion = bestIBuilder.build();
assertTrue(true);

View file

@ -1,13 +1,12 @@
package jsprit.core.algorithm.ruin;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import jsprit.core.algorithm.ruin.RuinRadial.JobNeighborhoodsImpl;
import jsprit.core.algorithm.ruin.RuinRadial.JobNeighborhoodsImplWithCapRestriction;
import jsprit.core.algorithm.ruin.distance.EuclideanServiceDistance;
import jsprit.core.algorithm.ruin.distance.JobDistance;

View file

@ -46,6 +46,7 @@ public class TestJobDistanceAvgCosts {
@Override
public double getTransportCost(String fromId, String toId,
double departureTime, Driver driver, Vehicle vehicle) {
@SuppressWarnings("unused")
String vehicleId = vehicle.getId();
return 0;
}
@ -82,6 +83,7 @@ public class TestJobDistanceAvgCosts {
@Override
public double getTransportCost(String fromId, String toId,
double departureTime, Driver driver, Vehicle vehicle) {
@SuppressWarnings("unused")
String vehicleId = vehicle.getId();
return 0;
}

View file

@ -53,7 +53,7 @@ public class SelectBestTest {
@Test
public void whenHavingNoSolutions_returnNull(){
assertNull(new SelectBest().selectSolution(Collections.EMPTY_LIST));
assertNull(new SelectBest().selectSolution(Collections.<VehicleRoutingProblemSolution> emptyList()));
}
}

View file

@ -78,6 +78,6 @@ public class SelectRandomlyTest {
SelectRandomly selectRandomly = new SelectRandomly();
selectRandomly.setRandom(random);
assertNull(selectRandomly.selectSolution(Collections.EMPTY_LIST));
assertNull(selectRandomly.selectSolution(Collections.<VehicleRoutingProblemSolution> emptyList()));
}
}

View file

@ -26,9 +26,7 @@ import java.util.Collection;
import java.util.List;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.FleetComposition;
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
import jsprit.core.problem.io.VrpXMLReader;
import jsprit.core.problem.job.Job;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.job.Shipment;
@ -53,7 +51,6 @@ public class VrpReaderV2Test {
new VrpXMLReader(builder, null).read(inFileName);
VehicleRoutingProblem vrp = builder.build();
assertEquals(FleetSize.FINITE,vrp.getFleetSize());
assertEquals(FleetComposition.HETEROGENEOUS,vrp.getFleetComposition());
}
@Test

View file

@ -17,23 +17,10 @@
package jsprit.core.problem.io;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.VehicleRoutingProblem.Builder;
import jsprit.core.problem.VehicleRoutingProblem.FleetComposition;
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
import jsprit.core.problem.io.VrpXMLReader;
import jsprit.core.problem.io.VrpXMLWriter;
import jsprit.core.problem.job.Service;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.solution.route.activity.End;
import jsprit.core.problem.solution.route.activity.ServiceActivity;
import jsprit.core.problem.solution.route.activity.Start;
import jsprit.core.problem.vehicle.Vehicle;
import jsprit.core.problem.vehicle.VehicleImpl;
import jsprit.core.problem.vehicle.VehicleTypeImpl;
@ -55,7 +42,6 @@ public class VrpWriterV2Test {
@Test
public void whenWritingInfiniteVrp_itWritesCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
builder.setFleetComposition(FleetComposition.HETEROGENEOUS);
builder.setFleetSize(FleetSize.INFINITE);
// Depot depot = new Depot("depotLoc",Coordinate.newInstance(0, 0));
// Depot depot2 = new Depot("depotLoc2",Coordinate.newInstance(100, 100));
@ -72,7 +58,6 @@ public class VrpWriterV2Test {
@Test
public void whenWritingFiniteVrp_itWritesCorrectly(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
builder.setFleetComposition(FleetComposition.HETEROGENEOUS);
builder.setFleetSize(FleetSize.FINITE);
// Depot depot = new Depot("depotLoc",Coordinate.newInstance(0, 0));
// Depot depot2 = new Depot("depotLoc2",Coordinate.newInstance(100, 100));
@ -81,8 +66,6 @@ public class VrpWriterV2Test {
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build();
builder.addVehicleType(type1);
builder.addVehicleType(type2);
builder.addVehicle(v1);
builder.addVehicle(v2);
VehicleRoutingProblem vrp = builder.build();
@ -92,7 +75,6 @@ public class VrpWriterV2Test {
@Test
public void t(){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
builder.setFleetComposition(FleetComposition.HETEROGENEOUS);
builder.setFleetSize(FleetSize.FINITE);
// Depot depot = new Depot("depotLoc",Coordinate.newInstance(0, 0));
// Depot depot2 = new Depot("depotLoc2",Coordinate.newInstance(100, 100));
@ -101,8 +83,6 @@ public class VrpWriterV2Test {
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build();
builder.addVehicleType(type1);
builder.addVehicleType(type2);
builder.addVehicle(v1);
builder.addVehicle(v2);
VehicleRoutingProblem vrp = builder.build();
@ -121,15 +101,13 @@ public class VrpWriterV2Test {
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build();
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build();
builder.addVehicleType(type1);
builder.addVehicleType(type2);
builder.addVehicle(v1);
builder.addVehicle(v2);
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
VehicleRoutingProblem vrp = builder.addService(s1).addService(s2).build();
VehicleRoutingProblem vrp = builder.addJob(s1).addJob(s2).build();
new VrpXMLWriter(vrp, null).write(infileName);
VehicleRoutingProblem.Builder vrpToReadBuilder = VehicleRoutingProblem.Builder.newInstance();

View file

@ -52,16 +52,14 @@ public class TestVehicleRoute {
@Test
public void whenBuildingEmptyRouteCorrectly_go(){
VehicleRoute route = VehicleRoute.newInstance(TourActivities.emptyTour(),DriverImpl.noDriver(),VehicleImpl.noVehicle());
assertTrue(true);
assertTrue(route!=null);
}
@Test
public void whenBuildingEmptyRouteCorrectlyV2_go(){
VehicleRoute route = VehicleRoute.emptyRoute();
assertTrue(true);
assertTrue(route!=null);
}
@Test
@ -78,17 +76,16 @@ public class TestVehicleRoute {
@Test(expected=IllegalStateException.class)
public void whenBuildingEmptyRoute_(){
@SuppressWarnings("unused")
VehicleRoute route = VehicleRoute.newInstance(null,null,null);
}
@Test(expected=IllegalStateException.class)
public void whenBuildingRouteWithNonEmptyTour_throwException(){
TourActivities tour = new TourActivities();
tour.addActivity(ServiceActivity.newInstance(Service.Builder.newInstance("jo", 10).build()));
@SuppressWarnings("unused")
VehicleRoute route = VehicleRoute.newInstance(tour,DriverImpl.noDriver(),VehicleImpl.noVehicle());
}
@Test
@ -99,6 +96,7 @@ public class TestVehicleRoute {
Iterator<TourActivity> iter = route.getTourActivities().iterator();
int count = 0;
while(iter.hasNext()){
@SuppressWarnings("unused")
TourActivity act = iter.next();
count++;
}
@ -113,6 +111,7 @@ public class TestVehicleRoute {
Iterator<TourActivity> iter = route.getTourActivities().iterator();
int count = 0;
while(iter.hasNext()){
@SuppressWarnings("unused")
TourActivity act = iter.next();
count++;
}
@ -130,6 +129,7 @@ public class TestVehicleRoute {
Iterator<TourActivity> iter = route.getTourActivities().iterator();
int count = 0;
while(iter.hasNext()){
@SuppressWarnings("unused")
TourActivity act = iter.next();
count++;
}
@ -140,6 +140,7 @@ public class TestVehicleRoute {
Iterator<TourActivity> iter = route.getTourActivities().iterator();
int count = 0;
while(iter.hasNext()){
@SuppressWarnings("unused")
TourActivity act = iter.next();
count++;
}
@ -154,6 +155,7 @@ public class TestVehicleRoute {
Iterator<TourActivity> iter = route.getTourActivities().reverseActivityIterator();
int count = 0;
while(iter.hasNext()){
@SuppressWarnings("unused")
TourActivity act = iter.next();
count++;
}
@ -168,6 +170,7 @@ public class TestVehicleRoute {
Iterator<TourActivity> iter = route.getTourActivities().reverseActivityIterator();
int count = 0;
while(iter.hasNext()){
@SuppressWarnings("unused")
TourActivity act = iter.next();
count++;
}

View file

@ -42,7 +42,7 @@ public class TestRefs {
private void doSmth(List<Start> starts) {
int count = 0;
for(Start s : starts){
for(@SuppressWarnings("unused") Start s : starts){
s = Start.newInstance("yo_"+count,0.0,0.0);
count++;
}

View file

@ -64,6 +64,7 @@ public class TestVehicleFleetManager extends TestCase{
assertEquals(1, vehicles.size());
try{
fleetManager.lock(v1);
@SuppressWarnings("unused")
Collection<Vehicle> vehicles_ = fleetManager.getAvailableVehicles();
assertFalse(true);
}