Clp  1.17.8
ClpGubMatrix.hpp
Go to the documentation of this file.
1 /* $Id$ */
2 // Copyright (C) 2003, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef ClpGubMatrix_H
7 #define ClpGubMatrix_H
8 
9 #include "CoinPragma.hpp"
10 
11 #include "ClpPackedMatrix.hpp"
12 class ClpSimplex;
21 class ClpGubMatrix : public ClpPackedMatrix {
22 
23 public:
27  virtual ClpMatrixBase *reverseOrderedCopy() const;
29  virtual int countBasis(const int *whichColumn,
30  int &numberColumnBasic);
32  virtual void fillBasis(ClpSimplex *model,
33  const int *whichColumn,
34  int &numberColumnBasic,
35  int *row, int *start,
36  int *rowCount, int *columnCount,
37  CoinFactorizationDouble *element);
40  virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray,
41  int column) const;
46  virtual void unpackPacked(ClpSimplex *model,
47  CoinIndexedVector *rowArray,
48  int column) const;
51  virtual void add(const ClpSimplex *model, CoinIndexedVector *rowArray,
52  int column, double multiplier) const;
54  virtual void add(const ClpSimplex *model, double *array,
55  int column, double multiplier) const;
57  virtual void partialPricing(ClpSimplex *model, double start, double end,
58  int &bestSequence, int &numberWanted);
60  virtual int hiddenRows() const;
62 
65 
71  virtual void transposeTimes(const ClpSimplex *model, double scalar,
72  const CoinIndexedVector *x,
73  CoinIndexedVector *y,
74  CoinIndexedVector *z) const;
80  virtual void transposeTimesByRow(const ClpSimplex *model, double scalar,
81  const CoinIndexedVector *x,
82  CoinIndexedVector *y,
83  CoinIndexedVector *z) const;
87  virtual void subsetTransposeTimes(const ClpSimplex *model,
88  const CoinIndexedVector *x,
89  const CoinIndexedVector *y,
90  CoinIndexedVector *z) const;
97  virtual int extendUpdated(ClpSimplex *model, CoinIndexedVector *update, int mode);
103  virtual void primalExpanded(ClpSimplex *model, int mode);
112  virtual void dualExpanded(ClpSimplex *model, CoinIndexedVector *array,
113  double *other, int mode);
131  virtual int generalExpanded(ClpSimplex *model, int mode, int &number);
135  virtual int updatePivot(ClpSimplex *model, double oldInValue, double oldOutValue);
137  virtual void useEffectiveRhs(ClpSimplex *model, bool cheapest = true);
141  virtual double *rhsOffset(ClpSimplex *model, bool forceRefresh = false,
142  bool check = false);
155  virtual int synchronize(ClpSimplex *model, int mode);
157  virtual void correctSequence(const ClpSimplex *model, int &sequenceIn, int &sequenceOut);
159 
163  ClpGubMatrix();
165  virtual ~ClpGubMatrix();
167 
171  ClpGubMatrix(const ClpGubMatrix &);
173  ClpGubMatrix(const CoinPackedMatrix &);
176  ClpGubMatrix(const ClpGubMatrix &wholeModel,
177  int numberRows, const int *whichRows,
178  int numberColumns, const int *whichColumns);
179  ClpGubMatrix(const CoinPackedMatrix &wholeModel,
180  int numberRows, const int *whichRows,
181  int numberColumns, const int *whichColumns);
182 
184  ClpGubMatrix(CoinPackedMatrix *matrix);
185 
189  const int *start, const int *end,
190  const double *lower, const double *upper,
191  const unsigned char *status = NULL);
192 
195  virtual ClpMatrixBase *clone() const;
198  virtual ClpMatrixBase *subsetClone(
199  int numberRows, const int *whichRows,
200  int numberColumns, const int *whichColumns) const;
202  void redoSet(ClpSimplex *model, int newKey, int oldKey, int iSet);
204 
206  inline ClpSimplex::Status getStatus(int sequence) const
208  {
209  return static_cast< ClpSimplex::Status >(status_[sequence] & 7);
210  }
211  inline void setStatus(int sequence, ClpSimplex::Status status)
212  {
213  unsigned char &st_byte = status_[sequence];
214  st_byte = static_cast< unsigned char >(st_byte & ~7);
215  st_byte = static_cast< unsigned char >(st_byte | status);
216  }
218  inline void setFlagged(int sequence)
219  {
220  status_[sequence] = static_cast< unsigned char >(status_[sequence] | 64);
221  }
222  inline void clearFlagged(int sequence)
223  {
224  status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~64);
225  }
226  inline bool flagged(int sequence) const
227  {
228  return ((status_[sequence] & 64) != 0);
229  }
231  inline void setAbove(int sequence)
232  {
233  unsigned char iStat = status_[sequence];
234  iStat = static_cast< unsigned char >(iStat & ~24);
235  status_[sequence] = static_cast< unsigned char >(iStat | 16);
236  }
238  inline void setFeasible(int sequence)
239  {
240  unsigned char iStat = status_[sequence];
241  iStat = static_cast< unsigned char >(iStat & ~24);
242  status_[sequence] = static_cast< unsigned char >(iStat | 8);
243  }
245  inline void setBelow(int sequence)
246  {
247  unsigned char iStat = status_[sequence];
248  iStat = static_cast< unsigned char >(iStat & ~24);
249  status_[sequence] = iStat;
250  }
251  inline double weight(int sequence) const
252  {
253  int iStat = status_[sequence] & 31;
254  iStat = iStat >> 3;
255  return static_cast< double >(iStat - 1);
256  }
258  inline int *start() const
259  {
260  return start_;
261  }
263  inline int *end() const
264  {
265  return end_;
266  }
268  inline double *lower() const
269  {
270  return lower_;
271  }
273  inline double *upper() const
274  {
275  return upper_;
276  }
278  inline int *keyVariable() const
279  {
280  return keyVariable_;
281  }
283  inline int *backward() const
284  {
285  return backward_;
286  }
288  inline int numberSets() const
289  {
290  return numberSets_;
291  }
293  void switchOffCheck();
295 
296 protected:
311  int *start_;
313  int *end_;
315  double *lower_;
317  double *upper_;
319  mutable unsigned char *status_;
321  unsigned char *saveStatus_;
325  int *backward_;
329  double *changeCost_;
331  mutable int *keyVariable_;
335  mutable int *next_;
337  int *toIndex_;
338  // Reverse pointer from index to set
351  int noCheck_;
363  int lastGub_;
366  int gubType_;
368 };
369 
370 #endif
371 
372 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
373 */
ClpSimplex
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:106
ClpGubMatrix::status_
unsigned char * status_
Status of slacks.
Definition: ClpGubMatrix.hpp:319
ClpPackedMatrix::transposeTimes
virtual void transposeTimes(double scalar, const double *x, double *y) const
Return y + x * scalar * A in y.
ClpGubMatrix::fillBasis
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.
ClpGubMatrix::subsetClone
virtual ClpMatrixBase * subsetClone(int numberRows, const int *whichRows, int numberColumns, const int *whichColumns) const
Subset clone (without gaps).
ClpGubMatrix::saveNumber_
int saveNumber_
Number in vector without gub extension.
Definition: ClpGubMatrix.hpp:355
ClpGubMatrix::keyVariable_
int * keyVariable_
Key variable of set.
Definition: ClpGubMatrix.hpp:331
ClpGubMatrix::setFeasible
void setFeasible(int sequence)
To say key is feasible.
Definition: ClpGubMatrix.hpp:238
ClpGubMatrix::getStatus
ClpSimplex::Status getStatus(int sequence) const
Status.
Definition: ClpGubMatrix.hpp:207
ClpGubMatrix::clone
virtual ClpMatrixBase * clone() const
Clone.
ClpGubMatrix::backward_
int * backward_
Backward pointer to set number.
Definition: ClpGubMatrix.hpp:325
ClpGubMatrix::sumPrimalInfeasibilities_
double sumPrimalInfeasibilities_
Sum of primal infeasibilities.
Definition: ClpGubMatrix.hpp:303
ClpGubMatrix::ClpGubMatrix
ClpGubMatrix()
Default constructor.
ClpGubMatrix
This implements Gub rows plus a ClpPackedMatrix.
Definition: ClpGubMatrix.hpp:21
ClpGubMatrix::hiddenRows
virtual int hiddenRows() const
Returns number of hidden rows e.g. gub.
ClpGubMatrix::sumDualInfeasibilities_
double sumDualInfeasibilities_
Sum of dual infeasibilities.
Definition: ClpGubMatrix.hpp:301
ClpGubMatrix::subsetTransposeTimes
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.
ClpGubMatrix::weight
double weight(int sequence) const
Definition: ClpGubMatrix.hpp:251
ClpGubMatrix::model_
ClpSimplex * model_
Pointer back to model.
Definition: ClpGubMatrix.hpp:341
ClpGubMatrix::next_
int * next_
Next basic variable in set - starts at key and end with -(set+1).
Definition: ClpGubMatrix.hpp:335
ClpGubMatrix::add
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.
ClpGubMatrix::reverseOrderedCopy
virtual ClpMatrixBase * reverseOrderedCopy() const
Returns a new matrix in reverse order without gaps (GUB wants NULL)
ClpGubMatrix::backward
int * backward() const
Backward pointer to set number.
Definition: ClpGubMatrix.hpp:283
ClpGubMatrix::operator=
ClpGubMatrix & operator=(const ClpGubMatrix &)
ClpGubMatrix::clearFlagged
void clearFlagged(int sequence)
Definition: ClpGubMatrix.hpp:222
ClpGubMatrix::start
int * start() const
Starts.
Definition: ClpGubMatrix.hpp:258
ClpGubMatrix::lower
double * lower() const
Lower bounds on sets.
Definition: ClpGubMatrix.hpp:268
ClpGubMatrix::countBasis
virtual int countBasis(const int *whichColumn, int &numberColumnBasic)
Returns number of elements in column part of basis.
ClpPackedMatrix
Definition: ClpPackedMatrix.hpp:23
ClpGubMatrix::numberPrimalInfeasibilities_
int numberPrimalInfeasibilities_
Number of primal infeasibilities.
Definition: ClpGubMatrix.hpp:345
ClpGubMatrix::gubSlackIn_
int gubSlackIn_
Gub slack in (set number or -1)
Definition: ClpGubMatrix.hpp:359
ClpGubMatrix::primalExpanded
virtual void primalExpanded(ClpSimplex *model, int mode)
mode=0 - Set up before "update" and "times" for primal solution using extended rows mode=1 - Cleanup ...
ClpGubMatrix::firstGub_
int firstGub_
First gub variables (same as start_[0] at present)
Definition: ClpGubMatrix.hpp:361
ClpGubMatrix::setAbove
void setAbove(int sequence)
To say key is above ub.
Definition: ClpGubMatrix.hpp:231
ClpGubMatrix::unpackPacked
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.
ClpGubMatrix::toIndex_
int * toIndex_
Backward pointer to index in CoinIndexedVector.
Definition: ClpGubMatrix.hpp:337
ClpPackedMatrix::matrix
CoinPackedMatrix * matrix() const
Returns CoinPackedMatrix (non const)
Definition: ClpPackedMatrix.hpp:314
ClpMatrixBase
Abstract base class for Clp Matrices.
Definition: ClpMatrixBase.hpp:38
ClpGubMatrix::setBelow
void setBelow(int sequence)
To say key is below lb.
Definition: ClpGubMatrix.hpp:245
ClpGubMatrix::start_
int * start_
Starts.
Definition: ClpGubMatrix.hpp:311
ClpGubMatrix::unpack
virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, int column) const
Unpacks a column into an CoinIndexedvector.
ClpGubMatrix::synchronize
virtual int synchronize(ClpSimplex *model, int mode)
This is local to Gub to allow synchronization: mode=0 when status of basis is good mode=1 when variab...
ClpGubMatrix::partialPricing
virtual void partialPricing(ClpSimplex *model, double start, double end, int &bestSequence, int &numberWanted)
Partial pricing.
ClpGubMatrix::correctSequence
virtual void correctSequence(const ClpSimplex *model, int &sequenceIn, int &sequenceOut)
Correct sequence in and out to give true value.
ClpGubMatrix::numberDualInfeasibilities_
int numberDualInfeasibilities_
Number of dual infeasibilities.
Definition: ClpGubMatrix.hpp:343
ClpGubMatrix::transposeTimes
virtual void transposeTimes(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
ClpGubMatrix::extendUpdated
virtual int extendUpdated(ClpSimplex *model, CoinIndexedVector *update, int mode)
expands an updated column to allow for extra rows which the main solver does not know about and retur...
ClpGubMatrix::useEffectiveRhs
virtual void useEffectiveRhs(ClpSimplex *model, bool cheapest=true)
Sets up an effective RHS and does gub crash if needed.
ClpGubMatrix::switchOffCheck
void switchOffCheck()
Switches off dj checking each factorization (for BIG models)
ClpGubMatrix::lower_
double * lower_
Lower bounds on sets.
Definition: ClpGubMatrix.hpp:315
ClpGubMatrix::rhsOffset
virtual double * rhsOffset(ClpSimplex *model, bool forceRefresh=false, bool check=false)
Returns effective RHS offset if it is being used.
ClpGubMatrix::infeasibilityWeight_
double infeasibilityWeight_
Infeasibility weight when last full pass done.
Definition: ClpGubMatrix.hpp:309
ClpGubMatrix::upper
double * upper() const
Upper bounds on sets.
Definition: ClpGubMatrix.hpp:273
ClpGubMatrix::numberSets_
int numberSets_
Number of sets (gub rows)
Definition: ClpGubMatrix.hpp:353
ClpGubMatrix::gubType_
int gubType_
type of gub - 0 not contiguous, 1 contiguous add 8 bit to say no ubs on individual variables
Definition: ClpGubMatrix.hpp:366
ClpGubMatrix::~ClpGubMatrix
virtual ~ClpGubMatrix()
Destructor.
ClpGubMatrix::sumOfRelaxedDualInfeasibilities_
double sumOfRelaxedDualInfeasibilities_
Sum of Dual infeasibilities using tolerance based on error in duals.
Definition: ClpGubMatrix.hpp:305
ClpGubMatrix::keyVariable
int * keyVariable() const
Key variable of set.
Definition: ClpGubMatrix.hpp:278
ClpGubMatrix::redoSet
void redoSet(ClpSimplex *model, int newKey, int oldKey, int iSet)
redoes next_ for a set.
ClpGubMatrix::numberSets
int numberSets() const
Number of sets (gub rows)
Definition: ClpGubMatrix.hpp:288
ClpGubMatrix::backToPivotRow_
int * backToPivotRow_
Backward pointer to pivot row !!!
Definition: ClpGubMatrix.hpp:327
ClpGubMatrix::noCheck_
int noCheck_
If pricing will declare victory (i.e.
Definition: ClpGubMatrix.hpp:351
ClpGubMatrix::end
int * end() const
End.
Definition: ClpGubMatrix.hpp:263
ClpGubMatrix::fromIndex_
int * fromIndex_
Definition: ClpGubMatrix.hpp:339
ClpPackedMatrix.hpp
ClpGubMatrix::setFlagged
void setFlagged(int sequence)
To flag a variable.
Definition: ClpGubMatrix.hpp:218
ClpGubMatrix::flagged
bool flagged(int sequence) const
Definition: ClpGubMatrix.hpp:226
ClpGubMatrix::savedKeyVariable_
int * savedKeyVariable_
Saved key variables.
Definition: ClpGubMatrix.hpp:323
ClpGubMatrix::saveStatus_
unsigned char * saveStatus_
Saved status of slacks.
Definition: ClpGubMatrix.hpp:321
ClpGubMatrix::end_
int * end_
End.
Definition: ClpGubMatrix.hpp:313
ClpGubMatrix::generalExpanded
virtual int generalExpanded(ClpSimplex *model, int mode, int &number)
mode=0 - Create list of non-key basics in pivotVariable_ using number as numberBasic in and out mode=...
ClpGubMatrix::lastGub_
int lastGub_
last gub variable (same as end_[numberSets_-1] at present)
Definition: ClpGubMatrix.hpp:363
ClpGubMatrix::updatePivot
virtual int updatePivot(ClpSimplex *model, double oldInValue, double oldOutValue)
update information for a pivot (and effective rhs)
ClpGubMatrix::sumOfRelaxedPrimalInfeasibilities_
double sumOfRelaxedPrimalInfeasibilities_
Sum of Primal infeasibilities using tolerance based on error in primals.
Definition: ClpGubMatrix.hpp:307
ClpGubMatrix::upper_
double * upper_
Upper bounds on sets.
Definition: ClpGubMatrix.hpp:317
ClpGubMatrix::possiblePivotKey_
int possiblePivotKey_
Pivot row of possible next key.
Definition: ClpGubMatrix.hpp:357
ClpGubMatrix::changeCost_
double * changeCost_
Change in costs for keys.
Definition: ClpGubMatrix.hpp:329
ClpGubMatrix::setStatus
void setStatus(int sequence, ClpSimplex::Status status)
Definition: ClpGubMatrix.hpp:211
ClpSimplex::Status
Status
enums for status of various sorts.
Definition: ClpSimplex.hpp:114
ClpGubMatrix::transposeTimesByRow
virtual void transposeTimesByRow(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
ClpGubMatrix::dualExpanded
virtual void dualExpanded(ClpSimplex *model, CoinIndexedVector *array, double *other, int mode)
mode=0 - Set up before "updateTranspose" and "transposeTimes" for duals using extended updates array ...