Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CoinLpIO Class Reference

Class to read and write Lp files. More...

#include <CoinLpIO.hpp>

+ Collaboration diagram for CoinLpIO:

Classes

struct  CoinHashLink
 

Public Member Functions

void convertBoundToSense (const double lower, const double upper, char &sense, double &right, double &range) const
 A quick inlined function to convert from lb/ub style constraint definition to sense/rhs/range style. More...
 
Constructor and Destructor
 CoinLpIO ()
 Default Constructor. More...
 
void gutsOfDestructor ()
 Does the heavy lifting for destruct and assignment. More...
 
void gutsOfCopy (const CoinLpIO &)
 Does the heavy lifting for copy and assignment. More...
 
CoinLpIOoperator= (const CoinLpIO &rhs)
 assignment operator More...
 
 CoinLpIO (const CoinLpIO &)
 Copy constructor. More...
 
 ~CoinLpIO ()
 Destructor. More...
 
void freePreviousNames (const int section)
 Free the vector previous_names_[section] and set card_previous_names_[section] to 0. More...
 
void freeAll ()
 Free all memory (except memory related to hash tables and objName_). More...
 
Queries
const char * getProblemName () const
 Get the problem name. More...
 
void setProblemName (const char *name)
 Set problem name. More...
 
int getNumCols () const
 Get number of columns. More...
 
int getNumRows () const
 Get number of rows. More...
 
CoinBigIndex getNumElements () const
 Get number of nonzero elements. More...
 
const double * getColLower () const
 Get pointer to array[getNumCols()] of column lower bounds. More...
 
const double * getColUpper () const
 Get pointer to array[getNumCols()] of column upper bounds. More...
 
const double * getRowLower () const
 Get pointer to array[getNumRows()] of row lower bounds. More...
 
const double * getRowUpper () const
 Get pointer to array[getNumRows()] of row upper bounds. More...
 
const char * getRowSense () const
 Get pointer to array[getNumRows()] of constraint senses. More...
 
const double * getRightHandSide () const
 Get pointer to array[getNumRows()] of constraint right-hand sides. More...
 
const double * getRowRange () const
 Get pointer to array[getNumRows()] of row ranges. More...
 
const int getNumObjectives () const
 Get pointer to array[getNumCols()] of objective function coefficients. More...
 
const double * getObjCoefficients () const
 Get pointer to array[getNumCols()] of objective function coefficients. More...
 
const double * getObjCoefficients (int j) const
 Get pointer to array[getNumCols()] of objective function coefficients for objective j. More...
 
const CoinPackedMatrixgetMatrixByRow () const
 Get pointer to row-wise copy of the coefficient matrix. More...
 
const CoinPackedMatrixgetMatrixByCol () const
 Get pointer to column-wise copy of the coefficient matrix. More...
 
const char * getObjName () const
 Get objective function name. More...
 
const char * getObjName (int j) const
 Get objective function name for objective j. More...
 
void getPreviousRowNames (char const *const *prev, int *card_prev) const
 Get pointer to array[*card_prev] of previous row names. More...
 
void getPreviousColNames (char const *const *prev, int *card_prev) const
 Get pointer to array[*card_prev] of previous column names. More...
 
char const *const * getRowNames () const
 Get pointer to array[getNumRows()+1] of row names, including objective function name as last entry. More...
 
char const *const * getColNames () const
 Get pointer to array[getNumCols()] of column names. More...
 
const char * rowName (int index) const
 Return the row name for the specified index. More...
 
const char * columnName (int index) const
 Return the column name for the specified index. More...
 
int rowIndex (const char *name) const
 Return the index for the specified row name. More...
 
int columnIndex (const char *name) const
 Return the index for the specified column name. More...
 
double objectiveOffset () const
 Returns the (constant) objective offset. More...
 
double objectiveOffset (int j) const
 Returns the (constant) objective offset for objective j. More...
 
void setObjectiveOffset (double value)
 Set objective offset. More...
 
bool wasMaximization () const
 Return true if maximization problem reformulated as minimization. More...
 
void setObjectiveOffset (double value, int j)
 Set objective offset. More...
 
bool isInteger (int columnNumber) const
 Return true if a column is an integer (binary or general integer) variable. More...
 
const char * integerColumns () const
 Get characteristic vector of integer variables. More...
 
Parameters
double getInfinity () const
 Get infinity. More...
 
void setInfinity (const double)
 Set infinity. More...
 
double getEpsilon () const
 Get epsilon. More...
 
void setEpsilon (const double)
 Set epsilon. More...
 
int getNumberAcross () const
 Get numberAcross, the number of monomials to be printed per line. More...
 
void setNumberAcross (const int)
 Set numberAcross. More...
 
int getDecimals () const
 Get decimals, the number of digits to write after the decimal point. More...
 
void setDecimals (const int)
 Set decimals. More...
 
Public methods
void setLpDataWithoutRowAndColNames (const CoinPackedMatrix &m, const double *collb, const double *colub, const double *obj_coeff, const char *integrality, const double *rowlb, const double *rowub)
 Set the data of the object. More...
 
