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

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/ClpGubDynamicMatrix.hpp
r2279 r2385 7 7 #define ClpGubDynamicMatrix_H 8 8 9 10 9 #include "CoinPragma.hpp" 11 10 … … 21 20 22 21 public: 23 24 25 26 virtual void partialPricing(ClpSimplex *model, double start, double end,27 int & bestSequence, int &numberWanted);28 22 /**@name Main functions provided */ 23 //@{ 24 /// Partial pricing 25 virtual void partialPricing(ClpSimplex *model, double start, double end, 26 int &bestSequence, int &numberWanted); 27 /** This is local to Gub to allow synchronization: 29 28 mode=0 when status of basis is good 30 29 mode=1 when variable is flagged … … 36 35 mode=9  adjust lower, upper on set by incoming 37 36 */ 38 virtual int synchronize(ClpSimplex *model, int mode);39 40 virtual void useEffectiveRhs(ClpSimplex *model, bool cheapest = true);41 37 virtual int synchronize(ClpSimplex *model, int mode); 38 /// Sets up an effective RHS and does gub crash if needed 39 virtual void useEffectiveRhs(ClpSimplex *model, bool cheapest = true); 40 /** 42 41 update information for a pivot (and effective rhs) 43 42 */ 44 virtual int updatePivot(ClpSimplex *model, double oldInValue, double oldOutValue);45 46 47 43 virtual int updatePivot(ClpSimplex *model, double oldInValue, double oldOutValue); 44 /// Add a new variable to a set 45 void insertNonBasic(int sequence, int iSet); 46 /** Returns effective RHS offset if it is being used. This is used for long problems 48 47 or big gub or anywhere where going through full columns is 49 48 expensive. This may recompute */ 50 virtual double * rhsOffset(ClpSimplex *model, bool forceRefresh = false,51 52 53 using ClpPackedMatrix::times;54 49 virtual double *rhsOffset(ClpSimplex *model, bool forceRefresh = false, 50 bool check = false); 51 52 using ClpPackedMatrix::times; 53 /** Return <code>y + A * scalar *x</code> in <code>y</code>. 55 54 @pre <code>x</code> must be of size <code>numColumns()</code> 56 55 @pre <code>y</code> must be of size <code>numRows()</code> */ 57 58 const double * x, double *y) const;59 56 virtual void times(double scalar, 57 const double *x, double *y) const; 58 /** Just for debug 60 59 Returns sum and number of primal infeasibilities. Recomputes keys 61 60 */ 62 virtual int checkFeasible(ClpSimplex * model, double & sum) const; 63 /// Cleans data after setWarmStart 64 void cleanData(ClpSimplex * model); 65 //@} 66 67 68 69 /**@name Constructors, destructor */ 70 //@{ 71 /** Default constructor. */ 72 ClpGubDynamicMatrix(); 73 /** Destructor */ 74 virtual ~ClpGubDynamicMatrix(); 75 //@} 76 77 /**@name Copy method */ 78 //@{ 79 /** The copy constructor. */ 80 ClpGubDynamicMatrix(const ClpGubDynamicMatrix&); 81 /** This is the real constructor. 61 virtual int checkFeasible(ClpSimplex *model, double &sum) const; 62 /// Cleans data after setWarmStart 63 void cleanData(ClpSimplex *model); 64 //@} 65 66 /**@name Constructors, destructor */ 67 //@{ 68 /** Default constructor. */ 69 ClpGubDynamicMatrix(); 70 /** Destructor */ 71 virtual ~ClpGubDynamicMatrix(); 72 //@} 73 74 /**@name Copy method */ 75 //@{ 76 /** The copy constructor. */ 77 ClpGubDynamicMatrix(const ClpGubDynamicMatrix &); 78 /** This is the real constructor. 82 79 It assumes factorization frequency will not be changed. 83 80 This resizes model !!!! 84 81 */ 85 ClpGubDynamicMatrix(ClpSimplex * model, int numberSets, 86 int numberColumns, const int * starts, 87 const double * lower, const double * upper, 88 const CoinBigIndex * startColumn, const int * row, 89 const double * element, const double * cost, 90 const double * lowerColumn = NULL, const double * upperColumn = NULL, 91 const unsigned char * status = NULL); 92 93 ClpGubDynamicMatrix& operator=(const ClpGubDynamicMatrix&); 94 /// Clone 95 virtual ClpMatrixBase * clone() const ; 96 //@} 97 /**@name gets and sets */ 98 //@{ 99 /// enums for status of various sorts 100 enum DynamicStatus { 101 inSmall = 0x01, 102 atUpperBound = 0x02, 103 atLowerBound = 0x03 104 }; 105 /// Whether flagged 106 inline bool flagged(int i) const { 107 return (dynamicStatus_[i] & 8) != 0; 108 } 109 inline void setFlagged(int i) { 110 dynamicStatus_[i] = static_cast<unsigned char>(dynamicStatus_[i]  8); 111 } 112 inline void unsetFlagged(int i) { 113 dynamicStatus_[i] = static_cast<unsigned char>(dynamicStatus_[i] & ~8); 114 } 115 inline void setDynamicStatus(int sequence, DynamicStatus status) { 116 unsigned char & st_byte = dynamicStatus_[sequence]; 117 st_byte = static_cast<unsigned char>(st_byte & ~7); 118 st_byte = static_cast<unsigned char>(st_byte  status); 119 } 120 inline DynamicStatus getDynamicStatus(int sequence) const { 121 return static_cast<DynamicStatus> (dynamicStatus_[sequence] & 7); 122 } 123 /// Saved value of objective offset 124 inline double objectiveOffset() const { 125 return objectiveOffset_; 126 } 127 /// Starts of each column 128 inline CoinBigIndex * startColumn() const { 129 return startColumn_; 130 } 131 /// rows 132 inline int * row() const { 133 return row_; 134 } 135 /// elements 136 inline double * element() const { 137 return element_; 138 } 139 /// costs 140 inline double * cost() const { 141 return cost_; 142 } 143 /// full starts 144 inline int * fullStart() const { 145 return fullStart_; 146 } 147 /// ids of active columns (just index here) 148 inline int * id() const { 149 return id_; 150 } 151 /// Optional lower bounds on columns 152 inline double * lowerColumn() const { 153 return lowerColumn_; 154 } 155 /// Optional upper bounds on columns 156 inline double * upperColumn() const { 157 return upperColumn_; 158 } 159 /// Optional true lower bounds on sets 160 inline double * lowerSet() const { 161 return lowerSet_; 162 } 163 /// Optional true upper bounds on sets 164 inline double * upperSet() const { 165 return upperSet_; 166 } 167 /// size 168 inline int numberGubColumns() const { 169 return numberGubColumns_; 170 } 171 /// first free 172 inline int firstAvailable() const { 173 return firstAvailable_; 174 } 175 /// set first free 176 inline void setFirstAvailable(int value) { 177 firstAvailable_ = value; 178 } 179 /// first dynamic 180 inline int firstDynamic() const { 181 return firstDynamic_; 182 } 183 /// number of columns in dynamic model 184 inline int lastDynamic() const { 185 return lastDynamic_; 186 } 187 /// size of working matrix (max) 188 inline CoinBigIndex numberElements() const { 189 return numberElements_; 190 } 191 /// Status region for gub slacks 192 inline unsigned char * gubRowStatus() const { 193 return status_; 194 } 195 /// Status region for gub variables 196 inline unsigned char * dynamicStatus() const { 197 return dynamicStatus_; 198 } 199 /// Returns which set a variable is in 200 int whichSet (int sequence) const; 201 //@} 202 82 ClpGubDynamicMatrix(ClpSimplex *model, int numberSets, 83 int numberColumns, const int *starts, 84 const double *lower, const double *upper, 85 const CoinBigIndex *startColumn, const int *row, 86 const double *element, const double *cost, 87 const double *lowerColumn = NULL, const double *upperColumn = NULL, 88 const unsigned char *status = NULL); 89 90 ClpGubDynamicMatrix &operator=(const ClpGubDynamicMatrix &); 91 /// Clone 92 virtual ClpMatrixBase *clone() const; 93 //@} 94 /**@name gets and sets */ 95 //@{ 96 /// enums for status of various sorts 97 enum DynamicStatus { 98 inSmall = 0x01, 99 atUpperBound = 0x02, 100 atLowerBound = 0x03 101 }; 102 /// Whether flagged 103 inline bool flagged(int i) const 104 { 105 return (dynamicStatus_[i] & 8) != 0; 106 } 107 inline void setFlagged(int i) 108 { 109 dynamicStatus_[i] = static_cast< unsigned char >(dynamicStatus_[i]  8); 110 } 111 inline void unsetFlagged(int i) 112 { 113 dynamicStatus_[i] = static_cast< unsigned char >(dynamicStatus_[i] & ~8); 114 } 115 inline void setDynamicStatus(int sequence, DynamicStatus status) 116 { 117 unsigned char &st_byte = dynamicStatus_[sequence]; 118 st_byte = static_cast< unsigned char >(st_byte & ~7); 119 st_byte = static_cast< unsigned char >(st_byte  status); 120 } 121 inline DynamicStatus getDynamicStatus(int sequence) const 122 { 123 return static_cast< DynamicStatus >(dynamicStatus_[sequence] & 7); 124 } 125 /// Saved value of objective offset 126 inline double objectiveOffset() const 127 { 128 return objectiveOffset_; 129 } 130 /// Starts of each column 131 inline CoinBigIndex *startColumn() const 132 { 133 return startColumn_; 134 } 135 /// rows 136 inline int *row() const 137 { 138 return row_; 139 } 140 /// elements 141 inline double *element() const 142 { 143 return element_; 144 } 145 /// costs 146 inline double *cost() const 147 { 148 return cost_; 149 } 150 /// full starts 151 inline int *fullStart() const 152 { 153 return fullStart_; 154 } 155 /// ids of active columns (just index here) 156 inline int *id() const 157 { 158 return id_; 159 } 160 /// Optional lower bounds on columns 161 inline double *lowerColumn() const 162 { 163 return lowerColumn_; 164 } 165 /// Optional upper bounds on columns 166 inline double *upperColumn() const 167 { 168 return upperColumn_; 169 } 170 /// Optional true lower bounds on sets 171 inline double *lowerSet() const 172 { 173 return lowerSet_; 174 } 175 /// Optional true upper bounds on sets 176 inline double *upperSet() const 177 { 178 return upperSet_; 179 } 180 /// size 181 inline int numberGubColumns() const 182 { 183 return numberGubColumns_; 184 } 185 /// first free 186 inline int firstAvailable() const 187 { 188 return firstAvailable_; 189 } 190 /// set first free 191 inline void setFirstAvailable(int value) 192 { 193 firstAvailable_ = value; 194 } 195 /// first dynamic 196 inline int firstDynamic() const 197 { 198 return firstDynamic_; 199 } 200 /// number of columns in dynamic model 201 inline int lastDynamic() const 202 { 203 return lastDynamic_; 204 } 205 /// size of working matrix (max) 206 inline CoinBigIndex numberElements() const 207 { 208 return numberElements_; 209 } 210 /// Status region for gub slacks 211 inline unsigned char *gubRowStatus() const 212 { 213 return status_; 214 } 215 /// Status region for gub variables 216 inline unsigned char *dynamicStatus() const 217 { 218 return dynamicStatus_; 219 } 220 /// Returns which set a variable is in 221 int whichSet(int sequence) const; 222 //@} 203 223 204 224 protected: 205 225 /**@name Data members 206 226 The data members are protected to allow access for derived classes. */ 207 208 209 210 211 CoinBigIndex *startColumn_;212 213 int *row_;214 215 double *element_;216 217 double *cost_;218 219 int *fullStart_;220 221 int *id_;222 223 unsigned char *dynamicStatus_;224 225 double *lowerColumn_;226 227 double *upperColumn_;228 229 double *lowerSet_;230 231 double *upperSet_;232 233 234 235 236 237 238 239 240 241 242 243 244 227 //@{ 228 /// Saved value of objective offset 229 double objectiveOffset_; 230 /// Starts of each column 231 CoinBigIndex *startColumn_; 232 /// rows 233 int *row_; 234 /// elements 235 double *element_; 236 /// costs 237 double *cost_; 238 /// full starts 239 int *fullStart_; 240 /// ids of active columns (just index here) 241 int *id_; 242 /// for status and which bound 243 unsigned char *dynamicStatus_; 244 /// Optional lower bounds on columns 245 double *lowerColumn_; 246 /// Optional upper bounds on columns 247 double *upperColumn_; 248 /// Optional true lower bounds on sets 249 double *lowerSet_; 250 /// Optional true upper bounds on sets 251 double *upperSet_; 252 /// size 253 int numberGubColumns_; 254 /// first free 255 int firstAvailable_; 256 /// saved first free 257 int savedFirstAvailable_; 258 /// first dynamic 259 int firstDynamic_; 260 /// number of columns in dynamic model 261 int lastDynamic_; 262 /// size of working matrix (max) 263 CoinBigIndex numberElements_; 264 //@} 245 265 }; 246 266 247 267 #endif 268 269 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 270 */
Note: See TracChangeset
for help on using the changeset viewer.