Taking too long? Close loading screen.

Prophet – Extended Formulas

Extended formulas enable more complex calculations to be carried out than standard Prophet formulas. They are also able to retain the values that they have calculated from one model point to the next and from one loop to the next in a dynamic or stochastic run.

Examples of situations where extended formulas can be useful include:

  • The calculation of commutation factors at the start of each product
  • The processing of policies that have a number of increments or benefits
  • Separate calculations for each tranche of new PUPs, rather than just carrying out the calculations on the aggregate average of all PUPs
  • Rebasing of sterling reserve calculations
  • Scheme level calculations for group pension schemes
  • Dynamic Financial Analysis (DFA) for general insurance companies
  • Any other complex calculations that require looping or vectors

Issues

Although extended formulas represent a significant extension to the standard Prophet programming language there are a number of issues to be aware of:

  • Diagram view does not display the dependencies between the variables used in an extended formula, although it does show the normal variables which an extended formula uses and the normal variables that depend on an extended formula
  • The values calculated by the variables in an extended formula cannot be viewed, only the values calculated in normal variables. It is, however, easy to set up normal variables to read and display the values calculated by variables in extended formulas.
  • The order of the calculations within an extended formula is not determined by Prophet automatically. Instead the calculations are always carried out in the order specified within the extended formula.
  • Extended formulas are generally more difficult to set up, use and debug than normal formulas.

You should therefore use normal formulas except in those situations where extended formulas are necessary in order to carry out the required calculations or to increase the speed of the calculations.

Implementation

Extended formula features can be used directly in any Prophet library formula by setting up an extended formula definition. You do this by selecting the Extended Formula definition from the Definition Type dialog box when specifying a variable.

The Structure of Extended Formulas

Standard Extended Formula

Variable declarations
    ...
Statements
    ... 

Parameterised Extended Formula

A parameterised extended formula allows you to create a general purpose formula that can be called by any other formula. The arguments passed to the general formula are declared in the parameterised extended formula as parameters.

Parameter declarations
    ...
Variable declarations
    ...
Statements
    ...

Declaring Parameters in a Parameterised Extended Formula

PARAMETER <name> as <type>

where:

    • PARAMETER: Keyword declaring the named variable to be used as an argument
    • <name>: The name of the variable which must conform to the standard Prophet variable naming convention
    • as <type>: <type> declares the variable type. It can be either TEXT or NUMBER

Instantiating Parameterised Formulas

A parameterised formula can only be instantiated from within another extended formula using the following syntax:

#<extended_formula> (parameter_1 [, parameter_2 ...])

where:

    • #<extended_formula>: The name of the variable containing the parameterised formula preceded by a #.
    • parameter_1 [,parameter_2 ...]): The text or number parameters, each separated by a comma, expected by the parameterised formula.

Calling Prophet Functions in an Extended Formulas

<function name> ( [argument, argument...] )

Declaring Variables and Arrays in Extended Formulas

Variables and arrays in extended formulas are declared using the following syntax:

<access qualifier> [Persistent] [Dynamic_Persistent].<name>[dimensions] as <type> [CONSTRAINT {constraint1, constraint2, ..} ]

Multiple variables and arrays of the same type are declared as follows:

<access qualifier> [Persistent] [Dynamic_Persistent]<name1>[dimensions1], <name2>[dimensions2],... as <type>

where:

  • <access qualifier>: Refers to whether the variable can be accessed from other variables. Valid entries are:
      • PUBLIC: The variable or array can be accessed by any other formula in the product.
      • PRIVATE: The variable or array can only be accessed locally within the formula in which it is declared.
  • [Persistent]: Optional variable parameter. The variable or array can only be accessed locally within the formula in which it is declared. Can improve performance at the expense of memory in t-dependent extended formulas. When the extended formula is called the variable is calculated once for a particular time period and then retained in memory.
  • [Dynamic_Persistent]: Optional variable parameter. Ensures that the values will be retained across dynamic loops. Only the appropriate time periods are retained by the system and not each time period as would be the case in Persistent.
  • <name>: The name of the variable or array. The name should conform to the standard Prophet variable naming conventions.
  • [dimensions]: Used for an array variable only. It takes the form: (dimension1, dimension2, ,..) where dimension1, dimension2 are integers or enumerations both of which define the size of the dimension. An array variable cannot have more than 4 dimensions.
  • <type>: This can be Number, Text or an Enumeration.
  • [CONSTRAINT {constraint1, constraint2,. . } ]: Using this qualifier for a variable within an extended formula indicates that the variable may only take specific values. The qualifier can be applied to NUMBER as well as TEXT variables. If the first argument to the READ_RESULTS (or RES) function is unknown at compile time then a TEXT variable with the CONSTRAINT qualifier can be used.

PUBLIC and PRIVATE Variables in Extended Formulas

    • The results of PUBLIC variables calculated in an extended formula are available publicly and can be referenced by other extended formula variables and ordinary Prophet variables.
    • The results of PRIVATE variables calculated in an extended formula are available privately within the current extended formula. They cannot be referenced by other variables.

Declaring Persistent Variables in t-dependent Extended Formulas

For a t-dependent extended formula you can optionally declare persistent variables as PUBLIC PERSISTENT or PRIVATE PERSISTENT

Declaring Dynamic Persistent Variables in t-dependent Extended Formulas

For a t-dependent extended formula you can optionally declare dynamic persistent variables as Public Dynamic_Persistent or Private Dynamic_Persistent

Array Variables in Extended Formulas

Array variables in extended formulas can either be specified with fixed dimensions or they can be dynamically sized at runtime. They can have up to 4 dimensions and can be either global or local in scope. An array can only hold number elements.

<ArrayName>(ItemIndex1, ItemIndex2,..)

    • Dynamically Sized

PUBLIC Q(0,0) as Number

Using Enumerations

An enumeration is a data type that consists of a set of values that are named integral constants. They also referred to as an enumerated type since you must list or enumerate each of the values in creating a name for each of them. Enumerations are useful for variables that have a range of possible values.

    • Enumerations can be associated with extended formula arrays. For example,to associate BOND_TYPE with MY_ARRAY you specify the BOND_TYPE instead of the array size.

PRIVATE MY_ARRAY(BOND_TYPE)

    • You can also have a mixture of enum and constants in array declarations:

PRIVATE MY_ARRAY(0, BOND_TYPE)

    • Enumeration functions
      Enumerations can be converted to/from integer and text using the following functions:

INT_TO_ENUM
ENUM_TO_INT
TEXT_TO_ENUM
ENUM_TO_TEXT

Variable Assignments in Extended Formulas

<variable>[(indices)] := <expression>

    • <variable>: The name of the variable as declared previously in the formula
    • [(indices)]: Used for array variables. It refers to the element in the array to which the value is to be assigned.
    • <expression>: The text or number value assigned to the variable.

Extended Formula Statements

Conditional Statements

    • If / Then / Elseif / Else / EndIf
    • Switch / Case / Case Else

Looping Statements

    • For / To / Step / Next
    • Do While / Loop
    • Do Loop / While
Syntax
      • For Each / Next
      • Do
        <statement list>
        Loop While <conditional expression>

Terminating Execution Statements

    • Quit
    • QuitLoop