Custom Macros

<< Click to Display Table of Contents >>

Navigation:  Defining Entity Types >

Custom Macros

Previous pageReturn to chapter overviewNext page

 

Custom Macros are reusable structures that can be called as functions in an equation. Macros work like built-in functions, but they can be modified and imported into other models. See the Patterns folder for an example.

 

To create a Custom Macro, right-click on Macro in the Model Overview and select "New Macro" or, if you have a Macro from a different model you wish to import, "Import Macro". This will create a new screen where you can design the Macro's structure.

 

macro

 

Write equations as you would in any entitytype definition. For inputs like X and horizon above, the value defined within the macro will be overriden, so you can use a constant as a placeholder.

 

Once you're finished building the structure,

Define the Value Var - the variable which will be returned as the result from the Macro being called.

Define the Inputs list - the variables which will be arguments to the Macro function call. Note that order matters!

 

Then, in entity definitions elsewhere in the model, call the Macro via it's name as you would any other variable within the relevant equations. It will appear in autocomplete suggestions.

 

Units

 

Ventity will check to ensure that:

Units are consistent within the Macro definition. Where time units occur, you can use "time" rather than the model time unit (e.g., "day") to make the definition more reusable.

Units of the Macro Inputs and Value Var are consistent where it is used.

 

Hierarchy and Nesting Constraints

 

1. You can't call a Custom Macro within another Custom Macro call. For example, this equation will not work:

 

Expected Price = MySmooth( MySmooth(Price, Horizon), Horizon )

 

2. You can't use one Custom Macro in the definition of another Custom Macro. So, for example, you may not use MySmooth() in the definition of MyForecast().