Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | List of all members
CoinModel Class Reference

This is a simple minded model which is stored in a format which makes it easier to construct and modify but not efficient for algorithms. More...

#include <CoinModel.hpp>

+ Inheritance diagram for CoinModel:
+ Collaboration diagram for CoinModel:

Public Member Functions

int computeAssociated (double *associated)
 Fills in all associated - returning number of errors. More...
 
CoinPackedMatrixquadraticRow (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 other variables are involved with tiny (1.0e-100) elements and count of total number of variables which could not be put in quadratic form. More...
 
void replaceQuadraticRow (int rowNumber, const double *linear, const CoinPackedMatrix *quadraticPart)
 Replaces a quadratic row. More...
 
CoinModelreorder (const char *mark) const
 If possible return a model where if all variables marked nonzero are fixed the problem will be linear. More...
 
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 - returns number elements On entry numberOutput is maximum allowed, on exit it is number needed or -1 (as will be number elements) if maximum exceeded. More...
 
void setCutMarker (int size, const int *marker)
 Sets cut marker array. More...
 
void setPriorities (int size, const int *priorities)
 Sets priority array. More...
 
const int * priorities () const
 priorities (given for all columns (-1 if not integer) More...
 
void setOriginalIndices (const int *row, const int *column)
 For decomposition set original row and column indices. More...
 
Useful methods for building model
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 More...
 
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 */ More...
 
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 */ More...
 
void operator() (int i, int j, double value)
 Sets value for row i and column j. More...
 
void setElement (int i, int j, double value)
 Sets value for row i and column j. More...
 
int getRow (int whichRow, int *column, double *element)
 Gets sorted row - user must provide enough space (easiest is allocate number of columns). More...
 
int getColumn (int whichColumn, int *column, double *element)
 Gets sorted column - user must provide enough space (easiest is allocate number of rows). More...
 
void setQuadraticElement (int i, int j, double value)
 Sets quadratic value for column i and j. More...
 
void operator() (int i, int j, const char *value)
 Sets value for row i and column j as string. More...
 
void setElement (int i, int j, const char *value)
 Sets value for row i and column j as string. More...
 
int associateElement (const char *stringValue, double value)
 Associates a string with a value. Returns string id (or -1 if does not exist) More...
 
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 elements) More...
 
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 elements) More...
 
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 values and no elements) More...
 
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 elements) More...
 
void setColumnLower (int whichColumn, double columnLower)
 Sets columnLower (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
void setColumnUpper (int whichColumn, double columnUpper)
 Sets columnUpper (if column does not exist then all columns up to this are defined with default values and no elements) 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 with default values and no elements) More...
 
void setColumnObjective (int whichColumn, double columnObjective)
 Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements) 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 no elements) More...
 
