Osi 0.107.9

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:
[legend]

## 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...
CoinLpIO & | operator= (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...
int | 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 CoinPackedMatrix * | getMatrixByRow () const
| Get pointer to row-wise copy of the coefficient matrix. More...
const CoinPackedMatrix * | getMatrixByCol () 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...
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 | 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...
CoinMessageHandler * | messageHandler () const
| Return the message handler. More...
CoinMessages | messages ()
| Return the messages. More...
CoinMessages * | messagesPointer ()
| Return the messages pointer. More...

## Protected Member Functions
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 (FILE *fp) 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, FILE *fp) const
| Read the file fp until buff contains an end of line. More...
void | scan_next (char *buff, FILE *fp) const
| Put in buff the next string that is not part of a comment. 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 (FILE *fp, 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 (FILE *fp, 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, int **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 (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. 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...
CoinMessageHandler * | handler_
| 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...
int | numberElements_
| Number of elements. More...
CoinPackedMatrix * | matrixByColumn_
| Pointer to column-wise copy of problem matrix coefficients. More...
CoinPackedMatrix * | matrixByRow_
| 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...
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...
CoinHashLink * | hash_ [2]
| Hash tables with two sections. 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:

- 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().
- Multiple objectives may be specified, but when there are multiple objectives, they must have names (to indicate where each one starts).
- The objective function names must be followed by ':' without blank space. If there is a single objective, the objective function name is optional. If no name is given, the name 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 104 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 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 282 of file CoinLpIO.hpp.

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

Set objective offset.

Definition at line 286 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::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 501 of file CoinLpIO.hpp.

CoinSet** CoinLpIO::setInformation | ( |  | ) | const
| inline

Set information.

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

CoinMessageHandler* CoinLpIO::messageHandler | ( |  | ) | const
| inline

Return the message handler.

Definition at line 524 of file CoinLpIO.hpp.

CoinMessages CoinLpIO::messages | ( |  | ) |
| inline

Return the messages.

Definition at line 527 of file CoinLpIO.hpp.

CoinMessages* CoinLpIO::messagesPointer | ( |  | ) |
| inline

Return the messages pointer.

Definition at line 529 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", "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 | ( | FILE * | fp,
|  | 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 | ( | 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 534 of file CoinLpIO.hpp.

CoinMessageHandler* CoinLpIO::handler_
| protected

Message handler.

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

CoinMessages CoinLpIO::messages_
| protected

Messages.

Definition at line 545 of file CoinLpIO.hpp.

int CoinLpIO::numberRows_
| protected

Number of rows.

Definition at line 548 of file CoinLpIO.hpp.

int CoinLpIO::numberColumns_
| protected

Number of columns.

Definition at line 551 of file CoinLpIO.hpp.

int CoinLpIO::numberElements_
| protected

Number of elements.

Definition at line 554 of file CoinLpIO.hpp.

CoinPackedMatrix* CoinLpIO::matrixByColumn_
| mutable protected

Pointer to column-wise copy of problem matrix coefficients.

Definition at line 557 of file CoinLpIO.hpp.

CoinPackedMatrix* CoinLpIO::matrixByRow_
| protected

Pointer to row-wise copy of problem matrix coefficients.

Definition at line 560 of file CoinLpIO.hpp.

double* CoinLpIO::rowlower_
| protected

Pointer to dense vector of row lower bounds.

Definition at line 563 of file CoinLpIO.hpp.

double* CoinLpIO::rowupper_
| protected

Pointer to dense vector of row upper bounds.

Definition at line 566 of file CoinLpIO.hpp.

double* CoinLpIO::collower_
| protected

Pointer to dense vector of column lower bounds.

Definition at line 569 of file CoinLpIO.hpp.

double* CoinLpIO::colupper_
| protected

Pointer to dense vector of column upper bounds.

Definition at line 572 of file CoinLpIO.hpp.

double* CoinLpIO::rhs_
| mutable protected

Pointer to dense vector of row rhs.

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

char* CoinLpIO::rowsense_
| mutable protected

Pointer to dense vector of row senses.

Definition at line 583 of file CoinLpIO.hpp.

double* CoinLpIO::objective_[MAX_OBJECTIVES]
| protected

Pointer to dense vector of objective coefficients.

Definition at line 586 of file CoinLpIO.hpp.

int CoinLpIO::num_objectives_
| protected

Number of objectives.

Definition at line 589 of file CoinLpIO.hpp.

double CoinLpIO::objectiveOffset_[MAX_OBJECTIVES]
| protected

Constant offset for objective value.

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

CoinSet** CoinLpIO::set_
| protected

Pointer to sets.

Definition at line 599 of file CoinLpIO.hpp.

int CoinLpIO::numberSets_
| protected

Number of sets.

Definition at line 602 of file CoinLpIO.hpp.

char* CoinLpIO::fileName_
| protected

Current file name.

Definition at line 605 of file CoinLpIO.hpp.

double CoinLpIO::infinity_
| protected

Value to use for infinity.

Definition at line 608 of file CoinLpIO.hpp.

double CoinLpIO::epsilon_
| protected

Value to use for epsilon.

Definition at line 611 of file CoinLpIO.hpp.

int CoinLpIO::numberAcross_
| protected

Number of monomials printed in a row.

Definition at line 614 of file CoinLpIO.hpp.

int CoinLpIO::decimals_
| protected

Number of decimals printed for coefficients.

Definition at line 617 of file CoinLpIO.hpp.

char* CoinLpIO::objName_[MAX_OBJECTIVES]
| protected

Objective function name.

Definition at line 620 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 628 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 634 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 640 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 649 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 654 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 659 of file CoinLpIO.hpp.

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

- /tmp/Osi-0.107.9/CoinUtils/src/CoinLpIO.hpp