Functions

AmplModel.cpp File Reference

#include "AmplModel.h"
#include "backend.h"
#include "ExpandedModel.h"
#include "GlobalVariables.h"
#include "ModelComp.h"
#include "misc.h"
#include "nodes.h"
#include "sml.tab.h"
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>

Functions

void modified_write (ostream &fout, ModelComp *comp)
 Writes out a component of a model.
static bool is_int (const char *tok)
 Checks if a cstring represents a natural number (i.e [0-9]*) or not.
static string crush (const string &inst)
 Crushes a set element "(N0,N1)" into "N0N1".
static void getListOfInstances (istream &file, list< string > &li)

Function Documentation

string crush ( const string &  inst  )  [static]

Crushes a set element "(N0,N1)" into "N0N1".

Referenced by AmplModel::createExpandedModel().

void getListOfInstances ( istream &  file,
list< string > &  li 
) [static]
bool is_int ( const char *  tok  )  [static]

Checks if a cstring represents a natural number (i.e [0-9]*) or not.

Referenced by AmplModel::createExpandedModel().

void modified_write ( ostream &  fout,
ModelComp comp 
)

Writes out a component of a model.

Components can be modified: if this is down into a submodel, then

  • all declarations get new indexing expressions appended to it
  • all references to entities get new subscripts attached to it.
Parameters:
[in] fout The file to write to.
[in] comp The component definition to write out.
Precondition:
Depends on l_addIndex: currently applicable indexing expresssions.

Prints the global definition of the given ModelComponent to the given file.

  1. get the global name of the model component
  2. prepend all indexing expressions on the stack to the indexing expression of this entity
  3. for all components that are referenced in the definition
    1. use their global name
    2. prepend the dummy variables for all indexing expressions on the stack to the argument list

The last part is simply done by a call to (comp->attributes)->print() (SyntaxNode::print) (with SyntaxNode::use_global_names set to true => the argument list version of ModelComp::getGlobalName is called)

Referenced by ModelComp::modifiedWriteAllTagged(), write_ampl_for_submodel_(), and AmplModel::writeTaggedComponents().