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