PIPS-NLP
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
MpsReader Class Reference

#include <MpsReader.h>

Public Member Functions

void numberOfNonZeros (int &nnzQ, int &nnzA, int &nnzC)
 
void numbersOfNonZeros (int nnzQ[], int nnzA[], int nnzC[])
 
virtual void readQpBound (OoqpVector &c, SymMatrix &Q, OoqpVector &xlow, OoqpVector &ixlow, OoqpVector &xupp, OoqpVector &ixupp, int &ierr)
 
virtual void readQpGen (OoqpVector &c, SymMatrix &Q, OoqpVector &xlow, OoqpVector &ixlow, OoqpVector &xupp, OoqpVector &ixupp, GenMatrix &A, OoqpVector &b, GenMatrix &C, OoqpVector &clow, OoqpVector &iclow, OoqpVector &cupp, OoqpVector &icupp, int &ierr)
 
virtual void readQpGen (double c[], int irowQ[], int jcolQ[], double dQ[], double xlow[], char ixlow[], double xupp[], char ixupp[], int irowA[], int jcolA[], double dA[], double b[], int irowC[], int jcolC[], double dC[], double clow[], char iclow[], double cupp[], char icupp[], int &ierr)
 
virtual void getSizes (int &nx, int &my, int &mz)
 
virtual void releaseFile (int &ierr)
 
virtual ~MpsReader ()
 
double objconst ()
 
void printSolution (double x[], int nx, double xlow[], char ixlow[], double xupp[], char ixupp[], double gamma[], double phi[], double y[], int my, double s[], int mz, double clow[], char iclow[], double cupp[], char icupp[], double lambda[], double pi[], double z[], double objectiveValue, int &iErr)
 
char * defaultOutputFilename (int &iErr)
 

Static Public Member Functions

static MpsReadernewReadingFile (char _filename[], int &iErr)
 
static void findFile (FILE *&file, char *&resolvedName, char _filename[])
 

Public Attributes

int scalingOption
 
char objectiveSense [3]
 

Protected Member Functions

 MpsReader ()
 
 MpsReader (FILE *file)
 
virtual void scanFile (int &iErr)
 
virtual int GetLine_old (char *line)
 
virtual int GetLine (char *line)
 
virtual int ParseHeaderLine (char line[], char entry1[])
 
virtual int ParseHeaderLine2 (char line[], char entry1[])
 
virtual int ParseBoundsLine (char line[], int &code, char name1[], char name2[], double *val)
 
virtual int ParseBoundsLine2 (char line[], int &code, char name1[], char name2[], double *val)
 
virtual int ParseRowsLine (char line[], char code[], char name1[])
 
virtual int ParseRowsLine2 (char line[], char code[], char name1[])
 
virtual void expectHeader (int kindOfLine, const char expectName[], char line[], int &ierr)
 
virtual void expectHeader2 (int kindOfLine, const char expectName[], char line[], int &ierr)
 
virtual void remapRows ()
 
virtual int acceptHeader (int kindOfLine, const char expectName[], char line[], int &ierr)
 
virtual int acceptHeader2 (int kindOfLine, const char expectName[], char line[], int &ierr)
 
virtual int ParseDataLine2 (char line[], char code[], char name1[], char name2[], double *val1, int &hasSecondValue, char name3[], double *val2)
 
virtual int ParseDataLine (char line[], char code[], char name1[], char name2[], double *val1, int &hasSecondValue, char name3[], double *val2)
 
virtual int string_copy (char dest[], char string[], int max)
 
virtual void readProblemName (char line[], int &iErr, int kindOfLine)
 
virtual void readProblemName2 (char line[], int &iErr, int kindOfLine)
 
virtual void readObjectiveSense (char line[], int &iErr, int kindOfLine)
 
virtual void readRowsSection (char line[62], int &iErr, int &return_getline)
 
virtual void scanColsSection (char line[62], int &iErr, int &return_getline)
 
virtual void scanRangesSection (char line[62], int &iErr, int &return_getline)
 
