June 3, 2010

Process to initialize object

Often you need to do so some initialization of state variables or other things at the beginning of the simulation. The objects in the Simio standard library have a process called OnIntialize that serves this purpose. But what about your own customly built objects?

Unfortunately, Simio does not offer you an event that is fired at the beginning of the simulation which you could use to trigger your initialize-process. The workaround is quite easy though: Add a timer element, set the first event to zero or Math.Epsilon. Math.Epsilon is a math function in Simio that returns the smallest possible time. Using this means that the event is fired at the very next moment after time zero. This can be useful if you want to make sure that other actions that must precede the initialize process are executed before. Now, set the timer's maximum event count to 1 and additionally the time interval to infinity. This way it is absolute safe that only one event is fired at the beginning of the simulation, and none afterwards.

UPDATE: Simio lets you overwrite the OnRunInitialize process and put in your own logic. You find this process when you're in the process pane under File -> Select Process -> OnRunInitialize.

Now simply create a new process and use the timer event as its trigger; there you go - you have your initialize process!