Objects in this document may appear out of sequence if not viewed with Internet Explorer

ORMSware NMOD Primer: Chapter 13


Events, execution feedback, and model debugging

As mentioned before, NMOD is a subset of ORMSware Suite's discrete event simulator component. As such, NMOD is pretty much a discrete event simulator, except that it does not provide users access to resource entities, features associated with automatic handling of resources, automatic collection of statistics, etc.

Events in NMOD

A powerful object in the simulator, which is also available in NMOD, is the Events Queue. Events Queue is essentially the spinal chord in the NMOD nervous system. NMOD's brain receives stimuli from the networks through the Events Queue and carries out responses through the same. Events Queue sequences each new stimulus and response according to the conceptual time when they are supposed to occur. If two events are supposed to occur at the same conceptual time, they are ordered in the last-in-first-out sequence.

Current version of our example model has no time dimension. i.e. the Duration property of every network object in the model is 0. Therefore, everything is supposed to happen at the same conceptual time. However, the sequence of calculations in real time is still controlled by the network structures in the model.

The easiest way to learn how events work is to look at the execution feedback file of our example model.

Model execution feedback and debugging

NMOD can be instructed to automatically trace customer/surrogate travels through a model's network(s). To keep the feedback file short for this illustration, we have switched the model from curve building mode to normal single what-if mode. If you recall, the way to do this is to simply change the Type property of CostPerPiece.[2] to Normal. By defining this node Type to be Normal rather than Network, we can also prevent NMOD from executing the PiecesPerHour [sub]network. Since, n[2] is not an Arrival node now, we have to also change the Type property of n[5] from Departure to Normal.

Figure 12

Click Figure 12 to open a separate window displaying the execution feedback file (Figure12NMOD.TXT) of the model. If possible, it will be a good idea to get a printout of the model's networks in Figure 11a/PrimerVSD window as well as that of Primer.NET in Figure 11b/PrimerNET.TXT window.

If Figure 11a window is not already open click here. If Figure 11b window is not already open click here.