virtual void rowHasRange (int rownum, double val, int &iErr)
 
virtual void scanHessSection (char line[62], int &iErr, int &return_getline)
 
virtual void readColsSection (OoqpVector &c, GenMatrix &A, GenMatrix &C, char line[62], int &iErr, int &return_getline)
 
virtual void readColsSection (double c[], int irowA[], int jcolA[], double dA[], int irowC[], int jcolC[], double dC[], char line[62], int &iErr, int &return_getline)
 
virtual void readRHSSection (OoqpVector &b, SimpleVector &clow, OoqpVector &iclow, SimpleVector &cupp, OoqpVector &icupp, char line[], int &ierr, int &kindOfLine)
 
virtual void readRHSSection (double b[], double clow[], char iclow[], double cupp[], char icupp[], char line[], int &ierr, int &kindOfLine)
 
virtual void readRangesSection (SimpleVector &clow, SimpleVector &cupp, char line[], int &ierr, int &kindOfLine)
 
virtual void readRangesSection (double clow[], double cupp[], char line[], int &ierr, int &kindOfLine)
 
virtual void readBoundsSection (OoqpVector &xlow, OoqpVector &ixlow, OoqpVector &xupp, OoqpVector &ixupp, char line[], int &ierr, int &kindOfLine)
 
virtual void defaultBounds (double xlow[], char ixlow[], double xupp[], char ixupp[])
 
virtual void defaultBounds (OoqpVector &xlow, OoqpVector &ixlow, OoqpVector &xupp, OoqpVector &ixupp)
 
virtual void readBoundsSection (double xlow[], char ixlow[], double xupp[], char ixupp[], char line[], int &ierr, int &kindOfLine)
 
virtual void readHessSection (SymMatrix &Q, char line[], int &ierr, int &kindOfLine)
 
virtual void readHessSection (int irowQ[], int jcolQ[], double dQ[], char line[], int &ierr, int &kindOfLine)
 

Protected Attributes

char * infilename
 
int iline
 
int nnzA
 
int nnzC
 
int nnzQ
 
int my
 
int mz
 
FILE * file
 
char * boundType
 
MpsRowInforowInfo
 
int * rowRemap
 
int totalRows
 
MpsColInfocolInfo
 
int totalCols
 
int firstColumnLine
 
int columnFilePosition
 
char problemName [17]
 
char objectiveName [17]
 
char RHSName [17]
 
char boundName [17]
 
qpHashTablerowTable
 
qpHashTablecolTable
 
double objminus
 

Private Member Functions

void insertElt (int irow[], int len, int jcol[], double dval[], int &ne, int row, int col, double val, int &ier)
 
void stuffMatrix (GenMatrix &A, int irow[], int nnz, int jcol[], double dA[])
 
void stuffMatrix (SymMatrix &A, int irow[], int nnz, int jcol[], double dA[])
 

Detailed Description

A class for reading a Quadratic Programming problem from a file in modified MPS format.

The problem to be read is in QpGen format:

minimize    c' x + ( 1/2 ) x' * Q x         ; 
subject to                      A x  = b    ;
                       clow <=  C x <= cupp ;
                       xlow <=    x <= xupp ;

The general linear equality constraints must have either an upper or lower bound, but need not have both bounds. The variables may have no bounds; an upper bound; a lower bound or both an upper and lower bound.

Constructor & Destructor Documentation

MpsReader::MpsReader ( )
inlineprotected

protected constructor. Call the class method MpsReader::newReadingFile to obtain a new, initalized MpsReader.

See also
MpsReader::newReadingFile
MpsReader::MpsReader ( FILE *  file)
protected

protected constructor. Call the class method MpsReader::newReadingFile to obtain a new, initalized MpsReader.

See also
MpsReader::newReadingFile
MpsReader::~MpsReader ( )
virtual

Destructor

Member Function Documentation

