Changeset 2385 for trunk/Clp/src/ClpNetworkMatrix.hpp
 Timestamp:
 Jan 6, 2019 2:43:06 PM (4 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/ClpNetworkMatrix.hpp
r2271 r2385 7 7 #define ClpNetworkMatrix_H 8 8 9 10 9 #include "CoinPragma.hpp" 11 10 … … 20 19 21 20 public: 22 /**@name Useful methods */ 23 //@{ 24 /// Return a complete CoinPackedMatrix 25 virtual CoinPackedMatrix * getPackedMatrix() const; 26 /** Whether the packed matrix is column major ordered or not. */ 27 virtual bool isColOrdered() const { 28 return true; 29 } 30 /** Number of entries in the packed matrix. */ 31 virtual CoinBigIndex getNumElements() const { 32 return 2 * numberColumns_; 33 } 34 /** Number of columns. */ 35 virtual int getNumCols() const { 36 return numberColumns_; 37 } 38 /** Number of rows. */ 39 virtual int getNumRows() const { 40 return numberRows_; 41 } 42 43 /** A vector containing the elements in the packed matrix. Note that there 21 /**@name Useful methods */ 22 //@{ 23 /// Return a complete CoinPackedMatrix 24 virtual CoinPackedMatrix *getPackedMatrix() const; 25 /** Whether the packed matrix is column major ordered or not. */ 26 virtual bool isColOrdered() const 27 { 28 return true; 29 } 30 /** Number of entries in the packed matrix. */ 31 virtual CoinBigIndex getNumElements() const 32 { 33 return 2 * numberColumns_; 34 } 35 /** Number of columns. */ 36 virtual int getNumCols() const 37 { 38 return numberColumns_; 39 } 40 /** Number of rows. */ 41 virtual int getNumRows() const 42 { 43 return numberRows_; 44 } 45 46 /** A vector containing the elements in the packed matrix. Note that there 44 47 might be gaps in this list, entries that do not belong to any 45 48 majordimension vector. To get the actual elements one should look at 46 49 this vector together with vectorStarts and vectorLengths. */ 47 virtual const double *getElements() const;48 50 virtual const double *getElements() const; 51 /** A vector containing the minor indices of the elements in the packed 49 52 matrix. Note that there might be gaps in this list, entries that do not 50 53 belong to any majordimension vector. To get the actual elements one 51 54 should look at this vector together with vectorStarts and 52 55 vectorLengths. */ 53 virtual const int * getIndices() const { 54 return indices_; 55 } 56 57 virtual const CoinBigIndex * getVectorStarts() const; 58 /** The lengths of the majordimension vectors. */ 59 virtual const int * getVectorLengths() const; 60 61 /** Delete the columns whose indices are listed in <code>indDel</code>. */ 62 virtual void deleteCols(const int numDel, const int * indDel); 63 /** Delete the rows whose indices are listed in <code>indDel</code>. */ 64 virtual void deleteRows(const int numDel, const int * indDel); 65 /// Append Columns 66 virtual void appendCols(int number, const CoinPackedVectorBase * const * columns); 67 /// Append Rows 68 virtual void appendRows(int number, const CoinPackedVectorBase * const * rows); 56 virtual const int *getIndices() const 57 { 58 return indices_; 59 } 60 61 virtual const CoinBigIndex *getVectorStarts() const; 62 /** The lengths of the majordimension vectors. */ 63 virtual const int *getVectorLengths() const; 64 65 /** Delete the columns whose indices are listed in <code>indDel</code>. */ 66 virtual void deleteCols(const int numDel, const int *indDel); 67 /** Delete the rows whose indices are listed in <code>indDel</code>. */ 68 virtual void deleteRows(const int numDel, const int *indDel); 69 /// Append Columns 70 virtual void appendCols(int number, const CoinPackedVectorBase *const *columns); 71 /// Append Rows 72 virtual void appendRows(int number, const CoinPackedVectorBase *const *rows); 69 73 #ifndef SLIM_CLP 70 74 /** Append a set of rows/columns to the end of the matrix. Returns number of errors 71 75 i.e. if any of the new rows/columns contain an index that's larger than the 72 76 number of columns1/rows1 (if numberOther>0) or duplicates 73 77 If 0 then rows, 1 if columns */ 74 75 const CoinBigIndex * starts, const int *index,76 const double *element, int numberOther = 1);78 virtual int appendMatrix(int number, int type, 79 const CoinBigIndex *starts, const int *index, 80 const double *element, int numberOther = 1); 77 81 #endif 78 79 virtual ClpMatrixBase *reverseOrderedCopy() const;80 81 82 const int *whichColumn,83 int &numberColumnBasic);84 85 virtual void fillBasis(ClpSimplex *model,86 const int *whichColumn,87 int &numberColumnBasic,88 int * row, int *start,89 int * rowCount, int *columnCount,90 CoinFactorizationDouble *element);91 82 /** Returns a new matrix in reverse order without gaps */ 83 virtual ClpMatrixBase *reverseOrderedCopy() const; 84 /// Returns number of elements in column part of basis 85 virtual int countBasis( 86 const int *whichColumn, 87 int &numberColumnBasic); 88 /// Fills in column part of basis 89 virtual void fillBasis(ClpSimplex *model, 90 const int *whichColumn, 91 int &numberColumnBasic, 92 int *row, int *start, 93 int *rowCount, int *columnCount, 94 CoinFactorizationDouble *element); 95 /** Given positive integer weights for each row fills in sum of weights 92 96 for each column (and slack). 93 97 Returns weights vector 94 98 */ 95 virtual CoinBigIndex * dubiousWeights(const ClpSimplex * model, int *inputWeights) const;96 99 virtual CoinBigIndex *dubiousWeights(const ClpSimplex *model, int *inputWeights) const; 100 /** Returns largest and smallest elements of both signs. 97 101 Largest refers to largest absolute value. 98 102 */ 99 virtual void rangeOfElements(double & smallestNegative, double &largestNegative,100 double & smallestPositive, double &largestPositive);101 103 virtual void rangeOfElements(double &smallestNegative, double &largestNegative, 104 double &smallestPositive, double &largestPositive); 105 /** Unpacks a column into an CoinIndexedvector 102 106 */ 103 virtual void unpack(const ClpSimplex * model, CoinIndexedVector *rowArray,104 int column) const;105 107 virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, 108 int column) const; 109 /** Unpacks a column into an CoinIndexedvector 106 110 ** in packed format 107 111 Note that model is NOT const. Bounds and objective could 108 112 be modified if doing column generation (just for this variable) */ 109 virtual void unpackPacked(ClpSimplex *model,110 CoinIndexedVector *rowArray,111 112 113 virtual void unpackPacked(ClpSimplex *model, 114 CoinIndexedVector *rowArray, 115 int column) const; 116 /** Adds multiple of a column into an CoinIndexedvector 113 117 You can use quickAdd to add to vector */ 114 virtual void add(const ClpSimplex * model, CoinIndexedVector *rowArray,115 int column, double multiplier) const;116 117 virtual void add(const ClpSimplex * model, double *array,118 119 120 virtual void releasePackedMatrix() const;121 122 123 124 virtual void partialPricing(ClpSimplex *model, double start, double end,125 int & bestSequence, int &numberWanted);126 127 128 129 130 118 virtual void add(const ClpSimplex *model, CoinIndexedVector *rowArray, 119 int column, double multiplier) const; 120 /** Adds multiple of a column into an array */ 121 virtual void add(const ClpSimplex *model, double *array, 122 int column, double multiplier) const; 123 /// Allow any parts of a created CoinMatrix to be deleted 124 virtual void releasePackedMatrix() const; 125 /// Says whether it can do partial pricing 126 virtual bool canDoPartialPricing() const; 127 /// Partial pricing 128 virtual void partialPricing(ClpSimplex *model, double start, double end, 129 int &bestSequence, int &numberWanted); 130 //@} 131 132 /**@name Matrix times vector methods */ 133 //@{ 134 /** Return <code>y + A * scalar *x</code> in <code>y</code>. 131 135 @pre <code>x</code> must be of size <code>numColumns()</code> 132 136 @pre <code>y</code> must be of size <code>numRows()</code> */ 133 134 const double * x, double *y) const;135 136 137 const double * x, double *y,138 const double *rowScale,139 const double *columnScale) const;140 137 virtual void times(double scalar, 138 const double *x, double *y) const; 139 /// And for scaling 140 virtual void times(double scalar, 141 const double *x, double *y, 142 const double *rowScale, 143 const double *columnScale) const; 144 /** Return <code>y + x * scalar * A</code> in <code>y</code>. 141 145 @pre <code>x</code> must be of size <code>numRows()</code> 142 146 @pre <code>y</code> must be of size <code>numColumns()</code> */ 143 144 const double * x, double *y) const;145 146 147 const double * x, double *y,148 const double *rowScale,149 const double * columnScale, double *spare = NULL) const;150 147 virtual void transposeTimes(double scalar, 148 const double *x, double *y) const; 149 /// And for scaling 150 virtual void transposeTimes(double scalar, 151 const double *x, double *y, 152 const double *rowScale, 153 const double *columnScale, double *spare = NULL) const; 154 /** Return <code>x * scalar * A + y</code> in <code>z</code>. 151 155 Can use y as temporary array (will be empty at end) 152 156 Note  If x packed mode  then z packed mode 153 157 Squashes small elements and knows about ClpSimplex */ 154 virtual void transposeTimes(const ClpSimplex *model, double scalar,155 const CoinIndexedVector *x,156 CoinIndexedVector *y,157 CoinIndexedVector *z) const;158 158 virtual void transposeTimes(const ClpSimplex *model, double scalar, 159 const CoinIndexedVector *x, 160 CoinIndexedVector *y, 161 CoinIndexedVector *z) const; 162 /** Return <code>x *A</code> in <code>z</code> but 159 163 just for indices in y. 160 164 Note  z always packed mode */ 161 virtual void subsetTransposeTimes(const ClpSimplex *model,162 const CoinIndexedVector *x,163 const CoinIndexedVector *y,164 CoinIndexedVector *z) const;165 166 167 168 169 170 inline bool trueNetwork() const {171 return trueNetwork_;172 }173 //@}174 175 176 177 178 179 180 181 ClpNetworkMatrix(int numberColumns, const int *head,182 const int *tail);183 184 185 186 187 188 189 190 ClpNetworkMatrix(const ClpNetworkMatrix&);191 192 ClpNetworkMatrix(const CoinPackedMatrix&);193 194 ClpNetworkMatrix& operator=(const ClpNetworkMatrix&);195 196 virtual ClpMatrixBase * clone() const;197 165 virtual void subsetTransposeTimes(const ClpSimplex *model, 166 const CoinIndexedVector *x, 167 const CoinIndexedVector *y, 168 CoinIndexedVector *z) const; 169 //@} 170 171 /**@name Other */ 172 //@{ 173 /// Return true if really network, false if has slacks 174 inline bool trueNetwork() const 175 { 176 return trueNetwork_; 177 } 178 //@} 179 180 /**@name Constructors, destructor */ 181 //@{ 182 /** Default constructor. */ 183 ClpNetworkMatrix(); 184 /** Constructor from two arrays */ 185 ClpNetworkMatrix(int numberColumns, const int *head, 186 const int *tail); 187 /** Destructor */ 188 virtual ~ClpNetworkMatrix(); 189 //@} 190 191 /**@name Copy method */ 192 //@{ 193 /** The copy constructor. */ 194 ClpNetworkMatrix(const ClpNetworkMatrix &); 195 /** The copy constructor from an CoinNetworkMatrix. */ 196 ClpNetworkMatrix(const CoinPackedMatrix &); 197 198 ClpNetworkMatrix &operator=(const ClpNetworkMatrix &); 199 /// Clone 200 virtual ClpMatrixBase *clone() const; 201 /** Subset constructor (without gaps). Duplicates are allowed 198 202 and order is as given */ 199 ClpNetworkMatrix (const ClpNetworkMatrix &wholeModel,200 int numberRows, const int *whichRows,201 int numberColumns, const int *whichColumns);202 203 ClpNetworkMatrix(const ClpNetworkMatrix &wholeModel, 204 int numberRows, const int *whichRows, 205 int numberColumns, const int *whichColumns); 206 /** Subset clone (without gaps). Duplicates are allowed 203 207 and order is as given */ 204 virtual ClpMatrixBase * subsetClone ( 205 int numberRows, const int * whichRows, 206 int numberColumns, const int * whichColumns) const ; 207 //@} 208 208 virtual ClpMatrixBase *subsetClone( 209 int numberRows, const int *whichRows, 210 int numberColumns, const int *whichColumns) const; 211 //@} 209 212 210 213 protected: 211 214 /**@name Data members 212 215 The data members are protected to allow access for derived classes. */ 213 214 215 mutable CoinPackedMatrix *matrix_;216 mutable int *lengths_;217 218 int *indices_;219 220 221 222 223 224 225 226 216 //@{ 217 /// For fake CoinPackedMatrix 218 mutable CoinPackedMatrix *matrix_; 219 mutable int *lengths_; 220 /// Data 1, then +1 rows in pairs (row==1 if one entry) 221 int *indices_; 222 /// Number of rows 223 int numberRows_; 224 /// Number of columns 225 int numberColumns_; 226 /// True if all entries have two elements 227 bool trueNetwork_; 228 229 //@} 227 230 }; 228 231 229 232 #endif 233 234 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 235 */
Note: See TracChangeset
for help on using the changeset viewer.