Difference between revisions of "STEM Expression Language"
|Line 11:||Line 11:|
* Local variables
* Local variables
A fifth type of variable
A fifth type of variable '''system variables'''. These variables are '''not visible to the expression language''' and are only used in function definitions.
==== Global Variables ====
==== Global Variables ====
Revision as of 17:39, 19 June 2013
- 1 About STEM Expressions
- 2 Expression Editor
About STEM Expressions
The STEM Expression Language is designed to allow easy access to key components of the STEM modeling and simulation framework by using variable and function-driven equations. The variables and functions are designed to simplify access to STEM APIs for getting compartment values, model parameter values, as well as access to various denominator datas through functions.
There are four types of user variables that are visible to your expressions, three of which a user can change.
- Global Variables that represent key parts of the simulation state. These are fixed and cannot be edited.
- Model Parameter variables that represent the model parameters in your model
- Compartment variables that represent the absolute and relative values of compartments in your model
- Local variables
A fifth type of variable are system variables. These variables are not visible to the expression language and are only used in function definitions.
Model Parameter Variables
Compartment variables provide access to your model's compartment values for each region for a step in the simulation. There are two types of compartment variables:
- Relative Compartment Value variables - lower case
- Absolute Compartment Value variables - upper case
Relative Value (lower case)
Relative compartment values are calculated as Compartment Value divided by Region Population Count. They are accessible to expressions using the compartment name beginning with a lower case letter.
Example: s, e, i, r
Absolute Value (upper case)
Absolute compartment values are the absolute current value of the compartment. They are accessible to expressions using the compartment name beginning with an upper case letter.
Example: S, E, I, R
Expression statements are "local" variables. A user may define statements above the "delta" line that then can be used in subsequent statements in the expression.
myVariable = S*effective(i); delta transmissionRate*myVariable;
The Visual Editor's Expression Editor is a simple tool to enter the equations that describe the movement of a population between two compartments for each region for each step of the simulation. The transition value - the delta - as calculated by the equation entered represents a balanced decrease from the source compartment equal to the increase in the target compartment.
Select a Transition
To select a transition, a user may either:
- Select from the Visual Editor's canvas using the Chooser Tool
- Select from the Transition drop-down menu
The expressions used in the Expression Editor follow the STEM Expression Language. For full details, see above
The last statement in the expression editor must start with the delta keyword/operator. This is the value used to compute the movement from source to target compartments.
Contextual Content Assist
The content assist feature provides contextual suggestions to assist a user authoring expressions. This includes partial-completion of variables, functions, and operators. In the future, complete documentation will also be available from the content assist window.
Content assist is available at all times while editing an expression. To access the content assist prompt, simply type Control-<Space>. You can continue typing to further filter available syntax/semantic options.
Syntax Highlighting / Coloring
For internal and reporting purposes, the STEM simulation engine needs to know which transitions represent an increase in disease incidence. The (positive) delta value of the transition will be added to each incidence total after each step.
A transition can account to zero or more incidences that are included in a disease. Under For Incidence, check the box(es) next to the incidence name for a given transition.
Any problems with the syntax (structure) or semantic (types, etc) of your expression will result in an error.
Important note: Errors in the model will prevent the expression compiler from generating the code to update your disease/population model. Please fix any errors before trying to run the model in STEM.
The Expression Editor will notify you of an error in several ways:
- The part of the expression that is not understood will be underlined in red
- A small red X icon will appear next to the line in the Expression Editor
- The transition connection in the Visual Editor will be highlighted red indicating an invalid expression
- If the Model is saved with an invalid expression, a red icon will appear next to the metamodel file in the Project Explorer
Error notification in the Visual Editor
Error notification in the Project Explorer