Variables

<< Click to Display Table of Contents >>

Navigation:  Defining Entity Types > Create a New Entity Type >

Variables

Previous pageReturn to chapter overviewNext page

A variable is a quantity whose value changes can change over time. A variable has a name, an expression used to calculate its value, and a value at each point in time during the model simulation. A constant is a quantity whose value does not change during the simulation; a constant has a name and a value. In Ventity, a constant is a type of "variable." (Even though it does not vary during a simulation, it may have different values from run to run). Some examples of variables:

 

In your "wine" entity type, you might include a variable called vintage with expression 1987. You might also have a variable called age with expression current year - vintage.

In your "business" entity you might have variables for revenue, expenses, profit, assets, liabilities, and equity. The expression for profit would of course be revenue - expenses, and the expression for equity would be assets - liabilities.

 

If you are used to working in spreadsheets, a variable is comparable to a named range: a set of values with a common name and a common formula used to compute them.

 

In Ventity, every variable is a stock, a flow, an auxiliary, or an aggregate. Clouds are used to symbolize flows to or from outside the model.

 

vartypes

 

Stocks

Stocks are like the balance of a bank account: they are accumulations, the amount that remains if all activity stops. Many people recommend starting with the stocks when deciding what variables to include in your entity definition. If you were to freeze time, what would be the important quantities that would determine the status of an entity of this type? For a living organism, these might be age, height and weight. For an air transportation system, these might be numbers of aircraft, pilots, and travelers. For a business, these might be assets, liabilities, and equity. If you are accustomed to modeling in spreadsheets, stocks are the best way to handle any cumulative quantity.

 

Note that some stocks don't need to be defined as stocks. Equity is Assets - Liabilities, so if Assets and Liabilities are stocks in the model, it is easier to make Equity an auxiliary than to make it its own stock with its own inflows and outflows.

 

 

Style Tip: Some people use the convention of capitalizing the first letter of the names of stocks, and using lower case for all other variables.

 

 

Flows and Clouds

Flows: Every stock has flows: inflows, outflows, or both. For the stock bank balance, an inflow is deposits, and an outflow is withdrawals. A flow can also represent the movement from one stock to another. For example, a flow called promotion might be an outflow from workers and an inflow to managers.

 

Note that the units of a flow in an entity should always be the same as the units of the source and destination stocks, divided by the model time unit. So if bank balance is in dollars, then deposits should have units of dollars/day, dollars/week, dollars/month etc. See below for more information about units.

 

Clouds: Note that every flow must have an origin and a destination. Sometimes, only one of these is of interest. In those cases, a cloud is used in place of the irrelevant stock.  The classic example is that one inflow to a population stock is births. Where babies come from, and how many unborn babies are waiting their turn to be born, are not generally a concern. Clouds represent an assumption in the model that the source can supply infinite numbers without being depleted, and that how much is left in the source at any time is not relevant in the model. As destinations, clouds represent an infinite sink: an assumption that neither the amount of material that has "left" the model, nor its destination, is of interest. It is often recommended to think twice when using a cloud. Assumptions that groundwater is inexhaustible, or that the total amount of pesticide applied to a field is irrelevant, may not be reasonable assumptions.

 

For an exercise example in the creation of Stocks, Flows and Clouds, click [here]. Or to read more about the various nodes in Ventity, click [here].

 

Auxiliaries

Any variable that is neither a stock nor a flow is an auxiliary. Auxiliaries are generally used to break the calculation up into pieces of an understandable size. For example, it is useful to compute revenue and expenses as separate variables, before combining them into a flow called profit.

 

Aggregates

A variable computed from the properties of a collection of entities is called an aggregate variable. Aggregates are discussed in Collections and Aggregates.

 

 

Creating New Variables

 

To add a variable to the model, you can

drag its icon onto a diagram from the palette,

 

NodePalette

 