void setColumnIsInteger (int whichColumn, bool columnIsInteger)
 Sets integer state (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
void setObjective (int whichColumn, double columnObjective)
 Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
void setIsInteger (int whichColumn, bool columnIsInteger)
 Sets integer state (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
void setInteger (int whichColumn)
 Sets integer (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
void setContinuous (int whichColumn)
 Sets continuous (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
void setColLower (int whichColumn, double columnLower)
 Sets columnLower (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
void setColUpper (int whichColumn, double columnUpper)
 Sets columnUpper (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
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 with default values and no elements) More...
 
void setColObjective (int whichColumn, double columnObjective)
 Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
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 no elements) More...
 
void setColIsInteger (int whichColumn, bool columnIsInteger)
 Sets integer (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
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 elements) More...
 
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 elements) More...
 
void setColumnLower (int whichColumn, const char *columnLower)
 Sets columnLower (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
void setColumnUpper (int whichColumn, const char *columnUpper)
 Sets columnUpper (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
void setColumnObjective (int whichColumn, const char *columnObjective)
 Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
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 and no elements) More...
 
void setObjective (int whichColumn, const char *columnObjective)
 Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements) More...
 
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 and no elements) More...
 
void deleteRow (int whichRow)
 Deletes all entries in row and bounds. More...
 
void deleteColumn (int whichColumn)
 Deletes all entries in column and bounds and objective. More...
 
void deleteCol (int whichColumn)
 Deletes all entries in column and bounds. More...
 
int deleteElement (int row, int column)
 Takes element out of matrix - returning position (<0 if not there);. More...
 
void deleteThisElement (int row, int column, int position)
 Takes element out of matrix when position known. More...
 
int packRows ()
 Packs down all rows i.e. More...
 
int packColumns ()
 Packs down all columns i.e. More...
 
int packCols ()
 Packs down all columns i.e. More...
 
int pack ()
 Packs down all rows and columns. More...
 
void setObjective (int numberColumns, const double *objective)
 Sets columnObjective array. More...
 
void setColumnLower (int numberColumns, const double *columnLower)
 Sets columnLower array. More...
 
void setColLower (int numberColumns, const double *columnLower)
 Sets columnLower array. More...
 
void setColumnUpper (int numberColumns, const double *columnUpper)
 Sets columnUpper array. More...
 
void setColUpper (int numberColumns, const double *columnUpper)
 Sets columnUpper array. More...
 
void setRowLower (int numberRows, const double *rowLower)
 Sets rowLower array. More...
 
void setRowUpper (int numberRows, const double *rowUpper)
 Sets rowUpper array. More...
 
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. More...
 
int differentModel (CoinModel &other, bool ignoreNames)
 Check two models against each other. More...
 
For structured models
void passInMatrix (const CoinPackedMatrix &matrix)
 Pass in CoinPackedMatrix (and switch off element updates) More...
 
int convertMatrix ()
 Convert elements to CoinPackedMatrix (and switch off element updates). More...
 
const CoinPackedMatrixpackedMatrix () const
 Return a pointer to CoinPackedMatrix (or NULL) More...
 
const int * originalRows () const
 Return pointers to original rows (for decomposition) More...
 
const int * originalColumns () const
 Return pointers to original columns (for decomposition) More...
 
For getting information
CoinBigIndex numberElements () const
 Return number of elements. More...
 
const CoinModelTripleelements () const
 Return elements as triples. More...
 
double operator() (int i, int j) const
 Returns value for row i and column j. More...
 
double getElement (int i, int j) const
 Returns value for row i and column j. More...
 
double operator() (const char *rowName, const char *columnName) const
 Returns value for row rowName and column columnName. More...
 
double getElement (const char *rowName, const char *columnName) const
 Returns value for row rowName and column columnName. More...
 
double getQuadraticElement (int i, int j) const
 Returns quadratic value for columns i and j. More...
 
const char * getElementAsString (int i, int j) const
 Returns value for row i and column j as string. More...
 
double * pointer (int i, int j) const
 Returns pointer to element for row i column j. More...
 
int position (int i, int j) const
 Returns position in elements for row i column j. More...
 
CoinModelLink firstInRow (int whichRow) const
 Returns first element in given row - index is -1 if none. More...
 
CoinModelLink lastInRow (int whichRow) const
 Returns last element in given row - index is -1 if none. More...
 
CoinModelLink firstInColumn (int whichColumn) const
 Returns first element in given column - index is -1 if none. More...
 
CoinModelLink lastInColumn (int whichColumn) const
 Returns last element in given column - index is -1 if none. More...
 
CoinModelLink next (CoinModelLink &current) const
 Returns next element in current row or column - index is -1 if none. More...
 
CoinModelLink previous (CoinModelLink &current) const
 Returns previous element in current row or column - index is -1 if none. More...
 
CoinModelLink firstInQuadraticColumn (int whichColumn) const
 Returns first element in given quadratic column - index is -1 if none. More...
 
CoinModelLink lastInQuadraticColumn (int whichColumn) const
 Returns last element in given quadratic column - index is -1 if none. More...
 
double getRowLower (int whichRow) const
 Gets rowLower (if row does not exist then -COIN_DBL_MAX) More...
 
double getRowUpper (int whichRow) const
 Gets rowUpper (if row does not exist then +COIN_DBL_MAX) More...
 
const char * getRowName (int whichRow) const
 Gets name (if row does not exist then NULL) More...
 
double rowLower (int whichRow) const
 
double rowUpper (int whichRow) const
 Gets rowUpper (if row does not exist then COIN_DBL_MAX) More...
 
const char * rowName (int whichRow) const
 Gets name (if row does not exist then NULL) More...
 
double getColumnLower (int whichColumn) const
 Gets columnLower (if column does not exist then 0.0) More...
 
double getColumnUpper (int whichColumn) const
 Gets columnUpper (if column does not exist then COIN_DBL_MAX) More...
 
double getColumnObjective (int whichColumn) const
 Gets columnObjective (if column does not exist then 0.0) More...
 
const char * getColumnName (int whichColumn) const
 Gets name (if column does not exist then NULL) More...
 
bool getColumnIsInteger (int whichColumn) const
 Gets if integer (if column does not exist then false) More...
 
double columnLower (int whichColumn) const
 Gets columnLower (if column does not exist then 0.0) More...
 
double columnUpper (int whichColumn) const
 Gets columnUpper (if column does not exist then COIN_DBL_MAX) More...
 
double columnObjective (int whichColumn) const
 Gets columnObjective (if column does not exist then 0.0) More...
 
double objective (int whichColumn) const
 Gets columnObjective (if column does not exist then 0.0) More...
 
const char * columnName (int whichColumn) const
 Gets name (if column does not exist then NULL) More...
 
bool columnIsInteger (int whichColumn) const
 Gets if integer (if column does not exist then false) More...
 
bool isInteger (int whichColumn) const
 Gets if integer (if column does not exist then false) More...
 
double getColLower (int whichColumn) const
 Gets columnLower (if column does not exist then 0.0) More...
 
double getColUpper (int whichColumn) const
 Gets columnUpper (if column does not exist then COIN_DBL_MAX) More...
 
double getColObjective (int whichColumn) const
 Gets columnObjective (if column does not exist then 0.0) More...
 
const char * getColName (int whichColumn) const
 Gets name (if column does not exist then NULL) More...
 
bool getColIsInteger (int whichColumn) const
 Gets if integer (if column does not exist then false) More...
 
const char * getRowLowerAsString (int whichRow) const
 Gets rowLower (if row does not exist then -COIN_DBL_MAX) More...
 
const char * getRowUpperAsString (int whichRow) const
 Gets rowUpper (if row does not exist then +COIN_DBL_MAX) More...
 
const char * rowLowerAsString (int whichRow) const
 
const char * rowUpperAsString (int whichRow) const
 Gets rowUpper (if row does not exist then COIN_DBL_MAX) More...
 
const char * getColumnLowerAsString (int whichColumn) const
 Gets columnLower (if column does not exist then 0.0) More...
 
const char * getColumnUpperAsString (int whichColumn) const
 Gets columnUpper (if column does not exist then COIN_DBL_MAX) More...
 
const char * getColumnObjectiveAsString (int whichColumn) const
 Gets columnObjective (if column does not exist then 0.0) More...
 
const char * getColumnIsIntegerAsString (int whichColumn) const
 Gets if integer (if column does not exist then false) More...
 
const char * columnLowerAsString (int whichColumn) const
 Gets columnLower (if column does not exist then 0.0) More...
 
const char * columnUpperAsString (int whichColumn) const
 Gets columnUpper (if column does not exist then COIN_DBL_MAX) More...
 
const char * columnObjectiveAsString (int whichColumn) const
 Gets columnObjective (if column does not exist then 0.0) More...
 
const char * objectiveAsString (int whichColumn) const
 Gets columnObjective (if column does not exist then 0.0) More...
 
const char * columnIsIntegerAsString (int whichColumn) const
 Gets if integer (if column does not exist then false) More...
 
const char * isIntegerAsString (int whichColumn) const
 Gets if integer (if column does not exist then false) More...
 
int row (const char *rowName) const
 Row index from row name (-1 if no names or no match) More...
 
int column (const char *columnName) const
 Column index from column name (-1 if no names or no match) More...
 
int type () const
 Returns type. More...
 
double unsetValue () const
 returns unset value More...
 
int createPackedMatrix (CoinPackedMatrix &matrix, const double *associated)
 Creates a packed matrix - return number of errors. More...
 
int countPlusMinusOne (CoinBigIndex *startPositive, CoinBigIndex *startNegative, const double *associated)
 Fills in startPositive and startNegative with counts for +-1 matrix. More...
 
void createPlusMinusOne (CoinBigIndex *startPositive, CoinBigIndex *startNegative, int *indices, const double *associated)
 Creates +-1 matrix given startPositive and startNegative counts for +-1 matrix. More...
 
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. More...
 
bool stringsExist () const
 Says if strings exist. More...
 
const CoinModelHashstringArray () const
 Return string array. More...
 
double * associatedArray () const
 Returns associated array. More...
 
double * rowLowerArray () const
 Return rowLower array. More...
 
double * rowUpperArray () const
 Return rowUpper array. More...
 
double * columnLowerArray () const
 Return columnLower array. More...
 
double * columnUpperArray () const
 Return columnUpper array. More...
 
double * objectiveArray () const
 Return objective array. More...
 
int * integerTypeArray () const
 Return integerType array. More...
 
const CoinModelHashrowNames () const
 Return row names array. More...
 
const CoinModelHashcolumnNames () const
 Return column names array. More...
 
void zapRowNames ()
 Reset row names. More...
 
void zapColumnNames ()
 Reset column names. More...
 
const int * cutMarker () const
 Returns array of 0 or nonzero if can be a cut (or returns NULL) More...
 
double optimizationDirection () const
 Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
void setOptimizationDirection (double value)
 Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
voidmoreInfo () const
 Return pointer to more information. More...
 
void setMoreInfo (void *info)
 Set pointer to more information. More...
 
int whatIsSet () const
 Returns which parts of model are set 1 - matrix 2 - rhs 4 - row names 8 - column bounds and/or objective 16 - column names 32 - integer types. More...
 
for block models - matrix will be CoinPackedMatrix
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. More...
 
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. More...
 
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. More...
 
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. More...
 
Constructors, destructor
 CoinModel ()
 Default constructor. More...
 
 CoinModel (int firstRows, int firstColumns, int firstElements, bool noNames=false)
 Constructor with sizes. More...
 
 CoinModel (const char *fileName, int allowStrings=0)
 Read a problem in MPS or GAMS format from the given filename. More...
 
 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_ampl.cpp! More...
 
 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. More...
 
virtual CoinBaseModelclone () const
 Clone. More...
 
virtual ~CoinModel ()
 Destructor. More...
 
Copy method
 CoinModel (const CoinModel &)
 The copy constructor. More...
 
CoinModeloperator= (const CoinModel &)
 = More...
 
For debug
void validateLinks () const
 Checks that links are consistent. More...
 
- Public Member Functions inherited from CoinBaseModel
 CoinBaseModel ()
 Default Constructor. More...
 
 CoinBaseModel (const CoinBaseModel &rhs)
 Copy constructor. More...
 
CoinBaseModeloperator= (const CoinBaseModel &rhs)
 Assignment operator. More...
 
virtual ~CoinBaseModel ()
 Destructor. More...
 
int numberRows () const
 Return number of rows. More...
 
int numberColumns () const
 Return number of columns. More...
 
double objectiveOffset () const
 Returns the (constant) objective offset This is the RHS entry for the objective row. More...
 
void setObjectiveOffset (double value)
 Set objective offset. More...
 
double optimizationDirection () const
 Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
void setOptimizationDirection (double value)
 Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
int logLevel () const
 Get print level 0 - off, 1 - errors, 2 - more. More...
 
void setLogLevel (int value)
 Set print level 0 - off, 1 - errors, 2 - more. More...
 
const char * getProblemName () const
 Return the problem name. More...
 
void setProblemName (const char *name)
 Set problem name. More...
 
void setProblemName (const std::string &name)
 Set problem name. More...
 
const std::string & getRowBlock () const
 Return the row block name. More...
 
void setRowBlock (const std::string &name)
 Set row block name. More...
 
const std::string & getColumnBlock () const
 Return the column block name. More...
 
void setColumnBlock (const std::string &name)
 Set column block name. More...
 
void setMessageHandler (CoinMessageHandler *handler)
 Pass in message handler. More...
 

Private Member Functions

void resize (int maximumRows, int maximumColumns, int maximumElements)
 Resize. More...
 
void fillRows (int which, bool forceCreation, bool fromAddRow=false)
 Fill in default row information. More...
 
void fillColumns (int which, bool forceCreation, bool fromAddColumn=false)
 Fill in default column information. More...
 
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. More...
 
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 mutable. More...
 
int addString (const char *string)
 Adds one string, returns index. More...
 
double getDoubleFromString (CoinYacc &info, const char *string)
 Gets a double from a string possibly containing named strings, returns unset if not found. More...
 
void freeStringMemory (CoinYacc &info)
 Frees value memory. More...
 
void gdb (int nonLinear, const char *fileName, const void *info)
 Read a problem from AMPL nl file so not constructor so gdb will work. More...
 
int decodeBit (char *phrase, char *&nextPhrase, double &coefficient, bool ifFirst) const
 returns jColumn (-2 if linear term, -1 if unknown) and coefficient More...
 
void badType () const
 Aborts with message about packedMatrix. More...
 

Private Attributes

Data members
int maximumRows_
 Maximum number of rows. More...
 
int maximumColumns_
 Maximum number of columns. More...
 
int numberElements_
 Current number of elements. More...
 
int maximumElements_
 Maximum number of elements. More...
 
int numberQuadraticElements_
 Current number of quadratic elements. More...
 
int maximumQuadraticElements_
 Maximum number of quadratic elements. More...
 
double * rowLower_
 Row lower. More...
 
double * rowUpper_
 Row upper. More...
 
CoinModelHash rowName_
 Row names. More...
 
int * rowType_
 Row types. More...
 
double * objective_
 Objective. More...
 
double * columnLower_
 Column Lower. More...
 
double * columnUpper_
 Column Upper. More...
 
CoinModelHash columnName_
 Column names. More...
 
int * integerType_
 Integer information. More...
 
CoinModelHash string_
 Strings. More...
 
int * columnType_
 Column types. More...
 
int * start_
 If simple then start of each row/column. More...
 
CoinModelTripleelements_
 Actual elements. More...
 
CoinPackedMatrixpackedMatrix_
 Actual elements as CoinPackedMatrix. More...
 
CoinModelHash2 hashElements_
 Hash for elements. More...
 
CoinModelLinkedList rowList_
 Linked list for rows. More...
 
CoinModelLinkedList columnList_
 Linked list for columns. More...
 
CoinModelTriplequadraticElements_
 Actual quadratic elements (always linked lists) More...
 
CoinModelHash2 hashQuadraticElements_
 Hash for quadratic elements. More...
 
int * sortIndices_
 Array for sorting indices. More...
 
double * sortElements_
 Array for sorting elements. More...
 
int sortSize_
 Size of sort arrays. More...
 
CoinModelLinkedList quadraticRowList_
 Linked list for quadratic rows. More...
 
CoinModelLinkedList quadraticColumnList_
 Linked list for quadratic columns. More...
 
int sizeAssociated_
 Size of associated values. More...
 
double * associated_
 Associated values. More...
 
int numberSOS_
 Number of SOS - all these are done in one go e.g. from ampl. More...
 
int * startSOS_
 SOS starts. More...
 
int * memberSOS_
 SOS members. More...
 
int * typeSOS_
 SOS type. More...
 
int * prioritySOS_
 SOS priority. More...
 
double * referenceSOS_
 SOS reference. More...
 
int * priority_
 priorities (given for all columns (-1 if not integer) More...
 
int * cut_
 Nonzero if row is cut - done in one go e.g. from ampl. More...
 
voidmoreInfo_
 Pointer to more information. More...
 
int type_
 Type of build - -1 unset, 0 for row, 1 for column, 2 linked. More...
 
bool noNames_
 True if no names EVER being used (for users who know what they are doing) More...
 
int links_
 Links present (could be tested by sizes of objects) 0 - none, 1 - row links, 2 - column links, 3 - both. More...
 

Additional Inherited Members

- Protected Attributes inherited from CoinBaseModel
int numberRows_
 Current number of rows. More...
 
int numberColumns_
 Current number of columns. More...
 
double optimizationDirection_
 Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
double objectiveOffset_
 Objective offset to be passed on. More...
 
std::string problemName_
 Problem name. More...
 
std::string rowBlockName_
 Rowblock name. More...
 
std::string columnBlockName_
 Columnblock name. More...
 
CoinMessageHandlerhandler_
 Message handler (Passed in) More...
 
CoinMessages messages_
 Messages. More...
 
int logLevel_
 Print level. More...
 

Detailed Description

This is a simple minded model which is stored in a format which makes it easier to construct and modify but not efficient for algorithms.

It has to be passed across to ClpModel or OsiSolverInterface by addRows, addCol(umn)s or loadProblem.

It may have up to four parts - 1) A matrix of doubles (or strings - see note A) 2) Column information including integer information and names 3) Row information including names 4) Quadratic objective (not implemented - but see A)

