The calculation engine for Slope follows a specific order for how it calculates all the variables defined for a given projection. This article explains how that order works and how this can affect certain types of formulas and references within the model.
The calculation process of Slope is divided up into 4 main parts:
- Initialization
- Static Processing
- Dynamic Projection Processing
- Post-Projection Processing
Initialization
During the initialization phase, the calculation engine loads the projection parameters, model, and inputs onto the VM to be used for calculating the model. The system does a number of internal setup steps to prepare for the run including loading all decrement and data tables, reading the model point files to be used, and constructing the formula execution structures for each portfolio, product, and formula.
The calculation engine will also determine which products can by processed by static processing and which will be run during the dynamic processing cycle. This process usually only takes a few seconds to run, but can take longer if input files are unusually large.
Static Processing
Static processing is where products get calculated without any dynamic interaction between assets, liabilities, or portfolio and company level calculations. During static processing, each model point is calculated from the projection start date all the way to the end of the projection one model point at a time. The results are written to the results database and then cleared from memory to make room for the next model point.
Static processing can occur in 2 different situations. First, any liability product that does not rely on portfolio or company level variables will be processed statically by default. This is determined by the calculation engine by examining all of the variables on the product. If no references to portfolio or company variable results exist, this product will be run during static processing every time the product is run.
There is also an option on the projection to Force Static Processing which will cause all products to be run statically. If this option is selected, care should be taken to ensure that portfolio and company level results are not needed to properly calculate the product because these results will not yet be available to the product during static processing. If a product is calculated statically and tries to read from portfolio or company results, the read will return a value of 0.
Static processing is much more memory and processing time efficient and should be used whenever possible to speed up the processing time.
Dynamic Projection Processing
The dynamic projection processing is where the majority of the model processing occurs. During this step, all of the variables are calculated for the Products and Portfolios included on the Projection other than static processed liability products, as well as all the Company variables. The order of processing is shown by the diagram below:
The calculations are processed in time order. First, all non-time indexed calculations are run. Next, the projection starts at time 0, then time 1, etc.
Within each time index, variables are calculated one level at a time. First, all the products are run, with the variables being run for each model point at that time index. Next, all portfolio variables are run at the same time index, and finally, the company variables at that time index.
This calculation order has implications for how certain formulas are constructed when data is passed between levels. Within a product variable, a formula should only reference data from the Portfolio or Company variables at a time index that is less than the current time since those variables are not guaranteed to be calculated until after the product has finished. The same is true of Portfolio variables that reference Company variable results.
However, it is safe to use the summarized results of Products within Portfolio and Company variables as these will have already been calculated.
Post-Projection Processing
The post projection process is a repeat of the projection process. During this phase, the same calculation process and order is repeated again, but this time only including variables that are marked as Post-Projection in the variable options.
Post projection variables are able to reference any other variable in the model, including the variables that are calculated during the projection process described above. This means that all variables have already been calculated, at all calculation levels, and for all time periods during the projection period. This allows for the calculation of some items that would not be possible during the regular projection process, such as calculating present values of projected cash flows.