Changeset 2385 for trunk/Clp/src/AbcPrimalColumnSteepest.hpp
 Timestamp:
 Jan 6, 2019 2:43:06 PM (19 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/AbcPrimalColumnSteepest.hpp
r1910 r2385 13 13 class CoinIndexedVector; 14 14 15 16 15 /** Primal Column Pivot Steepest Edge Algorithm Class 17 16 … … 20 19 */ 21 20 22 23 21 class AbcPrimalColumnSteepest : public AbcPrimalColumnPivot { 24 22 25 23 public: 26 27 ///@name Algorithmic methods 28 //@{ 29 30 /** Returns pivot column, 1 if none. 24 ///@name Algorithmic methods 25 //@{ 26 27 /** Returns pivot column, 1 if none. 31 28 The Packed CoinIndexedVector updates has cost updates  for normal LP 32 29 that is just +weight where a feasibility changed. It also has … … 35 32 profiling and speed 36 33 */ 37 virtual int pivotColumn(CoinPartitionedVector *updates,38 CoinPartitionedVector *spareRow2,39 CoinPartitionedVector *spareColumn1);40 41 void justDjs(CoinIndexedVector *updates,42 CoinIndexedVector *spareColumn1);43 44 int partialPricing(CoinIndexedVector *updates,45 46 47 48 void djsAndDevex(CoinIndexedVector *updates,49 CoinIndexedVector *spareRow2,50 CoinIndexedVector *spareColumn1);51 52 void djsAndDevex2(CoinIndexedVector *updates,53 CoinIndexedVector *spareColumn1);54 55 void justDevex(CoinIndexedVector *updates,56 CoinIndexedVector *spareColumn1);34 virtual int pivotColumn(CoinPartitionedVector *updates, 35 CoinPartitionedVector *spareRow2, 36 CoinPartitionedVector *spareColumn1); 37 /// Just update djs 38 void justDjs(CoinIndexedVector *updates, 39 CoinIndexedVector *spareColumn1); 40 /// Update djs doing partial pricing (dantzig) 41 int partialPricing(CoinIndexedVector *updates, 42 int numberWanted, 43 int numberLook); 44 /// Update djs, weights for Devex using djs 45 void djsAndDevex(CoinIndexedVector *updates, 46 CoinIndexedVector *spareRow2, 47 CoinIndexedVector *spareColumn1); 48 /// Update djs, weights for Devex using pivot row 49 void djsAndDevex2(CoinIndexedVector *updates, 50 CoinIndexedVector *spareColumn1); 51 /// Update weights for Devex 52 void justDevex(CoinIndexedVector *updates, 53 CoinIndexedVector *spareColumn1); 57 54 /** Does steepest work 58 55 type  … … 62 59 3  both using extra array 63 60 */ 64 int doSteepestWork(CoinPartitionedVector *updates,65 CoinPartitionedVector *spareRow2,66 CoinPartitionedVector *spareColumn1,67 68 69 70 virtual void updateWeights(CoinIndexedVector *input);71 72 73 74 CoinIndexedVector *rowArray1);75 76 77 78 79 61 int doSteepestWork(CoinPartitionedVector *updates, 62 CoinPartitionedVector *spareRow2, 63 CoinPartitionedVector *spareColumn1, 64 int type); 65 66 /// Updates weights  part 1  also checks accuracy 67 virtual void updateWeights(CoinIndexedVector *input); 68 69 /// Checks accuracy  just for debug 70 void checkAccuracy(int sequence, double relativeTolerance, 71 CoinIndexedVector *rowArray1); 72 73 /// Initialize weights 74 void initializeWeights(); 75 76 /** Save weights  this may initialize weights as well 80 77 mode is  81 78 1) before factorization … … 85 82 5) at end of values pass (so need initialization) 86 83 */ 87 virtual void saveWeights(AbcSimplex * model, int mode); 88 /// Gets rid of last update 89 virtual void unrollWeights(); 90 /// Gets rid of all arrays 91 virtual void clearArrays(); 92 /// Returns true if would not find any column 93 virtual bool looksOptimal() const; 94 /// Called when maximum pivots changes 95 virtual void maximumPivotsChanged(); 96 //@} 97 98 /**@name gets and sets */ 99 //@{ 100 /// Mode 101 inline int mode() const { 102 return mode_; 103 } 104 //@} 105 106 /** enums for persistence 107 */ 108 enum Persistence { 109 normal = 0x00, // create (if necessary) and destroy 110 keep = 0x01 // create (if necessary) and leave 111 }; 112 113 ///@name Constructors and destructors 114 //@{ 115 /** Default Constructor 84 virtual void saveWeights(AbcSimplex *model, int mode); 85 /// Gets rid of last update 86 virtual void unrollWeights(); 87 /// Gets rid of all arrays 88 virtual void clearArrays(); 89 /// Returns true if would not find any column 90 virtual bool looksOptimal() const; 91 /// Called when maximum pivots changes 92 virtual void maximumPivotsChanged(); 93 //@} 94 95 /**@name gets and sets */ 96 //@{ 97 /// Mode 98 inline int mode() const 99 { 100 return mode_; 101 } 102 //@} 103 104 /** enums for persistence 105 */ 106 enum Persistence { 107 normal = 0x00, // create (if necessary) and destroy 108 keep = 0x01 // create (if necessary) and leave 109 }; 110 111 ///@name Constructors and destructors 112 //@{ 113 /** Default Constructor 116 114 0 is exact devex, 1 full steepest, 2 is partial exact devex 117 115 3 switches between 0 and 2 depending on factorization … … 121 119 This can be faster on very easy problems. 122 120 */ 123 124 125 126 AbcPrimalColumnSteepest(const AbcPrimalColumnSteepest &rhs);127 128 129 AbcPrimalColumnSteepest & operator=(const AbcPrimalColumnSteepest&rhs);130 131 132 virtual ~AbcPrimalColumnSteepest();133 134 135 virtual AbcPrimalColumnPivot *clone(bool copyData = true) const;136 137 138 139 140 121 AbcPrimalColumnSteepest(int mode = 3); 122 123 /// Copy constructor 124 AbcPrimalColumnSteepest(const AbcPrimalColumnSteepest &rhs); 125 126 /// Assignment operator 127 AbcPrimalColumnSteepest &operator=(const AbcPrimalColumnSteepest &rhs); 128 129 /// Destructor 130 virtual ~AbcPrimalColumnSteepest(); 131 132 /// Clone 133 virtual AbcPrimalColumnPivot *clone(bool copyData = true) const; 134 135 //@} 136 137 ///@name Private functions to deal with devex 138 /** reference would be faster using AbcSimplex's status_, 141 139 but I prefer to keep modularity. 142 140 */ 143 inline bool reference(int i) const { 144 return ((reference_[i>>5] >> (i & 31)) & 1) != 0; 145 } 146 inline void setReference(int i, bool trueFalse) { 147 unsigned int & value = reference_[i>>5]; 148 int bit = i & 31; 149 if (trueFalse) 150 value = (1 << bit); 151 else 152 value &= ~(1 << bit); 153 } 154 /// Set/ get persistence 155 inline void setPersistence(Persistence life) { 156 persistence_ = life; 157 } 158 inline Persistence persistence() const { 159 return persistence_ ; 160 } 161 162 //@} 163 // 141 inline bool reference(int i) const 142 { 143 return ((reference_[i >> 5] >> (i & 31)) & 1) != 0; 144 } 145 inline void setReference(int i, bool trueFalse) 146 { 147 unsigned int &value = reference_[i >> 5]; 148 int bit = i & 31; 149 if (trueFalse) 150 value = (1 << bit); 151 else 152 value &= ~(1 << bit); 153 } 154 /// Set/ get persistence 155 inline void setPersistence(Persistence life) 156 { 157 persistence_ = life; 158 } 159 inline Persistence persistence() const 160 { 161 return persistence_; 162 } 163 164 //@} 165 // 164 166 165 167 private: 166 167 168 169 170 double *weights_;171 172 CoinIndexedVector *infeasible_;173 174 CoinIndexedVector *alternateWeights_;175 176 double *savedWeights_;177 178 unsigned int *reference_;179 168 ///@name Private member data 169 // Update weight 170 double devex_; 171 /// weight array 172 double *weights_; 173 /// square of infeasibility array (just for infeasible columns) 174 CoinIndexedVector *infeasible_; 175 /// alternate weight array (so we can unroll) 176 CoinIndexedVector *alternateWeights_; 177 /// save weight array (so we can use checkpoint) 178 double *savedWeights_; 179 // Array for exact devex to say what is in reference framework 180 unsigned int *reference_; 181 /** Status 180 182 0) Normal 181 183 1) Needs initialization 182 184 1) Weights are stored by sequence number 183 185 */ 184 185 186 int state_; 187 /** 186 188 0 is exact devex, 1 full steepest, 2 is partial exact devex 187 189 3 switches between 0 and 2 depending on factorization … … 195 197 196 198 */ 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 199 int mode_; 200 /// Life of weights 201 Persistence persistence_; 202 /// Number of times switched from partial dantzig to 0/2 203 int numberSwitched_; 204 // This is pivot row (or pivot sequence round refactorization) 205 int pivotSequence_; 206 // This is saved pivot sequence 207 int savedPivotSequence_; 208 // This is saved outgoing variable 209 int savedSequenceOut_; 210 // Iteration when last rectified 211 int lastRectified_; 212 // Size of factorization at invert (used to decide algorithm) 213 int sizeFactorization_; 214 //@} 213 215 }; 214 216 215 217 #endif 218 219 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 220 */
Note: See TracChangeset
for help on using the changeset viewer.