metrosim/docs/architecture/simulator/within-day_model.rst

104 lines
7.7 KiB
ReStructuredText

Within-Day Model
================
The within-day model simulates the movements of vehicles and individuals in the network, for a single day.
It is an event-based model that triggers event according to the time of the day.
Events
------
PVReachesNode
^^^^^^^^^^^^^
This event signals that a private vehicle reaches a node, at a given time.
Expected Travel Times
---------------------
At each node of the network, car drivers choose the next edge that they will take.
The choice is made based on the expected utility.
For each downstream edge, the expected utility depends on
- the past travel time of the car driver from the origin to the current node,
- the observed travel time on the downstream edge,
- the expected travel time from the target node to the destination,
- the observed road toll on the downstream edge,
- the expected road toll from the target node to the destination.
This mean that MetroSim should know, for each pair of nodes :math:`(s, t)` and for each departure time :math:`t_d`, all feasible and non-Pareto-dominated pairs :math:`({tt}, \tau)` where :math:`{tt}` is the travel time from :math:`s` to :math:`t` and :math:`\tau` is the toll paid.
A pair :math:`({tt}, \tau)` is feasible if there is at least one path, from :math:`s` to :math:`t`, starting at time :math:`t_d` such that the travel time is :math:`{tt}` and the toll paid is :math:`\tau`.
A pair :math:`({tt}, \tau)` is Pareto dominated if there is another feasible pair :math:`({tt}', \tau')` such that :math:`{tt}\geq{tt}'` and :math:`\tau\geq\tau'`, where at least one inequality is strict.
It can be very computationally and memory intensive to compute and store all the feasible and non-Pareto-dominated :math:`({tt}, \tau)` pairs, for all node pairs and for all departure times (or even for some departure-time intervals).
Therefore, each time a car driver wants to compute the expected travel utility from a source node :math:`s` to a target node :math:`t`, starting at time :math:`t_d`, MetroSim uses the following rules:
1. If the pairs :math:`({tt}, \tau)` are known for both a starting time :math:`t_d' \in [t_d - M, t_d - m]` and for a starting time :math:`t_d'' \in [t_d + m, t_d + M]`, then compute expected travel times using linear interpolation.
2. If the pairs :math:`({tt}, \tau)` are known for a starting time :math:`t_d' \in [t_d - m, t_d + m]`, then use the expected travel times with starting time :math:`t_d'` as a proxy for the expected travel times with starting time :math:`t_d`.
3. If the pairs :math:`({tt}, \tau)` are known for a starting time :math:`t_d' \in [t_d - M, t_d - m]` only, then compute expected travel times with starting time :math:`t_d'' = t_d' + 2 \cdot M`, store the results and use a linear interpolation between :math:`t_d'` and :math:`t_d''`.
4. In all other cases, compute expected travel times with starting time :math:`t_d`, store the results and use them.
The parameters :math:`m` and :math:`M` can be fixed by the user.
Reasonable values are :math:`m=30` seconds and :math:`M=10` minutes.
If memory is getting low, we can remove all the expected travel-time results such that the starting time is earlier than the current time of the simulation minus :math:`M`.
When computing the expected travel times from :math:`s` to :math:`t`, we can also get the expected travel times from :math:`s` to any node :math:`t'` on the fastest paths.
Example
^^^^^^^
We consider the following road network, where all edges only go from West to East.
To keep it simple, free-flow travel-times are set to 1 minute for each edge and we assume that they are never congested.
The edge from node 2 to node 4 is the only edge with a road toll, set to 1 euro.
We set :math:`m=30` seconds and :math:`M=10` minutes.
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| From / to | 1 | 2 | 3 | 4 | 5 |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 1 | X | (1, 0) | X | X | X |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 2 | X | X | (1, 0) | (1, 1) | X |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 3 | X | X | X | (1, 0) | X |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 4 | X | X | X | X | (1, 0) |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 5 | X | X | X | X | X |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
.. plot:: plots/network.py
Example road network
Assume that the first car entering the network goes from node 1 to node 5, starting at 08:00:00.
Following rule 4., we compute expected travel times with starting time 08:00:00.
Two paths are found: the path (1, 2, 3, 4, 5) with 4-minute travel-time and no toll and the path (1, 2, 4, 5) with 3-minute travel-time and a toll of 1 euro.
The car driver chooses the best path to take, given his preferences (value of time, schedule utility, etc.).
At the same time, we have also found two paths from node 1 to node 4, with their travel-time and toll values, starting at 08:00:00.
And we have found two paths from node 2 to node 5, with their travel-time and toll values, starting at 08:01:00.
All these results are stored in memory (only the travel times and tolls are stored, not the paths).
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| From / to | 1 | 2 | 3 | 4 | 5 |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 1 | X | (1, 0) | (2, 0) at 08:00:00 | [(3, 0), (2, 1)] at 08:00:00 | [(4, 0), (3, 1)] at 08:00:00 |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 2 | X | X | (1, 0) | (1, 1) | [(3, 0), (2, 1)] at 08:01:00 |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 3 | X | X | X | (1, 0) | (2, 0) at 08:02:00 |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 4 | X | X | X | X | (1, 0) |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
| 5 | X | X | X | X | X |
+-----------+---+--------+--------------------+------------------------------+-------------------------------+
Assume that the next car to move goes from node 1 to node 4, starting at time 08:00:45.
The only known results between node 1 and node 4 are for a starting time at 08:00:00.
Then, following rule 3., we compute the fastest paths for a starting time at 08:10:00.
We find the same two paths as previously.
.. warning::
TODO: Enrich the algorithm to consider cordon tolls, mobility permits and class-specific policies.