コード例 #1
0
ファイル: SolutionAnalyser.java プロジェクト: sanga/jsprit
 /**
  * @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()));
 }
コード例 #2
0
ファイル: SolutionAnalyser.java プロジェクト: sanga/jsprit
 private void recalculateSolutionIndicators() {
   for (VehicleRoute route : solution.getRoutes()) {
     tp_distance += getDistance(route);
     tp_time += getTransportTime(route);
     waiting_time += getWaitingTime(route);
     service_time += getServiceTime(route);
     operation_time += getOperationTime(route);
     tw_violation += getTimeWindowViolation(route);
     cap_violation = Capacity.addup(cap_violation, getCapacityViolation(route));
     fixed_costs += getFixedCosts(route);
     variable_transport_costs += getVariableTransportCosts(route);
     if (hasSkillConstraintViolation(route)) hasSkillConstraintViolation = true;
     if (hasShipmentConstraintViolation(route)) hasShipmentConstraintViolation = true;
     if (hasBackhaulConstraintViolation(route)) hasBackhaulConstraintViolation = true;
     noPickups += getNumberOfPickups(route);
     noPickupsAtBeginning += getNumberOfPickupsAtBeginning(route);
     noDeliveries += getNumberOfDeliveries(route);
     noDeliveriesAtEnd += getNumberOfDeliveriesAtEnd(route);
     pickupLoad = Capacity.addup(pickupLoad, getLoadPickedUp(route));
     pickupLoadAtBeginning = Capacity.addup(pickupLoadAtBeginning, getLoadAtBeginning(route));
     deliveryLoad = Capacity.addup(deliveryLoad, getLoadDelivered(route));
     deliveryLoadAtEnd = Capacity.addup(deliveryLoadAtEnd, getLoadAtEnd(route));
   }
   total_costs = solutionCostCalculator.getCosts(this.solution);
 }
コード例 #3
0
ファイル: SolutionAnalyser.java プロジェクト: sanga/jsprit
 /**
  * @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()));
 }
コード例 #4
0
ファイル: SolutionAnalyser.java プロジェクト: sanga/jsprit
 @Override
 public void visit(TourActivity activity) {
   if (activity instanceof PickupActivity) {
     pickupCounter++;
     pickedUp = Capacity.addup(pickedUp, ((PickupActivity) activity).getJob().getSize());
     if (activity instanceof PickupService) {
       deliverAtEndCounter++;
     }
   } else if (activity instanceof DeliveryActivity) {
     deliveryCounter++;
     delivered = Capacity.addup(delivered, ((DeliveryActivity) activity).getJob().getSize());
     if (activity instanceof DeliverService) {
       pickupAtBeginningCounter++;
     }
   }
 }
コード例 #5
0
ファイル: SolutionAnalyser.java プロジェクト: sanga/jsprit
 /**
  * @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;
 }