6#ifndef ClpPackedMatrix_H
7#define ClpPackedMatrix_H
9#include "CoinPragma.hpp"
36 return matrix_->getNumElements();
56 return matrix_->getMutableElements();
68 return matrix_->getVectorStarts();
72 return matrix_->getVectorLengths();
76 return matrix_->getVectorSize(index);
80 virtual void deleteCols(
const int numDel,
const int * indDel);
82 virtual void deleteRows(
const int numDel,
const int * indDel);
85 virtual void appendCols(
int number,
const CoinPackedVectorBase *
const * columns);
87 virtual void appendRows(
int number,
const CoinPackedVectorBase *
const * rows);
94 const CoinBigIndex * starts,
const int * index,
95 const double * element,
int numberOther = -1);
101 const int numReplace,
const double * newElements) {
102 matrix_->replaceVector(index, numReplace, newElements);
108 bool keepZero =
false) {
109 matrix_->modifyCoefficient(row, column, newElement, keepZero);
115 int & numberColumnBasic);
118 const int * whichColumn,
119 int & numberColumnBasic,
120 int * row,
int * start,
121 int * rowCount,
int * columnCount,
122 CoinFactorizationDouble * element);
146 double smallest,
double largest,
152 double & smallestPositive,
double & largestPositive);
163 CoinIndexedVector * rowArray,
168 int column,
double multiplier)
const ;
171 int column,
double multiplier)
const;
183 int & bestSequence,
int & numberWanted);
187 virtual void reallyScale(
const double * rowScale,
const double * columnScale);
202 const double * x,
double * y)
const;
205 const double * x,
double * y,
206 const double * rowScale,
207 const double * columnScale)
const;
212 const double * x,
double * y)
const;
215 const double * x,
double * y,
216 const double * rowScale,
217 const double * columnScale,
218 double * spare = NULL)
const;
225 const double * pi,
double * y,
226 const double * rowScale,
227 const double * columnScale,
228 double * spare = NULL)
const;
234 const CoinIndexedVector * x,
235 CoinIndexedVector * y,
236 CoinIndexedVector * z)
const;
242 const CoinIndexedVector * x,
243 CoinIndexedVector * y,
244 CoinIndexedVector * z)
const;
251 const CoinIndexedVector * x,
252 CoinIndexedVector * y,
253 CoinIndexedVector * z)
const;
258 const CoinIndexedVector * x,
259 const CoinIndexedVector * y,
260 CoinIndexedVector * z)
const;
264 const CoinIndexedVector * pi)
const;
267 const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
268 const CoinIndexedVector * pi2,
269 CoinIndexedVector * spare,
270 double referenceIn,
double devex,
272 unsigned int * reference,
273 double * weights,
double scaleFactor);
276 CoinIndexedVector * dj1,
277 const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
278 double referenceIn,
double devex,
280 unsigned int * reference,
281 double * weights,
double scaleFactor);
286 virtual void times(CoinWorkDouble scalar,
287 const CoinWorkDouble * x, CoinWorkDouble * y)
const ;
289 const CoinWorkDouble * x, CoinWorkDouble * y)
const ;
296 inline CoinPackedMatrix *
matrix()
const {
313 return ((
flags_ & 1) != 0);
317 return ((
flags_ & 16) != 0);
353 int numberRows,
const int * whichRows,
354 int numberColumns,
const int * whichColumns);
356 int numberRows,
const int * whichRows,
357 int numberColumns,
const int * whichColumns);
370 int numberRows,
const int * whichRows,
371 int numberColumns,
const int * whichColumns)
const ;
381 int gutsOfTransposeTimesUnscaled(
const double *
COIN_RESTRICT pi,
384 const double tolerance)
const;
386 int gutsOfTransposeTimesScaled(
const double *
COIN_RESTRICT pi,
390 const double tolerance)
const;
392 int gutsOfTransposeTimesUnscaled(
const double *
COIN_RESTRICT pi,
395 const unsigned char * status,
396 const double tolerance)
const;
399 int gutsOfTransposeTimesUnscaled(
const double *
COIN_RESTRICT pi,
402 const unsigned char * status,
407 double & bestPossible,
408 double acceptablePivot,
409 double dualTolerance,
410 int & numberRemaining,
411 const double zeroTolerance)
const;
413 int gutsOfTransposeTimesScaled(
const double *
COIN_RESTRICT pi,
417 const unsigned char * status,
418 const double tolerance)
const;
420 int gutsOfTransposeTimesByRowGEK(
const CoinIndexedVector *
COIN_RESTRICT piVector,
424 const double tolerance,
425 const double scalar)
const;
427 int gutsOfTransposeTimesByRowGE3(
const CoinIndexedVector *
COIN_RESTRICT piVector,
431 const double tolerance,
432 const double scalar)
const;
434 int gutsOfTransposeTimesByRowGE3a(
const CoinIndexedVector *
COIN_RESTRICT piVector,
439 const double tolerance,
440 const double scalar)
const;
442 void gutsOfTransposeTimesByRowEQ2(
const CoinIndexedVector * piVector, CoinIndexedVector * output,
443 CoinIndexedVector * spareVector,
const double tolerance,
const double scalar)
const;
445 void gutsOfTransposeTimesByRowEQ1(
const CoinIndexedVector * piVector, CoinIndexedVector * output,
446 const double tolerance,
const double scalar)
const;
478 double acceptablePivot;
485 double * bestPossiblePtr;
486 double * upperThetaPtr;
488 double * freePivotPtr;
490 const unsigned short * count;
492 const CoinBigIndex * rowStart;
493 const double * element;
494 const unsigned short * column;
496 int numberInRowArray;
509 const CoinPackedMatrix * rowCopy,
510 const CoinIndexedVector * x,
511 CoinIndexedVector * spareArray,
512 CoinIndexedVector * z)
const;
557 pthread_t * threadId_;
558 dualColumn0Struct * info_;
579 CoinIndexedVector * output)
const;
582 const double * pi, CoinIndexedVector * dj1,
583 const double * piWeight,
584 double referenceIn,
double devex,
586 unsigned int * reference,
587 double * weights,
double scaleFactor);
Abstract base class for Clp Matrices.
double reducedCost(ClpSimplex *model, int sequence) const
Returns reduced cost of a variable.
int type() const
Returns type.
ClpPackedMatrix2(ClpSimplex *model, const CoinPackedMatrix *rowCopy)
Constructor from copy.
double * work_
work arrays
ClpPackedMatrix2 & operator=(const ClpPackedMatrix2 &)
ClpPackedMatrix2()
Default constructor.
ClpPackedMatrix2(const ClpPackedMatrix2 &)
The copy constructor.
int numberBlocks_
Number of blocks.
void transposeTimes(const ClpSimplex *model, const CoinPackedMatrix *rowCopy, const CoinIndexedVector *x, CoinIndexedVector *spareArray, CoinIndexedVector *z) const
Return x * -1 * A in z.
virtual ~ClpPackedMatrix2()
Destructor.
unsigned short * count_
Counts of elements in each part of row.
int numberRows_
Number of rows.
int * offset_
Column offset for each block (plus one at end)
unsigned short * column_
columns within block
CoinBigIndex * rowStart_
Row starts.
bool usefulInfo() const
Returns true if copy has useful information.
ClpPackedMatrix3 & operator=(const ClpPackedMatrix3 &)
double * element_
Elements.
ClpPackedMatrix3(const ClpPackedMatrix3 &)
The copy constructor.
void sortBlocks(const ClpSimplex *model)
Sort blocks.
ClpPackedMatrix3()
Default constructor.
blockStruct * block_
Blocks (ordinary start at 0 and go to first block)
ClpPackedMatrix3(ClpSimplex *model, const CoinPackedMatrix *columnCopy)
Constructor from copy.
int * column_
Column indices and reverse lookup (within block)
void swapOne(const ClpSimplex *model, const ClpPackedMatrix *matrix, int iColumn)
Swap one variable.
int numberBlocks_
Number of blocks.
void transposeTimes(const ClpSimplex *model, const double *pi, CoinIndexedVector *output) const
Return x * -1 * A in z.
int numberColumns_
Number of columns.
CoinBigIndex * start_
Starts for odd/long vectors.
virtual ~ClpPackedMatrix3()
Destructor.
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 ~ClpPackedMatrix()
Destructor.
void useEffectiveRhs(ClpSimplex *model)
Sets up an effective RHS.
virtual ClpMatrixBase * clone() const
Clone.
void checkFlags(int type) const
Check validity.
double * getMutableElements() const
Mutable elements.
ClpPackedMatrix(const CoinPackedMatrix &)
The copy constructor from an CoinPackedMatrix.
virtual CoinBigIndex getNumElements() const
Number of entries in the packed matrix.
virtual bool canDoPartialPricing() const
Says whether it can do partial pricing.
virtual void appendCols(int number, const CoinPackedVectorBase *const *columns)
Append Columns.
virtual void appendRows(int number, const CoinPackedVectorBase *const *rows)
Append Rows.
void checkGaps()
Sets flags_ correctly.
virtual void reallyScale(const double *rowScale, const double *columnScale)
bool wantsSpecialColumnCopy() const
Do we want special column copy.
virtual bool allElementsInRange(ClpModel *model, double smallest, double largest, int check=15)
Checks if all elements are in valid range.
bool zeros() const
Are there zeros?
virtual bool isColOrdered() const
Whether the packed matrix is column major ordered or not.
void releaseSpecialColumnCopy()
Say we don't want special column copy.
virtual int getVectorLength(int index) const
The length of a single major-dimension vector.
virtual void replaceVector(const int index, const int numReplace, const double *newElements)
Replace the elements of a vector.
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.
ClpPackedMatrix(const ClpPackedMatrix &)
The copy constructor.
void setNumberActiveColumns(int value)
Set number of active columns (normally same as number of columns)
void setMatrixNull()
Just sets matrix_ to NULL so it can be used elsewhere.
virtual void releasePackedMatrix() const
Allow any parts of a created CoinPackedMatrix to be deleted.
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 times(double scalar, const double *x, double *y) const
Return y + A * scalar *x in y.
virtual void copy(const ClpPackedMatrix *from)
Copy contents - resizing if necessary - otherwise re-use memory.
ClpPackedMatrix()
Default constructor.
ClpPackedMatrix(const CoinPackedMatrix &wholeModel, int numberRows, const int *whichRows, int numberColumns, const int *whichColumns)
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 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 void scaleRowCopy(ClpModel *model) const
Scales rowCopy if column copy scaled Only called if scales already exist.
int flags_
Flags - 1 - has zero elements 2 - has gaps 4 - has special row copy 8 - has special column copy 16 - ...
virtual ClpMatrixBase * subsetClone(int numberRows, const int *whichRows, int numberColumns, const int *whichColumns) const
Subset clone (without gaps).
virtual void partialPricing(ClpSimplex *model, double start, double end, int &bestSequence, int &numberWanted)
Partial pricing.
virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, int column) const
Unpacks a column into an CoinIndexedvector.
virtual CoinPackedMatrix * getPackedMatrix() const
Return a complete CoinPackedMatrix.
virtual int refresh(ClpSimplex *model)
makes sure active columns correct
void transposeTimesByColumn(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y 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 double *rowScale, const double *columnScale, double *spare=NULL) const
And for scaling.
virtual void correctSequence(const ClpSimplex *model, int &sequenceIn, int &sequenceOut)
Correct sequence in and out to give true value.
void makeSpecialColumnCopy()
Say we want special column copy.
void specialColumnCopy(ClpSimplex *model)
make special column copy
ClpPackedMatrix3 * columnCopy_
Special column copy.
virtual void modifyCoefficient(int row, int column, double newElement, bool keepZero=false)
Modify one element of packed matrix.
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.
virtual void rangeOfElements(double &smallestNegative, double &largestNegative, double &smallestPositive, double &largestPositive)
Returns largest and smallest elements of both signs.
int numberActiveColumns_
number of active columns (normally same as number of 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 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.
int numberActiveColumns() const
number of active columns (normally same as number of columns)
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 const CoinBigIndex * getVectorStarts() const
virtual void transposeTimes(double scalar, const double *x, double *y) const
Return y + x * scalar * A in y.
CoinPackedMatrix * matrix() const
Returns CoinPackedMatrix (non const)
virtual void add(const ClpSimplex *model, double *array, int column, double multiplier) const
Adds multiple of a column into an array.
virtual int getNumRows() const
Number of rows.
virtual ClpMatrixBase * scaledColumnCopy(ClpModel *model) const
Realy really scales column copy Only called if scales already exist.
virtual void transposeTimesByRow(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
ClpPackedMatrix(CoinPackedMatrix *matrix)
This takes over ownership (for space reasons)
virtual CoinBigIndex countBasis(const int *whichColumn, int &numberColumnBasic)
Returns number of elements in column part of basis.
CoinPackedMatrix * matrix_
Data.
virtual ClpMatrixBase * reverseOrderedCopy() const
Returns a new matrix in reverse order without gaps.
virtual const int * getVectorLengths() const
The lengths of the major-dimension vectors.
virtual const double * getElements() const
A vector containing the elements 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.
void specialRowCopy(ClpSimplex *model, const ClpMatrixBase *rowCopy)
make special row copy
ClpPackedMatrix & operator=(const ClpPackedMatrix &)
virtual void setDimensions(int numrows, int numcols)
Set the dimensions of the matrix.
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...
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.
ClpPackedMatrix2 * rowCopy_
Special row copy.
void createScaledMatrix(ClpSimplex *model) const
Creates scaled column copy if scales exist.
virtual void transposeTimes(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
virtual int getNumCols() const
Number of columns.
virtual void deleteRows(const int numDel, const int *indDel)
Delete the rows whose indices are listed in indDel.
virtual void times(double scalar, const double *x, double *y, const double *rowScale, const double *columnScale) const
And for scaling.
ClpPackedMatrix(const ClpPackedMatrix &wholeModel, int numberRows, const int *whichRows, int numberColumns, const int *whichColumns)
Subset constructor (without gaps).
virtual const int * getIndices() const
A vector containing the minor indices of the elements in the packed matrix.
This solves LPs using the simplex method.
CoinBigIndex startElements_