From 218e7d9817193031c0cf69dde854e28fa8d39298 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Tue, 22 Jul 2014 20:45:50 +0200 Subject: [PATCH] removed defaultValues from core.algorithm.state.StateManager. Null checking is moved to client classes --- ...outeLevelActivityInsertionCostsEstimator.java | 16 +++++++++------- .../ServiceInsertionOnRouteLevelCalculator.java | 13 +++++++++---- .../core/algorithm/state/StateManager.java | 13 ++++++------- .../jsprit/core/algorithm/state/UpdateLoads.java | 8 +++++++- ...tionAtActivitiesByLookingBackwardInRoute.java | 4 ++++ ...ationAtActivitiesByLookingForwardInRoute.java | 6 +++++- .../UpdateMaxCapacityUtilisationAtRoute.java | 6 +++++- ...liverShipmentLoadActivityLevelConstraint.java | 5 +++++ .../ServiceLoadActivityLevelConstraint.java | 13 ++++++++----- .../ServiceLoadRouteLevelConstraint.java | 12 +++++++++--- .../algorithm/BuildPDVRPAlgoFromScratch_IT.java | 4 +++- .../core/algorithm/state/StateManagerTest.java | 6 +++--- 12 files changed, 73 insertions(+), 33 deletions(-) diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RouteLevelActivityInsertionCostsEstimator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RouteLevelActivityInsertionCostsEstimator.java index 81845ec9..cc2c2951 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RouteLevelActivityInsertionCostsEstimator.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RouteLevelActivityInsertionCostsEstimator.java @@ -64,17 +64,19 @@ class RouteLevelActivityInsertionCostsEstimator implements ActivityInsertionCost * calculates the path costs with new vehicle, c(forwardPath,newVehicle). */ double forwardPathCost_newVehicle = auxilliaryPathCostCalculator.costOfPath(path, depTimeAtPrevAct, iFacts.getNewDriver(), iFacts.getNewVehicle()); - double additionalCosts = forwardPathCost_newVehicle - (actCostsOld(iFacts.getRoute(), path.get(path.size()-1)) - actCostsOld(iFacts.getRoute(), prevAct)); - - return additionalCosts; - + return forwardPathCost_newVehicle - (actCostsOld(iFacts.getRoute(), path.get(path.size()-1)) - actCostsOld(iFacts.getRoute(), prevAct)); } private double actCostsOld(VehicleRoute vehicleRoute, TourActivity act) { - if(act instanceof End){ - return stateManager.getRouteState(vehicleRoute,StateFactory.COSTS,Double.class); + Double cost_at_act; + if(act instanceof End){ + cost_at_act = stateManager.getRouteState(vehicleRoute, StateFactory.COSTS, Double.class); } - return stateManager.getActivityState(act,StateFactory.COSTS,Double.class); + else{ + cost_at_act = stateManager.getActivityState(act, StateFactory.COSTS, Double.class); + } + if(cost_at_act == null) cost_at_act = 0.; + return cost_at_act; } private List getForwardLookingPath(VehicleRoute route, int actIndex) { diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionOnRouteLevelCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionOnRouteLevelCalculator.java index b422ee2e..89823537 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionOnRouteLevelCalculator.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionOnRouteLevelCalculator.java @@ -261,7 +261,9 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC /** * compute cost-diff of tour with and without new activity --> insertion_costs */ - double insertion_costs = auxilliaryPathCostCalculator.costOfPath(wholeTour, start.getEndTime(), newDriver, newVehicle) - stateManager.getRouteState(currentRoute,StateFactory.COSTS,Double.class); + Double currentRouteCosts = stateManager.getRouteState(currentRoute, StateFactory.COSTS, Double.class); + if(currentRouteCosts == null) currentRouteCosts = 0.; + double insertion_costs = auxilliaryPathCostCalculator.costOfPath(wholeTour, start.getEndTime(), newDriver, newVehicle) - currentRouteCosts; /** * if better than best known, make it the best known @@ -307,10 +309,13 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC } private double sumOf_prevCosts_oldVehicle(VehicleRoute vehicleRoute, TourActivity act) { - if(act instanceof End){ - return stateManager.getRouteState(vehicleRoute,StateFactory.COSTS,Double.class); + Double prevCost; + if(act instanceof End){ + prevCost = stateManager.getRouteState(vehicleRoute,StateFactory.COSTS,Double.class); } - return stateManager.getActivityState(act,StateFactory.COSTS,Double.class); + else prevCost = stateManager.getActivityState(act,StateFactory.COSTS,Double.class); + if(prevCost == null) prevCost = 0.; + return prevCost; } /** diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java index dc2e7e5f..dd4c6673 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java @@ -285,7 +285,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart */ @Override public T getActivityState(TourActivity act, StateId stateId, Class type) { -// if(act.getIndex()<0) return getDefaultTypedActivityState(act, stateId, type); + if(act.getIndex()<0) return null; T state; try{ state = type.cast(activity_states[act.getIndex()][stateId.getIndex()]); @@ -293,7 +293,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart catch (ClassCastException e){ throw getClassCastException(e,stateId,type.toString(),activity_states[act.getIndex()][stateId.getIndex()].getClass().toString()); } -// if(state == null) throw new NullPointerException("state " + stateId.toString() + " of activity " + act + " is missing."); return state; } @@ -323,7 +322,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart * @throws java.lang.ClassCastException if type class is not equal to the associated type class of the requested state value */ public T getActivityState(TourActivity act, Vehicle vehicle, StateId stateId, Class type) { -// if(act.getIndex()<0) return getDefaultTypedActivityState(act, stateId, type); + if(act.getIndex()<0) return null; T state; try { state = type.cast(vehicle_dependent_activity_states[act.getIndex()][vehicle.getVehicleTypeIdentifier().getIndex()][stateId.getIndex()]); @@ -332,7 +331,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart Object state_class = vehicle_dependent_activity_states[act.getIndex()][vehicle.getVehicleTypeIdentifier().getIndex()][stateId.getIndex()]; throw getClassCastException(e,stateId,type.toString(),state_class.getClass().toString()); } -// if(state == null) throw new NullPointerException("state " + stateId.toString() + " of activity " + act + " for vehicle " + vehicle.getId() + " is missing."); return state; } @@ -363,10 +361,11 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart * @param type the class of the associated state value * @param the type of the class * @return the route state that is associated to the route and stateId, or null if no state is associated. + * @throws java.lang.ClassCastException if type class is not equal to the associated type class of the requested state value */ @Override public T getRouteState(VehicleRoute route, StateId stateId, Class type) { -// if(route.isEmpty()) return getDefaultTypedRouteState(stateId,type); + if(route.isEmpty()) return null; T state; try{ state = type.cast(route_states[route.getActivities().get(0).getIndex()][stateId.getIndex()]); @@ -374,7 +373,6 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart catch (ClassCastException e){ throw getClassCastException(e,stateId,type.toString(),route_states[route.getActivities().get(0).getIndex()][stateId.getIndex()].getClass().toString()); } - if(state==null) throw new NullPointerException("state " + stateId.toString() + " of route " + route + " is missing."); return state; } @@ -402,7 +400,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart * @throws java.lang.ClassCastException if specified type is not equal to the memorized type */ public T getRouteState(VehicleRoute route, Vehicle vehicle, StateId stateId, Class type) { - if(route.isEmpty()) return getDefaultTypedRouteState(stateId,type); + if(route.isEmpty()) return null; T state; try{ state = type.cast(vehicle_dependent_route_states[route.getActivities().get(0).getIndex()][vehicle.getVehicleTypeIdentifier().getIndex()][stateId.getIndex()]); @@ -413,6 +411,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart return state; } + @Deprecated private T getDefaultTypedRouteState(StateId stateId, Class type) { if(defaultRouteStates_.containsKey(stateId)){ return type.cast(defaultRouteStates_.get(stateId)); diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateLoads.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateLoads.java index 6a97e668..2eeaee0a 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateLoads.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateLoads.java @@ -51,18 +51,22 @@ class UpdateLoads implements ActivityVisitor, StateUpdater, InsertionStartsListe /* * default has one dimension with a value of zero */ - private Capacity currentLoad = Capacity.Builder.newInstance().build(); + private Capacity currentLoad; + + private Capacity defaultValue; private VehicleRoute route; public UpdateLoads(StateManager stateManager) { super(); this.stateManager = stateManager; + defaultValue = Capacity.Builder.newInstance().build(); } @Override public void begin(VehicleRoute route) { currentLoad = stateManager.getRouteState(route, StateFactory.LOAD_AT_BEGINNING, Capacity.class); + if(currentLoad == null) currentLoad = defaultValue; this.route = route; } @@ -103,10 +107,12 @@ class UpdateLoads implements ActivityVisitor, StateUpdater, InsertionStartsListe public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) { if(job2insert instanceof Delivery){ Capacity loadAtDepot = stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING, Capacity.class); + if(loadAtDepot == null) loadAtDepot = defaultValue; stateManager.putTypedInternalRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING, Capacity.addup(loadAtDepot, job2insert.getSize())); } else if(job2insert instanceof Pickup || job2insert instanceof Service){ Capacity loadAtEnd = stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_END, Capacity.class); + if(loadAtEnd == null) loadAtEnd = defaultValue; stateManager.putTypedInternalRouteState(inRoute, StateFactory.LOAD_AT_END, Capacity.addup(loadAtEnd, job2insert.getSize())); } } diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtActivitiesByLookingBackwardInRoute.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtActivitiesByLookingBackwardInRoute.java index 8983060e..785d3af5 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtActivitiesByLookingBackwardInRoute.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtActivitiesByLookingBackwardInRoute.java @@ -38,15 +38,19 @@ class UpdateMaxCapacityUtilisationAtActivitiesByLookingBackwardInRoute implement private VehicleRoute route; private Capacity maxLoad; + + private Capacity defaultValue; public UpdateMaxCapacityUtilisationAtActivitiesByLookingBackwardInRoute(StateManager stateManager) { this.stateManager = stateManager; + defaultValue = Capacity.Builder.newInstance().build(); } @Override public void begin(VehicleRoute route) { this.route = route; maxLoad = stateManager.getRouteState(route, StateFactory.LOAD_AT_BEGINNING, Capacity.class); + if(maxLoad == null) maxLoad = defaultValue; } @Override diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtActivitiesByLookingForwardInRoute.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtActivitiesByLookingForwardInRoute.java index 2863a443..d8a9a8c6 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtActivitiesByLookingForwardInRoute.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtActivitiesByLookingForwardInRoute.java @@ -49,17 +49,21 @@ class UpdateMaxCapacityUtilisationAtActivitiesByLookingForwardInRoute implements private VehicleRoute route; - private Capacity maxLoad = Capacity.Builder.newInstance().build(); + private Capacity maxLoad; + + private Capacity defaultValue; public UpdateMaxCapacityUtilisationAtActivitiesByLookingForwardInRoute(StateManager stateManager) { super(); this.stateManager = stateManager; + defaultValue = Capacity.Builder.newInstance().build(); } @Override public void begin(VehicleRoute route) { this.route = route; maxLoad = stateManager.getRouteState(route, StateFactory.LOAD_AT_END, Capacity.class); + if(maxLoad == null) maxLoad = defaultValue; } @Override diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtRoute.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtRoute.java index 30a94f41..ca83aea8 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtRoute.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxCapacityUtilisationAtRoute.java @@ -43,16 +43,20 @@ class UpdateMaxCapacityUtilisationAtRoute implements ActivityVisitor, StateUpdat private VehicleRoute route; - private Capacity maxLoad = Capacity.Builder.newInstance().build(); + private Capacity maxLoad; + + private Capacity defaultValue; public UpdateMaxCapacityUtilisationAtRoute(StateManager stateManager) { super(); this.stateManager = stateManager; + defaultValue = Capacity.Builder.newInstance().build(); } @Override public void begin(VehicleRoute route) { currentLoad = stateManager.getRouteState(route, StateFactory.LOAD_AT_BEGINNING, Capacity.class); + if(currentLoad == null) currentLoad = defaultValue; maxLoad = currentLoad; this.route = route; } diff --git a/jsprit-core/src/main/java/jsprit/core/problem/constraint/PickupAndDeliverShipmentLoadActivityLevelConstraint.java b/jsprit-core/src/main/java/jsprit/core/problem/constraint/PickupAndDeliverShipmentLoadActivityLevelConstraint.java index 13ce17f1..4b21efe1 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/constraint/PickupAndDeliverShipmentLoadActivityLevelConstraint.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/constraint/PickupAndDeliverShipmentLoadActivityLevelConstraint.java @@ -40,6 +40,8 @@ import jsprit.core.problem.solution.route.state.StateFactory; public class PickupAndDeliverShipmentLoadActivityLevelConstraint implements HardActivityStateLevelConstraint { private RouteAndActivityStateGetter stateManager; + + private Capacity defaultValue; /** * Constructs the constraint ensuring capacity constraint at each activity. @@ -53,6 +55,7 @@ public class PickupAndDeliverShipmentLoadActivityLevelConstraint implements Hard public PickupAndDeliverShipmentLoadActivityLevelConstraint(RouteAndActivityStateGetter stateManager) { super(); this.stateManager = stateManager; + defaultValue = Capacity.Builder.newInstance().build(); } /** @@ -67,9 +70,11 @@ public class PickupAndDeliverShipmentLoadActivityLevelConstraint implements Hard Capacity loadAtPrevAct; if(prevAct instanceof Start){ loadAtPrevAct = stateManager.getRouteState(iFacts.getRoute(), StateFactory.LOAD_AT_BEGINNING, Capacity.class); + if(loadAtPrevAct == null) loadAtPrevAct = defaultValue; } else{ loadAtPrevAct = stateManager.getActivityState(prevAct, StateFactory.LOAD, Capacity.class); + if(loadAtPrevAct == null) loadAtPrevAct = defaultValue; } if(newAct instanceof PickupShipment){ if(!Capacity.addup(loadAtPrevAct, newAct.getSize()).isLessOrEqual(iFacts.getNewVehicle().getType().getCapacityDimensions())){ diff --git a/jsprit-core/src/main/java/jsprit/core/problem/constraint/ServiceLoadActivityLevelConstraint.java b/jsprit-core/src/main/java/jsprit/core/problem/constraint/ServiceLoadActivityLevelConstraint.java index 0a8b6767..c2d0d0dd 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/constraint/ServiceLoadActivityLevelConstraint.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/constraint/ServiceLoadActivityLevelConstraint.java @@ -20,11 +20,7 @@ package jsprit.core.problem.constraint; import jsprit.core.problem.Capacity; import jsprit.core.problem.misc.JobInsertionContext; -import jsprit.core.problem.solution.route.activity.DeliverService; -import jsprit.core.problem.solution.route.activity.PickupService; -import jsprit.core.problem.solution.route.activity.ServiceActivity; -import jsprit.core.problem.solution.route.activity.Start; -import jsprit.core.problem.solution.route.activity.TourActivity; +import jsprit.core.problem.solution.route.activity.*; import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter; import jsprit.core.problem.solution.route.state.StateFactory; @@ -41,10 +37,13 @@ import jsprit.core.problem.solution.route.state.StateFactory; class ServiceLoadActivityLevelConstraint implements HardActivityStateLevelConstraint { private RouteAndActivityStateGetter stateManager; + + private Capacity defaultValue; public ServiceLoadActivityLevelConstraint(RouteAndActivityStateGetter stateManager) { super(); this.stateManager = stateManager; + defaultValue = Capacity.Builder.newInstance().build(); } @Override @@ -53,11 +52,15 @@ class ServiceLoadActivityLevelConstraint implements HardActivityStateLevelConstr Capacity prevMaxLoad; if(prevAct instanceof Start){ futureMaxLoad = stateManager.getRouteState(iFacts.getRoute(), StateFactory.MAXLOAD, Capacity.class); + if(futureMaxLoad == null) futureMaxLoad = defaultValue; prevMaxLoad = stateManager.getRouteState(iFacts.getRoute(), StateFactory.LOAD_AT_BEGINNING, Capacity.class); + if(prevMaxLoad == null) prevMaxLoad = defaultValue; } else{ futureMaxLoad = stateManager.getActivityState(prevAct, StateFactory.FUTURE_MAXLOAD, Capacity.class); + if(futureMaxLoad == null) futureMaxLoad = defaultValue; prevMaxLoad = stateManager.getActivityState(prevAct, StateFactory.PAST_MAXLOAD, Capacity.class); + if(prevMaxLoad == null) prevMaxLoad = defaultValue; } if(newAct instanceof PickupService || newAct instanceof ServiceActivity){ diff --git a/jsprit-core/src/main/java/jsprit/core/problem/constraint/ServiceLoadRouteLevelConstraint.java b/jsprit-core/src/main/java/jsprit/core/problem/constraint/ServiceLoadRouteLevelConstraint.java index beb5bee9..5dd1569d 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/constraint/ServiceLoadRouteLevelConstraint.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/constraint/ServiceLoadRouteLevelConstraint.java @@ -38,28 +38,34 @@ import jsprit.core.problem.solution.route.state.StateFactory; class ServiceLoadRouteLevelConstraint implements HardRouteStateLevelConstraint { private RouteAndActivityStateGetter stateManager; + + private Capacity defaultValue; public ServiceLoadRouteLevelConstraint(RouteAndActivityStateGetter stateManager) { super(); this.stateManager = stateManager; + this.defaultValue = Capacity.Builder.newInstance().build(); } @Override public boolean fulfilled(JobInsertionContext insertionContext) { Capacity maxLoadAtRoute = stateManager.getRouteState(insertionContext.getRoute(), StateFactory.MAXLOAD, Capacity.class); - Capacity capacityDimensions = insertionContext.getNewVehicle().getType().getCapacityDimensions(); + if(maxLoadAtRoute == null) maxLoadAtRoute = defaultValue; + Capacity capacityDimensions = insertionContext.getNewVehicle().getType().getCapacityDimensions(); if(!maxLoadAtRoute.isLessOrEqual(capacityDimensions)){ return false; } if(insertionContext.getJob() instanceof Delivery){ Capacity loadAtDepot = stateManager.getRouteState(insertionContext.getRoute(), StateFactory.LOAD_AT_BEGINNING, Capacity.class); - if(!Capacity.addup(loadAtDepot, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)){ + if(loadAtDepot == null) loadAtDepot = defaultValue; + if(!Capacity.addup(loadAtDepot, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)){ return false; } } else if(insertionContext.getJob() instanceof Pickup || insertionContext.getJob() instanceof Service){ Capacity loadAtEnd = stateManager.getRouteState(insertionContext.getRoute(), StateFactory.LOAD_AT_END, Capacity.class); - if(!Capacity.addup(loadAtEnd, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)){ + if(loadAtEnd == null) loadAtEnd = defaultValue; + if(!Capacity.addup(loadAtEnd, insertionContext.getJob().getSize()).isLessOrEqual(capacityDimensions)){ return false; } } diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPAlgoFromScratch_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPAlgoFromScratch_IT.java index b1cccc7a..b4e60763 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPAlgoFromScratch_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/BuildPDVRPAlgoFromScratch_IT.java @@ -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; } diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/StateManagerTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/state/StateManagerTest.java index 2f90d48a..11c6d586 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/StateManagerTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/state/StateManagerTest.java @@ -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