Primitive Operators and Properties

From Nova Documentation
Revision as of 19:33, 12 December 2014 by Novaadmin (Talk | contribs)

Jump to: navigation, search

The Properties/Primops list is correct as of Release 12, which became available on March 31, 2014 Primops added subsequently are identified by version number.

Nova supports a large set of primitives divided into properties and primitive operators, or primops.

A property is an identifier assigned a value at the beginning of a simulation run which is not expected to change. For example, the rows and cols properties of a CellMatrix are fixed at the start of a run and don’t change. A special type of property, called an state object, is used to look up the current values of components.

Primops are functions of zero or more arguments. Some primitives may be used without restriction; others make sense only in specific contexts; for example rows and cols are only useful in spatial contexts such as CellMatrices, AgentVectors and SimWorlds.

Here are the properties and primops supported by the current Nova implementation, organized by type and area of applicability. All properties begin with a lower case letter, state objects begin with a capital letter, and primops are composed entirely of capital letters. Primops are always functions, and therefore require an argument list (even if empty) in order to be invoked.

Notation: x, y represent values (numbers or string constants or expressions); fn represents a Javascript function; exp represents a string expression; [x, y] represents one or more optional arguments.

Universal Properties and Primops

These can be used in any expression in any component.

Properties

Self
The state object of the enclosing simulator (Capsule, CellMatrix, etc.) Used to look up component values (see the section on state objects, coming soon).

Control Primops

ALERT(s)
Displays message s in a dialog box.
COUNT(fn, l)
fn is a boolean function of one argument and a l is list.
Returns: COUNT(f, l) applies f to each element of l and returns the number of times the result is true.
DELAY(comp, x, [y])
Returns: the value of component comp delayed by x time units. Comp is a string naming a stateful component (i.e., stock, variable or sequence).
Optional y is returned if the current time is less than x. If y is omitted then 0 is returned.
PULSE(amount, start, interval)
Returns: amount when current time is start, start + interval, start + 2*interval, etc.; 0 otherwise
STEP(x, y)
Returns: the value of x if the current time is y or greater; 0 otherwise.
TOTAL(fn, l)
fn is a numerical function of one argument and a l is list.
Returns: TOTAL(fn, l) applies fn to each element of l and returns the sum of the results.

Convenience Primops

These primops perform useful functions that could otherwise be programmed.

FLIP(p)
Simulates a Bernoulli trial.
Returns: true with probability p and false with probability 1-p.
Available as of release 12.1.