or, right-click an empty space on the diagram and choose "new stock", "new flow" or "new auxiliary", or  

 

vars01

 

choose one of the "add" buttons from the bottom of the variables tab on the entity type inspector. Your new variable will appear in the inspector's variable list. If you wish to add it to a diagram as well, simply drag it from the inspector onto a diagram.

 

vars02

 

 

Name

When you create a new variable, you will be prompted for a name. Ventity™ variable names must ...

 

... start with

a letter (upper or lower case), $, @ or #.

... continue with

letters, $, @ or #, numbers, spaces, underscores or apostrophes.

... end with

a letter, $, @ or #, or a number.

 

Ventity variable names are not case sensitive. Also, any number of adjacent spaces or underscores ("whitespace") are collapsed to a single whitespace. Thus, "patients in remission", "Patients In Remission", and "Patients_In_    Remission" are all ways of writing the same variable in Ventity. Similarly, "$howers tod@y" and "$HOWers  _ _ _   toD@Y" are two ways of writing the same variable in Ventity.  

 

You can always rename a variable by right-clicking it and choosing "rename". Renaming it anywhere will automatically rename it everywhere in the model, including built-in data files. Use caution, however, because renaming a variable can create mismatches with external data files.  

 

Ventity will display variable names in whatever form they are first entered. If you create "patients in remission", that's how it will appear, even if you type it other ways. To change the way a variable name is displayed (for example, to see "Patients in Remission" instead),

Step:

Example:

1. Change the name to something with a different spelling. This resets Ventity's memory of the original capitalization.

Rename "patients in remission" to "patients in remission XXX"

2. Change the name back to the original but with the desired capitalization.

Rename "patients in remission XXX" to "Patients in Remission".

 

Each variable name in an entity type must be unique: you can't use "x" for two different purposes in the same entity type definition. Variable names cannot be the same as the entity type they are in, and they cannot be the same as any attributes or references of the entity type.

 

To add information other than the name, edit the variable by double-clicking or right-clicking and choose "Edit variable." The following fields will appear:

 

 

Default Initial Value (for stocks)

 

EditStock

 

There's no need to enter an equation for any of the stocks in your entity type definition, as stocks are automatically calculated from their inflows, outflows and initial values. Inflows and outflows are determined by which flows you create and connect to your stock and they appear listed at the bottom of the dialog. Initial values for stocks are set during initialization. However, if no value is provided during initialization, Ventity will calculate the initial value from the expression you put in the Default Initial Value field. That expression can be a constant, or a formula. If you enter a formula, in most cases your formula will refer to another variable. You can use names of other variables in the same way you'd use named ranges in a spreadsheet. For the variable profit, the equation would be revenue - expenses.  Along with the basic operators (+, -, *, /), you can also use a large range of functions in your equations, such as the square root function sqrt() and the summation function sum(), similar to the functions that spreadsheets provide. A complete list of functions appears below.  Ventity will evaluate the formula at the start of the simulation and use the result for the default initial value.

 

Constant and Equation (for flows and auxiliaries)

 

EditFlow

 

The "Constant" checkbox appears for flows and auxiliaries.

If "Constant" is checked, the variable can be assigned a different value for each entity during initialization. That value will be used throughout the simulation. If no value is provided from initialization, the value will be computed from the equation at the model start time, then held constant at that initial value throughout the simulation.

If "Constant" is not checked, the value of the variable will be determined from the equation at each time slice.

 

Description

 

EditAux

 

The description field is a place for you to annotate your variable with a natural language description of the intent of the variable, sources, or any other explanation or notes,

 

 

Causes and Uses

 

When variables depend on other variables, the independent (input) variables in the relationship are often called causes. Dependent variables are often called uses. For example, if profit depends on revenue and expenses, and sales tax depends on revenue, then revenue and expenses are profit's causes. Profit and sales tax are uses of of revenue.

 

For more information on tracking causes and uses, see Causal Tracing.