Skip to content

Commit

Permalink
Update MATSim CW26 (#104)
Browse files Browse the repository at this point in the history
* CreateDrtDashboard

* rename pooling ratio to occupancy rate

* account for group bookings in DrtAnalysisPostProcessing (and thus DrtDashboard)

* typo in CreateDrtDashboard

* fix wrong sum calculation

* debug NoiseAnalysis and proper testing in NoiseDashboardTests

* fix wrong map selection

* add reduction of numberOfJobs

* add comments and format log massages

* combine

* rename parameter

* reduce code

* format logging

* use method for demand calculating

* use method for shipment creation

* remove todo

* use method to calculate demand based on link lengths

* introduce parameter

* simplify

* cleanup

* Support TransitRouteStops where boarding or alighting is not allowed

In reality, there are trains that call at stops but where it might not be allowed to enter or exit such trains. Examples are night trains, where on the first few stops, only boarding is allowed, while at the last few stops only alighting is allowed. This means that it is not allowed to use such night trains to just travel between the first few stops.

This commit adds two optional attributes `allowBoarding` and `allowAlighting` to TransitRouteStops, with the default value being true for backwards compatibility and when the attribute is not specified. SwissRailRaptor respects these attributes and will not return routes where agents would enter a vehicle at a route stop where boarding is not allowed, or where agents would exit a vehicle at a route stop where alighting is not allowed.

* make drt shifts multi mode drt comatible

* adjust shift efficiency tracker as well

---------

Co-authored-by: schlenther <[email protected]>
Co-authored-by: Ricardo Ewert <[email protected]>
Co-authored-by: Ricardo Ewert <[email protected]>
Co-authored-by: Marcel Rieser <[email protected]>
  • Loading branch information
5 people authored Jun 24, 2024
1 parent ab3aa0d commit 039d209
Show file tree
Hide file tree
Showing 37 changed files with 1,184 additions and 572 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 039d209

Please sign in to comment.