ifference between revisions of "EMK:Formulae and Functions"
Line 32: | Line 32: | ||
| \ || Integer Division || 3\2 = 1 || Real; Int || Int | | \ || Integer Division || 3\2 = 1 || Real; Int || Int | ||
|- | |- | ||
− | | | + | | % || Modulus || 7%5 = 2 || Real; Int || Int |
+ | |- | ||
+ | | / || Division || 3/2 = 1.5 || Real; Int || Real | ||
+ | |- | ||
+ | | * || Multiplication || 5*4.2 = 21 || Real; Int || Real | ||
+ | |- | ||
+ | | - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real | ||
+ | |- | ||
+ | | + || Addition || 3.5+1.5 = 5 || Real; Int || Real | ||
+ | |} |
Revision as of 08:35, 21 November 2012
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:
- Constants
- Variables
- Operators
- Entities and Traits
- Functions
Constants
Constants can be:
- Numbers: Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.
- Strings: Written inside double quotes e.g. "A Node"
- Dates: Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005'
Warning: The format for entering dates should compatible with the computer's local date (locality) setting
Variables
Variables can be regarded as user-defined Entity.Traits which can be defined in the Volatility Matrix or the Schedule. Previously defined variables can be used in formulae.
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.
Operators
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.
The following operators are shown in descending order of precedence.
Operator | Meaning | Example | Parameter Type | Return Type |
---|---|---|---|---|
\ | Integer Division | 3\2 = 1 | Real; Int | Int |
% | Modulus | 7%5 = 2 | Real; Int | Int |
/ | Division | 3/2 = 1.5 | Real; Int | Real |
* | Multiplication | 5*4.2 = 21 | Real; Int | Real |
- | Subtraction | 7-3.2 = 3.8 | Real; Int | Real |
+ | Addition | 3.5+1.5 = 5 | Real; Int | Real |