Expressions of decision variables

Shows how to declare and use decision variable expressions in the OPL language.

The keyword dexpr allows you to create reusable decision expressions. Indeed, if an expression has a particular meaning in terms of the original problem, writing it as a decision expression (dexpr) makes the model more readable.

For example, the scalableWarehouse.mod example expresses the total fixed costs as a decision expression:

dexpr int TotalFixedCost = sum( w in Warehouses ) Fixed * Open[w];
dexpr float TotalSupplyCost = sum( w in Warehouses, s in Stores )  SupplyCost[s][w] * Supply[s][w];

This way, the two total cost expressions defined are shown in the OPL IDE along with their values.

You can also use arrays of decision expressions. For example:


dexpr int slack[i in r] = x[i] - y[i];

This array is handled efficiently as only the “definition” is kept. Not all the expressions for each value of the indices are created. As a consequence, you cannot change the definition of the dexpr for a particular element of the array.

Using decision expressions is particularly useful and recommended if you plan to write objectives to be used with ODM Enterprise. Please refer to the ODM Enterprise documentation.