Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ClpPrimalColumnSteepest.hpp
Go to the documentation of this file.
1 /* $Id: ClpPrimalColumnSteepest.hpp 1665 2011-01-04 17:55:54Z lou $ */
2 // Copyright (C) 2002, 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 ClpPrimalColumnSteepest_H
7 #define ClpPrimalColumnSteepest_H
8 
10 #include <bitset>
11 
12 //#############################################################################
13 class CoinIndexedVector;
14 
15 
24 
25 public:
26 
28 
29 
37  virtual int pivotColumn(CoinIndexedVector * updates,
38  CoinIndexedVector * spareRow1,
39  CoinIndexedVector * spareRow2,
40  CoinIndexedVector * spareColumn1,
41  CoinIndexedVector * spareColumn2);
44  CoinIndexedVector * spareRow1,
45  CoinIndexedVector * spareRow2,
46  CoinIndexedVector * spareColumn1,
47  CoinIndexedVector * spareColumn2);
49  void justDjs(CoinIndexedVector * updates,
50  CoinIndexedVector * spareRow2,
51  CoinIndexedVector * spareColumn1,
52  CoinIndexedVector * spareColumn2);
54  int partialPricing(CoinIndexedVector * updates,
55  CoinIndexedVector * spareRow2,
56  int numberWanted,
57  int numberLook);
59  void djsAndDevex(CoinIndexedVector * updates,
60  CoinIndexedVector * spareRow2,
61  CoinIndexedVector * spareColumn1,
62  CoinIndexedVector * spareColumn2);
64  void djsAndSteepest(CoinIndexedVector * updates,
65  CoinIndexedVector * spareRow2,
66  CoinIndexedVector * spareColumn1,
67  CoinIndexedVector * spareColumn2);
69  void djsAndDevex2(CoinIndexedVector * updates,
70  CoinIndexedVector * spareRow2,
71  CoinIndexedVector * spareColumn1,
72  CoinIndexedVector * spareColumn2);
74  void djsAndSteepest2(CoinIndexedVector * updates,
75  CoinIndexedVector * spareRow2,
76  CoinIndexedVector * spareColumn1,
77  CoinIndexedVector * spareColumn2);
79  void justDevex(CoinIndexedVector * updates,
80  CoinIndexedVector * spareRow2,
81  CoinIndexedVector * spareColumn1,
82  CoinIndexedVector * spareColumn2);
84  void justSteepest(CoinIndexedVector * updates,
85  CoinIndexedVector * spareRow2,
86  CoinIndexedVector * spareColumn1,
87  CoinIndexedVector * spareColumn2);
89  void transposeTimes2(const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
90  const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
91  CoinIndexedVector * spare, double scaleFactor);
92 
94  virtual void updateWeights(CoinIndexedVector * input);
95 
97  void checkAccuracy(int sequence, double relativeTolerance,
98  CoinIndexedVector * rowArray1,
99  CoinIndexedVector * rowArray2);
100 
102  void initializeWeights();
103 
112  virtual void saveWeights(ClpSimplex * model, int mode);
114  virtual void unrollWeights();
116  virtual void clearArrays();
118  virtual bool looksOptimal() const;
120  virtual void maximumPivotsChanged();
122 
125  inline int mode() const {
127  return mode_;
128  }
132  virtual int numberSprintColumns(int & numberIterations) const;
134  virtual void switchOffSprint();
135 
137 
140  enum Persistence {
141  normal = 0x00, // create (if necessary) and destroy
142  keep = 0x01 // create (if necessary) and leave
143  };
144 
146 
147 
155  ClpPrimalColumnSteepest(int mode = 3);
156 
159 
162 
164  virtual ~ClpPrimalColumnSteepest ();
165 
167  virtual ClpPrimalColumnPivot * clone(bool copyData = true) const;
168 
170 
172 
175  inline bool reference(int i) const {
176  return ((reference_[i>>5] >> (i & 31)) & 1) != 0;
177  }
178  inline void setReference(int i, bool trueFalse) {
179  unsigned int & value = reference_[i>>5];
180  int bit = i & 31;
181  if (trueFalse)
182  value |= (1 << bit);
183  else
184  value &= ~(1 << bit);
185  }
187  inline void setPersistence(Persistence life) {
188  persistence_ = life;
189  }
190  inline Persistence persistence() const {
191  return persistence_ ;
192  }
193 
195  //---------------------------------------------------------------------------
196 
197 private:
199  // Update weight
200  double devex_;
202  double * weights_;
208  double * savedWeights_;
209  // Array for exact devex to say what is in reference framework
210  unsigned int * reference_;
216  int state_;
229  int mode_;
234  // This is pivot row (or pivot sequence round re-factorization)
236  // This is saved pivot sequence
238  // This is saved outgoing variable
240  // Iteration when last rectified
242  // Size of factorization at invert (used to decide algorithm)
245 };
246 
247 #endif
virtual bool looksOptimal() const
Returns true if would not find any column.
void djsAndDevex(CoinIndexedVector *updates, CoinIndexedVector *spareRow2, CoinIndexedVector *spareColumn1, CoinIndexedVector *spareColumn2)
Update djs, weights for Devex using djs.
virtual void saveWeights(ClpSimplex *model, int mode)
Save weights - this may initialize weights as well mode is - 1) before factorization 2) after factori...
int mode_
0 is exact devex, 1 full steepest, 2 is partial exact devex 3 switches between 0 and 2 depending on f...
Primal Column Pivot Abstract Base Class.
int partialPricing(CoinIndexedVector *updates, CoinIndexedVector *spareRow2, int numberWanted, int numberLook)
Update djs doing partial pricing (dantzig)
void justSteepest(CoinIndexedVector *updates, CoinIndexedVector *spareRow2, CoinIndexedVector *spareColumn1, CoinIndexedVector *spareColumn2)
Update weights for Steepest.
double * savedWeights_
save weight array (so we can use checkpoint)
void djsAndDevex2(CoinIndexedVector *updates, CoinIndexedVector *spareRow2, CoinIndexedVector *spareColumn1, CoinIndexedVector *spareColumn2)
Update djs, weights for Devex using pivot row.
Primal Column Pivot Steepest Edge Algorithm Class.
void initializeWeights()
Initialize weights.
CoinIndexedVector * infeasible_
square of infeasibility array (just for infeasible columns)
void setPersistence(Persistence life)
Set/ get persistence.
virtual ClpPrimalColumnPivot * clone(bool copyData=true) const
Clone.
void checkAccuracy(int sequence, double relativeTolerance, CoinIndexedVector *rowArray1, CoinIndexedVector *rowArray2)
Checks accuracy - just for debug.
bool reference(int i) const
reference would be faster using ClpSimplex&#39;s status_, but I prefer to keep modularity.
void justDjs(CoinIndexedVector *updates, CoinIndexedVector *spareRow2, CoinIndexedVector *spareColumn1, CoinIndexedVector *spareColumn2)
Just update djs.
int pivotColumnOldMethod(CoinIndexedVector *updates, CoinIndexedVector *spareRow1, CoinIndexedVector *spareRow2, CoinIndexedVector *spareColumn1, CoinIndexedVector *spareColumn2)
For quadratic or funny nonlinearities.
virtual int numberSprintColumns(int &numberIterations) const
Returns number of extra columns for sprint algorithm - 0 means off.
virtual void switchOffSprint()
Switch off sprint idea.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:70
Indexed Vector.
void djsAndSteepest2(CoinIndexedVector *updates, CoinIndexedVector *spareRow2, CoinIndexedVector *spareColumn1, CoinIndexedVector *spareColumn2)
Update djs, weights for Steepest using pivot row.
ClpPrimalColumnSteepest & operator=(const ClpPrimalColumnSteepest &rhs)
Assignment operator.
void justDevex(CoinIndexedVector *updates, CoinIndexedVector *spareRow2, CoinIndexedVector *spareColumn1, CoinIndexedVector *spareColumn2)
Update weights for Devex.
virtual void clearArrays()
Gets rid of all arrays.
ClpSimplex * model()
Returns model.
virtual void unrollWeights()
Gets rid of last update.
virtual void updateWeights(CoinIndexedVector *input)
Updates weights - part 1 - also checks accuracy.
void transposeTimes2(const CoinIndexedVector *pi1, CoinIndexedVector *dj1, const CoinIndexedVector *pi2, CoinIndexedVector *dj2, CoinIndexedVector *spare, double scaleFactor)
Updates two arrays for steepest.
Persistence persistence_
Life of weights.
void setReference(int i, bool trueFalse)
CoinIndexedVector * alternateWeights_
alternate weight array (so we can unroll)
Persistence
enums for persistence
virtual void maximumPivotsChanged()
Called when maximum pivots changes.
int state_
Status 0) Normal -1) Needs initialization 1) Weights are stored by sequence number.
void djsAndSteepest(CoinIndexedVector *updates, CoinIndexedVector *spareRow2, CoinIndexedVector *spareColumn1, CoinIndexedVector *spareColumn2)
Update djs, weights for Steepest using djs.
ClpPrimalColumnSteepest(int mode=3)
Default Constructor 0 is exact devex, 1 full steepest, 2 is partial exact devex 3 switches between 0 ...
virtual ~ClpPrimalColumnSteepest()
Destructor.
int numberSwitched_
Number of times switched from partial dantzig to 0/2.
virtual int pivotColumn(CoinIndexedVector *updates, CoinIndexedVector *spareRow1, CoinIndexedVector *spareRow2, CoinIndexedVector *spareColumn1, CoinIndexedVector *spareColumn2)
Returns pivot column, -1 if none.