Public Member Functions | Public Attributes | Private Attributes | List of all members
OSnl2OS Class Reference

The OSnl2OS Class. More...

#include <OSnl2OS.h>

Collaboration diagram for OSnl2OS:
Collaboration graph
[legend]

Public Member Functions

 OSnl2OS ()
 the OSnl2OS class constructor More...
 
 OSnl2OS (ASL *cw, ASL *rw, ASL *asl)
 alternate constructor which does not allocate the ASL structs More...
 
 ~OSnl2OS ()
 the OSnl2OS class destructor More...
 
ASL * getASL (std::string name)
 return a pointer to an ASL object More...
 
bool readNl (std::string stub)
 read the nl file More...
 
void setOsol (std::string osol)
 set the osol string More...
 
void setJobID (std::string jobID)
 set the job ID More...
 
bool setASL (ASL *asl, ASL *rw, ASL *cw)
 set the pointers to the three ASL objects More...
 
bool createOSObjects ()
 create an OSInstance and OSOption representation from the AMPL nl content (Some of the information in the nl file — such as initial values, basis information, branching priorities, etc. More...
 
void setVar (OSInstance *osinstance, int lower, int upper, char vartype)
 store a number of variables into an OSInstance object More...
 
void setIBVar (OSInstance *osinstance, int lower, int upper)
 special version of the previous method because AMPL makes no distinction between integer and binary variables that occur in nonlinear expressions. More...
 
OSnLNodewalkTree (expr *e)
 parse an nl tree structure holding a nonlinear expression More...
 

Public Attributes

OSoLReaderosolreader
 we may need to parse an OSoL file if there is suffix information indicated in the AMPL nl content More...
 
OSInstanceosinstance
 osinstance is a pointer to the OSInstance object that gets created from the information in the nl file More...
 
OSOptionosoption
 osoption is a pointer to the OSOption object that gets created from the information in the nl file (and the OSoL string if present) More...
 
std::string osol
 osol is a string containing the content of the OS option file (it may be empty if no option file was provided). More...
 
std::string jobID
 jobID is a string containing a jobID that may have been supplied on the command line (it may be empty). More...
 
std::vector< std::string > op_type
 
std::vector< double > operand
 
int numkount
 

Private Attributes

ograd * og
 og is a pointer to the AMPL data structure holding the objective function coefficients More...
 
ASL * cw
 Pointers to AMPL data structures. More...
 
ASL * rw
 
ASL * asl
 
std::string stub
 stub is the name of the file with the nl instance More...
 

Detailed Description

The OSnl2OS Class.

Author
Horand Gassmann, Jun Ma, Kipp Martin
Remarks
The OSnl2OS class is used for reading an AMPL nl file, extracting from it the instance along with any options indexed over variables, constraints, objectives. The latter may, if needed, be merged with the contents of an OSoL file. The processed information is stored into an OSInstance object and either an OSOption object (if not NULL) or an OSoL string.

Definition at line 78 of file OSnl2OS.h.

Constructor & Destructor Documentation

OSnl2OS::OSnl2OS ( )

the OSnl2OS class constructor

Definition at line 71 of file OSnl2OS.cpp.

OSnl2OS::OSnl2OS ( ASL *  cw,
ASL *  rw,
ASL *  asl 
)

alternate constructor which does not allocate the ASL structs

&param cw a pointer to a (previously allocated) struct used for column-wise representation &param rw a pointer to a (previously allocated) struct used for row-wise representation &param asl an extra pointer that can be used to switch between rw and cw

Definition at line 79 of file OSnl2OS.cpp.

OSnl2OS::~OSnl2OS ( )

the OSnl2OS class destructor

Definition at line 178 of file OSnl2OS.cpp.

Member Function Documentation

ASL * OSnl2OS::getASL ( std::string  name)

return a pointer to an ASL object

Parameters
namecarries the name of the ASL object (there are three of them: asl, rw, cw)
Returns
the pointer to the object named

Definition at line 87 of file OSnl2OS.cpp.

bool OSnl2OS::readNl ( std::string  stub)

read the nl file

Parameters
stubis the (relevant part of the) file name
Returns
whether the read was successful

Definition at line 109 of file OSnl2OS.cpp.

void OSnl2OS::setOsol ( std::string  osol)

set the osol string

Definition at line 99 of file OSnl2OS.cpp.

void OSnl2OS::setJobID ( std::string  jobID)

set the job ID

Definition at line 104 of file OSnl2OS.cpp.

bool OSnl2OS::setASL ( ASL *  asl,
ASL *  rw,
ASL *  cw 
)

set the pointers to the three ASL objects

Parameters
aslcarries a pointer to the object named "asl"
rwcarries a pointer to the object named "rw"
cwcarries a pointer to the object named "cw" (asl should point to the same location as either rw or cw)
Returns
whether the operation was successful
bool OSnl2OS::createOSObjects ( )

create an OSInstance and OSOption representation from the AMPL nl content (Some of the information in the nl file — such as initial values, basis information, branching priorities, etc.

— cannot be stored into an OSInstance and must be stored in an OSOption object instead.)

Returns
whether the objects were created successfully.

Before we can process the rest of the instance, we check for QP (using the row-wise representation) This needs to be done here because of the possibility of expressions like (1 - x[0])^2 which may modify the A matrix as well as the right-hand sides. If the A-matrix is modified, the column-wise representation is out of date and must be rebuilt from the row-wise form.

The nl file may contain options that are indexed over model entities: variables, constraints, objectives, problems. An example would be initial primal and dual variables. AMPL stores these as suffixes, which are processed next. The code below is based on ideas expressed by David Gay.

osolreader maintains a private pointer to tmpoption, which will cause the OSOption object to be destroyed when osolreader is deleted. The solution is to do a deep copy of tmpoption. This is not as bad as it looks because the information read from the OSoL file is likely to be much smaller than the array-valued information in the .nl file, which triggered the merge of the .nl options with the .osol options in the first place. (HIG - 28/Jan/2013)

Definition at line 504 of file OSnl2OS.cpp.

void OSnl2OS::setVar ( OSInstance osinstance,
int  lower,
int  upper,
char  vartype 
)

store a number of variables into an OSInstance object

Parameters
osinstance,:a pointer to the OSInstance object
lower,:index of the first variable to be set in this call
upper,:set all variables from lower...upper-1
vartype,:the type of the variable (in AMPL this is 'C', 'B' or 'I')

Definition at line 461 of file OSnl2OS.cpp.

void OSnl2OS::setIBVar ( OSInstance osinstance,
int  lower,
int  upper 
)

special version of the previous method because AMPL makes no distinction between integer and binary variables that occur in nonlinear expressions.

The actual type ('B' or 'I') must be inferred from the variable bounds.

Parameters
osinstance,:a pointer to the OSInstance object
lower,:index of the first variable to be set in this call
upper,:set all variables from lower...upper-1

Definition at line 481 of file OSnl2OS.cpp.

OSnLNode * OSnl2OS::walkTree ( expr *  e)

parse an nl tree structure holding a nonlinear expression

Returns
the AMPL nonlinear structure as an OSnLNode.

Definition at line 206 of file OSnl2OS.cpp.

Member Data Documentation

OSoLReader* OSnl2OS::osolreader

we may need to parse an OSoL file if there is suffix information indicated in the AMPL nl content

Definition at line 160 of file OSnl2OS.h.

OSInstance* OSnl2OS::osinstance

osinstance is a pointer to the OSInstance object that gets created from the information in the nl file

Definition at line 172 of file OSnl2OS.h.

OSOption* OSnl2OS::osoption

osoption is a pointer to the OSOption object that gets created from the information in the nl file (and the OSoL string if present)

Definition at line 177 of file OSnl2OS.h.

std::string OSnl2OS::osol

osol is a string containing the content of the OS option file (it may be empty if no option file was provided).

If osoption is NULL, the option information is found in osol.

Definition at line 183 of file OSnl2OS.h.

std::string OSnl2OS::jobID

jobID is a string containing a jobID that may have been supplied on the command line (it may be empty).

If osoption is not NULL, the jobID has been duplicated to osoption.

Definition at line 189 of file OSnl2OS.h.

std::vector<std::string> OSnl2OS::op_type

Definition at line 191 of file OSnl2OS.h.

std::vector<double> OSnl2OS::operand

Definition at line 192 of file OSnl2OS.h.

int OSnl2OS::numkount

Definition at line 193 of file OSnl2OS.h.

ograd* OSnl2OS::og
private

og is a pointer to the AMPL data structure holding the objective function coefficients

Definition at line 200 of file OSnl2OS.h.

ASL* OSnl2OS::cw
private

Pointers to AMPL data structures.

cw is loaded in column-wise format. rw is loaded in row-wise format. asl is for conveniently switching.

Definition at line 207 of file OSnl2OS.h.

ASL * OSnl2OS::rw
private

Definition at line 207 of file OSnl2OS.h.

ASL * OSnl2OS::asl
private

Definition at line 207 of file OSnl2OS.h.

std::string OSnl2OS::stub
private

stub is the name of the file with the nl instance

Definition at line 211 of file OSnl2OS.h.


The documentation for this class was generated from the following files: