given in the appendix. As explained above, all problem constraints must be given as a part of the forall(scen in Scenarios) { <Constraints> }; **statement.**

- **capital = wealth[1];** *// "capital" is a constant, "wealth" is a decision variable* is compiled into **capital = wealth[<1,ScenTree[1,scen]>];**
- **finalwealth = wealth[N+1];** *// "finalwealth" is a decision variable* is compiled into **finalwealth[scen] = wealth[<N+1,ScenTree[N+1,scen]>];**
- **wealth[p] = sum(i in Instr) investment[i,p];** *// "investment" is a decision variable* is compiled into **wealth[<p,ScenTree[p,scen]>] =**
sum(i in Instr) investment[i,<p,ScenTree[p,scen]>];
- **wealth[p+1] = sum (i in Instr)**
investment[i,p]*(1+ret[i,p]^market);
is compiled into wealth[<p+1,ScenTree[p+1,scen]>] = sum (i in Instr)
investment[i,<p,ScenTree[p,scen]>]*(1+ret[i,<p,ScenTree[p+1,scen]>]);

## 5.2 Compiling Chance Constraints

The chance constraints posted using a command of the form prob(<Constraint>) <ArithOp> <Expr>;
are compiled into a sum constraint of the form sum(scen in Scenarios)
Probability[scen]*(<Constraint[scen]>) <ArithOp> <Expr>;
where <Constraint[scen]> is a compiled Stochastic OPL constraint in scenario scen, **Probability[scen]**
the probability of scenario scen and Scenarios **the set of all scenarios.**
As an example of chance constraint compilation consider the **following inventory constraints:**
forall (p in Periods) Stock[p]+Order[p]-Demand[p] = Stock[p+1]; forall (p in Periods) Stock[p+1] >= 0; These are inventory balance equations and non-negative stock constraints, respectively. In the case of stochastic demand, it is generally very expensive to follow **a policy which guarantees no backlogging,** i.e., meeting all customers' demand. Instead, generally, a **target service level is introduced by the** management and the complete demand satisfaction policy is relaxed. Hence, the inventory problem now becomes: forall (p in Periods) Stock[p]+Order[p]-Demand[p] = Stock[p+1];
forall (p in Periods) prob(Stock[p+1] >= 0) >= ServLev; The inventory balance equation, which is a hard constraint, can be compiled into its certainty equivalent form as explained in Sec.5.1. The compilation of chance **constraints are done in a similar fashion,** with the only exception of the introduction of weights, which are actually the probabilities of relevant scenarios. The service-level expression is compiled into the following OPL constraint:
10