Go to the documentation of this file.
167 void addRow(
int numberInRow,
const int * columns,
175 const char * name=NULL,
bool isInteger=
false);
177 inline void addCol(
int numberInColumn,
const int * rows,
181 const char * name=NULL,
bool isInteger=
false)
413 int writeMps(
const char *filename,
int compression = 0,
414 int formatType = 0,
int numberAcross = 2,
bool keepStrings=
false) ;
531 inline const char *
rowName(
int whichRow)
const
653 {
return -1.23456787654321e-97;}
656 const double * associated);
663 const double * associated);
668 const double * associated);
672 double * &
objective,
int * & integerType,
673 double * & associated);
758 const double* collb,
const double* colub,
760 const double* rowlb,
const double* rowub) ;
778 const double* collb,
const double* colub,
780 const char* rowsen,
const double* rowrhs,
781 const double* rowrng) ;
798 const double* collb,
const double* colub,
800 const double* rowlb,
const double* rowub) ;
817 const double* collb,
const double* colub,
819 const char* rowsen,
const double* rowrhs,
820 const double* rowrng) ;
829 CoinModel(
int firstRows,
int firstColumns,
int firstElements,
bool noNames=
false);
836 CoinModel(
int nonLinear,
const char * fileName,
const void * info);
865 void resize(
int maximumRows,
int maximumColumns,
int maximumElements);
867 void fillRows(
int which,
bool forceCreation,
bool fromAddRow=
false);
869 void fillColumns(
int which,
bool forceCreation,
bool fromAddColumn=
false);
894 int & numberBad)
const;
913 int * buildRow,
double * buildElement,
int reConstruct=-1)
const;
928 void gdb(
int nonLinear,
const char * fileName,
const void * info);
930 int decodeBit(
char * phrase,
char * & nextPhrase,
double & coefficient,
bool ifFirst)
const;
const char * rowUpperAsString(int whichRow) const
Gets rowUpper (if row does not exist then COIN_DBL_MAX)
const int * priorities() const
priorities (given for all columns (-1 if not integer)
int deleteElement(int row, int column)
Takes element out of matrix - returning position (<0 if not there);.
void setElement(int i, int j, const char *value)
Sets value for row i and column j as string.
void setColumnLower(int whichColumn, double columnLower)
Sets columnLower (if column does not exist then all columns up to this are defined with default value...
int sizeAssociated_
Size of associated values.
void setColumnUpper(int numberColumns, const double *columnUpper)
Sets columnUpper array.
int numberRows() const
Return number of rows.
double objectiveOffset() const
Returns the (constant) objective offset This is the RHS entry for the objective row.
void loadBlock(const int numcols, const int numrows, const CoinBigIndex *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
Load in a problem by copying the arguments.
CoinModelLink next(CoinModelLink ¤t) const
Returns next element in current row or column - index is -1 if none.
const double COIN_DBL_MAX
double getRowUpper(int whichRow) const
Gets rowUpper (if row does not exist then +COIN_DBL_MAX)
void setRowLower(int whichRow, const char *rowLower)
Sets rowLower (if row does not exist then all rows up to this are defined with default values and no ...
void fillList(int which, CoinModelLinkedList &list, int type) const
Fill in default linked list information (1= row, 2 = column) Marked as const as list is mutable.
int * priority_
priorities (given for all columns (-1 if not integer)
double columnUpper(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
CoinModelLinkedList rowList_
Linked list for rows.
void setOptimizationDirection(double value)
Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
void validateLinks() const
Checks that links are consistent.
void setColumnUpper(int whichColumn, const char *columnUpper)
Sets columnUpper (if column does not exist then all columns up to this are defined with default value...
void gdb(int nonLinear, const char *fileName, const void *info)
Read a problem from AMPL nl file so not constructor so gdb will work.
const int * originalColumns() const
Return pointers to original columns (for decomposition)
int convertMatrix()
Convert elements to CoinPackedMatrix (and switch off element updates).
CoinModelHash string_
Strings.
double * objectiveArray() const
Return objective array.
const int * cutMarker() const
Returns array of 0 or nonzero if can be a cut (or returns NULL)
CoinPackedMatrix * quadraticRow(int rowNumber, double *linear, int &numberBad) const
Gets correct form for a quadratic row - user to delete If row is not quadratic then returns which oth...
double optimizationDirection() const
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
int countPlusMinusOne(CoinBigIndex *startPositive, CoinBigIndex *startNegative, const double *associated)
Fills in startPositive and startNegative with counts for +-1 matrix.
CoinModel(int firstRows, int firstColumns, int firstElements, bool noNames=false)
Constructor with sizes.
void setMessageHandler(CoinMessageHandler *handler)
Pass in message handler.
CoinModelLink previous(CoinModelLink ¤t) const
Returns previous element in current row or column - index is -1 if none.
void setObjective(int whichColumn, double columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
void setObjectiveOffset(double value)
Set objective offset.
void setColumnIsInteger(int whichColumn, bool columnIsInteger)
Sets integer state (if column does not exist then all columns up to this are defined with default val...
double getElement(int i, int j) const
Returns value for row i and column j.
int row(const char *rowName) const
Row index from row name (-1 if no names or no match)
const char * columnName(int whichColumn) const
Gets name (if column does not exist then NULL)
int * sortIndices_
Array for sorting indices.
const char * getColumnUpperAsString(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
int pack()
Packs down all rows and columns.
int associateElement(const char *stringValue, double value)
Associates a string with a value. Returns string id (or -1 if does not exist)
int logLevel_
Print level.
CoinModelLink lastInColumn(int whichColumn) const
Returns last element in given column - index is -1 if none.
const std::string & getColumnBlock() const
Return the column block name.
int numberColumns_
Current number of columns.
int * columnType_
Column types.
void setColObjective(int whichColumn, double columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
double * columnUpperArray() const
Return columnUpper array.
int * prioritySOS_
SOS priority.
const CoinModelHash * stringArray() const
Return string array.
void setIsInteger(int whichColumn, bool columnIsInteger)
Sets integer state (if column does not exist then all columns up to this are defined with default val...
int * cut_
Nonzero if row is cut - done in one go e.g. from ampl.
void setObjective(int whichColumn, const char *columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
Class to hold and manipulate an array of massaged messages.
double * rowLowerArray() const
Return rowLower array.
CoinModelLink firstInQuadraticColumn(int whichColumn) const
Returns first element in given quadratic column - index is -1 if none.
double getElement(const char *rowName, const char *columnName) const
Returns value for row rowName and column columnName.
double optimizationDirection_
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
CoinModelTriple * elements_
Actual elements.
const int * originalRows() const
Return pointers to original rows (for decomposition)
int expandKnapsack(int knapsackRow, int &numberOutput, double *buildObj, CoinBigIndex *buildStart, int *buildRow, double *buildElement, int reConstruct=-1) const
Expands out all possible combinations for a knapsack If buildObj NULL then just computes space needed...
virtual ~CoinBaseModel()
Destructor.
void setRowUpper(int whichRow, double rowUpper)
Sets rowUpper (if row does not exist then all rows up to this are defined with default values and no ...
std::string columnBlockName_
Columnblock name.
const char * getColumnLowerAsString(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
double getColumnUpper(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
CoinModelLink firstInColumn(int whichColumn) const
Returns first element in given column - index is -1 if none.
void setInteger(int whichColumn)
Sets integer (if column does not exist then all columns up to this are defined with default values an...
virtual ~CoinModel()
Destructor.
CoinModelLink lastInQuadraticColumn(int whichColumn) const
Returns last element in given quadratic column - index is -1 if none.
const CoinModelTriple * elements() const
Return elements as triples.
void addRow(int numberInRow, const int *columns, const double *elements, double rowLower=-COIN_DBL_MAX, double rowUpper=COIN_DBL_MAX, const char *name=NULL)
add a row - numberInRow may be zero
CoinBaseModel(const CoinBaseModel &rhs)
Copy constructor.
void setColumnObjective(int whichColumn, const char *columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
bool columnIsInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
double * rowLower_
Row lower.
const char * getColumnObjectiveAsString(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
double optimizationDirection() const
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
void setLogLevel(int value)
Set print level 0 - off, 1 - errors, 2 - more.
void setColumnName(int whichColumn, const char *columnName)
Sets name (if column does not exist then all columns up to this are defined with default values and n...
int position(int i, int j) const
Returns position in elements for row i column j.
void setColumnLower(int whichColumn, const char *columnLower)
Sets columnLower (if column does not exist then all columns up to this are defined with default value...
int * start_
If simple then start of each row/column.
void loadBlock(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const char *rowsen, const double *rowrhs, const double *rowrng)
Load in a problem by copying the arguments.
void setRowName(int whichRow, const char *rowName)
Sets name (if row does not exist then all rows up to this are defined with default values and no elem...
CoinModelHash2 hashElements_
Hash for elements.
virtual CoinBaseModel * clone() const =0
Clone.
void setMoreInfo(void *info)
Set pointer to more information.
int type() const
Returns type.
This is for various structures/classes needed by CoinModel.
void setRowUpper(int whichRow, const char *rowUpper)
Sets rowUpper (if row does not exist then all rows up to this are defined with default values and no ...
CoinBigIndex numberElements() const
Return number of elements.
double * columnLowerArray() const
Return columnLower array.
int writeMps(const char *filename, int compression=0, int formatType=0, int numberAcross=2, bool keepStrings=false)
Write the problem in MPS format to a file with the given filename.
int decodeBit(char *phrase, char *&nextPhrase, double &coefficient, bool ifFirst) const
returns jColumn (-2 if linear term, -1 if unknown) and coefficient
bool getColIsInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
double * columnUpper_
Column Upper.
This is a first attempt at a message handler.
CoinModel(int nonLinear, const char *fileName, const void *info)
Read a problem from AMPL nl file NOTE - as I can't work out configure etc the source code is in Cbc_a...
CoinModelLink lastInRow(int whichRow) const
Returns last element in given row - index is -1 if none.
void badType() const
Aborts with message about packedMatrix.
CoinMessageHandler * handler_
Message handler (Passed in)
const char * rowLowerAsString(int whichRow) const
void setOriginalIndices(const int *row, const int *column)
For decomposition set original row and column indices.
int * integerType_
Integer information.
int computeAssociated(double *associated)
Fills in all associated - returning number of errors.
const char * getColumnName(int whichColumn) const
Gets name (if column does not exist then NULL)
CoinModelLinkedList quadraticColumnList_
Linked list for quadratic columns.
void setColumnBlock(const std::string &name)
Set column block name.
double columnLower(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
int differentModel(CoinModel &other, bool ignoreNames)
Check two models against each other.
This is a simple minded model which is stored in a format which makes it easier to construct and modi...
double getFunctionValueFromString(const char *string, const char *x, double xValue)
Just function of single variable x.
void resize(int maximumRows, int maximumColumns, int maximumElements)
Resize.
void setPriorities(int size, const int *priorities)
Sets priority array.
void addCol(int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0, const char *name=NULL, bool isInteger=false)
add a column - numberInColumn may be zero */
double rowUpper(int whichRow) const
Gets rowUpper (if row does not exist then COIN_DBL_MAX)
double columnObjective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
CoinModelLinkedList quadraticRowList_
Linked list for quadratic rows.
CoinMessages messages_
Messages.
void * moreInfo() const
Return pointer to more information.
double * associated_
Associated values.
void addColumn(int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0, const char *name=NULL, bool isInteger=false)
add a column - numberInColumn may be zero */
int getRow(int whichRow, int *column, double *element)
Gets sorted row - user must provide enough space (easiest is allocate number of columns).
double getColLower(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
void replaceQuadraticRow(int rowNumber, const double *linear, const CoinPackedMatrix *quadraticPart)
Replaces a quadratic row.
std::string problemName_
Problem name.
void setColumnIsInteger(int whichColumn, const char *columnIsInteger)
Sets integer (if column does not exist then all columns up to this are defined with default values an...
void setIsInteger(int whichColumn, const char *columnIsInteger)
Sets integer (if column does not exist then all columns up to this are defined with default values an...
const char * getRowLowerAsString(int whichRow) const
Gets rowLower (if row does not exist then -COIN_DBL_MAX)
double * rowUpper_
Row upper.
void fillColumns(int which, bool forceCreation, bool fromAddColumn=false)
Fill in default column information.
CoinModel(int numberRows, int numberColumns, const CoinPackedMatrix *matrix, const double *rowLower, const double *rowUpper, const double *columnLower, const double *columnUpper, const double *objective)
From arrays.
const char * objectiveAsString(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
void deleteColumn(int whichColumn)
Deletes all entries in column and bounds and objective.
CoinBaseModel & operator=(const CoinBaseModel &rhs)
Assignment operator.
void setObjective(int numberColumns, const double *objective)
Sets columnObjective array.
Base class for message handling.
double getColumnObjective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
CoinModelTriple * quadraticElements_
Actual quadratic elements (always linked lists)
const char * getRowUpperAsString(int whichRow) const
Gets rowUpper (if row does not exist then +COIN_DBL_MAX)
CoinModelLinkedList columnList_
Linked list for columns.
double objectiveOffset_
Objective offset to be passed on.
int numberRows_
Current number of rows.
double getDoubleFromString(CoinYacc &info, const char *string, const char *x, double xValue)
faster version
bool noNames_
True if no names EVER being used (for users who know what they are doing)
const char * getProblemName() const
Return the problem name.
virtual CoinBaseModel * clone() const
Clone.
double unsetValue() const
returns unset value
void setOptimizationDirection(double value)
Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
void setRowLower(int numberRows, const double *rowLower)
Sets rowLower array.
int sortSize_
Size of sort arrays.
CoinPackedMatrix * packedMatrix_
Actual elements as CoinPackedMatrix.
void freeStringMemory(CoinYacc &info)
Frees value memory.
int numberQuadraticElements_
Current number of quadratic elements.
CoinModelHash columnName_
Column names.
void setRowLower(int whichRow, double rowLower)
Sets rowLower (if row does not exist then all rows up to this are defined with default values and no ...
void * moreInfo_
Pointer to more information.
void deleteCol(int whichColumn)
Deletes all entries in column and bounds.
const char * columnUpperAsString(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
int maximumRows_
Maximum number of rows.
int getColumn(int whichColumn, int *column, double *element)
Gets sorted column - user must provide enough space (easiest is allocate number of rows).
void setRowUpper(int numberRows, const double *rowUpper)
Sets rowUpper array.
bool isInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
const char * columnObjectiveAsString(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
void deleteThisElement(int row, int column, int position)
Takes element out of matrix when position known.
CoinModelHash2 hashQuadraticElements_
Hash for quadratic elements.
double objective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
void setRowBlock(const std::string &name)
Set row block name.
Sparse Matrix Base Class.
const char * getElementAsString(int i, int j) const
Returns value for row i and column j as string.
int createPackedMatrix(CoinPackedMatrix &matrix, const double *associated)
Creates a packed matrix - return number of errors.
int type_
Type of build - -1 unset, 0 for row, 1 for column, 2 linked.
int createArrays(double *&rowLower, double *&rowUpper, double *&columnLower, double *&columnUpper, double *&objective, int *&integerType, double *&associated)
Creates copies of various arrays - return number of errors.
double getRowLower(int whichRow) const
Gets rowLower (if row does not exist then -COIN_DBL_MAX)
void setQuadraticElement(int i, int j, double value)
Sets quadratic value for column i and j.
const CoinModelHash * rowNames() const
Return row names array.
const char * getColumnIsIntegerAsString(int whichColumn) const
Gets if integer (if column does not exist then false)
bool stringsExist() const
Says if strings exist.
void zapRowNames()
Reset row names.
void setColumnLower(int numberColumns, const double *columnLower)
Sets columnLower array.
void operator()(int i, int j, double value)
Sets value for row i and column j.
double getQuadraticElement(int i, int j) const
Returns quadratic value for columns i and j.
int column(const char *columnName) const
Column index from column name (-1 if no names or no match)
double * objective_
Objective.
int maximumQuadraticElements_
Maximum number of quadratic elements.
const char * getRowName(int whichRow) const
Gets name (if row does not exist then NULL)
int packRows()
Packs down all rows i.e.
void setCutMarker(int size, const int *marker)
Sets cut marker array.
int numberSOS_
Number of SOS - all these are done in one go e.g. from ampl.
CoinModel * reorder(const char *mark) const
If possible return a model where if all variables marked nonzero are fixed the problem will be linear...
void setColIsInteger(int whichColumn, bool columnIsInteger)
Sets integer (if column does not exist then all columns up to this are defined with default values an...
CoinModel(const CoinModel &)
The copy constructor.
int * integerTypeArray() const
Return integerType array.
void setElement(int i, int j, double value)
Sets value for row i and column j.
CoinModel & operator=(const CoinModel &)
=
void createList(int type) const
Create a linked list and synchronize free type 1 for row 2 for column Marked as const as list is muta...
const std::string & getRowBlock() const
Return the row block name.
void setColUpper(int whichColumn, double columnUpper)
Sets columnUpper (if column does not exist then all columns up to this are defined with default value...
int * memberSOS_
SOS members.
int whatIsSet() const
Returns which parts of model are set 1 - matrix 2 - rhs 4 - row names 8 - column bounds and/or object...
const char * columnLowerAsString(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
const char * isIntegerAsString(int whichColumn) const
Gets if integer (if column does not exist then false)
double rowLower(int whichRow) const
void createPlusMinusOne(CoinBigIndex *startPositive, CoinBigIndex *startNegative, int *indices, const double *associated)
Creates +-1 matrix given startPositive and startNegative counts for +-1 matrix.
double getColumnLower(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
double getColUpper(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
void setColBounds(int whichColumn, double columnLower, double columnUpper)
Sets columnLower and columnUpper (if column does not exist then all columns up to this are defined wi...
const CoinModelHash * columnNames() const
Return column names array.
void setProblemName(const std::string &name)
Set problem name.
const char * getColName(int whichColumn) const
Gets name (if column does not exist then NULL)
double * pointer(int i, int j) const
Returns pointer to element for row i column j.
void setContinuous(int whichColumn)
Sets continuous (if column does not exist then all columns up to this are defined with default values...
void fillRows(int which, bool forceCreation, bool fromAddRow=false)
Fill in default row information.
virtual CoinBigIndex numberElements() const =0
Return number of elements.
void setColLower(int whichColumn, double columnLower)
Sets columnLower (if column does not exist then all columns up to this are defined with default value...
double getColObjective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
void loadBlock(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
Load in a problem by copying the arguments.
CoinModel(const char *fileName, int allowStrings=0)
Read a problem in MPS or GAMS format from the given filename.
double * referenceSOS_
SOS reference.
void setProblemName(const char *name)
Set problem name.
const char * columnIsIntegerAsString(int whichColumn) const
Gets if integer (if column does not exist then false)
int addString(const char *string)
Adds one string, returns index.
int packColumns()
Packs down all columns i.e.
double * columnLower_
Column Lower.
CoinModel()
Default constructor.
int maximumElements_
Maximum number of elements.
int numberColumns() const
Return number of columns.
const char * rowName(int whichRow) const
Gets name (if row does not exist then NULL)
CoinBaseModel()
Default Constructor.
void deleteRow(int whichRow)
Deletes all entries in row and bounds.
void setColLower(int numberColumns, const double *columnLower)
Sets columnLower array.
int logLevel() const
Get print level 0 - off, 1 - errors, 2 - more.
void setColumnObjective(int whichColumn, double columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
void setColUpper(int numberColumns, const double *columnUpper)
Sets columnUpper array.
int * startSOS_
SOS starts.
int numberItems() const
Number of items i.e. rows if just row names.
void setRowBounds(int whichRow, double rowLower, double rowUpper)
Sets rowLower and rowUpper (if row does not exist then all rows up to this are defined with default v...
void zapColumnNames()
Reset column names.
void loadBlock(const int numcols, const int numrows, const CoinBigIndex *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const char *rowsen, const double *rowrhs, const double *rowrng)
Load in a problem by copying the arguments.
std::string rowBlockName_
Rowblock name.
bool getColumnIsInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
void setColName(int whichColumn, const char *columnName)
Sets name (if column does not exist then all columns up to this are defined with default values and n...
const CoinPackedMatrix * packedMatrix() const
Return a pointer to CoinPackedMatrix (or NULL)
int maximumColumns_
Maximum number of columns.
double * associatedArray() const
Returns associated array.
double * sortElements_
Array for sorting elements.
int numberElements_
Current number of elements.
CoinModelHash rowName_
Row names.
double * rowUpperArray() const
Return rowUpper array.
void setColumnUpper(int whichColumn, double columnUpper)
Sets columnUpper (if column does not exist then all columns up to this are defined with default value...
double getDoubleFromString(CoinYacc &info, const char *string)
Gets a double from a string possibly containing named strings, returns unset if not found.
void setColumnBounds(int whichColumn, double columnLower, double columnUpper)
Sets columnLower and columnUpper (if column does not exist then all columns up to this are defined wi...
int links_
Links present (could be tested by sizes of objects) 0 - none, 1 - row links, 2 - column links,...
CoinModelLink firstInRow(int whichRow) const
Returns first element in given row - index is -1 if none.
void passInMatrix(const CoinPackedMatrix &matrix)
Pass in CoinPackedMatrix (and switch off element updates)
int packCols()
Packs down all columns i.e.