Dynamic variable

While stock and flow diagrams may contain only stocks and flows, it is a good practice to define intermediate concepts with dynamic variables

Commonly dynamic variables consist of functions of stocks (and constants or exogeneous inputs). In case you need to define a constant, use a parameter.

 To create a dynamic variable
  1. Drag the  Dynamic variable  element from the  System Dynamics palette onto the diagram of agent.
  1. Go to the Properties view and specify the name of the dynamic variable in the Name edit box. 
  2. Type the formula for a variable in the variable_name = edit box (you may use code completion here to insert names of other elements). 
In case there are some other elements mentioned in the formula, you should draw links from those elements to this dynamic variable first. There is however, link autocreation mechanism supported by AnyLogic - you may just specify the formula - when finished typing, the error indicator will be shown to the left of the formula.

Click this indicator to show the popup menu with items offering you to create missing links from the mentioned elements to this dynamic variable. Choosing an item from the list you create the corresponding missing link.

You can subsequently create all missing links in such an easy way:

  1. If you explicitly specify units of measurements for elements of your stock and flow diagram, do it for this dynamic variable. Go to the Advanced section of its properties and select the System dynamics units checkbox and type the unit name in the edit box (you can find more information on units and unit checking here.)
  2. If you do not want this variable to get its value according constantly reevaluated formula but otherwise want it to be equal to some specified value (that can be changed during the simulation), check the Constant check box. Constant dynamic variable is drawn with an equal sign over its icon: .
  3. If this dynamic variable has multiple dimensions, declare this dynamic variable as array and then define formulas for its elements as described here
  4. If you are creating hierarchical model by exposing system dynamics variables onto interface of the agent type and you want to connect this variable and make it dependent so that it will get its value from the connected variable, select the Dependent check box.
  5. Optionally change the fill color of the variable icon by choosing the required color from the Color control.

Properties

General properties

Name – The name of the dynamic variable. The name is used to identify and access the dynamic variable in formulas.

Show name – If selected, the name of the dynamic variable is displayed on the presentation diagram.

Ignore – If selected, the dynamic variable is excluded from the model.

Visible on upper level – If selected, the variable is also visible on the upper level where this agent lives.

Show at runtime – If selected, the variable is visible on the presentation at runtime.

Color – The fill color of the variable icon.

Array – If selected, the variable is of array type. Properties for array variables look slightly different. Instead of one variable_name = field defining the formula for the dynamic variable, there can be several fields defining formulas for some particular elements or sub-arrays of the array variable. To add new section allowing to define one more formula, click the Add formula button. Defining formulas for array elements and sub-arrays is described here.

Dependent – If selected, the dynamic variable will get value of the connected variable constantly.

Constant – If selected, the dynamic variable is a constant, i.e. its value does not change according constantly reevaluated formula but is equal to the specified value (that can be changed by the user during the simulation).

variable_name =The formula defining the value of the dynamic variable. In the case this variable is an array, there can be several fields defining formulas for some particular elements or sub-arrays of the array variable. To add new section allowing to define one more formula, click the Add formula button. Defining formulas for array elements and sub-arrays is described here.

Array properties
Array properties are available only if this variable is of array type. To make the variable an array, check the Array check box on the General property page.

Available dimensions – The list of dimensions defined in this model.

Selected dimensions – The list of dimensions that will act as dimensions of this array variable.

These properties are used to define dimensions that make up the array variable.
Please refer to the Defining an array variable section for details.

Advanced

System dynamics units – If selected, you will be able to specify units of measurements for this variable in the edit box to the right. Having specified units for all elements of your stock-and-flow diagram, you may perform unit checking to find out dimension inconsistencies in your model.

At model runtime you can view value and chart of the dynamic variable as well as copy the collected history of values to Clipboard, you can find more information here.


Related topics

 System Dynamics tutorial

 System Dynamics modeling

 Viewing variables at runtime

 Modifying variables at runtime