ClpGubMatrix.hpp
Go to the documentation of this file.
1 /* $Id: ClpGubMatrix.hpp 1525 2010-02-26 17:27:59Z mjs $ */
2 // Copyright (C) 2003, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef ClpGubMatrix_H
5 #define ClpGubMatrix_H
6 
7 
8 #include "CoinPragma.hpp"
9 
10 #include "ClpPackedMatrix.hpp"
11 class ClpSimplex;
20 class ClpGubMatrix : public ClpPackedMatrix {
21 
22 public:
26  virtual ClpMatrixBase * reverseOrderedCopy() const;
28  virtual CoinBigIndex countBasis(const int * whichColumn,
29  int & numberColumnBasic);
31  virtual void fillBasis(ClpSimplex * model,
32  const int * whichColumn,
33  int & numberColumnBasic,
34  int * row, int * start,
35  int * rowCount, int * columnCount,
36  CoinFactorizationDouble * element);
39  virtual void unpack(const ClpSimplex * model, CoinIndexedVector * rowArray,
40  int column) const ;
45  virtual void unpackPacked(ClpSimplex * model,
46  CoinIndexedVector * rowArray,
47  int column) const;
50  virtual void add(const ClpSimplex * model, CoinIndexedVector * rowArray,
51  int column, double multiplier) const ;
53  virtual void add(const ClpSimplex * model, double * array,
54  int column, double multiplier) const;
56  virtual void partialPricing(ClpSimplex * model, double start, double end,
57  int & bestSequence, int & numberWanted);
59  virtual int hiddenRows() const;
61 
64 
70  virtual void transposeTimes(const ClpSimplex * model, double scalar,
71  const CoinIndexedVector * x,
72  CoinIndexedVector * y,
73  CoinIndexedVector * z) const;
79  virtual void transposeTimesByRow(const ClpSimplex * model, double scalar,
80  const CoinIndexedVector * x,
81  CoinIndexedVector * y,
82  CoinIndexedVector * z) const;
86  virtual void subsetTransposeTimes(const ClpSimplex * model,
87  const CoinIndexedVector * x,
88  const CoinIndexedVector * y,
89  CoinIndexedVector * z) const;
96  virtual int extendUpdated(ClpSimplex * model, CoinIndexedVector * update, int mode);
102  virtual void primalExpanded(ClpSimplex * model, int mode);
111  virtual void dualExpanded(ClpSimplex * model, CoinIndexedVector * array,
112  double * other, int mode);
130  virtual int generalExpanded(ClpSimplex * model, int mode, int & number);
134  virtual int updatePivot(ClpSimplex * model, double oldInValue, double oldOutValue);
136  virtual void useEffectiveRhs(ClpSimplex * model, bool cheapest = true);
140  virtual double * rhsOffset(ClpSimplex * model, bool forceRefresh = false,
141  bool check = false);
154  virtual int synchronize(ClpSimplex * model, int mode);
156  virtual void correctSequence(const ClpSimplex * model, int & sequenceIn, int & sequenceOut) ;
158 
159 
160 
164  ClpGubMatrix();
166  virtual ~ClpGubMatrix();
168 
172  ClpGubMatrix(const ClpGubMatrix&);
174  ClpGubMatrix(const CoinPackedMatrix&);
177  ClpGubMatrix (const ClpGubMatrix & wholeModel,
178  int numberRows, const int * whichRows,
179  int numberColumns, const int * whichColumns);
180  ClpGubMatrix (const CoinPackedMatrix & wholeModel,
181  int numberRows, const int * whichRows,
182  int numberColumns, const int * whichColumns);
183 
185  ClpGubMatrix(CoinPackedMatrix * matrix);
186 
190  const int * start, const int * end,
191  const double * lower, const double * upper,
192  const unsigned char * status = NULL);
193 
196  virtual ClpMatrixBase * clone() const ;
199  virtual ClpMatrixBase * subsetClone (
200  int numberRows, const int * whichRows,
201  int numberColumns, const int * whichColumns) const ;
203  void redoSet(ClpSimplex * model, int newKey, int oldKey, int iSet);
205 
207  inline ClpSimplex::Status getStatus(int sequence) const {
209  return static_cast<ClpSimplex::Status> (status_[sequence] & 7);
210  }
211  inline void setStatus(int sequence, ClpSimplex::Status status) {
212  unsigned char & st_byte = status_[sequence];
213  st_byte = static_cast<unsigned char>(st_byte & ~7);
214  st_byte = static_cast<unsigned char>(st_byte | status);
215  }
217  inline void setFlagged( int sequence) {
218  status_[sequence] = static_cast<unsigned char>(status_[sequence] | 64);
219  }
220  inline void clearFlagged( int sequence) {
221  status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64);
222  }
223  inline bool flagged(int sequence) const {
224  return ((status_[sequence] & 64) != 0);
225  }
227  inline void setAbove( int sequence) {
228  unsigned char iStat = status_[sequence];
229  iStat = static_cast<unsigned char>(iStat & ~24);
230  status_[sequence] = static_cast<unsigned char>(iStat | 16);
231  }
233  inline void setFeasible( int sequence) {
234  unsigned char iStat = status_[sequence];
235  iStat = static_cast<unsigned char>(iStat & ~24);
236  status_[sequence] = static_cast<unsigned char>(iStat | 8);
237  }
239  inline void setBelow( int sequence) {
240  unsigned char iStat = status_[sequence];
241  iStat = static_cast<unsigned char>(iStat & ~24);
242  status_[sequence] = iStat;
243  }
244  inline double weight( int sequence) const {
245  int iStat = status_[sequence] & 31;
246  iStat = iStat >> 3;
247  return static_cast<double> (iStat - 1);
248  }
250  inline int * start() const {
251  return start_;
252  }
254  inline int * end() const {
255  return end_;
256  }
258  inline double * lower() const {
259  return lower_;
260  }
262  inline double * upper() const {
263  return upper_;
264  }
266  inline int * keyVariable() const {
267  return keyVariable_;
268  }
270  inline int * backward() const {
271  return backward_;
272  }
274  inline int numberSets() const {
275  return numberSets_;
276  }
278  void switchOffCheck();
280 
281 
282 protected:
297  int * start_;
299  int * end_;
301  double * lower_;
303  double * upper_;
305  mutable unsigned char * status_;
307  unsigned char * saveStatus_;
311  int * backward_;
315  double * changeCost_;
317  mutable int * keyVariable_;
321  mutable int * next_;
323  int * toIndex_;
324  // Reverse pointer from index to set
325  int * fromIndex_;
337  int noCheck_;
349  int lastGub_;
352  int gubType_;
354 };
355 
356 #endif
bool flagged(int sequence) const
Status.
virtual CoinBigIndex countBasis(const int *whichColumn, int &numberColumnBasic)
Returns number of elements in column part of basis.
double sumOfRelaxedPrimalInfeasibilities_
Sum of Primal infeasibilities using tolerance based on error in primals.
int numberDualInfeasibilities_
Number of dual infeasibilities.
int gubSlackIn_
Gub slack in (set number or -1)
ClpSimplex * model_
Pointer back to model.
void redoSet(ClpSimplex *model, int newKey, int oldKey, int iSet)
redoes next_ for a set.
This implements Gub rows plus a ClpPackedMatrix.
double sumDualInfeasibilities_
Sum of dual infeasibilities.
ClpSimplex::Status getStatus(int sequence) const
Status.
virtual double * rhsOffset(ClpSimplex *model, bool forceRefresh=false, bool check=false)
Returns effective RHS offset if it is being used.
int noCheck_
If pricing will declare victory (i.e.
double * lower_
Lower bounds on sets.
ClpGubMatrix()
Default constructor.
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...
int * fromIndex_
Sum of dual infeasibilities.
void setAbove(int sequence)
To say key is above ub.
double sumPrimalInfeasibilities_
Sum of primal infeasibilities.
unsigned char * saveStatus_
Saved status of slacks.
virtual void primalExpanded(ClpSimplex *model, int mode)
mode=0 - Set up before "update" and "times" for primal solution using extended rows mode=1 - Cleanup ...
int * backward_
Backward pointer to set number.
int lastGub_
last gub variable (same as end_[numberSets_-1] at present)
int * end() const
End.
int possiblePivotKey_
Pivot row of possible next key.
CoinPackedMatrix * matrix() const
Returns CoinPackedMatrix (non const)
int * start() const
Starts.
double * upper() const
Upper bounds on sets.
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 ...
void setFlagged(int sequence)
To flag a variable.
virtual void transposeTimesByRow(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
void setFeasible(int sequence)
To say key is feasible.
int saveNumber_
Number in vector without gub extension.
void switchOffCheck()
Switches off dj checking each factorization (for BIG models)
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 numberSets() const
Number of sets (gub rows)
virtual void correctSequence(const ClpSimplex *model, int &sequenceIn, int &sequenceOut)
Correct sequence in and out to give true value.
virtual void useEffectiveRhs(ClpSimplex *model, bool cheapest=true)
Sets up an effective RHS and does gub crash if needed.
void clearFlagged(int sequence)
Status.
int * keyVariable_
Key variable of set.
Status
enums for status of various sorts.
Definition: ClpSimplex.hpp:57
virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray, int column) const
Unpacks a column into an CoinIndexedvector.
virtual ClpMatrixBase * reverseOrderedCopy() const
Returns a new matrix in reverse order without gaps (GUB wants NULL)
virtual ClpMatrixBase * clone() const
Clone.
void setBelow(int sequence)
To say key is below lb.
virtual void transposeTimes(double scalar, const double *x, double *y) const
Return y + x * scalar * A in y.
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=...
int * backward() const
Backward pointer to set number.
double * changeCost_
Change in costs for keys.
double * upper_
Upper bounds on sets.
int numberSets_
Number of sets (gub rows)
int firstGub_
First gub variables (same as start_[0] at present)
virtual int updatePivot(ClpSimplex *model, double oldInValue, double oldOutValue)
update information for a pivot (and effective rhs)
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:49
virtual void transposeTimes(const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const
Return x * scalar * A + y in z.
void setStatus(int sequence, ClpSimplex::Status status)
Status.
unsigned char * status_
Status of slacks.
int * backToPivotRow_
Backward pointer to pivot row !!!
Abstract base class for Clp Matrices.
virtual void partialPricing(ClpSimplex *model, double start, double end, int &bestSequence, int &numberWanted)
Partial pricing.
int * next_
Next basic variable in set - starts at key and end with -(set+1).
virtual ~ClpGubMatrix()
Destructor.
int * start_
Starts.
int * toIndex_
Backward pointer to index in CoinIndexedVector.
virtual int hiddenRows() const
Returns number of hidden rows e.g. gub.
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.
int * keyVariable() const
Key variable of set.
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...
int * end_
End.
double weight(int sequence) const
Status.
virtual ClpMatrixBase * subsetClone(int numberRows, const int *whichRows, int numberColumns, const int *whichColumns) const
Subset clone (without gaps).
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 & operator=(const ClpGubMatrix &)
The copy constructor.
double infeasibilityWeight_
Infeasibility weight when last full pass done.
double * lower() const
Lower bounds on sets.
int gubType_
type of gub - 0 not contiguous, 1 contiguous add 8 bit to say no ubs on individual variables ...
int * savedKeyVariable_
Saved key variables.
int numberPrimalInfeasibilities_
Number of primal infeasibilities.
double sumOfRelaxedDualInfeasibilities_
Sum of Dual infeasibilities using tolerance based on error in duals.
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.