Classes | Enumerations | Functions

ModelComp.h File Reference

#include "CompDescr.h"
#include <list>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

class  ModelComp
 Object to represent a component of an AMPL/SML model/block. More...

Enumerations

enum  { NOARG = 0, WITHARG = 1, ONLYARG = 2 }
enum  compType {
  TVAR, TCON, TPARAM, TSET,
  TMIN, TMAX, TMODEL, TNOTYPE
}
 

Possible types of a model component.

More...

Functions

std::string getGlobalName (const ModelComp *node, const SyntaxNode *opn, const AmplModel *current_model, int witharg)
 Find the global name of the model component pointed to by 'node':

  • Generate the global name of a model component by pre-pending the names of models on the model-tree up to the model of this component to the name 'Flow' becomes 'MCNF_Net_Flow'.

std::string getGlobalNameNew (const ModelComp *node, const SyntaxNode *opn, const AmplModel *current_model, int witharg)
 New version of getGlobalName that does *not* use the addIndex stack but creates the modified argument list by looking at the indexing expressions of the submodel tree leading to this ModelComp.

Enumeration Type Documentation

anonymous enum
Enumerator:
NOARG 
WITHARG 
ONLYARG 
enum compType

Possible types of a model component.

Enumerator:
TVAR 
TCON 
TPARAM 
TSET 
TMIN 
TMAX 
TMODEL 
TNOTYPE 

Function Documentation

std::string getGlobalName ( const ModelComp node,
const SyntaxNode opn,
const AmplModel current_model,
int  witharg 
)

Find the global name of the model component pointed to by 'node':

  • Generate the global name of a model component by pre-pending the names of models on the model-tree up to the model of this component to the name 'Flow' becomes 'MCNF_Net_Flow'.

  • If 'witharg' is set, then the argument list is also generated: The argument list is composed of + dummy variables of indexing expressions of block up to model_of_comp + original arguments of the component (as given in the SML file) The appropriate argument list depends on both the model of the component and in which model this instance of referal of the ModelComp is (the current_model) Basically we need to identify the common ancestor model of the current_model and the model_of_comp. The arguments originating from block indexing expressions between here and the model_of_comp are already included in the argument list of the ModelComp. Anything below needs to be prepended to the argument list
Parameters:
[in] node The model component in question.
[in] opn The node (IDREF) of the model component (needed for the (local) argument list).
[in] current_model The block for which this is written: indexing is given in the original SML model wrt a given node in the model tree. FIXME: what happens if the component referenced in the definition is not in the same model_tree node as the component to be defined? In the original ampl file this is correct, since the indexing will be given relative to the current_model. However the local indexing is lost(?) in the node representation => I don't think so, it is still encoded in the rest of the SyntaxNode structure
[in] witharg WITHARG: if the argument list should be processed, NOARG: only the global name, ONLYARG: only the argument list.
Precondition:
l_addIndex needs to be set. It is assumed that this is a stack of indexing expressions from the root at least to the common ancestor node (likely set up to the current_model).

References buildModelPath(), SyntaxNode::getArgumentList(), ModelComp::id, l_addIndex, ModelComp::model, AmplModel::name, SyntaxNode::nchild(), NOARG, AmplModel::parent, SyntaxNode::printDummyVar(), and WITHARG.

Referenced by AmplModel::createExpandedModel(), modified_write(), and process_model().

std::string getGlobalNameNew ( const ModelComp node,
const SyntaxNode opn,
const AmplModel current_model,
int  witharg 
)

New version of getGlobalName that does *not* use the addIndex stack but creates the modified argument list by looking at the indexing expressions of the submodel tree leading to this ModelComp.

Parameters:
[in] node The model component in question.
[in] opn The node (IDREF) of the model component (needed for the (local) argument list).
[in] current_model The block for which this is written: indexing is given in the original SML model wrt a given node in the model tree.
[in] witharg WITHARG: if the argument list should be processed, NOARG: only the global name, ONLYARG: only the argument list.

Find the global name of the model component pointed to by 'node':

  • Generate the global name of a model component by pre-pending the names of models on the model-tree up to the model of this component to the name 'Flow' becomes 'MCNF_Net_Flow'
  • If 'witharg' is set, then the argument list is also generated: The argument list is composed of + dummy variables of indexing expressions of block up to model_of_comp + original arguments of the component (as given in the SML file) The appropriate argument list depends on both the model of the component and in which model this instance of referal of the ModelComp is (the current_model). Basically we need to identify the common ancestor model of the current_model and the model_of_comp. The arguments originating from block indexing expressions between here and the model_of_comp are already included in the argument list of the ModelComp. Anything below needs to be prepended to the argument list.

References buildModelPath(), SyntaxNode::getArgumentList(), SyntaxNodeIx::getDummyVarExpr(), SyntaxNodeIx::getNComp(), ModelComp::id, ModelComp::indexing, ModelComp::model, AmplModel::name, SyntaxNode::nchild(), NOARG, AmplModel::node, AmplModel::parent, SyntaxNode::printDummyVar(), and WITHARG.

Referenced by SyntaxNodeIDREF::put().