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

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/ClpPlusMinusOneMatrix.hpp
r2271 r2385 7 7 #define ClpPlusMinusOneMatrix_H 8 8 9 10 9 #include "CoinPragma.hpp" 11 10 … … 19 18 20 19 public: 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 /** Number of entries in the packed matrix. */ 28 virtual CoinBigIndex getNumElements() const; 29 /** Number of columns. */ 30 virtual int getNumCols() const { 31 return numberColumns_; 32 } 33 /** Number of rows. */ 34 virtual int getNumRows() const { 35 return numberRows_; 36 } 37 38 /** A vector containing the elements in the packed matrix. Note that there 20 /**@name Useful methods */ 21 //@{ 22 /// Return a complete CoinPackedMatrix 23 virtual CoinPackedMatrix *getPackedMatrix() const; 24 /** Whether the packed matrix is column major ordered or not. */ 25 virtual bool isColOrdered() const; 26 /** Number of entries in the packed matrix. */ 27 virtual CoinBigIndex getNumElements() const; 28 /** Number of columns. */ 29 virtual int getNumCols() const 30 { 31 return numberColumns_; 32 } 33 /** Number of rows. */ 34 virtual int getNumRows() const 35 { 36 return numberRows_; 37 } 38 39 /** A vector containing the elements in the packed matrix. Note that there 39 40 might be gaps in this list, entries that do not belong to any 40 41 majordimension vector. To get the actual elements one should look at 41 42 this vector together with vectorStarts and vectorLengths. */ 42 virtual const double *getElements() const;43 43 virtual const double *getElements() const; 44 /** A vector containing the minor indices of the elements in the packed 44 45 matrix. Note that there might be gaps in this list, entries that do not 45 46 belong to any majordimension vector. To get the actual elements one 46 47 should look at this vector together with vectorStarts and 47 48 vectorLengths. */ 48 virtual const int * getIndices() const { 49 return indices_; 50 } 51 // and for advanced use 52 int * getMutableIndices() const { 53 return indices_; 54 } 55 56 virtual const CoinBigIndex * getVectorStarts() const; 57 /** The lengths of the majordimension vectors. */ 58 virtual const int * getVectorLengths() const; 59 60 /** Delete the columns whose indices are listed in <code>indDel</code>. */ 61 virtual void deleteCols(const int numDel, const int * indDel); 62 /** Delete the rows whose indices are listed in <code>indDel</code>. */ 63 virtual void deleteRows(const int numDel, const int * indDel); 64 /// Append Columns 65 virtual void appendCols(int number, const CoinPackedVectorBase * const * columns); 66 /// Append Rows 67 virtual void appendRows(int number, const CoinPackedVectorBase * const * rows); 49 virtual const int *getIndices() const 50 { 51 return indices_; 52 } 53 // and for advanced use 54 int *getMutableIndices() const 55 { 56 return indices_; 57 } 58 59 virtual const CoinBigIndex *getVectorStarts() const; 60 /** The lengths of the majordimension vectors. */ 61 virtual const int *getVectorLengths() const; 62 63 /** Delete the columns whose indices are listed in <code>indDel</code>. */ 64 virtual void deleteCols(const int numDel, const int *indDel); 65 /** Delete the rows whose indices are listed in <code>indDel</code>. */ 66 virtual void deleteRows(const int numDel, const int *indDel); 67 /// Append Columns 68 virtual void appendCols(int number, const CoinPackedVectorBase *const *columns); 69 /// Append Rows 70 virtual void appendRows(int number, const CoinPackedVectorBase *const *rows); 68 71 #ifndef SLIM_CLP 69 72 /** Append a set of rows/columns to the end of the matrix. Returns number of errors 70 73 i.e. if any of the new rows/columns contain an index that's larger than the 71 74 number of columns1/rows1 (if numberOther>0) or duplicates 72 75 If 0 then rows, 1 if columns */ 73 74 const CoinBigIndex * starts, const int *index,75 const double *element, int numberOther = 1);76 virtual int appendMatrix(int number, int type, 77 const CoinBigIndex *starts, const int *index, 78 const double *element, int numberOther = 1); 76 79 #endif 77 78 virtual ClpMatrixBase *reverseOrderedCopy() const;79 80 81 const int *whichColumn,82 int &numberColumnBasic);83 84 virtual void fillBasis(ClpSimplex *model,85 const int *whichColumn,86 int &numberColumnBasic,87 int * row, int *start,88 int * rowCount, int *columnCount,89 CoinFactorizationDouble *element);90 80 /** Returns a new matrix in reverse order without gaps */ 81 virtual ClpMatrixBase *reverseOrderedCopy() const; 82 /// Returns number of elements in column part of basis 83 virtual int countBasis( 84 const int *whichColumn, 85 int &numberColumnBasic); 86 /// Fills in column part of basis 87 virtual void fillBasis(ClpSimplex *model, 88 const int *whichColumn, 89 int &numberColumnBasic, 90 int *row, int *start, 91 int *rowCount, int *columnCount, 92 CoinFactorizationDouble *element); 93 /** Given positive integer weights for each row fills in sum of weights 91 94 for each column (and slack). 92 95 Returns weights vector 93 96 */ 94 virtual CoinBigIndex * dubiousWeights(const ClpSimplex * model, int *inputWeights) const;95 97 virtual CoinBigIndex *dubiousWeights(const ClpSimplex *model, int *inputWeights) const; 98 /** Returns largest and smallest elements of both signs. 96 99 Largest refers to largest absolute value. 97 100 */ 98 virtual void rangeOfElements(double & smallestNegative, double &largestNegative,99 double & smallestPositive, double &largestPositive);100 101 virtual void rangeOfElements(double &smallestNegative, double &largestNegative, 102 double &smallestPositive, double &largestPositive); 103 /** Unpacks a column into an CoinIndexedvector 101 104 */ 102 virtual void unpack(const ClpSimplex * model, CoinIndexedVector *rowArray,103 int column) const;104 105 virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, 106 int column) const; 107 /** Unpacks a column into an CoinIndexedvector 105 108 ** in packed foramt 106 109 Note that model is NOT const. Bounds and objective could 107 110 be modified if doing column generation (just for this variable) */ 108 virtual void unpackPacked(ClpSimplex *model,109 CoinIndexedVector *rowArray,110 111 111 virtual void unpackPacked(ClpSimplex *model, 112 CoinIndexedVector *rowArray, 113 int column) const; 114 /** Adds multiple of a column into an CoinIndexedvector 112 115 You can use quickAdd to add to vector */ 113 virtual void add(const ClpSimplex * model, CoinIndexedVector *rowArray,114 int column, double multiplier) const;115 116 virtual void add(const ClpSimplex * model, double *array,117 118 119 120 116 virtual void add(const ClpSimplex *model, CoinIndexedVector *rowArray, 117 int column, double multiplier) const; 118 /** Adds multiple of a column into an array */ 119 virtual void add(const ClpSimplex *model, double *array, 120 int column, double multiplier) const; 121 /// Allow any parts of a created CoinMatrix to be deleted 122 virtual void releasePackedMatrix() const; 123 /** Set the dimensions of the matrix. In effect, append new empty 121 124 columns/rows to the matrix. A negative number for either dimension 122 125 means that that dimension doesn't change. Otherwise the new dimensions 123 126 MUST be at least as large as the current ones otherwise an exception 124 127 is thrown. */ 125 126 127 128 129 130 131 132 128 virtual void setDimensions(int numrows, int numcols); 129 /// Just checks matrix valid  will say if dimensions not quite right if detail 130 void checkValid(bool detail) const; 131 //@} 132 133 /**@name Matrix times vector methods */ 134 //@{ 135 /** Return <code>y + A * scalar *x</code> in <code>y</code>. 133 136 @pre <code>x</code> must be of size <code>numColumns()</code> 134 137 @pre <code>y</code> must be of size <code>numRows()</code> */ 135 136 const double * x, double *y) const;137 138 139 const double * x, double *y,140 const double *rowScale,141 const double *columnScale) const;142 138 virtual void times(double scalar, 139 const double *x, double *y) const; 140 /// And for scaling 141 virtual void times(double scalar, 142 const double *x, double *y, 143 const double *rowScale, 144 const double *columnScale) const; 145 /** Return <code>y + x * scalar * A</code> in <code>y</code>. 143 146 @pre <code>x</code> must be of size <code>numRows()</code> 144 147 @pre <code>y</code> must be of size <code>numColumns()</code> */ 145 146 const double * x, double *y) const;147 148 149 const double * x, double *y,150 const double *rowScale,151 const double * columnScale, double *spare = NULL) const;152 148 virtual void transposeTimes(double scalar, 149 const double *x, double *y) const; 150 /// And for scaling 151 virtual void transposeTimes(double scalar, 152 const double *x, double *y, 153 const double *rowScale, 154 const double *columnScale, double *spare = NULL) const; 155 /** Return <code>x * scalar * A + y</code> in <code>z</code>. 153 156 Can use y as temporary array (will be empty at end) 154 157 Note  If x packed mode  then z packed mode 155 158 Squashes small elements and knows about ClpSimplex */ 156 virtual void transposeTimes(const ClpSimplex *model, double scalar,157 const CoinIndexedVector *x,158 CoinIndexedVector *y,159 CoinIndexedVector *z) const;160 159 virtual void transposeTimes(const ClpSimplex *model, double scalar, 160 const CoinIndexedVector *x, 161 CoinIndexedVector *y, 162 CoinIndexedVector *z) const; 163 /** Return <code>x * scalar * A + y</code> in <code>z</code>. 161 164 Can use y as temporary array (will be empty at end) 162 165 Note  If x packed mode  then z packed mode 163 166 Squashes small elements and knows about ClpSimplex. 164 167 This version uses row copy*/ 165 virtual void transposeTimesByRow(const ClpSimplex *model, double scalar,166 const CoinIndexedVector *x,167 CoinIndexedVector *y,168 CoinIndexedVector *z) const;169 168 virtual void transposeTimesByRow(const ClpSimplex *model, double scalar, 169 const CoinIndexedVector *x, 170 CoinIndexedVector *y, 171 CoinIndexedVector *z) const; 172 /** Return <code>x *A</code> in <code>z</code> but 170 173 just for indices in y. 171 174 Note  z always packed mode */ 172 virtual void subsetTransposeTimes(const ClpSimplex *model,173 const CoinIndexedVector *x,174 const CoinIndexedVector *y,175 CoinIndexedVector *z) const;176 175 virtual void subsetTransposeTimes(const ClpSimplex *model, 176 const CoinIndexedVector *x, 177 const CoinIndexedVector *y, 178 CoinIndexedVector *z) const; 179 /** Returns true if can combine transposeTimes and subsetTransposeTimes 177 180 and if it would be faster */ 178 virtual bool canCombine(const ClpSimplex *model,179 const CoinIndexedVector *pi) const;180 181 virtual bool canCombine(const ClpSimplex *model, 182 const CoinIndexedVector *pi) const; 183 /** Updates two arrays for steepest and does devex weights 181 184 Returns nonzero if updates reduced cost and infeas  182 185 new infeas in dj1 */ 183 virtual int transposeTimes2(const ClpSimplex * model, 184 const CoinIndexedVector * pi1, CoinIndexedVector * dj1, 185 const CoinIndexedVector * pi2, 186 CoinIndexedVector * spare, 187 double * infeas, double * reducedCost, 188 double referenceIn, double devex, 189 // Array for exact devex to say what is in reference framework 190 unsigned int * reference, 191 double * weights, double scaleFactor); 192 /// Updates second array for steepest and does devex weights 193 virtual void subsetTimes2(const ClpSimplex * model, 194 CoinIndexedVector * dj1, 195 const CoinIndexedVector * pi2, CoinIndexedVector * dj2, 196 double referenceIn, double devex, 197 // Array for exact devex to say what is in reference framework 198 unsigned int * reference, 199 double * weights, double scaleFactor); 200 //@} 201 202 /**@name Other */ 203 //@{ 204 /// Return starts of +1s 205 inline CoinBigIndex * startPositive() const { 206 return startPositive_; 207 } 208 /// Return starts of 1s 209 inline CoinBigIndex * startNegative() const { 210 return startNegative_; 211 } 212 //@} 213 214 215 /**@name Constructors, destructor */ 216 //@{ 217 /** Default constructor. */ 218 ClpPlusMinusOneMatrix(); 219 /** Destructor */ 220 virtual ~ClpPlusMinusOneMatrix(); 221 //@} 222 223 /**@name Copy method */ 224 //@{ 225 /** The copy constructor. */ 226 ClpPlusMinusOneMatrix(const ClpPlusMinusOneMatrix&); 227 /** The copy constructor from an CoinPlusMinusOneMatrix. 186 virtual int transposeTimes2(const ClpSimplex *model, 187 const CoinIndexedVector *pi1, CoinIndexedVector *dj1, 188 const CoinIndexedVector *pi2, 189 CoinIndexedVector *spare, 190 double *infeas, double *reducedCost, 191 double referenceIn, double devex, 192 // Array for exact devex to say what is in reference framework 193 unsigned int *reference, 194 double *weights, double scaleFactor); 195 /// Updates second array for steepest and does devex weights 196 virtual void subsetTimes2(const ClpSimplex *model, 197 CoinIndexedVector *dj1, 198 const CoinIndexedVector *pi2, CoinIndexedVector *dj2, 199 double referenceIn, double devex, 200 // Array for exact devex to say what is in reference framework 201 unsigned int *reference, 202 double *weights, double scaleFactor); 203 //@} 204 205 /**@name Other */ 206 //@{ 207 /// Return starts of +1s 208 inline CoinBigIndex *startPositive() const 209 { 210 return startPositive_; 211 } 212 /// Return starts of 1s 213 inline CoinBigIndex *startNegative() const 214 { 215 return startNegative_; 216 } 217 //@} 218 219 /**@name Constructors, destructor */ 220 //@{ 221 /** Default constructor. */ 222 ClpPlusMinusOneMatrix(); 223 /** Destructor */ 224 virtual ~ClpPlusMinusOneMatrix(); 225 //@} 226 227 /**@name Copy method */ 228 //@{ 229 /** The copy constructor. */ 230 ClpPlusMinusOneMatrix(const ClpPlusMinusOneMatrix &); 231 /** The copy constructor from an CoinPlusMinusOneMatrix. 228 232 If not a valid matrix then getIndices will be NULL and 229 233 startPositive[0] will have number of +1, … … 231 235 startPositive[2] will have number of others, 232 236 */ 233 ClpPlusMinusOneMatrix(const CoinPackedMatrix&);234 235 236 bool columnOrdered, const int *indices,237 const CoinBigIndex * startPositive, const CoinBigIndex *startNegative);238 237 ClpPlusMinusOneMatrix(const CoinPackedMatrix &); 238 /// Constructor from arrays 239 ClpPlusMinusOneMatrix(int numberRows, int numberColumns, 240 bool columnOrdered, const int *indices, 241 const CoinBigIndex *startPositive, const CoinBigIndex *startNegative); 242 /** Subset constructor (without gaps). Duplicates are allowed 239 243 and order is as given */ 240 ClpPlusMinusOneMatrix (const ClpPlusMinusOneMatrix &wholeModel,241 int numberRows, const int *whichRows,242 int numberColumns, const int *whichColumns);243 244 ClpPlusMinusOneMatrix& operator=(const ClpPlusMinusOneMatrix&);245 246 virtual ClpMatrixBase * clone() const;247 244 ClpPlusMinusOneMatrix(const ClpPlusMinusOneMatrix &wholeModel, 245 int numberRows, const int *whichRows, 246 int numberColumns, const int *whichColumns); 247 248 ClpPlusMinusOneMatrix &operator=(const ClpPlusMinusOneMatrix &); 249 /// Clone 250 virtual ClpMatrixBase *clone() const; 251 /** Subset clone (without gaps). Duplicates are allowed 248 252 and order is as given */ 249 virtual ClpMatrixBase * subsetClone ( 250 int numberRows, const int * whichRows, 251 int numberColumns, const int * whichColumns) const ; 252 /// pass in copy (object takes ownership) 253 void passInCopy(int numberRows, int numberColumns, 254 bool columnOrdered, int * indices, 255 CoinBigIndex * startPositive, CoinBigIndex * startNegative); 256 /// Says whether it can do partial pricing 257 virtual bool canDoPartialPricing() const; 258 /// Partial pricing 259 virtual void partialPricing(ClpSimplex * model, double start, double end, 260 int & bestSequence, int & numberWanted); 261 //@} 262 253 virtual ClpMatrixBase *subsetClone( 254 int numberRows, const int *whichRows, 255 int numberColumns, const int *whichColumns) const; 256 /// pass in copy (object takes ownership) 257 void passInCopy(int numberRows, int numberColumns, 258 bool columnOrdered, int *indices, 259 CoinBigIndex *startPositive, CoinBigIndex *startNegative); 260 /// Says whether it can do partial pricing 261 virtual bool canDoPartialPricing() const; 262 /// Partial pricing 263 virtual void partialPricing(ClpSimplex *model, double start, double end, 264 int &bestSequence, int &numberWanted); 265 //@} 263 266 264 267 protected: 265 268 /**@name Data members 266 269 The data members are protected to allow access for derived classes. */ 267 268 269 mutable CoinPackedMatrix *matrix_;270 mutable int *lengths_;271 272 CoinBigIndex *COIN_RESTRICT startPositive_;273 274 CoinBigIndex *COIN_RESTRICT startNegative_;275 276 int *COIN_RESTRICT indices_;277 278 279 280 270 //@{ 271 /// For fake CoinPackedMatrix 272 mutable CoinPackedMatrix *matrix_; 273 mutable int *lengths_; 274 /// Start of +1's for each 275 CoinBigIndex *COIN_RESTRICT startPositive_; 276 /// Start of 1's for each 277 CoinBigIndex *COIN_RESTRICT startNegative_; 278 /// Data 1, then +1 rows in pairs (row==1 if one entry) 279 int *COIN_RESTRICT indices_; 280 /// Number of rows 281 int numberRows_; 282 /// Number of columns 283 int numberColumns_; 281 284 #ifdef CLP_PLUS_ONE_MATRIX 282 285 /** Other flags (could have columnOrdered_?) 283 286 1 bit  says just +1 284 287 */ 285 288 mutable int otherFlags_; 286 289 #endif 287 288 289 290 290 /// True if column ordered 291 bool columnOrdered_; 292 293 //@} 291 294 }; 292 295 #if CLP_POOL_MATRIX … … 294 297 as derived from ClpMatrixBase. This version only up to 65K rows 295 298 */ 296 #define CLP_POOL_SIZE 32 CLP_POOL_MATRIX297 #if CLP_POOL_MATRIX ==16299 #define CLP_POOL_SIZE 32  CLP_POOL_MATRIX 300 #if CLP_POOL_MATRIX == 16 298 301 typedef struct { 299 302 unsigned short row_; … … 302 305 #else 303 306 typedef struct { 304 unsigned int row_:CLP_POOL_MATRIX;305 unsigned short pool_:CLP_POOL_SIZE;307 unsigned int row_ : CLP_POOL_MATRIX; 308 unsigned short pool_ : CLP_POOL_SIZE; 306 309 } poolInfo; 307 310 #endif … … 310 313 311 314 public: 312 /**@name Useful methods */ 313 //@{ 314 /// Return a complete CoinPackedMatrix 315 virtual CoinPackedMatrix * getPackedMatrix() const; 316 /** Whether the packed matrix is column major ordered or not. */ 317 virtual bool isColOrdered() const ; 318 /** Number of entries in the packed matrix. */ 319 virtual CoinBigIndex getNumElements() const; 320 /** Number of different entries in the packed matrix. */ 321 inline int getNumDifferentElements() const 322 { return numberDifferent_;} 323 /** Number of columns. */ 324 virtual int getNumCols() const { 325 return numberColumns_; 326 } 327 /** Number of rows. */ 328 virtual int getNumRows() const { 329 return numberRows_; 330 } 331 332 /** A vector containing the elements in the packed matrix. Note that there 315 /**@name Useful methods */ 316 //@{ 317 /// Return a complete CoinPackedMatrix 318 virtual CoinPackedMatrix *getPackedMatrix() const; 319 /** Whether the packed matrix is column major ordered or not. */ 320 virtual bool isColOrdered() const; 321 /** Number of entries in the packed matrix. */ 322 virtual CoinBigIndex getNumElements() const; 323 /** Number of different entries in the packed matrix. */ 324 inline int getNumDifferentElements() const 325 { 326 return numberDifferent_; 327 } 328 /** Number of columns. */ 329 virtual int getNumCols() const 330 { 331 return numberColumns_; 332 } 333 /** Number of rows. */ 334 virtual int getNumRows() const 335 { 336 return numberRows_; 337 } 338 339 /** A vector containing the elements in the packed matrix. Note that there 333 340 might be gaps in this list, entries that do not belong to any 334 341 majordimension vector. To get the actual elements one should look at 335 342 this vector together with vectorStarts and vectorLengths. */ 336 virtual const double *getElements() const;337 343 virtual const double *getElements() const; 344 /** A vector containing the minor indices of the elements in the packed 338 345 matrix. Note that there might be gaps in this list, entries that do not 339 346 belong to any majordimension vector. To get the actual elements one 340 347 should look at this vector together with vectorStarts and 341 348 vectorLengths. */ 342 virtual const int *getIndices() const;343 344 int *getMutableIndices() const;345 346 virtual const CoinBigIndex *getVectorStarts() const;347 348 virtual const int *getVectorLengths() const;349 350 351 352 virtual void deleteCols(const int numDel, const int *indDel);353 354 virtual void deleteRows(const int numDel, const int *indDel);355 356 virtual ClpMatrixBase *reverseOrderedCopy() const;357 358 359 const int *whichColumn,360 int &numberColumnBasic);361 362 virtual void fillBasis(ClpSimplex *model,363 const int *whichColumn,364 int &numberColumnBasic,365 int * row, int *start,366 int * rowCount, int *columnCount,367 CoinFactorizationDouble *element);368 349 virtual const int *getIndices() const; 350 // and for advanced use 351 int *getMutableIndices() const; 352 353 virtual const CoinBigIndex *getVectorStarts() const; 354 /** The lengths of the majordimension vectors. */ 355 virtual const int *getVectorLengths() const; 356 /** The length of a majordimension vector. */ 357 virtual int getVectorLength(int index) const; 358 /** Delete the columns whose indices are listed in <code>indDel</code>. */ 359 virtual void deleteCols(const int numDel, const int *indDel); 360 /** Delete the rows whose indices are listed in <code>indDel</code>. */ 361 virtual void deleteRows(const int numDel, const int *indDel); 362 /** Returns a new matrix in reverse order without gaps */ 363 virtual ClpMatrixBase *reverseOrderedCopy() const; 364 /// Returns number of elements in column part of basis 365 virtual int countBasis( 366 const int *whichColumn, 367 int &numberColumnBasic); 368 /// Fills in column part of basis 369 virtual void fillBasis(ClpSimplex *model, 370 const int *whichColumn, 371 int &numberColumnBasic, 372 int *row, int *start, 373 int *rowCount, int *columnCount, 374 CoinFactorizationDouble *element); 375 /** Returns largest and smallest elements of both signs. 369 376 Largest refers to largest absolute value. 370 377 */ 371 virtual void rangeOfElements(double & smallestNegative, double &largestNegative,372 double & smallestPositive, double &largestPositive);373 378 virtual void rangeOfElements(double &smallestNegative, double &largestNegative, 379 double &smallestPositive, double &largestPositive); 380 /** Unpacks a column into an CoinIndexedvector 374 381 */ 375 virtual void unpack(const ClpSimplex * model, CoinIndexedVector *rowArray,376 int column) const;377 382 virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, 383 int column) const; 384 /** Unpacks a column into an CoinIndexedvector 378 385 ** in packed foramt 379 386 Note that model is NOT const. Bounds and objective could 380 387 be modified if doing column generation (just for this variable) */ 381 virtual void unpackPacked(ClpSimplex *model,382 CoinIndexedVector *rowArray,383 384 388 virtual void unpackPacked(ClpSimplex *model, 389 CoinIndexedVector *rowArray, 390 int column) const; 391 /** Adds multiple of a column into an CoinIndexedvector 385 392 You can use quickAdd to add to vector */ 386 virtual void add(const ClpSimplex * model, CoinIndexedVector *rowArray,387 int column, double multiplier) const;388 389 virtual void add(const ClpSimplex * model, double *array,390 391 392 393 393 virtual void add(const ClpSimplex *model, CoinIndexedVector *rowArray, 394 int column, double multiplier) const; 395 /** Adds multiple of a column into an array */ 396 virtual void add(const ClpSimplex *model, double *array, 397 int column, double multiplier) const; 398 /// Allow any parts of a created CoinMatrix to be deleted 399 virtual void releasePackedMatrix() const; 400 /** Set the dimensions of the matrix. In effect, append new empty 394 401 columns/rows to the matrix. A negative number for either dimension 395 402 means that that dimension doesn't change. Otherwise the new dimensions 396 403 MUST be at least as large as the current ones otherwise an exception 397 404 is thrown. */ 398 399 400 401 402 403 404 405 405 virtual void setDimensions(int numrows, int numcols); 406 /// Just checks matrix valid  will say if dimensions not quite right if detail 407 void checkValid(bool detail) const; 408 //@} 409 410 /**@name Matrix times vector methods */ 411 //@{ 412 /** Return <code>y + A * scalar *x</code> in <code>y</code>. 406 413 @pre <code>x</code> must be of size <code>numColumns()</code> 407 414 @pre <code>y</code> must be of size <code>numRows()</code> */ 408 409 const double * x, double *y) const;410 411 412 const double * x, double *y,413 const double *rowScale,414 const double *columnScale) const;415 415 virtual void times(double scalar, 416 const double *x, double *y) const; 417 /// And for scaling 418 virtual void times(double scalar, 419 const double *x, double *y, 420 const double *rowScale, 421 const double *columnScale) const; 422 /** Return <code>y + x * scalar * A</code> in <code>y</code>. 416 423 @pre <code>x</code> must be of size <code>numRows()</code> 417 424 @pre <code>y</code> must be of size <code>numColumns()</code> */ 418 419 const double * x, double *y) const;420 421 422 const double * x, double *y,423 const double *rowScale,424 const double * columnScale, double *spare = NULL) const;425 425 virtual void transposeTimes(double scalar, 426 const double *x, double *y) const; 427 /// And for scaling 428 virtual void transposeTimes(double scalar, 429 const double *x, double *y, 430 const double *rowScale, 431 const double *columnScale, double *spare = NULL) const; 432 /** Return <code>x * scalar * A + y</code> in <code>z</code>. 426 433 Can use y as temporary array (will be empty at end) 427 434 Note  If x packed mode  then z packed mode 428 435 Squashes small elements and knows about ClpSimplex */ 429 virtual void transposeTimes(const ClpSimplex *model, double scalar,430 const CoinIndexedVector *x,431 CoinIndexedVector *y,432 CoinIndexedVector *z) const;433 436 virtual void transposeTimes(const ClpSimplex *model, double scalar, 437 const CoinIndexedVector *x, 438 CoinIndexedVector *y, 439 CoinIndexedVector *z) const; 440 /** Return <code>x * scalar * A + y</code> in <code>z</code>. 434 441 Can use y as temporary array (will be empty at end) 435 442 Note  If x packed mode  then z packed mode 436 443 Squashes small elements and knows about ClpSimplex. 437 444 This version uses row copy*/ 438 virtual void transposeTimesByRow(const ClpSimplex *model, double scalar,439 const CoinIndexedVector *x,440 CoinIndexedVector *y,441 CoinIndexedVector *z) const;442 445 virtual void transposeTimesByRow(const ClpSimplex *model, double scalar, 446 const CoinIndexedVector *x, 447 CoinIndexedVector *y, 448 CoinIndexedVector *z) const; 449 /** Return <code>x *A</code> in <code>z</code> but 443 450 just for indices in y. 444 451 Note  z always packed mode */ 445 virtual void subsetTransposeTimes(const ClpSimplex *model,446 const CoinIndexedVector *x,447 const CoinIndexedVector *y,448 CoinIndexedVector *z) const;449 452 virtual void subsetTransposeTimes(const ClpSimplex *model, 453 const CoinIndexedVector *x, 454 const CoinIndexedVector *y, 455 CoinIndexedVector *z) const; 456 /** Returns true if can combine transposeTimes and subsetTransposeTimes 450 457 and if it would be faster */ 451 virtual bool canCombine(const ClpSimplex * model, 452 const CoinIndexedVector * pi) const 453 { return true;} 454 /** Updates two arrays for steepest and does devex weights 458 virtual bool canCombine(const ClpSimplex *model, 459 const CoinIndexedVector *pi) const 460 { 461 return true; 462 } 463 /** Updates two arrays for steepest and does devex weights 455 464 Returns nonzero if updates reduced cost and infeas  456 465 new infeas in dj1 */ 457 virtual int transposeTimes2(const ClpSimplex *model,458 const CoinIndexedVector * pi1, CoinIndexedVector *dj1,459 const CoinIndexedVector *pi2,460 CoinIndexedVector *spare,461 double * infeas, double *reducedCost,462 463 464 unsigned int *reference,465 double *weights, double scaleFactor);466 467 virtual void subsetTimes2(const ClpSimplex *model,468 CoinIndexedVector *dj1,469 const CoinIndexedVector * pi2, CoinIndexedVector *dj2,470 471 472 unsigned int *reference,473 double *weights, double scaleFactor);474 475 476 477 478 479 inline CoinBigIndex * columnStart() const {480 return columnStart_;481 }482 //@}483 484 485 486 487 488 489 490 491 492 493 494 495 496 ClpPoolMatrix(const ClpPoolMatrix&);497 466 virtual int transposeTimes2(const ClpSimplex *model, 467 const CoinIndexedVector *pi1, CoinIndexedVector *dj1, 468 const CoinIndexedVector *pi2, 469 CoinIndexedVector *spare, 470 double *infeas, double *reducedCost, 471 double referenceIn, double devex, 472 // Array for exact devex to say what is in reference framework 473 unsigned int *reference, 474 double *weights, double scaleFactor); 475 /// Updates second array for steepest and does devex weights 476 virtual void subsetTimes2(const ClpSimplex *model, 477 CoinIndexedVector *dj1, 478 const CoinIndexedVector *pi2, CoinIndexedVector *dj2, 479 double referenceIn, double devex, 480 // Array for exact devex to say what is in reference framework 481 unsigned int *reference, 482 double *weights, double scaleFactor); 483 //@} 484 485 /**@name Other */ 486 //@{ 487 /// Return column starts 488 inline CoinBigIndex *columnStart() const 489 { 490 return columnStart_; 491 } 492 //@} 493 494 /**@name Constructors, destructor */ 495 //@{ 496 /** Default constructor. */ 497 ClpPoolMatrix(); 498 /** Destructor */ 499 virtual ~ClpPoolMatrix(); 500 //@} 501 502 /**@name Copy method */ 503 //@{ 504 /** The copy constructor. */ 505 ClpPoolMatrix(const ClpPoolMatrix &); 506 /** The copy constructor from an CoinPoolMatrix. 498 507 */ 499 ClpPoolMatrix(const CoinPackedMatrix&);500 501 502 const int * indices, const double *elements,503 const CoinBigIndex *columnStart);504 505 ClpPoolMatrix(int numberColumns,CoinBigIndex *columnStart,506 poolInfo * stuff, double *elements);507 508 ClpPoolMatrix(const CoinPackedMatrix &); 509 /// Constructor from arrays 510 ClpPoolMatrix(int numberRows, int numberColumns, 511 const int *indices, const double *elements, 512 const CoinBigIndex *columnStart); 513 /// Constructor from arrays  handing over ownership 514 ClpPoolMatrix(int numberColumns, CoinBigIndex *columnStart, 515 poolInfo *stuff, double *elements); 516 /** Subset constructor (without gaps). Duplicates are allowed 508 517 and order is as given */ 509 ClpPoolMatrix (const ClpPoolMatrix &wholeModel,510 int numberRows, const int *whichRows,511 int numberColumns, const int *whichColumns);512 513 ClpPoolMatrix& operator=(const ClpPoolMatrix&);514 515 virtual ClpMatrixBase * clone() const;516 518 ClpPoolMatrix(const ClpPoolMatrix &wholeModel, 519 int numberRows, const int *whichRows, 520 int numberColumns, const int *whichColumns); 521 522 ClpPoolMatrix &operator=(const ClpPoolMatrix &); 523 /// Clone 524 virtual ClpMatrixBase *clone() const; 525 /** Subset clone (without gaps). Duplicates are allowed 517 526 and order is as given */ 518 virtual ClpMatrixBase * subsetClone ( 519 int numberRows, const int * whichRows, 520 int numberColumns, const int * whichColumns) const ; 521 /// Says whether it can do partial pricing 522 virtual bool canDoPartialPricing() const; 523 /// Partial pricing 524 virtual void partialPricing(ClpSimplex * model, double start, double end, 525 int & bestSequence, int & numberWanted); 526 //@} 527 527 virtual ClpMatrixBase *subsetClone( 528 int numberRows, const int *whichRows, 529 int numberColumns, const int *whichColumns) const; 530 /// Says whether it can do partial pricing 531 virtual bool canDoPartialPricing() const; 532 /// Partial pricing 533 virtual void partialPricing(ClpSimplex *model, double start, double end, 534 int &bestSequence, int &numberWanted); 535 //@} 528 536 529 537 protected: 530 531 ClpPackedMatrix *createMatrix() const;532 538 /// Create matrix_ 539 ClpPackedMatrix *createMatrix() const; 540 /**@name Data members 533 541 The data members are protected to allow access for derived classes. */ 534 535 536 mutable ClpPackedMatrix *matrix_;537 mutable int *lengths_;538 539 double *COIN_RESTRICT elements_;540 541 CoinBigIndex *COIN_RESTRICT columnStart_;542 543 poolInfo *COIN_RESTRICT stuff_;544 545 546 547 548 549 550 551 542 //@{ 543 /// For fake ClpPackedMatrix 544 mutable ClpPackedMatrix *matrix_; 545 mutable int *lengths_; 546 /// Unique values 547 double *COIN_RESTRICT elements_; 548 /// Column starts 549 CoinBigIndex *COIN_RESTRICT columnStart_; 550 /// Rows and values 551 poolInfo *COIN_RESTRICT stuff_; 552 /// Number of rows 553 int numberRows_; 554 /// Number of columns 555 int numberColumns_; 556 /// Number of different elements 557 int numberDifferent_; 558 559 //@} 552 560 }; 553 561 #endif 554 562 #endif 563 564 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 565 */
Note: See TracChangeset
for help on using the changeset viewer.