This object represents a *.nl file: it is associated with an ExpandedModel object and provides routines to access the *.nl file through the amplsolver library. More...
#include <AmplsolverCalls.h>
Public Member Functions | |
NlFile (const std::string &name) | |
Constructor. | |
~NlFile () | |
Destructor. | |
int | getNoVariables () |
Return the number of variables defined in this *.nl file. | |
int | getNoHessianEntries () |
Return the number of Hessian entries defined in this *.nl file. | |
void | getHessianStructure (int *colbeg, int *rownbs) |
Return the Hessian structure of the objective in this *.nl file. | |
void | getHessianEntries (int *colbeg, int *rownbs, double *el) |
Return the Hessian entries of the objective in this *.nl file. | |
Private Member Functions | |
int | getNoConstraints () |
Return the number of constraints defined in this *.nl file. | |
void | readNlFile () |
Open the *.nl file and read it with pfgh_read(). | |
void | readNlFile_f () |
Open the *.nl file and read it with f_read(). | |
int | getNoNonzerosAMPL (int nvar, const int *lvar) |
Return the number of nonzeros for a (vertical) slice of the constraint matrix (Jacobian) defined in this file. | |
void | fillSparseAMPL (int nvar, const int *lvar, int *colbeg, int *collen, int *rownbs, double *el) |
Return a (vertical) slice of the constraint matrix (Jacobian) defined in this file in (columnwise) sparse matrix format (by filling in the memory locations provided). | |
void | getRowBoundsAMPL (double *lower, double *upper) const |
Return the row bounds for the constraints defined in this *.nl file. | |
void | getObjAMPL (int nvar, int *lvar, double *elts) |
Evaluate the objective gradient (linear coefficients) for a (vertical) slice of the problem stored in the *.nl file. | |
void | getColLowBoundsAMPL (int nvar, int *lvar, double *elts) |
Return lower variable (column) bounds for a selection of the variables in the *.nl file. | |
void | getColUpBoundsAMPL (int nvar, int *lvar, double *elts) |
Return upper variable (column) bounds for a selection of the variables in the *.nl file. | |
int | findIxOfLocalVarsInNlFile (ExpandedModel *em, int *lvar) |
Find the indices of the local variables of a given model in this nlfile. | |
Private Attributes | |
std::string | nlfilename |
Name of the *.nl file (without the '.nl' extension). | |
int | ncol |
Number of constraints defined in this file. | |
int | nrow |
Number of variables defined in this file. | |
int | nzH |
Number of nonzeros in the Hessian. | |
int | nzA |
Number of nonzeros in the Jacobian. | |
ASL_pfgh * | asl_pfgh_ptr |
The structure used in reading the *.nl file with pfgh_read(). | |
ASL * | asl_ptr |
The structure used in reading the *.nl file with f_read(). | |
std::map< ExpandedModel *, IndexListValue * > | indexList |
The NlFile defines constraints that span over several column blocks. | |
Friends | |
class | ExpandedModel |
This object represents a *.nl file: it is associated with an ExpandedModel object and provides routines to access the *.nl file through the amplsolver library.
NlFile::NlFile | ( | const std::string & | name | ) |
Constructor.
References asl_pfgh_ptr, asl_ptr, and readNlFile().
NlFile::~NlFile | ( | ) |
Destructor.
References asl_pfgh_ptr, asl_ptr, and indexList.
void NlFile::fillSparseAMPL | ( | int | nvar, | |
const int * | lvar, | |||
int * | colbeg, | |||
int * | collen, | |||
int * | rownbs, | |||
double * | el | |||
) | [private] |
Return a (vertical) slice of the constraint matrix (Jacobian) defined in this file in (columnwise) sparse matrix format (by filling in the memory locations provided).
[in] | nvar | Number of variables (columns) in the slice. |
[in] | lvar | The indices of the variables in the slice. |
[out] | colbeg | Pointer to column starts in rownbs, el. |
[out] | collen | Vector of column lengths (can be NULL). |
[out] | rownbs | Row indices for the sparse elements. |
[out] | el | The actual nonzero elements. |
For the part of the problem defined by the intersection of all the constraints in the *.nl file and the variables given by nvar, lvar this routine will return the Jacobian in (columnwise) sparse matrix format.
References asl_ptr, log_NL, nlfilename, and readNlFile_f().
Referenced by ExpandedModel::getJacobianOfIntersection().
int NlFile::findIxOfLocalVarsInNlFile | ( | ExpandedModel * | em, | |
int * | lvar | |||
) | [private] |
Find the indices of the local variables of a given model in this nlfile.
[in] | em | The model that defines the local variables. |
[out] | lvar | Assumed to be allocated with em->nLocalVar elements: lvar[i] is the the index of the ith local variable in em in the nlfile. |
The given nlfile will define variables spanning different column blocks. This routine scans through those variables and sees if any of them match the local variables of the model 'em'. For every local variable in em it returns '-1' if it is not found in the nlfile, or the position at which it is found in the nlfile otherwise.
References ExpandedModel::findIxOfLocalVarsInNlFile().
Referenced by ExpandedModel::getColLowBounds(), ExpandedModel::getColUpBounds(), ExpandedModel::getJacobianOfIntersection(), ExpandedModel::getNzJacobianOfIntersection(), and ExpandedModel::getObjGradient().
void NlFile::getColLowBoundsAMPL | ( | int | nvar, | |
int * | lvar, | |||
double * | elts | |||
) | [private] |
Return lower variable (column) bounds for a selection of the variables in the *.nl file.
[in] | nvar | Number of variables defining the slice. |
[in] | lvar | The indices of the variables defining the slice. |
[out] | elts | The lower bounds for the defined variables. |
References asl_pfgh_ptr, log_NL, and nlfilename.
Referenced by ExpandedModel::getColLowBounds().
void NlFile::getColUpBoundsAMPL | ( | int | nvar, | |
int * | lvar, | |||
double * | elts | |||
) | [private] |
Return upper variable (column) bounds for a selection of the variables in the *.nl file.
[in] | nvar | Number of variables defining the slice. |
[in] | lvar | The indices of the variables defining the slice. |
[out] | elts | The upper bounds for the defined variables. |
References asl_pfgh_ptr, log_NL, and nlfilename.
Referenced by ExpandedModel::getColUpBounds().
void NlFile::getHessianEntries | ( | int * | colbeg, | |
int * | rownbs, | |||
double * | el | |||
) |
Return the Hessian entries of the objective in this *.nl file.
Assumes that the Hessian is constant (pass in x=0).
References asl_pfgh_ptr, log_NL, ncol, nlfilename, and nzH.
void NlFile::getHessianStructure | ( | int * | colbeg, | |
int * | rownbs | |||
) |
Return the Hessian structure of the objective in this *.nl file.
Assumes that the Hessian is constant (pass in x=0).
References asl_pfgh_ptr, log_NL, ncol, nlfilename, and nzH.
int NlFile::getNoConstraints | ( | ) | [private] |
Return the number of constraints defined in this *.nl file.
References nrow.
Referenced by ExpandedModel::setLocalVarInfo().
int NlFile::getNoHessianEntries | ( | ) |
Return the number of Hessian entries defined in this *.nl file.
References asl_pfgh_ptr, log_NL, nlfilename, and nzH.
int NlFile::getNoNonzerosAMPL | ( | int | nvar, | |
const int * | lvar | |||
) | [private] |
Return the number of nonzeros for a (vertical) slice of the constraint matrix (Jacobian) defined in this file.
nvar | Number of variables (columns) in the slice. | |
lvar | The indices of the variables in the slice. |
For the part of the problem defined by the intersection of all the constraints in the *.nl file and the variables given by nvar, lvar this routine will return the nonzeros in the Jacobian.
References asl_ptr, log_NL, nlfilename, and readNlFile_f().
Referenced by ExpandedModel::getNzJacobianOfIntersection().
int NlFile::getNoVariables | ( | ) |
Return the number of variables defined in this *.nl file.
References ncol.
void NlFile::getObjAMPL | ( | int | nvar, | |
int * | lvar, | |||
double * | elts | |||
) | [private] |
Evaluate the objective gradient (linear coefficients) for a (vertical) slice of the problem stored in the *.nl file.
[in] | nvar | Number of variables defining the slice. |
[in] | lvar | The indices of the variables defining the slice. |
[out] | elts | The objective gradient vector w.r.t. the variables defined in nvar/lvar. |
References asl_pfgh_ptr, log_NL, and nlfilename.
Referenced by ExpandedModel::getObjGradient().
void NlFile::getRowBoundsAMPL | ( | double * | lower, | |
double * | upper | |||
) | const [private] |
Return the row bounds for the constraints defined in this *.nl file.
[out] | lower | The row lower bounds as a dense array. |
[out] | upper | The row upper bounds as a dense array. |
References asl_pfgh_ptr, log_NL, nlfilename, and nrow.
Referenced by ExpandedModel::getRowBounds().
void NlFile::readNlFile | ( | ) | [private] |
Open the *.nl file and read it with pfgh_read().
References asl_pfgh_ptr, log_NL, ncol, nlfilename, nrow, and nzA.
Referenced by NlFile().
void NlFile::readNlFile_f | ( | ) | [private] |
Open the *.nl file and read it with f_read().
References asl_ptr, and nlfilename.
Referenced by fillSparseAMPL(), and getNoNonzerosAMPL().
friend class ExpandedModel [friend] |
ASL_pfgh* NlFile::asl_pfgh_ptr [private] |
The structure used in reading the *.nl file with pfgh_read().
Referenced by getColLowBoundsAMPL(), getColUpBoundsAMPL(), getHessianEntries(), getHessianStructure(), getNoHessianEntries(), getObjAMPL(), getRowBoundsAMPL(), NlFile(), readNlFile(), and ~NlFile().
ASL* NlFile::asl_ptr [private] |
The structure used in reading the *.nl file with f_read().
Referenced by fillSparseAMPL(), getNoNonzerosAMPL(), NlFile(), readNlFile_f(), and ~NlFile().
std::map<ExpandedModel*, IndexListValue*> NlFile::indexList [private] |
The NlFile defines constraints that span over several column blocks.
Typically only the intersection with one of these blocks needs to be evaluated. For this we need to know which columns in the NlFile belong to a given column block (given by an ExpandedModel). This is stored in terms of this map: for every ExpandedModel it gives an array of indices of the corresponding columns.
Referenced by ExpandedModel::findIxOfLocalVarsInNlFile(), and ~NlFile().
int NlFile::ncol [private] |
Number of constraints defined in this file.
Referenced by getHessianEntries(), getHessianStructure(), getNoVariables(), and readNlFile().
std::string NlFile::nlfilename [private] |
Name of the *.nl file (without the '.nl' extension).
Referenced by fillSparseAMPL(), ExpandedModel::findIxOfLocalVarsInNlFile(), getColLowBoundsAMPL(), getColUpBoundsAMPL(), getHessianEntries(), getHessianStructure(), getNoHessianEntries(), getNoNonzerosAMPL(), getObjAMPL(), getRowBoundsAMPL(), ExpandedModel::print(), readNlFile(), and readNlFile_f().
int NlFile::nrow [private] |
Number of variables defined in this file.
Referenced by getNoConstraints(), getRowBoundsAMPL(), and readNlFile().
int NlFile::nzA [private] |
Number of nonzeros in the Jacobian.
Referenced by readNlFile().
int NlFile::nzH [private] |
Number of nonzeros in the Hessian.
Referenced by getHessianEntries(), getHessianStructure(), and getNoHessianEntries().