Processing of Stochastic Programming blocks

A stochastic block definition is read in as a normal block definition (just that it creates a StochModel object rather than an AmplModel object).

The difference is that StochModel carries information about the stochastic parameters of the block (STAGES, NODES, PROBABILITY, PARENT).

The components of a StochModel are StochModelComp objects (rather than ModelComp objects). The difference here is that a StochModelComp carries information about which stages this component belongs to and if a component is "deterministic" (i.e. there is only one copy of it per stage, instead of one copy per node).

After the reading of the stochastic block is complete, the StochModel object is translated into a chain of AmplModel objects. This is done by StochModel::expandToFlatModel().

Expansion to flat model tree

Expansion works in two passes. In the first pass the chain of AmplModel objects is built (whose components are still StochModelComp objects) In the second pass the StochModelComp objects are translated to ModelComp objects (that is references to StochModelComp objects are resolved to references to ModelComp objects and special stochastic programming expressions such as Exp, node, stage are translated).

The two passes are necessary since model components can refer to other components up or down the tree. Hence the re-resolving of references from StochModelComp to ModelComp can only be done once the AmplModel tree is complete.

In detail the steps in the expansion procedure are as follows