Actions

<< Click to Display Table of Contents >>

Navigation:  Defining a Model >

Actions

Previous pageReturn to chapter overviewNext page

Actions and triggers are used to make instantaneous changes to stocks and attributes, to create or delete entities, or both. Actions describe what will happen; triggers determine when the action occurs. We will discuss actions first, then triggers. There is also a separate exercise provided as a step-by-step example of using actions.

 

You define an action as part of an entity type definition. If you are defining chameleon entities, one property you will add is a "change color" action that, when triggered, changes the color of the chameleon. The "change color" action will be listed on the actions tab of the chameleon entity type, and the chameleon entity type is said to be the parent of the action.

 

Action Components

 

Properties

 

Most action types have some settings on the Properties tab of their inspector.

 

actionProperties1

 

References

 

All actions have an Invoker and a Parent on the References tab of their inspector.

 

actionReferences1

 

 

The Parent is the entitytype or collection within which the action is defined. You can't change this type (unless you redefine the action somewhere else).

The Invoker is the context of the Trigger that caused the action to occur. By default, the invoker type is the same as the parent type, but you can change this if your action will be called from a different entitytype. More than one type can invoke an action, though this will produce a warning, or an error if a necessary variable is needed but not available from the actual invoker.

Create actions have a special reference for the new entity to be created, e.g., newPerson.

Process List actions have a special reference for the current entity target in the iteration over a collection, e.g., refPerson.

You can add other references you may need, for example to the top-level Model singleton, to a collection, or to some other entity known to the Invoker or Parent.

 

Local Variables and Attributes

 

Actions can contain local variables for performing intermediate computations, like determining the attractiveness of options to be selected in a Process List.

 

You can use stock-flow notation to calculate accumulations within a Process List action. In this case, the accumulation is not over time, but over iterations of the action on its target collection.

 

actionStockFlow

 

Because action computations are volatile, these have no independent existence outside the action, and are not stored.

 

Surrogates and References

 

Variables used from the Parent, Invoker, or other references can be references or surrogates. A reference is a pointer to a variable somewhere else, whereas a surrogate is a local proxy for the variable.

 


Reference (or Referenced Variable)

Surrogate

Appearance (in default color schemes)

actionReference1

actionSurrogate1 or actionSurrogate2

Notation (in diagram labels and expressions)

. (dot)

Parent.BankBalance

• (bullet)

newPerson•BankBalance

 

Creation

Drag from the inspector. In some cases you may need to use the <control> key as a modifier while dragging.

 

-or-

 

Enter the desired name in the expression (autocomplete will help you fill in the name if you start with Parent. etc.). The result will be underlined, indicating that the cause is not shown on the diagram. Right-click the underline and use the "Draw Arrows" method from the context menu.

Generally automatic in a Create action.

 

Attribute

 

To initialize it (Create action only): surrogate

To change it: surrogate

To use it: reference

Unless you already have the surrogate, in which case you could use that

 

Stock

 

To initialize it (Create action only): surrogate

To change it: reference, with a local flow

To use it: reference

 

Other variable types always use a reference.

 

actionSurrogateReference1

Initializing Surrogates from Parent references.

 

actionSurrogateReference2

Initializing a Surrogate from a Parent reference, then propagating the value to initialize another Surrogate (rare).

 

actionReferenceFlow1

Making a conserved flow from one referenced stock to another in a Process List action.

 

actionSurrogateReference3

Invoker (a Bank) lends startup cash to the surrogate of a newCompany in a Create action.

 

Action Types

 

There are several types of actions, but all of them have in common the ability to make immediate changes to the values of stocks and attributes. Actions that do nothing other than make such changes are called command actions, and are the most basic type. The other types of actions have the same capabilities as command actions, plus additional capabilities depending on the type.

 

Note: On any of the action tabs, you can create surrogate links by dragging and dropping a variable on to the page. You can suppress the creation of surrogates and instead create ghosts by holding the Cntrl key while dragging and dropping a variable.

 

 

Command actions are the most basic actions that can change attributes and stock values and trigger other actions.

 Self-delete actions that perform commands then remove an entity from the model, create actions that create new entities and then perform commands, and process list actions, that perform commands on one or more entities from a collection. Finally we looked at allocate and market actions that resolve mismatches in supply and demand. All these actions specify what will happen. We next discuss how to use triggers to specify whether and when an action happens.