int MpsReader::acceptHeader ( int  kindOfLine,
const char  expectName[],
char  line[],
int &  ierr 
)
protectedvirtual
int MpsReader::acceptHeader2 ( int  kindOfLine,
const char  expectName[],
char  line[],
int &  ierr 
)
protectedvirtual
void MpsReader::defaultBounds ( double  xlow[],
char  ixlow[],
double  xupp[],
char  ixupp[] 
)
protectedvirtual
void MpsReader::defaultBounds ( OoqpVector xlow,
OoqpVector ixlow,
OoqpVector xupp,
OoqpVector ixupp 
)
protectedvirtual
char * MpsReader::defaultOutputFilename ( int &  iErr)
void MpsReader::expectHeader ( int  kindOfLine,
const char  expectName[],
char  line[],
int &  ierr 
)
protectedvirtual
void MpsReader::expectHeader2 ( int  kindOfLine,
const char  expectName[],
char  line[],
int &  ierr 
)
protectedvirtual
void MpsReader::findFile ( FILE *&  file,
char *&  resolvedName,
char  _filename[] 
)
static

Locate an input file, given the user-supplied name and applying the MpsReader search rules

int MpsReader::GetLine ( char *  line)
protectedvirtual
int MpsReader::GetLine_old ( char *  line)
protectedvirtual
void MpsReader::getSizes ( int &  nx,
int &  my,
int &  mz 
)
virtual

Returns the sizes of the various components of the QP.

Parameters
nxthe number of variables
mythe number of equality constraints
mzthe number of general inequality constraints (this number does not include simple bounds on the variables.)
void MpsReader::insertElt ( int  irow[],
int  len,
int  jcol[],
double  dval[],
int &  ne,
int  row,
int  col,
double  val,
int &  ier 
)
private
MpsReader * MpsReader::newReadingFile ( char  _filename[],
int &  iErr 
)
static

Creates a new MpsReader that initializes itself from the data in a file.

Parameters
_filenamethe name of the file to read. If _filename == '-' standard input will be read.
iErriErr is non-zero if some error prevented the new MpsReader from initializing itself, for example if the file could not be read.
Returns
the new MpsReader, or nil if there was an error.
void MpsReader::numberOfNonZeros ( int &  nnzQ,
int &  nnzA,
int &  nnzC 
)

responds with the number of non-zeros in the QP data.

Parameters
nnzQthe number of non-zeros in Q
nnzAthe number of non-zeros in A
nnzCthe number of non-zeros in C
void MpsReader::numbersOfNonZeros ( int  nnzQ[],
int  nnzA[],
int  nnzC[] 
)
double MpsReader::objconst ( )
inline
int MpsReader::ParseBoundsLine ( char  line[],
int &  code,
char  name1[],
char  name2[],
double *  val 
)
protectedvirtual
int MpsReader::ParseBoundsLine2 ( char  line[],
int &  code,
char  name1[],
char  name2[],
double *  val 
)
protectedvirtual
int MpsReader::ParseDataLine ( char  line[],
char  code[],
char  name1[],
char  name2[],
double *  val1,
int &  hasSecondValue,
char  name3[],
double *  val2 
)
protectedvirtual
int MpsReader::ParseDataLine2 ( char  line[],
char  code[],
char  name1[],
char  name2[],
double *  val1,
int &  hasSecondValue,
char  name3[],
double *  val2 
)
protectedvirtual
int MpsReader::ParseHeaderLine ( char  line[],
char  entry1[] 
)
protectedvirtual
int MpsReader::ParseHeaderLine2 ( char  line[],
char  entry1[] 
)
protectedvirtual
int MpsReader::ParseRowsLine ( char  line[],
char  code[],
char  name1[] 
)
protectedvirtual
int MpsReader::ParseRowsLine2 ( char  line[],
char  code[],
char  name1[] 
)
protectedvirtual
void MpsReader::printSolution ( double  x[],
int  nx,
double  xlow[],
char  ixlow[],
double  xupp[],
char  ixupp[],
double  gamma[],
double  phi[],
double  y[],
int  my,
double  s[],
int  mz,
double  clow[],
char  iclow[],
double  cupp[],
char  icupp[],
double  lambda[],
double  pi[],
double  z[],
double  objectiveValue,
int &  iErr 
)

