private Set<String> getInitialVehicleIds(VehicleRoutingProblem vehicleRoutingProblem) { Set<String> ids = new HashSet<String>(); for (VehicleRoute r : vehicleRoutingProblem.getInitialVehicleRoutes()) { ids.add(r.getVehicle().getId()); } return ids; }
@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; }