Transport simulator with the following characteristics:
Python scripts can be shared between users or replaced by other tools
Public-transit flows by line, Paris' urban area, Morning peak
Road-level congestion variation when Paris' Low Emission Zone is implemented
Variation of exposure cost to air pollution when Paris' Low Emission Zone is implemented
Car flows for all trips going through highway A15 near Cergy
Vehicle movements in the surroundings of Cergy, 08:00 to 08:05
{
"key": "value",
"integer": 1,
"float": 3.6,
"boolean": true,
"array": [
0, 1, 2
],
"nested_array": [
{"some": "value"},
{"another": "value"}
]
}
dict
type
col1,col2,col3,col4
1,Alice,3.2,true
2,Bob,1.4,false
3,Charlie,2.5,false
import polars as pl
df = pl.DataFrame(
{
"agent_id": [0, 1, 2],
"alt_choice.type": ["Deterministic", "Logit", "Logit"],
"alt_choice.u": [0.3, 0.6, 0.5],
"alt_choice.mu": [None, 0.9, 1.0],
"alt_choice.constants": [[0.9, 1.3, 2.1], None, None],
}
)
df.write_parquet("input/agents.parquet")
In [3]: df
Out[3]:
shape: (3, 5)
┌──────────┬─────────────────┬──────────────┬───────────────┬──────────────────────┐
│ agent_id ┆ alt_choice.type ┆ alt_choice.u ┆ alt_choice.mu ┆ alt_choice.constants │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ f64 ┆ f64 ┆ list[f64] │
╞══════════╪═════════════════╪══════════════╪═══════════════╪══════════════════════╡
│ 0 ┆ Deterministic ┆ 0.3 ┆ null ┆ [0.9, 1.3, 2.1] │
│ 1 ┆ Logit ┆ 0.6 ┆ 0.9 ┆ null │
│ 2 ┆ Logit ┆ 0.5 ┆ 1.0 ┆ null │
└──────────┴─────────────────┴──────────────┴───────────────┴──────────────────────┘
For consistency and to prevent mistakes, METROPOLIS2 uses the same units for all input and output variables.
Type | Unit | Example |
---|---|---|
Time of day | Seconds after midnight | 8 * 3600 = 28800 is 8 a.m. |
Time duration | Seconds | 300 (5 minutes) |
Length | Meters | |
Speed | Meters / Second | 50 / 3.6 = 13.89 m/s is 50 km/h |
Passenger Car Equivalent (PCE) | N/A | Usually normalized to 1 for car |
Flow | PCE / Second | 0.5 PCE/s = 1800 PCE per hour |
Utility | No specific unit (can be monetary units) | |
Value of Time | Utility / Second | 15 / 3600 = 0.004167 is 15 $/h |
Mistakes are still possibles, be careful!
The documentation (WIP) is the best way to understand the input and output formats
https://docs.metropolis.lucasjavaudin.com
.\execs\metropolis_cli.exe .\examples\data\csv\parameters.json
./execs/metropolis_cli ./examples/data/csv/parameters.json
examples/data/csv/output/
edge_id
: Identifier of the edge (positive integer, unique)source
: Identifier of the source node (positive integer)target
: Identifier of the target node (positive integer)speed
: Free-flow speed on the edge (m/s)length
: Length of the edge (m)bottleneck_flow
: Maximum inflow and outflow of the edge (PCE/s)overtaking
: If `True`, vehicles can overtake other vehicles in the bottleneck queues if they are going to different edgeslanes
: number of lanes available to vehicles on the edge (in the current direction)constant_travel_time
: time penalty that is added to the edge's travel time, in secondsvehicle_id
: Identifier of the vehicle (positive integer, unique)headway
: Head-to-head length between two vehicles (m, used to compute edge's density)pce
: Passenger-car equivalent for the vehicle (non-negative number)
{
[...]
"road_network": {
"recording_interval": 300.0,
"approximation_bound": 1.0,
"spillback": true,
"backward_wave_speed": 4.0,
"max_pending_duration": 60.0,
"constrain_inflow": true,
"algorithm_type": "Best",
},
[...]
}
recording_interval
: time, in seconds, between two breakpoints in the edge-level travel-time functions (Mandatory; Recommendation: 5, 10 or 15 minutes for large-scale networks)approximation_bound
: for a given travel-time function, if the difference between the maximum and the minimum travel time is smaller than this value, the function is represented as a constant function for optimization (Default: 0; Recommendation: between 0 and 5 seconds)
{
[...]
"road_network": {
"recording_interval": 300.0,
"approximation_bound": 1.0,
"spillback": true,
"backward_wave_speed": 4.0,
"max_pending_duration": 60.0,
"constrain_inflow": true,
"algorithm_type": "Best",
},
[...]
}
spillback
: whether spillback congestion (queue propagation) is enabled (Default: TRUE; Recommendation: TRUE for more realistic congestion modeling)backward_wave_speed
: speed at which the space taken by vehicles propagates backward upon exit (Default: instantaneous propagation; Recommendation: default or 15 km/h = 4.17 m/s)max_pending_duration
: maximum amount of time a vehicle can stay in a pending state (Mandatory; Recommendation: between 30s and 5m, larger values are more realistic but generate more congestion)
{
[...]
"road_network": {
"recording_interval": 300.0,
"approximation_bound": 1.0,
"spillback": true,
"backward_wave_speed": 4.0,
"max_pending_duration": 60.0,
"constrain_inflow": true,
"algorithm_type": "Best",
},
[...]
}
constrain_inflow
: whether bottlenecks limit vehicle inflow in addition to vehicle outflow (Default: TRUE; Recommendation: TRUE, set to FALSE to replicate MATSim behavior)algorithm_type
: routing algorithm to use for profile queries, "Best", "TCH", or "Intersect" (Default: "Best"; Recommendation: "Intersect" for a smaller running time, "TCH" for a smaller memory consumption)
{
[...]
"road_network": {
"recording_interval": 300.0,
"approximation_bound": 1.0,
"spillback": true,
"backward_wave_speed": 4.0,
"max_pending_duration": 60.0,
"constrain_inflow": true,
"algorithm_type": "Best",
},
[...]
}
stopping_time
variable can be used to add a delay between two trips (this can represent the activity duration)File agents.csv
Define agents and their choice model between alternatives
File alts.csv
:
Define alternatives for each agent, with the constant utility and departure-time choice model (except for alternatives with no trip)
File trips.csv
:
Define the trips of each alternative, with the type (road / virtual), characteristics (origin, destination, travel time), and travel and schedule utility parameters
File alts.csv
:
File trips.csv
:
stopping_time
is the time that elapses before the next trip starts
File trips.csv
:
Warning: travel_utility.one
is expressed in utility / second; schedule_utility.beta
and schedule_utility.gamma
are expressed in "generalized cost" / second
exp_road_network_cond_rmse
: Difference between the expected road-network conditions and the simulated road-network conditionsalt_dep_time_rmse
: Difference between the departure times of the previous and current iterationroad_trip_exp_travel_time_diff_rmse
: Difference between the expected travel time and the simulated travel time
{
"input_files": {
"agents": "input/agents.parquet",
"alternatives": "input/alts.parquet",
"trips": "input/trips.parquet",
"edges": "input/edges.parquet",
"vehicle_types": "input/vehicles.parquet",
},
"output_directory": "output/",
"period": [0.0, 86400.0],
"road_network": {
"recording_interval": 50.0,
"approximation_bound": 1.0,
"spillback": true,
"backward_wave_speed": 4.0,
"max_pending_duration": 20.0,
"constrain_inflow": true,
"algorithm_type": "Intersect"
},
"learning_model": {
"type": "Exponential",
"value": 0.01
},
"max_iterations": 20,
"saving_format": "CSV",
}
log.txt
: METROPOLIS2 log messages during the simulationrunning_times.json
: simulation running time, by categoryreport.html
: webpage summarizing the resultsiteration_results.{parquet,csv}
: aggregate results for each iterationFile running_times.json
{
"total": "49181.060006808",
"total_skims_computation": "37804.951886765",
"total_demand_model": "2943.497363545",
"total_supply_model": "8150.961492634",
"total_learning_model": "9.425217904",
"total_aggregate_results_computation": "148.839589353",
"total_stopping_rules_check": "0.000029886",
"per_iteration": "245.905300034",
"per_iteration_skims_computation": "189.024759433",
"per_iteration_demand_model": "14.717486817",
"per_iteration_supply_model": "40.754807463",
"per_iteration_learning_model": "0.047126089",
"per_iteration_aggregate_results_computation": "0.744197946",
"per_iteration_stopping_rules_check": "0.000000149"
}
skims_computation: computation of OD-level travel-time functions given the expected road-network conditions
Skims comp. | Demand model | Supply model | |
---|---|---|---|
# agents | · | Large¹ | Large¹ |
# nodes / edges | Large | · | Medium |
# unique origin / dest. | Very large | · | · |
# unique OD pairs | Large | · | · |
# breakpoints | Small | Very small | Very small |
Old scenario | New scenario | Variation | |
---|---|---|---|
# agents | 477 192 | 629 314 | ×1.32 |
# road trips | 477 192 | 548 480 | ×1.15 |
# virtual trips | 0 | 1 442 883 | ×∞ |
# nodes | 20 648 | 116 971 | ×5.67 |
# edges | 43 857 | 196 980 | ×4.49 |
# unique origins | 1326 | 50 774 | ×38.29 |
# unique destinations | 1326 | 49 607 | ×37.41 |
# unique OD pairs | 161 871 | 466 079 | ×2.88 |
# breakpoints | 27 | 93 | ×3.44 |
Old scenario | New scenario | Variation | |
---|---|---|---|
Total | 01:49:42 | 09:00:28 | ×4.93 |
Skims computation | 00:20:04 | 06:57:25 | ×20.80 |
Demand model | 00:44:43 | 00:39:28 | ×0.88 |
Supply model | 00:42:35 | 01:19:11 | ×1.86 |
All the results are specific to the last iteration
agent_results.{parquet,csv}
: results at the agent-leveltrip_results.{parquet,csv}
: results at the trip-levelroute_results.{parquet,csv}
: detailed itineraries for the road tripsutility
: Simulated utility, based on the selected alternative $j$ and departure time $\tau$: $V^{\text{sim}}_{j}(\tau)$
alt_expected_utility
: Expected utility of the departure-time choice of the selected alternative $j$: $\mathbb{E}_{\varepsilon}[\max_{\tau} U_j(\tau)]$
expected_utility
: Expected utility of the alternative choice: $\mathbb{E}_{\varepsilon}[\max_{j} U_j]$
Example with a deterministic alternative-choice model and a constant departure time
utility
: Simulated utility, based on the selected alternative $j$, departure time $\tau$ and simulated travel times: $V^{\text{sim}}_{j}(\tau)$
alt_expected_utility
: Expected utility, based on the selected alternative $j$, departure time $\tau$ and expected travel times: $V^{\text{exp}}_{j}(\tau)$
expected_utility
: Expected utility, based on the selected alternative $j$, departure time $\tau$ and expected travel times: $V^{\text{exp}}_{j}(\tau)$
When the simulation has converged: $V^{\text{sim}}_j(\tau) \approx V^{\text{exp}}_j(\tau)$
Example with a Logit alternative-choice model and a Continuous Logit departure-time choice model
utility
: Simulated utility, based on the selected alternative $j$, departure time $\tau$ and simulated travel times: $V^{\text{sim}}_{j}(\tau)$
alt_expected_utility
: Logsum of departure-time choice for the selected alternative $j$
\[ \bar{U}_j \equiv \mathbb{E}_{\varepsilon}[\max_\tau U_j(\tau)] = \mu \ln \int_{t^0}^{t^1} e^{V_j^{\text{exp}}(\tau) / \mu} \text{d} \tau + \mu \cdot 0.577 \]
expected_utility
: Logsum of alternative choice ("logsum of logsum")
\[ \mathbb{E}_{\varepsilon}[\max_j U_j] = \mu \ln \sum_j e^{\bar{U}_j / \mu} + \mu \cdot 0.577 \]
Which one to use (e.g., for cost-benefit analysis)?
utility
: not really adapted when using random-utility models (the random perturbations $\varepsilon$ are omitted); recommended when using deterministic models (including models with drawn epsilons)
alt_expected_utility
: intermediate indicator, useful in some special cases only
expected_utility
: recommended when using random-utility models (it depends on the range of alternatives available, not just the realized choice: two identical agents always have the same expected_utility
but they can have different utility
if their uniform draws differ)route_results.{csv,parquet}
output file allows to show the detailed itinerary of an agent.
route_results.{csv,parquet}
output file allows to show a video of the vehicle movements.
Three files for the road-network conditions (edge-level travel-time functions):
net_cond_sim_edge_ttfs.{parquet,csv}
: last iteration, simulatednet_cond_exp_edge_ttfs.{parquet,csv}
: last iteration, expectednet_cond_next_exp_edge_ttfs.{parquet,csv}
: next iteration, expectedOne extra file:
skim_results.json.zst
: OD-level (expected) travel-time functions
{
"input_files": {
"agents": "agents.csv",
"alternatives": "alts.csv",
"trips": "trips.csv",
"edges": "edges.csv",
"vehicle_types": "vehicles.csv",
"road_network_conditions": "net_cond_next_exp_edge_ttfs.csv"
},
"output_directory": "output",
"period": [
25200.0,
28800.0
],
"road_network": {
"recording_interval": 60.0,
"spillback": false,
"max_pending_duration": 0.0
},
"max_iterations": 100,
"init_iteration_counter": 100,
"saving_format": "CSV",
"learning_model": {
"type": "Exponential",
"value": 0.4
}
}
parameters.json
https://lucasjavaudin.com/research/phd-thesis/javaudin_lucas_phd_manuscript-final.pdf