Exemplo n.º 1
0
 /**
  * @param route to get the capacity violation from (at end of the route)
  * @return violation, i.e. all dimensions and their corresponding violation. For example, if
  *     vehicle has two capacity dimension with dimIndex=0 and dimIndex=1 and dimIndex=1 is
  *     violated by 4 units then this method returns
  *     [[dimIndex=0][dimValue=0][dimIndex=1][dimValue=4]]
  */
 public Capacity getCapacityViolationAtEnd(VehicleRoute route) {
   if (route == null) throw new IllegalArgumentException("route is missing.");
   Capacity atEnd = getLoadAtEnd(route);
   return Capacity.max(
       Capacity.Builder.newInstance().build(),
       Capacity.subtract(atEnd, route.getVehicle().getType().getCapacityDimensions()));
 }
Exemplo n.º 2
0
 /**
  * @param route to get the capacity violation from (at activity of the route)
  * @return violation, i.e. all dimensions and their corresponding violation. For example, if
  *     vehicle has two capacity dimension with dimIndex=0 and dimIndex=1 and dimIndex=1 is
  *     violated by 4 units then this method returns
  *     [[dimIndex=0][dimValue=0][dimIndex=1][dimValue=4]]
  */
 public Capacity getCapacityViolationAfterActivity(TourActivity activity, VehicleRoute route) {
   if (route == null) throw new IllegalArgumentException("route is missing.");
   if (activity == null) throw new IllegalArgumentException("activity is missing.");
   Capacity afterAct = getLoadRightAfterActivity(activity, route);
   return Capacity.max(
       Capacity.Builder.newInstance().build(),
       Capacity.subtract(afterAct, route.getVehicle().getType().getCapacityDimensions()));
 }
Exemplo n.º 3
0
 /**
  * @param activity to get the load from (before activity)
  * @return load just before the specified activity. If act is Start, it returns the load
  *     atBeginning of the specified route. If act is End, it returns the load atEnd of specified
  *     route.
  */
 public Capacity getLoadJustBeforeActivity(TourActivity activity, VehicleRoute route) {
   if (route == null) throw new IllegalArgumentException("route is missing.");
   if (activity == null) throw new IllegalArgumentException("activity is missing.");
   if (activity instanceof Start) return getLoadAtBeginning(route);
   if (activity instanceof End) return getLoadAtEnd(route);
   verifyThatRouteContainsAct(activity, route);
   Capacity afterAct =
       stateManager.getActivityState(activity, InternalStates.LOAD, Capacity.class);
   if (afterAct != null && activity.getSize() != null) {
     return Capacity.subtract(afterAct, activity.getSize());
   } else if (afterAct != null) return afterAct;
   else return null;
 }