# CoinLpIO Class Reference

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

`#include <CoinLpIO.hpp>`

Collaboration diagram for CoinLpIO:
[legend]

List of all members.

## 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.
Constructor and Destructor
| CoinLpIO ()
| Default Constructor.
void | gutsOfDestructor ()
| Does the heavy lifting for destruct and assignment.
void | gutsOfCopy (const CoinLpIO &)
| Does the heavy lifting for copy and assignment.
CoinLpIO & | operator= (const CoinLpIO &rhs)
| assignment operator
| CoinLpIO (const CoinLpIO &)
| Copy constructor.
| ~CoinLpIO ()
| Destructor.
void | freePreviousNames (const int section)
| Free the vector previous_names_[section] and set card_previous_names_[section] to 0.
void | freeAll ()
| Free all memory (except memory related to hash tables and objName_).
Queries
const char * | getProblemName () const
| Get the problem name.
void | setProblemName (const char *name)
| Set problem name.
int | getNumCols () const
| Get number of columns.
int | getNumRows () const
| Get number of rows.
int | getNumElements () const
| Get number of nonzero elements.
const double * | getColLower () const
| Get pointer to array[getNumCols()] of column lower bounds.
const double * | getColUpper () const
| Get pointer to array[getNumCols()] of column upper bounds.
const double * | getRowLower () const
| Get pointer to array[getNumRows()] of row lower bounds.
const double * | getRowUpper () const
| Get pointer to array[getNumRows()] of row upper bounds.
const char * | getRowSense () const
| Get pointer to array[getNumRows()] of constraint senses.
const double * | getRightHandSide () const
| Get pointer to array[getNumRows()] of constraint right-hand sides.
const double * | getRowRange () const
| Get pointer to array[getNumRows()] of row ranges.
const double * | getObjCoefficients () const
| Get pointer to array[getNumCols()] of objective function coefficients.
const CoinPackedMatrix * | getMatrixByRow () const
| Get pointer to row-wise copy of the coefficient matrix.
const CoinPackedMatrix * | getMatrixByCol () const
| Get pointer to column-wise copy of the coefficient matrix.
const char * | getObjName () const
| Get objective function name.
void | getPreviousRowNames (char const *const *prev, int *card_prev) const
| Get pointer to array[*card_prev] of previous row names.
void | getPreviousColNames (char const *const *prev, int *card_prev) const
| Get pointer to array[*card_prev] of previous column names.
char const *const * | getRowNames () const
| Get pointer to array[getNumRows()+1] of row names, including objective function name as last entry.
char const *const * | getColNames () const
| Get pointer to array[getNumCols()] of column names.
const char * | rowName (int index) const
| Return the row name for the specified index.
const char * | columnName (int index) const
| Return the column name for the specified index.
int | rowIndex (const char *name) const
| Return the index for the specified row name.
int | columnIndex (const char *name) const
| Return the index for the specified column name.
double | objectiveOffset () const
| Returns the (constant) objective offset.
void | setObjectiveOffset (double value)
| Set objective offset.
bool | isInteger (int columnNumber) const
| Return true if a column is an integer (binary or general integer) variable.
const char * | integerColumns () const
| Get characteristic vector of integer variables.
Parameters
double | getInfinity () const
| Get infinity.
void | setInfinity (const double)
| Set infinity.
double | getEpsilon () const
| Get epsilon.
void | setEpsilon (const double)
| Set epsilon.
int | getNumberAcross () const
| Get numberAcross, the number of monomials to be printed per line.
void | setNumberAcross (const int)
| Set numberAcross.
int | getDecimals () const
| Get decimals, the number of digits to write after the decimal point.
void | setDecimals (const int)
| Set decimals.
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.
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.
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.
void | setDefaultRowNames ()
| Set objective function name to the default "obj" and row names to the default "cons0", "cons1", .
void | setDefaultColNames ()
| Set column names to the default "x0", "x1", ...
void | setLpDataRowAndColNames (char const *const *const rownames, char const *const *const colnames)
| Set the row and column names.
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.
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.
int | writeLp (const char *filename, const bool useRowNames=true)
| Write the data in Lp format in the file with name filename.
int | writeLp (FILE *fp, const bool useRowNames=true)
| Write the data in Lp format in the file pointed to by the parameter fp.
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.
void | readLp (const char *filename)
| Read the data in Lp format from the file with name filename.
void | readLp (FILE *fp, const double epsilon)
| Read the data in Lp format from the file stream, using the given value for epsilon.
void | readLp (FILE *fp)
| Read the data in Lp format from the file stream.
void | print () const
| Dump the data. Low level method for debugging.
Message handling
void | passInMessageHandler (CoinMessageHandler *handler)
| Pass in Message handler.
void | newLanguage (CoinMessages::Language language)
| Set the language for messages.
void | setLanguage (CoinMessages::Language language)
| Set the language for messages.
CoinMessageHandler * | messageHandler () const
| Return the message handler.
CoinMessages | messages ()
| Return the messages.
CoinMessages * | messagesPointer ()
| Return the messages pointer.
## Protected Member Functions
void | startHash (char const *const *const names, const COINColumnIndex number, int section)
| Build the hash table for the given names.
void | stopHash (int section)
| Delete hash storage.
COINColumnIndex | findHash (const char *name, int section) const
| Return the index of the given name, return -1 if the name is not found.
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.
void | out_coeff (FILE *fp, double v, int print_1) const
| Write a coefficient.
int | find_obj (FILE *fp) const
| Locate the objective function.
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.
int | first_is_number (const char *buff) const
| Return 1 if the first character of buff is a number.
int | is_comment (const char *buff) const
| Return 1 if the first character of buff is '/' or '\'.
void | skip_comment (char *buff, FILE *fp) const
| Read the file fp until buff contains an end of line.
void | scan_next (char *buff, FILE *fp) const
| Put in buff the next string that is not part of a comment.
int | is_free (const char *buff) const
| Return 1 if buff is the keyword "free" or one of its variants.
int | is_inf (const char *buff) const
| Return 1 if buff is the keyword "inf" or one of its variants.
int | is_sense (const char *buff) const
| Return an integer indicating the inequality sense read.
int | is_keyword (const char *buff) const
| Return an integer indicating if one of the keywords "Bounds", "Integers", "Generals", "Binaries", "End", or one of their variants has been read.
int | read_monom_obj (FILE *fp, double *coeff, char **name, int *cnt, char **obj_name)
| Read a monomial of the objective function.
int | read_monom_row (FILE *fp, char *start_str, double *coeff, char **name, int cnt_coeff) const
| Read a monomial of a constraint.
void | realloc_coeff (double **coeff, char ***colNames, int *maxcoeff) const
| Reallocate vectors related to number of coefficients.
void | realloc_row (char ***rowNames, int **start, double **rhs, double **rowlow, double **rowup, int *maxrow) const
| Reallocate vectors related to rows.
void | realloc_col (double **collow, double **colup, char **is_int, int *maxcol) const
| Reallocate vectors related to columns.
void | read_row (FILE *fp, 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.
void | checkRowNames ()
| Check that current objective name and all row names are distinct including row names obtained by adding "_low" for ranged constraints.
void | checkColNames ()
| Check that current column names are distinct.
## Protected Attributes
char * | problemName_
| Problem name.
CoinMessageHandler * | handler_
| Message handler.
bool | defaultHandler_
| Flag to say if the message handler is the default handler.
CoinMessages | messages_
| Messages.
int | numberRows_
| Number of rows.
int | numberColumns_
| Number of columns.
int | numberElements_
| Number of elements.
CoinPackedMatrix * | matrixByColumn_
| Pointer to column-wise copy of problem matrix coefficients.
CoinPackedMatrix * | matrixByRow_
| Pointer to row-wise copy of problem matrix coefficients.
double * | rowlower_
| Pointer to dense vector of row lower bounds.
double * | rowupper_
| Pointer to dense vector of row upper bounds.
double * | collower_
| Pointer to dense vector of column lower bounds.
double * | colupper_
| Pointer to dense vector of column upper bounds.
double * | rhs_
| Pointer to dense vector of row rhs.
double * | rowrange_
| Pointer to dense vector of slack variable upper bounds for ranged constraints (undefined for non-ranged constraints).
char * | rowsense_
| Pointer to dense vector of row senses.
double * | objective_
| Pointer to dense vector of objective coefficients.
double | objectiveOffset_
| Constant offset for objective value.
char * | integerType_
| Pointer to dense vector specifying if a variable is continuous (0) or integer (1).
char * | fileName_
| Current file name.
double | infinity_
| Value to use for infinity.
double | epsilon_
| Value to use for epsilon.
int | numberAcross_
| Number of monomials printed in a row.
int | decimals_
| Number of decimals printed for coefficients.
char * | objName_
| Objective function name.
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.
int | card_previous_names_ [2]
| card_previous_names_[section] holds the number of entries in the vector previous_names_[section].
char ** | names_ [2]
| Row names (including objective function name) and column names (linked to Hash tables).
int | maxHash_ [2]
| Maximum number of entries in a hash table section.
int | numberHash_ [2]
| Number of entries in a hash table section.
CoinHashLink * | hash_ [2]
| Hash tables with two sections.
## 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:

- Keywords are: Min, Max, Minimize, Maximize, s.t., Subject To, Bounds, Integers, Generals, Binaries, End, Free, Inf.
- Keywords are not case sensitive and may be in plural or singular form. They should not be used as objective, row or column names.
- Bounds, Integers, Generals, Binaries sections are optional.
- Generals and Integers are synonymous.
- Bounds section (if any) must come before Integers, Generals, and Binaries sections.
- Row names must be followed by ':' without blank space. Row names are optional. If row names are present, they must be distinct (if the k-th constraint has no given name, its name is set automatically to "consk" for k=0,...,). For valid row names, see the method is_invalid_name().
- Column names must be followed by a blank space. They must be distinct. For valid column names, see the method is_invalid_name().
- The objective function name must be followed by ':' without blank space. Objective function name is optional (if no objective function name is given, it is set to "obj" by default). For valid objective function names, see the method is_invalid_name().
- Ranged constraints are written as two constraints. If a name is given for a ranged constraint, the upper bound constraint has that name and the lower bound constraint has that name with "_low" as suffix. This should be kept in mind when assigning names to ranged constraint, as the resulting name must be distinct from all the other names and be considered valid by the method is_invalid_name().
- At most one term related to any single variable may appear in the objective function; if more than one term are present, only the last one is taken into account. At most one constant term may appear in the objective function; if present, it must appear last.
- Default bounds are 0 for lower bound and +infinity for upper bound.
- Free variables get default lower bound -infinity and default upper bound +infinity. Writing "x0 Free" in an LP file means "set lower bound on x0 to -infinity".
- If more than one upper (resp. lower) bound on a variable appears in the Bounds section, the last one is the one taken into account. The bounds for a binary variable are set to 0/1 only if this bound is stronger than the bound obtained from the Bounds section.
- Numbers larger than DBL_MAX (or larger than 1e+400) in the input file might crash the code.
- A comment must start with '\' or '/'. That symbol must either be the first character of a line or be preceded by a blank space. The comment ends at the end of the line. Comments are skipped while reading an Lp file and they may be inserted anywhere.

Definition at line 99 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.

int 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 double* CoinLpIO::getObjCoefficients | ( |  | ) | const

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

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.

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.

void CoinLpIO::setObjectiveOffset | ( | double | value | ) | `[inline]`

Set objective offset.

Definition at line 265 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.

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::print | ( |  | ) | const

Dump the data. Low level method for debugging.

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 477 of file CoinLpIO.hpp.

CoinMessageHandler* CoinLpIO::messageHandler | ( |  | ) | const`[inline]`

Return the message handler.

Definition at line 480 of file CoinLpIO.hpp.

CoinMessages CoinLpIO::messages | ( |  | ) | `[inline]`

Return the messages.

Definition at line 483 of file CoinLpIO.hpp.

CoinMessages* CoinLpIO::messagesPointer | ( |  | ) | `[inline]`

Return the messages pointer.

Definition at line 485 of file CoinLpIO.hpp.

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 | ( | FILE * | fp | ) | 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,
|  | FILE * | fp |
| ) |  |  | const`[protected]`

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

