1

I am composing a library for Discrete-Event Simulation of vehicle traffic. Vehicles are modelled as agents, while the network is modelled as a set of interconnected edges and nodes (a bidirectional graph of locations). At some point, vehicles will have to queue up on some nodes/edges, such as, for example, traffic lights. In an event-driven scenario, I would go about modelling the traffic lights as a queue.

  1. Vehicles calculate their distance from the traffic lights based on their position and some path (to the traffic lights).
  2. An event is created at the time calculated by estimating how long it takes to cross that distance at a constant speed. Upon this event, a check occurs, regarding whether the traffic lights correspond to a "halt" (relevant), or a "pass" (irrelevant).
  3. If the vehicle must halt, the event simply increases the Queue associated with the traffic lights by 1.
  4. In time, the traffic lights become "green" (pass) and the queue is "unloaded" during a corresponding event.

The actual scenario is more complicated, of course, but even from those few steps, I could foresee a very specific problem. My intention is to have the possibility of "replaying" the results of the simulation in the form of a "playback". The output of the steps described above can be "faithfully" visualised in a replay as an animation of a bucket placed right where the traffic lights are located, with a size that increases as vehicles queue up and decreases as they "unload" (resume motion).

This is, obviously, not very realistic. What I want to end up with is a "faithful" replay of actual traffic moving about. So my question is, how do I "transition" from a Discrete-Event Simulation result to a realistic replay? Is there some standardised manner to actually transition from, for example, a FIFO-bucket-based queue to actual vehicle sprites queuing up one behind the other in a relatively precise (spatially) manner? Or must I "set up" my model in a manner that is different to the steps outlined above, to actually "catch" that behavior right upon its manifestation? Or am I just hitting a dead end with this and I should just switch it all to a time-based simulation modality (instead of discrete-event), so that I can evaluate full-blown motion dynamics in discrete time steps?

Bear in mind that I don't want to just get a "representational" visualisation. What I am looking for is to end up with the actual positions of the vehicles in-between the events.

1 Answer 1

1

Is there some standardised manner to actually transition from a FIFO-bucket-based queue to actual vehicle sprites queuing up one behind the other in a relatively precise (spatially) manner?

I don't think there is a standardized approach, this is a specific problem, and it has specific solutions with a lot of options how it can be solved.

However, that does not mean you necessarily need to change your model fundamentally. In fact, I think the scenario, as described, can be approached in a straightforward manner:

  • The nodes/edges in your graph represent the topology of some geometric (or spatial) situation. So the first thing you need to do is make sure you have a model of the latter, like a spatial map, and a mapping from each node to a location within that map, as well as a mapping from each edge to a path within the map (including the direction).

    The paths might be described as a sequence of 2D points (a polyline), which naturally maps to a sequence of 2D line segments, which can be interpreted as a linear spline, allowing to calculate any intermediate points on the path by a parametric formula. If you want to make this more "smooth", you may replace the linear splines by quadratic or cubic splines, for example, by spline interpolation.

  • Events correspond to points in time where a vehicle starts/and or stops at one node with its related location. For a playback, you simply have to divide the time between an event and the next one into small sub-intervals of a given size, and then interpolate the position of each vehicle on its path from its last stop to the next one. The spline form of the paths should make this fairly simple

This is not too hard when you assume the vehicles having a constant speed. It becomes more complicated when you want to make this more realistic, with vehicles accelerating from their last stop, and slowing down when reaching the next halt, or keeping their speed when their pass a non-halting node.

Of course, in case you want an even more realistic traffic model, with distances between vehicles, taking care for their size, number of lanes one the road, dynamic minimum distances between vehicles depending on their speed, and more of these details, then a more complex model starts to make more sense. For this, I would not use an event FIFO as origin, but the spatial map together with small, discrete time intervals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.