How to Configure a new Forecast Engine

The setup of the Forecast engine is almost identical to the Input-Based Formulas.

There are few steps required to configure the Forecast Engine:

  1. Company Parameter Configuration – here you define the name of the forecast and its calculation configuration.

  2. Inputs – create an InputGeneration table, fill it with data, and connect it to the Forecast Company Parameter.

  3. Groovy logic – write the calculation method code and any additional support methods, such as input generation code.

The setup is done only in the user interface and Groovy, there is no Formula Designer support for Forecast Engines.

Company Parameter Configuration

The configuration starts with Company Parameter named AGR_ForecastTypes. This table contains several columns that need to be filled in:

  • Forecast Type Name – defines the name that will be used for this Forecast Engine. It will be displayed, for example, on the Agreement Header input where the user selects the Forecast Engine.

  • Calculation Engine Path – defines the path to the library containing the calculation method of the Forecast Engine. The Accelerator comes with a library called AGR_ForecastEnginesLib that can be used for this purpose. The path should point to the main calculation method that will return the valid result structure (more details in the Groovy Logic section below).
    For example: libs.AGR_ForecastEnginesLib.MyTestingForecast.calculate (notice there are no parentheses at the end of the path).

  • Engine Calculation Parameters – defines calculation parameters that the calculation method will use. All parameters and their usage are described in the Calculation Parameters article.

  • Input Generation Table Name – defines the name of the InputManager inputs definition table.

Inputs

All inputs used by the Forecast Engine should be defined as Configurator Entries (The “Input Type” column in the InputGeneration table should be set as “Configurator Entry”). More information on Inputs can be found in the How to Modify, Add and Remove Inputs article.

Groovy Logic

For Groovy logic the only necessity is the definition of calculation method that matches the path defined in the AGR_ForecastTypes Company Parameter.

The calculation method must take the parameters in the order specified by the Engine Calculation Parameters column.

There are additional parameters that can be returned by the Forecast Engine under the additionalInfo key. These are productCost and productVolume. If they will be present in the returned data set, then the respective “Change” output will be calculated. For example, if productVolume is present, then the Volume Change output will be calculated.

Example calculation method return structure:

[result : result, additionalInfo: [productCost : productCost, productVolume: productVolume]]

 

Exemple configuration

  • AGR_ForecastTypes

    • Forecast Type Name - AGR_DemoForecast

    • Calculation Engine Path - libs.AGR_ForecastEnginesLib.AGR_DemoForecast.calculate

    • Engine Calculation Parameters - FORECAST_INPUTS,SKU

    • Input Generation Table Name - AGR_DemoForecast_InputGeneration

  • AGR_DemoForecast_InputGeneration

    • Lookup Key - AGR_DemoForecast

    • Input Name - demo_AdderInput

    • Execution Path - libs.AGR_ForecastInputsLib.AGR_DemoForecast.getAdderInput

    • Order - 0

    • Input Type - Configurator Entry

    • Is Active - true

The calculation method in the pseudocode could look something like this:

Map calculate(Map forecastInputs, String sku) { BigDecimal adderValue = getAdderValue(forecastInputs) BigDecimal productPrice = getProductPrice(sku) return [result : productPrice + adderValue, additionalInfo: [productPrice: productPrice, adderValue : adderValue]] }

The input generation method could look something like this:

ConfiguratorEntry getAdderInput(Map inputs) { ContextParameter adderParameter = api.inputBuilderFactory() .createUserEntry("demo_AdderInput") //Remember to use the same name as in Input Generation Table Config .setLabel("Adder Input") .setRequired(true) .buildContextParameter() return libs.AGR_InputLib.CommonInputGenerationUtils.buildConfiguratorEntry(adderParameter) }

The following example should generate a Forecast that will take some Product Price and add some static Adder value to it.