The Structured Modelling Language (SML)

Blocks (Submodels)

The main extension of SML over AMPL is the introduction of the keyword 'block':

 set COMMODITIES;
 block Net{k in COMMODITIES}: 
    var Flow{ARCS} >=0;
    ...
 end block;

A block groups a set of model declarations (set, var, param, subject to, minimize/maximize) together. These can be repeated over an indexing set (as any AMPL entity can). A block is a natural representation of a subproblem in AMPL.

Blocks can be nested. Several blocks can be defined on the same level, thus creating a tree of blocks.

All entities within the block are local variables to this block. They are all repeated over the indexing set indicated in the block command. The above piece of code actually defines a variable Net_Flow:

 var Net_Flow{k in COMMODITIES, ARCS} >=0;

Blocks can also be defined with the alternative syntax

 set COMMODITIES;
 block Net{k in COMMODITIES}:{
    var Flow{ARCS} >=0;
    ...
 }

Scoping

From within the block all model components that were defined in the block and its ancestor blocks can be used in definitions. Model components defined in a sublock can be used by need to be accessed "through" the name of the subblock. That is from outside the block variable Flow can be referred to as

 Net[k].Flow[j];

Model components defined in sibling blocks (i.e. blocks defined on the same level) or their child blocks cannot be used.

Stochastic Programming

A stochastic programming block can be defined as

 block alm stochastic using (NODES, PARENTS, PROBS, STAGES): {
   ...
 }

Here 'alm' is the name of the block, 'STAGES' and 'NODES' are sets of stages and nodes respectively, 'PARENTS{NODES}, PROBS{NODES}' are parameter arrays indexed over the set NODES that give the parent node and the conditional probability of a given node respectively. The parent of the root node must be set to the string "null". The PARENTS array must imply the same number of stages as are given in the STAGES set.

Note:
PARENT is a (symbolic) parameter indexed over the set NODES that gives for every node in NODES the name of its parent node. For the root node it is required that PARENT[root] = "null"

There are a variety of specifiers that can be applied to model components declared within a stochastic block:

Expectation Constraints

Add something on how to write Expectation type constraints

Known problems

Read the Known Problems page to see the current limitations in SML.