This class is meant to make it more efficient to build a model. It is at its most efficient when all additions are done as addRow or as addCol but not mixed. If only 1 and 2 exist then solver.addColumns may be used to pass to solver, if only 1 and 3 exist then solver.addRows may be used. Otherwise solver.loadProblem must be used.

If addRows and addColumns are mixed or if individual elements are set then the speed will drop to some extent and more memory will be used.

It is also possible to iterate over existing elements and to access columns and rows by name. Again each of these use memory and cpu time. However memory is unlikely to be critical as most algorithms will use much more.

Notes: A) Although this could be used to pass nonlinear information around the only use at present is to have named values e.g. value1 which can then be set to a value after model is created. I have no idea whether that could be useful but I thought it might be fun. Quadratic terms are allowed in strings! A solver could try and use this if so - the convention is that 0.5* quadratic is stored

B) This class could be useful for modeling.

Definition at line 161 of file CoinModel.hpp.

Constructor & Destructor Documentation

CoinModel::CoinModel ( )

Default constructor.

CoinModel::CoinModel ( int  firstRows,
int  firstColumns,
int  firstElements,
bool  noNames = false 
)

Constructor with sizes.

CoinModel::CoinModel ( const char *  fileName,
int  allowStrings = 0 
)

Read a problem in MPS or GAMS format from the given filename.