Note: If you have Visio 2002, you can download Primer.VSD from the link listed in Chapter 1 (Installing ORMSware's modeling environment) of the Hands-on Tutorial and look at the actual VSD file of the model.

We will be looking at a total of 13 events in the model's execution feedback file. In Figure 12 window, ignore all of NMOD's Configuration feedback trace, etc. at the top of the feedback file and page down (or search) to find Created T0-C0 below Start of model execution feedback.

Notes

1. If you have not downloaded ORMSware's modeling environment, you can copy and paste the bold text into search dialog box that pops up when Ctrl-F is pressed in your browser (Internet Explorer). In case the search doesn't find the text you pasted into the dialog box, try searching for part of the boldened text. You shouldn't have to do this (barring human errors we have missed), since search texts in this primer were copied from the linked files and pasted here.

2. Switching between files and searching for Events (which you will be doing a lot) will be so much easier if you have downloaded the environment. Load the files we refer to into UltraEdit browser set up for ORMSware. Then (for example) when you are going through feedback files, you can press Ctrl-F, make sure the List Lines Containing String option is checked in the Find dialog box, and initiate a search on End event. A box will pop up with a list of all events in the feedback file. Then when you read in this document to jump to an event, you can simply double-click on the event referred to make the jump.

Recall our discussion earlier about default customer, default token and the first two surrogates. In feedback file, Created T0-C0 means that NMOD has created the default token with ID of 0 and assigned it to a customer with ID of 0. The next two lines indicate creation of the first two surrogates which are assigned to serve T0-C0. The 1 and 2 at the end of the lines are traces of the Surrogate count property of token T0-C0.

The next line shows that NMOD is executing the Start node of the top network, which is the CostPerPiece network.

When NMOD executes a node or arc, it does the following in the order listed below:

  • Executes the object's Trans procedure property, if any
  • Executes the object's Duration property, if any
  • Places the triggering surrogate (in this case S2-T0-C0) in Events queue

&L.CurveBuild F in the next line is the result of the analyst's WRITE statement in the Trans property of n[6]Initialize (see code block for object 6 in Figure12NET.TXT window).

Upon finishing execution of [6]'s Trans procedure property, NMOD enters surrogate S2-T0-C0 in Events queue as you can see in the next feedback message. The message only says Entity 2 entering Events queue, but we know from the context that the entity is Surrogate S2.

Every time NMOD finishes a task set (such as execution of a property block) it looks in the Events queue to see what is pending to be done next. In this case it sees now that there is one pending event in the Events queue, viz. the very first event of this model described in the paragraph above. When there is an event pending, NMOD writes an End event block/mark (in this case End event 1 mark) to the feedback file and dequeues the next pending event entity from the Events queue.

Note: Every Event message marks the completion of that event.

Upon dequeuing an entity from Events queue NMOD examines various properties of the entity and the context of the event it completed to decide what to do next and how to handle that entity.

Feedback lines till the message Disposed S2-T0-C0  1 are self-explanatory. You may recall our explanation in Chapter 9 (Creation, assignment and disposal of tokens and surrogates) that NMOD disposes off a surrogate when it finishes execution of a node. Then, NMOD looks to see if the node has any successors.

n[6] has one successor arc, a[11], which terminates in successor node [2]. NMOD executes the Branch procedure property of a[11] and comes up with a value of True, because [11] is an unconditional arc. So, it creates a surrogate (see Created S2-T0-C0  2) to traverse [11]. Note that S2-T0-C0 was the last surrogate that was disposed by NMOD.

Normal in the next line means that NMOD is sending a Normal surrogate along this arc.

Note: There are entities called Null surrogates, but only Normal surrogates are available in current version of NMOD.

Continuing with the feedback file, when NMOD refers to the rank value of an entity entering a queue, it is referring to the value of the entity property used for determining the position of the entity in the queue (i.e. where in the queue the entity should be placed). In Events queue the rank value is usually the time when an entity is is scheduled to come out of the Events queue (i.e. time when the event which the entity is executing will be complete). 

Note: We say usually, because NMOD does not know what exactly the analyst has in mind when s/ he enters a value for the Duration property of an object. To NMOD it is only a number. Therefore, the analyst has the flexibility and freedom to use Duration properties in a model to indicate distance, cost, etc. If the analyst uses them for cost, events will get ordered in the Events queue from the smallest cost to the highest. You can see how this works in Example Problem 1 (Equipment Replacement). When the Duration is used for time, obviously, events get ordered from the closest to the farthest.

Follow along the feedback to Disposed S2-T0-C0  1 under Event 3 mark. Successor arc 3 from n[2] happens to be a[16]. The feedback says that the branch condition for that arc was not satisfied. Looking in the Figure12NMOD.TXT window under object 16's Branch property, you can see that the condition says that the Customer ID must be > 1. Customer ID of S2-T0-C0 is 0. Therefore, this branch does not execute.

Note: Successor arcs from a node are not stored in any particular predetermined sequence. As such, one should not rely on arcs being tested and executed in any assumed sequence.

Notice now that the Branch properties of the other three successor arcs evaluate to True. NMOD creates a surrogate for each and places it in the Events queue. Once NMOD enters S4-T0-C0 in Events queue for traversing [8], it has finished the task-set of evaluating all successor arcs of [2] and taking appropriate actions accordingly. So, having completed that task-set, NMOD looks in the Events queue to see what is pending to be done next.

Looking below Event 4 mark, you can see (from the Dequeued entity feedback) what was at the front of the Events queue. Since all events are happening at the conceptual time of zero, the entity at the front of the queue was the entity that entered the queue last (using the Last-in-First-out queue discipline we mentioned earlier). Upon taking Event 3 entity out of the Events queue (finishing of CostPerPiece.[2]PiecesPerHour) and going through the arcs evaluation and execution process, the last thing NMOD did was enter a surrogate (S4-T0-C0) to execute/traverse [8]. Then, when NMOD looked in the Events queue to see what was to be done next, S4-T0-C0 was at the front of the Events queue.

Again, since all Durations are 0, that thread (S4-T0-C0) will keep going until it comes to a point where it has to wait for something else to happen. In this case, this happens after the very next event.

Follow along to Event 4 mark. When S4-T0-C0 finishes AND arc a[8], it reaches Convergence node [3]MachineCostPerHour. Since it is arriving through an AND arc, NMOD checks [3]'s convergence status for customer token T0-C0. Feedback message >> << 2 required for convergence, 0 waiting shows that another entity representing Customer 0 should arrive through an AND arc at [3] before it can be evoked. Since convergence condition is not satisfied, NMOD puts S4-T0-C0 in  n[3]'s [automatically created] Convergence queue. Since nothing more can be done with this surrogate at this time, NMOD leaves it in the queue and picks up the next entity in the Events queue.

Follow along now to Event 7 mark. When Entity 3 is dequeued, the other item remaining in the Events queue (in case you are wondering) is S2-T0-C0 created after completion of n[2], i.e. Event 3, for traversing [12]. After dequeuing and disposing off entities in [3]'s convergence queue is complete (look for ===), you will see #S.MachineCostPerHour,&S.WearCoeff,#D.PiecesPerHour,&S.WearExpon and their corresponding values in the 2nd record below the === mark. This custom feedback is from our WRITE statements in n[3] (see code block for object 3 in Figure12NMOD.TXT window).

Follow along to Event 12 mark. Notice the convergence situation for n[5].

Feedback below Event 12 mark shows the arrival of a surrogate along an AND arc to n[5] (see message >>!<< 2 required for convergence, 1 waiting. Requirement satisfied). This triggers the process for executing n[5] for Customer 0. NMOD searches for that 1 waiting surrogate representing Customer 0 in [5]'s Convergence queue (see message Search by rank value 0.000000000000000, rank value being the Customer ID), dequeues it and disposes it off before executing appropriate procedure properties of n[5].

You now know enough to follow along through Event 13 mark.

When n[5] is finished, a[15]'s Branch property evaluates to False. Notice the result from the WRITE statement in [15]'s Branch property and the fact that though the branch condition evaluates to False, all of the logic in [5]'s Branch property block still executed as intended.

You may have noticed by now that when NMOD issues a feedback message about a node or arc, it puts a number in front of the notation for that object. For example, below the Event 10 mark, the message says S2-T0-C0 finished arc 3 CostPerPiece.[12]PiecesPerHour--->|LaborCostPerHour.

While [12] is the Visio object ID of this arc (as displayed in the network), 3 is the arc sequence number assigned to it by NMOD. When NMOD needs to access or manipulate properties of an arc, it uses this sequence number to find the arc's logical location in memory. Same process applies to nodes, too.

Note: NMOD uses two sets of sequence numbers for tracking the two network object types. One sequence set for nodes and the other for arcs. 

There are no more events pending in the Events queue after the task-set following Event 13. So, NMOD executes the cleanup-and-wrap-up process. Cleanup involves checking for entities remaining in Events queue (in case model execution was logically/programmatically terminated before Events queue is empty), Convergence queues, and other queues in the model. If there are any entities remaining in any of the queues, NMOD dequeues them and writes trace messages to execution feedback file so that the analyst can see where things may have hung up.

After cleanup, NMOD disposes off the very first surrogate created for housekeeping purposes and then disposes off the default Token and default Customer. And, model execution ends normally.

Execution time written at the very end of the feedback file will vary for the same model (with same data) depending on other tasks the computer is handling at any given time.

 

Click to go to Chapter 12: Working with Visio interface and NET file

Click to go to Chapter 14: Signal targets/temporal arcs property of network objects

Click to go to Introduction: NMOD Primer