Expressions

See also: Analysis View , Examples of Expressions , Expression Builder , Time-Series Wizard , Expression Elaboration , Specifying Excel File and Range Parameters, Referencing Results in Expressions

LEAP borrows an approach made popular in spreadsheets: the ability for users to enter data and construct models using mathematical expressions. Expressions are mathematical formulae used to specify the values of variables in LEAP's Analysis View. In Current Accounts an expression defines the historical values for a given variable at a branch, while in scenarios, the expression defines how that variable changes over time from the First Scenario Year to the End Year of the study period.

Expressions can range from simple numeric values to complex mathematical formulae. Each formula can optionally use LEAP's many built-in functions as well as referencing the values of other data and results variables. Expressions can also dynamically reference the values stored in an external Excel spreadsheet.

LEAP provides a number of ways of editing expressions. The most common are:

Understanding Expression Inheritance

Nearly all data in LEAP are specified as expressions for a given variable at a given branch in the LEAP tree.  These expressions are entered in LEAP's Analysis View and different expressions can be entered for different scenarios (or for different regions in a multi-region area).  To minimize data entry requirements and to make data management as easy as possible, scenarios are organized in a hierarchy so that you need only enter data in one scenario if it differs from the data entered in its parent (ancestor) scenario. Before describing the scenario manager, it is important to first understand the way that expression inheritance works in LEAP since this is fundamental to understanding how scenarios help you manage data. See Understanding Expression Inheritance for more information.

To reset an expression back to its inherited default, highlight the expression and press Delete, or right-click and select the Reset to Inherited () option.  .

Creating Models by Referencing Other Variables in Expressions

In addition to using expressions to directly specify data, you can also create expressions that refer to the values of other variables in LEAP.  In this way you can create your own models that include both exogenous (externally specified) data and endogenous (internally calculated) variables.

You can reference both data variables and results variables.  Data variables are those that are specified directly in LEAP's Analysis View through LEAP's expressions. Results variables are the additional values calculated internally by LEAP.  Results variables include values such as total final energy demand, total emissions or total costs, as well as many other types of results.

Because they are calculated internally, in general, you can only reference results that were calculated in a previous year. This is done by using the PrevYearValue function to reference a past value of a result variable.  An exception is when specifying calculated Indicator variables.  Because these are calculated after LEAP's main calculation routines they may include references to the present-year value of results variables.

You can create references to data variables by dragging and dropping items from the Analysis View tree into the Expression Builder, by using LEAP's built-in code completion features, or by using the Branch/Variable Wizard (Ctrl+B).

For more information on how to create references to other variables, see these two pages:

Expression Elaboration

Expression Elaboration is a feature that elaborates the various branches and variables upon which the current expression depends.  Expression elaboration is implemented as a tab on a panel under the main data entry table in Analysis View to elaborate complex expressions.   Expression Elaboration is useful for helping you to understand and explain your analyses without continually having to navigate from branch to branch in the tree.  You can disable Expression Elaboration by right-clicking within the Analysis View data entry table and choosing Expression Elaboration.

Expression Elaboration shows the branches and variables upon which the current expression depends,  and also lists the branches, variables and scenarios that depend on the current branch.  Double-click one of the listed items to jump directly to that branch and variable.