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

removed defaultValues from core.algorithm.state.StateManager.

Null checking is moved to client classes
This commit is contained in:
oblonski 2014-07-22 20:45:50 +02:00
parent c13d6d8901
commit 218e7d9817
12 changed files with 73 additions and 33 deletions

View file

@ -80,7 +80,9 @@ public class BuildPDVRPAlgoFromScratch_IT {
public double getCosts(VehicleRoutingProblemSolution solution) {
double costs = 0.0;
for(VehicleRoute route : solution.getRoutes()){
costs += stateManager.getRouteState(route, StateFactory.COSTS, Double.class);
Double cost_of_route = stateManager.getRouteState(route, StateFactory.COSTS, Double.class);
if(cost_of_route == null) cost_of_route = 0.;
costs += cost_of_route;
}
return costs;
}

View file

@ -125,14 +125,14 @@ public class StateManagerTest {
}
@Test
public void whenProblemStateIsSetAndStateManagerClearedAfterwards_itReturnsDefault(){
public void whenProblemStateIsSetAndStateManagerClearedAfterwards_itReturnsNull(){
StateManager stateManager = new StateManager(mock(VehicleRoutingProblem.class));
StateId id = StateFactory.createId("problemState");
stateManager.addDefaultProblemState(id, Boolean.class, false);
stateManager.putProblemState(id, Boolean.class, true);
stateManager.clear();
boolean problemState = stateManager.getProblemState(id, Boolean.class);
assertFalse(problemState);
Boolean problemState = stateManager.getProblemState(id, Boolean.class);
assertNull(problemState);
}
@Test