print the solution contained in the individual arrays of the QpGenVars "variables" object as an ascii file,associating the numerical values with the names stored in the MpsReader structure

output file

void MpsReader::readBoundsSection ( OoqpVector xlow,
OoqpVector ixlow,
OoqpVector xupp,
OoqpVector ixupp,
char  line[],
int &  ierr,
int &  kindOfLine 
)
protectedvirtual
void MpsReader::readBoundsSection ( double  xlow[],
char  ixlow[],
double  xupp[],
char  ixupp[],
char  line[],
int &  ierr,
int &  kindOfLine 
)
protectedvirtual
virtual void MpsReader::readColsSection ( OoqpVector c,
GenMatrix A,
GenMatrix C,
char  line[62],
int &  iErr,
int &  return_getline 
)
protectedvirtual
virtual void MpsReader::readColsSection ( double  c[],
int  irowA[],
int  jcolA[],
double  dA[],
int  irowC[],
int  jcolC[],
double  dC[],
char  line[62],
int &  iErr,
int &  return_getline 
)
protectedvirtual
void MpsReader::readHessSection ( SymMatrix Q,
char  line[],
int &  ierr,
int &  kindOfLine 
)
protectedvirtual
void MpsReader::readHessSection ( int  irowQ[],
int  jcolQ[],
double  dQ[],
char  line[],
int &  ierr,
int &  kindOfLine 
)
protectedvirtual
void MpsReader::readObjectiveSense ( char  line[],
int &  iErr,
int  kindOfLine 
)
protectedvirtual
void MpsReader::readProblemName ( char  line[],
int &  iErr,
int  kindOfLine 
)
protectedvirtual
void MpsReader::readProblemName2 ( char  line[],
int &  iErr,
int  kindOfLine 
)
protectedvirtual
void MpsReader::readQpBound ( OoqpVector c,
SymMatrix Q,
OoqpVector xlow,
OoqpVector ixlow,
OoqpVector xupp,
OoqpVector ixupp,
int &  ierr 
)
virtual

Reads the various components of a QP in the "general" formulation into their respective matrices and vectors, stored as objects from OOQP's linear algebra classes. See the class comments for the meaning of the variables.

Parameters
iErriErr is non-zero if there was some error reading the data, in partical if this QP has more than simple bounds.
void MpsReader::readQpGen ( OoqpVector c,
SymMatrix Q,
OoqpVector xlow,
OoqpVector ixlow,
OoqpVector xupp,
OoqpVector ixupp,
GenMatrix A,
OoqpVector b,
GenMatrix C,
OoqpVector clow,
OoqpVector iclow,
OoqpVector cupp,
OoqpVector icupp,
int &  ierr 
)
virtual

Reads the various components of a QP in the "general" formulation into their respective matrices and vectors, stored as objects from OOQP's linear algebra classes. See the class comments for the meaning of the variables.

Parameters
iErriErr is non-zero if there was some error reading the data.
void MpsReader::readQpGen ( double  c[],
int  irowQ[],
int  jcolQ[],
double  dQ[],
double  xlow[],
char  ixlow[],
double  xupp[],
char  ixupp[],
int  irowA[],
int  jcolA[],
double  dA[],
double  b[],
int  irowC[],
int  jcolC[],
double  dC[],
double  clow[],
char  iclow[],
double  cupp[],
char  icupp[],
int &  ierr 
)
virtual

Reads the various components of a QP in the "general" formulation into data representaions consisting of arrays of doubles and ints. For instance, the matrices Q, A, and C from this formulation each are represented in three arrays, in Harwell-Boeing format. See the class comments for the meaning of the various variables.

