6#ifndef ClpPlusMinusOneMatrix_H
7#define ClpPlusMinusOneMatrix_H
9#include "CoinPragma.hpp"
64 virtual void deleteCols(
const int numDel,
const int *indDel);
66 virtual void deleteRows(
const int numDel,
const int *indDel);
68 virtual void appendCols(
int number,
const CoinPackedVectorBase *
const *columns);
70 virtual void appendRows(
int number,
const CoinPackedVectorBase *
const *rows);
77 const CoinBigIndex *starts,
const int *index,
78 const double *element,
int numberOther = -1);
84 const int *whichColumn,
85 int &numberColumnBasic);
88 const int *whichColumn,
89 int &numberColumnBasic,
91 int *rowCount,
int *columnCount,
92 CoinFactorizationDouble *element);
102 double &smallestPositive,
double &largestPositive);
112 CoinIndexedVector *rowArray,
117 int column,
double multiplier)
const;
120 int column,
double multiplier)
const;
139 const double *x,
double *y)
const;
142 const double *x,
double *y,
143 const double *rowScale,
144 const double *columnScale)
const;
149 const double *x,
double *y)
const;
152 const double *x,
double *y,
153 const double *rowScale,
154 const double *columnScale,
double *spare = NULL)
const;
160 const CoinIndexedVector *x,
161 CoinIndexedVector *y,
162 CoinIndexedVector *z)
const;
169 const CoinIndexedVector *x,
170 CoinIndexedVector *y,
171 CoinIndexedVector *z)
const;
176 const CoinIndexedVector *x,
177 const CoinIndexedVector *y,
178 CoinIndexedVector *z)
const;
182 const CoinIndexedVector *pi)
const;
187 const CoinIndexedVector *pi1, CoinIndexedVector *dj1,
188 const CoinIndexedVector *pi2,
189 CoinIndexedVector *spare,
191 double referenceIn,
double devex,
193 unsigned int *reference,
194 double *weights,
double scaleFactor);
197 CoinIndexedVector *dj1,
198 const CoinIndexedVector *pi2, CoinIndexedVector *dj2,
199 double referenceIn,
double devex,
201 unsigned int *reference,
202 double *weights,
double scaleFactor);
240 bool columnOrdered,
const int *indices,
245 int numberRows,
const int *whichRows,
246 int numberColumns,
const int *whichColumns);
254 int numberRows,
const int *whichRows,
255 int numberColumns,
const int *whichColumns)
const;
258 bool columnOrdered,
int *indices,
264 int &bestSequence,
int &numberWanted);
284#ifdef CLP_PLUS_ONE_MATRIX
288 mutable int otherFlags_;
299#define CLP_POOL_SIZE 32 - CLP_POOL_MATRIX
300#if CLP_POOL_MATRIX == 16
303 unsigned short pool_;
307 unsigned int row_ : CLP_POOL_MATRIX;
308 unsigned short pool_ : CLP_POOL_SIZE;
324 inline int getNumDifferentElements()
const
326 return numberDifferent_;
331 return numberColumns_;
351 int *getMutableIndices()
const;
359 virtual void deleteCols(
const int numDel,
const int *indDel);
361 virtual void deleteRows(
const int numDel,
const int *indDel);
366 const int *whichColumn,
367 int &numberColumnBasic);
370 const int *whichColumn,
371 int &numberColumnBasic,
372 int *row,
int *start,
373 int *rowCount,
int *columnCount,
374 CoinFactorizationDouble *element);
378 virtual void rangeOfElements(
double &smallestNegative,
double &largestNegative,
379 double &smallestPositive,
double &largestPositive);
389 CoinIndexedVector *rowArray,
393 virtual void add(
const ClpSimplex *model, CoinIndexedVector *rowArray,
394 int column,
double multiplier)
const;
397 int column,
double multiplier)
const;
407 void checkValid(
bool detail)
const;
415 virtual void times(
double scalar,
416 const double *x,
double *y)
const;
418 virtual void times(
double scalar,
419 const double *x,
double *y,
420 const double *rowScale,
421 const double *columnScale)
const;
426 const double *x,
double *y)
const;
429 const double *x,
double *y,
430 const double *rowScale,
431 const double *columnScale,
double *spare = NULL)
const;
437 const CoinIndexedVector *x,
438 CoinIndexedVector *y,
439 CoinIndexedVector *z)
const;
445 virtual void transposeTimesByRow(
const ClpSimplex *model,
double scalar,
446 const CoinIndexedVector *x,
447 CoinIndexedVector *y,
448 CoinIndexedVector *z)
const;
453 const CoinIndexedVector *x,
454 const CoinIndexedVector *y,
455 CoinIndexedVector *z)
const;
459 const CoinIndexedVector *pi)
const
467 const CoinIndexedVector *pi1, CoinIndexedVector *dj1,
468 const CoinIndexedVector *pi2,
469 CoinIndexedVector *spare,
470 double *infeas,
double *reducedCost,
471 double referenceIn,
double devex,
473 unsigned int *reference,
474 double *weights,
double scaleFactor);
477 CoinIndexedVector *dj1,
478 const CoinIndexedVector *pi2, CoinIndexedVector *dj2,
479 double referenceIn,
double devex,
481 unsigned int *reference,
482 double *weights,
double scaleFactor);
488 inline CoinBigIndex *columnStart()
const
499 virtual ~ClpPoolMatrix();
505 ClpPoolMatrix(
const ClpPoolMatrix &);
508 ClpPoolMatrix(
const CoinPackedMatrix &);
510 ClpPoolMatrix(
int numberRows,
int numberColumns,
511 const int *indices,
const double *elements,
512 const CoinBigIndex *columnStart);
514 ClpPoolMatrix(
int numberColumns, CoinBigIndex *columnStart,
515 poolInfo *stuff,
double *elements);
518 ClpPoolMatrix(
const ClpPoolMatrix &wholeModel,
519 int numberRows,
const int *whichRows,
520 int numberColumns,
const int *whichColumns);
522 ClpPoolMatrix &operator=(
const ClpPoolMatrix &);
528 int numberRows,
const int *whichRows,
529 int numberColumns,
const int *whichColumns)
const;
531 virtual bool canDoPartialPricing()
const;
533 virtual void partialPricing(
ClpSimplex *model,
double start,
double end,
534 int &bestSequence,
int &numberWanted);
545 mutable int *lengths_;
557 int numberDifferent_;
Abstract base class for Clp Matrices.
virtual void unpackPacked(ClpSimplex *model, CoinIndexedVector *rowArray, int column) const =0
Unpacks a column into an CoinIndexedvector in packed format Note that model is NOT const.
virtual bool isColOrdered() const =0
Whether the packed matrix is column major ordered or not.
virtual const int * getIndices() const =0
A vector containing the minor indices of the elements in the packed matrix.
virtual void setDimensions(int numrows, int numcols)
Set the dimensions of the matrix.
virtual void releasePackedMatrix() const =0
Allow any parts of a created CoinPackedMatrix to be deleted.
virtual const int * getVectorLengths() const =0
The lengths of the major-dimension vectors.
virtual ClpMatrixBase * reverseOrderedCopy() const
Returns a new matrix in reverse order without gaps Is allowed to return NULL if doesn't want to have ...
virtual void add(const ClpSimplex *model, CoinIndexedVector *rowArray, int column, double multiplier) const =0
Adds multiple of a column into an CoinIndexedvector You can use quickAdd to add to vector.
virtual int getNumCols() const =0
Number of columns.
virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, int column) const =0
Unpacks a column into an CoinIndexedvector.
virtual int getNumRows() const =0
Number of rows.
double reducedCost(ClpSimplex *model, int sequence) const
Returns reduced cost of a variable.
virtual CoinPackedMatrix * getPackedMatrix() const =0
Return a complete CoinPackedMatrix.
virtual void transposeTimes(double scalar, const double *COIN_RESTRICT x, double *COIN_RESTRICT y) const =0
Return y + x * scalar * A in y.
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 (need not be coded)
int type() const
Returns type.
virtual const CoinBigIndex * getVectorStarts() const =0
virtual int countBasis(const int *whichColumn, int &numberColumnBasic)=0
Returns number of elements in column part of basis.
virtual void fillBasis(ClpSimplex *model, const int *whichColumn, int &numberColumnBasic, int *row, int *start, int *rowCount, int *columnCount, CoinFactorizationDouble *element)=0
Fills in column part of basis.
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 (need not be coded) Returns nonzero if updates...
virtual const double * getElements() const =0
A vector containing the elements in the packed matrix.
virtual void rangeOfElements(double &smallestNegative, double &largestNegative, double &smallestPositive, double &largestPositive)
Returns largest and smallest elements of both signs.
virtual void deleteRows(const int numDel, const int *indDel)=0
Delete the rows whose indices are listed in indDel.
virtual void times(double scalar, const double *COIN_RESTRICT x, double *COIN_RESTRICT y) const =0
Return y + A * x * scalar in y.
virtual bool canCombine(const ClpSimplex *, const CoinIndexedVector *) const
Returns true if can combine transposeTimes and subsetTransposeTimes and if it would be faster.
virtual CoinBigIndex getNumElements() const =0
Number of entries in the packed matrix.
virtual int getVectorLength(int index) const
The length of a single major-dimension vector.
virtual void subsetTransposeTimes(const ClpSimplex *model, const CoinIndexedVector *x, const CoinIndexedVector *y, CoinIndexedVector *z) const =0
Return x *A in z but just for indices in y.
virtual void deleteCols(const int numDel, const int *indDel)=0
Delete the columns whose indices are listed in indDel.
This implements a simple +- one matrix as derived from ClpMatrixBase.
virtual void add(const ClpSimplex *model, double *array, int column, double multiplier) const
Adds multiple of a column into an array.
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 const CoinBigIndex * getVectorStarts() const
virtual bool canDoPartialPricing() const
Says whether it can do partial pricing.
virtual int getNumCols() const
Number of columns.
virtual const int * getIndices() const
A vector containing the minor indices of the elements in the packed matrix.
virtual const int * getVectorLengths() const
The lengths of the major-dimension vectors.
virtual void times(double scalar, const double *x, double *y) const
Return y + A * scalar *x in y.
virtual void setDimensions(int numrows, int numcols)
Set the dimensions of the matrix.
int * getMutableIndices() const
virtual const double * getElements() const
A vector containing the elements in the packed matrix.
virtual void deleteCols(const int numDel, const int *indDel)
Delete the columns whose indices are listed in indDel.
virtual int countBasis(const int *whichColumn, int &numberColumnBasic)
Returns number of elements in column part of basis.
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 void deleteRows(const int numDel, const int *indDel)
Delete the rows whose indices are listed in indDel.
int numberRows_
Number of rows.
virtual void transposeTimes(double scalar, const double *x, double *y) const
Return y + x * scalar * A in y.
int *COIN_RESTRICT indices_
Data -1, then +1 rows in pairs (row==-1 if one entry)
virtual void partialPricing(ClpSimplex *model, double start, double end, int &bestSequence, int &numberWanted)
Partial pricing.
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.
ClpPlusMinusOneMatrix(const ClpPlusMinusOneMatrix &)
The copy constructor.
CoinPackedMatrix * matrix_
For fake CoinPackedMatrix.
void passInCopy(int numberRows, int numberColumns, bool columnOrdered, int *indices, CoinBigIndex *startPositive, CoinBigIndex *startNegative)
pass in copy (object takes ownership)
virtual void rangeOfElements(double &smallestNegative, double &largestNegative, double &smallestPositive, double &largestPositive)
Returns largest and smallest elements of both signs.
int numberColumns_
Number of columns.
ClpPlusMinusOneMatrix & operator=(const ClpPlusMinusOneMatrix &)
virtual void transposeTimes(double scalar, const double *x, double *y, const double *rowScale, const double *columnScale, double *spare=NULL) const
And for scaling.
CoinBigIndex * startNegative() const
Return starts of -1s.
bool columnOrdered_
True if column ordered.
virtual void appendCols(int number, const CoinPackedVectorBase *const *columns)
Append Columns.
virtual void appendRows(int number, const CoinPackedVectorBase *const *rows)
Append Rows.
void checkValid(bool detail) const
Just checks matrix valid - will say if dimensions not quite right if detail.
CoinBigIndex *COIN_RESTRICT startNegative_
Start of -1's for each.
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.
CoinBigIndex *COIN_RESTRICT startPositive_
Start of +1's for each.
virtual void releasePackedMatrix() const
Allow any parts of a created CoinMatrix to be deleted.
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 transposeTimes(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
virtual ClpMatrixBase * reverseOrderedCopy() const
Returns a new matrix in reverse order without gaps.
virtual ~ClpPlusMinusOneMatrix()
Destructor.
ClpPlusMinusOneMatrix(const CoinPackedMatrix &)
The copy constructor from an CoinPlusMinusOneMatrix.
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 unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, int column) const
Unpacks a column into an CoinIndexedvector.
ClpPlusMinusOneMatrix()
Default constructor.
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 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 int getNumRows() const
Number of rows.
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.
virtual CoinPackedMatrix * getPackedMatrix() const
Return a complete CoinPackedMatrix.
virtual void transposeTimesByRow(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
virtual void times(double scalar, const double *x, double *y, const double *rowScale, const double *columnScale) const
And for scaling.
virtual CoinBigIndex getNumElements() const
Number of entries in the packed matrix.
ClpPlusMinusOneMatrix(int numberRows, int numberColumns, bool columnOrdered, const int *indices, const CoinBigIndex *startPositive, const CoinBigIndex *startNegative)
Constructor from arrays.
virtual bool isColOrdered() const
Whether the packed matrix is column major ordered or not.
virtual ClpMatrixBase * subsetClone(int numberRows, const int *whichRows, int numberColumns, const int *whichColumns) const
Subset clone (without gaps).
CoinBigIndex * startPositive() const
Return starts of +1s.
virtual ClpMatrixBase * clone() const
Clone.
ClpPlusMinusOneMatrix(const ClpPlusMinusOneMatrix &wholeModel, int numberRows, const int *whichRows, int numberColumns, const int *whichColumns)
Subset constructor (without gaps).
This solves LPs using the simplex method.