167 void addRow(
int numberInRow,
const int * columns,
171 void addColumn(
int numberInColumn,
const int * rows,
172 const double * elements,
173 double columnLower=0.0,
174 double columnUpper=
COIN_DBL_MAX,
double objectiveValue=0.0,
175 const char * name=NULL,
bool isInteger=
false);
177 inline void addCol(
int numberInColumn,
const int * rows,
178 const double * elements,
179 double columnLower=0.0,
180 double columnUpper=
COIN_DBL_MAX,
double objectiveValue=0.0,
181 const char * name=NULL,
bool isInteger=
false)
182 { addColumn(numberInColumn, rows, elements, columnLower, columnUpper, objectiveValue,
185 inline void operator() (
int i,
int j,
double value)
186 { setElement(i,j,value);}
188 void setElement(
int i,
int j,
double value) ;
194 int getRow(
int whichRow,
int * column,
double * element);
200 int getColumn(
int whichColumn,
int * column,
double * element);
202 void setQuadraticElement(
int i,
int j,
double value) ;
204 inline void operator() (
int i,
int j,
const char * value)
205 { setElement(i,j,value);}
207 void setElement(
int i,
int j,
const char * value) ;
209 int associateElement(
const char * stringValue,
double value);
213 void setRowLower(
int whichRow,
double rowLower);
217 void setRowUpper(
int whichRow,
double rowUpper);
221 void setRowBounds(
int whichRow,
double rowLower,
double rowUpper);
225 void setRowName(
int whichRow,
const char * rowName);
229 void setColumnLower(
int whichColumn,
double columnLower);
233 void setColumnUpper(
int whichColumn,
double columnUpper);
237 void setColumnBounds(
int whichColumn,
double columnLower,
double columnUpper);
241 void setColumnObjective(
int whichColumn,
double columnObjective);
245 void setColumnName(
int whichColumn,
const char * columnName);
249 void setColumnIsInteger(
int whichColumn,
bool columnIsInteger);
254 { setColumnObjective( whichColumn, columnObjective);}
259 { setColumnIsInteger( whichColumn, columnIsInteger);}
264 { setColumnIsInteger( whichColumn,
true);}
269 { setColumnIsInteger( whichColumn,
false);}
274 { setColumnLower( whichColumn, columnLower);}
279 { setColumnUpper( whichColumn, columnUpper);}
283 inline void setColBounds(
int whichColumn,
double columnLower,
double columnUpper)
284 { setColumnBounds( whichColumn, columnLower, columnUpper);}
289 { setColumnObjective( whichColumn, columnObjective);}
293 inline void setColName(
int whichColumn,
const char * columnName)
294 { setColumnName( whichColumn, columnName);}
299 { setColumnIsInteger( whichColumn, columnIsInteger);}
303 void setRowLower(
int whichRow,
const char * rowLower);
307 void setRowUpper(
int whichRow,
const char * rowUpper);
311 void setColumnLower(
int whichColumn,
const char * columnLower);
315 void setColumnUpper(
int whichColumn,
const char * columnUpper);
319 void setColumnObjective(
int whichColumn,
const char * columnObjective);
323 void setColumnIsInteger(
int whichColumn,
const char * columnIsInteger);
328 { setColumnObjective( whichColumn, columnObjective);}
333 { setColumnIsInteger( whichColumn, columnIsInteger);}
336 void deleteRow(
int whichRow);
339 void deleteColumn(
int whichColumn);
343 { deleteColumn(whichColumn);}
345 int deleteElement(
int row,
int column);
347 void deleteThisElement(
int row,
int column,
int position);
357 {
return packColumns();}
366 void setObjective(
int numberColumns,
const double * objective) ;
369 void setColumnLower(
int numberColumns,
const double * columnLower);
372 inline void setColLower(
int numberColumns,
const double * columnLower)
373 { setColumnLower( numberColumns, columnLower);}
376 void setColumnUpper(
int numberColumns,
const double * columnUpper);
379 inline void setColUpper(
int numberColumns,
const double * columnUpper)
380 { setColumnUpper( numberColumns, columnUpper);}
383 void setRowLower(
int numberRows,
const double * rowLower);
386 void setRowUpper(
int numberRows,
const double * rowUpper);
413 int writeMps(
const char *filename,
int compression = 0,
414 int formatType = 0,
int numberAcross = 2,
bool keepStrings=
false) ;
420 int differentModel(
CoinModel & other,
bool ignoreNames);
433 {
return packedMatrix_;}
439 {
return columnType_;}
447 {
return numberElements_;}
452 inline double operator() (
int i,
int j)
const 453 {
return getElement(i,j);}
455 double getElement(
int i,
int j)
const;
457 inline double operator() (
const char * rowName,
const char * columnName)
const 458 {
return getElement(rowName,columnName);}
460 double getElement(
const char * rowName,
const char * columnName)
const;
462 double getQuadraticElement(
int i,
int j)
const;
467 const char * getElementAsString(
int i,
int j)
const;
471 double * pointer (
int i,
int j)
const;
475 int position (
int i,
int j)
const;
509 CoinModelLink firstInQuadraticColumn(
int whichColumn)
const ;
516 double getRowLower(
int whichRow)
const ;
519 double getRowUpper(
int whichRow)
const ;
522 const char * getRowName(
int whichRow)
const ;
524 {
return getRowLower(whichRow);}
528 {
return getRowUpper(whichRow) ;}
531 inline const char *
rowName(
int whichRow)
const 532 {
return getRowName(whichRow);}
535 double getColumnLower(
int whichColumn)
const ;
538 double getColumnUpper(
int whichColumn)
const ;
541 double getColumnObjective(
int whichColumn)
const ;
544 const char * getColumnName(
int whichColumn)
const ;
547 bool getColumnIsInteger(
int whichColumn)
const ;
551 {
return getColumnLower(whichColumn);}
555 {
return getColumnUpper(whichColumn) ;}
559 {
return getColumnObjective(whichColumn);}
563 {
return getColumnObjective(whichColumn);}
567 {
return getColumnName(whichColumn);}
571 {
return getColumnIsInteger(whichColumn);}
575 {
return getColumnIsInteger(whichColumn);}
579 {
return getColumnLower(whichColumn);}
583 {
return getColumnUpper(whichColumn) ;}
587 {
return getColumnObjective(whichColumn);}
591 {
return getColumnName(whichColumn);}
595 {
return getColumnIsInteger(whichColumn);}
598 const char * getRowLowerAsString(
int whichRow)
const ;
601 const char * getRowUpperAsString(
int whichRow)
const ;
603 {
return getRowLowerAsString(whichRow);}
607 {
return getRowUpperAsString(whichRow) ;}
610 const char * getColumnLowerAsString(
int whichColumn)
const ;
613 const char * getColumnUpperAsString(
int whichColumn)
const ;
616 const char * getColumnObjectiveAsString(
int whichColumn)
const ;
619 const char * getColumnIsIntegerAsString(
int whichColumn)
const ;
623 {
return getColumnLowerAsString(whichColumn);}
627 {
return getColumnUpperAsString(whichColumn) ;}
631 {
return getColumnObjectiveAsString(whichColumn);}
635 {
return getColumnObjectiveAsString(whichColumn);}
639 {
return getColumnIsIntegerAsString(whichColumn);}
643 {
return getColumnIsIntegerAsString(whichColumn);}
645 int row(
const char * rowName)
const;
647 int column(
const char * columnName)
const;
653 {
return -1.23456787654321e-97;}
656 const double * associated);
663 const double * associated);
668 const double * associated);
670 int createArrays(
double * & rowLower,
double * & rowUpper,
671 double * & columnLower,
double * & columnUpper,
672 double * & objective,
int * & integerType,
673 double * & associated);
676 {
return string_.numberItems()!=0;}
682 {
return associated_;}
691 {
return columnLower_;}
694 {
return columnUpper_;}
697 {
return objective_;}
700 {
return integerType_;}
706 {
return &columnName_;}
737 int whatIsSet()
const;
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);
838 CoinModel(
int numberRows,
int numberColumns,
840 const double * rowLower,
const double * rowUpper,
841 const double * columnLower,
const double * columnUpper,
842 const double * objective);
860 void validateLinks()
const;
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);
876 void createList(
int type)
const;
878 int addString(
const char *
string);
884 void freeStringMemory(
CoinYacc & info);
887 int computeAssociated(
double * associated);
894 int & numberBad)
const;
896 void replaceQuadraticRow(
int rowNumber,
const double * linear,
const CoinPackedMatrix * quadraticPart);
901 CoinModel * reorder(
const char * mark)
const;
912 int expandKnapsack(
int knapsackRow,
int & numberOutput,
double * buildObj,
CoinBigIndex * buildStart,
913 int * buildRow,
double * buildElement,
int reConstruct=-1)
const;
915 void setCutMarker(
int size,
const int * marker);
917 void setPriorities(
int size,
const int * priorities);
922 void setOriginalIndices(
const int * row,
const int * column);
928 void gdb(
int nonLinear,
const char * fileName,
const void * info);
930 int decodeBit(
char * phrase,
char * & nextPhrase,
double & coefficient,
bool ifFirst)
const;
932 void badType()
const;
const char * isIntegerAsString(int whichColumn) const
Gets if integer (if column does not exist then false)
void zapColumnNames()
Reset column names.
const int * cutMarker() const
Returns array of 0 or nonzero if can be a cut (or returns NULL)
bool noNames_
True if no names EVER being used (for users who know what they are doing)
CoinPackedMatrix * packedMatrix_
Actual elements as CoinPackedMatrix.
CoinModelTriple * quadraticElements_
Actual quadratic elements (always linked lists)
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...
const char * columnUpperAsString(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
int sizeAssociated_
Size of associated values.
double columnLower(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
int packCols()
Packs down all columns i.e.
const CoinModelHash * stringArray() const
Return string array.
CoinMessageHandler * handler_
Message handler (Passed in)
bool getColIsInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
bool isInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
double optimizationDirection_
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
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 char * getColName(int whichColumn) const
Gets name (if column does not exist then NULL)
CoinModelLinkedList rowList_
Linked list for rows.
const CoinModelHash * columnNames() const
Return column names array.
int * start_
If simple then start of each row/column.
int numberQuadraticElements_
Current number of quadratic elements.
void deleteCol(int whichColumn)
Deletes all entries in column and bounds.
const CoinPackedMatrix * packedMatrix() const
Return a pointer to CoinPackedMatrix (or NULL)
double optimizationDirection() const
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
int numberColumns() const
Return number of columns.
void setColumnBlock(const std::string &name)
Set column block name.
int numberRows() const
Return number of rows.
int logLevel() const
Get print level 0 - off, 1 - errors, 2 - more.
int numberElements_
Current number of elements.
double * rowLower_
Row lower.
void setColLower(int numberColumns, const double *columnLower)
Sets columnLower array.
virtual CoinBigIndex numberElements() const =0
Return number of elements.
This is for various structures/classes needed by CoinModel.
int sortSize_
Size of sort arrays.
int * cut_
Nonzero if row is cut - done in one go e.g. from ampl.
This is a simple minded model which is stored in a format which makes it easier to construct and modi...
double rowUpper(int whichRow) const
Gets rowUpper (if row does not exist then COIN_DBL_MAX)
double getColLower(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
double * rowUpperArray() const
Return rowUpper array.
int * memberSOS_
SOS members.
const char * columnIsIntegerAsString(int whichColumn) const
Gets if integer (if column does not exist then false)
double unsetValue() const
returns unset value
double * rowUpper_
Row upper.
const char * rowLowerAsString(int whichRow) const
Base class for message handling.
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...
double * columnLowerArray() const
Return columnLower array.
const char * columnLowerAsString(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
int maximumElements_
Maximum number of elements.
const char * rowUpperAsString(int whichRow) const
Gets rowUpper (if row does not exist then COIN_DBL_MAX)
double * columnUpper_
Column Upper.
int maximumQuadraticElements_
Maximum number of quadratic elements.
double columnObjective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
int * columnType_
Column types.
double * rowLowerArray() const
Return rowLower array.
int * priority_
priorities (given for all columns (-1 if not integer)
void setOptimizationDirection(double value)
Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
double * objective_
Objective.
double * referenceSOS_
SOS reference.
CoinModelHash string_
Strings.
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 * columnLower_
Column Lower.
double rowLower(int whichRow) const
This is a first attempt at a message handler.
const std::string & getRowBlock() const
Return the row block name.
CoinModelTriple * elements_
Actual elements.
int * integerTypeArray() const
Return integerType array.
void setContinuous(int whichColumn)
Sets continuous (if column does not exist then all columns up to this are defined with default values...
CoinModelLinkedList quadraticRowList_
Linked list for quadratic rows.
const int * priorities() const
priorities (given for all columns (-1 if not integer)
const char * columnName(int whichColumn) const
Gets name (if column does not exist then NULL)
double * associated_
Associated values.
CoinModelHash2 hashQuadraticElements_
Hash for quadratic elements.
double columnUpper(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
void setMessageHandler(CoinMessageHandler *handler)
Pass in message handler.
CoinModelLinkedList quadraticColumnList_
Linked list for quadratic columns.
CoinBaseModel()
Default Constructor.
bool columnIsInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
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 * moreInfo() const
Return pointer to more information.
int numberSOS_
Number of SOS - all these are done in one go e.g. from ampl.
std::string rowBlockName_
Rowblock name.
void setMoreInfo(void *info)
Set pointer to more information.
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 CoinModelTriple * elements() const
Return elements as triples.
int numberColumns_
Current number of columns.
Sparse Matrix Base Class.
int type_
Type of build - -1 unset, 0 for row, 1 for column, 2 linked.
CoinModelLinkedList columnList_
Linked list for columns.
int * startSOS_
SOS starts.
double objective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
int * prioritySOS_
SOS priority.
void * moreInfo_
Pointer to more information.
CoinMessages messages_
Messages.
virtual CoinBaseModel * clone() const =0
Clone.
const int * originalRows() const
Return pointers to original rows (for decomposition)
void setProblemName(const char *name)
Set problem name.
double optimizationDirection() const
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
const std::string & getColumnBlock() const
Return the column block name.
bool stringsExist() const
Says if strings exist.
const char * objectiveAsString(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
int numberRows_
Current number of rows.
double * columnUpperArray() const
Return columnUpper array.
void zapRowNames()
Reset row names.
double * sortElements_
Array for sorting elements.
double * associatedArray() const
Returns associated array.
double objectiveOffset() const
Returns the (constant) objective offset This is the RHS entry for the objective row.
void setObjective(int whichColumn, const char *columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
double objectiveOffset_
Objective offset to be passed on.
CoinModelHash2 hashElements_
Hash for elements.
int links_
Links present (could be tested by sizes of objects) 0 - none, 1 - row links, 2 - column links...
void setRowBlock(const std::string &name)
Set row block name.
const int * originalColumns() const
Return pointers to original columns (for decomposition)
std::string columnBlockName_
Columnblock name.
void setOptimizationDirection(double value)
Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
double getDoubleFromString(CoinYacc &info, const char *string, const char *x, double xValue)
faster version
int maximumColumns_
Maximum number of columns.
const double COIN_DBL_MAX
void addCol(int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0, const char *name=NULL, bool isInteger=false)
add a column - numberInColumn may be zero */
double getColUpper(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
const char * rowName(int whichRow) const
Gets name (if row does not exist then NULL)
void setLogLevel(int value)
Set print level 0 - off, 1 - errors, 2 - more.
int * sortIndices_
Array for sorting indices.
CoinBaseModel & operator=(const CoinBaseModel &rhs)
Assignment operator.
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 CoinModelHash * rowNames() const
Return row names array.
virtual ~CoinBaseModel()
Destructor.
const char * columnObjectiveAsString(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
int logLevel_
Print level.
void setColUpper(int numberColumns, const double *columnUpper)
Sets columnUpper array.
void setInteger(int whichColumn)
Sets integer (if column does not exist then all columns up to this are defined with default values an...
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...
std::string problemName_
Problem name.
CoinModelHash columnName_
Column names.
double * objectiveArray() const
Return objective array.
double getColObjective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
CoinModelHash rowName_
Row names.
int * integerType_
Integer information.
Class to hold and manipulate an array of massaged messages.
double getFunctionValueFromString(const char *string, const char *x, double xValue)
Just function of single variable x.
void setObjective(int whichColumn, double columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
void setObjectiveOffset(double value)
Set objective offset.
const char * getProblemName() const
Return the problem name.
int type() const
Returns type.