WEAP borrows an approach made popular in spreadsheets: the ability for users to enter data and construct models using mathematical expressions. Expressions are standard mathematical formulae used to specify the values of variables in WEAP's Data View. In the Current Accounts an expression defines the initial value for a given variable at a branch, while in scenarios, the expression defines how that variable changes over time (from one year after the Current Accounts to the end of the study period).
Expressions can range from simple numeric values to complex mathematical formulae. Each formula can optionally use WEAP's many built-in functions, as well as referencing the values of other branches, both data and result variables. Expressions can even create dynamic links to the values stored in an external Microsoft Excel spreadsheet.
WEAP provides a number of ways of editing expressions. The most common are:
Typing directly into the expression field in one of the data entry table's in WEAP's Data View.
Using the Yearly Time-Series Wizard (a tool for easily entering time-series functions such as Interpolation, Step, and Smooth Curve functions) or the Monthly Time-Series Wizard.
Using the Expression Builder tool: a tool for creating expressions by dragging-and-dropping functions and WEAP data and result variables.
When editing scenario data in WEAP's Data View, expressions are color coded to show which expressions have been entered explicitly, and which are inherited from another scenario. Red text indicates a value entered explicitly, whereas black text indicates an inherited value. To reset an expression back to its inherited default, highlight the expression and press the Delete key. For more information, see Scenario Inheritance.
If no data has been entered yet for an expression, either for the current scenario or any of its parent scenarios or Current Accounts, a default value will be shown in light gray. For most variables the default value is 0, although there are a few exceptions, such as Demand Site Consumption, which defaults to 100%.
Data Variables: In an expression, the values of other branches/variables are referenced by typing the branch name followed by a colon followed by the variable name. For example, the value of the consumption variable in the Demand Sites\West City branch (of the Weaping River Basin dataset) would be referenced by typing Demand Sites\West City:Consumption. Note: Expressions are not case-sensitive. You can enter variable and function names in any combination of upper and lower-case letters. When you have finished entering the formula, WEAP will put the names in a standard format: capitalizing the names. When referencing branches that are immediate siblings or parents of the current branch, you need only specify the last part of the branch name (e.g. South City). When referencing more distant branches, include the full path name (e.g. Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Capacity). When referencing a different variable at the same branch, you need not enter the branch name. Similarly, when referencing the same variable at a different branch you need not enter the variable name. When you specify a reference to another variable in an expression, WEAP will automatically append the scale and units of the referenced variable to the expression text using square brackets written immediately following the variable name. For example, if you enter a branch/variable reference to an Activity Level variable with a scale and units of Million Person as:
West City:Annual Activity Level
WEAP will change this to read
West City:Annual Activity Level[Million Person]
Thus the general syntax of branch/variable references is:
Notice that some variables will have no scaling factor and thus the square bracket will simply contain the unit name. You can subsequently edit the scale and units specified within the square brackets and WEAP will convert the values returned to the scale and units you specify. Note however, that you must specify a unit of the same class as the one specified for the referenced variable, For example, if the referenced variable is measured in a mass unit (e.g. "Tonne"), you may specify another mass unit (e.g. "kg") but using a volume unit such as liters, or any a unit of any other class will generate an error message. You can specify units either using their long names (e.g. Kilogram) or using their abbreviations (kg). Refer to the General: Units screen for a full list of available units. The allowable scaling factors values are: % (10E-2), Hundred (10E2), Thousand (10E3), Million (10E6), Billion (10E9) and Trillion (10E12). Note that you can reset an expression to use the default scaling factors (those used in the referenced variable) by simply deleting the contents of the square brackets.
Result Variables: In addition to including references to data variables in your expression, you can also include references to results from a previous timestep using the PrevTSValue function. These are the values that are evaluated during WEAP's calculation routines. When you reference them in Data View or in the Expression Builder, WEAP will show the most recently calculated results for these variables. Note however, that following a calculation the value may change (because of any edits you made in Data View). Referencing a result variable before it has been calculated will return a zero value when displayed in Data View, but the value will ultimately be resolved when WEAP is calculated. Just as with referencing data variables, WEAP will automatically add the variable's scale and unit in square brackets. Similarly, you can convert from the default unit to another by changing the unit name within the brackets.
Tip: Using the Expression Builder tool is the easiest way to create expressions that reference other branches and variables.
See also: Functions, Data View, Examples of Expressions, Expression Builder