# DPL 9 Help

Specifying the Use of a Utility Function (DPL Code)

# Specifying the Use of a Utility Function (DPL Code)

DPL allows you to represent a decision maker's attitude toward risk by one or more utility functions. DPL selects the best alternative for each decision that follows a utility function in the event sequence (or decision tree) based on expected utilities instead of expected values.

DPL provides two ways to define a utility function: One produces an exponential utility function, and the other lets you define any function and its inverse. You can specify multiple utility functions in the same sequence section. Each specification applies only to the subtree below it, and each specification overrides any specification higher in the tree.

The Built-in Utility Function

The expression for DPL's built-in exponential utility function is -exp(-V/T), where V is a value and T is the risk tolerance coefficient. To use it, you only need to specify the decision maker's risk tolerance coefficient.

`use tolerance 100`

The following program uses the built-in exponential utility function; the risk tolerance coefficient is defined as a value called RiskTolerance.

```value RiskTolerance = 100;
chance Demand.{High,Average,Low} = {0.3,0.3};
value Revenues given Demand = 200, 150, 50;
chance MarketForecast.{High,Average,Low} given Demand =
{0.7,0.2}, {0.15,0.7}, {0.1,0.2};
sequence:
use tolerance RiskTolerance and
decide
to MainDecision: decide
to gamble on Demand and receive Revenues - 120
to quit
to pay 10 and gamble on MarketForecast then
perform MainDecision```

The expression for the risk tolerance coefficient cannot contain values that depend on events. Also, this expression cannot contain the state function. Because the specification occurred at the beginning of the sequence section, it applies to the entire tree.

User-Defined Utility Functions

You can define your own utility function for converting values into utiles. If you do so, you must also define the inverse utility function for converting utiles to values.

The expressions for the utility function and inverse utility function use a dollar sign (\$) to represent the arguments of these functions. For example, the following defines a utility function that is equivalent to the built-in exponential utility function.

`use utility -exp(-\$/RiskTolerance),-RiskTolerance*log(-\$)`

The expressions for the utility function and inverse utility function cannot contain values that depend on events. Also, these expressions cannot contain the state function.

The following program is equivalent to the previous one, except it defines a utility function and its inverse with the keyword utility.

```value RiskTolerance = 100;
chance Demand.{High,Average,Low} = {0.3,0.3};
value Revenues given Demand = 200, 150, 50;
chance MarketForecast.{High,Average,Low} given Demand =
{0.7,0.2}, {0.15,0.7}, {0.1,0.2};
sequence:
use utility -exp(-\$/RiskTolerance), -RiskTolerance *
log(-\$) and
decide
to MainDecision: decide
to gamble on Demand and receive Revenues - 120
to quit
to pay 10 and gamble on MarketForecast then
perform MainDecision```

The utility function defined in this program is the same as the default exponential utility function provided by DPL.

You are responsible for ensuring that the two functions are inverses of each other. DPL will perform an analysis with functions that are not inverses, but the results may be meaningless.

The \$ argument can appear more than once in a utility function or inverse utility function. For example the following clause could appear in a DPL program.

`use utility \$ / (1 + \$), \$ / (1 - \$)`

In this example, you must make sure that the utility function is never evaluated with an argument of -1 and that the inverse utility function is never evaluated with an argument of 1.

Versions: DPL Professional, DPL Enterprise, DPL Portfolio