#include <OSnl2OS.h>
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... | |
OSnLNode * | walkTree (expr *e) |
parse an nl tree structure holding a nonlinear expression More... | |
Public Attributes | |
OSoLReader * | osolreader |
we may need to parse an OSoL file if there is suffix information indicated in the AMPL nl content More... | |
OSInstance * | osinstance |
osinstance is a pointer to the OSInstance object that gets created from the information in the nl file More... | |
OSOption * | 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) 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... | |
The OSnl2OS Class.
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
¶m cw a pointer to a (previously allocated) struct used for column-wise representation ¶m rw a pointer to a (previously allocated) struct used for row-wise representation ¶m 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.
ASL * OSnl2OS::getASL | ( | std::string | name | ) |
return a pointer to an ASL object
name | carries the name of the ASL object (there are three of them: asl, rw, cw) |
Definition at line 87 of file OSnl2OS.cpp.
bool OSnl2OS::readNl | ( | std::string | stub | ) |
read the nl file
stub | is the (relevant part of the) file name |
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
asl | carries a pointer to the object named "asl" |
rw | carries a pointer to the object named "rw" |
cw | carries a pointer to the object named "cw" (asl should point to the same location as either rw or cw) |
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.)
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
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.
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
Definition at line 206 of file OSnl2OS.cpp.
OSoLReader* OSnl2OS::osolreader |
OSInstance* OSnl2OS::osinstance |
osinstance is a pointer to the OSInstance object that gets created from the information in the nl file
OSOption* OSnl2OS::osoption |
std::string OSnl2OS::osol |
std::string OSnl2OS::jobID |
|
private |
|
private |
|
private |