Simulation Time#
At its core, POLARIS is a discrete event simulation engine which aims to simulate an entire day worth of travel behaviours across a model area. It does this by allowing agents to perform actions / make decisions / etc at a fixed number of simulation intervals throughout the “day”.
In general, models are run with a time-step granulatity of 1 second - each simulation interval represents one second of simulated day. However, this default granularity can be increased or decreased to fit the needs of specific studies. In order to accomplish this there are two distinct concepts that need to be introduced:
Simulation Time - The modelled time within the simulation (i.e. “9AM” or 30 seconds)
Simulation Iteration - The discrete points in time within the simulation where agents can make decisions/actions
These concepts are modelled within the codebase using the Basic_Units
library. Simulation Time is represented using Time_Minutes
, Time_Seconds
, etc classes and Simulation Iterations are represented using the Time_Step
class.
The concordance between simulation steps and simulation time is handled via the Simulation_Time
module which provides a number of useful methods for translating between the two and also for identifying where in the simulation we are (in both units). A simplified representation of the actual c++ is given below however the key concepts are
The Current time - where we are now
The Last time - the last time that WILL be simluated
The End time - the first time that will NOT be simulated
The End_Step()
method is most often used in the next_iteration
section of an event’s response to indicate that that agent no longer requires simulation.
static int miliseconds_per_iteration = 1000;
// Conversions for timestep <-> simulation time
template <T> T Timestep_To_Time(Time_Step step);
template <T> Time_Step Time_To_Timestep(T time);
// Returns the current point within the simulation
template <T> T Current_Time();
Time_Step Current_Step();
// Returns a point "delta" units into the future from the current time
template <T, U = T> U Future_Time(T delta)
Time_Step Future_Step(Time_Step delta);
// Returns the first time point directly AFTER simulation - by convention this is 24:00:00
Time_Step End_Step();
template <T> T End_Time();
// Returns teh last time point that is actually simulated - for 1 second steps this is 23:59:59
Time_Step Last_Step();
template <T> T Last_Time();
bool Is_Last_Step();