void setLpDataWithoutRowAndColNames (const CoinPackedMatrix &m, const double *collb, const double *colub, const double *obj_coeff[MAX_OBJECTIVES], int num_objectives, const char *integrality, const double *rowlb, const double *rowub)
 
int is_invalid_name (const char *buff, const bool ranged) const
 Return 0 if buff is a valid name for a row, a column or objective function, return a positive number otherwise. More...
 
int are_invalid_names (char const *const *vnames, const int card_vnames, const bool check_ranged) const
 Return 0 if each of the card_vnames entries of vnames is a valid name, return a positive number otherwise. More...
 
void setDefaultRowNames ()
 Set objective function name to the default "obj" and row names to the default "cons0", "cons1", ... More...
 
void setDefaultColNames ()
 Set column names to the default "x0", "x1", ... More...
 
void setLpDataRowAndColNames (char const *const *const rownames, char const *const *const colnames)
 Set the row and column names. More...
 
int writeLp (const char *filename, const double epsilon, const int numberAcross, const int decimals, const bool useRowNames=true)
 Write the data in Lp format in the file with name filename. More...
 
int writeLp (FILE *fp, const double epsilon, const int numberAcross, const int decimals, const bool useRowNames=true)
 Write the data in Lp format in the file pointed to by the paramater fp. More...
 
int writeLp (const char *filename, const bool useRowNames=true)
 Write the data in Lp format in the file with name filename. More...
 
int writeLp (FILE *fp, const bool useRowNames=true)
 Write the data in Lp format in the file pointed to by the parameter fp. More...
 
void readLp (const char *filename, const double epsilon)
 Read the data in Lp format from the file with name filename, using the given value for epsilon. More...
 
void readLp (const char *filename)
 Read the data in Lp format from the file with name filename. More...
 
void readLp (FILE *fp, const double epsilon)
 Read the data in Lp format from the file stream, using the given value for epsilon. More...
 
void readLp (FILE *fp)
 Read the data in Lp format from the file stream. More...
 
void readLp ()
 Does work of readLp. More...
 
void print () const
 Dump the data. Low level method for debugging. More...
 
void loadSOS (int numberSets, const CoinSet *sets)
 Load in SOS stuff. More...
 
void loadSOS (int numberSets, const CoinSet **sets)
 Load in SOS stuff. More...
 
int numberSets () const
 Number of SOS sets. More...
 
CoinSet ** setInformation () const
 Set information. More...
 
Message handling
void passInMessageHandler (CoinMessageHandler *handler)
 Pass in Message handler. More...
 
void newLanguage (CoinMessages::Language language)
 Set the language for messages. More...
 
void setLanguage (CoinMessages::Language language)
 Set the language for messages. More...
 
CoinMessageHandlermessageHandler () const
 Return the message handler. More...
 
CoinMessages messages ()
 Return the messages. More...
 
CoinMessagesmessagesPointer ()
 Return the messages pointer. More...
 

Protected Member Functions

int fscanfLpIO (char *buff) const
 Get next string (returns number in) More...
 
int newCardLpIO () const
 Get next line into inputBuffer_ (returns number in) More...
 
void startHash (char const *const *const names, const COINColumnIndex number, int section)
 Build the hash table for the given names. More...
 
void stopHash (int section)
 Delete hash storage. More...
 
COINColumnIndex findHash (const char *name, int section) const
 Return the index of the given name, return -1 if the name is not found. More...
 
void insertHash (const char *thisName, int section)
 Insert thisName in the hash table if not present yet; does nothing if the name is already in. More...
 
void out_coeff (FILE *fp, double v, int print_1) const
 Write a coefficient. More...
 
int find_obj () const
 Locate the objective function. More...
 
int is_subject_to (const char *buff) const
 Return an integer indicating if the keyword "subject to" or one of its variants has been read. More...
 
int first_is_number (const char *buff) const
 Return 1 if the first character of buff is a number. More...
 
int is_comment (const char *buff) const
 Return 1 if the first character of buff is '/' or '\'. More...
 
void skip_comment (char *buff) const
 Read the file fp until buff contains an end of line. More...
 
int is_free (const char *buff) const
 Return 1 if buff is the keyword "free" or one of its variants. More...
 
int is_inf (const char *buff) const
 Return 1 if buff is the keyword "inf" or one of its variants. More...
 
int is_sense (const char *buff) const
 Return an integer indicating the inequality sense read. More...
 
int is_keyword (const char *buff) const
 Return an integer indicating if one of the keywords "Bounds", "Integers", "Generals", "Binaries", "Semi-continuous", "Sos", "End", or one of their variants has been read. More...
 
int read_monom_obj (double *coeff, char **name, int *cnt, char **obj_name, int *num_objectives, int *obj_starts)
 Read a monomial of the objective function. More...
 
int read_monom_row (char *start_str, double *coeff, char **name, int cnt_coeff) const
 Read a monomial of a constraint. More...
 
void realloc_coeff (double **coeff, char ***colNames, int *maxcoeff) const
 Reallocate vectors related to number of coefficients. More...
 
void realloc_row (char ***rowNames, CoinBigIndex **start, double **rhs, double **rowlow, double **rowup, int *maxrow) const
 Reallocate vectors related to rows. More...
 
void realloc_col (double **collow, double **colup, char **is_int, int *maxcol) const
 Reallocate vectors related to columns. More...
 
