Esempio n. 1
0
 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);
 }
 @Override
 public VehicleRoutingProblemSolution createSolution(final VehicleRoutingProblem vrp) {
   logger.info("create initial solution");
   List<VehicleRoute> vehicleRoutes = new ArrayList<>();
   vehicleRoutes.addAll(vrp.getInitialVehicleRoutes());
   Collection<Job> badJobs = insertion.insertJobs(vehicleRoutes, getUnassignedJobs(vrp));
   VehicleRoutingProblemSolution solution =
       new VehicleRoutingProblemSolution(vehicleRoutes, badJobs, Double.MAX_VALUE);
   double costs = solutionCostsCalculator.getCosts(solution);
   solution.setCost(costs);
   if (solutionCostsCalculator instanceof ModularSolutionCostCalculator) {
     ModularSolutionCostCalculator modCalc =
         (ModularSolutionCostCalculator) solutionCostsCalculator;
     solution.setDetailedCost(modCalc.calculate(solution));
   }
   return solution;
 }