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