Skip to content

Commit

Permalink
Merge pull request #3329 from matsim-org/modifyFreightDemandGeneratio…
Browse files Browse the repository at this point in the history
…nTool

Modify freight demand generation tool
  • Loading branch information
rewertvsp authored Jun 21, 2024
2 parents b9ab343 + 17bf445 commit 5960389
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 374 deletions.
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 5960389

Please sign in to comment.