4 #ifndef ClpPackedMatrix_H
5 #define ClpPackedMatrix_H
7 #include "CoinPragma.hpp"
34 return matrix_->getNumElements();
54 return matrix_->getMutableElements();
66 return matrix_->getVectorStarts();
70 return matrix_->getVectorLengths();
74 return matrix_->getVectorSize(index);
78 virtual void deleteCols(
const int numDel,
const int * indDel);
80 virtual void deleteRows(
const int numDel,
const int * indDel);
82 virtual void appendCols(
int number,
const CoinPackedVectorBase *
const * columns);
85 virtual void appendRows(
int number,
const CoinPackedVectorBase *
const * rows);
92 const CoinBigIndex * starts,
const int * index,
93 const double * element,
int numberOther = -1);
99 const int numReplace,
const double * newElements) {
100 matrix_->replaceVector(index, numReplace, newElements);
106 bool keepZero =
false) {
107 matrix_->modifyCoefficient(row, column, newElement, keepZero);
112 virtual CoinBigIndex
countBasis(
const int * whichColumn,
113 int & numberColumnBasic);
116 const int * whichColumn,
117 int & numberColumnBasic,
118 int * row,
int * start,
119 int * rowCount,
int * columnCount,
120 CoinFactorizationDouble * element);
144 double smallest,
double largest,
149 virtual void rangeOfElements(
double & smallestNegative,
double & largestNegative,
150 double & smallestPositive,
double & largestPositive);
161 CoinIndexedVector * rowArray,
165 virtual void add(
const ClpSimplex * model, CoinIndexedVector * rowArray,
166 int column,
double multiplier)
const ;
169 int column,
double multiplier)
const;
181 int & bestSequence,
int & numberWanted);
185 virtual void reallyScale(
const double * rowScale,
const double * columnScale);
199 virtual void times(
double scalar,
200 const double * x,
double * y)
const;
202 virtual void times(
double scalar,
203 const double * x,
double * y,
204 const double * rowScale,
205 const double * columnScale)
const;
210 const double * x,
double * y)
const;
213 const double * x,
double * y,
214 const double * rowScale,
215 const double * columnScale,
216 double * spare = NULL)
const;
223 const double * pi,
double * y,
224 const double * rowScale,
225 const double * columnScale,
226 double * spare = NULL)
const;
232 const CoinIndexedVector * x,
233 CoinIndexedVector * y,
234 CoinIndexedVector * z)
const;
240 const CoinIndexedVector * x,
241 CoinIndexedVector * y,
242 CoinIndexedVector * z)
const;
249 const CoinIndexedVector * x,
250 CoinIndexedVector * y,
251 CoinIndexedVector * z)
const;
256 const CoinIndexedVector * x,
257 const CoinIndexedVector * y,
258 CoinIndexedVector * z)
const;
262 const CoinIndexedVector * pi)
const;
265 const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
266 const CoinIndexedVector * pi2,
267 CoinIndexedVector * spare,
268 double referenceIn,
double devex,
270 unsigned int * reference,
271 double * weights,
double scaleFactor);
274 CoinIndexedVector * dj1,
275 const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
276 double referenceIn,
double devex,
278 unsigned int * reference,
279 double * weights,
double scaleFactor);
284 virtual void times(CoinWorkDouble scalar,
285 const CoinWorkDouble * x, CoinWorkDouble * y)
const ;
287 const CoinWorkDouble * x, CoinWorkDouble * y)
const ;
293 inline CoinPackedMatrix *
matrix()
const {
311 return ((
flags_ & 1) != 0);
315 return ((
flags_ & 16) != 0);
345 int numberRows,
const int * whichRows,
346 int numberColumns,
const int * whichColumns);
348 int numberRows,
const int * whichRows,
349 int numberColumns,
const int * whichColumns);
362 int numberRows,
const int * whichRows,
363 int numberColumns,
const int * whichColumns)
const ;
374 int * COIN_RESTRICT index,
375 double * COIN_RESTRICT array,
376 const double tolerance)
const;
379 const double * COIN_RESTRICT columnScale,
380 int * COIN_RESTRICT index,
381 double * COIN_RESTRICT array,
382 const double tolerance)
const;
385 int * COIN_RESTRICT index,
386 double * COIN_RESTRICT array,
387 const unsigned char * status,
388 const double tolerance)
const;
392 int * COIN_RESTRICT index,
393 double * COIN_RESTRICT array,
394 const unsigned char * status,
395 int * COIN_RESTRICT spareIndex,
396 double * COIN_RESTRICT spareArray,
399 double & bestPossible,
400 double acceptablePivot,
401 double dualTolerance,
402 int & numberRemaining,
403 const double zeroTolerance)
const;
406 const double * COIN_RESTRICT columnScale,
407 int * COIN_RESTRICT index,
408 double * COIN_RESTRICT array,
409 const unsigned char * status,
410 const double tolerance)
const;
413 int * COIN_RESTRICT index,
414 double * COIN_RESTRICT output,
416 const double tolerance,
417 const double scalar)
const;
420 int * COIN_RESTRICT index,
421 double * COIN_RESTRICT output,
422 int * COIN_RESTRICT lookup,
423 char * COIN_RESTRICT marked,
424 const double tolerance,
425 const double scalar)
const;
428 CoinIndexedVector * spareVector,
const double tolerance,
const double scalar)
const;
431 const double tolerance,
const double scalar)
const;
463 double acceptablePivot;
470 double * bestPossiblePtr;
471 double * upperThetaPtr;
473 double * freePivotPtr;
475 const unsigned short * count;
477 const CoinBigIndex * rowStart;
478 const double * element;
479 const unsigned short * column;
481 int numberInRowArray;
494 const CoinPackedMatrix * rowCopy,
495 const CoinIndexedVector * x,
496 CoinIndexedVector * spareArray,
497 CoinIndexedVector * z)
const;
542 pthread_t * threadId_;
543 dualColumn0Struct * info_;
564 CoinIndexedVector * output)
const;
567 const double * pi, CoinIndexedVector * dj1,
568 const double * piWeight,
569 double referenceIn,
double devex,
571 unsigned int * reference,
572 double * weights,
double scaleFactor);
void clearCopies()
Gets rid of special copies.
virtual int getNumCols() const
Number of columns.
virtual int scale(ClpModel *model, const ClpSimplex *baseModel=NULL) const
Creates scales for column copy (rowCopy in model may be modified) returns non-zero if no scaling done...
int numberBlocks_
Number of blocks.
void releaseSpecialColumnCopy()
Say we don't want special column copy.
bool usefulInfo() const
Returns true if copy has useful information.
ClpPackedMatrix3()
Default constructor.
int numberRows_
Number of rows.
void swapOne(const ClpSimplex *model, const ClpPackedMatrix *matrix, int iColumn)
Swap one variable.
virtual void copy(const ClpPackedMatrix *from)
Copy contents - resizing if necessary - otherwise re-use memory.
CoinBigIndex * start_
Starts for odd/long vectors.
void checkFlags(int type) const
Check validity.
int flags_
Flags - 1 - has zero elements 2 - has gaps 4 - has special row copy 8 - has special column copy 16 - ...
virtual void scaleRowCopy(ClpModel *model) const
Scales rowCopy if column copy scaled Only called if scales already exist.
virtual ClpMatrixBase * reverseOrderedCopy() const
Returns a new matrix in reverse order without gaps.
int gutsOfTransposeTimesScaled(const double *COIN_RESTRICT pi, const double *COIN_RESTRICT columnScale, int *COIN_RESTRICT index, double *COIN_RESTRICT array, const double tolerance) const
Meat of transposeTimes by column when scaled.
virtual ClpMatrixBase * subsetClone(int numberRows, const int *whichRows, int numberColumns, const int *whichColumns) const
Subset clone (without gaps).
double * getMutableElements() const
Mutable elements.
virtual void unpackPacked(ClpSimplex *model, CoinIndexedVector *rowArray, int column) const
Unpacks a column into an CoinIndexedvector in packed foramt Note that model is NOT const...
double * element_
Elements.
virtual void transposeTimes2(const ClpSimplex *model, const CoinIndexedVector *pi1, CoinIndexedVector *dj1, const CoinIndexedVector *pi2, CoinIndexedVector *spare, double referenceIn, double devex, unsigned int *reference, double *weights, double scaleFactor)
Updates two arrays for steepest.
virtual ~ClpPackedMatrix3()
Destructor.
int * column_
Column indices and reverse lookup (within block)
ClpPackedMatrix()
Default constructor.
virtual void partialPricing(ClpSimplex *model, double start, double end, int &bestSequence, int &numberWanted)
Partial pricing.
virtual void transposeTimesByRow(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
void gutsOfTransposeTimesByRowEQ2(const CoinIndexedVector *piVector, CoinIndexedVector *output, CoinIndexedVector *spareVector, const double tolerance, const double scalar) const
Meat of transposeTimes by row n == 2 if packed.
void specialColumnCopy(ClpSimplex *model)
make special column copy
ClpPackedMatrix & operator=(const ClpPackedMatrix &)
The copy constructor.
void transposeTimes(const ClpSimplex *model, const double *pi, CoinIndexedVector *output) const
Return x * -1 * A in z.
virtual void deleteRows(const int numDel, const int *indDel)
Delete the rows whose indices are listed in indDel.
void useEffectiveRhs(ClpSimplex *model)
Sets up an effective RHS.
int * offset_
Column offset for each block (plus one at end)
CoinPackedMatrix * matrix() const
Returns CoinPackedMatrix (non const)
virtual ClpMatrixBase * clone() const
Clone.
virtual int getNumRows() const
Number of rows.
virtual bool canCombine(const ClpSimplex *model, const CoinIndexedVector *pi) const
Returns true if can combine transposeTimes and subsetTransposeTimes and if it would be faster...
virtual void appendCols(int number, const CoinPackedVectorBase *const *columns)
Append Columns.
void transposeTimesSubset(int number, const int *which, const double *pi, double *y, const double *rowScale, const double *columnScale, double *spare=NULL) const
Return y - pi * A in y.
virtual const int * getVectorLengths() const
The lengths of the major-dimension vectors.
ClpPackedMatrix3 * columnCopy_
Special column copy.
int numberActiveColumns_
number of active columns (normally same as number of columns)
void gutsOfTransposeTimesByRowEQ1(const CoinIndexedVector *piVector, CoinIndexedVector *output, const double tolerance, const double scalar) const
Meat of transposeTimes by row n == 1 if packed.
int type() const
Returns type.
virtual void fillBasis(ClpSimplex *model, const int *whichColumn, int &numberColumnBasic, int *row, int *start, int *rowCount, int *columnCount, CoinFactorizationDouble *element)
Fills in column part of basis.
virtual void add(const ClpSimplex *model, CoinIndexedVector *rowArray, int column, double multiplier) const
Adds multiple of a column into an CoinIndexedvector You can use quickAdd to add to vector...
void makeSpecialColumnCopy()
Say we want special column copy.
virtual int appendMatrix(int number, int type, const CoinBigIndex *starts, const int *index, const double *element, int numberOther=-1)
Append a set of rows/columns to the end of the matrix.
virtual void appendRows(int number, const CoinPackedVectorBase *const *rows)
Append Rows.
virtual CoinBigIndex getNumElements() const
Number of entries in the packed matrix.
virtual void subsetTransposeTimes(const ClpSimplex *model, const CoinIndexedVector *x, const CoinIndexedVector *y, CoinIndexedVector *z) const
Return x *A in z but just for indices in y.
virtual int refresh(ClpSimplex *model)
makes sure active columns correct
void transposeTimes(const ClpSimplex *model, const CoinPackedMatrix *rowCopy, const CoinIndexedVector *x, CoinIndexedVector *spareArray, CoinIndexedVector *z) const
Return x * -1 * A in z.
virtual void deleteCols(const int numDel, const int *indDel)
Delete the columns whose indices are listed in indDel.
virtual void transposeTimes(double scalar, const double *x, double *y) const
Return y + x * scalar * A in y.
virtual void setDimensions(int numrows, int numcols)
Set the dimensions of the matrix.
void specialRowCopy(ClpSimplex *model, const ClpMatrixBase *rowCopy)
make special row copy
int numberColumns_
Number of columns.
virtual int getVectorLength(int index) const
The length of a single major-dimension vector.
void sortBlocks(const ClpSimplex *model)
Sort blocks.
virtual void times(double scalar, const double *x, double *y) const
Return y + A * scalar *x in y.
virtual void reallyScale(const double *rowScale, const double *columnScale)
Return a complete CoinPackedMatrix.
void transposeTimes2(const ClpSimplex *model, const double *pi, CoinIndexedVector *dj1, const double *piWeight, double referenceIn, double devex, unsigned int *reference, double *weights, double scaleFactor)
Updates two arrays for steepest.
virtual void rangeOfElements(double &smallestNegative, double &largestNegative, double &smallestPositive, double &largestPositive)
Returns largest and smallest elements of both signs.
ClpPackedMatrix2 * rowCopy_
Special row copy.
CoinBigIndex * rowStart_
Row starts.
This solves LPs using the simplex method.
void createScaledMatrix(ClpSimplex *model) const
Creates scaled column copy if scales exist.
bool wantsSpecialColumnCopy() const
Do we want special column copy.
virtual const double * getElements() const
A vector containing the elements in the packed matrix.
void checkGaps()
Sets flags_ correctly.
virtual ClpMatrixBase * scaledColumnCopy(ClpModel *model) const
Realy really scales column copy Only called if scales already exist.
virtual void correctSequence(const ClpSimplex *model, int &sequenceIn, int &sequenceOut)
Correct sequence in and out to give true value.
Abstract base class for Clp Matrices.
ClpPackedMatrix2()
Default constructor.
int gutsOfTransposeTimesByRowGE3(const CoinIndexedVector *COIN_RESTRICT piVector, int *COIN_RESTRICT index, double *COIN_RESTRICT output, int *COIN_RESTRICT lookup, char *COIN_RESTRICT marked, const double tolerance, const double scalar) const
Meat of transposeTimes by row n > 2 if packed - returns number nonzero.
virtual void modifyCoefficient(int row, int column, double newElement, bool keepZero=false)
Modify one element of packed matrix.
unsigned short * count_
Counts of elements in each part of row.
int numberBlocks_
Number of blocks.
virtual const int * getIndices() const
A vector containing the minor indices of the elements in the packed matrix.
double reducedCost(ClpSimplex *model, int sequence) const
Returns reduced cost of a variable.
void setMatrixNull()
Just sets matrix_ to NULL so it can be used elsewhere.
unsigned short * column_
columns within block
ClpPackedMatrix2 & operator=(const ClpPackedMatrix2 &)
The copy constructor.
virtual CoinPackedMatrix * getPackedMatrix() const
Return a complete CoinPackedMatrix.
virtual CoinBigIndex countBasis(const int *whichColumn, int &numberColumnBasic)
Returns number of elements in column part of basis.
int gutsOfTransposeTimesUnscaled(const double *COIN_RESTRICT pi, int *COIN_RESTRICT index, double *COIN_RESTRICT array, const double tolerance) const
Meat of transposeTimes by column when not scaled.
virtual void subsetTimes2(const ClpSimplex *model, CoinIndexedVector *dj1, const CoinIndexedVector *pi2, CoinIndexedVector *dj2, double referenceIn, double devex, unsigned int *reference, double *weights, double scaleFactor)
Updates second array for steepest and does devex weights.
virtual const CoinBigIndex * getVectorStarts() const
Return a complete CoinPackedMatrix.
virtual void replaceVector(const int index, const int numReplace, const double *newElements)
Replace the elements of a vector.
virtual ~ClpPackedMatrix2()
Destructor.
void transposeTimesByColumn(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
int gutsOfTransposeTimesByRowGEK(const CoinIndexedVector *COIN_RESTRICT piVector, int *COIN_RESTRICT index, double *COIN_RESTRICT output, int numberColumns, const double tolerance, const double scalar) const
Meat of transposeTimes by row n > K if packed - returns number nonzero.
CoinPackedMatrix * matrix_
Data.
virtual ~ClpPackedMatrix()
Destructor.
ClpPackedMatrix3 & operator=(const ClpPackedMatrix3 &)
The copy constructor.
virtual bool allElementsInRange(ClpModel *model, double smallest, double largest, int check=15)
Checks if all elements are in valid range.
virtual bool isColOrdered() const
Whether the packed matrix is column major ordered or not.
CoinBigIndex startElements_
bool zeros() const
Are there zeros?
virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, int column) const
Unpacks a column into an CoinIndexedvector.
virtual bool canDoPartialPricing() const
Says whether it can do partial pricing.
blockStruct * block_
Blocks (ordinary start at 0 and go to first block)
double * work_
work arrays
virtual CoinBigIndex * dubiousWeights(const ClpSimplex *model, int *inputWeights) const
Given positive integer weights for each row fills in sum of weights for each column (and slack)...
virtual void releasePackedMatrix() const
Allow any parts of a created CoinPackedMatrix to be deleted.