Skip to content

Commit

Permalink
Merge branch 'master' into trip-by-group-analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow authored Jun 24, 2024
2 parents ebb7d68 + 1663f22 commit fc7f525
Show file tree
Hide file tree
Showing 35 changed files with 1,087 additions and 549 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public Integer call() throws Exception {
private Config prepareConfig() {
Config config = ConfigUtils.loadConfig(ApplicationUtils.matchInput("config.xml", input.getRunDirectory()).toAbsolutePath().toString(), new NoiseConfigGroup());

//it is important to match "output_vehicles" because otherwise dvrpVehicle files might be matched and the code crashes later
config.vehicles().setVehiclesFile(ApplicationUtils.matchInput("output_vehicles", input.getRunDirectory()).toAbsolutePath().toString());
//it is important to match "output_vehicles.xml.gz" specifically, because otherwise dvrpVehicle files might be matched and the code crashes later
config.vehicles().setVehiclesFile(ApplicationUtils.matchInput("output_vehicles.xml.gz", input.getRunDirectory()).toAbsolutePath().toString());
config.network().setInputFile(ApplicationUtils.matchInput("network", input.getRunDirectory()).toAbsolutePath().toString());
config.transit().setTransitScheduleFile(null);
config.transit().setVehiclesFile(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ public void setFixedNumberOfVehiclePerTypeAndLocation(int fixedNumberOfVehiclePe
/**
* Reads and create the carriers with reading the information from the csv file.
*
* @param scenario
* @param freightCarriersConfigGroup
* @param csvLocationCarrier
* @param indexShape
* @param defaultJspritIterations
* @param crsTransformationNetworkAndShape
* @param shapeCategory
* @throws IOException
* @param scenario Scenario
* @param freightCarriersConfigGroup FreightCarriersConfigGroup
* @param csvLocationCarrier Path to the csv file with the carrier information
* @param indexShape ShpOptions.Index for the shape file
* @param defaultJspritIterations Default number of jsprit iterations
* @param crsTransformationNetworkAndShape CoordinateTransformation for the network and shape
* @param shapeCategory Column name in the shape file for the data connection in the csv files
* @throws IOException IOException
*/
public static void readAndCreateCarrierFromCSV(Scenario scenario, FreightCarriersConfigGroup freightCarriersConfigGroup,
Path csvLocationCarrier, ShpOptions.Index indexShape, int defaultJspritIterations,
Expand All @@ -255,12 +255,12 @@ public static void readAndCreateCarrierFromCSV(Scenario scenario, FreightCarrier
}

/**
* @param csvLocationCarrier
* @return
* @throws IOException
* @param csvLocationCarrier Path to the csv file with the carrier information
* @return Set<CarrierInformationElement> Set of CarrierInformationElements
* @throws IOException IOException
*/
static Set<CarrierInformationElement> readCarrierInformation(Path csvLocationCarrier) throws IOException {
log.info("Start reading carrier csv file: " + csvLocationCarrier);
log.info("Start reading carrier csv file: {}", csvLocationCarrier);
Set<CarrierInformationElement> allNewCarrierInformation = new HashSet<>();
CSVParser parse = new CSVParser(Files.newBufferedReader(csvLocationCarrier),
CSVFormat.Builder.create(CSVFormat.TDF).setHeader().setSkipHeaderRecord(true).build());
Expand Down Expand Up @@ -305,11 +305,11 @@ else if (!record.get("fleetSize").isBlank())
/**
* Checks if the read carrier information is consistent.
*
* @param allNewCarrierInformation
* @param freightCarriersConfigGroup
* @param scenario
* @param indexShape
* @param shapeCategory
* @param allNewCarrierInformation Set of CarrierInformationElements
* @param freightCarriersConfigGroup FreightCarriersConfigGroup
* @param scenario Scenario
* @param indexShape ShpOptions.Index for the shape file
* @param shapeCategory Column name in the shape file for the data connection in the csv files
*/
static void checkNewCarrier(Set<CarrierInformationElement> allNewCarrierInformation,
FreightCarriersConfigGroup freightCarriersConfigGroup, Scenario scenario, ShpOptions.Index indexShape, String shapeCategory) {
Expand Down Expand Up @@ -346,15 +346,12 @@ static void checkNewCarrier(Set<CarrierInformationElement> allNewCarrierInformat
throw new RuntimeException(
"If a vehicle type is selected in the input file, numberOfDepots or selectedVehicleDepots should be set. Please check carrier "
+ carrierElement.getName());
if (carrierElement.getVehicleDepots() != null
&& (carrierElement.getNumberOfDepotsPerType() > carrierElement.getVehicleDepots().size())
&& carrierElement.getAreaOfAdditionalDepots() == null)
if ((carrierElement.getVehicleDepots() != null
&& (carrierElement.getNumberOfDepotsPerType() > carrierElement.getVehicleDepots().size())
&& carrierElement.getAreaOfAdditionalDepots() == null) || (carrierElement.getVehicleDepots() == null && (carrierElement.getNumberOfDepotsPerType() > 0)
&& carrierElement.getAreaOfAdditionalDepots() == null))
log.warn(
"No possible area for additional depot given. Random choice in the hole network of a possible position");
if (carrierElement.getVehicleDepots() == null && (carrierElement.getNumberOfDepotsPerType() > 0)
&& carrierElement.getAreaOfAdditionalDepots() == null)
log.warn(
"No possible area for additional depot given. Random choice in the hole network of a possible position");
"No possible area for additional depot given. Random choice in the hole network of a possible position");
if (carrierElement.getAreaOfAdditionalDepots() != null) {
if (indexShape == null)
throw new RuntimeException("For carrier " + carrierElement.getName()
Expand Down Expand Up @@ -407,12 +404,12 @@ static void checkNewCarrier(Set<CarrierInformationElement> allNewCarrierInformat
/**
* Read and creates the carrier and the vehicle types.
*
* @param scenario
* @param allNewCarrierInformation
* @param freightCarriersConfigGroup
* @param indexShape
* @param defaultJspritIterations
* @param crsTransformationNetworkAndShape
* @param scenario Scenario
* @param allNewCarrierInformation Set of CarrierInformationElements
* @param freightCarriersConfigGroup FreightCarriersConfigGroup
* @param indexShape ShpOptions.Index for the shape file
* @param defaultJspritIterations Default number of jsprit iterations
* @param crsTransformationNetworkAndShape CoordinateTransformation for the network and shape
*/
static void createNewCarrierAndAddVehicleTypes(Scenario scenario,
Set<CarrierInformationElement> allNewCarrierInformation, FreightCarriersConfigGroup freightCarriersConfigGroup,
Expand Down Expand Up @@ -498,8 +495,7 @@ static void createNewCarrierAndAddVehicleTypes(Scenario scenario,
for (Carrier carrier : carriers.getCarriers().values()) {
if (CarriersUtils.getJspritIterations(carrier) == Integer.MIN_VALUE) {
CarriersUtils.setJspritIterations(carrier, defaultJspritIterations);
log.warn("The jspritIterations are now set to the default value of " + defaultJspritIterations
+ " in this simulation!");
log.warn("The jspritIterations are now set to the default value of {} in this simulation!", defaultJspritIterations);
}
}
}
Expand Down
Loading

0 comments on commit fc7f525

Please sign in to comment.