Functions | Variables

backend.cpp File Reference

#include "backend.h"
#include "AmplModel.h"
#include "GlobalVariables.h"
#include "ModelComp.h"
#include "nodes.h"
#include ""
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <fstream>


static void write_ampl_for_submodel (ostream &fout, AmplModel *submodel)
static void print_entry (const ModelComp *entry)
static void print_entries (const AmplModel *model, compType type)
static void print_model (const AmplModel *model)
static void fill_model_list_ (AmplModel *model, list< AmplModel * > &listam)
static void print_indent (ofstream &out, int k)
int process_model (AmplModel *model, const string &datafilename)
void write_ampl_for_submodel_ (ostream &fout, int thislevel, int sublevel, AmplModel **list, AmplModel *submodel)
void modified_write (ostream &fout, ModelComp *comp)
 Writes out a component of a model.


static const int MAX_NESTED_BLOCKS = 5
static bool prt_modwrite = false
vector< list< add_index > > l_addIndex

Function Documentation

void fill_model_list_ ( AmplModel model,
list< AmplModel * > &  listam 
) [static]
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.
[in] fout The file to write to.
[in] comp The component definition to write out.
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)

References ModelComp::attributes, ModelComp::compTypes, add_index::dummyVar, SyntaxNode::front(), getGlobalName(), SyntaxNode::getOpCode(), ModelComp::id, ModelComp::indexing, l_addIndex, ModelComp::model, NOARG, AmplModel::parent, prt_modwrite, add_index::set, TCON, TMAX, TMIN, TMODEL, and ModelComp::type.

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

static void print_entries ( const AmplModel model,
compType  type 
) [static]

References AmplModel::comps, print_entry(), and ModelComp::type.

Referenced by print_model().

static void print_entry ( const ModelComp entry  )  [static]
static void print_indent ( ofstream &  out,
int  k 
) [static]


Referenced by process_model().

static void print_model ( const AmplModel model  )  [static]
int process_model ( AmplModel model,
const string &  datafilename 
void write_ampl_for_submodel ( ostream &  fout,
AmplModel submodel 
) [static]
void write_ampl_for_submodel_ ( ostream &  fout,
int  thislevel,
int  sublevel,
AmplModel **  list,
AmplModel submodel 

Variable Documentation

vector<list<add_index> > l_addIndex
const int MAX_NESTED_BLOCKS = 5 [static]

Referenced by write_ampl_for_submodel().

bool prt_modwrite = false [static]

Referenced by modified_write().