void CoinLpIO::scan_next | ( | char * | buff,
|  | FILE * | fp |
| ) |  |  | const`[protected]`

Put in buff the next string that is not part of a comment.

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", "End", or one of their variants has been read.

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 "End" or one of its variants. Return 0 otherwise.

int CoinLpIO::read_monom_obj | ( | FILE * | fp,
|  | double * | coeff,
|  | char ** | name,
|  | int * | cnt,
|  | char ** | obj_name |
| ) |  |  | `[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 | ( | FILE * | fp,
|  | 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,
|  | int ** | 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 | ( | FILE * | fp,
|  | 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 490 of file CoinLpIO.hpp.

CoinMessageHandler* CoinLpIO::handler_`[protected]`

Message handler.

Definition at line 493 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 499 of file CoinLpIO.hpp.

CoinMessages CoinLpIO::messages_`[protected]`

Messages.

Definition at line 501 of file CoinLpIO.hpp.

int CoinLpIO::numberRows_`[protected]`

Number of rows.

Definition at line 504 of file CoinLpIO.hpp.

int CoinLpIO::numberColumns_`[protected]`

Number of columns.

Definition at line 507 of file CoinLpIO.hpp.

int CoinLpIO::numberElements_`[protected]`

Number of elements.

Definition at line 510 of file CoinLpIO.hpp.

CoinPackedMatrix* CoinLpIO::matrixByColumn_`[mutable, protected]`

Pointer to column-wise copy of problem matrix coefficients.

Definition at line 513 of file CoinLpIO.hpp.

CoinPackedMatrix* CoinLpIO::matrixByRow_`[protected]`

Pointer to row-wise copy of problem matrix coefficients.

Definition at line 516 of file CoinLpIO.hpp.

double* CoinLpIO::rowlower_`[protected]`

Pointer to dense vector of row lower bounds.

Definition at line 519 of file CoinLpIO.hpp.

double* CoinLpIO::rowupper_`[protected]`

Pointer to dense vector of row upper bounds.

Definition at line 522 of file CoinLpIO.hpp.

double* CoinLpIO::collower_`[protected]`

Pointer to dense vector of column lower bounds.

Definition at line 525 of file CoinLpIO.hpp.

double* CoinLpIO::colupper_`[protected]`

Pointer to dense vector of column upper bounds.

Definition at line 528 of file CoinLpIO.hpp.

double* CoinLpIO::rhs_`[mutable, protected]`

Pointer to dense vector of row rhs.

Definition at line 531 of file CoinLpIO.hpp.

double* CoinLpIO::rowrange_`[mutable, protected]`

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

Definition at line 536 of file CoinLpIO.hpp.

char* CoinLpIO::rowsense_`[mutable, protected]`

Pointer to dense vector of row senses.

Definition at line 539 of file CoinLpIO.hpp.

double* CoinLpIO::objective_`[protected]`

Pointer to dense vector of objective coefficients.

Definition at line 542 of file CoinLpIO.hpp.

double CoinLpIO::objectiveOffset_`[protected]`

Constant offset for objective value.

Definition at line 545 of file CoinLpIO.hpp.

char* CoinLpIO::integerType_`[protected]`

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

Definition at line 549 of file CoinLpIO.hpp.

char* CoinLpIO::fileName_`[protected]`

Current file name.

Definition at line 552 of file CoinLpIO.hpp.

double CoinLpIO::infinity_`[protected]`

Value to use for infinity.

Definition at line 555 of file CoinLpIO.hpp.

double CoinLpIO::epsilon_`[protected]`

Value to use for epsilon.

Definition at line 558 of file CoinLpIO.hpp.

int CoinLpIO::numberAcross_`[protected]`

Number of monomials printed in a row.

Definition at line 561 of file CoinLpIO.hpp.

int CoinLpIO::decimals_`[protected]`

Number of decimals printed for coefficients.

Definition at line 564 of file CoinLpIO.hpp.

char* CoinLpIO::objName_`[protected]`

Objective function name.

Definition at line 567 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 575 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 581 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 587 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 596 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 601 of file CoinLpIO.hpp.

CoinHashLink* CoinLpIO::hash_[2]`[mutable, protected]`

Hash tables with two sections.

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

Definition at line 606 of file CoinLpIO.hpp.

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

- /home/coin/svn-release/Alps-1.4.8/CoinUtils/src/CoinLpIO.hpp