Writing the scriptfile and submodel AMPL files

Writing the submodel AMPL files

This is done in backend.cpp by process_model() and write_ampl_for_submodel() called from it.

For every AmplModel object a separate *.mod file is generated. The name of the *.mod file is obtained by concatenating all the block names on the path from the root model down to this model. Every *.mod file contains the subset of all given ModelComp declarations needed for this block. They are obtained in the following manner:

The writing out of one component of the *.mod file is done by modified_write() Translating of local names into global names is done by a static variable SyntaxNode::use_global_names. SyntaxNode has a SyntaxNode::print() method that prints out the AMPL expression represented by the tree. If SyntaxNode::use_global_names is set then all names of IDREF nodes are replaced by their global name with the proper indexing expression.

A stack of applicable indexing expressions is kept in the global variable l_addIndex/n_addIndex in backend.cpp

The resulting *.mod file (and therefore the corresponding *.nl file contains exactly the constraints defined in the block, but may have more variables. Therefore in order to get the sparse matrix information for an OOPS Matrix tree node, some matching of variable names has to be done.

Writing the scriptfile "script.scr"

Is done in process_model() in backend.cpp. It uses much the same logic as the printing out of the *.mod files.