Go to the documentation of this file.
6 #ifndef ClpPackedMatrix_H
7 #define ClpPackedMatrix_H
9 #include "CoinPragma.hpp"
22 class CoinDoubleArrayWithLength;
41 return matrix_->getNumElements();
65 return matrix_->getMutableElements();
79 return matrix_->getVectorStarts();
84 return matrix_->getVectorLengths();
89 return matrix_->getVectorSize(index);
93 virtual void deleteCols(
const int numDel,
const int *indDel);
95 virtual void deleteRows(
const int numDel,
const int *indDel);
97 virtual void appendCols(
int number,
const CoinPackedVectorBase *
const *columns);
100 virtual void appendRows(
int number,
const CoinPackedVectorBase *
const *rows);
107 const CoinBigIndex *starts,
const int *index,
108 const double *element,
int numberOther = -1);
114 const int numReplace,
const double *newElements)
116 matrix_->replaceVector(index, numReplace, newElements);
122 bool keepZero =
false)
124 matrix_->modifyCoefficient(row, column, newElement, keepZero);
129 virtual int countBasis(
const int *whichColumn,
130 int &numberColumnBasic);
133 const int *whichColumn,
134 int &numberColumnBasic,
135 int *row,
int *start,
136 int *rowCount,
int *columnCount,
137 CoinFactorizationDouble *element);
161 double smallest,
double largest,
166 virtual void rangeOfElements(
double &smallestNegative,
double &largestNegative,
167 double &smallestPositive,
double &largestPositive);
178 CoinIndexedVector *rowArray,
182 virtual void add(
const ClpSimplex *model, CoinIndexedVector *rowArray,
183 int column,
double multiplier)
const;
186 int column,
double multiplier)
const;
198 int &bestSequence,
int &numberWanted);
202 virtual void reallyScale(
const double *rowScale,
const double *columnScale);
216 virtual void times(
double scalar,
217 const double *x,
double *y)
const;
219 virtual void times(
double scalar,
220 const double *x,
double *y,
221 const double *rowScale,
222 const double *columnScale)
const;
227 const double *x,
double *y)
const;
230 const double *x,
double *y,
231 const double *rowScale,
232 const double *columnScale,
233 double *spare = NULL)
const;
240 const double *pi,
double *y,
241 const double *rowScale,
242 const double *columnScale,
243 double *spare = NULL)
const;
249 const CoinIndexedVector *x,
250 CoinIndexedVector *y,
251 CoinIndexedVector *z)
const;
257 const CoinIndexedVector *x,
258 CoinIndexedVector *y,
259 CoinIndexedVector *z)
const;
266 const CoinIndexedVector *x,
267 CoinIndexedVector *y,
268 CoinIndexedVector *z)
const;
273 const CoinIndexedVector *x,
274 const CoinIndexedVector *y,
275 CoinIndexedVector *z)
const;
279 const CoinIndexedVector *pi)
const;
284 const CoinIndexedVector *pi1, CoinIndexedVector *dj1,
285 const CoinIndexedVector *pi2,
286 CoinIndexedVector *spare,
288 double referenceIn,
double devex,
290 unsigned int *reference,
291 double *weights,
double scaleFactor);
294 CoinIndexedVector *dj1,
295 const CoinIndexedVector *pi2, CoinIndexedVector *dj2,
296 double referenceIn,
double devex,
298 unsigned int *reference,
299 double *weights,
double scaleFactor);
304 virtual void times(CoinWorkDouble scalar,
305 const CoinWorkDouble *x, CoinWorkDouble *y)
const;
307 const CoinWorkDouble *x, CoinWorkDouble *y)
const;
313 inline CoinPackedMatrix *
matrix()
const
335 return ((
flags_ & 1) != 0);
340 return ((
flags_ & 16) != 0);
381 int numberRows,
const int *whichRows,
382 int numberColumns,
const int *whichColumns);
384 int numberRows,
const int *whichRows,
385 int numberColumns,
const int *whichColumns);
398 int numberRows,
const int *whichRows,
399 int numberColumns,
const int *whichColumns)
const;
412 const double tolerance)
const;
418 const double tolerance)
const;
423 const unsigned char *status,
424 const double tolerance)
const;
430 const unsigned char *status,
435 double acceptablePivot,
436 double dualTolerance,
437 int &numberRemaining,
438 const double zeroTolerance)
const;
444 const unsigned char *status,
445 const double tolerance)
const;
451 const double tolerance,
452 const double scalar)
const;
458 const double tolerance,
459 const double scalar)
const;
466 const double tolerance,
467 const double scalar)
const;
470 CoinIndexedVector *spareVector,
const double tolerance,
const double scalar)
const;
473 const double tolerance,
const double scalar)
const;
504 double acceptablePivot;
512 double *upperThetaPtr;
514 double *freePivotPtr;
516 const unsigned short *count;
518 const CoinBigIndex *rowStart;
519 const double *element;
520 const unsigned short *column;
522 int numberInRowArray;
535 const CoinPackedMatrix *rowCopy,
536 const CoinIndexedVector *x,
537 CoinIndexedVector *spareArray,
538 CoinIndexedVector *z)
const;
582 pthread_t *threadId_;
583 dualColumn0Struct *info_;
614 CoinIndexedVector *output)
const;
619 CoinIndexedVector *output,
620 CoinIndexedVector *candidate,
621 const CoinIndexedVector *rowArray)
const;
623 const double *pi, CoinIndexedVector *dj1,
624 const double *piWeight,
627 double referenceIn,
double devex,
629 unsigned int *reference,
630 double *weights,
double scaleFactor);
657 void swapOne(
int iBlock,
int kA,
int kB);
699 int endChunk_[2 * ABOCA_LITE + 1];
708 #elif INCLUDE_MATRIX3_PRICING
709 int iColumn = *column;
711 if (fabs(value) > zeroTolerance) {
712 double thisWeight = weights[iColumn];
713 double pivot = value * scaleFactor;
714 double pivotSquared = pivot * pivot;
715 thisWeight += pivotSquared * devex + pivot * modification;
717 if (referenceIn < 0.0) {
722 thisWeight = referenceIn * pivotSquared;
723 if (reference(iColumn))
729 weights[iColumn] = thisWeight;
730 value = reducedCost[iColumn] - value;
731 reducedCost[iColumn] = value;
732 unsigned char thisStatus = status[iColumn] & 7;
733 assert(thisStatus != 0 && thisStatus != 4);
734 if (thisStatus == 3) {
739 assert(thisStatus == 2);
742 if (value < dualTolerance) {
744 if (value > bestRatio * weights[iColumn]) {
745 bestSequence = iColumn;
746 bestRatio = value / weights[iColumn];
747 #if NO_CHANGE_MULTIPLIER != 1
748 bestRatio2 = bestRatio * NO_CHANGE_MULTIPLIER;
754 value = reducedCost[iColumn];
755 unsigned char thisStatus = status[iColumn] & 7;
756 assert(thisStatus != 0 && thisStatus != 4);
757 if (thisStatus == 3) {
758 }
else if ((thisStatus & 1) != 0) {
764 if (value < dualTolerance) {
766 if (value > bestRatio2 * weights[iColumn]) {
767 bestSequence = iColumn;
768 bestRatio2 = value / weights[iColumn];
769 #if NO_CHANGE_MULTIPLIER != 1
770 bestRatio = bestRatio2 * INVERSE_MULTIPLIER;
virtual void partialPricing(ClpSimplex *model, double start, double end, int &bestSequence, int &numberWanted)
Partial pricing.
This solves LPs using the simplex method.
virtual const CoinBigIndex * getVectorStarts() const
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.
ClpPackedMatrix3()
Default constructor.
virtual int transposeTimes2(const ClpSimplex *model, const CoinIndexedVector *pi1, CoinIndexedVector *dj1, const CoinIndexedVector *pi2, CoinIndexedVector *spare, double *infeas, double *reducedCost, double referenceIn, double devex, unsigned int *reference, double *weights, double scaleFactor)
Updates two arrays for steepest and does devex weights Returns nonzero if updates reduced cost and in...
virtual ClpMatrixBase * subsetClone(int numberRows, const int *whichRows, int numberColumns, const int *whichColumns) const
Subset clone (without gaps).
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.
int flags_
Flags - 1 - has zero elements 2 - has gaps 4 - has special row copy 8 - has special column copy 16 - ...
void transposeTimes(const ClpSimplex *model, const CoinPackedMatrix *rowCopy, const CoinIndexedVector *x, CoinIndexedVector *spareArray, CoinIndexedVector *z) const
Return x * -1 * A in z.
virtual void releasePackedMatrix() const
Allow any parts of a created CoinPackedMatrix to be deleted.
virtual void scaleRowCopy(ClpModel *model) const
Scales rowCopy if column copy scaled Only called if scales already exist.
bool wantsSpecialColumnCopy() const
Do we want special column copy.
void swapOne(const ClpSimplex *model, const ClpPackedMatrix *matrix, int iColumn)
Swap one variable.
int type() const
Returns type.
int numberRows_
Number of rows.
virtual void modifyCoefficient(int row, int column, double newElement, bool keepZero=false)
Modify one element of packed matrix.
virtual int scale(ClpModel *model, ClpSimplex *simplex=NULL) const
Creates scales for column copy (rowCopy in model may be modified) returns non-zero if no scaling done...
CoinBigIndex numberElements_
Number of elements (including gaps)
int numberColumnsWithGaps_
Number of columns including gaps.
void setMatrixNull()
Just sets matrix_ to NULL so it can be used elsewhere.
virtual void deleteRows(const int numDel, const int *indDel)
Delete the rows whose indices are listed in indDel.
virtual int refresh(ClpSimplex *model)
makes sure active columns correct
void makeSpecialColumnCopy()
Say we want special column copy.
virtual int getVectorLength(int index) const
The length of a single major-dimension vector.
ClpPackedMatrix3 * columnCopy_
Special column copy.
virtual void times(double scalar, const double *x, double *y) const
Return y + A * scalar *x in y.
virtual const double * getElements() const
A vector containing the elements in the packed matrix.
int gutsOfTransposeTimesByRowGE3(const CoinIndexedVector *COIN_RESTRICT piVector, int *COIN_RESTRICT index, double *COIN_RESTRICT output, double *COIN_RESTRICT array2, const double tolerance, const double scalar) const
Meat of transposeTimes by row n > 2 if packed - returns number nonzero.
int numberColumns_
Number of columns.
int numberBlocks_
Number of blocks.
void checkGaps()
Sets flags_ correctly.
virtual ClpMatrixBase * reverseOrderedCopy() const
Returns a new matrix in reverse order without gaps.
virtual bool isColOrdered() const
Whether the packed matrix is column major ordered or not.
CoinBigIndex * start_
Starts for odd/long vectors??
int redoInfeasibilities(const ClpSimplex *model, ClpPrimalColumnSteepest *pivotChoose, int type)
type - 1 redo infeasible, 2 choose sequenceIn, 3 both returns sequenceIn (or -1) for type 2
ClpPackedMatrix()
Default constructor.
void createScaledMatrix(ClpSimplex *model) const
Creates scaled column copy if scales exist.
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 ClpMatrixBase * scaledColumnCopy(ClpModel *model) const
Realy really scales column copy Only called if scales already exist.
void specialRowCopy(ClpSimplex *model, const ClpMatrixBase *rowCopy)
make special row copy
virtual ~ClpPackedMatrix2()
Destructor.
virtual ClpMatrixBase * clone() const
Clone.
CoinPackedMatrix * matrix_
Data.
virtual void correctSequence(const ClpSimplex *model, int &sequenceIn, int &sequenceOut)
Correct sequence in and out to give true value.
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.
void setNumberActiveColumns(int value)
Set number of active columns (normally same as number of columns)
virtual CoinPackedMatrix * getPackedMatrix() const
Return a complete CoinPackedMatrix.
unsigned short * column_
columns within block
virtual void deleteCols(const int numDel, const int *indDel)
Delete the columns whose indices are listed in indDel.
virtual bool canDoPartialPricing() const
Says whether it can do partial pricing.
ClpPackedMatrix & operator=(const ClpPackedMatrix &)
virtual void replaceVector(const int index, const int numReplace, const double *newElements)
Replace the elements of a vector.
CoinPackedMatrix * matrix() const
Returns CoinPackedMatrix (non const)
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.
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.
Abstract base class for Clp Matrices.
void checkFlags(int type) const
Check validity.
CoinDoubleArrayWithLength * temporary_
Temporary work area (aligned)
void checkBlocks(const ClpSimplex *model)
Debug - check blocks.
bool usefulInfo() const
Returns true if copy has useful information.
unsigned short * count_
Counts of elements in each part of row.
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.
double * element_
Elements.
virtual int countBasis(const int *whichColumn, int &numberColumnBasic)
Returns number of elements in column part of basis.
void transposeTimes2(const ClpSimplex *model, const double *pi, CoinIndexedVector *dj1, const double *piWeight, double *COIN_RESTRICT infeas, double *COIN_RESTRICT reducedCost, double referenceIn, double devex, unsigned int *reference, double *weights, double scaleFactor)
virtual void rangeOfElements(double &smallestNegative, double &largestNegative, double &smallestPositive, double &largestPositive)
Returns largest and smallest elements of both signs.
virtual bool canCombine(const ClpSimplex *model, const CoinIndexedVector *pi) const
Returns true if can combine transposeTimes and subsetTransposeTimes and if it would be faster.
ClpPackedMatrix2()
Default constructor.
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 void appendRows(int number, const CoinPackedVectorBase *const *rows)
Append Rows.
void transposeTimes(const ClpSimplex *model, const double *pi, CoinIndexedVector *output) const
Return x * -1 * A in z.
CoinBigIndex startElements_
int numberActiveColumns_
number of active columns (normally same as number of columns)
virtual ~ClpPackedMatrix()
Destructor.
CoinBigIndex * rowStart_
Row starts.
void useEffectiveRhs(ClpSimplex *model)
Sets up an effective RHS.
virtual bool allElementsInRange(ClpModel *model, double smallest, double largest, int check=15)
Checks if all elements are in valid range.
double reducedCost(ClpSimplex *model, int sequence) const
Returns reduced cost of a variable.
virtual void reallyScale(const double *rowScale, const double *columnScale)
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.
int numberBlocks_
Number of blocks.
void gutsOfTransposeTimesByRowEQ1(const CoinIndexedVector *piVector, CoinIndexedVector *output, const double tolerance, const double scalar) const
Meat of transposeTimes by row n == 1 if packed.
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.
blockStruct * block_
Blocks (ordinary start at 0 and go to first block)
double * getMutableElements() const
Mutable elements.
ClpPackedMatrix2 * rowCopy_
Special row copy.
void sortBlocks(const ClpSimplex *model)
Sort blocks.
double * work_
work arrays
void transposeTimesByColumn(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A in z.
ClpPackedMatrix3 & operator=(const ClpPackedMatrix3 &)
int * column_
Column indices and reverse lookup (within block)
virtual const int * getIndices() const
A vector containing the minor indices of the elements in the packed matrix.
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 int getNumCols() const
Number of columns.
void specialColumnCopy(ClpSimplex *model)
make special column copy
int numberActiveColumns() const
number of active columns (normally same as number of columns)
virtual void copy(const ClpPackedMatrix *from)
Copy contents - resizing if necessary - otherwise re-use memory.
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).
ClpPackedMatrix2 & operator=(const ClpPackedMatrix2 &)
int gutsOfTransposeTimesByRowGE3a(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.
void clearCopies()
Gets rid of special copies.
virtual int getNumRows() const
Number of rows.
virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, int column) const
Unpacks a column into an CoinIndexedvector.
Primal Column Pivot Steepest Edge Algorithm Class.
virtual CoinBigIndex getNumElements() const
Number of entries in the packed matrix.
virtual ~ClpPackedMatrix3()
Destructor.
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.
int maxBlockSize_
Maximum size of any block.
int * offset_
Column offset for each block (plus one at end)
void releaseSpecialColumnCopy()
Say we don't want special column copy.
virtual void appendCols(int number, const CoinPackedVectorBase *const *columns)
Append Columns.
virtual void transposeTimesByRow(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A in z.
bool zeros() const
Are there zeros?
virtual const int * getVectorLengths() const
The lengths of the major-dimension vectors.