srtree.gms : Simple Scenario Tree Construction Example

Description

This model takes some scenario data (that comes from a true tree),
builds a fan and lets ScenRed2 construct a tree. One without loss of
information, the other with some reduction requirement. The data is
taken from the GAMS/ScenRed2 manual, just the node numbering is
different.


Reference

  • H. Heitsch, W. Roemisch, and C. Strugarek, Stability of Multistage Stochastic Programs. SIAM Journal on Optimization 17 (2006), 511-525.

Small Model of Type : GAMS


Category : GAMS Model library


Main file : srtree.gms

$Title  Simple Scenario Tree Construction Example (SRTREE,SEQ=390)
$Ontext

This model takes some scenario data (that comes from a true tree),
builds a fan and lets ScenRed2 construct a tree. One without loss of
information, the other with some reduction requirement. The data is
taken from the GAMS/ScenRed2 manual, just the node numbering is
different.


H. Heitsch, W. Roemisch, and C. Strugarek
Stability of Multistage Stochastic Programs
SIAM Journal on Optimization 17 (2006), 511-525

$Offtext

Set s scenarios   / s1*s4 /
    t stage       / t1*t5 /
    r random data / r1*r4 /;

Parameter
    p(s) probability / (s1,s2) 0.25, s3 0.3, s4 0.2 /

Table sdata(s,t,r)
        r1  r2    r3    r4
s1.t1 42.5  9.1  7.5 120.0
s1.t2 39.8 11.2  8.4  90.0
s1.t3 37.6 14.0  6.3 110.0
s1.t4 38.9 12.4  8.1 130.0
s1.t5 40.3 14.9  7.2 120.0

s2.t1 42.5  9.1  7.5 120.0
s2.t2 39.8 11.2  8.4  90.0
s2.t3 37.6 14.0  6.3 110.0
s2.t4 38.9 12.4  8.1 130.0
s2.t5 38.4 15.2  8.9 100.0

s3.t1 42.5  9.1  7.5 120.0
s3.t2 39.8 11.2  8.4  90.0
s3.t3 37.6 14.0  6.3 110.0
s3.t4 35.7 13.8  7.5 120.0
s3.t5 37.6 14.9  9.3  80.0

s4.t1 42.5  9.1  7.5 120.0
s4.t2 39.8 11.2  8.4  90.0
s4.t3 37.6 14.0  6.3 110.0
s4.t4 35.7 13.8  7.5 120.0
s4.t5 36.3 12.8 10.3  90.0
;

* Construct a fan
$eval nnodes card(s)*(card(t)-1)
set n        nodes / n0*n%nnodes% /
    nn(n)    next nodes
    anc(n,n) ancestor relation;
parameter
    prob(n)  node probability
    rv(r,n)  random values;

nn('n0') = yes;
loop(s,
  loop(t$(ord(t)<card(t)),
     loop(nn(n),
        if (sameas('t1',t),
           anc(n+1,'n0') = yes;
        else
           anc(n+1,n) = yes;
        );
        prob(n+1)=p(s);
        rv(r,n+1) = sdata(s,t+1,r);
     );
     nn(n) = nn(n-1);
  )
);
prob('n0') = 1; rv(r,'n0') = sdata('s1','t1',r);

* Initialize ScenRed2
$set sr2prefix test
$libinclude scenred2

set anc_noloss(n,n), anc_red(n,n);
parameter
    prob_noloss(n),  prob_red(n);

* Scenred2 call
ScenredParms('red_percentage') = 0;
$libinclude runscenred2 %sr2prefix% tree_con n anc prob anc_noloss prob_noloss rv
abort$(card(anc_noloss)<>8) 'scenred tree construction gave incorrect noloss tree', anc_noloss;
display anc_noloss;

* Scenred2 call
ScenredParms('red_num_leaves') = 3;
$libinclude runscenred2 %sr2prefix% tree_con n anc prob anc_red prob_red rv
display anc_red;