diff --git a/examples/quickstart-fr.py.py b/examples/quickstart-fr.py similarity index 75% rename from examples/quickstart-fr.py.py rename to examples/quickstart-fr.py index ebc32e82..d7deaa37 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 @@ -21,10 +19,10 @@ # 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.CarMode(transport_zones), mobility.WalkMode(transport_zones), mobility.BicycleMode(transport_zones), mobility.PublicTransportMode(transport_zones)], [mobility.HomeMotive(), mobility.WorkMotive(), mobility.OtherMotive(population=pop)], [emp] ) diff --git a/mobility/transport_modes/modal_transfer.py b/mobility/transport_modes/modal_transfer.py index 9568a95b..84889664 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 + diff --git a/mobility/transport_modes/public_transport/public_transport_mode.py b/mobility/transport_modes/public_transport/public_transport_mode.py index 2837f046..7c9de85a 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 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 7e59c5dd..84e6bbd9 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(),