<< Click to Display Table of Contents >> Variables |
|
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.
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: 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].
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.
A variable computed from the properties of a collection of entities is called an aggregate variable. Aggregates are discussed in Collections and Aggregates.
To add a variable to the model, you can
•drag its icon onto a diagram from the palette,
•or, right-click an empty space on the diagram and choose "new stock", "new flow" or "new auxiliary", or
•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.
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:
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.
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,
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.