CoinUtils 2.11.4
CoinModel.hpp
Go to the documentation of this file.
1/* $Id$ */
2// Copyright (C) 2005, International Business Machines
3// Corporation and others. All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6#ifndef CoinModel_H
7#define CoinModel_H
8
9#include "CoinModelUseful.hpp"
11#include "CoinPackedMatrix.hpp"
12#include "CoinFinite.hpp"
14
15public:
20
23
26
28 virtual CoinBaseModel *clone() const = 0;
29
31 virtual ~CoinBaseModel();
33
37 inline int numberRows() const
38 {
39 return numberRows_;
40 }
42 inline int numberColumns() const
43 {
44 return numberColumns_;
45 }
47 virtual CoinBigIndex numberElements() const = 0;
51 inline double objectiveOffset() const
52 {
53 return objectiveOffset_;
54 }
56 inline void setObjectiveOffset(double value)
57 {
58 objectiveOffset_ = value;
59 }
61 inline double optimizationDirection() const
62 {
64 }
66 inline void setOptimizationDirection(double value)
67 {
69 }
71 inline int logLevel() const
72 {
73 return logLevel_;
74 }
76 void setLogLevel(int value);
78 inline const char *getProblemName() const
79 {
80 return problemName_.c_str();
81 }
83 void setProblemName(const char *name);
85 void setProblemName(const std::string &name);
87 inline const std::string &getRowBlock() const
88 {
89 return rowBlockName_;
90 }
92 inline void setRowBlock(const std::string &name)
93 {
94 rowBlockName_ = name;
95 }
97 inline const std::string &getColumnBlock() const
98 {
99 return columnBlockName_;
100 }
102 inline void setColumnBlock(const std::string &name)
103 {
104 columnBlockName_ = name;
105 }
109
110protected:
122 std::string problemName_;
124 std::string rowBlockName_;
126 std::string columnBlockName_;
131
142
143};
144
181class CoinModel : public CoinBaseModel {
182
183public:
187 void addRow(int numberInRow, const int *columns,
188 const double *elements, double rowLower = -COIN_DBL_MAX,
189 double rowUpper = COIN_DBL_MAX, const char *name = NULL);
191 void addColumn(int numberInColumn, const int *rows,
192 const double *elements,
193 double columnLower = 0.0,
194 double columnUpper = COIN_DBL_MAX, double objectiveValue = 0.0,
195 const char *name = NULL, bool isInteger = false);
197 inline void addCol(int numberInColumn, const int *rows,
198 const double *elements,
199 double columnLower = 0.0,
200 double columnUpper = COIN_DBL_MAX, double objectiveValue = 0.0,
201 const char *name = NULL, bool isInteger = false)
202 {
203 addColumn(numberInColumn, rows, elements, columnLower, columnUpper, objectiveValue,
204 name, isInteger);
205 }
207 inline void operator()(int i, int j, double value)
208 {
209 setElement(i, j, value);
210 }
212 void setElement(int i, int j, double value);
218 int getRow(int whichRow, int *column, double *element);
224 int getColumn(int whichColumn, int *column, double *element);
226 void setQuadraticElement(int i, int j, double value);
228 inline void operator()(int i, int j, const char *value)
229 {
230 setElement(i, j, value);
231 }
233 void setElement(int i, int j, const char *value);
235 int associateElement(const char *stringValue, double value);
239 void setRowLower(int whichRow, double rowLower);
243 void setRowUpper(int whichRow, double rowUpper);
247 void setRowBounds(int whichRow, double rowLower, double rowUpper);
251 void setRowName(int whichRow, const char *rowName);
255 void setColumnLower(int whichColumn, double columnLower);
259 void setColumnUpper(int whichColumn, double columnUpper);
263 void setColumnBounds(int whichColumn, double columnLower, double columnUpper);
267 void setColumnObjective(int whichColumn, double columnObjective);
271 void setColumnName(int whichColumn, const char *columnName);
275 void setColumnIsInteger(int whichColumn, bool columnIsInteger);
279 inline void setObjective(int whichColumn, double columnObjective)
280 {
282 }
286 inline void setIsInteger(int whichColumn, bool columnIsInteger)
287 {
289 }
293 inline void setInteger(int whichColumn)
294 {
295 setColumnIsInteger(whichColumn, true);
296 }
300 inline void setContinuous(int whichColumn)
301 {
302 setColumnIsInteger(whichColumn, false);
303 }
307 inline void setColLower(int whichColumn, double columnLower)
308 {
309 setColumnLower(whichColumn, columnLower);
310 }
314 inline void setColUpper(int whichColumn, double columnUpper)
315 {
316 setColumnUpper(whichColumn, columnUpper);
317 }
321 inline void setColBounds(int whichColumn, double columnLower, double columnUpper)
322 {
324 }
328 inline void setColObjective(int whichColumn, double columnObjective)
329 {
331 }
335 inline void setColName(int whichColumn, const char *columnName)
336 {
337 setColumnName(whichColumn, columnName);
338 }
342 inline void setColIsInteger(int whichColumn, bool columnIsInteger)
343 {
345 }
349 void setRowLower(int whichRow, const char *rowLower);
353 void setRowUpper(int whichRow, const char *rowUpper);
357 void setColumnLower(int whichColumn, const char *columnLower);
361 void setColumnUpper(int whichColumn, const char *columnUpper);
365 void setColumnObjective(int whichColumn, const char *columnObjective);
369 void setColumnIsInteger(int whichColumn, const char *columnIsInteger);
373 inline void setObjective(int whichColumn, const char *columnObjective)
374 {
376 }
380 inline void setIsInteger(int whichColumn, const char *columnIsInteger)
381 {
383 }
386 void deleteRow(int whichRow);
389 void deleteColumn(int whichColumn);
392 inline void deleteCol(int whichColumn)
393 {
394 deleteColumn(whichColumn);
395 }
402 int packRows();
408 inline int packCols()
409 {
410 return packColumns();
411 }
416 int pack();
417
420 void setObjective(int numberColumns, const double *objective);
423 void setColumnLower(int numberColumns, const double *columnLower);
426 inline void setColLower(int numberColumns, const double *columnLower)
427 {
429 }
432 void setColumnUpper(int numberColumns, const double *columnUpper);
435 inline void setColUpper(int numberColumns, const double *columnUpper)
436 {
438 }
441 void setRowLower(int numberRows, const double *rowLower);
444 void setRowUpper(int numberRows, const double *rowUpper);
445
471 int writeMps(const char *filename, int compression = 0,
472 int formatType = 0, int numberAcross = 2, bool keepStrings = false);
473
478 int differentModel(CoinModel &other, bool ignoreNames);
480
484 void passInMatrix(const CoinPackedMatrix &matrix);
489 inline const CoinPackedMatrix *packedMatrix() const
490 {
491 return packedMatrix_;
492 }
494 inline const int *originalRows() const
495 {
496 return rowType_;
497 }
499 inline const int *originalColumns() const
500 {
501 return columnType_;
502 }
504
509 {
510 return numberElements_;
511 }
513 inline const CoinModelTriple *elements() const
514 {
515 return elements_;
516 }
518 inline double operator()(int i, int j) const
519 {
520 return getElement(i, j);
521 }
523 double getElement(int i, int j) const;
525 inline double operator()(const char *rowName, const char *columnName) const
526 {
528 }
530 double getElement(const char *rowName, const char *columnName) const;
532 double getQuadraticElement(int i, int j) const;
537 const char *getElementAsString(int i, int j) const;
541 double *pointer(int i, int j) const;
545 CoinBigIndex position(int i, int j) const;
546
550 CoinModelLink firstInRow(int whichRow) const;
554 CoinModelLink lastInRow(int whichRow) const;
558 CoinModelLink firstInColumn(int whichColumn) const;
562 CoinModelLink lastInColumn(int whichColumn) const;
578 CoinModelLink firstInQuadraticColumn(int whichColumn) const;
582 CoinModelLink lastInQuadraticColumn(int whichColumn) const;
585 double getRowLower(int whichRow) const;
588 double getRowUpper(int whichRow) const;
591 const char *getRowName(int whichRow) const;
592 inline double rowLower(int whichRow) const
593 {
594 return getRowLower(whichRow);
595 }
598 inline double rowUpper(int whichRow) const
599 {
600 return getRowUpper(whichRow);
601 }
604 inline const char *rowName(int whichRow) const
605 {
606 return getRowName(whichRow);
607 }
610 double getColumnLower(int whichColumn) const;
613 double getColumnUpper(int whichColumn) const;
616 double getColumnObjective(int whichColumn) const;
619 const char *getColumnName(int whichColumn) const;
622 bool getColumnIsInteger(int whichColumn) const;
625 inline double columnLower(int whichColumn) const
626 {
627 return getColumnLower(whichColumn);
628 }
631 inline double columnUpper(int whichColumn) const
632 {
633 return getColumnUpper(whichColumn);
634 }
637 inline double columnObjective(int whichColumn) const
638 {
639 return getColumnObjective(whichColumn);
640 }
643 inline double objective(int whichColumn) const
644 {
645 return getColumnObjective(whichColumn);
646 }
649 inline const char *columnName(int whichColumn) const
650 {
651 return getColumnName(whichColumn);
652 }
655 inline bool columnIsInteger(int whichColumn) const
656 {
657 return getColumnIsInteger(whichColumn);
658 }
661 inline bool isInteger(int whichColumn) const
662 {
663 return getColumnIsInteger(whichColumn);
664 }
667 inline double getColLower(int whichColumn) const
668 {
669 return getColumnLower(whichColumn);
670 }
673 inline double getColUpper(int whichColumn) const
674 {
675 return getColumnUpper(whichColumn);
676 }
679 inline double getColObjective(int whichColumn) const
680 {
681 return getColumnObjective(whichColumn);
682 }
685 inline const char *getColName(int whichColumn) const
686 {
687 return getColumnName(whichColumn);
688 }
691 inline bool getColIsInteger(int whichColumn) const
692 {
693 return getColumnIsInteger(whichColumn);
694 }
697 const char *getRowLowerAsString(int whichRow) const;
700 const char *getRowUpperAsString(int whichRow) const;
701 inline const char *rowLowerAsString(int whichRow) const
702 {
703 return getRowLowerAsString(whichRow);
704 }
707 inline const char *rowUpperAsString(int whichRow) const
708 {
709 return getRowUpperAsString(whichRow);
710 }
713 const char *getColumnLowerAsString(int whichColumn) const;
716 const char *getColumnUpperAsString(int whichColumn) const;
719 const char *getColumnObjectiveAsString(int whichColumn) const;
722 const char *getColumnIsIntegerAsString(int whichColumn) const;
725 inline const char *columnLowerAsString(int whichColumn) const
726 {
727 return getColumnLowerAsString(whichColumn);
728 }
731 inline const char *columnUpperAsString(int whichColumn) const
732 {
733 return getColumnUpperAsString(whichColumn);
734 }
737 inline const char *columnObjectiveAsString(int whichColumn) const
738 {
739 return getColumnObjectiveAsString(whichColumn);
740 }
743 inline const char *objectiveAsString(int whichColumn) const
744 {
745 return getColumnObjectiveAsString(whichColumn);
746 }
749 inline const char *columnIsIntegerAsString(int whichColumn) const
750 {
751 return getColumnIsIntegerAsString(whichColumn);
752 }
755 inline const char *isIntegerAsString(int whichColumn) const
756 {
757 return getColumnIsIntegerAsString(whichColumn);
758 }
760 int row(const char *rowName) const;
762 int column(const char *columnName) const;
764 inline int type() const
765 {
766 return type_;
767 }
769 inline double unsetValue() const
770 {
771 return -1.23456787654321e-97;
772 }
775 const double *associated);
781 int countPlusMinusOne(CoinBigIndex *startPositive, CoinBigIndex *startNegative,
782 const double *associated);
785 void createPlusMinusOne(CoinBigIndex *startPositive, CoinBigIndex *startNegative,
786 int *indices,
787 const double *associated);
789 int createArrays(double *&rowLower, double *&rowUpper,
790 double *&columnLower, double *&columnUpper,
791 double *&objective, int *&integerType,
792 double *&associated);
794 inline bool stringsExist() const
795 {
796 return string_.numberItems() != 0;
797 }
799 inline const CoinModelHash *stringArray() const
800 {
801 return &string_;
802 }
804 inline double *associatedArray() const
805 {
806 return associated_;
807 }
809 inline double *rowLowerArray() const
810 {
811 return rowLower_;
812 }
814 inline double *rowUpperArray() const
815 {
816 return rowUpper_;
817 }
819 inline double *columnLowerArray() const
820 {
821 return columnLower_;
822 }
824 inline double *columnUpperArray() const
825 {
826 return columnUpper_;
827 }
829 inline double *objectiveArray() const
830 {
831 return objective_;
832 }
834 inline int *integerTypeArray() const
835 {
836 return integerType_;
837 }
839 inline const CoinModelHash *rowNames() const
840 {
841 return &rowName_;
842 }
844 inline const CoinModelHash *columnNames() const
845 {
846 return &columnName_;
847 }
849 inline void zapRowNames()
850 {
852 }
854 inline void zapColumnNames()
855 {
857 }
859 inline const int *cutMarker() const
860 {
861 return cut_;
862 }
864 inline double optimizationDirection() const
865 {
867 }
869 inline void setOptimizationDirection(double value)
870 {
872 }
874 inline void *moreInfo() const
875 {
876 return moreInfo_;
877 }
879 inline void setMoreInfo(void *info)
880 {
881 moreInfo_ = info;
882 }
891 int whatIsSet() const;
893
911 void loadBlock(const CoinPackedMatrix &matrix,
912 const double *collb, const double *colub,
913 const double *obj,
914 const double *rowlb, const double *rowub);
931 void loadBlock(const CoinPackedMatrix &matrix,
932 const double *collb, const double *colub,
933 const double *obj,
934 const char *rowsen, const double *rowrhs,
935 const double *rowrng);
936
949 void loadBlock(const int numcols, const int numrows,
950 const CoinBigIndex *start, const int *index,
951 const double *value,
952 const double *collb, const double *colub,
953 const double *obj,
954 const double *rowlb, const double *rowub);
955
968 void loadBlock(const int numcols, const int numrows,
969 const CoinBigIndex *start, const int *index,
970 const double *value,
971 const double *collb, const double *colub,
972 const double *obj,
973 const char *rowsen, const double *rowrhs,
974 const double *rowrng);
975
977
983 CoinModel(int firstRows, int firstColumns, CoinBigIndex firstElements, bool noNames = false);
986 CoinModel(const char *fileName, int allowStrings = 0);
990 CoinModel(int nonLinear, const char *fileName, const void *info);
993 const CoinPackedMatrix *matrix,
994 const double *rowLower, const double *rowUpper,
995 const double *columnLower, const double *columnUpper,
996 const double *objective);
998 virtual CoinBaseModel *clone() const;
999
1001 virtual ~CoinModel();
1003
1011
1015 void validateLinks() const;
1017private:
1019 void resize(int maximumRows, int maximumColumns, CoinBigIndex maximumElements);
1021 void fillRows(int which, bool forceCreation, bool fromAddRow = false);
1023 void fillColumns(int which, bool forceCreation, bool fromAddColumn = false);
1026 void fillList(int which, CoinModelLinkedList &list, int type) const;
1030 void createList(int type) const;
1032 int addString(const char *string);
1036 double getDoubleFromString(CoinYacc &info, const char *string);
1039
1040public:
1042 int computeAssociated(double *associated);
1048 CoinPackedMatrix *quadraticRow(int rowNumber, double *linear,
1049 int &numberBad) const;
1051 void replaceQuadraticRow(int rowNumber, const double *linear, const CoinPackedMatrix *quadraticPart);
1056 CoinModel *reorder(const char *mark) const;
1067 int expandKnapsack(int knapsackRow, int &numberOutput, double *buildObj, CoinBigIndex *buildStart,
1068 int *buildRow, double *buildElement, int reConstruct = -1) const;
1070 void setCutMarker(int size, const int *marker);
1072 void setPriorities(int size, const int *priorities);
1074 inline const int *priorities() const
1075 {
1076 return priority_;
1077 }
1079 void setOriginalIndices(const int *row, const int *column);
1080
1081private:
1085 void gdb(int nonLinear, const char *fileName, const void *info);
1087 int decodeBit(char *phrase, char *&nextPhrase, double &coefficient, bool ifFirst) const;
1089 void badType() const;
1105 double *rowLower_;
1107 double *rowUpper_;
1119 double *objective_;
1185 int *cut_;
1195 mutable int type_;
1204 mutable int links_;
1206};
1208double getFunctionValueFromString(const char *string, const char *x, double xValue);
1210double getDoubleFromString(CoinYacc &info, const char *string, const char *x, double xValue);
1211#endif
1212
1213/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
1214*/
const double COIN_DBL_MAX
Definition: CoinFinite.hpp:18
This is a first attempt at a message handler.
double getDoubleFromString(CoinYacc &info, const char *string, const char *x, double xValue)
faster version
double getFunctionValueFromString(const char *string, const char *x, double xValue)
Just function of single variable x.
int CoinBigIndex
void setObjectiveOffset(double value)
Set objective offset.
Definition: CoinModel.hpp:56
void setLogLevel(int value)
Set print level 0 - off, 1 - errors, 2 - more.
void setMessageHandler(CoinMessageHandler *handler)
Pass in message handler.
virtual ~CoinBaseModel()
Destructor.
CoinBaseModel & operator=(const CoinBaseModel &rhs)
Assignment operator.
void setRowBlock(const std::string &name)
Set row block name.
Definition: CoinModel.hpp:92
const char * getProblemName() const
Return the problem name.
Definition: CoinModel.hpp:78
void setProblemName(const char *name)
Set problem name.
int logLevel() const
Get print level 0 - off, 1 - errors, 2 - more.
Definition: CoinModel.hpp:71
double optimizationDirection() const
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Definition: CoinModel.hpp:61
int numberRows() const
Return number of rows.
Definition: CoinModel.hpp:37
void setProblemName(const std::string &name)
Set problem name.
double objectiveOffset() const
Returns the (constant) objective offset This is the RHS entry for the objective row.
Definition: CoinModel.hpp:51
void setColumnBlock(const std::string &name)
Set column block name.
Definition: CoinModel.hpp:102
CoinMessages messages_
Messages.
Definition: CoinModel.hpp:130
virtual CoinBaseModel * clone() const =0
Clone.
int numberColumns_
Current number of columns.
Definition: CoinModel.hpp:116
int numberRows_
Current number of rows.
Definition: CoinModel.hpp:114
const std::string & getColumnBlock() const
Return the column block name.
Definition: CoinModel.hpp:97
CoinMessageHandler * handler_
Message handler (Passed in)
Definition: CoinModel.hpp:128
CoinBaseModel()
Default Constructor.
std::string rowBlockName_
Rowblock name.
Definition: CoinModel.hpp:124
void setOptimizationDirection(double value)
Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Definition: CoinModel.hpp:66
virtual CoinBigIndex numberElements() const =0
Return number of elements.
int logLevel_
Print level.
Definition: CoinModel.hpp:140
CoinBaseModel(const CoinBaseModel &rhs)
Copy constructor.
int numberColumns() const
Return number of columns.
Definition: CoinModel.hpp:42
std::string problemName_
Problem name.
Definition: CoinModel.hpp:122
double objectiveOffset_
Objective offset to be passed on.
Definition: CoinModel.hpp:120
std::string columnBlockName_
Columnblock name.
Definition: CoinModel.hpp:126
const std::string & getRowBlock() const
Return the row block name.
Definition: CoinModel.hpp:87
double optimizationDirection_
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Definition: CoinModel.hpp:118
Base class for message handling.
Class to hold and manipulate an array of massaged messages.
For int,int hashing.
int numberItems() const
Number of items i.e. rows if just row names.
This is a simple minded model which is stored in a format which makes it easier to construct and modi...
Definition: CoinModel.hpp:181
int * priority_
priorities (given for all columns (-1 if not integer)
Definition: CoinModel.hpp:1183
CoinBigIndex maximumQuadraticElements_
Maximum number of quadratic elements.
Definition: CoinModel.hpp:1103
CoinModelLink firstInColumn(int whichColumn) const
Returns first element in given column - index is -1 if none.
const char * getColName(int whichColumn) const
Gets name (if column does not exist then NULL)
Definition: CoinModel.hpp:685
double rowUpper(int whichRow) const
Gets rowUpper (if row does not exist then COIN_DBL_MAX)
Definition: CoinModel.hpp:598
double getDoubleFromString(CoinYacc &info, const char *string)
Gets a double from a string possibly containing named strings, returns unset if not found.
int numberSOS_
Number of SOS - all these are done in one go e.g. from ampl.
Definition: CoinModel.hpp:1171
int getColumn(int whichColumn, int *column, double *element)
Gets sorted column - user must provide enough space (easiest is allocate number of rows).
const char * getRowName(int whichRow) const
Gets name (if row does not exist then NULL)
int * typeSOS_
SOS type.
Definition: CoinModel.hpp:1177
int getRow(int whichRow, int *column, double *element)
Gets sorted row - user must provide enough space (easiest is allocate number of columns).
void setRowBounds(int whichRow, double rowLower, double rowUpper)
Sets rowLower and rowUpper (if row does not exist then all rows up to this are defined with default v...
double getRowUpper(int whichRow) const
Gets rowUpper (if row does not exist then +COIN_DBL_MAX)
int decodeBit(char *phrase, char *&nextPhrase, double &coefficient, bool ifFirst) const
returns jColumn (-2 if linear term, -1 if unknown) and coefficient
double * associated_
Associated values.
Definition: CoinModel.hpp:1169
double columnObjective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
Definition: CoinModel.hpp:637
CoinModel(const char *fileName, int allowStrings=0)
Read a problem in MPS or GAMS format from the given filename.
void setObjective(int whichColumn, double columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
Definition: CoinModel.hpp:279
const char * getRowUpperAsString(int whichRow) const
Gets rowUpper (if row does not exist then +COIN_DBL_MAX)
double * associatedArray() const
Returns associated array.
Definition: CoinModel.hpp:804
double * rowLowerArray() const
Return rowLower array.
Definition: CoinModel.hpp:809
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...
Definition: CoinModel.hpp:286
CoinModel(int nonLinear, const char *fileName, const void *info)
Read a problem from AMPL nl file NOTE - as I can't work out configure etc the source code is in Cbc_a...
int computeAssociated(double *associated)
Fills in all associated - returning number of errors.
int createArrays(double *&rowLower, double *&rowUpper, double *&columnLower, double *&columnUpper, double *&objective, int *&integerType, double *&associated)
Creates copies of various arrays - return number of errors.
const char * getColumnObjectiveAsString(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
const char * getElementAsString(int i, int j) const
Returns value for row i and column j as string.
double columnUpper(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
Definition: CoinModel.hpp:631
void setColumnBounds(int whichColumn, double columnLower, double columnUpper)
Sets columnLower and columnUpper (if column does not exist then all columns up to this are defined wi...
int expandKnapsack(int knapsackRow, int &numberOutput, double *buildObj, CoinBigIndex *buildStart, int *buildRow, double *buildElement, int reConstruct=-1) const
Expands out all possible combinations for a knapsack If buildObj NULL then just computes space needed...
void setRowLower(int whichRow, const char *rowLower)
Sets rowLower (if row does not exist then all rows up to this are defined with default values and no ...
void setColumnLower(int whichColumn, double columnLower)
Sets columnLower (if column does not exist then all columns up to this are defined with default value...
const char * isIntegerAsString(int whichColumn) const
Gets if integer (if column does not exist then false)
Definition: CoinModel.hpp:755
bool stringsExist() const
Says if strings exist.
Definition: CoinModel.hpp:794
void setQuadraticElement(int i, int j, double value)
Sets quadratic value for column i and j.
int countPlusMinusOne(CoinBigIndex *startPositive, CoinBigIndex *startNegative, const double *associated)
Fills in startPositive and startNegative with counts for +-1 matrix.
void setColumnLower(int numberColumns, const double *columnLower)
Sets columnLower array.
void setColLower(int numberColumns, const double *columnLower)
Sets columnLower array.
Definition: CoinModel.hpp:426
CoinModelLink lastInRow(int whichRow) const
Returns last element in given row - index is -1 if none.
CoinModelHash string_
Strings.
Definition: CoinModel.hpp:1129
void setColumnIsInteger(int whichColumn, const char *columnIsInteger)
Sets integer (if column does not exist then all columns up to this are defined with default values an...
void setOriginalIndices(const int *row, const int *column)
For decomposition set original row and column indices.
void setColName(int whichColumn, const char *columnName)
Sets name (if column does not exist then all columns up to this are defined with default values and n...
Definition: CoinModel.hpp:335
CoinModelLink lastInQuadraticColumn(int whichColumn) const
Returns last element in given quadratic column - index is -1 if none.
int maximumColumns_
Maximum number of columns.
Definition: CoinModel.hpp:1095
int whatIsSet() const
Returns which parts of model are set 1 - matrix 2 - rhs 4 - row names 8 - column bounds and/or object...
void setElement(int i, int j, double value)
Sets value for row i and column j.
void badType() const
Aborts with message about packedMatrix.
CoinBigIndex maximumElements_
Maximum number of elements.
Definition: CoinModel.hpp:1099
CoinModelLinkedList rowList_
Linked list for rows.
Definition: CoinModel.hpp:1149
double getElement(int i, int j) const
Returns value for row i and column j.
int packRows()
Packs down all rows i.e.
void setColumnUpper(int whichColumn, const char *columnUpper)
Sets columnUpper (if column does not exist then all columns up to this are defined with default value...
void addCol(int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0, const char *name=NULL, bool isInteger=false)
add a column - numberInColumn may be zero *‍/
Definition: CoinModel.hpp:197
void deleteColumn(int whichColumn)
Deletes all entries in column and bounds and objective.
int convertMatrix()
Convert elements to CoinPackedMatrix (and switch off element updates).
int * memberSOS_
SOS members.
Definition: CoinModel.hpp:1175
void setColumnLower(int whichColumn, const char *columnLower)
Sets columnLower (if column does not exist then all columns up to this are defined with default value...
void zapColumnNames()
Reset column names.
Definition: CoinModel.hpp:854
double getRowLower(int whichRow) const
Gets rowLower (if row does not exist then -COIN_DBL_MAX)
CoinBigIndex * start_
If simple then start of each row/column.
Definition: CoinModel.hpp:1141
void setColUpper(int numberColumns, const double *columnUpper)
Sets columnUpper array.
Definition: CoinModel.hpp:435
bool columnIsInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
Definition: CoinModel.hpp:655
int row(const char *rowName) const
Row index from row name (-1 if no names or no match)
void deleteRow(int whichRow)
Deletes all entries in row and bounds.
CoinModelLink previous(CoinModelLink &current) const
Returns previous element in current row or column - index is -1 if none.
double getColumnLower(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
int type() const
Returns type.
Definition: CoinModel.hpp:764
CoinBigIndex numberElements() const
Return number of elements.
Definition: CoinModel.hpp:508
CoinBigIndex numberElements_
Current number of elements.
Definition: CoinModel.hpp:1097
void setMoreInfo(void *info)
Set pointer to more information.
Definition: CoinModel.hpp:879
void setColumnUpper(int numberColumns, const double *columnUpper)
Sets columnUpper array.
void setColObjective(int whichColumn, double columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
Definition: CoinModel.hpp:328
int associateElement(const char *stringValue, double value)
Associates a string with a value. Returns string id (or -1 if does not exist)
const CoinModelTriple * elements() const
Return elements as triples.
Definition: CoinModel.hpp:513
int packColumns()
Packs down all columns i.e.
void loadBlock(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const char *rowsen, const double *rowrhs, const double *rowrng)
Load in a problem by copying the arguments.
int * rowType_
Row types.
Definition: CoinModel.hpp:1117
void setRowUpper(int whichRow, const char *rowUpper)
Sets rowUpper (if row does not exist then all rows up to this are defined with default values and no ...
void setContinuous(int whichColumn)
Sets continuous (if column does not exist then all columns up to this are defined with default values...
Definition: CoinModel.hpp:300
const CoinModelHash * stringArray() const
Return string array.
Definition: CoinModel.hpp:799
void setRowLower(int numberRows, const double *rowLower)
Sets rowLower array.
double * rowUpper_
Row upper.
Definition: CoinModel.hpp:1107
int maximumRows_
Maximum number of rows.
Definition: CoinModel.hpp:1093
CoinModel()
Default constructor.
void loadBlock(const int numcols, const int numrows, const CoinBigIndex *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
Load in a problem by copying the arguments.
void setInteger(int whichColumn)
Sets integer (if column does not exist then all columns up to this are defined with default values an...
Definition: CoinModel.hpp:293
double getColUpper(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
Definition: CoinModel.hpp:673
const char * getRowLowerAsString(int whichRow) const
Gets rowLower (if row does not exist then -COIN_DBL_MAX)
int * startSOS_
SOS starts.
Definition: CoinModel.hpp:1173
void gdb(int nonLinear, const char *fileName, const void *info)
Read a problem from AMPL nl file so not constructor so gdb will work.
const char * rowLowerAsString(int whichRow) const
Definition: CoinModel.hpp:701
double operator()(int i, int j) const
Returns value for row i and column j.
Definition: CoinModel.hpp:518
void operator()(int i, int j, double value)
Sets value for row i and column j.
Definition: CoinModel.hpp:207
CoinModelLink firstInQuadraticColumn(int whichColumn) const
Returns first element in given quadratic column - index is -1 if none.
void fillList(int which, CoinModelLinkedList &list, int type) const
Fill in default linked list information (1= row, 2 = column) Marked as const as list is mutable.
void zapRowNames()
Reset row names.
Definition: CoinModel.hpp:849
double rowLower(int whichRow) const
Definition: CoinModel.hpp:592
const CoinPackedMatrix * packedMatrix() const
Return a pointer to CoinPackedMatrix (or NULL)
Definition: CoinModel.hpp:489
void setColumnName(int whichColumn, const char *columnName)
Sets name (if column does not exist then all columns up to this are defined with default values and n...
const char * objectiveAsString(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
Definition: CoinModel.hpp:743
CoinModelHash rowName_
Row names.
Definition: CoinModel.hpp:1109
CoinBigIndex deleteElement(int row, int column)
Takes element out of matrix - returning position (<0 if not there);.
void resize(int maximumRows, int maximumColumns, CoinBigIndex maximumElements)
Resize.
const char * getColumnIsIntegerAsString(int whichColumn) const
Gets if integer (if column does not exist then false)
const int * cutMarker() const
Returns array of 0 or nonzero if can be a cut (or returns NULL)
Definition: CoinModel.hpp:859
int sortSize_
Size of sort arrays.
Definition: CoinModel.hpp:1161
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...
Definition: CoinModel.hpp:321
bool isInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
Definition: CoinModel.hpp:661
void fillColumns(int which, bool forceCreation, bool fromAddColumn=false)
Fill in default column information.
int createPackedMatrix(CoinPackedMatrix &matrix, const double *associated)
Creates a packed matrix - return number of errors.
double * columnUpperArray() const
Return columnUpper array.
Definition: CoinModel.hpp:824
bool noNames_
True if no names EVER being used (for users who know what they are doing)
Definition: CoinModel.hpp:1197
int addString(const char *string)
Adds one string, returns index.
const int * originalColumns() const
Return pointers to original columns (for decomposition)
Definition: CoinModel.hpp:499
int type_
Type of build - -1 unset, 0 for row, 1 for column, 2 linked.
Definition: CoinModel.hpp:1195
virtual ~CoinModel()
Destructor.
void setColumnObjective(int whichColumn, const char *columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
void setIsInteger(int whichColumn, const char *columnIsInteger)
Sets integer (if column does not exist then all columns up to this are defined with default values an...
Definition: CoinModel.hpp:380
bool getColumnIsInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
CoinModel & operator=(const CoinModel &)
=
int * prioritySOS_
SOS priority.
Definition: CoinModel.hpp:1179
CoinModelLinkedList quadraticColumnList_
Linked list for quadratic columns.
Definition: CoinModel.hpp:1165
double * sortElements_
Array for sorting elements.
Definition: CoinModel.hpp:1159
double getColumnObjective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
double unsetValue() const
returns unset value
Definition: CoinModel.hpp:769
void freeStringMemory(CoinYacc &info)
Frees value memory.
void setElement(int i, int j, const char *value)
Sets value for row i and column j as string.
double * objectiveArray() const
Return objective array.
Definition: CoinModel.hpp:829
void setRowUpper(int numberRows, const double *rowUpper)
Sets rowUpper array.
void setColumnIsInteger(int whichColumn, bool columnIsInteger)
Sets integer state (if column does not exist then all columns up to this are defined with default val...
CoinModelTriple * elements_
Actual elements.
Definition: CoinModel.hpp:1143
int * columnType_
Column types.
Definition: CoinModel.hpp:1139
CoinModelHash columnName_
Column names.
Definition: CoinModel.hpp:1125
void loadBlock(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
Load in a problem by copying the arguments.
CoinModelLink firstInRow(int whichRow) const
Returns first element in given row - index is -1 if none.
CoinModel(int numberRows, int numberColumns, const CoinPackedMatrix *matrix, const double *rowLower, const double *rowUpper, const double *columnLower, const double *columnUpper, const double *objective)
From arrays.
int * integerType_
Integer information.
Definition: CoinModel.hpp:1127
const char * columnName(int whichColumn) const
Gets name (if column does not exist then NULL)
Definition: CoinModel.hpp:649
CoinModelLink lastInColumn(int whichColumn) const
Returns last element in given column - index is -1 if none.
double * rowUpperArray() const
Return rowUpper array.
Definition: CoinModel.hpp:814
void setObjective(int numberColumns, const double *objective)
Sets columnObjective array.
CoinModelTriple * quadraticElements_
Actual quadratic elements (always linked lists)
Definition: CoinModel.hpp:1153
void setRowLower(int whichRow, double rowLower)
Sets rowLower (if row does not exist then all rows up to this are defined with default values and no ...
const char * rowName(int whichRow) const
Gets name (if row does not exist then NULL)
Definition: CoinModel.hpp:604
double getQuadraticElement(int i, int j) const
Returns quadratic value for columns i and j.
const char * getColumnUpperAsString(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
void setColUpper(int whichColumn, double columnUpper)
Sets columnUpper (if column does not exist then all columns up to this are defined with default value...
Definition: CoinModel.hpp:314
virtual CoinBaseModel * clone() const
Clone.
double * columnUpper_
Column Upper.
Definition: CoinModel.hpp:1123
double getColLower(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
Definition: CoinModel.hpp:667
const char * columnLowerAsString(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
Definition: CoinModel.hpp:725
const char * columnIsIntegerAsString(int whichColumn) const
Gets if integer (if column does not exist then false)
Definition: CoinModel.hpp:749
void setOptimizationDirection(double value)
Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Definition: CoinModel.hpp:869
const char * getColumnName(int whichColumn) const
Gets name (if column does not exist then NULL)
void addColumn(int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0, const char *name=NULL, bool isInteger=false)
add a column - numberInColumn may be zero *‍/
const char * rowUpperAsString(int whichRow) const
Gets rowUpper (if row does not exist then COIN_DBL_MAX)
Definition: CoinModel.hpp:707
CoinModelHash2 hashQuadraticElements_
Hash for quadratic elements.
Definition: CoinModel.hpp:1155
double * columnLowerArray() const
Return columnLower array.
Definition: CoinModel.hpp:819
bool getColIsInteger(int whichColumn) const
Gets if integer (if column does not exist then false)
Definition: CoinModel.hpp:691
int * cut_
Nonzero if row is cut - done in one go e.g. from ampl.
Definition: CoinModel.hpp:1185
const CoinModelHash * rowNames() const
Return row names array.
Definition: CoinModel.hpp:839
int links_
Links present (could be tested by sizes of objects) 0 - none, 1 - row links, 2 - column links,...
Definition: CoinModel.hpp:1204
double getColObjective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
Definition: CoinModel.hpp:679
int writeMps(const char *filename, int compression=0, int formatType=0, int numberAcross=2, bool keepStrings=false)
Write the problem in MPS format to a file with the given filename.
void setObjective(int whichColumn, const char *columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
Definition: CoinModel.hpp:373
double * pointer(int i, int j) const
Returns pointer to element for row i column j.
void replaceQuadraticRow(int rowNumber, const double *linear, const CoinPackedMatrix *quadraticPart)
Replaces a quadratic row.
void * moreInfo() const
Return pointer to more information.
Definition: CoinModel.hpp:874
void setColLower(int whichColumn, double columnLower)
Sets columnLower (if column does not exist then all columns up to this are defined with default value...
Definition: CoinModel.hpp:307
double objective(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
Definition: CoinModel.hpp:643
double columnLower(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
Definition: CoinModel.hpp:625
void deleteCol(int whichColumn)
Deletes all entries in column and bounds.
Definition: CoinModel.hpp:392
void * moreInfo_
Pointer to more information.
Definition: CoinModel.hpp:1187
const CoinModelHash * columnNames() const
Return column names array.
Definition: CoinModel.hpp:844
void passInMatrix(const CoinPackedMatrix &matrix)
Pass in CoinPackedMatrix (and switch off element updates)
void validateLinks() const
Checks that links are consistent.
double getColumnUpper(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
int * integerTypeArray() const
Return integerType array.
Definition: CoinModel.hpp:834
void setCutMarker(int size, const int *marker)
Sets cut marker array.
double optimizationDirection() const
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Definition: CoinModel.hpp:864
CoinBigIndex numberQuadraticElements_
Current number of quadratic elements.
Definition: CoinModel.hpp:1101
double * objective_
Objective.
Definition: CoinModel.hpp:1119
void createPlusMinusOne(CoinBigIndex *startPositive, CoinBigIndex *startNegative, int *indices, const double *associated)
Creates +-1 matrix given startPositive and startNegative counts for +-1 matrix.
void setColumnObjective(int whichColumn, double columnObjective)
Sets columnObjective (if column does not exist then all columns up to this are defined with default v...
int * sortIndices_
Array for sorting indices.
Definition: CoinModel.hpp:1157
CoinModel(int firstRows, int firstColumns, CoinBigIndex firstElements, bool noNames=false)
Constructor with sizes.
void setColumnUpper(int whichColumn, double columnUpper)
Sets columnUpper (if column does not exist then all columns up to this are defined with default value...
const char * getColumnLowerAsString(int whichColumn) const
Gets columnLower (if column does not exist then 0.0)
int sizeAssociated_
Size of associated values.
Definition: CoinModel.hpp:1167
void setPriorities(int size, const int *priorities)
Sets priority array.
CoinModelLink next(CoinModelLink &current) const
Returns next element in current row or column - index is -1 if none.
const char * columnObjectiveAsString(int whichColumn) const
Gets columnObjective (if column does not exist then 0.0)
Definition: CoinModel.hpp:737
double getElement(const char *rowName, const char *columnName) const
Returns value for row rowName and column columnName.
double * referenceSOS_
SOS reference.
Definition: CoinModel.hpp:1181
void setRowUpper(int whichRow, double rowUpper)
Sets rowUpper (if row does not exist then all rows up to this are defined with default values and no ...
void deleteThisElement(int row, int column, CoinBigIndex position)
Takes element out of matrix when position known.
CoinPackedMatrix * quadraticRow(int rowNumber, double *linear, int &numberBad) const
Gets correct form for a quadratic row - user to delete If row is not quadratic then returns which oth...
int packCols()
Packs down all columns i.e.
Definition: CoinModel.hpp:408
CoinBigIndex position(int i, int j) const
Returns position in elements for row i column j.
int pack()
Packs down all rows and columns.
CoinModel * reorder(const char *mark) const
If possible return a model where if all variables marked nonzero are fixed the problem will be linear...
CoinModelHash2 hashElements_
Hash for elements.
Definition: CoinModel.hpp:1147
double * rowLower_
Row lower.
Definition: CoinModel.hpp:1105
CoinModelLinkedList quadraticRowList_
Linked list for quadratic rows.
Definition: CoinModel.hpp:1163
void setRowName(int whichRow, const char *rowName)
Sets name (if row does not exist then all rows up to this are defined with default values and no elem...
const char * columnUpperAsString(int whichColumn) const
Gets columnUpper (if column does not exist then COIN_DBL_MAX)
Definition: CoinModel.hpp:731
CoinModelLinkedList columnList_
Linked list for columns.
Definition: CoinModel.hpp:1151
CoinPackedMatrix * packedMatrix_
Actual elements as CoinPackedMatrix.
Definition: CoinModel.hpp:1145
void createList(int type) const
Create a linked list and synchronize free type 1 for row 2 for column Marked as const as list is muta...
int column(const char *columnName) const
Column index from column name (-1 if no names or no match)
const int * priorities() const
priorities (given for all columns (-1 if not integer)
Definition: CoinModel.hpp:1074
double * columnLower_
Column Lower.
Definition: CoinModel.hpp:1121
const int * originalRows() const
Return pointers to original rows (for decomposition)
Definition: CoinModel.hpp:494
void loadBlock(const int numcols, const int numrows, const CoinBigIndex *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const char *rowsen, const double *rowrhs, const double *rowrng)
Load in a problem by copying the arguments.
void operator()(int i, int j, const char *value)
Sets value for row i and column j as string.
Definition: CoinModel.hpp:228
CoinModel(const CoinModel &)
The copy constructor.
void fillRows(int which, bool forceCreation, bool fromAddRow=false)
Fill in default row information.
int differentModel(CoinModel &other, bool ignoreNames)
Check two models against each other.
double operator()(const char *rowName, const char *columnName) const
Returns value for row rowName and column columnName.
Definition: CoinModel.hpp:525
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...
Definition: CoinModel.hpp:342
void addRow(int numberInRow, const int *columns, const double *elements, double rowLower=-COIN_DBL_MAX, double rowUpper=COIN_DBL_MAX, const char *name=NULL)
add a row - numberInRow may be zero
Sparse Matrix Base Class.
for linked lists