Model time is the virtual (simulated) time maintained by the AnyLogic simulation engine. The model time has nothing to do with the real time or the computer clock (although you can run the model in a scale to real time).
In AnyLogic, the model time takes real numbers (double type values). The model clock is advanced in steps: while the engine is executing a discrete event model, the model time jumps from one event to another; if a continuous-time model is being executed, the time steps are typically smaller and have equal size.
To establish the correspondence between the model time and real-world time where the system being modeled lives, we need to define the time units. The type of time unit depends on the time scale of the activities you are modeling. For example, if you are modeling a call center where the call durations are measured in seconds or minutes, you may set the time units to seconds or minutes. If you are modeling a supply chain, where manufacturing and shipping times are measured in days, days would be the right choice.
AnyLogic supports all popular time units: milliseconds, seconds, minutes, hours, days, weeks, months, years. You may change the model time units whenever you like, though we advise that you select the model time units when you create the model.
To set the time units
- In the Projects view, select the model (the topmost item).
- In the model’s Properties, choose required time units from the Model time units drop-down list.
You can set the stop time, the time at which you wish the simulation run to be terminated.
To set start and stop times
- In the Projects view, select the experiment you are currently working with.
- Open the Model time section of the experiment’s Properties.
- If you want the model to work infinitely until you stop it manually, select Never from the Stop drop-down list.
- Otherwise, if you want simulation to be stopped at some other time moment, you can specify stop time as a calendar date or you can specify simulation time horizon as a number of model time units.
- If you want to define the simulation time horizon as a number of model time units, choose Stop model at specified time from the Stop drop-down list, and specify the stop time in the Stop time edit box.
- Otherwise, if you prefer to specify times as calendar dates, choose Stop model at specified date from the Stop drop-down list, and enter the start and stop dates using Start date and Stop date controls. By default, the start date is set to the date when the model is created.
AnyLogic can execute the simulation model in two modes, virtual time and real time on a given scale.
- In real time mode, the mapping of AnyLogic model time to the real time is made, i.e. you specify how many model time units one second takes. It is frequently needed when you want your presentation to appear as in real life. The engine tries to keep to a given scale, say 10 model time units (e.g., 10 simulated weeks) per 1 real second. Sometimes, though, the engine is unable to keep a given time scale because of too-frequent or too-complex events or because of a large system of equations and/or a too-small time step. Then the engine will work as fast as possible until it finds the next opportunity to maintain the real-time scale. Thus, the only thing the model can guarantee with respect to the real time is that the model execution will never go faster than requested.
- In virtual time mode, the simulation engine executes the model as fast as possible. The model runs at its maximum speed and no mapping is made between model time units and seconds of astronomical time. This time mode is useful when you need to simulate your model for a long period of time. The virtual time mode is used when simulation performance is important and animation of the model dynamics is not needed.
In real time mode, you can increase or decrease model simulation speed by changing the model simulation speed scale. The default 1x scale means that the model is simulated with the model simulation speed defined in the properties of the current AnyLogic experiment; 2x means that model is run twice faster than the specified model speed, etc. For instance, if the model speed is 6 model time units per second, 2x means that 12 model time units correspond to 1 second.
You can set the desired execution mode in the simulation experiment’s Model time properties section (for other experiment types, the virtual time mode is assumed). Later, you can use the controls in the model window to change the mode during runtime or do it programmatically.
To set the default time mode and simulation speed
- In the Projects view, select the experiment you are working with.
- In the Model time section of the experiment’s Properties, set the time mode using the controls in the Execution mode section.
- If you want to run your model in virtual time mode, select the Virtual time (as fast as possible) option.
- Otherwise, if you want to set the mapping between model time and real time units, select Real time with scale and set the scale value (number of model time units executed per one second) from the drop-down list to the right.
The easiest way to display model time while the model is running is to open the developer panel. The model time indicators are at the very top of it.
However, if you need to show model time right on the model screen, add the text shape, switch its Text property to the dynamic mode and place the time() function call there.
-
How can we improve this article?
-