CoinModel::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_ampl.cpp!

CoinModel::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.

virtual CoinModel::~CoinModel ( )
virtual

Destructor.

CoinModel::CoinModel ( const CoinModel )

The copy constructor.

Member Function Documentation

void CoinModel::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

void CoinModel::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 CoinModel::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 
)
inline

add a column - numberInColumn may be zero */

Definition at line 177 of file CoinModel.hpp.

void CoinModel::operator() ( int  i,
int  j,
double  value 
)
inline

Sets value for row i and column j.

Definition at line 185 of file CoinModel.hpp.

void CoinModel::setElement ( int  i,
int  j,
double  value 
)

Sets value for row i and column j.

int CoinModel::getRow ( int  whichRow,
int *  column,
double *  element 
)

Gets sorted row - user must provide enough space (easiest is allocate number of columns).

If column or element NULL then just returns number Returns number of elements

int CoinModel::getColumn ( int  whichColumn,
int *  column,
double *  element 
)

Gets sorted column - user must provide enough space (easiest is allocate number of rows).

If row or element NULL then just returns number Returns number of elements

void CoinModel::setQuadraticElement ( int  i,
int  j,
double  value 
)

Sets quadratic value for column i and j.

void CoinModel::operator() ( int  i,
int  j,
const char *  value 
)
inline

Sets value for row i and column j as string.

Definition at line 204 of file CoinModel.hpp.

void CoinModel::setElement ( int  i,
int  j,
const char *  value 
)

Sets value for row i and column j as string.

int CoinModel::associateElement ( const char *  stringValue,
double  value 
)

Associates a string with a value. Returns string id (or -1 if does not exist)

void CoinModel::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 elements)

void CoinModel::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 elements)

void CoinModel::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 values and no elements)

void CoinModel::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 elements)

void CoinModel::setColumnLower ( int  whichColumn,
double  columnLower 
)

Sets columnLower (if column does not exist then all columns up to this are defined with default values and no elements)

void CoinModel::setColumnUpper ( int  whichColumn,
double  columnUpper 
)

Sets columnUpper (if column does not exist then all columns up to this are defined with default values and no elements)

void CoinModel::setColumnBounds ( int  whichColumn,
double  columnLower,
double  columnUpper 
)

Sets columnLower and columnUpper (if column does not exist then all columns up to this are defined with default values and no elements)

void CoinModel::setColumnObjective ( int  whichColumn,
double  columnObjective 
)

Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements)

void CoinModel::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 no elements)

void CoinModel::setColumnIsInteger ( int  whichColumn,
bool  columnIsInteger 
)

Sets integer state (if column does not exist then all columns up to this are defined with default values and no elements)

void CoinModel::setObjective ( int  whichColumn,
double  columnObjective 
)
inline

Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 253 of file CoinModel.hpp.

void CoinModel::setIsInteger ( int  whichColumn,
bool  columnIsInteger 
)
inline