void read_row (char *buff, double **pcoeff, char ***pcolNames, int *cnt_coeff, int *maxcoeff, double *rhs, double *rowlow, double *rowup, int *cnt_row, double inf) const
 Read a constraint. More...
 
void checkRowNames ()
 Check that current objective name and all row names are distinct including row names obtained by adding "_low" for ranged constraints. More...
 
void checkColNames ()
 Check that current column names are distinct. More...
 

Protected Attributes

char * problemName_
 Problem name. More...
 
CoinMessageHandlerhandler_
 Message handler. More...
 
bool defaultHandler_
 Flag to say if the message handler is the default handler. More...
 
CoinMessages messages_
 Messages. More...
 
int numberRows_
 Number of rows. More...
 
int numberColumns_
 Number of columns. More...
 
CoinBigIndex numberElements_
 Number of elements. More...
 
CoinPackedMatrixmatrixByColumn_
 Pointer to column-wise copy of problem matrix coefficients. More...
 
CoinPackedMatrixmatrixByRow_
 Pointer to row-wise copy of problem matrix coefficients. More...
 
double * rowlower_
 Pointer to dense vector of row lower bounds. More...
 
double * rowupper_
 Pointer to dense vector of row upper bounds. More...
 
double * collower_
 Pointer to dense vector of column lower bounds. More...
 
double * colupper_
 Pointer to dense vector of column upper bounds. More...
 
double * rhs_
 Pointer to dense vector of row rhs. More...
 
double * rowrange_
 Pointer to dense vector of slack variable upper bounds for ranged constraints (undefined for non-ranged constraints) More...
 
char * rowsense_
 Pointer to dense vector of row senses. More...
 
double * objective_ [MAX_OBJECTIVES]
 Pointer to dense vector of objective coefficients. More...
 
int num_objectives_
 Number of objectives. More...
 
double objectiveOffset_ [MAX_OBJECTIVES]
 Constant offset for objective value. More...
 
char * integerType_
 Pointer to dense vector specifying if a variable is continuous (0) or integer (1). More...
 
CoinSet ** set_
 Pointer to sets. More...
 
int numberSets_
 Number of sets. More...
 
char * fileName_
 Current file name. More...
 
double infinity_
 Value to use for infinity. More...
 
double epsilon_
 Value to use for epsilon. More...
 
int numberAcross_
 Number of monomials printed in a row. More...
 
int decimals_
 Number of decimals printed for coefficients. More...
 
char * objName_ [MAX_OBJECTIVES]
 Objective function name. More...
 
bool wasMaximization_
 Maximization reformulation flag. More...
 
char ** previous_names_ [2]
 Row names (including objective function name) and column names when stopHash() for the corresponding section was last called or for initial names (deemed invalid) read from a file. More...
 
int card_previous_names_ [2]
 card_previous_names_[section] holds the number of entries in the vector previous_names_[section]. More...
 
char ** names_ [2]
 Row names (including objective function name) and column names (linked to Hash tables). More...
 
int maxHash_ [2]
 Maximum number of entries in a hash table section. More...
 
int numberHash_ [2]
 Number of entries in a hash table section. More...
 
CoinHashLinkhash_ [2]
 Hash tables with two sections. More...
 
