Creating Expanded Model

The SML file describes the problem in "flat" form: that is only one instance of each type of block is present (and therefore only one instance of an AmplModel object).

The indexing expression that carries information about the number of instances of a block is just passed through but not analysed.

In the ExpandedModel tree however there is one instance of each block for each member of the indexing set. Since the SML interpreter does not attempt to understand AMPL enough to generate the indexing set member list itself, the ampl-interpreter is used for this purpose.

Naming of Nodes

While nodes in the "flat" model are named by concatenating the block names from root to the current model, in the expanded model nodes are named by also concatenating the instance of each block (this is the value of the dummy variable in the indexing expression in this branch). That is a model tree

block MCNF{i in ARCS}:

 block RouteComm{j in COMM}:

 end block

end block

results in flat tree nodes (and the AMPL submodel *.mod files) being called root, root_MCNF and root_MCNF_RouteComm and expanded tree nodes being called root_MCNF_A1, root_MCNF_A2, ... and root_MCNF_RouteComm_A1_C1, root_MCNF_RouteComm_A1_C2, etc.

Generation of expanded model instance lists/cardinalities

Lines

print card(<indexing-set-name>) > "<name-of-node>.crd"
display <indexing-set-name> > "<name-of-node>.set" 

are included in the script file for every block definition within a given (sub)model to print out the cardinality and the members for each indexing set. <name-of-node> is here the name of the node in the expanded tree (including instance names). So the cardinality (and list of members) of COMM in the example above could be different depending on the value of the first level dummy variable i. These different values for the second level indexing set COMM would be reflected in the files root_MCNF_RouteComm_A1.crd/set, root_MCNF_RouteComm_A2.crd/set, giving the cardinality and instance names of the root_MCNF_RouteComm submodel in the root_MCNF_A1/A2 branches of the expanded model

Generation of the expanded model tree

The expanded model is represented as a tree of ExpandedTree objects. The tree is generated by calling the constructor ExpandedModel::ExpandedModel(AmplModel* ) which in turn calls AmplModel::createExpandedModel(string, string).