! Conditional Value at Risk model(PORTCVAR)
  We specify a probability, theta, e.g., 0.1, and
  then we want the model to choose a) a target return,
  and b) a portfolio composition, so as to 
   Max theta*target - (expected shortfall below target).
  It is easy to see that if all scenarios are equally likely,
  then it is worthwhile increasing the target as long as
  less than theta of the scenarios fall short of the target.
  So at an optimum, the probability of missing the target
  is about theta.;
! Key words: Conditional Value at Risk, CVAR, Value at Risk,
     Downside risk, Scenario method, Portfolio;
SETS: 
 SCENE: PROB, R, DVU, DVL;
 ASSET: X;
 SXA( SCENE, ASSET): VE ;
ENDSETS
DATA: ! Conditional Value at Risk probability; THETA = 0.1; SCENE = 1..12; PROB = .0833333; ! Probability of each scenario; ASSET= ATT GMC USX ; VE = 1.300 1.225 1.149 1.103 1.290 1.260 1.216 1.216 1.419 0.954 0.728 0.922 0.929 1.144 1.169 1.056 1.107 0.965 1.038 1.321 1.133 1.089 1.305 1.732 1.09 1.195 1.021 1.083 1.390 1.131 1.035 0.928 1.006 1.176 1.715 1.908; ENDDATA NS = @SIZE( SCENE); @FOR( SCENE( S): ! Compute value of portfolio under each scenario; R( S) = @SUM( ASSET( J): VE( S, J) * X( J)); @FREE( R( S)); ! Measure deviations from Target; DVU( S) - DVL( S) = R(S) - TARGET; ); ! Budget for assets; [BUD] @SUM( ASSET( J): X(J))= 1; ! The Conditional Value at Risk metric; [CVAR] CVAR_RISK = @SUM( SCENE(S): PROB(S)*DVL(S)); ! We would like to have a both a high target, which we achieve with probability approximately 1-theta, and a low expected shortfall when we miss the target, so...; [OBJ] MIN = CVAR_RISK - THETA*TARGET;