CoinMpsIO
MPS IO Interface.
MPS IO Interface.
Description
This class can be used to read in mps files without a solver. After reading the file, the CoinMpsIO object contains all relevant data, which may be more than a particular OsiSolverInterface allows for. Items may be deleted to allow for flexibility of data storage. The implementation makes the CoinMpsIO object look very like a dummy solver, as the same conventions are used.
Public Methods
getNumCols
Get number of columns.
int getNumCols()
getNumRows
Get number of rows.
int getNumRows()
getNumElements
Get number of nonzero elements.
CoinBigIndex getNumElements()
getColLower
Get pointer to array[getNumCols()] of column lower bounds.
const double * getColLower()
getColUpper
Get pointer to array[getNumCols()] of column upper bounds.
const double * getColUpper()
getRowSense
Get pointer to array[getNumRows()] of constraint senses.
const char * getRowSense()
getRightHandSide
Get pointer to array[getNumRows()] of constraint right-hand sides.
const double * getRightHandSide()
getRowRange
Get pointer to array[getNumRows()] of row ranges.
const double * getRowRange()
getRowLower
Get pointer to array[getNumRows()] of row lower bounds.
const double * getRowLower()
getRowUpper
Get pointer to array[getNumRows()] of row upper bounds.
const double * getRowUpper()
getObjCoefficients
Get pointer to array[getNumCols()] of objective function coefficients.
const double * getObjCoefficients()
getMatrixByRow
Get pointer to row-wise copy of the coefficient matrix.
const CoinPackedMatrix * getMatrixByRow()
getMatrixByCol
Get pointer to column-wise copy of the coefficient matrix.
const CoinPackedMatrix * getMatrixByCol()
isContinuous
Return true if column is a continuous variable.
bool isContinuous(int colNumber)
Parameters:
colNumber(int)
isInteger
Return true if a column is an integer variable.
bool isInteger(int columnNumber)
Parameters:
columnNumber(int)
isIntegerOrSemiContinuous
Return 1 if a column is an integer variable, 2 if semi-continuous.
int isIntegerOrSemiContinuous(int columnNumber)
Parameters:
columnNumber(int)
integerColumns
Returns array[getNumCols()] specifying if a variable is integer.
const char * integerColumns()
rowName
Returns the row name for the specified index.
const char * rowName(int index)
Parameters:
index(int)
columnName
Returns the column name for the specified index.
const char * columnName(int index)
Parameters:
index(int)
rowIndex
Returns the index for the specified row name.
int rowIndex(const char * name)
Parameters:
name(const char *)
columnIndex
Returns the index for the specified column name.
int columnIndex(const char * name)
Parameters:
name(const char *)
objectiveOffset
Returns the (constant) objective offset.
double objectiveOffset()
setObjectiveOffset
Set objective offset.
void setObjectiveOffset(double value)
Parameters:
value(double)
getProblemName
Return the problem name.
const char * getProblemName()
getObjectiveName
Return the objective name.
const char * getObjectiveName()
getRhsName
Return the RHS vector name.
const char * getRhsName()
getRangeName
Return the range vector name.
const char * getRangeName()
getBoundName
Return the bound vector name.
const char * getBoundName()
numberStringElements
Number of string elements.
int numberStringElements()
stringElement
String element.
const char * stringElement(int i)
Parameters:
i(int)
setMpsData
Set the problem data.
void setMpsData(const CoinPackedMatrix & m, const double infinity, const double * collb, const double * colub, const double * obj, const char * integrality, const double * rowlb, const double * rowub, char const *const *const colnames, char const *const *const rownames)
Parameters:
m(const CoinPackedMatrix &)infinity(const double)collb(const double *)colub(const double *)obj(const double *)integrality(const char *)rowlb(const double *)rowub(const double *)colnames(char const *const *const)rownames(char const *const *const)
setMpsData
void setMpsData(const CoinPackedMatrix & m, const double infinity, const double * collb, const double * colub, const double * obj, const char * integrality, const double * rowlb, const double * rowub, const std::vector< std::string > & colnames, const std::vector< std::string > & rownames)
Parameters:
m(const CoinPackedMatrix &)infinity(const double)collb(const double *)colub(const double *)obj(const double *)integrality(const char *)rowlb(const double *)rowub(const double *)colnames(const std::vector< std::string > &)rownames(const std::vector< std::string > &)
setMpsData
void setMpsData(const CoinPackedMatrix & m, const double infinity, const double * collb, const double * colub, const double * obj, const char * integrality, const char * rowsen, const double * rowrhs, const double * rowrng, char const *const *const colnames, char const *const *const rownames)
Parameters:
m(const CoinPackedMatrix &)infinity(const double)collb(const double *)colub(const double *)obj(const double *)integrality(const char *)rowsen(const char *)rowrhs(const double *)rowrng(const double *)colnames(char const *const *const)rownames(char const *const *const)
setMpsData
void setMpsData(const CoinPackedMatrix & m, const double infinity, const double * collb, const double * colub, const double * obj, const char * integrality, const char * rowsen, const double * rowrhs, const double * rowrng, const std::vector< std::string > & colnames, const std::vector< std::string > & rownames)
Parameters:
m(const CoinPackedMatrix &)infinity(const double)collb(const double *)colub(const double *)obj(const double *)integrality(const char *)rowsen(const char *)rowrhs(const double *)rowrng(const double *)colnames(const std::vector< std::string > &)rownames(const std::vector< std::string > &)
copyInIntegerInformation
Pass in an array[getNumCols()] specifying if a variable is integer.
void copyInIntegerInformation(const char * integerInformation)
Parameters:
integerInformation(const char *)
setProblemName
Set problem name.
void setProblemName(const char * name)
Parameters:
name(const char *)
setObjectiveName
Set objective name.
void setObjectiveName(const char * name)
Parameters:
name(const char *)
setInfinity
Set infinity.
void setInfinity(double value)
Parameters:
value(double)
getInfinity
Get infinity.
double getInfinity()
setDefaultBound
Set default upper bound for integer variables.
void setDefaultBound(int value)
Parameters:
value(int)
getDefaultBound
Get default upper bound for integer variables.
int getDefaultBound()
allowStringElements
Whether to allow string elements.
int allowStringElements()
setAllowStringElements
Whether to allow string elements (0 no, 1 yes, 2 yes and try flip)
void setAllowStringElements(int yesNo)
Parameters:
yesNo(int)
getSmallElementValue
Small element value - elements less than this set to zero on input default is 1.0e-14.
double getSmallElementValue()
setSmallElementValue
void setSmallElementValue(double value)
Parameters:
value(double)
wasMaximization
Return true if maximization problem reformulated as minimization.
bool wasMaximization()
isMaximization
Return true if maximization problem and still formulated as maximization.
bool isMaximization()
setFileName
Set the current file name for the CoinMpsIO object.
void setFileName(const char * name)
Parameters:
name(const char *)
getFileName
Get the current file name for the CoinMpsIO object.
const char * getFileName()
readMps
Read a problem in MPS format from the given filename.
int readMps(const char * filename, const char * extension = "mps")
Parameters:
filename(const char *)extension(const char *)
readMps
Read a problem in MPS format from the given filename.
int readMps(const char * filename, const char * extension, int & numberSets, CoinSet **& sets)
Parameters:
filename(const char *)extension(const char *)numberSets(int &)sets(CoinSet **&)
readMps
Read a problem in MPS format from a previously opened file.
int readMps()
readMps
and
int readMps(int & numberSets, CoinSet **& sets)
Parameters:
numberSets(int &)sets(CoinSet **&)
readBasis
Read a basis in MPS format from the given filename.
int readBasis(const char * filename, const char * extension, double * solution, unsigned char * rowStatus, unsigned char * columnStatus, const std::vector< std::string > & colnames, int numberColumns, const std::vector< std::string > & rownames, int numberRows)
Parameters:
filename(const char *)extension(const char *)solution(double *)rowStatus(unsigned char *)columnStatus(unsigned char *)colnames(const std::vector< std::string > &)numberColumns(int)rownames(const std::vector< std::string > &)numberRows(int)
readGms
Read a problem in GAMS format from the given filename.
int readGms(const char * filename, const char * extension = "gms", bool convertObjective = false)
Parameters:
filename(const char *)extension(const char *)convertObjective(bool)
readGms
Read a problem in GAMS format from the given filename.
int readGms(const char * filename, const char * extension, int & numberSets, CoinSet **& sets)
Parameters:
filename(const char *)extension(const char *)numberSets(int &)sets(CoinSet **&)
readGms
Read a problem in GAMS format from a previously opened file.
int readGms(int & numberSets, CoinSet **& sets)
Parameters:
numberSets(int &)sets(CoinSet **&)
writeMps
Write the problem in MPS format to a file with the given filename.
int writeMps(const char * filename, int compression = 0, int formatType = 0, int numberAcross = 2, CoinPackedMatrix * quadratic = NULL, int numberSOS = 0, const CoinSet * setInfo = NULL)
Parameters:
filename(const char *)compression(int) - can be set to three values to indicate what kind of file should be written 0: plain text (default) 1: gzip compressed (.gz is appended tofilename) 2: bzip2 compressed (.bz2 is appended tofilename) (TODO) If the library was not compiled with the requested compression then writeMps falls back to writing a plain text file.formatType(int) - specifies the precision to used for values in the MPS file 0: normal precision (default) 1: extra accuracy 2: IEEE hexnumberAcross(int) - specifies whether 1 or 2 (default) values should be specified on every data line in the MPS file.quadratic(CoinPackedMatrix *) - specifies quadratic objective to be outputnumberSOS(int)setInfo(const CoinSet *)
reader
Return card reader object so can see what last card was e.g. QUADOBJ.
const CoinMpsCardReader * reader()
readQuadraticMps
Read in a quadratic objective from the given filename.
int readQuadraticMps(const char * filename, CoinBigIndex *& columnStart, int *& column, double *& elements, int checkSymmetry)
Parameters:
filename(const char *)columnStart(CoinBigIndex *&)column(int *&)elements(double *&)checkSymmetry(int)
readConicMps
Read in a list of cones from the given filename.
int readConicMps(const char * filename, int *& columnStart, int *& column, int *& coneType, int & numberCones)
Parameters:
filename(const char *)columnStart(int *&)column(int *&)coneType(int *&)numberCones(int &)
setConvertObjective
Set whether to move objective from matrix.
void setConvertObjective(bool trueFalse)
Parameters:
trueFalse(bool)
copyStringElements
copies in strings from a CoinModel - returns number
int copyStringElements(const CoinModel * model)
Parameters:
model(const CoinModel *)
CoinMpsIO
Default Constructor.
CoinMpsIO()
CoinMpsIO
Copy constructor.
CoinMpsIO(const CoinMpsIO & )
Parameters:
- `` (const CoinMpsIO &)
operator=
Assignment operator.
CoinMpsIO & operator=(const CoinMpsIO & rhs)
Parameters:
rhs(const CoinMpsIO &)
~CoinMpsIO
Destructor.
~CoinMpsIO()
passInMessageHandler
Pass in Message handler.
void passInMessageHandler(CoinMessageHandler * handler)
Parameters:
handler(CoinMessageHandler *)
newLanguage
Set the language for messages.
void newLanguage(CoinMessages::Language language)
Parameters:
language(CoinMessages::Language)
setLanguage
Set the language for messages.
void setLanguage(CoinMessages::Language language)
Parameters:
language(CoinMessages::Language)
messageHandler
Return the message handler.
CoinMessageHandler * messageHandler()
messages
Return the messages.
CoinMessages messages()
messagesPointer
Return the messages pointer.
CoinMessages * messagesPointer()
releaseRedundantInformation
Release all information which can be re-calculated.
void releaseRedundantInformation()
releaseRowInformation
Release all row information (lower, upper)
void releaseRowInformation()
releaseColumnInformation
Release all column information (lower, upper, objective)
void releaseColumnInformation()
releaseIntegerInformation
Release integer information.
void releaseIntegerInformation()
releaseRowNames
Release row names.
void releaseRowNames()
releaseColumnNames
Release column names.
void releaseColumnNames()
releaseMatrixInformation
Release matrix information.
void releaseMatrixInformation()
Source
Header: layer-0/CoinUtils/src/CoinMpsIO.hpp