Model 1d - Scripted Time Instant for Start Events
Goals of the lesson
-
Learn how set up a simple scripted time instant to determine a start event’s inter-arrival time
-
This is only used, if timing is very complicated, e.g. it depends on complex computations. This example is very trivial, and could be achieved more easily with Time Instants. But maybe, you want to substitute the '9' with a variable, which is the result on an individual algorithm, you programmed in Python language
How-to
Model 1d accords with Model 1a. The only difference is that we use a Scripted Time Instant to determine the start event’s inter-arrival time.
Approach
-
Click the start event (make sure you selected simulation from the property set)
-
Open up the Time Editor to set up the inter-arrival time of the start event
-
Now select Time Instant from the drop-down-box in the top-left corner of the time editor
-
From the second drop-down-box (right to the previous one) select Scripted Time Instants
-
The Time Editor now contains an input-box, in which you can write your Python code
-
Put this line into the text area: Result=SimulationContext.Time.GotoHour(9); (see Figure 2)
-
This tells the simulation to advance to 09:00 o’clock when the event is being initialized by the simulation
If the simulation time is past 09:00 o’clock it will advance to the next day’s 09:00 o’clock -
Report
See below for the run configuration, which we set up to receive the report statistics from below.
Please refer to the section Experiment Results for more information on the report specific data.
Run configuration
-
Stochastic Seed: 12345
-
Simulation start date: 1/1/2014 12:00:00 a.m.
-
Simulation stop time: 240
-
Simulation stop time unit: Hours
Report statistics
-
Contrary to the former configurations we defined a simulation time of 240 hours (10 days)
-
Our start event fires only one time per day (always at 9 a. m.)
-
Therefore the process will start ten times (see Figure 3 below) within the simulation time