Term definitions

  • A variable is an identifier whose value can be changed during the execution of the model.
  • A binding is the association of a value with a variable. A binding has both scope and content.
  • A scope is the locations in a model in which a particular binding can be referenced.
  • An extent is the interval during which a particular binding is in effect.

CPN variables

CPN variables are variables that are used in CP-net inscriptions. They have the following characteristics:

  • They are declared using the reserved word var and the name of a previously declared color set.
  • They are bound to a variety of different values from their color set by the simulator as it attempts to determine if a transition is enabled.
  • A variable is bound to a value, the scope of a variable is local to the transition.
  • There can be multiple bindings simultaneously active on different transitions. These bindings can exist simultaneously because they have different scopes.
  • The extent of a CPN variable binding is the firing of a particular transition.
  • They provide arc inscriptions with the ability to reference different values.

If a variable is from a color set with less than 100 elements, the simulator is always able to bind a value to it.

Declaration Syntax

var id1, id2, …, idn : cs_name;

where:

  • idi must be an identifier.
  • : is the syntactic separator between the identifier(s)
  • cs_name is the name of a previously declared color set.

Declaration Examples

var i,j,k : INT;

var intList : IntList;

Reference variables

A reference variable is similar to a pointer in C. The scope of a reference variable is the entire CPN.

Reference variables must never be used in any way that affects the enabling of transitions. To illustrate the problems that could arise if this rule were broken, consider the following example:

A reference variable, refvar is used in arc inscriptions for input arcs of two different transitions, transition A and transition B. Both are enabled, and transition A fires. Transition A changes the value of refvar in such a way that transition B is no longer actually enabled. However, the simulator has no way of knowing this, since enabled transitions are not rechecked before they are fired (to recheck each time a transition is chosen for firing would degrade performance to the point of unusability). Attempting to fire transition B results in unpredictable system errors.

Reference variables may be read and updated in code segments.

Reference variables may be read in

Several kinds of inscriptions may not depend on reference variables in any way. The following kinds of inscriptions may not be used to read or update reference variables, nor may they depend on any declarations that depend on reference variables:

The restrictions on where reference variables may and may not be used are currently not checked or enforced by CPN Tools. The simulator and state space tool may malfunction if the restrictions are violated.

Declaration Syntax

globref id = exp;

Declaration Examples

globref i = 10;

globref cur_date = (Mon, 5);

Operations

  • !r: contents of the reference variable r
  • r:=v: assignment of the value v to the reference variable r
  • ref v: reference constructor
  • inc r: increment contents of integer reference variable r by one, i.e. add one to the contents of r
  • dec r: decrement contents of integer reference variable r by one, i.e. subtract one from the contents of r
Value declaration

You must be logged in to post a comment.