Skip to content

Commit

Permalink
add reduction of unused vehicleTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
rewertvsp committed Apr 17, 2024
1 parent 09f1e96 commit db13a2c
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ public Integer call() throws Exception {
freightCarriersConfigGroup.setCarriersVehicleTypesFile(config.vehicles().getVehiclesFile());
log.info("Load carriers from: {}", freightCarriersConfigGroup.getCarriersFile());
CarriersUtils.loadCarriersAccordingToFreightConfig(scenario);

// Remove vehicle types which are not used by the carriers
Map<Id<VehicleType>, VehicleType> readVehicleTypes = CarriersUtils.getCarrierVehicleTypes(scenario).getVehicleTypes();
List<Id<VehicleType>> usedCarrierVehicleTypes = CarriersUtils.getCarriers(scenario).getCarriers().values().stream()
.flatMap(carrier -> carrier.getCarrierCapabilities().getCarrierVehicles().values().stream())
.map(vehicle -> vehicle.getType().getId())
.distinct()
.toList();

readVehicleTypes.keySet().removeIf(vehicleType -> !usedCarrierVehicleTypes.contains(vehicleType));

if (Objects.requireNonNull(usedCreationOption) == CreationOption.useExistingCarrierFileWithoutSolution) {
solveSeparatedVRPs(scenario, null);
}
Expand Down

0 comments on commit db13a2c

Please sign in to comment.