Sets integer state (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 258 of file CoinModel.hpp.

void CoinModel::setInteger ( int  whichColumn)
inline

Sets integer (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 263 of file CoinModel.hpp.

void CoinModel::setContinuous ( int  whichColumn)
inline

Sets continuous (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 268 of file CoinModel.hpp.

void CoinModel::setColLower ( int  whichColumn,
double  columnLower 
)
inline

Sets columnLower (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 273 of file CoinModel.hpp.

void CoinModel::setColUpper ( int  whichColumn,
double  columnUpper 
)
inline

Sets columnUpper (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 278 of file CoinModel.hpp.

void CoinModel::setColBounds ( int  whichColumn,
double  columnLower,
double  columnUpper 
)
inline

Sets columnLower and columnUpper (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 283 of file CoinModel.hpp.

void CoinModel::setColObjective ( int  whichColumn,
double  columnObjective 
)
inline

Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 288 of file CoinModel.hpp.

void CoinModel::setColName ( int  whichColumn,
const char *  columnName 
)
inline

Sets name (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 293 of file CoinModel.hpp.

void CoinModel::setColIsInteger ( int  whichColumn,
bool  columnIsInteger 
)
inline

Sets integer (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 298 of file CoinModel.hpp.

void CoinModel::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 elements)

void CoinModel::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 elements)

void CoinModel::setColumnLower ( int  whichColumn,
const char *  columnLower 
)

Sets columnLower (if column does not exist then all columns up to this are defined with default values and no elements)

void CoinModel::setColumnUpper ( int  whichColumn,
const char *  columnUpper 
)

Sets columnUpper (if column does not exist then all columns up to this are defined with default values and no elements)

void CoinModel::setColumnObjective ( int  whichColumn,
const char *  columnObjective 
)

Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements)

void CoinModel::setColumnIsInteger ( int  whichColumn,
const char *  columnIsInteger 
)

Sets integer (if column does not exist then all columns up to this are defined with default values and no elements)

void CoinModel::setObjective ( int  whichColumn,
const char *  columnObjective 
)
inline

Sets columnObjective (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 327 of file CoinModel.hpp.

void CoinModel::setIsInteger ( int  whichColumn,
const char *  columnIsInteger 
)
inline

Sets integer (if column does not exist then all columns up to this are defined with default values and no elements)

Definition at line 332 of file CoinModel.hpp.

void CoinModel::deleteRow ( int  whichRow)

Deletes all entries in row and bounds.

Will be ignored by writeMps etc and will be packed down if asked for.

void CoinModel::deleteColumn ( int  whichColumn)

Deletes all entries in column and bounds and objective.

Will be ignored by writeMps etc and will be packed down if asked for.

void CoinModel::deleteCol ( int  whichColumn)
inline

Deletes all entries in column and bounds.

If last column the number of columns will be decremented and true returned.

Definition at line 342 of file CoinModel.hpp.

int CoinModel::deleteElement ( int  row,
int  column 
)

Takes element out of matrix - returning position (<0 if not there);.

void CoinModel::deleteThisElement ( int  row,
int  column,
int  position 
)

Takes element out of matrix when position known.

int CoinModel::packRows ( )

Packs down all rows i.e.

removes empty rows permanently. Empty rows have no elements and feasible bounds. returns number of rows deleted.

int CoinModel::packColumns ( )

Packs down all columns i.e.

removes empty columns permanently. Empty columns have no elements and no objective. returns number of columns deleted.

int CoinModel::packCols ( )
inline

Packs down all columns i.e.

removes empty columns permanently. Empty columns have no elements and no objective. returns number of columns deleted.

Definition at line 356 of file CoinModel.hpp.

int CoinModel::pack ( )

Packs down all rows and columns.

i.e. removes empty rows and columns permanently. Empty rows have no elements and feasible bounds. Empty columns have no elements and no objective. returns number of rows+columns deleted.

void CoinModel::setObjective ( int  numberColumns,
const double *  objective 
)

Sets columnObjective array.

void CoinModel::setColumnLower ( int  numberColumns,
const double *  columnLower 
)

Sets columnLower array.

void CoinModel::setColLower ( int  numberColumns,
const double *  columnLower 
)
inline

Sets columnLower array.

Definition at line 372 of file CoinModel.hpp.

void CoinModel::setColumnUpper ( int  numberColumns,
const double *  columnUpper 
)

Sets columnUpper array.

void CoinModel::setColUpper ( int  numberColumns,
const double *  columnUpper 
)
inline

Sets columnUpper array.

Definition at line 379 of file CoinModel.hpp.

void CoinModel::setRowLower ( int  numberRows,
const double *  rowLower 
)

Sets rowLower array.

void CoinModel::setRowUpper ( int  numberRows,
const double *  rowUpper 
)

Sets rowUpper array.

int CoinModel::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.

Parameters
compressioncan be set to three values to indicate what kind of file should be written
  • 0: plain text (default)
  • 1: gzip compressed (.gz is appended to filename)
  • 2: bzip2 compressed (.bz2 is appended to filename) (TODO)
If the library was not compiled with the requested compression then writeMps falls back to writing a plain text file.
formatTypespecifies the precision to used for values in the MPS file
  • 0: normal precision (default)
  • 1: extra accuracy
  • 2: IEEE hex
numberAcrossspecifies whether 1 or 2 (default) values should be specified on every data line in the MPS file.

not const as may change model e.g. fill in default bounds

int CoinModel::differentModel ( CoinModel other,
bool  ignoreNames 
)

Check two models against each other.

Return nonzero if different. Ignore names if that set. May modify both models by cleaning up

void CoinModel::passInMatrix ( const CoinPackedMatrix matrix)

Pass in CoinPackedMatrix (and switch off element updates)

int CoinModel::convertMatrix ( )

Convert elements to CoinPackedMatrix (and switch off element updates).

Returns number of errors

const CoinPackedMatrix* CoinModel::packedMatrix ( ) const
inline

Return a pointer to CoinPackedMatrix (or NULL)

Definition at line 432 of file CoinModel.hpp.

const int* CoinModel::originalRows ( ) const
inline

Return pointers to original rows (for decomposition)

Definition at line 435 of file CoinModel.hpp.

const int* CoinModel::originalColumns ( ) const
inline

Return pointers to original columns (for decomposition)

Definition at line 438 of file CoinModel.hpp.

CoinBigIndex CoinModel::numberElements ( ) const
inlinevirtual

Return number of elements.

Implements CoinBaseModel.

Definition at line 446 of file CoinModel.hpp.

const CoinModelTriple* CoinModel::elements ( ) const
inline

Return elements as triples.

Definition at line 449 of file CoinModel.hpp.

double CoinModel::operator() ( int  i,
int  j 
) const
inline

Returns value for row i and column j.

Definition at line 452 of file CoinModel.hpp.

double CoinModel::getElement ( int  i,
int  j 
) const

Returns value for row i and column j.

double CoinModel::operator() ( const char *  rowName,
const char *  columnName 
) const
inline

Returns value for row rowName and column columnName.

Definition at line 457 of file CoinModel.hpp.

double CoinModel::getElement ( const char *  rowName,
const char *  columnName 
) const

Returns value for row rowName and column columnName.

double CoinModel::getQuadraticElement ( int  i,
int  j 
) const

Returns quadratic value for columns i and j.

const char* CoinModel::getElementAsString ( int  i,
int  j 
) const

Returns value for row i and column j as string.

Returns NULL if does not exist. Returns "Numeric" if not a string

double* CoinModel::pointer ( int  i,
int  j 
) const

Returns pointer to element for row i column j.

Only valid until next modification. NULL if element does not exist

int CoinModel::position ( int  i,
int  j 
) const

Returns position in elements for row i column j.

Only valid until next modification. -1 if element does not exist

CoinModelLink CoinModel::firstInRow ( int  whichRow) const

Returns first element in given row - index is -1 if none.

Index is given by .index and value by .value

CoinModelLink CoinModel::lastInRow ( int  whichRow) const

Returns last element in given row - index is -1 if none.

Index is given by .index and value by .value

CoinModelLink CoinModel::firstInColumn ( int  whichColumn) const

Returns first element in given column - index is -1 if none.

Index is given by .index and value by .value

CoinModelLink CoinModel::lastInColumn ( int  whichColumn) const

Returns last element in given column - index is -1 if none.

Index is given by .index and value by .value

CoinModelLink CoinModel::next ( CoinModelLink current) const

Returns next element in current row or column - index is -1 if none.

Index is given by .index and value by .value. User could also tell because input.next would be NULL

CoinModelLink CoinModel::previous ( CoinModelLink current) const

Returns previous element in current row or column - index is -1 if none.

Index is given by .index and value by .value. User could also tell because input.previous would be NULL May not be correct if matrix updated.

CoinModelLink CoinModel::firstInQuadraticColumn ( int  whichColumn) const

Returns first element in given quadratic column - index is -1 if none.

Index is given by .index and value by .value May not be correct if matrix updated.

CoinModelLink CoinModel::lastInQuadraticColumn ( int  whichColumn) const

Returns last element in given quadratic column - index is -1 if none.

Index is given by .index and value by .value

double CoinModel::getRowLower ( int  whichRow) const

Gets rowLower (if row does not exist then -COIN_DBL_MAX)

double CoinModel::getRowUpper ( int  whichRow) const

Gets rowUpper (if row does not exist then +COIN_DBL_MAX)

const char* CoinModel::getRowName ( int  whichRow) const

Gets name (if row does not exist then NULL)

double CoinModel::rowLower ( int  whichRow) const
inline

Definition at line 523 of file CoinModel.hpp.

double CoinModel::rowUpper ( int  whichRow) const
inline

Gets rowUpper (if row does not exist then COIN_DBL_MAX)

Definition at line 527 of file CoinModel.hpp.

const char* CoinModel::rowName ( int  whichRow) const
inline

Gets name (if row does not exist then NULL)

Definition at line 531 of file CoinModel.hpp.

double CoinModel::getColumnLower ( int  whichColumn) const

Gets columnLower (if column does not exist then 0.0)

double CoinModel::getColumnUpper ( int  whichColumn) const

Gets columnUpper (if column does not exist then COIN_DBL_MAX)

double CoinModel::getColumnObjective ( int  whichColumn) const

Gets columnObjective (if column does not exist then 0.0)

const char* CoinModel::getColumnName ( int  whichColumn) const

Gets name (if column does not exist then NULL)

bool CoinModel::getColumnIsInteger ( int  whichColumn) const

Gets if integer (if column does not exist then false)

double CoinModel::columnLower ( int  whichColumn) const
inline

Gets columnLower (if column does not exist then 0.0)

Definition at line 550 of file CoinModel.hpp.

double CoinModel::columnUpper ( int  whichColumn) const
inline

Gets columnUpper (if column does not exist then COIN_DBL_MAX)

Definition at line 554 of file CoinModel.hpp.

double CoinModel::columnObjective ( int  whichColumn) const
inline

Gets columnObjective (if column does not exist then 0.0)

Definition at line 558 of file CoinModel.hpp.

double CoinModel::objective ( int  whichColumn) const
inline

Gets columnObjective (if column does not exist then 0.0)

Definition at line 562 of file CoinModel.hpp.

const char* CoinModel::columnName ( int  whichColumn) const
inline

Gets name (if column does not exist then NULL)

Definition at line 566 of file CoinModel.hpp.

bool CoinModel::columnIsInteger ( int  whichColumn) const
inline

Gets if integer (if column does not exist then false)

Definition at line 570 of file CoinModel.hpp.

bool CoinModel::isInteger ( int  whichColumn) const
inline

Gets if integer (if column does not exist then false)

Definition at line 574 of file CoinModel.hpp.

double CoinModel::getColLower ( int  whichColumn) const
inline

Gets columnLower (if column does not exist then 0.0)

Definition at line 578 of file CoinModel.hpp.

double CoinModel::getColUpper ( int  whichColumn) const
inline

Gets columnUpper (if column does not exist then COIN_DBL_MAX)

Definition at line 582 of file CoinModel.hpp.

double CoinModel::getColObjective ( int  whichColumn) const
inline

Gets columnObjective (if column does not exist then 0.0)

Definition at line 586 of file CoinModel.hpp.

const char* CoinModel::getColName ( int  whichColumn) const
inline

Gets name (if column does not exist then NULL)

Definition at line 590 of file CoinModel.hpp.

bool CoinModel::getColIsInteger ( int  whichColumn) const
inline

Gets if integer (if column does not exist then false)

Definition at line 594 of file CoinModel.hpp.

const char* CoinModel::getRowLowerAsString ( int  whichRow) const

Gets rowLower (if row does not exist then -COIN_DBL_MAX)

const char* CoinModel::getRowUpperAsString ( int  whichRow) const

Gets rowUpper (if row does not exist then +COIN_DBL_MAX)

const char* CoinModel::rowLowerAsString ( int  whichRow) const
inline

Definition at line 602 of file CoinModel.hpp.

const char* CoinModel::rowUpperAsString ( int  whichRow) const
inline

Gets rowUpper (if row does not exist then COIN_DBL_MAX)

Definition at line 606 of file CoinModel.hpp.

const char* CoinModel::getColumnLowerAsString ( int  whichColumn) const

Gets columnLower (if column does not exist then 0.0)

const char* CoinModel::getColumnUpperAsString ( int  whichColumn) const

Gets columnUpper (if column does not exist then COIN_DBL_MAX)

const char* CoinModel::getColumnObjectiveAsString ( int  whichColumn) const

Gets columnObjective (if column does not exist then 0.0)

const char* CoinModel::getColumnIsIntegerAsString ( int  whichColumn) const

Gets if integer (if column does not exist then false)

const char* CoinModel::columnLowerAsString ( int  whichColumn) const
inline

Gets columnLower (if column does not exist then 0.0)

Definition at line 622 of file CoinModel.hpp.

const char* CoinModel::columnUpperAsString ( int  whichColumn) const
inline

Gets columnUpper (if column does not exist then COIN_DBL_MAX)

Definition at line 626 of file CoinModel.hpp.

const char* CoinModel::columnObjectiveAsString ( int  whichColumn) const
inline

Gets columnObjective (if column does not exist then 0.0)

Definition at line 630 of file CoinModel.hpp.

const char* CoinModel::objectiveAsString ( int  whichColumn) const
inline

Gets columnObjective (if column does not exist then 0.0)

Definition at line 634 of file CoinModel.hpp.

const char* CoinModel::columnIsIntegerAsString ( int  whichColumn) const
inline

Gets if integer (if column does not exist then false)

Definition at line 638 of file CoinModel.hpp.

const char* CoinModel::isIntegerAsString ( int  whichColumn) const
inline

Gets if integer (if column does not exist then false)

Definition at line 642 of file CoinModel.hpp.

int CoinModel::row ( const char *  rowName) const

Row index from row name (-1 if no names or no match)

int CoinModel::column ( const char *  columnName) const

Column index from column name (-1 if no names or no match)

int CoinModel::type ( ) const
inline

Returns type.

Definition at line 649 of file CoinModel.hpp.

double CoinModel::unsetValue ( ) const
inline

returns unset value

Definition at line 652 of file CoinModel.hpp.

int CoinModel::createPackedMatrix ( CoinPackedMatrix matrix,
const double *  associated 
)

Creates a packed matrix - return number of errors.

int CoinModel::countPlusMinusOne ( CoinBigIndex startPositive,
CoinBigIndex startNegative,
const double *  associated 
)

Fills in startPositive and startNegative with counts for +-1 matrix.

If not +-1 then startPositive[0]==-1 otherwise counts and startPositive[numberColumns]== size

  • return number of errors
void CoinModel::createPlusMinusOne ( CoinBigIndex startPositive,
CoinBigIndex startNegative,
int *  indices,
const double *  associated 
)

Creates +-1 matrix given startPositive and startNegative counts for +-1 matrix.

int CoinModel::createArrays ( double *&  rowLower,
double *&  rowUpper,
double *&  columnLower,
double *&  columnUpper,
double *&  objective,
int *&  integerType,
double *&  associated 
)

Creates copies of various arrays - return number of errors.

bool CoinModel::stringsExist ( ) const
inline

Says if strings exist.

Definition at line 675 of file CoinModel.hpp.

const CoinModelHash* CoinModel::stringArray ( ) const
inline

Return string array.

Definition at line 678 of file CoinModel.hpp.

double* CoinModel::associatedArray ( ) const
inline

Returns associated array.

Definition at line 681 of file CoinModel.hpp.

double* CoinModel::rowLowerArray ( ) const
inline

Return rowLower array.

Definition at line 684 of file CoinModel.hpp.

double* CoinModel::rowUpperArray ( ) const
inline

Return rowUpper array.

Definition at line 687 of file CoinModel.hpp.

double* CoinModel::columnLowerArray ( ) const
inline

Return columnLower array.

Definition at line 690 of file CoinModel.hpp.

double* CoinModel::columnUpperArray ( ) const
inline

Return columnUpper array.

Definition at line 693 of file CoinModel.hpp.

double* CoinModel::objectiveArray ( ) const
inline

Return objective array.

Definition at line 696 of file CoinModel.hpp.

int* CoinModel::integerTypeArray ( ) const
inline

Return integerType array.

Definition at line 699 of file CoinModel.hpp.

const CoinModelHash* CoinModel::rowNames ( ) const
inline

Return row names array.

Definition at line 702 of file CoinModel.hpp.

const CoinModelHash* CoinModel::columnNames ( ) const
inline

Return column names array.

Definition at line 705 of file CoinModel.hpp.

void CoinModel::zapRowNames ( )
inline

Reset row names.

Definition at line 708 of file CoinModel.hpp.

void CoinModel::zapColumnNames ( )
inline

Reset column names.

Definition at line 711 of file CoinModel.hpp.

const int* CoinModel::cutMarker ( ) const
inline

Returns array of 0 or nonzero if can be a cut (or returns NULL)

Definition at line 714 of file CoinModel.hpp.

double CoinModel::optimizationDirection ( ) const
inline

Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.

Definition at line 717 of file CoinModel.hpp.

void CoinModel::setOptimizationDirection ( double  value)
inline

Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.

Definition at line 721 of file CoinModel.hpp.

void* CoinModel::moreInfo ( ) const
inline

Return pointer to more information.

Definition at line 724 of file CoinModel.hpp.

void CoinModel::setMoreInfo ( void info)
inline

Set pointer to more information.

Definition at line 727 of file CoinModel.hpp.

int CoinModel::whatIsSet ( ) const

Returns which parts of model are set 1 - matrix 2 - rhs 4 - row names 8 - column bounds and/or objective 16 - column names 32 - integer types.

void CoinModel::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 bounds.

If a pointer is 0 then the following values are the default:

  • colub: all columns have upper bound infinity
  • collb: all columns have lower bound 0
  • rowub: all rows have upper bound infinity
  • rowlb: all rows have lower bound -infinity
  • obj: all variables have 0 objective coefficient

Note that the default values for rowub and rowlb produce the constraint -infty <= ax <= infty. This is probably not what you want.

void CoinModel::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.

The constraints on the rows are given by sense/rhs/range triplets.

If a pointer is 0 then the following values are the default:

  • colub: all columns have upper bound infinity
  • collb: all columns have lower bound 0
  • obj: all variables have 0 objective coefficient
  • rowsen: all rows are >=
  • rowrhs: all right hand sides are 0
  • rowrng: 0 for the ranged rows

Note that the default values for rowsen, rowrhs, and rowrng produce the constraint ax >= 0.

void CoinModel::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.

The constraint matrix is is specified with standard column-major column starts / row indices / coefficients vectors. The constraints on the rows are given by lower and upper bounds.

The matrix vectors must be gap-free. Note that start must have numcols+1 entries so that the length of the last column can be calculated as start[numcols]-start[numcols-1].

See the previous loadBlock method using rowlb and rowub for default argument values.

void CoinModel::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.

The constraint matrix is is specified with standard column-major column starts / row indices / coefficients vectors. The constraints on the rows are given by sense/rhs/range triplets.

The matrix vectors must be gap-free. Note that start must have numcols+1 entries so that the length of the last column can be calculated as start[numcols]-start[numcols-1].

See the previous loadBlock method using sense/rhs/range for default argument values.

virtual CoinBaseModel* CoinModel::clone ( ) const
virtual

Clone.

Implements CoinBaseModel.

CoinModel& CoinModel::operator= ( const CoinModel )

=

void CoinModel::validateLinks ( ) const

Checks that links are consistent.

void CoinModel::resize ( int  maximumRows,
int  maximumColumns,
int  maximumElements 
)
private

Resize.

void CoinModel::fillRows ( int  which,
bool  forceCreation,
bool  fromAddRow = false 
)
private

Fill in default row information.

void CoinModel::fillColumns ( int  which,
bool  forceCreation,
bool  fromAddColumn = false 
)
private

Fill in default column information.

void CoinModel::fillList ( int  which,
CoinModelLinkedList list,
int  type 
) const
private

Fill in default linked list information (1= row, 2 = column) Marked as const as list is mutable.

void CoinModel::createList ( int  type) const
private

Create a linked list and synchronize free type 1 for row 2 for column Marked as const as list is mutable.

int CoinModel::addString ( const char *  string)
private

Adds one string, returns index.

double CoinModel::getDoubleFromString ( CoinYacc info,
const char *  string 
)
private

Gets a double from a string possibly containing named strings, returns unset if not found.

void CoinModel::freeStringMemory ( CoinYacc info)
private

Frees value memory.

int CoinModel::computeAssociated ( double *  associated)

Fills in all associated - returning number of errors.

CoinPackedMatrix* CoinModel::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 other variables are involved with tiny (1.0e-100) elements and count of total number of variables which could not be put in quadratic form.

void CoinModel::replaceQuadraticRow ( int  rowNumber,
const double *  linear,
const CoinPackedMatrix quadraticPart 
)

Replaces a quadratic row.

CoinModel* CoinModel::reorder ( const char *  mark) const

If possible return a model where if all variables marked nonzero are fixed the problem will be linear.

At present may only work if quadratic. Returns NULL if not possible

int CoinModel::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 - returns number elements On entry numberOutput is maximum allowed, on exit it is number needed or -1 (as will be number elements) if maximum exceeded.

numberOutput will have at least space to return values which reconstruct input. Rows returned will be original rows but no entries will be returned for any rows all of whose entries are in knapsack. So up to user to allow for this. If reConstruct >=0 then returns number of entrie which make up item "reConstruct" in expanded knapsack. Values in buildRow and buildElement;

void CoinModel::setCutMarker ( int  size,
const int *  marker 
)

Sets cut marker array.

void CoinModel::setPriorities ( int  size,
const int *  priorities 
)

Sets priority array.

const int* CoinModel::priorities ( ) const
inline

priorities (given for all columns (-1 if not integer)

Definition at line 919 of file CoinModel.hpp.

void CoinModel::setOriginalIndices ( const int *  row,
const int *  column 
)

For decomposition set original row and column indices.

void CoinModel::gdb ( int  nonLinear,
const char *  fileName,
const void info 
)
private

Read a problem from AMPL nl file so not constructor so gdb will work.

int CoinModel::decodeBit ( char *  phrase,
char *&  nextPhrase,
double &  coefficient,
bool  ifFirst 
) const
private

returns jColumn (-2 if linear term, -1 if unknown) and coefficient

void CoinModel::badType ( ) const
private

Aborts with message about packedMatrix.

Member Data Documentation

int CoinModel::maximumRows_
private

Maximum number of rows.

Definition at line 936 of file CoinModel.hpp.

int CoinModel::maximumColumns_
private

Maximum number of columns.

Definition at line 938 of file CoinModel.hpp.

int CoinModel::numberElements_
private

Current number of elements.

Definition at line 940 of file CoinModel.hpp.

int CoinModel::maximumElements_
private

Maximum number of elements.

Definition at line 942 of file CoinModel.hpp.

int CoinModel::numberQuadraticElements_
private

Current number of quadratic elements.

Definition at line 944 of file CoinModel.hpp.

int CoinModel::maximumQuadraticElements_
private

Maximum number of quadratic elements.

Definition at line 946 of file CoinModel.hpp.

double* CoinModel::rowLower_
private

Row lower.

Definition at line 948 of file CoinModel.hpp.

double* CoinModel::rowUpper_
private

Row upper.

Definition at line 950 of file CoinModel.hpp.

CoinModelHash CoinModel::rowName_
private

Row names.

Definition at line 952 of file CoinModel.hpp.

int* CoinModel::rowType_
private

Row types.

Has information - at present bit 0 - rowLower is a string bit 1 - rowUpper is a string NOTE - if converted to CoinPackedMatrix - may be indices of original rows (i.e. when decomposed)

Definition at line 960 of file CoinModel.hpp.

double* CoinModel::objective_
private

Objective.

Definition at line 962 of file CoinModel.hpp.

double* CoinModel::columnLower_
private

Column Lower.

Definition at line 964 of file CoinModel.hpp.

double* CoinModel::columnUpper_
private

Column Upper.

Definition at line 966 of file CoinModel.hpp.

CoinModelHash CoinModel::columnName_
private

Column names.

Definition at line 968 of file CoinModel.hpp.

int* CoinModel::integerType_
private

Integer information.

Definition at line 970 of file CoinModel.hpp.

CoinModelHash CoinModel::string_
private

Strings.

Definition at line 972 of file CoinModel.hpp.

int* CoinModel::columnType_
private

Column types.

Has information - at present bit 0 - columnLower is a string bit 1 - columnUpper is a string bit 2 - objective is a string bit 3 - integer setting is a string NOTE - if converted to CoinPackedMatrix - may be indices of original columns (i.e. when decomposed)

Definition at line 982 of file CoinModel.hpp.

int* CoinModel::start_
private

If simple then start of each row/column.

Definition at line 984 of file CoinModel.hpp.

CoinModelTriple* CoinModel::elements_
private

Actual elements.

Definition at line 986 of file CoinModel.hpp.

CoinPackedMatrix* CoinModel::packedMatrix_
private

Actual elements as CoinPackedMatrix.

Definition at line 988 of file CoinModel.hpp.

CoinModelHash2 CoinModel::hashElements_
mutableprivate

Hash for elements.

Definition at line 990 of file CoinModel.hpp.

CoinModelLinkedList CoinModel::rowList_
mutableprivate

Linked list for rows.

Definition at line 992 of file CoinModel.hpp.

CoinModelLinkedList CoinModel::columnList_
mutableprivate

Linked list for columns.

Definition at line 994 of file CoinModel.hpp.

CoinModelTriple* CoinModel::quadraticElements_
private

Actual quadratic elements (always linked lists)

Definition at line 996 of file CoinModel.hpp.

CoinModelHash2 CoinModel::hashQuadraticElements_
mutableprivate

Hash for quadratic elements.

Definition at line 998 of file CoinModel.hpp.

int* CoinModel::sortIndices_
private

Array for sorting indices.

Definition at line 1000 of file CoinModel.hpp.

double* CoinModel::sortElements_
private

Array for sorting elements.

Definition at line 1002 of file CoinModel.hpp.

int CoinModel::sortSize_
private

Size of sort arrays.

Definition at line 1004 of file CoinModel.hpp.

CoinModelLinkedList CoinModel::quadraticRowList_
mutableprivate

Linked list for quadratic rows.

Definition at line 1006 of file CoinModel.hpp.

CoinModelLinkedList CoinModel::quadraticColumnList_
mutableprivate

Linked list for quadratic columns.

Definition at line 1008 of file CoinModel.hpp.

int CoinModel::sizeAssociated_
private

Size of associated values.

Definition at line 1010 of file CoinModel.hpp.

double* CoinModel::associated_
private

Associated values.

Definition at line 1012 of file CoinModel.hpp.

int CoinModel::numberSOS_
private

Number of SOS - all these are done in one go e.g. from ampl.

Definition at line 1014 of file CoinModel.hpp.

int* CoinModel::startSOS_
private

SOS starts.

Definition at line 1016 of file CoinModel.hpp.

int* CoinModel::memberSOS_
private

SOS members.

Definition at line 1018 of file CoinModel.hpp.

int* CoinModel::typeSOS_
private

SOS type.

Definition at line 1020 of file CoinModel.hpp.

int* CoinModel::prioritySOS_
private

SOS priority.

Definition at line 1022 of file CoinModel.hpp.

double* CoinModel::referenceSOS_
private

SOS reference.

Definition at line 1024 of file CoinModel.hpp.

int* CoinModel::priority_
private

priorities (given for all columns (-1 if not integer)

Definition at line 1026 of file CoinModel.hpp.

int* CoinModel::cut_
private

Nonzero if row is cut - done in one go e.g. from ampl.

Definition at line 1028 of file CoinModel.hpp.

void* CoinModel::moreInfo_
private

Pointer to more information.

Definition at line 1030 of file CoinModel.hpp.

int CoinModel::type_
mutableprivate

Type of build - -1 unset, 0 for row, 1 for column, 2 linked.

3 matrix is CoinPackedMatrix (and at present can't be modified);

Definition at line 1038 of file CoinModel.hpp.

bool CoinModel::noNames_
private

True if no names EVER being used (for users who know what they are doing)

Definition at line 1040 of file CoinModel.hpp.

int CoinModel::links_
mutableprivate

Links present (could be tested by sizes of objects) 0 - none, 1 - row links, 2 - column links, 3 - both.

Definition at line 1047 of file CoinModel.hpp.


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