char inputBuffer_ [1028]
 Current buffer (needed so can get rid of blanks with : More...
 
int bufferLength_
 Current buffer length (negative if not got eol) More...
 
int bufferPosition_
 Current buffer position. More...
 
CoinFileInputinput_
 File handler. More...
 
bool eofFound_
 If already inserted one End. More...
 

Friends

void CoinLpIOUnitTest (const std::string &lpDir)
 

Detailed Description

Class to read and write Lp files.

Lp file format:

/ this is a comment
\ this too
Min
obj: x0 + x1 + 3 x2 - 4.5 xyr + 1
s.t.
cons1: x0 - x2 - 2.3 x4 <= 4.2 / this is another comment
c2: x1 + x2 >= 1
cc: x1 + x2 + xyr = 2
Bounds
0 <= x1 <= 3
1 >= x2
x3 = 1
-2 <= x4 <= Inf
xyr free
Integers
x0
Generals
x1 xyr
Binaries
x2
End

Notes:

Definition at line 105 of file CoinLpIO.hpp.

Constructor & Destructor Documentation

CoinLpIO::CoinLpIO ( )

Default Constructor.

CoinLpIO::CoinLpIO ( const CoinLpIO )

Copy constructor.

CoinLpIO::~CoinLpIO ( )

Destructor.

Member Function Documentation

void CoinLpIO::gutsOfDestructor ( )

Does the heavy lifting for destruct and assignment.

void CoinLpIO::gutsOfCopy ( const CoinLpIO )

Does the heavy lifting for copy and assignment.

CoinLpIO& CoinLpIO::operator= ( const CoinLpIO rhs)

assignment operator

void CoinLpIO::freePreviousNames ( const int  section)

Free the vector previous_names_[section] and set card_previous_names_[section] to 0.

section = 0 for row names, section = 1 for column names.

void CoinLpIO::freeAll ( )

Free all memory (except memory related to hash tables and objName_).

void CoinLpIO::convertBoundToSense ( const double  lower,
const double  upper,
char &  sense,
double &  right,
double &  range 
) const
inline

A quick inlined function to convert from lb/ub style constraint definition to sense/rhs/range style.

const char* CoinLpIO::getProblemName ( ) const

Get the problem name.

void CoinLpIO::setProblemName ( const char *  name)

Set problem name.

int CoinLpIO::getNumCols ( ) const

Get number of columns.

int CoinLpIO::getNumRows ( ) const

Get number of rows.

CoinBigIndex CoinLpIO::getNumElements ( ) const

Get number of nonzero elements.

const double* CoinLpIO::getColLower ( ) const

Get pointer to array[getNumCols()] of column lower bounds.

const double* CoinLpIO::getColUpper ( ) const

Get pointer to array[getNumCols()] of column upper bounds.

const double* CoinLpIO::getRowLower ( ) const

Get pointer to array[getNumRows()] of row lower bounds.

const double* CoinLpIO::getRowUpper ( ) const

Get pointer to array[getNumRows()] of row upper bounds.

const char* CoinLpIO::getRowSense ( ) const

Get pointer to array[getNumRows()] of constraint senses.

  • 'L': <= constraint
  • 'E': = constraint
  • 'G': >= constraint
  • 'R': ranged constraint
  • 'N': free constraint
const double* CoinLpIO::getRightHandSide ( ) const

Get pointer to array[getNumRows()] of constraint right-hand sides.

Given constraints with upper (rowupper) and/or lower (rowlower) bounds, the constraint right-hand side (rhs) is set as

  • if rowsense()[i] == 'L' then rhs()[i] == rowupper()[i]
  • if rowsense()[i] == 'G' then rhs()[i] == rowlower()[i]
  • if rowsense()[i] == 'R' then rhs()[i] == rowupper()[i]
  • if rowsense()[i] == 'N' then rhs()[i] == 0.0
const double* CoinLpIO::getRowRange ( ) const

Get pointer to array[getNumRows()] of row ranges.

Given constraints with upper (rowupper) and/or lower (rowlower) bounds, the constraint range (rowrange) is set as

  • if rowsense()[i] == 'R' then rowrange()[i] == rowupper()[i] - rowlower()[i]
  • if rowsense()[i] != 'R' then rowrange()[i] is 0.0

Put another way, only ranged constraints have a nontrivial value for rowrange.

const int CoinLpIO::getNumObjectives ( ) const

Get pointer to array[getNumCols()] of objective function coefficients.

const double* CoinLpIO::getObjCoefficients ( ) const

Get pointer to array[getNumCols()] of objective function coefficients.

const double* CoinLpIO::getObjCoefficients ( int  j) const

Get pointer to array[getNumCols()] of objective function coefficients for objective j.

const CoinPackedMatrix* CoinLpIO::getMatrixByRow ( ) const

Get pointer to row-wise copy of the coefficient matrix.

const CoinPackedMatrix* CoinLpIO::getMatrixByCol ( ) const

Get pointer to column-wise copy of the coefficient matrix.

const char* CoinLpIO::getObjName ( ) const

Get objective function name.

const char* CoinLpIO::getObjName ( int  j) const

Get objective function name for objective j.

void CoinLpIO::getPreviousRowNames ( char const *const *  prev,
int *  card_prev 
) const

Get pointer to array[*card_prev] of previous row names.

The value of *card_prev might be different than getNumRows()+1 if non distinct row names were present or if no previous names were saved or if the object was holding a different problem before.

void CoinLpIO::getPreviousColNames ( char const *const *  prev,
int *  card_prev 
) const

Get pointer to array[*card_prev] of previous column names.

The value of *card_prev might be different than getNumCols() if non distinct column names were present of if no previous names were saved, or if the object was holding a different problem before.

char const* const* CoinLpIO::getRowNames ( ) const

Get pointer to array[getNumRows()+1] of row names, including objective function name as last entry.

char const* const* CoinLpIO::getColNames ( ) const

Get pointer to array[getNumCols()] of column names.

const char* CoinLpIO::rowName ( int  index) const

Return the row name for the specified index.

Return the objective function name if index = getNumRows(). Return 0 if the index is out of range or if row names are not defined.

const char* CoinLpIO::columnName ( int  index) const

Return the column name for the specified index.

Return 0 if the index is out of range or if column names are not defined.

int CoinLpIO::rowIndex ( const char *  name) const

Return the index for the specified row name.

Return getNumRows() for the objective function name. Return -1 if the name is not found.

int CoinLpIO::columnIndex ( const char *  name) const

Return the index for the specified column name.

Return -1 if the name is not found.

double CoinLpIO::objectiveOffset ( ) const

Returns the (constant) objective offset.

double CoinLpIO::objectiveOffset ( int  j) const

Returns the (constant) objective offset for objective j.

void CoinLpIO::setObjectiveOffset ( double  value)
inline

Set objective offset.

Definition at line 283 of file CoinLpIO.hpp.

bool CoinLpIO::wasMaximization ( ) const
inline

Return true if maximization problem reformulated as minimization.

Definition at line 288 of file CoinLpIO.hpp.

void CoinLpIO::setObjectiveOffset ( double  value,
int  j 
)
inline

Set objective offset.

Definition at line 294 of file CoinLpIO.hpp.

bool CoinLpIO::isInteger ( int  columnNumber) const

Return true if a column is an integer (binary or general integer) variable.

const char* CoinLpIO::integerColumns ( ) const

Get characteristic vector of integer variables.

double CoinLpIO::getInfinity ( ) const

Get infinity.

void CoinLpIO::setInfinity ( const double  )

Set infinity.

Any number larger is considered infinity. Default: DBL_MAX

double CoinLpIO::getEpsilon ( ) const

Get epsilon.

void CoinLpIO::setEpsilon ( const double  )

Set epsilon.

Default: 1e-5.

int CoinLpIO::getNumberAcross ( ) const

Get numberAcross, the number of monomials to be printed per line.

void CoinLpIO::setNumberAcross ( const int  )

Set numberAcross.

Default: 10.

int CoinLpIO::getDecimals ( ) const

Get decimals, the number of digits to write after the decimal point.

void CoinLpIO::setDecimals ( const int  )

Set decimals.

Default: 5

void CoinLpIO::setLpDataWithoutRowAndColNames ( const CoinPackedMatrix m,
const double *  collb,
const double *  colub,
const double *  obj_coeff,
const char *  integrality,
const double *  rowlb,
const double *  rowub 
)

Set the data of the object.

Set it from the coefficient matrix m, the lower bounds collb, the upper bounds colub, objective function obj_coeff, integrality vector integrality, lower/upper bounds on the constraints. The sense of optimization of the objective function is assumed to be a minimization. Numbers larger than DBL_MAX (or larger than 1e+400) might crash the code. There are two version. The second one is for setting multiple objectives.

void CoinLpIO::setLpDataWithoutRowAndColNames ( const CoinPackedMatrix m,
const double *  collb,
const double *  colub,
const double *  obj_coeff[MAX_OBJECTIVES],
int  num_objectives,
const char *  integrality,
const double *  rowlb,
const double *  rowub 
)
int CoinLpIO::is_invalid_name ( const char *  buff,
const bool  ranged 
) const

Return 0 if buff is a valid name for a row, a column or objective function, return a positive number otherwise.

If parameter ranged = true, the name is intended for a ranged constraint.
Return 1 if the name has more than 100 characters (96 characters for a ranged constraint name, as "_low" will be added to the name).
Return 2 if the name starts with a number.
Return 3 if the name is not built with the letters a to z, A to Z, the numbers 0 to 9 or the characters " ! # $ % & ( ) . ; ? @ _ ' ` { } ~
Return 4 if the name is a keyword.
Return 5 if the name is empty or NULL.

int CoinLpIO::are_invalid_names ( char const *const *  vnames,
const int  card_vnames,
const bool  check_ranged 
) const

Return 0 if each of the card_vnames entries of vnames is a valid name, return a positive number otherwise.

The return value, if not 0, is the return value of is_invalid_name() for the last invalid name in vnames. If check_ranged = true, the names are row names and names for ranged constaints must be checked for additional restrictions since "_low" will be added to the name if an Lp file is written. When check_ranged = true, card_vnames must have getNumRows()+1 entries, with entry vnames[getNumRows()] being the name of the objective function. For a description of valid names and return values, see the method is_invalid_name().

This method must not be called with check_ranged = true before setLpDataWithoutRowAndColNames() has been called, since access to the indices of all the ranged constraints is required.

void CoinLpIO::setDefaultRowNames ( )

Set objective function name to the default "obj" and row names to the default "cons0", "cons1", ...

void CoinLpIO::setDefaultColNames ( )

Set column names to the default "x0", "x1", ...

void CoinLpIO::setLpDataRowAndColNames ( char const *const *const  rownames,
char const *const *const  colnames 
)

Set the row and column names.

The array rownames must either be NULL or have exactly getNumRows()+1 distinct entries, each of them being a valid name (see is_invalid_name()) and the last entry being the intended name for the objective function. If rownames is NULL, existing row names and objective function name are not changed. If rownames is deemed invalid, default row names and objective function name are used (see setDefaultRowNames()). The memory location of array rownames (or its entries) should not be related to the memory location of the array (or entries) obtained from getRowNames() or getPreviousRowNames(), as the call to setLpDataRowAndColNames() modifies the corresponding arrays. Unpredictable results are obtained if this requirement is ignored.

Similar remarks apply to the array colnames, which must either be NULL or have exactly getNumCols() entries.

int CoinLpIO::writeLp ( const char *  filename,
const double  epsilon,
const int  numberAcross,
const int  decimals,
const bool  useRowNames = true 
)

Write the data in Lp format in the file with name filename.

Coefficients with value less than epsilon away from an integer value are written as integers. Write at most numberAcross monomials on a line. Write non integer numbers with decimals digits after the decimal point. Write objective function name and row names if useRowNames = true.

Ranged constraints are written as two constraints. If row names are used, the upper bound constraint has the name of the original ranged constraint and the lower bound constraint has for name the original name with "_low" as suffix. If doing so creates two identical row names, default row names are used (see setDefaultRowNames()).

int CoinLpIO::writeLp ( FILE *  fp,
const double  epsilon,
const int  numberAcross,
const int  decimals,
const bool  useRowNames = true 
)

Write the data in Lp format in the file pointed to by the paramater fp.

Coefficients with value less than epsilon away from an integer value are written as integers. Write at most numberAcross monomials on a line. Write non integer numbers with decimals digits after the decimal point. Write objective function name and row names if useRowNames = true.

Ranged constraints are written as two constraints. If row names are used, the upper bound constraint has the name of the original ranged constraint and the lower bound constraint has for name the original name with "_low" as suffix. If doing so creates two identical row names, default row names are used (see setDefaultRowNames()).

int CoinLpIO::writeLp ( const char *  filename,
const bool  useRowNames = true 
)

Write the data in Lp format in the file with name filename.

Write objective function name and row names if useRowNames = true.

int CoinLpIO::writeLp ( FILE *  fp,
const bool  useRowNames = true 
)

Write the data in Lp format in the file pointed to by the parameter fp.

Write objective function name and row names if useRowNames = true.

void CoinLpIO::readLp ( const char *  filename,
const double  epsilon 
)

Read the data in Lp format from the file with name filename, using the given value for epsilon.

If the original problem is a maximization problem, the objective function is immediadtly flipped to get a minimization problem.

void CoinLpIO::readLp ( const char *  filename)

Read the data in Lp format from the file with name filename.

If the original problem is a maximization problem, the objective function is immediadtly flipped to get a minimization problem.

void CoinLpIO::readLp ( FILE *  fp,
const double  epsilon 
)

Read the data in Lp format from the file stream, using the given value for epsilon.

If the original problem is a maximization problem, the objective function is immediadtly flipped to get a minimization problem.

void CoinLpIO::readLp ( FILE *  fp)

Read the data in Lp format from the file stream.

If the original problem is a maximization problem, the objective function is immediadtly flipped to get a minimization problem.

void CoinLpIO::readLp ( )

Does work of readLp.

void CoinLpIO::print ( ) const

Dump the data. Low level method for debugging.

void CoinLpIO::loadSOS ( int  numberSets,
const CoinSet sets 
)

Load in SOS stuff.

void CoinLpIO::loadSOS ( int  numberSets,
const CoinSet **  sets 
)

Load in SOS stuff.

int CoinLpIO::numberSets ( ) const
inline

Number of SOS sets.

Definition at line 513 of file CoinLpIO.hpp.

CoinSet** CoinLpIO::setInformation ( ) const
inline

Set information.

Definition at line 519 of file CoinLpIO.hpp.

void CoinLpIO::passInMessageHandler ( CoinMessageHandler handler)

Pass in Message handler.

Supply a custom message handler. It will not be destroyed when the CoinMpsIO object is destroyed.

void CoinLpIO::newLanguage ( CoinMessages::Language  language)

Set the language for messages.

void CoinLpIO::setLanguage ( CoinMessages::Language  language)
inline

Set the language for messages.

Definition at line 537 of file CoinLpIO.hpp.

CoinMessageHandler* CoinLpIO::messageHandler ( ) const
inline

Return the message handler.

Definition at line 540 of file CoinLpIO.hpp.

CoinMessages CoinLpIO::messages ( )
inline

Return the messages.

Definition at line 543 of file CoinLpIO.hpp.

CoinMessages* CoinLpIO::messagesPointer ( )
inline

Return the messages pointer.

Definition at line 545 of file CoinLpIO.hpp.

int CoinLpIO::fscanfLpIO ( char *  buff) const
protected

Get next string (returns number in)

int CoinLpIO::newCardLpIO ( ) const
protected

Get next line into inputBuffer_ (returns number in)

void CoinLpIO::startHash ( char const *const *const  names,
const COINColumnIndex  number,
int  section 
)
protected

Build the hash table for the given names.

The parameter number is the cardinality of parameter names. Remove duplicate names.

section = 0 for row names, section = 1 for column names.

void CoinLpIO::stopHash ( int  section)
protected

Delete hash storage.

If section = 0, it also frees objName_. section = 0 for row names, section = 1 for column names.

COINColumnIndex CoinLpIO::findHash ( const char *  name,
int  section 
) const
protected

Return the index of the given name, return -1 if the name is not found.

Return getNumRows() for the objective function name. section = 0 for row names (including objective function name), section = 1 for column names.

void CoinLpIO::insertHash ( const char *  thisName,
int  section 
)
protected

Insert thisName in the hash table if not present yet; does nothing if the name is already in.

section = 0 for row names, section = 1 for column names.

void CoinLpIO::out_coeff ( FILE *  fp,
double  v,
int  print_1 
) const
protected

Write a coefficient.

print_1 = 0 : do not print the value 1.

int CoinLpIO::find_obj ( ) const
protected

Locate the objective function.

Return 1 if found the keyword "Minimize" or one of its variants, -1 if found keyword "Maximize" or one of its variants.

int CoinLpIO::is_subject_to ( const char *  buff) const
protected

Return an integer indicating if the keyword "subject to" or one of its variants has been read.

Return 1 if buff is the keyword "s.t" or one of its variants. Return 2 if buff is the keyword "subject" or one of its variants. Return 0 otherwise.

int CoinLpIO::first_is_number ( const char *  buff) const
protected

Return 1 if the first character of buff is a number.

Return 0 otherwise.

int CoinLpIO::is_comment ( const char *  buff) const
protected

Return 1 if the first character of buff is '/' or '\'.

Return 0 otherwise.

void CoinLpIO::skip_comment ( char *  buff) const
protected

Read the file fp until buff contains an end of line.

int CoinLpIO::is_free ( const char *  buff) const
protected

Return 1 if buff is the keyword "free" or one of its variants.

Return 0 otherwise.

int CoinLpIO::is_inf ( const char *  buff) const
protected

Return 1 if buff is the keyword "inf" or one of its variants.

Return 0 otherwise.

int CoinLpIO::is_sense ( const char *  buff) const
protected

Return an integer indicating the inequality sense read.

Return 0 if buff is '<='. Return 1 if buff is '='. Return 2 if buff is '>='. Return -1 otherwise.

int CoinLpIO::is_keyword ( const char *  buff) const
protected

Return an integer indicating if one of the keywords "Bounds", "Integers", "Generals", "Binaries", "Semi-continuous", "Sos", "End", or one of their variants has been read.

(note Semi-continuous not coded) Return 1 if buff is the keyword "Bounds" or one of its variants. Return 2 if buff is the keyword "Integers" or "Generals" or one of their variants. Return 3 if buff is the keyword "Binaries" or one of its variants. Return 4 if buff is the keyword "Semi-continuous" or one of its variants. Return 5 if buff is the keyword "Sos" or one of its variants. Return 6 if buff is the keyword "End" or one of its variants. Return 0 otherwise.

int CoinLpIO::read_monom_obj ( double *  coeff,
char **  name,
int *  cnt,
char **  obj_name,
int *  num_objectives,
int *  obj_starts 
)
protected

Read a monomial of the objective function.

Return 1 if "subject to" or one of its variants has been read.

int CoinLpIO::read_monom_row ( char *  start_str,
double *  coeff,
char **  name,
int  cnt_coeff 
) const
protected

Read a monomial of a constraint.

Return a positive number if the sense of the inequality has been read (see method is_sense() for the return code). Return -1 otherwise.

void CoinLpIO::realloc_coeff ( double **  coeff,
char ***  colNames,
int *  maxcoeff 
) const
protected

Reallocate vectors related to number of coefficients.

void CoinLpIO::realloc_row ( char ***  rowNames,
CoinBigIndex **  start,
double **  rhs,
double **  rowlow,
double **  rowup,
int *  maxrow 
) const
protected

Reallocate vectors related to rows.

void CoinLpIO::realloc_col ( double **  collow,
double **  colup,
char **  is_int,
int *  maxcol 
) const
protected

Reallocate vectors related to columns.

void CoinLpIO::read_row ( char *  buff,
double **  pcoeff,
char ***  pcolNames,
int *  cnt_coeff,
int *  maxcoeff,
double *  rhs,
double *  rowlow,
double *  rowup,
int *  cnt_row,
double  inf 
) const
protected

Read a constraint.

void CoinLpIO::checkRowNames ( )
protected

Check that current objective name and all row names are distinct including row names obtained by adding "_low" for ranged constraints.

If there is a conflict in the names, they are replaced by default row names (see setDefaultRowNames()).

This method must not be called before setLpDataWithoutRowAndColNames() has been called, since access to the indices of all the ranged constraints is required.

This method must not be called before setLpDataRowAndColNames() has been called, since access to all the row names is required.

void CoinLpIO::checkColNames ( )
protected

Check that current column names are distinct.

If not, they are replaced by default column names (see setDefaultColNames()).

This method must not be called before setLpDataRowAndColNames() has been called, since access to all the column names is required.

Friends And Related Function Documentation

void CoinLpIOUnitTest ( const std::string &  lpDir)
friend

Member Data Documentation

char* CoinLpIO::problemName_
protected

Problem name.

Definition at line 550 of file CoinLpIO.hpp.

CoinMessageHandler* CoinLpIO::handler_
protected

Message handler.

Definition at line 553 of file CoinLpIO.hpp.

bool CoinLpIO::defaultHandler_
protected

Flag to say if the message handler is the default handler.

If true, the handler will be destroyed when the CoinMpsIO object is destroyed; if false, it will not be destroyed.

Definition at line 559 of file CoinLpIO.hpp.

CoinMessages CoinLpIO::messages_
protected

Messages.

Definition at line 561 of file CoinLpIO.hpp.

int CoinLpIO::numberRows_
protected

Number of rows.

Definition at line 564 of file CoinLpIO.hpp.

int CoinLpIO::numberColumns_
protected

Number of columns.

Definition at line 567 of file CoinLpIO.hpp.

CoinBigIndex CoinLpIO::numberElements_
protected

Number of elements.

Definition at line 570 of file CoinLpIO.hpp.

CoinPackedMatrix* CoinLpIO::matrixByColumn_
mutableprotected

Pointer to column-wise copy of problem matrix coefficients.

Definition at line 573 of file CoinLpIO.hpp.

CoinPackedMatrix* CoinLpIO::matrixByRow_
protected

Pointer to row-wise copy of problem matrix coefficients.

Definition at line 576 of file CoinLpIO.hpp.

double* CoinLpIO::rowlower_
protected

Pointer to dense vector of row lower bounds.

Definition at line 579 of file CoinLpIO.hpp.

double* CoinLpIO::rowupper_
protected

Pointer to dense vector of row upper bounds.

Definition at line 582 of file CoinLpIO.hpp.

double* CoinLpIO::collower_
protected

Pointer to dense vector of column lower bounds.

Definition at line 585 of file CoinLpIO.hpp.

double* CoinLpIO::colupper_
protected

Pointer to dense vector of column upper bounds.

Definition at line 588 of file CoinLpIO.hpp.

double* CoinLpIO::rhs_
mutableprotected

Pointer to dense vector of row rhs.

Definition at line 591 of file CoinLpIO.hpp.

double* CoinLpIO::rowrange_
mutableprotected

Pointer to dense vector of slack variable upper bounds for ranged constraints (undefined for non-ranged constraints)

Definition at line 596 of file CoinLpIO.hpp.

char* CoinLpIO::rowsense_
mutableprotected

Pointer to dense vector of row senses.

Definition at line 599 of file CoinLpIO.hpp.

double* CoinLpIO::objective_[MAX_OBJECTIVES]
protected

Pointer to dense vector of objective coefficients.

Definition at line 602 of file CoinLpIO.hpp.

int CoinLpIO::num_objectives_
protected

Number of objectives.

Definition at line 605 of file CoinLpIO.hpp.

double CoinLpIO::objectiveOffset_[MAX_OBJECTIVES]
protected

Constant offset for objective value.

Definition at line 608 of file CoinLpIO.hpp.

char* CoinLpIO::integerType_
protected

Pointer to dense vector specifying if a variable is continuous (0) or integer (1).

Added (3) sc (4) sc int.

Definition at line 612 of file CoinLpIO.hpp.

CoinSet** CoinLpIO::set_
protected

Pointer to sets.

Definition at line 615 of file CoinLpIO.hpp.

int CoinLpIO::numberSets_
protected

Number of sets.

Definition at line 618 of file CoinLpIO.hpp.

char* CoinLpIO::fileName_
protected

Current file name.

Definition at line 621 of file CoinLpIO.hpp.

double CoinLpIO::infinity_
protected

Value to use for infinity.

Definition at line 624 of file CoinLpIO.hpp.

double CoinLpIO::epsilon_
protected

Value to use for epsilon.

Definition at line 627 of file CoinLpIO.hpp.

int CoinLpIO::numberAcross_
protected

Number of monomials printed in a row.

Definition at line 630 of file CoinLpIO.hpp.

int CoinLpIO::decimals_
protected

Number of decimals printed for coefficients.

Definition at line 633 of file CoinLpIO.hpp.

char* CoinLpIO::objName_[MAX_OBJECTIVES]
protected

Objective function name.

Definition at line 636 of file CoinLpIO.hpp.

bool CoinLpIO::wasMaximization_
protected

Maximization reformulation flag.

Definition at line 639 of file CoinLpIO.hpp.

char** CoinLpIO::previous_names_[2]
protected

Row names (including objective function name) and column names when stopHash() for the corresponding section was last called or for initial names (deemed invalid) read from a file.


section = 0 for row names, section = 1 for column names.

Definition at line 647 of file CoinLpIO.hpp.

int CoinLpIO::card_previous_names_[2]
protected

card_previous_names_[section] holds the number of entries in the vector previous_names_[section].

section = 0 for row names, section = 1 for column names.

Definition at line 653 of file CoinLpIO.hpp.

char** CoinLpIO::names_[2]
protected

Row names (including objective function name) and column names (linked to Hash tables).

section = 0 for row names, section = 1 for column names.

Definition at line 659 of file CoinLpIO.hpp.

int CoinLpIO::maxHash_[2]
protected

Maximum number of entries in a hash table section.

section = 0 for row names, section = 1 for column names.

Definition at line 668 of file CoinLpIO.hpp.

int CoinLpIO::numberHash_[2]
protected

Number of entries in a hash table section.

section = 0 for row names, section = 1 for column names.

Definition at line 673 of file CoinLpIO.hpp.

CoinHashLink* CoinLpIO::hash_[2]
mutableprotected

Hash tables with two sections.

section = 0 for row names (including objective function name), section = 1 for column names.

Definition at line 678 of file CoinLpIO.hpp.

char CoinLpIO::inputBuffer_[1028]
mutableprotected

Current buffer (needed so can get rid of blanks with :

Definition at line 681 of file CoinLpIO.hpp.

int CoinLpIO::bufferLength_
mutableprotected

Current buffer length (negative if not got eol)

Definition at line 683 of file CoinLpIO.hpp.

int CoinLpIO::bufferPosition_
mutableprotected

Current buffer position.

Definition at line 685 of file CoinLpIO.hpp.

CoinFileInput* CoinLpIO::input_
protected

File handler.

Definition at line 687 of file CoinLpIO.hpp.

bool CoinLpIO::eofFound_
mutableprotected

If already inserted one End.

Definition at line 689 of file CoinLpIO.hpp.


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