Changeset 2464 for trunk/Cbc/src/CbcTreeLocal.hpp
 Timestamp:
 Jan 3, 2019 2:03:23 PM (9 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcTreeLocal.hpp
r1573 r2464 37 37 class CbcModel; 38 38 39 40 39 class CbcTreeLocal : public CbcTree { 41 40 42 41 public: 43 44 // Default Constructor 45 CbcTreeLocal (); 46 47 /* Constructor with solution. 42 // Default Constructor 43 CbcTreeLocal(); 44 45 /* Constructor with solution. 48 46 If solution NULL no solution, otherwise must be integer 49 47 range is initial upper bound (k) on difference from given solution. … … 58 56 if false then no refinement but reverse cuts weaker 59 57 */ 60 CbcTreeLocal (CbcModel * model, const double * solution , int range = 10, 61 int typeCuts = 0, int maxDiversification = 0, 62 int timeLimit = 1000000, int nodeLimit = 1000000, bool refine = true); 63 // Copy constructor 64 CbcTreeLocal ( const CbcTreeLocal & rhs); 65 66 // = operator 67 CbcTreeLocal & operator=(const CbcTreeLocal & rhs); 68 69 virtual ~CbcTreeLocal(); 70 71 /// Clone 72 virtual CbcTree * clone() const; 73 /// Create C++ lines to get to current state 74 virtual void generateCpp( FILE * fp) ; 75 76 /*! \name Heap access and maintenance methods */ 77 //@{ 78 79 /// Return the top node of the heap 80 virtual CbcNode * top() const; 81 82 /// Add a node to the heap 83 virtual void push(CbcNode * x); 84 85 /// Remove the top node from the heap 86 virtual void pop() ; 87 88 //@} 89 /*! \name Other stuff */ 90 //@{ 91 92 /// Create cut  return 1 if bad, 0 if okay and 1 if cut is everything 93 int createCut(const double * solution, OsiRowCut & cut); 94 95 /// Test if empty *** note may be overridden 96 virtual bool empty() ; 97 98 /// We may have got an intelligent tree so give it one more chance 99 virtual void endSearch() ; 100 /// Other side of last cut branch (if bias==rhs_ will be weakest possible) 101 void reverseCut(int state, double bias = 0.0); 102 /// Delete last cut branch 103 void deleteCut(OsiRowCut & cut); 104 /// Pass in solution (so can be used after heuristic) 105 void passInSolution(const double * solution, double solutionValue); 106 // range i.e. k 107 inline int range() const { 108 return range_; 109 } 110 // setrange i.e. k 111 inline void setRange(int value) { 112 range_ = value; 113 } 114 // Type of cuts  0=just 01, 1=all 115 inline int typeCuts() const { 116 return typeCuts_; 117 } 118 // Type of cuts  0=just 01, 1=all 119 inline void setTypeCuts(int value) { 120 typeCuts_ = value; 121 } 122 // maximum number of diversifications 123 inline int maxDiversification() const { 124 return maxDiversification_; 125 } 126 // maximum number of diversifications 127 inline void setMaxDiversification(int value) { 128 maxDiversification_ = value; 129 } 130 // time limit per subtree 131 inline int timeLimit() const { 132 return timeLimit_; 133 } 134 // time limit per subtree 135 inline void setTimeLimit(int value) { 136 timeLimit_ = value; 137 } 138 // node limit for subtree 139 inline int nodeLimit() const { 140 return nodeLimit_; 141 } 142 // node limit for subtree 143 inline void setNodeLimit(int value) { 144 nodeLimit_ = value; 145 } 146 // Whether to do refinement step 147 inline bool refine() const { 148 return refine_; 149 } 150 // Whether to do refinement step 151 inline void setRefine(bool yesNo) { 152 refine_ = yesNo; 153 } 154 155 //@} 58 CbcTreeLocal(CbcModel *model, const double *solution, int range = 10, 59 int typeCuts = 0, int maxDiversification = 0, 60 int timeLimit = 1000000, int nodeLimit = 1000000, bool refine = true); 61 // Copy constructor 62 CbcTreeLocal(const CbcTreeLocal &rhs); 63 64 // = operator 65 CbcTreeLocal &operator=(const CbcTreeLocal &rhs); 66 67 virtual ~CbcTreeLocal(); 68 69 /// Clone 70 virtual CbcTree *clone() const; 71 /// Create C++ lines to get to current state 72 virtual void generateCpp(FILE *fp); 73 74 /*! \name Heap access and maintenance methods */ 75 //@{ 76 77 /// Return the top node of the heap 78 virtual CbcNode *top() const; 79 80 /// Add a node to the heap 81 virtual void push(CbcNode *x); 82 83 /// Remove the top node from the heap 84 virtual void pop(); 85 86 //@} 87 /*! \name Other stuff */ 88 //@{ 89 90 /// Create cut  return 1 if bad, 0 if okay and 1 if cut is everything 91 int createCut(const double *solution, OsiRowCut &cut); 92 93 /// Test if empty *** note may be overridden 94 virtual bool empty(); 95 96 /// We may have got an intelligent tree so give it one more chance 97 virtual void endSearch(); 98 /// Other side of last cut branch (if bias==rhs_ will be weakest possible) 99 void reverseCut(int state, double bias = 0.0); 100 /// Delete last cut branch 101 void deleteCut(OsiRowCut &cut); 102 /// Pass in solution (so can be used after heuristic) 103 void passInSolution(const double *solution, double solutionValue); 104 // range i.e. k 105 inline int range() const 106 { 107 return range_; 108 } 109 // setrange i.e. k 110 inline void setRange(int value) 111 { 112 range_ = value; 113 } 114 // Type of cuts  0=just 01, 1=all 115 inline int typeCuts() const 116 { 117 return typeCuts_; 118 } 119 // Type of cuts  0=just 01, 1=all 120 inline void setTypeCuts(int value) 121 { 122 typeCuts_ = value; 123 } 124 // maximum number of diversifications 125 inline int maxDiversification() const 126 { 127 return maxDiversification_; 128 } 129 // maximum number of diversifications 130 inline void setMaxDiversification(int value) 131 { 132 maxDiversification_ = value; 133 } 134 // time limit per subtree 135 inline int timeLimit() const 136 { 137 return timeLimit_; 138 } 139 // time limit per subtree 140 inline void setTimeLimit(int value) 141 { 142 timeLimit_ = value; 143 } 144 // node limit for subtree 145 inline int nodeLimit() const 146 { 147 return nodeLimit_; 148 } 149 // node limit for subtree 150 inline void setNodeLimit(int value) 151 { 152 nodeLimit_ = value; 153 } 154 // Whether to do refinement step 155 inline bool refine() const 156 { 157 return refine_; 158 } 159 // Whether to do refinement step 160 inline void setRefine(bool yesNo) 161 { 162 refine_ = yesNo; 163 } 164 165 //@} 156 166 private: 157 // Node for local cuts 158 CbcNode * localNode_; 159 // best solution 160 double * bestSolution_; 161 // saved solution 162 double * savedSolution_; 163 // solution number at start of pass 164 int saveNumberSolutions_; 165 /* Cut. If zero size then no solution yet. Otherwise is left hand branch */ 166 OsiRowCut cut_; 167 // This cut fixes all 01 variables 168 OsiRowCut fixedCut_; 169 // Model 170 CbcModel * model_; 171 // Original lower bounds 172 double * originalLower_; 173 // Original upper bounds 174 double * originalUpper_; 175 // range i.e. k 176 int range_; 177 // Type of cuts  0=just 01, 1=all 178 int typeCuts_; 179 // maximum number of diversifications 180 int maxDiversification_; 181 // current diversification 182 int diversification_; 183 // Whether next will be strong diversification 184 bool nextStrong_; 185 // Current rhs 186 double rhs_; 187 // Save allowable gap 188 double savedGap_; 189 // Best solution 190 double bestCutoff_; 191 // time limit per subtree 192 int timeLimit_; 193 // time when subtree started 194 int startTime_; 195 // node limit for subtree 196 int nodeLimit_; 197 // node count when subtree started 198 int startNode_; 199 // 1 not started, 0 == stop on first solution, 1 don't stop on first, 2 refinement step 200 int searchType_; 201 // Whether to do refinement step 202 bool refine_; 203 167 // Node for local cuts 168 CbcNode *localNode_; 169 // best solution 170 double *bestSolution_; 171 // saved solution 172 double *savedSolution_; 173 // solution number at start of pass 174 int saveNumberSolutions_; 175 /* Cut. If zero size then no solution yet. Otherwise is left hand branch */ 176 OsiRowCut cut_; 177 // This cut fixes all 01 variables 178 OsiRowCut fixedCut_; 179 // Model 180 CbcModel *model_; 181 // Original lower bounds 182 double *originalLower_; 183 // Original upper bounds 184 double *originalUpper_; 185 // range i.e. k 186 int range_; 187 // Type of cuts  0=just 01, 1=all 188 int typeCuts_; 189 // maximum number of diversifications 190 int maxDiversification_; 191 // current diversification 192 int diversification_; 193 // Whether next will be strong diversification 194 bool nextStrong_; 195 // Current rhs 196 double rhs_; 197 // Save allowable gap 198 double savedGap_; 199 // Best solution 200 double bestCutoff_; 201 // time limit per subtree 202 int timeLimit_; 203 // time when subtree started 204 int startTime_; 205 // node limit for subtree 206 int nodeLimit_; 207 // node count when subtree started 208 int startNode_; 209 // 1 not started, 0 == stop on first solution, 1 don't stop on first, 2 refinement step 210 int searchType_; 211 // Whether to do refinement step 212 bool refine_; 204 213 }; 205 214 … … 207 216 208 217 public: 209 210 // Default Constructor 211 CbcTreeVariable (); 212 213 /* Constructor with solution. 218 // Default Constructor 219 CbcTreeVariable(); 220 221 /* Constructor with solution. 214 222 If solution NULL no solution, otherwise must be integer 215 223 range is initial upper bound (k) on difference from given solution. … … 224 232 if false then no refinement but reverse cuts weaker 225 233 */ 226 CbcTreeVariable (CbcModel * model, const double * solution , int range = 10, 227 int typeCuts = 0, int maxDiversification = 0, 228 int timeLimit = 1000000, int nodeLimit = 1000000, bool refine = true); 229 // Copy constructor 230 CbcTreeVariable ( const CbcTreeVariable & rhs); 231 232 // = operator 233 CbcTreeVariable & operator=(const CbcTreeVariable & rhs); 234 235 virtual ~CbcTreeVariable(); 236 237 /// Clone 238 virtual CbcTree * clone() const; 239 /// Create C++ lines to get to current state 240 virtual void generateCpp( FILE * fp) ; 241 242 /*! \name Heap access and maintenance methods */ 243 //@{ 244 245 /// Return the top node of the heap 246 virtual CbcNode * top() const; 247 248 /// Add a node to the heap 249 virtual void push(CbcNode * x); 250 251 /// Remove the top node from the heap 252 virtual void pop() ; 253 254 //@} 255 /*! \name Other stuff */ 256 //@{ 257 258 /// Create cut  return 1 if bad, 0 if okay and 1 if cut is everything 259 int createCut(const double * solution, OsiRowCut & cut); 260 261 /// Test if empty *** note may be overridden 262 virtual bool empty() ; 263 264 /// We may have got an intelligent tree so give it one more chance 265 virtual void endSearch() ; 266 /// Other side of last cut branch (if bias==rhs_ will be weakest possible) 267 void reverseCut(int state, double bias = 0.0); 268 /// Delete last cut branch 269 void deleteCut(OsiRowCut & cut); 270 /// Pass in solution (so can be used after heuristic) 271 void passInSolution(const double * solution, double solutionValue); 272 // range i.e. k 273 inline int range() const { 274 return range_; 275 } 276 // setrange i.e. k 277 inline void setRange(int value) { 278 range_ = value; 279 } 280 // Type of cuts  0=just 01, 1=all 281 inline int typeCuts() const { 282 return typeCuts_; 283 } 284 // Type of cuts  0=just 01, 1=all 285 inline void setTypeCuts(int value) { 286 typeCuts_ = value; 287 } 288 // maximum number of diversifications 289 inline int maxDiversification() const { 290 return maxDiversification_; 291 } 292 // maximum number of diversifications 293 inline void setMaxDiversification(int value) { 294 maxDiversification_ = value; 295 } 296 // time limit per subtree 297 inline int timeLimit() const { 298 return timeLimit_; 299 } 300 // time limit per subtree 301 inline void setTimeLimit(int value) { 302 timeLimit_ = value; 303 } 304 // node limit for subtree 305 inline int nodeLimit() const { 306 return nodeLimit_; 307 } 308 // node limit for subtree 309 inline void setNodeLimit(int value) { 310 nodeLimit_ = value; 311 } 312 // Whether to do refinement step 313 inline bool refine() const { 314 return refine_; 315 } 316 // Whether to do refinement step 317 inline void setRefine(bool yesNo) { 318 refine_ = yesNo; 319 } 320 321 //@} 234 CbcTreeVariable(CbcModel *model, const double *solution, int range = 10, 235 int typeCuts = 0, int maxDiversification = 0, 236 int timeLimit = 1000000, int nodeLimit = 1000000, bool refine = true); 237 // Copy constructor 238 CbcTreeVariable(const CbcTreeVariable &rhs); 239 240 // = operator 241 CbcTreeVariable &operator=(const CbcTreeVariable &rhs); 242 243 virtual ~CbcTreeVariable(); 244 245 /// Clone 246 virtual CbcTree *clone() const; 247 /// Create C++ lines to get to current state 248 virtual void generateCpp(FILE *fp); 249 250 /*! \name Heap access and maintenance methods */ 251 //@{ 252 253 /// Return the top node of the heap 254 virtual CbcNode *top() const; 255 256 /// Add a node to the heap 257 virtual void push(CbcNode *x); 258 259 /// Remove the top node from the heap 260 virtual void pop(); 261 262 //@} 263 /*! \name Other stuff */ 264 //@{ 265 266 /// Create cut  return 1 if bad, 0 if okay and 1 if cut is everything 267 int createCut(const double *solution, OsiRowCut &cut); 268 269 /// Test if empty *** note may be overridden 270 virtual bool empty(); 271 272 /// We may have got an intelligent tree so give it one more chance 273 virtual void endSearch(); 274 /// Other side of last cut branch (if bias==rhs_ will be weakest possible) 275 void reverseCut(int state, double bias = 0.0); 276 /// Delete last cut branch 277 void deleteCut(OsiRowCut &cut); 278 /// Pass in solution (so can be used after heuristic) 279 void passInSolution(const double *solution, double solutionValue); 280 // range i.e. k 281 inline int range() const 282 { 283 return range_; 284 } 285 // setrange i.e. k 286 inline void setRange(int value) 287 { 288 range_ = value; 289 } 290 // Type of cuts  0=just 01, 1=all 291 inline int typeCuts() const 292 { 293 return typeCuts_; 294 } 295 // Type of cuts  0=just 01, 1=all 296 inline void setTypeCuts(int value) 297 { 298 typeCuts_ = value; 299 } 300 // maximum number of diversifications 301 inline int maxDiversification() const 302 { 303 return maxDiversification_; 304 } 305 // maximum number of diversifications 306 inline void setMaxDiversification(int value) 307 { 308 maxDiversification_ = value; 309 } 310 // time limit per subtree 311 inline int timeLimit() const 312 { 313 return timeLimit_; 314 } 315 // time limit per subtree 316 inline void setTimeLimit(int value) 317 { 318 timeLimit_ = value; 319 } 320 // node limit for subtree 321 inline int nodeLimit() const 322 { 323 return nodeLimit_; 324 } 325 // node limit for subtree 326 inline void setNodeLimit(int value) 327 { 328 nodeLimit_ = value; 329 } 330 // Whether to do refinement step 331 inline bool refine() const 332 { 333 return refine_; 334 } 335 // Whether to do refinement step 336 inline void setRefine(bool yesNo) 337 { 338 refine_ = yesNo; 339 } 340 341 //@} 322 342 private: 323 // Node for local cuts 324 CbcNode * localNode_; 325 // best solution 326 double * bestSolution_; 327 // saved solution 328 double * savedSolution_; 329 // solution number at start of pass 330 int saveNumberSolutions_; 331 /* Cut. If zero size then no solution yet. Otherwise is left hand branch */ 332 OsiRowCut cut_; 333 // This cut fixes all 01 variables 334 OsiRowCut fixedCut_; 335 // Model 336 CbcModel * model_; 337 // Original lower bounds 338 double * originalLower_; 339 // Original upper bounds 340 double * originalUpper_; 341 // range i.e. k 342 int range_; 343 // Type of cuts  0=just 01, 1=all 344 int typeCuts_; 345 // maximum number of diversifications 346 int maxDiversification_; 347 // current diversification 348 int diversification_; 349 // Whether next will be strong diversification 350 bool nextStrong_; 351 // Current rhs 352 double rhs_; 353 // Save allowable gap 354 double savedGap_; 355 // Best solution 356 double bestCutoff_; 357 // time limit per subtree 358 int timeLimit_; 359 // time when subtree started 360 int startTime_; 361 // node limit for subtree 362 int nodeLimit_; 363 // node count when subtree started 364 int startNode_; 365 // 1 not started, 0 == stop on first solution, 1 don't stop on first, 2 refinement step 366 int searchType_; 367 // Whether to do refinement step 368 bool refine_; 369 343 // Node for local cuts 344 CbcNode *localNode_; 345 // best solution 346 double *bestSolution_; 347 // saved solution 348 double *savedSolution_; 349 // solution number at start of pass 350 int saveNumberSolutions_; 351 /* Cut. If zero size then no solution yet. Otherwise is left hand branch */ 352 OsiRowCut cut_; 353 // This cut fixes all 01 variables 354 OsiRowCut fixedCut_; 355 // Model 356 CbcModel *model_; 357 // Original lower bounds 358 double *originalLower_; 359 // Original upper bounds 360 double *originalUpper_; 361 // range i.e. k 362 int range_; 363 // Type of cuts  0=just 01, 1=all 364 int typeCuts_; 365 // maximum number of diversifications 366 int maxDiversification_; 367 // current diversification 368 int diversification_; 369 // Whether next will be strong diversification 370 bool nextStrong_; 371 // Current rhs 372 double rhs_; 373 // Save allowable gap 374 double savedGap_; 375 // Best solution 376 double bestCutoff_; 377 // time limit per subtree 378 int timeLimit_; 379 // time when subtree started 380 int startTime_; 381 // node limit for subtree 382 int nodeLimit_; 383 // node count when subtree started 384 int startNode_; 385 // 1 not started, 0 == stop on first solution, 1 don't stop on first, 2 refinement step 386 int searchType_; 387 // Whether to do refinement step 388 bool refine_; 370 389 }; 371 390 #endif 372
Note: See TracChangeset
for help on using the changeset viewer.