There are six categories of formulas in this model:

1.computing the expected rate of return (AVG),
2.constraining the expected rate of return to exceed our target,
3.computing the expected rate of return under each scenario (R),
4.computing deviations from average return for each scenario (DVU and DVL),
5.constraining the portfolio to be fully invested, and
6.computing the three measures of risk (VAR, SEMIVAR, and DNRISK).

The following expression computes the expected rate of return for the entire portfolio:

! Compute expected value of ending position;

  AVG = @SUM( SCENE: PRB * R);

We do this by taking the sum of the expected returns for each scenario (R) weighted by the probabilities of the scenarios (PRB).

We constrain expected return to be greater than or equal to our target using the constraint:

! Target ending value;

  AVG >= TARGET;

The expected return under scenario S is computed using:

R( S) = @SUM( STOCKS( J): VE( S, J) * X( J));

This is just the sum of the return of each stock under the scenario weighted by the fraction of the portfolio in each stock.

The deviations from average return for each of the scenarios is computed with:

DVU( S) - DVL( S) = R(S) - AVG

If the expected return from the scenario is greater than the average, DVU will be positive. If the expected return is less than average, DVL will be positive. Given the fact that DVL and DVU impact the objective, there will never be an optimal solution where both DVL and DVU are greater than 0. If both are greater than 0, then a better solution can always be obtained by driving one of the two to zero. By setting things up this way, we have partitioned the deviations into two parts. DVU represents deviations above the average, which only the variance measure is concerned with. On the other hand, DVL represents deviations below average, which both the downside risk and semi-variance measures are computed from.

The following constraint forces us to be fully invested and should be familiar from the discussion of the Markowitz model:

! Budget;

  @SUM( STOCKS: X) = 1;

We compute our three measures of risk using:

! Our three measures of risk;

  [VARI] VAR = @SUM( SCENE: PRB * ( DVU + DVL)^2);

  [SEMI] SEMIVAR = @SUM( SCENE: PRB * (DVL) ^2);

  [DOWN] DNRISK = @SUM( SCENE: PRB * DVL);

Each of these are simply the sum of a measure of deviation across the scenarios weighted by the probabilities of the scenarios. The variance measure takes the square of both the above and below average deviations, the semi-variance measure squares just the below average deviation, and the downside risk measure uses the below average deviations without squaring.