Running Models


Once a model has been drawn and the details of each of its boxes have been specified, it can be run using the items in the run menu, or the buttons in the run toolbar. Whilst the model is running, the user can watch messages being received and processed by boxes by opening the boxes and selecting the Current Contents or Messages tabs.

The Execution Model

Execution of a COGENT model takes place in a series of cycles. On each cycle a box undergoes a state transition during which it may send and/or receive messages and/or change its contents. On any given cycle the boxes may be assumed to undergo their state transitions in parallel.

A COGENT specification of a model is effectively a specification of the initial state of each box together with a specification of a state transition function for each box. Within this execution model, communication between boxes is handled by simple message passing: messages are removed from a bus at the beginning of each cycle, processed, and then results are placed onto the bus at the end of each cycle. This execution model is both simple and effective.

Cycles, Steps, Trials, Blocks, Subjects, and Sessions

In order to explain the various ways in which a model can be run it is first necessary to define some terms:

Initialisation and Experiments

Normally you will want to initialise a model before executing it. Initialisation empties boxes of their current contents and message lists, and loads relevant boxes with their initial contents. Some box types, such as buffers, have properties which govern when they are initialised, allowing them to accumulate information across a sequence of trials, blocks or even subjects if required.

Boxes can be initialised on each trial, each block, each subject or each session. Correspondingly, there are four levels of initialisation. As well as initialising the appropriate boxes, these levels of initialisation interact with the trial, block and subject counters, such that when, say, a subject initialisation occurs, the subject counter is incremented and the block and trial counters are reset. These counters can be queried by means of special conditions, intended for use by "Experimenter" boxes to facilitate data gathering and analysis.

While developing a model, the different initialisation levels will not generally be required; in such circumstances the default, Initialise Session, which initialises everything and resets all counters, should be adequate.

N.B. if COGENT detects that a given model has never been run then it will automatically perform an Initialise Session operation before running or stepping through that model. An attempt to initialise such a model in trial, block, or subject mode, will also result in its being initialised in Session mode. The reason for doing this is that a model has to be initialised in Session mode at least once before it can be run.

The Run Toolbar

The run toolbar, which is displayed in the window of every open box, provides access to the instructions most commonly used when running a model. The instructions made available by the toolbar should be sufficient for most purposes, at least whilst a model is being developed. More advanced instructions are available from the run menu.

ButtonAction PerformedEquivalent Menu Item
Initialise Session Run->Initialise->Session
Stop Execution Run->Stop
Step Through Predefined Number of Cycles Run->Step
Run a Trial Run->Run Trial
Run a Block of Trials Run->Run Block

Stopping and Resuming Execution of A Model

Execution of a model may be stopped using either the Run->Pause or Run->Stop menu items. The difference between the two is that Pause simply stops execution of the model whereas Stop also halts the prolog process which is running that model

Execution of a stopped or paused model may be resumed using the Run->Restart and the various Run->Finish->.... menu items. Execution can sometimes be resumed using only one of these items, however it may be necessary to use Run->Restart and then one of the Run->Finish->... items.

The File->Save and File->Save As menu items will save the current state of the model. Once the file has been reopened the Run->Restart and Run->Finish->... items allow execution to be resumed from the point that was reached immediately before the file was saved.

The Run Menu

The run menu contains the following items:

Tracing and Debugging

Models rarely work first time as intended. COGENT provides some tracing facilities to assist with debugging in the form of message logs for all boxes and, for those boxes whose contents change, a window onto their current state throughout processing.

To see the current state of any box, open that box and select its Current Contents tab. (Boxes whose current state does not change will not have this tab.) It is thus possible to, for example, open up a buffer and watch its contents change as execution progresses. Hence if something isn't quite right, one possible strategy is to step through your model's execution examining the contents of any suspect buffers at each step. A similar facility is available for data sources and data sinks.

Being able to examine the contents of buffers and data boxes doesn't solve all debugging problems. It can also be useful to see the generation and passing of messages. For this reason all messages are logged and the messages received and sent by any given box can be examined by selecting that box's Message tab. If the message log is open whilst the system is running, messages will appear in the log as they are generated. Thus in trial mode it is possible to step through and examine the messages generated on any given cycle, and in block mode it is possible to sit back and watch messages arrive and depart.

If something is going drastically wrong, for instance if your model does not even star executing, it may be useful to examine the standard output and standard error channels of the prolog process that is executing the model. These may be seen using the View->Prolog Standard Output and View->Prolog Standard Error menu items. These menu items were, however initially provided to allow COGENT programmers to debug their programs and may not be of any great help to COGENT users.