Parameters
iErriErr is non-zero if there was some error reading the data.
void MpsReader::readRangesSection ( SimpleVector clow,
SimpleVector cupp,
char  line[],
int &  ierr,
int &  kindOfLine 
)
protectedvirtual
void MpsReader::readRangesSection ( double  clow[],
double  cupp[],
char  line[],
int &  ierr,
int &  kindOfLine 
)
protectedvirtual
void MpsReader::readRHSSection ( OoqpVector b,
SimpleVector clow,
OoqpVector iclow,
SimpleVector cupp,
OoqpVector icupp,
char  line[],
int &  ierr,
int &  kindOfLine 
)
protectedvirtual
void MpsReader::readRHSSection ( double  b[],
double  clow[],
char  iclow[],
double  cupp[],
char  icupp[],
char  line[],
int &  ierr,
int &  kindOfLine 
)
protectedvirtual
void MpsReader::readRowsSection ( char  line[62],
int &  iErr,
int &  return_getline 
)
protectedvirtual
void MpsReader::releaseFile ( int &  ierr)
virtual

Closes the data file if necessary, and forgets all references to it. Call this method immediately before deleting the MpsReader. We do not close the data file in the destructor, because that operation can fail!

Call this method even when reading from stdin. This method will not close stdin.

Parameters
iErriErr is non-zero if there was some error closing the file.
void MpsReader::remapRows ( )
protectedvirtual
void MpsReader::rowHasRange ( int  rownum,
double  val,
int &  iErr 
)
protectedvirtual
void MpsReader::scanColsSection ( char  line[62],
int &  iErr,
int &  return_getline 
)
protectedvirtual
void MpsReader::scanFile ( int &  iErr)
protectedvirtual

protected method for scanning the file while initializing the MpsReader. Once the dimensions of the problem have been determined, it calls the class method MpsReader::newReadingFile to obtain an MpsReader with the dimensions appropriately initialized.

Parameters
iErriErr is non-zero if there was some error scanning the file.
See also
MpsReader::newReadingFile
void MpsReader::scanHessSection ( char  line[62],
int &  iErr,
int &  return_getline 
)
protectedvirtual
void MpsReader::scanRangesSection ( char  line[62],
int &  iErr,
int &  return_getline 
)
protectedvirtual
int MpsReader::string_copy ( char  dest[],
char  string[],
int  max 
)
protectedvirtual
void MpsReader::stuffMatrix ( GenMatrix A,
int  irow[],
int  nnz,
int  jcol[],
double  dA[] 
)
private
void MpsReader::stuffMatrix ( SymMatrix A,
int  irow[],
int  nnz,
int  jcol[],
double  dA[] 
)
private

Member Data Documentation

char MpsReader::boundName[17]
protected
char* MpsReader::boundType
protected

the type of bound on each variable, normal, free, upper, lower, upperlower, fix, minfty

MpsColInfo* MpsReader::colInfo
protected
qpHashTable* MpsReader::colTable
protected

has table containing column names

int MpsReader::columnFilePosition
protected
FILE* MpsReader::file
protected

the file to be read

int MpsReader::firstColumnLine
protected
int MpsReader::iline
protected

Input file line number

char* MpsReader::infilename
protected

root of the _filename for input (and possibly output) files

int MpsReader::my
protected

cached values for the sizes of the parts of this QP

int MpsReader::mz
protected
int MpsReader::nnzA
protected

cached values for the number of non-zeros in the parts of this QP

int MpsReader::nnzC
protected
int MpsReader::nnzQ
protected
char MpsReader::objectiveName[17]
protected
char MpsReader::objectiveSense[3]

Objective sense is either MAX or MIN

double MpsReader::objminus
protected
char MpsReader::problemName[17]
protected
char MpsReader::RHSName[17]
protected
MpsRowInfo* MpsReader::rowInfo
protected
int* MpsReader::rowRemap
protected
qpHashTable* MpsReader::rowTable
protected

hash tables containing row names

int MpsReader::scalingOption

The scaling option allows solution of problems in which the variables or equations have a vast range of values. By default, we do not scale unless the user requests it via the commandline argument.

int MpsReader::totalCols
protected
int MpsReader::totalRows
protected

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