Understanding prefix notation

Expressions in IBM® Analytical Decision Management are defined in Prefix notation (also known as Polish notation). Infix and Prefix notations are two different but equivalent ways of writing expressions. The Infix column displays formulas people are used to, and the Prefix column displays the equivalent notation that would be used in IBM Analytical Decision Management expressions. All parentheses are implied in the Prefix column; they've been included to make the table easier to read by showing the order of evaluation.

Table 1. Infix vs. Prefix expression notation
Infix notation Prefix (Polish) notation
( (A * B) + (C / D) ) (+ (* A B) (/ C D) )
((A * (B + C) ) / D) (/ (* A (+ B C) ) D)
(A * (B + (C / D) ) ) (* A (+ B (/ C D) ) )

An example would be coded as follows:

"-"
"*"
ProbabilityToRespond
Revenue
Cost

The actual expression starts with the ObjectiveFunction element that specifies the storage data type of the result, its name, and the initial Functor--which is our Prefix notation for subtraction.

<ObjectiveFunction Domain="double" Functor="-" Name="Predicted Profit">

Unless otherwise specified, the subtraction functor will be applied to all expressions with this objective function.

The next operation specifies multiplication as the functor, overriding the default. Within this expression, two variable references are defined, inserting the values of the Prob.to Respond and Revenue variables and multiplying them together.

<Expression xmlns="http://com.spss.pasw.dms/rules" Domain="double" Functor="*">
        <Expression Domain="double" Functor="variableReference">
            <Expression>
                <Value>value</Value>
            </Expression>
            <Expression>
                <Value>Variable</Value>
            </Expression>
            <Expression>
                <Value>Prob.to Respond</Value>
            </Expression>
            <Expression>
                <Value>Value</Value>
            </Expression>
        </Expression>
        <Expression Domain="double" Functor="variableReference">
            <Expression>
                <Value>value</Value>
            </Expression>
            <Expression>
                <Value>Variable</Value>
            </Expression>
            <Expression>
                <Value>Revenue</Value>
            </Expression>
            <Expression>
                <Value>Value</Value>
            </Expression>
        </Expression>
</Expression>

In other words, the example expression is referencing a simple value of a Variable named ProbabilityToRespond in order to use its output field named Value in this spot of the equation.

A third variable reference inserts the value of the Cost variable. Because it is a child of the top-level ObjectiveFunction element (and not the multiplication expression) its value is subtracted.

<Expression xmlns="http://com.spss.pasw.dms/rules" Domain="double" Functor="variableReference">
        <Expression>
            <Value>value</Value>
        </Expression>
        <Expression>
            <Value>Variable</Value>
        </Expression>
        <Expression>
            <Value>Cost</Value>
        </Expression>
        <Expression>
            <Value>Value</Value>
        </Expression>
</Expression>