From 3fea585de456c913110983f6f664d5c85ef3792e Mon Sep 17 00:00:00 2001 From: Cap Date: Thu, 25 Dec 2025 17:42:29 +0100 Subject: [PATCH 1/5] Add walk as default value for first and last legs in PublicTransportMode Add walk as default value for first and last legs in PublicTransportMode: it will be easier for users --- .../public_transport/public_transport_mode.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mobility/transport_modes/public_transport/public_transport_mode.py b/mobility/transport_modes/public_transport/public_transport_mode.py index 2837f04..7c9de85 100644 --- a/mobility/transport_modes/public_transport/public_transport_mode.py +++ b/mobility/transport_modes/public_transport/public_transport_mode.py @@ -4,6 +4,7 @@ from mobility.transport_zones import TransportZones from mobility.transport_modes.transport_mode import TransportMode +from mobility.transport_modes.walk import WalkMode from mobility.transport_modes.public_transport.public_transport_routing_parameters import PublicTransportRoutingParameters from mobility.transport_modes.public_transport.public_transport_travel_costs import PublicTransportTravelCosts from mobility.transport_modes.public_transport.public_transport_generalized_cost import PublicTransportGeneralizedCost @@ -32,8 +33,8 @@ def __init__( transport_zones: TransportZones, first_leg_mode: TransportMode = None, last_leg_mode: TransportMode = None, - first_intermodal_transfer: IntermodalTransfer = None, - last_intermodal_transfer: IntermodalTransfer = None, + first_intermodal_transfer: IntermodalTransfer = IntermodalTransfer(), + last_intermodal_transfer: IntermodalTransfer = IntermodalTransfer(), routing_parameters: PublicTransportRoutingParameters = PublicTransportRoutingParameters(), generalized_cost_parameters: GeneralizedCostParameters = None, survey_ids: List[str] = [ @@ -43,6 +44,11 @@ def __init__( ], ghg_intensity: float = 0.05 ): + + if first_leg_mode is None: + first_leg_mode = WalkMode(transport_zones) + if last_leg_mode is None: + last_leg_mode = WalkMode(transport_zones) travel_costs = PublicTransportTravelCosts( transport_zones, @@ -94,4 +100,4 @@ def __init__( def audit_gtfs(self): logging.info("Auditing GTFS for this mode") travel_costs = self.travel_costs.audit_gtfs() - return travel_costs \ No newline at end of file + return travel_costs From 49fb564c150f87d6f06812e2a07de896953df686 Mon Sep 17 00:00:00 2001 From: Cap Date: Thu, 25 Dec 2025 17:51:27 +0100 Subject: [PATCH 2/5] add default values for intermodal transfers --- mobility/transport_modes/modal_transfer.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mobility/transport_modes/modal_transfer.py b/mobility/transport_modes/modal_transfer.py index 9568a95..8488966 100644 --- a/mobility/transport_modes/modal_transfer.py +++ b/mobility/transport_modes/modal_transfer.py @@ -11,20 +11,24 @@ class IntermodalTransfer(): Dataclass for intermodal transfer parameters. Args: - max_travel_time: maximum travel time to consider when estima + max_travel_time: maximum travel time to consider between those two modes + average_speed: average speed during the transfer (default is 4.0 km/h, considering walking) + transfer_time: to document + shortcuts_transfer_time: to document + shortcuts_locations: to document """ # Max travel time from or to the connection nodes, estimated from the crow # fly distance around connection nodes and an average speed - max_travel_time: float # hours - average_speed: float # km/h + max_travel_time: float = 20.0 / 60.0 # hours + average_speed: float = 4.0 # km/h # Average transfer time between the two connected modes - transfer_time: float # minutes + transfer_time: float = 1.0 # minutes # Optional shortcuts to make some connections faster than average shortcuts_transfer_time: float = None # minutes shortcuts_locations: List[Coordinates] = None - \ No newline at end of file + From ef4f3e94f5890f02a0ff2739a6b13cc9d4b479a7 Mon Sep 17 00:00:00 2001 From: Cap Date: Thu, 25 Dec 2025 23:54:18 +0100 Subject: [PATCH 3/5] test all 4 modes in test_008 --- .../integration/test_008_population_trips_can_be_computed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/back/integration/test_008_population_trips_can_be_computed.py b/tests/back/integration/test_008_population_trips_can_be_computed.py index 7e59c5d..84e6bbd 100644 --- a/tests/back/integration/test_008_population_trips_can_be_computed.py +++ b/tests/back/integration/test_008_population_trips_can_be_computed.py @@ -141,7 +141,7 @@ def test_008_population_trips_can_be_computed(test_data, safe_json): pop_trips = PopulationTrips( population=pop, - modes=[mobility.CarMode(transport_zones)], + modes=[mobility.CarMode(transport_zones), mobility.WalkMode(transport_zones), mobility.BicycleMode(transport_zones), mobility.PublicTransportMode(transport_zones)], motives=[ HomeMotive(), WorkMotive(), From 6972122c44deca82a01e99cba56a366feb35ef9a Mon Sep 17 00:00:00 2001 From: Cap Date: Fri, 26 Dec 2025 00:30:00 +0100 Subject: [PATCH 4/5] Update and rename quickstart-fr.py.py to quickstart-fr.py --- examples/{quickstart-fr.py.py => quickstart-fr.py} | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) rename examples/{quickstart-fr.py.py => quickstart-fr.py} (80%) diff --git a/examples/quickstart-fr.py.py b/examples/quickstart-fr.py similarity index 80% rename from examples/quickstart-fr.py.py rename to examples/quickstart-fr.py index ebc32e8..95187d6 100644 --- a/examples/quickstart-fr.py.py +++ b/examples/quickstart-fr.py @@ -6,10 +6,8 @@ dotenv.load_dotenv() mobility.set_params( - # package_data_folder_path=os.environ["MOBILITY_PACKAGE_DATA_FOLDER"], - # project_data_folder_path=os.environ["MOBILITY_PROJECT_DATA_FOLDER"] - package_data_folder_path="D:/mobility-data", - project_data_folder_path="D:/test-09", + package_data_folder_path=os.environ["MOBILITY_PACKAGE_DATA_FOLDER"], + project_data_folder_path=os.environ["MOBILITY_PROJECT_DATA_FOLDER"] ) # Using Foix (a small town) and a limited radius for quick results @@ -24,7 +22,7 @@ # Simulating the trips for this population for three modes : car, walk and bicyle, and only home and work motives (OtherMotive is mandatory) pop_trips = mobility.PopulationTrips( pop, - [mobility.CarMode(transport_zones), mobility.WalkMode(transport_zones), mobility.BicycleMode(transport_zones)], + [mobility.CarMode(transport_zones), mobility.WalkMode(transport_zones), mobility.BicycleMode(transport_zones), mobility.PublicTransportMode(transport_zones)], [mobility.HomeMotive(), mobility.WorkMotive(), mobility.OtherMotive(population=pop)], [emp] ) From 59acadb2cd0c329e78f75850c840c363d26b1100 Mon Sep 17 00:00:00 2001 From: Cap Date: Fri, 26 Dec 2025 00:30:33 +0100 Subject: [PATCH 5/5] Update quickstart-fr.py --- examples/quickstart-fr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/quickstart-fr.py b/examples/quickstart-fr.py index 95187d6..d7deaa3 100644 --- a/examples/quickstart-fr.py +++ b/examples/quickstart-fr.py @@ -19,7 +19,7 @@ # Creating a synthetic population of 1000 for the area pop = mobility.Population(transport_zones, sample_size = 1000) -# Simulating the trips for this population for three modes : car, walk and bicyle, and only home and work motives (OtherMotive is mandatory) +# Simulating the trips for this population for three modes : car, walk, bicyle and public transport, and only home and work motives (OtherMotive is mandatory) pop_trips = mobility.PopulationTrips( pop, [mobility.CarMode(transport_zones), mobility.WalkMode(transport_zones), mobility.BicycleMode(transport_zones), mobility.PublicTransportMode(transport_zones)],