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

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcModel.hpp
r2404 r2464 18 18 #include "CbcEventHandler.hpp" 19 19 #include "ClpDualRowPivot.hpp" 20 21 20 22 21 class CbcCutGenerator; … … 38 37 class CbcStatistics; 39 38 class CbcFullNodeInfo; 40 class CbcEventHandler 39 class CbcEventHandler; 41 40 class CglPreProcess; 42 41 class OsiClpSolverInterface; … … 99 98 */ 100 99 101 class CbcModel 100 class CbcModel { 102 101 103 102 public: 104 105 enum CbcIntParam { 106 /** The maximum number of nodes before terminating */ 107 CbcMaxNumNode = 0, 108 /** The maximum number of solutions before terminating */ 109 CbcMaxNumSol, 110 /** Fathoming discipline 103 enum CbcIntParam { 104 /** The maximum number of nodes before terminating */ 105 CbcMaxNumNode = 0, 106 /** The maximum number of solutions before terminating */ 107 CbcMaxNumSol, 108 /** Fathoming discipline 111 109 112 110 Controls objective function comparisons for purposes of fathoming by bound … … 117 115 the target. 118 116 */ 119 120 117 CbcFathomDiscipline, 118 /** Adjusts printout 121 119 1 does different node message with number unsatisfied on last branch 122 120 */ 123 124 121 CbcPrinting, 122 /** Number of branches (may be more than number of nodes as may 125 123 include strong branching) */ 126 127 128 129 130 131 132 124 CbcNumberBranches, 125 /** Just a marker, so that a static sized array can store parameters. */ 126 CbcLastIntParam 127 }; 128 129 enum CbcDblParam { 130 /** The maximum amount the value of an integer variable can vary from 133 131 integer and still be considered feasible. */ 134 135 132 CbcIntegerTolerance = 0, 133 /** The objective is assumed to worsen by this amount for each 136 134 integer infeasibility. */ 137 138 135 CbcInfeasibilityWeight, 136 /** The amount by which to tighten the objective function cutoff when 139 137 a new solution is discovered. */ 140 141 138 CbcCutoffIncrement, 139 /** Stop when the gap between the objective value of the best known solution 142 140 and the best bound on the objective of any solution is less than this. 143 141 … … 145 143 client. 146 144 */ 147 148 145 CbcAllowableGap, 146 /** Stop when the gap between the objective value of the best known solution 149 147 and the best bound on the objective of any solution is less than this 150 148 fraction of of the absolute value of best known solution. … … 152 150 Code stops if either this test or CbcAllowableGap test succeeds 153 151 */ 154 155 152 CbcAllowableFractionGap, 153 /** \brief The maximum number of seconds before terminating. 156 154 A double should be adequate! */ 157 158 159 160 161 162 163 164 165 166 155 CbcMaximumSeconds, 156 /// Cutoff  stored for speed 157 CbcCurrentCutoff, 158 /// Optimization direction  stored for speed 159 CbcOptimizationDirection, 160 /// Current objective value 161 CbcCurrentObjectiveValue, 162 /// Current minimization objective value 163 CbcCurrentMinimizationObjectiveValue, 164 /** \brief The time at start of model. 167 165 So that other pieces of code can access */ 168 169 166 CbcStartSeconds, 167 /** Stop doing heuristics when the gap between the objective value of the 170 168 best known solution and the best bound on the objective of any solution 171 169 is less than this. … … 174 172 client. 175 173 */ 176 177 174 CbcHeuristicGap, 175 /** Stop doing heuristics when the gap between the objective value of the 178 176 best known solution and the best bound on the objective of any solution 179 177 is less than this fraction of of the absolute value of best known … … 182 180 Code stops if either this test or CbcAllowableGap test succeeds 183 181 */ 184 185 186 187 188 189 190 191 192 193 194 195 196 197 182 CbcHeuristicFractionGap, 183 /// Smallest nonzero change on a branch 184 CbcSmallestChange, 185 /// Sum of nonzero changes on a branch 186 CbcSumChange, 187 /// Largest nonzero change on a branch 188 CbcLargestChange, 189 /// Small nonzero change on a branch to be used as guess 190 CbcSmallChange, 191 /** Just a marker, so that a static sized array can store parameters. */ 192 CbcLastDblParam 193 }; 194 195 // 198 196 199 197 public: 200 201 202 198 ///@name Solve methods 199 //@{ 200 /** \brief Solve the initial LP relaxation 203 201 204 202 Invoke the solver's %initialSolve() method. 205 203 */ 206 207 208 204 void initialSolve(); 205 206 /** \brief Invoke the branch \& cut algorithm 209 207 210 208 The method assumes that initialSolve() has been called to solve the … … 216 214 if 3 then also one line per node 217 215 */ 218 void branchAndBound(int doStatistics = 0); 216 void branchAndBound(int doStatistics = 0); 217 219 218 private: 220 221 /** \brief Evaluate a subproblem using cutting planes and heuristics 219 /** \brief Evaluate a subproblem using cutting planes and heuristics 222 220 223 221 The method invokes a main loop which generates cuts, applies heuristics, … … 226 224 evaluation. 227 225 */ 228 bool solveWithCuts(OsiCuts & cuts, int numberTries, CbcNode *node);229 226 bool solveWithCuts(OsiCuts &cuts, int numberTries, CbcNode *node); 227 /** Generate one round of cuts  serial mode 230 228 returns  231 229 0  normal … … 234 232 1  infeasible 235 233 */ 236 int serialCuts(OsiCuts & cuts, CbcNode * node, OsiCuts &slackCuts, int lastNumberCuts);237 234 int serialCuts(OsiCuts &cuts, CbcNode *node, OsiCuts &slackCuts, int lastNumberCuts); 235 /** Generate one round of cuts  parallel mode 238 236 returns  239 237 0  normal … … 242 240 1  infeasible 243 241 */ 244 int parallelCuts(CbcBaseModel * master, OsiCuts & cuts, CbcNode * node, OsiCuts &slackCuts, int lastNumberCuts);245 242 int parallelCuts(CbcBaseModel *master, OsiCuts &cuts, CbcNode *node, OsiCuts &slackCuts, int lastNumberCuts); 243 /** Input one node output N nodes to put on tree and optional solution update 246 244 This should be able to operate in parallel so is given a solver and is const(ish) 247 245 However we will need to keep an array of solver_ and bases and more … … 249 247 Calling code should always push nodes back on tree 250 248 */ 251 CbcNode ** solveOneNode(int whichSolver, CbcNode * node, 252 int & numberNodesOutput, int & status) ; 253 /// Update size of whichGenerator 254 void resizeWhichGenerator(int numberNow, int numberAfter); 249 CbcNode **solveOneNode(int whichSolver, CbcNode *node, 250 int &numberNodesOutput, int &status); 251 /// Update size of whichGenerator 252 void resizeWhichGenerator(int numberNow, int numberAfter); 253 255 254 public: 256 255 #ifdef CBC_KEEP_DEPRECATED 257 258 256 // See if anyone is using these any more!! 257 /** \brief create a clean model from partially fixed problem 259 258 260 259 The method creates a new model with given bounds and with no tree. 261 260 */ 262 CbcModel * cleanModel(const double * lower, const double *upper);263 261 CbcModel *cleanModel(const double *lower, const double *upper); 262 /** \brief Invoke the branch \& cut algorithm on partially fixed problem 264 263 265 264 The method presolves the given model and does branch and cut. The search … … 277 276 Deletes model2 278 277 */ 279 int subBranchAndBound(CbcModel *model2,280 CbcModel *presolvedModel,281 282 278 int subBranchAndBound(CbcModel *model2, 279 CbcModel *presolvedModel, 280 int maximumNodes); 281 /** \brief Invoke the branch \& cut algorithm on partially fixed problem 283 282 284 283 The method creates a new model with given bounds, presolves it … … 295 294 296 295 */ 297 int subBranchAndBound(const double * lower, const double *upper,298 299 300 296 int subBranchAndBound(const double *lower, const double *upper, 297 int maximumNodes); 298 299 /** \brief Process root node and return a strengthened model 301 300 302 301 The method assumes that initialSolve() has been called to solve the … … 304 303 to the strengthened model (or NULL if infeasible) 305 304 */ 306 OsiSolverInterface *strengthenedModel();307 305 OsiSolverInterface *strengthenedModel(); 306 /** preProcess problem  replacing solver 308 307 If makeEquality true then <= cliques converted to ==. 309 308 Presolve will be done numberPasses times. … … 314 313 if 2 add slacks to get sos (but only if looks plausible) and keep sos info 315 314 */ 316 CglPreProcess * preProcess(int makeEquality = 0, int numberPasses = 5,317 318 315 CglPreProcess *preProcess(int makeEquality = 0, int numberPasses = 5, 316 int tuning = 5); 317 /** Does postprocessing  original solver back. 319 318 User has to delete process */ 320 void postProcess(CglPreProcess *process);319 void postProcess(CglPreProcess *process); 321 320 #endif 322 /// Returns CglPreProcess used before branch and bound 323 inline CglPreProcess * preProcess( ) const 324 { return preProcess_;} 325 /// Set CglPreProcess used before branch and bound 326 inline void setPreProcess(CglPreProcess * preProcess) 327 { preProcess_ = preProcess;} 328 /// Adds an update information object 329 void addUpdateInformation(const CbcObjectUpdateData & data); 330 /** Do one node  broken out for clarity? 321 /// Returns CglPreProcess used before branch and bound 322 inline CglPreProcess *preProcess() const 323 { 324 return preProcess_; 325 } 326 /// Set CglPreProcess used before branch and bound 327 inline void setPreProcess(CglPreProcess *preProcess) 328 { 329 preProcess_ = preProcess; 330 } 331 /// Adds an update information object 332 void addUpdateInformation(const CbcObjectUpdateData &data); 333 /** Do one node  broken out for clarity? 331 334 also for parallel (when baseModel!=this) 332 335 Returns 1 if solution found … … 334 337 newNode NULL if no new node created 335 338 */ 336 int doOneNode(CbcModel * baseModel, CbcNode * & node, CbcNode * &newNode);339 int doOneNode(CbcModel *baseModel, CbcNode *&node, CbcNode *&newNode); 337 340 338 341 public: 339 342 /** \brief Reoptimise an LP relaxation 340 343 341 344 Invoke the solver's %resolve() method. … … 350 353 returns 1 feasible, 0 infeasible, 1 feasible but skip cuts 351 354 */ 352 int resolve(CbcNodeInfo * parent, int whereFrom, 353 double * saveSolution = NULL, 354 double * saveLower = NULL, 355 double * saveUpper = NULL); 356 /// Make given rows (L or G) into global cuts and remove from lp 357 void makeGlobalCuts(int numberRows, const int * which); 358 /// Make given cut into a global cut 359 int makeGlobalCut(const OsiRowCut * cut); 360 /// Make given cut into a global cut 361 int makeGlobalCut(const OsiRowCut & cut); 362 /// Make given column cut into a global cut 363 void makeGlobalCut(const OsiColCut * cut); 364 /// Make given column cut into a global cut 365 void makeGlobalCut(const OsiColCut & cut); 366 /// Make partial cut into a global cut and save 367 void makePartialCut(const OsiRowCut * cut, const OsiSolverInterface * solver=NULL); 368 /// Make partial cuts into global cuts 369 void makeGlobalCuts(); 370 /// Which cut generator generated this cut 371 inline const int * whichGenerator() const 372 { return whichGenerator_;} 373 //@} 374 375 /** \name Presolve methods */ 376 //@{ 377 378 /** Identify cliques and construct corresponding objects. 355 int resolve(CbcNodeInfo *parent, int whereFrom, 356 double *saveSolution = NULL, 357 double *saveLower = NULL, 358 double *saveUpper = NULL); 359 /// Make given rows (L or G) into global cuts and remove from lp 360 void makeGlobalCuts(int numberRows, const int *which); 361 /// Make given cut into a global cut 362 int makeGlobalCut(const OsiRowCut *cut); 363 /// Make given cut into a global cut 364 int makeGlobalCut(const OsiRowCut &cut); 365 /// Make given column cut into a global cut 366 void makeGlobalCut(const OsiColCut *cut); 367 /// Make given column cut into a global cut 368 void makeGlobalCut(const OsiColCut &cut); 369 /// Make partial cut into a global cut and save 370 void makePartialCut(const OsiRowCut *cut, const OsiSolverInterface *solver = NULL); 371 /// Make partial cuts into global cuts 372 void makeGlobalCuts(); 373 /// Which cut generator generated this cut 374 inline const int *whichGenerator() const 375 { 376 return whichGenerator_; 377 } 378 //@} 379 380 /** \name Presolve methods */ 381 //@{ 382 383 /** Identify cliques and construct corresponding objects. 379 384 380 385 Find cliques with size in the range … … 387 392 If priorities exist, clique priority is set to the default. 388 393 */ 389 CbcModel *findCliques(bool makeEquality, int atLeastThisMany,390 391 392 394 CbcModel *findCliques(bool makeEquality, int atLeastThisMany, 395 int lessThanThis, int defaultValue = 1000); 396 397 /** Do integer presolve, creating a new (presolved) model. 393 398 394 399 Returns the new model, or NULL if feasibility is lost. … … 398 403 the original problem at the end. So this is very preliminary. 399 404 */ 400 CbcModel *integerPresolve(bool weak = false);401 402 405 CbcModel *integerPresolve(bool weak = false); 406 407 /** Do integer presolve, modifying the current model. 403 408 404 409 Returns true if the model remains feasible after presolve. 405 410 */ 406 bool integerPresolveThisModel(OsiSolverInterface * originalSolver, bool weak = false); 407 408 409 /// Put back information into the original model after integer presolve. 410 void originalModel(CbcModel * presolvedModel, bool weak); 411 412 /** \brief For variables involved in VUB constraints, see if we can tighten 411 bool integerPresolveThisModel(OsiSolverInterface *originalSolver, bool weak = false); 412 413 /// Put back information into the original model after integer presolve. 414 void originalModel(CbcModel *presolvedModel, bool weak); 415 416 /** \brief For variables involved in VUB constraints, see if we can tighten 413 417 bounds by solving lp's 414 418 … … 430 434 constraint with \p useCutoff as a bound. 431 435 */ 432 433 434 435 436 bool tightenVubs(int type, bool allowMultipleBinary = false, 437 double useCutoff = 1.0e50); 438 439 /** \brief For variables involved in VUB constraints, see if we can tighten 436 440 bounds by solving lp's 437 441 438 442 This version is just handed a list of variables to be processed. 439 443 */ 440 bool tightenVubs(int numberVubs, const int *which,441 442 444 bool tightenVubs(int numberVubs, const int *which, 445 double useCutoff = 1.0e50); 446 /** 443 447 Analyze problem to find a minimum change in the objective function. 444 448 */ 445 446 449 void analyzeObjective(); 450 /** Returns postProcessed solution in solver(called from event handler) 447 451 Normally used for integer solution (not really tested otherwise) 448 452 solutionType 1 is best integer so far, 0 is current solution 449 453 (may not be integer) */ 450 const OsiSolverInterface * postProcessedSolver(int solutionType=1);451 452 454 const OsiSolverInterface *postProcessedSolver(int solutionType = 1); 455 456 /** 453 457 Add additional integers. 454 458 */ 455 456 459 void AddIntegers(); 460 /** 457 461 Save copy of the model. 458 462 */ 459 void saveModel(OsiSolverInterface * saveSolver, double * checkCutoffForRestart, bool *feasible);460 463 void saveModel(OsiSolverInterface *saveSolver, double *checkCutoffForRestart, bool *feasible); 464 /** 461 465 Flip direction of optimization on all models 462 466 */ 463 464 467 void flipModel(); 468 /** 465 469 Clean model i.e. make SOS/integer variables exactly at bound if needed. 466 470 Only if moreSpecialOptions2_ 15 bit set (32768) as there is a small … … 475 479 cleanVariables array will be used if exists 476 480 */ 477 int cleanBounds(OsiSolverInterface * solver, char *cleanVariables);478 479 char *setupCleanVariables();480 481 482 481 int cleanBounds(OsiSolverInterface *solver, char *cleanVariables); 482 /// Sets up cleanVariables array (i.e. ones to be careful about) 483 char *setupCleanVariables(); 484 //@} 485 486 /** \name Object manipulation routines 483 487 484 488 See OsiObject for an explanation of `object' in the context of CbcModel. 485 489 */ 486 //@{ 487 488 /// Get the number of objects 489 inline int numberObjects() const { 490 return numberObjects_; 491 } 492 /// Set the number of objects 493 inline void setNumberObjects(int number) { 494 numberObjects_ = number; 495 } 496 497 /// Get the array of objects 498 inline OsiObject ** objects() const { 499 return object_; 500 } 501 502 /// Get the specified object 503 const inline OsiObject * object(int which) const { 504 return object_[which]; 505 } 506 /// Get the specified object 507 inline OsiObject * modifiableObject(int which) const { 508 return object_[which]; 509 } 510 511 void setOptionalInteger(int index); 512 513 /// Delete all object information (and just back to integers if true) 514 void deleteObjects(bool findIntegers = true); 515 516 /** Add in object information. 490 //@{ 491 492 /// Get the number of objects 493 inline int numberObjects() const 494 { 495 return numberObjects_; 496 } 497 /// Set the number of objects 498 inline void setNumberObjects(int number) 499 { 500 numberObjects_ = number; 501 } 502 503 /// Get the array of objects 504 inline OsiObject **objects() const 505 { 506 return object_; 507 } 508 509 /// Get the specified object 510 const inline OsiObject *object(int which) const 511 { 512 return object_[which]; 513 } 514 /// Get the specified object 515 inline OsiObject *modifiableObject(int which) const 516 { 517 return object_[which]; 518 } 519 520 void setOptionalInteger(int index); 521 522 /// Delete all object information (and just back to integers if true) 523 void deleteObjects(bool findIntegers = true); 524 525 /** Add in object information. 517 526 518 527 Objects are cloned; the owner can delete the originals. 519 528 */ 520 void addObjects(int numberObjects, OsiObject **objects);521 522 529 void addObjects(int numberObjects, OsiObject **objects); 530 531 /** Add in object information. 523 532 524 533 Objects are cloned; the owner can delete the originals. 525 534 */ 526 void addObjects(int numberObjects, CbcObject **objects);527 528 529 void synchronizeModel();530 531 535 void addObjects(int numberObjects, CbcObject **objects); 536 537 /// Ensure attached objects point to this model. 538 void synchronizeModel(); 539 540 /** \brief Identify integer variables and create corresponding objects. 532 541 533 542 Record integer variables and create an CbcSimpleInteger object for each … … 538 547 */ 539 548 540 541 549 void findIntegers(bool startAgain, int type = 0); 550 /** Add SOS info to solver  542 551 Overwrites SOS information in solver with information 543 552 in CbcModel. Has no effect with some solvers. 544 553 Also updates integer info. */ 545 554 void addSOSEtcToSolver(); 546 555 547 556 #ifdef SWITCH_VARIABLES 548 /// Convert Dynamic to Switching549 550 551 int fixAssociated(OsiSolverInterface * solver,int cleanBasis);552 553 int checkAssociated(const OsiSolverInterface *solver,554 const double *solution, int printLevel);557 /// Convert Dynamic to Switching 558 int findSwitching(); 559 /// Fix associated variables 560 int fixAssociated(OsiSolverInterface *solver, int cleanBasis); 561 /// Debug associated variables 562 int checkAssociated(const OsiSolverInterface *solver, 563 const double *solution, int printLevel); 555 564 #endif 556 557 558 559 560 565 //@} 566 567 // 568 569 /**@name Parameter set/get methods 561 570 562 571 The set methods return true if the parameter was set to the given value, … … 566 575 567 576 */ 568 //@{ 569 /// Set an integer parameter 570 inline bool setIntParam(CbcIntParam key, int value) { 571 intParam_[key] = value; 572 return true; 573 } 574 /// Set a double parameter 575 inline bool setDblParam(CbcDblParam key, double value) { 576 dblParam_[key] = value; 577 return true; 578 } 579 /// Get an integer parameter 580 inline int getIntParam(CbcIntParam key) const { 581 return intParam_[key]; 582 } 583 /// Get a double parameter 584 inline double getDblParam(CbcDblParam key) const { 585 return dblParam_[key]; 586 } 587 /*! \brief Set cutoff bound on the objective function. 577 //@{ 578 /// Set an integer parameter 579 inline bool setIntParam(CbcIntParam key, int value) 580 { 581 intParam_[key] = value; 582 return true; 583 } 584 /// Set a double parameter 585 inline bool setDblParam(CbcDblParam key, double value) 586 { 587 dblParam_[key] = value; 588 return true; 589 } 590 /// Get an integer parameter 591 inline int getIntParam(CbcIntParam key) const 592 { 593 return intParam_[key]; 594 } 595 /// Get a double parameter 596 inline double getDblParam(CbcDblParam key) const 597 { 598 return dblParam_[key]; 599 } 600 /*! \brief Set cutoff bound on the objective function. 588 601 589 602 When using strict comparison, the bound is adjusted by a tolerance to 590 603 avoid accidentally cutting off the optimal solution. 591 604 */ 592 void setCutoff(double value) ; 593 594 /// Get the cutoff bound on the objective function  always as minimize 595 inline double getCutoff() const { //double value ; 596 //solver_>getDblParam(OsiDualObjectiveLimit,value) ; 597 //assert( dblParam_[CbcCurrentCutoff]== value * solver_>getObjSense()); 598 return dblParam_[CbcCurrentCutoff]; 599 } 600 601 /// Set the \link CbcModel::CbcMaxNumNode maximum node limit \endlink 602 inline bool setMaximumNodes( int value) { 603 return setIntParam(CbcMaxNumNode, value); 604 } 605 606 /// Get the \link CbcModel::CbcMaxNumNode maximum node limit \endlink 607 inline int getMaximumNodes() const { 608 return getIntParam(CbcMaxNumNode); 609 } 610 611 /** Set the 605 void setCutoff(double value); 606 607 /// Get the cutoff bound on the objective function  always as minimize 608 inline double getCutoff() const 609 { //double value ; 610 //solver_>getDblParam(OsiDualObjectiveLimit,value) ; 611 //assert( dblParam_[CbcCurrentCutoff]== value * solver_>getObjSense()); 612 return dblParam_[CbcCurrentCutoff]; 613 } 614 615 /// Set the \link CbcModel::CbcMaxNumNode maximum node limit \endlink 616 inline bool setMaximumNodes(int value) 617 { 618 return setIntParam(CbcMaxNumNode, value); 619 } 620 621 /// Get the \link CbcModel::CbcMaxNumNode maximum node limit \endlink 622 inline int getMaximumNodes() const 623 { 624 return getIntParam(CbcMaxNumNode); 625 } 626 627 /** Set the 612 628 \link CbcModel::CbcMaxNumSol maximum number of solutions \endlink 613 629 desired. 614 630 */ 615 inline bool setMaximumSolutions( int value) { 616 return setIntParam(CbcMaxNumSol, value); 617 } 618 /** Get the 631 inline bool setMaximumSolutions(int value) 632 { 633 return setIntParam(CbcMaxNumSol, value); 634 } 635 /** Get the 619 636 \link CbcModel::CbcMaxNumSol maximum number of solutions \endlink 620 637 desired. 621 638 */ 622 inline int getMaximumSolutions() const { 623 return getIntParam(CbcMaxNumSol); 624 } 625 /// Set the printing mode 626 inline bool setPrintingMode( int value) { 627 return setIntParam(CbcPrinting, value); 628 } 629 630 /// Get the printing mode 631 inline int getPrintingMode() const { 632 return getIntParam(CbcPrinting); 633 } 634 635 /** Set the 639 inline int getMaximumSolutions() const 640 { 641 return getIntParam(CbcMaxNumSol); 642 } 643 /// Set the printing mode 644 inline bool setPrintingMode(int value) 645 { 646 return setIntParam(CbcPrinting, value); 647 } 648 649 /// Get the printing mode 650 inline int getPrintingMode() const 651 { 652 return getIntParam(CbcPrinting); 653 } 654 655 /** Set the 636 656 \link CbcModel::CbcMaximumSeconds maximum number of seconds \endlink 637 657 desired. 638 658 */ 639 inline bool setMaximumSeconds( double value) { 640 return setDblParam(CbcMaximumSeconds, value); 641 } 642 /** Get the 659 inline bool setMaximumSeconds(double value) 660 { 661 return setDblParam(CbcMaximumSeconds, value); 662 } 663 /** Get the 643 664 \link CbcModel::CbcMaximumSeconds maximum number of seconds \endlink 644 665 desired. 645 666 */ 646 inline double getMaximumSeconds() const { 647 return getDblParam(CbcMaximumSeconds); 648 } 649 /// Current time since start of branchAndbound 650 double getCurrentSeconds() const ; 651 652 /// Return true if maximum time reached 653 bool maximumSecondsReached() const ; 654 655 /** Set the 667 inline double getMaximumSeconds() const 668 { 669 return getDblParam(CbcMaximumSeconds); 670 } 671 /// Current time since start of branchAndbound 672 double getCurrentSeconds() const; 673 674 /// Return true if maximum time reached 675 bool maximumSecondsReached() const; 676 677 /** Set the 656 678 \link CbcModel::CbcIntegerTolerance integrality tolerance \endlink 657 679 */ 658 inline bool setIntegerTolerance( double value) { 659 return setDblParam(CbcIntegerTolerance, value); 660 } 661 /** Get the 680 inline bool setIntegerTolerance(double value) 681 { 682 return setDblParam(CbcIntegerTolerance, value); 683 } 684 /** Get the 662 685 \link CbcModel::CbcIntegerTolerance integrality tolerance \endlink 663 686 */ 664 inline double getIntegerTolerance() const { 665 return getDblParam(CbcIntegerTolerance); 666 } 667 668 /** Set the 687 inline double getIntegerTolerance() const 688 { 689 return getDblParam(CbcIntegerTolerance); 690 } 691 692 /** Set the 669 693 \link CbcModel::CbcInfeasibilityWeight 670 694 weight per integer infeasibility \endlink 671 695 */ 672 inline bool setInfeasibilityWeight( double value) { 673 return setDblParam(CbcInfeasibilityWeight, value); 674 } 675 /** Get the 696 inline bool setInfeasibilityWeight(double value) 697 { 698 return setDblParam(CbcInfeasibilityWeight, value); 699 } 700 /** Get the 676 701 \link CbcModel::CbcInfeasibilityWeight 677 702 weight per integer infeasibility \endlink 678 703 */ 679 inline double getInfeasibilityWeight() const { 680 return getDblParam(CbcInfeasibilityWeight); 681 } 682 683 /** Set the \link CbcModel::CbcAllowableGap allowable gap \endlink 704 inline double getInfeasibilityWeight() const 705 { 706 return getDblParam(CbcInfeasibilityWeight); 707 } 708 709 /** Set the \link CbcModel::CbcAllowableGap allowable gap \endlink 684 710 between the best known solution and the best possible solution. 685 711 */ 686 inline bool setAllowableGap( double value) { 687 return setDblParam(CbcAllowableGap, value); 688 } 689 /** Get the \link CbcModel::CbcAllowableGap allowable gap \endlink 712 inline bool setAllowableGap(double value) 713 { 714 return setDblParam(CbcAllowableGap, value); 715 } 716 /** Get the \link CbcModel::CbcAllowableGap allowable gap \endlink 690 717 between the best known solution and the best possible solution. 691 718 */ 692 inline double getAllowableGap() const { 693 return getDblParam(CbcAllowableGap); 694 } 695 696 /** Set the \link CbcModel::CbcAllowableFractionGap fraction allowable gap \endlink 719 inline double getAllowableGap() const 720 { 721 return getDblParam(CbcAllowableGap); 722 } 723 724 /** Set the \link CbcModel::CbcAllowableFractionGap fraction allowable gap \endlink 697 725 between the best known solution and the best possible solution. 698 726 */ 699 inline bool setAllowableFractionGap( double value) { 700 return setDblParam(CbcAllowableFractionGap, value); 701 } 702 /** Get the \link CbcModel::CbcAllowableFractionGap fraction allowable gap \endlink 727 inline bool setAllowableFractionGap(double value) 728 { 729 return setDblParam(CbcAllowableFractionGap, value); 730 } 731 /** Get the \link CbcModel::CbcAllowableFractionGap fraction allowable gap \endlink 703 732 between the best known solution and the best possible solution. 704 733 */ 705 inline double getAllowableFractionGap() const { 706 return getDblParam(CbcAllowableFractionGap); 707 } 708 /** Set the \link CbcModel::CbcAllowableFractionGap percentage allowable gap \endlink 734 inline double getAllowableFractionGap() const 735 { 736 return getDblParam(CbcAllowableFractionGap); 737 } 738 /** Set the \link CbcModel::CbcAllowableFractionGap percentage allowable gap \endlink 709 739 between the best known solution and the best possible solution. 710 740 */ 711 inline bool setAllowablePercentageGap( double value) { 712 return setDblParam(CbcAllowableFractionGap, value*0.01); 713 } 714 /** Get the \link CbcModel::CbcAllowableFractionGap percentage allowable gap \endlink 741 inline bool setAllowablePercentageGap(double value) 742 { 743 return setDblParam(CbcAllowableFractionGap, value * 0.01); 744 } 745 /** Get the \link CbcModel::CbcAllowableFractionGap percentage allowable gap \endlink 715 746 between the best known solution and the best possible solution. 716 747 */ 717 inline double getAllowablePercentageGap() const { 718 return 100.0*getDblParam(CbcAllowableFractionGap); 719 } 720 /** Set the \link CbcModel::CbcHeuristicGap heuristic gap \endlink 748 inline double getAllowablePercentageGap() const 749 { 750 return 100.0 * getDblParam(CbcAllowableFractionGap); 751 } 752 /** Set the \link CbcModel::CbcHeuristicGap heuristic gap \endlink 721 753 between the best known solution and the best possible solution. 722 754 */ 723 inline bool setHeuristicGap( double value) { 724 return setDblParam(CbcHeuristicGap, value); 725 } 726 /** Get the \link CbcModel::CbcHeuristicGap heuristic gap \endlink 755 inline bool setHeuristicGap(double value) 756 { 757 return setDblParam(CbcHeuristicGap, value); 758 } 759 /** Get the \link CbcModel::CbcHeuristicGap heuristic gap \endlink 727 760 between the best known solution and the best possible solution. 728 761 */ 729 inline double getHeuristicGap() const { 730 return getDblParam(CbcHeuristicGap); 731 } 732 733 /** Set the \link CbcModel::CbcHeuristicFractionGap fraction heuristic gap \endlink 762 inline double getHeuristicGap() const 763 { 764 return getDblParam(CbcHeuristicGap); 765 } 766 767 /** Set the \link CbcModel::CbcHeuristicFractionGap fraction heuristic gap \endlink 734 768 between the best known solution and the best possible solution. 735 769 */ 736 inline bool setHeuristicFractionGap( double value) { 737 return setDblParam(CbcHeuristicFractionGap, value); 738 } 739 /** Get the \link CbcModel::CbcHeuristicFractionGap fraction heuristic gap \endlink 770 inline bool setHeuristicFractionGap(double value) 771 { 772 return setDblParam(CbcHeuristicFractionGap, value); 773 } 774 /** Get the \link CbcModel::CbcHeuristicFractionGap fraction heuristic gap \endlink 740 775 between the best known solution and the best possible solution. 741 776 */ 742 inline double getHeuristicFractionGap() const { 743 return getDblParam(CbcHeuristicFractionGap); 744 } 745 /** Set the 777 inline double getHeuristicFractionGap() const 778 { 779 return getDblParam(CbcHeuristicFractionGap); 780 } 781 /** Set the 746 782 \link CbcModel::CbcCutoffIncrement \endlink 747 783 desired. 748 784 */ 749 inline bool setCutoffIncrement( double value) { 750 return setDblParam(CbcCutoffIncrement, value); 751 } 752 /** Get the 785 inline bool setCutoffIncrement(double value) 786 { 787 return setDblParam(CbcCutoffIncrement, value); 788 } 789 /** Get the 753 790 \link CbcModel::CbcCutoffIncrement \endlink 754 791 desired. 755 792 */ 756 inline double getCutoffIncrement() const { 757 return getDblParam(CbcCutoffIncrement); 758 } 759 /// See if can stop on gap 760 bool canStopOnGap() const; 761 762 /** Pass in target solution and optional priorities. 793 inline double getCutoffIncrement() const 794 { 795 return getDblParam(CbcCutoffIncrement); 796 } 797 /// See if can stop on gap 798 bool canStopOnGap() const; 799 800 /** Pass in target solution and optional priorities. 763 801 If priorities then >0 means only branch if incorrect 764 802 while <0 means branch even if correct. +1 or 1 are 765 803 highest priority */ 766 void setHotstartSolution(const double * solution, const int * priorities = NULL) ; 767 768 /// Set the minimum drop to continue cuts 769 inline void setMinimumDrop(double value) { 770 minimumDrop_ = value; 771 } 772 /// Get the minimum drop to continue cuts 773 inline double getMinimumDrop() const { 774 return minimumDrop_; 775 } 776 777 /** Set the maximum number of cut passes at root node (default 20) 804 void setHotstartSolution(const double *solution, const int *priorities = NULL); 805 806 /// Set the minimum drop to continue cuts 807 inline void setMinimumDrop(double value) 808 { 809 minimumDrop_ = value; 810 } 811 /// Get the minimum drop to continue cuts 812 inline double getMinimumDrop() const 813 { 814 return minimumDrop_; 815 } 816 817 /** Set the maximum number of cut passes at root node (default 20) 778 818 Minimum drop can also be used for fine tuning */ 779 inline void setMaximumCutPassesAtRoot(int value) { 780 maximumCutPassesAtRoot_ = value; 781 } 782 /** Get the maximum number of cut passes at root node */ 783 inline int getMaximumCutPassesAtRoot() const { 784 return maximumCutPassesAtRoot_; 785 } 786 787 /** Set the maximum number of cut passes at other nodes (default 10) 819 inline void setMaximumCutPassesAtRoot(int value) 820 { 821 maximumCutPassesAtRoot_ = value; 822 } 823 /** Get the maximum number of cut passes at root node */ 824 inline int getMaximumCutPassesAtRoot() const 825 { 826 return maximumCutPassesAtRoot_; 827 } 828 829 /** Set the maximum number of cut passes at other nodes (default 10) 788 830 Minimum drop can also be used for fine tuning */ 789 inline void setMaximumCutPasses(int value) { 790 maximumCutPasses_ = value; 791 } 792 /** Get the maximum number of cut passes at other nodes (default 10) */ 793 inline int getMaximumCutPasses() const { 794 return maximumCutPasses_; 795 } 796 /** Get current cut pass number in this round of cuts. 831 inline void setMaximumCutPasses(int value) 832 { 833 maximumCutPasses_ = value; 834 } 835 /** Get the maximum number of cut passes at other nodes (default 10) */ 836 inline int getMaximumCutPasses() const 837 { 838 return maximumCutPasses_; 839 } 840 /** Get current cut pass number in this round of cuts. 797 841 (1 is first pass) */ 798 inline int getCurrentPassNumber() const { 799 return currentPassNumber_; 800 } 801 /** Set current cut pass number in this round of cuts. 842 inline int getCurrentPassNumber() const 843 { 844 return currentPassNumber_; 845 } 846 /** Set current cut pass number in this round of cuts. 802 847 (1 is first pass) */ 803 inline void setCurrentPassNumber(int value) { 804 currentPassNumber_ = value; 805 } 806 807 /** Set the maximum number of candidates to be evaluated for strong 848 inline void setCurrentPassNumber(int value) 849 { 850 currentPassNumber_ = value; 851 } 852 853 /** Set the maximum number of candidates to be evaluated for strong 808 854 branching. 809 855 810 856 A value of 0 disables strong branching. 811 857 */ 812 813 858 void setNumberStrong(int number); 859 /** Get the maximum number of candidates to be evaluated for strong 814 860 branching. 815 861 */ 816 inline int numberStrong() const { 817 return numberStrong_; 818 } 819 /** Set global preferred way to branch 862 inline int numberStrong() const 863 { 864 return numberStrong_; 865 } 866 /** Set global preferred way to branch 820 867 1 down, +1 up, 0 no preference */ 821 inline void setPreferredWay(int value) { 822 preferredWay_ = value; 823 } 824 /** Get the preferred way to branch (default 0) */ 825 inline int getPreferredWay() const { 826 return preferredWay_; 827 } 828 /// Get at which depths to do cuts 829 inline int whenCuts() const { 830 return whenCuts_; 831 } 832 /// Set at which depths to do cuts 833 inline void setWhenCuts(int value) { 834 whenCuts_ = value; 835 } 836 /** Return true if we want to do cuts 868 inline void setPreferredWay(int value) 869 { 870 preferredWay_ = value; 871 } 872 /** Get the preferred way to branch (default 0) */ 873 inline int getPreferredWay() const 874 { 875 return preferredWay_; 876 } 877 /// Get at which depths to do cuts 878 inline int whenCuts() const 879 { 880 return whenCuts_; 881 } 882 /// Set at which depths to do cuts 883 inline void setWhenCuts(int value) 884 { 885 whenCuts_ = value; 886 } 887 /** Return true if we want to do cuts 837 888 If allowForTopOfTree zero then just does on multiples of depth 838 889 if 1 then allows for doing at top of tree 839 890 if 2 then says if cuts allowed anywhere apart from root 840 891 */ 841 842 843 892 bool doCutsNow(int allowForTopOfTree) const; 893 894 /** Set the number of branches before pseudo costs believed 844 895 in dynamic strong branching. 845 896 846 897 A value of 0 disables dynamic strong branching. 847 898 */ 848 849 899 void setNumberBeforeTrust(int number); 900 /** get the number of branches before pseudo costs believed 850 901 in dynamic strong branching. */ 851 inline int numberBeforeTrust() const { 852 return numberBeforeTrust_; 853 } 854 /** Set the number of variables for which to compute penalties 902 inline int numberBeforeTrust() const 903 { 904 return numberBeforeTrust_; 905 } 906 /** Set the number of variables for which to compute penalties 855 907 in dynamic strong branching. 856 908 857 909 A value of 0 disables penalties. 858 910 */ 859 860 911 void setNumberPenalties(int number); 912 /** get the number of variables for which to compute penalties 861 913 in dynamic strong branching. */ 862 inline int numberPenalties() const { 863 return numberPenalties_; 864 } 865 /// Pointer to top of tree 866 inline const CbcFullNodeInfo * topOfTree() const 867 { return topOfTree_;} 868 /// Number of analyze iterations to do 869 inline void setNumberAnalyzeIterations(int number) { 870 numberAnalyzeIterations_ = number; 871 } 872 inline int numberAnalyzeIterations() const { 873 return numberAnalyzeIterations_; 874 } 875 /** Get scale factor to make penalties match strong. 914 inline int numberPenalties() const 915 { 916 return numberPenalties_; 917 } 918 /// Pointer to top of tree 919 inline const CbcFullNodeInfo *topOfTree() const 920 { 921 return topOfTree_; 922 } 923 /// Number of analyze iterations to do 924 inline void setNumberAnalyzeIterations(int number) 925 { 926 numberAnalyzeIterations_ = number; 927 } 928 inline int numberAnalyzeIterations() const 929 { 930 return numberAnalyzeIterations_; 931 } 932 /** Get scale factor to make penalties match strong. 876 933 Should/will be computed */ 877 inline double penaltyScaleFactor() const { 878 return penaltyScaleFactor_; 879 } 880 /** Set scale factor to make penalties match strong. 934 inline double penaltyScaleFactor() const 935 { 936 return penaltyScaleFactor_; 937 } 938 /** Set scale factor to make penalties match strong. 881 939 Should/will be computed */ 882 883 940 void setPenaltyScaleFactor(double value); 941 /** Problem type as set by user or found by analysis. This will be extended 884 942 0  not known 885 943 1  Set partitioning <= … … 888 946 4  all + 1 or all +1 and odd 889 947 */ 890 void inline setProblemType(int number) { 891 problemType_ = number; 892 } 893 inline int problemType() const { 894 return problemType_; 895 } 896 /// Current depth 897 inline int currentDepth() const { 898 return currentDepth_; 899 } 900 901 /// Set how often to scan global cuts 902 void setHowOftenGlobalScan(int number); 903 /// Get how often to scan global cuts 904 inline int howOftenGlobalScan() const { 905 return howOftenGlobalScan_; 906 } 907 /// Original columns as created by integerPresolve or preprocessing 908 inline int * originalColumns() const { 909 return originalColumns_; 910 } 911 /// Set original columns as created by preprocessing 912 void setOriginalColumns(const int * originalColumns, 913 int numberGood=COIN_INT_MAX) ; 914 /// Create conflict cut (well  most of) 915 OsiRowCut * conflictCut(const OsiSolverInterface * solver, bool & localCuts); 916 917 /** Set the print frequency. 948 void inline setProblemType(int number) 949 { 950 problemType_ = number; 951 } 952 inline int problemType() const 953 { 954 return problemType_; 955 } 956 /// Current depth 957 inline int currentDepth() const 958 { 959 return currentDepth_; 960 } 961 962 /// Set how often to scan global cuts 963 void setHowOftenGlobalScan(int number); 964 /// Get how often to scan global cuts 965 inline int howOftenGlobalScan() const 966 { 967 return howOftenGlobalScan_; 968 } 969 /// Original columns as created by integerPresolve or preprocessing 970 inline int *originalColumns() const 971 { 972 return originalColumns_; 973 } 974 /// Set original columns as created by preprocessing 975 void setOriginalColumns(const int *originalColumns, 976 int numberGood = COIN_INT_MAX); 977 /// Create conflict cut (well  most of) 978 OsiRowCut *conflictCut(const OsiSolverInterface *solver, bool &localCuts); 979 980 /** Set the print frequency. 918 981 919 982 Controls the number of nodes evaluated between status prints. … … 922 985 Print frequency has very slight overhead if small. 923 986 */ 924 inline void setPrintFrequency(int number) { 925 printFrequency_ = number; 926 } 927 /// Get the print frequency 928 inline int printFrequency() const { 929 return printFrequency_; 930 } 931 //@} 932 933 // 934 ///@name Methods returning info on how the solution process terminated 935 //@{ 936 /// Are there a numerical difficulties? 937 bool isAbandoned() const; 938 /// Is optimality proven? 939 bool isProvenOptimal() const; 940 /// Is infeasiblity proven (or none better than cutoff)? 941 bool isProvenInfeasible() const; 942 /// Was continuous solution unbounded 943 bool isContinuousUnbounded() const; 944 /// Was continuous solution unbounded 945 bool isProvenDualInfeasible() const; 946 /// Node limit reached? 947 bool isNodeLimitReached() const; 948 /// Time limit reached? 949 bool isSecondsLimitReached() const; 950 /// Solution limit reached? 951 bool isSolutionLimitReached() const; 952 /// Get how many iterations it took to solve the problem. 953 inline int getIterationCount() const { 954 return numberIterations_; 955 } 956 /// Increment how many iterations it took to solve the problem. 957 inline void incrementIterationCount(int value) { 958 numberIterations_ += value; 959 } 960 /// Get how many Nodes it took to solve the problem (including those in complete fathoming B&B inside CLP). 961 inline int getNodeCount() const { 962 return numberNodes_; 963 } 964 /// Increment how many nodes it took to solve the problem. 965 inline void incrementNodeCount(int value) { 966 numberNodes_ += value; 967 } 968 /// Get how many Nodes were enumerated in complete fathoming B&B inside CLP 969 inline int getExtraNodeCount() const { 970 return numberExtraNodes_; 971 } 972 /// Get how many times complete fathoming B&B was done 973 inline int getFathomCount() const { 974 return numberFathoms_; 975 } 976 /** Final status of problem 987 inline void setPrintFrequency(int number) 988 { 989 printFrequency_ = number; 990 } 991 /// Get the print frequency 992 inline int printFrequency() const 993 { 994 return printFrequency_; 995 } 996 //@} 997 998 // 999 ///@name Methods returning info on how the solution process terminated 1000 //@{ 1001 /// Are there a numerical difficulties? 1002 bool isAbandoned() const; 1003 /// Is optimality proven? 1004 bool isProvenOptimal() const; 1005 /// Is infeasiblity proven (or none better than cutoff)? 1006 bool isProvenInfeasible() const; 1007 /// Was continuous solution unbounded 1008 bool isContinuousUnbounded() const; 1009 /// Was continuous solution unbounded 1010 bool isProvenDualInfeasible() const; 1011 /// Node limit reached? 1012 bool isNodeLimitReached() const; 1013 /// Time limit reached? 1014 bool isSecondsLimitReached() const; 1015 /// Solution limit reached? 1016 bool isSolutionLimitReached() const; 1017 /// Get how many iterations it took to solve the problem. 1018 inline int getIterationCount() const 1019 { 1020 return numberIterations_; 1021 } 1022 /// Increment how many iterations it took to solve the problem. 1023 inline void incrementIterationCount(int value) 1024 { 1025 numberIterations_ += value; 1026 } 1027 /// Get how many Nodes it took to solve the problem (including those in complete fathoming B&B inside CLP). 1028 inline int getNodeCount() const 1029 { 1030 return numberNodes_; 1031 } 1032 /// Increment how many nodes it took to solve the problem. 1033 inline void incrementNodeCount(int value) 1034 { 1035 numberNodes_ += value; 1036 } 1037 /// Get how many Nodes were enumerated in complete fathoming B&B inside CLP 1038 inline int getExtraNodeCount() const 1039 { 1040 return numberExtraNodes_; 1041 } 1042 /// Get how many times complete fathoming B&B was done 1043 inline int getFathomCount() const 1044 { 1045 return numberFathoms_; 1046 } 1047 /** Final status of problem 977 1048 Some of these can be found out by is...... functions 978 1049 1 before branchAndBound … … 983 1054 (5 event user programmed event occurred) 984 1055 */ 985 inline int status() const { 986 return status_; 987 } 988 inline void setProblemStatus(int value) { 989 status_ = value; 990 } 991 /** Secondary status of problem 1056 inline int status() const 1057 { 1058 return status_; 1059 } 1060 inline void setProblemStatus(int value) 1061 { 1062 status_ = value; 1063 } 1064 /** Secondary status of problem 992 1065 1 unset (status_ will also be 1) 993 1066 0 search completed with solution … … 1001 1074 8 stopped on iteration limit 1002 1075 */ 1003 inline int secondaryStatus() const { 1004 return secondaryStatus_; 1005 } 1006 inline void setSecondaryStatus(int value) { 1007 secondaryStatus_ = value; 1008 } 1009 /// Are there numerical difficulties (for initialSolve) ? 1010 bool isInitialSolveAbandoned() const ; 1011 /// Is optimality proven (for initialSolve) ? 1012 bool isInitialSolveProvenOptimal() const ; 1013 /// Is primal infeasiblity proven (for initialSolve) ? 1014 bool isInitialSolveProvenPrimalInfeasible() const ; 1015 /// Is dual infeasiblity proven (for initialSolve) ? 1016 bool isInitialSolveProvenDualInfeasible() const ; 1017 1018 //@} 1019 1020 // 1021 /**@name Problem information methods 1076 inline int secondaryStatus() const 1077 { 1078 return secondaryStatus_; 1079 } 1080 inline void setSecondaryStatus(int value) 1081 { 1082 secondaryStatus_ = value; 1083 } 1084 /// Are there numerical difficulties (for initialSolve) ? 1085 bool isInitialSolveAbandoned() const; 1086 /// Is optimality proven (for initialSolve) ? 1087 bool isInitialSolveProvenOptimal() const; 1088 /// Is primal infeasiblity proven (for initialSolve) ? 1089 bool isInitialSolveProvenPrimalInfeasible() const; 1090 /// Is dual infeasiblity proven (for initialSolve) ? 1091 bool isInitialSolveProvenDualInfeasible() const; 1092 1093 //@} 1094 1095 // 1096 /**@name Problem information methods 1022 1097 1023 1098 These methods call the solver's query routines to return … … 1030 1105 long as the data is unchanged and the solver is not called. 1031 1106 */ 1032 //@{ 1033 /// Number of rows in continuous (root) problem. 1034 inline int numberRowsAtContinuous() const { 1035 return numberRowsAtContinuous_; 1036 } 1037 1038 /// Get number of columns 1039 inline int getNumCols() const { 1040 return solver_>getNumCols(); 1041 } 1042 1043 /// Get number of rows 1044 inline int getNumRows() const { 1045 return solver_>getNumRows(); 1046 } 1047 1048 /// Get number of nonzero elements 1049 inline CoinBigIndex getNumElements() const { 1050 return solver_>getNumElements(); 1051 } 1052 1053 /// Number of integers in problem 1054 inline int numberIntegers() const { 1055 return numberIntegers_; 1056 } 1057 // Integer variables 1058 inline const int * integerVariable() const { 1059 return integerVariable_; 1060 } 1061 /// Whether or not integer 1062 inline char integerType(int i) const { 1063 assert (integerInfo_); 1064 assert (integerInfo_[i] == 0  integerInfo_[i] == 1); 1065 return integerInfo_[i]; 1066 } 1067 /// Whether or not integer 1068 inline const char * integerType() const { 1069 return integerInfo_; 1070 } 1071 1072 /// Get pointer to array[getNumCols()] of column lower bounds 1073 inline const double * getColLower() const { 1074 return solver_>getColLower(); 1075 } 1076 1077 /// Get pointer to array[getNumCols()] of column upper bounds 1078 inline const double * getColUpper() const { 1079 return solver_>getColUpper(); 1080 } 1081 1082 /** Get pointer to array[getNumRows()] of row constraint senses. 1107 //@{ 1108 /// Number of rows in continuous (root) problem. 1109 inline int numberRowsAtContinuous() const 1110 { 1111 return numberRowsAtContinuous_; 1112 } 1113 1114 /// Get number of columns 1115 inline int getNumCols() const 1116 { 1117 return solver_>getNumCols(); 1118 } 1119 1120 /// Get number of rows 1121 inline int getNumRows() const 1122 { 1123 return solver_>getNumRows(); 1124 } 1125 1126 /// Get number of nonzero elements 1127 inline CoinBigIndex getNumElements() const 1128 { 1129 return solver_>getNumElements(); 1130 } 1131 1132 /// Number of integers in problem 1133 inline int numberIntegers() const 1134 { 1135 return numberIntegers_; 1136 } 1137 // Integer variables 1138 inline const int *integerVariable() const 1139 { 1140 return integerVariable_; 1141 } 1142 /// Whether or not integer 1143 inline char integerType(int i) const 1144 { 1145 assert(integerInfo_); 1146 assert(integerInfo_[i] == 0  integerInfo_[i] == 1); 1147 return integerInfo_[i]; 1148 } 1149 /// Whether or not integer 1150 inline const char *integerType() const 1151 { 1152 return integerInfo_; 1153 } 1154 1155 /// Get pointer to array[getNumCols()] of column lower bounds 1156 inline const double *getColLower() const 1157 { 1158 return solver_>getColLower(); 1159 } 1160 1161 /// Get pointer to array[getNumCols()] of column upper bounds 1162 inline const double *getColUpper() const 1163 { 1164 return solver_>getColUpper(); 1165 } 1166 1167 /** Get pointer to array[getNumRows()] of row constraint senses. 1083 1168 <ul> 1084 1169 <li>'L': <= constraint … … 1089 1174 </ul> 1090 1175 */ 1091 inline const char * getRowSense() const { 1092 return solver_>getRowSense(); 1093 } 1094 1095 /** Get pointer to array[getNumRows()] of rows righthand sides 1176 inline const char *getRowSense() const 1177 { 1178 return solver_>getRowSense(); 1179 } 1180 1181 /** Get pointer to array[getNumRows()] of rows righthand sides 1096 1182 <ul> 1097 1183 <li> if rowsense()[i] == 'L' then rhs()[i] == rowupper()[i] … … 1101 1187 </ul> 1102 1188 */ 1103 inline const double * getRightHandSide() const { 1104 return solver_>getRightHandSide(); 1105 } 1106 1107 /** Get pointer to array[getNumRows()] of row ranges. 1189 inline const double *getRightHandSide() const 1190 { 1191 return solver_>getRightHandSide(); 1192 } 1193 1194 /** Get pointer to array[getNumRows()] of row ranges. 1108 1195 <ul> 1109 1196 <li> if rowsense()[i] == 'R' then … … 1113 1200 </ul> 1114 1201 */ 1115 inline const double * getRowRange() const { 1116 return solver_>getRowRange(); 1117 } 1118 1119 /// Get pointer to array[getNumRows()] of row lower bounds 1120 inline const double * getRowLower() const { 1121 return solver_>getRowLower(); 1122 } 1123 1124 /// Get pointer to array[getNumRows()] of row upper bounds 1125 inline const double * getRowUpper() const { 1126 return solver_>getRowUpper(); 1127 } 1128 1129 /// Get pointer to array[getNumCols()] of objective function coefficients 1130 inline const double * getObjCoefficients() const { 1131 return solver_>getObjCoefficients(); 1132 } 1133 1134 /// Get objective function sense (1 for min (default), 1 for max) 1135 inline double getObjSense() const { 1136 //assert (dblParam_[CbcOptimizationDirection]== solver_>getObjSense()); 1137 return dblParam_[CbcOptimizationDirection]; 1138 } 1139 1140 /// Return true if variable is continuous 1141 inline bool isContinuous(int colIndex) const { 1142 return solver_>isContinuous(colIndex); 1143 } 1144 1145 /// Return true if variable is binary 1146 inline bool isBinary(int colIndex) const { 1147 return solver_>isBinary(colIndex); 1148 } 1149 1150 /** Return true if column is integer. 1202 inline const double *getRowRange() const 1203 { 1204 return solver_>getRowRange(); 1205 } 1206 1207 /// Get pointer to array[getNumRows()] of row lower bounds 1208 inline const double *getRowLower() const 1209 { 1210 return solver_>getRowLower(); 1211 } 1212 1213 /// Get pointer to array[getNumRows()] of row upper bounds 1214 inline const double *getRowUpper() const 1215 { 1216 return solver_>getRowUpper(); 1217 } 1218 1219 /// Get pointer to array[getNumCols()] of objective function coefficients 1220 inline const double *getObjCoefficients() const 1221 { 1222 return solver_>getObjCoefficients(); 1223 } 1224 1225 /// Get objective function sense (1 for min (default), 1 for max) 1226 inline double getObjSense() const 1227 { 1228 //assert (dblParam_[CbcOptimizationDirection]== solver_>getObjSense()); 1229 return dblParam_[CbcOptimizationDirection]; 1230 } 1231 1232 /// Return true if variable is continuous 1233 inline bool isContinuous(int colIndex) const 1234 { 1235 return solver_>isContinuous(colIndex); 1236 } 1237 1238 /// Return true if variable is binary 1239 inline bool isBinary(int colIndex) const 1240 { 1241 return solver_>isBinary(colIndex); 1242 } 1243 1244 /** Return true if column is integer. 1151 1245 Note: This function returns true if the the column 1152 1246 is binary or a general integer. 1153 1247 */ 1154 inline bool isInteger(int colIndex) const { 1155 return solver_>isInteger(colIndex); 1156 } 1157 1158 /// Return true if variable is general integer 1159 inline bool isIntegerNonBinary(int colIndex) const { 1160 return solver_>isIntegerNonBinary(colIndex); 1161 } 1162 1163 /// Return true if variable is binary and not fixed at either bound 1164 inline bool isFreeBinary(int colIndex) const { 1165 return solver_>isFreeBinary(colIndex) ; 1166 } 1167 1168 /// Get pointer to rowwise copy of matrix 1169 inline const CoinPackedMatrix * getMatrixByRow() const { 1170 return solver_>getMatrixByRow(); 1171 } 1172 1173 /// Get pointer to columnwise copy of matrix 1174 inline const CoinPackedMatrix * getMatrixByCol() const { 1175 return solver_>getMatrixByCol(); 1176 } 1177 1178 /// Get solver's value for infinity 1179 inline double getInfinity() const { 1180 return solver_>getInfinity(); 1181 } 1182 /// Get pointer to array[getNumCols()] (for speed) of column lower bounds 1183 inline const double * getCbcColLower() const { 1184 return cbcColLower_; 1185 } 1186 /// Get pointer to array[getNumCols()] (for speed) of column upper bounds 1187 inline const double * getCbcColUpper() const { 1188 return cbcColUpper_; 1189 } 1190 /// Get pointer to array[getNumRows()] (for speed) of row lower bounds 1191 inline const double * getCbcRowLower() const { 1192 return cbcRowLower_; 1193 } 1194 /// Get pointer to array[getNumRows()] (for speed) of row upper bounds 1195 inline const double * getCbcRowUpper() const { 1196 return cbcRowUpper_; 1197 } 1198 /// Get pointer to array[getNumCols()] (for speed) of primal solution vector 1199 inline const double * getCbcColSolution() const { 1200 return cbcColSolution_; 1201 } 1202 /// Get pointer to array[getNumRows()] (for speed) of dual prices 1203 inline const double * getCbcRowPrice() const { 1204 return cbcRowPrice_; 1205 } 1206 /// Get a pointer to array[getNumCols()] (for speed) of reduced costs 1207 inline const double * getCbcReducedCost() const { 1208 return cbcReducedCost_; 1209 } 1210 /// Get pointer to array[getNumRows()] (for speed) of row activity levels. 1211 inline const double * getCbcRowActivity() const { 1212 return cbcRowActivity_; 1213 } 1214 //@} 1215 1216 1217 /**@name Methods related to querying the solution */ 1218 //@{ 1219 /// Holds solution at continuous (after cuts if branchAndBound called) 1220 inline double * continuousSolution() const { 1221 return continuousSolution_; 1222 } 1223 /** Array marked whenever a solution is found if nonzero. 1248 inline bool isInteger(int colIndex) const 1249 { 1250 return solver_>isInteger(colIndex); 1251 } 1252 1253 /// Return true if variable is general integer 1254 inline bool isIntegerNonBinary(int colIndex) const 1255 { 1256 return solver_>isIntegerNonBinary(colIndex); 1257 } 1258 1259 /// Return true if variable is binary and not fixed at either bound 1260 inline bool isFreeBinary(int colIndex) const 1261 { 1262 return solver_>isFreeBinary(colIndex); 1263 } 1264 1265 /// Get pointer to rowwise copy of matrix 1266 inline const CoinPackedMatrix *getMatrixByRow() const 1267 { 1268 return solver_>getMatrixByRow(); 1269 } 1270 1271 /// Get pointer to columnwise copy of matrix 1272 inline const CoinPackedMatrix *getMatrixByCol() const 1273 { 1274 return solver_>getMatrixByCol(); 1275 } 1276 1277 /// Get solver's value for infinity 1278 inline double getInfinity() const 1279 { 1280 return solver_>getInfinity(); 1281 } 1282 /// Get pointer to array[getNumCols()] (for speed) of column lower bounds 1283 inline const double *getCbcColLower() const 1284 { 1285 return cbcColLower_; 1286 } 1287 /// Get pointer to array[getNumCols()] (for speed) of column upper bounds 1288 inline const double *getCbcColUpper() const 1289 { 1290 return cbcColUpper_; 1291 } 1292 /// Get pointer to array[getNumRows()] (for speed) of row lower bounds 1293 inline const double *getCbcRowLower() const 1294 { 1295 return cbcRowLower_; 1296 } 1297 /// Get pointer to array[getNumRows()] (for speed) of row upper bounds 1298 inline const double *getCbcRowUpper() const 1299 { 1300 return cbcRowUpper_; 1301 } 1302 /// Get pointer to array[getNumCols()] (for speed) of primal solution vector 1303 inline const double *getCbcColSolution() const 1304 { 1305 return cbcColSolution_; 1306 } 1307 /// Get pointer to array[getNumRows()] (for speed) of dual prices 1308 inline const double *getCbcRowPrice() const 1309 { 1310 return cbcRowPrice_; 1311 } 1312 /// Get a pointer to array[getNumCols()] (for speed) of reduced costs 1313 inline const double *getCbcReducedCost() const 1314 { 1315 return cbcReducedCost_; 1316 } 1317 /// Get pointer to array[getNumRows()] (for speed) of row activity levels. 1318 inline const double *getCbcRowActivity() const 1319 { 1320 return cbcRowActivity_; 1321 } 1322 //@} 1323 1324 /**@name Methods related to querying the solution */ 1325 //@{ 1326 /// Holds solution at continuous (after cuts if branchAndBound called) 1327 inline double *continuousSolution() const 1328 { 1329 return continuousSolution_; 1330 } 1331 /** Array marked whenever a solution is found if nonzero. 1224 1332 Code marks if heuristic returns better so heuristic 1225 1333 need only mark if it wants to on solutions which 1226 1334 are worse than current */ 1227 inline int * usedInSolution() const { 1228 return usedInSolution_; 1229 } 1230 /// Increases usedInSolution for nonzeros 1231 void incrementUsed(const double * solution); 1232 /// Record a new incumbent solution and update objectiveValue 1233 void setBestSolution(CBC_Message how, 1234 double & objectiveValue, const double *solution, 1235 int fixVariables = 0); 1236 /// Just update objectiveValue 1237 void setBestObjectiveValue( double objectiveValue); 1238 /// Deals with event handler and solution 1239 CbcEventHandler::CbcAction dealWithEventHandler(CbcEventHandler::CbcEvent event, 1240 double objValue, 1241 const double * solution); 1242 1243 /** Call this to really test if a valid solution can be feasible 1335 inline int *usedInSolution() const 1336 { 1337 return usedInSolution_; 1338 } 1339 /// Increases usedInSolution for nonzeros 1340 void incrementUsed(const double *solution); 1341 /// Record a new incumbent solution and update objectiveValue 1342 void setBestSolution(CBC_Message how, 1343 double &objectiveValue, const double *solution, 1344 int fixVariables = 0); 1345 /// Just update objectiveValue 1346 void setBestObjectiveValue(double objectiveValue); 1347 /// Deals with event handler and solution 1348 CbcEventHandler::CbcAction dealWithEventHandler(CbcEventHandler::CbcEvent event, 1349 double objValue, 1350 const double *solution); 1351 1352 /** Call this to really test if a valid solution can be feasible 1244 1353 Solution is number columns in size. 1245 1354 If fixVariables true then bounds of continuous solver updated. … … 1248 1357 virtual so user can override 1249 1358 */ 1250 virtual double checkSolution(double cutoff, double *solution,1251 1252 1359 virtual double checkSolution(double cutoff, double *solution, 1360 int fixVariables, double originalObjValue); 1361 /** Test the current solution for feasiblility. 1253 1362 1254 1363 Scan all objects for indications of infeasibility. This is broken down … … 1256 1365 and all other reports of infeasibility (\p numberObjectInfeasibilities). 1257 1366 */ 1258 bool feasibleSolution(int &numberIntegerInfeasibilities,1259 int &numberObjectInfeasibilities) const;1260 1261 1367 bool feasibleSolution(int &numberIntegerInfeasibilities, 1368 int &numberObjectInfeasibilities) const; 1369 1370 /** Solution to the most recent lp relaxation. 1262 1371 1263 1372 The solver's solution to the most recent lp relaxation. 1264 1373 */ 1265 1374 1266 inline double * currentSolution() const { 1267 return currentSolution_; 1268 } 1269 /** For testing infeasibilities  will point to 1375 inline double *currentSolution() const 1376 { 1377 return currentSolution_; 1378 } 1379 /** For testing infeasibilities  will point to 1270 1380 currentSolution_ or solver>getColSolution() 1271 1381 */ 1272 inline const double * testSolution() const { 1273 return testSolution_; 1274 } 1275 inline void setTestSolution(const double * solution) { 1276 testSolution_ = solution; 1277 } 1278 /// Make sure region there and optionally copy solution 1279 void reserveCurrentSolution(const double * solution = NULL); 1280 1281 /// Get pointer to array[getNumCols()] of primal solution vector 1282 inline const double * getColSolution() const { 1283 return solver_>getColSolution(); 1284 } 1285 1286 /// Get pointer to array[getNumRows()] of dual prices 1287 inline const double * getRowPrice() const { 1288 return solver_>getRowPrice(); 1289 } 1290 1291 /// Get a pointer to array[getNumCols()] of reduced costs 1292 inline const double * getReducedCost() const { 1293 return solver_>getReducedCost(); 1294 } 1295 1296 /// Get pointer to array[getNumRows()] of row activity levels. 1297 inline const double * getRowActivity() const { 1298 return solver_>getRowActivity(); 1299 } 1300 1301 /// Get current objective function value 1302 inline double getCurrentObjValue() const { 1303 return dblParam_[CbcCurrentObjectiveValue]; 1304 } 1305 /// Get current minimization objective function value 1306 inline double getCurrentMinimizationObjValue() const { 1307 return dblParam_[CbcCurrentMinimizationObjectiveValue]; 1308 } 1309 1310 /// Get best objective function value as minimization 1311 inline double getMinimizationObjValue() const { 1312 return bestObjective_; 1313 } 1314 /// Set best objective function value as minimization 1315 inline void setMinimizationObjValue(double value) { 1316 bestObjective_ = value; 1317 } 1318 1319 /// Get best objective function value 1320 inline double getObjValue() const { 1321 return bestObjective_ * solver_>getObjSense() ; 1322 } 1323 /** Get best possible objective function value. 1382 inline const double *testSolution() const 1383 { 1384 return testSolution_; 1385 } 1386 inline void setTestSolution(const double *solution) 1387 { 1388 testSolution_ = solution; 1389 } 1390 /// Make sure region there and optionally copy solution 1391 void reserveCurrentSolution(const double *solution = NULL); 1392 1393 /// Get pointer to array[getNumCols()] of primal solution vector 1394 inline const double *getColSolution() const 1395 { 1396 return solver_>getColSolution(); 1397 } 1398 1399 /// Get pointer to array[getNumRows()] of dual prices 1400 inline const double *getRowPrice() const 1401 { 1402 return solver_>getRowPrice(); 1403 } 1404 1405 /// Get a pointer to array[getNumCols()] of reduced costs 1406 inline const double *getReducedCost() const 1407 { 1408 return solver_>getReducedCost(); 1409 } 1410 1411 /// Get pointer to array[getNumRows()] of row activity levels. 1412 inline const double *getRowActivity() const 1413 { 1414 return solver_>getRowActivity(); 1415 } 1416 1417 /// Get current objective function value 1418 inline double getCurrentObjValue() const 1419 { 1420 return dblParam_[CbcCurrentObjectiveValue]; 1421 } 1422 /// Get current minimization objective function value 1423 inline double getCurrentMinimizationObjValue() const 1424 { 1425 return dblParam_[CbcCurrentMinimizationObjectiveValue]; 1426 } 1427 1428 /// Get best objective function value as minimization 1429 inline double getMinimizationObjValue() const 1430 { 1431 return bestObjective_; 1432 } 1433 /// Set best objective function value as minimization 1434 inline void setMinimizationObjValue(double value) 1435 { 1436 bestObjective_ = value; 1437 } 1438 1439 /// Get best objective function value 1440 inline double getObjValue() const 1441 { 1442 return bestObjective_ * solver_>getObjSense(); 1443 } 1444 /** Get best possible objective function value. 1324 1445 This is better of best possible left on tree 1325 1446 and best solution found. 1326 1447 If called from within branch and cut may be optimistic. 1327 1448 */ 1328 double getBestPossibleObjValue() const; 1329 /// Set best objective function value 1330 inline void setObjValue(double value) { 1331 bestObjective_ = value * solver_>getObjSense() ; 1332 } 1333 /// Get solver objective function value (as minimization) 1334 inline double getSolverObjValue() const { 1335 return solver_>getObjValue() * solver_>getObjSense() ; 1336 } 1337 1338 /** The best solution to the integer programming problem. 1449 double getBestPossibleObjValue() const; 1450 /// Set best objective function value 1451 inline void setObjValue(double value) 1452 { 1453 bestObjective_ = value * solver_>getObjSense(); 1454 } 1455 /// Get solver objective function value (as minimization) 1456 inline double getSolverObjValue() const 1457 { 1458 return solver_>getObjValue() * solver_>getObjSense(); 1459 } 1460 1461 /** The best solution to the integer programming problem. 1339 1462 1340 1463 The best solution to the integer programming problem found during … … 1342 1465 */ 1343 1466 1344 inline double * bestSolution() const { 1345 return bestSolution_; 1346 } 1347 /** User callable setBestSolution. 1467 inline double *bestSolution() const 1468 { 1469 return bestSolution_; 1470 } 1471 /** User callable setBestSolution. 1348 1472 If check false does not check valid 1349 1473 If true then sees if feasible and warns if objective value … … 1351 1475 If check true then does not save solution if not feasible 1352 1476 */ 1353 void setBestSolution(const double * solution, int numberColumns, 1354 double objectiveValue, bool check = false); 1355 1356 /// Get number of solutions 1357 inline int getSolutionCount() const { 1358 return numberSolutions_; 1359 } 1360 1361 /// Set number of solutions (so heuristics will be different) 1362 inline void setSolutionCount(int value) { 1363 numberSolutions_ = value; 1364 } 1365 /// Number of saved solutions (including best) 1366 int numberSavedSolutions() const; 1367 /// Maximum number of extra saved solutions 1368 inline int maximumSavedSolutions() const { 1369 return maximumSavedSolutions_; 1370 } 1371 /// Set maximum number of extra saved solutions 1372 void setMaximumSavedSolutions(int value); 1373 /// Return a saved solution (0==best)  NULL if off end 1374 const double * savedSolution(int which) const; 1375 /// Return a saved solution objective (0==best)  COIN_DBL_MAX if off end 1376 double savedSolutionObjective(int which) const; 1377 /// Delete a saved solution and move others up 1378 void deleteSavedSolution(int which); 1379 1380 /** Current phase (so heuristics etc etc can find out). 1477 void setBestSolution(const double *solution, int numberColumns, 1478 double objectiveValue, bool check = false); 1479 1480 /// Get number of solutions 1481 inline int getSolutionCount() const 1482 { 1483 return numberSolutions_; 1484 } 1485 1486 /// Set number of solutions (so heuristics will be different) 1487 inline void setSolutionCount(int value) 1488 { 1489 numberSolutions_ = value; 1490 } 1491 /// Number of saved solutions (including best) 1492 int numberSavedSolutions() const; 1493 /// Maximum number of extra saved solutions 1494 inline int maximumSavedSolutions() const 1495 { 1496 return maximumSavedSolutions_; 1497 } 1498 /// Set maximum number of extra saved solutions 1499 void setMaximumSavedSolutions(int value); 1500 /// Return a saved solution (0==best)  NULL if off end 1501 const double *savedSolution(int which) const; 1502 /// Return a saved solution objective (0==best)  COIN_DBL_MAX if off end 1503 double savedSolutionObjective(int which) const; 1504 /// Delete a saved solution and move others up 1505 void deleteSavedSolution(int which); 1506 1507 /** Current phase (so heuristics etc etc can find out). 1381 1508 0  initial solve 1382 1509 1  solve with cuts at root … … 1386 1513 5  at end of search 1387 1514 */ 1388 inline int phase() const { 1389 return phase_; 1390 } 1391 1392 /// Get number of heuristic solutions 1393 inline int getNumberHeuristicSolutions() const { 1394 return numberHeuristicSolutions_; 1395 } 1396 /// Set number of heuristic solutions 1397 inline void setNumberHeuristicSolutions(int value) { 1398 numberHeuristicSolutions_ = value; 1399 } 1400 1401 /// Set objective function sense (1 for min (default), 1 for max,) 1402 inline void setObjSense(double s) { 1403 dblParam_[CbcOptimizationDirection] = s; 1404 solver_>setObjSense(s); 1405 } 1406 1407 /// Value of objective at continuous 1408 inline double getContinuousObjective() const { 1409 return originalContinuousObjective_; 1410 } 1411 inline void setContinuousObjective(double value) { 1412 originalContinuousObjective_ = value; 1413 } 1414 /// Number of infeasibilities at continuous 1415 inline int getContinuousInfeasibilities() const { 1416 return continuousInfeasibilities_; 1417 } 1418 inline void setContinuousInfeasibilities(int value) { 1419 continuousInfeasibilities_ = value; 1420 } 1421 /// Value of objective after root node cuts added 1422 inline double rootObjectiveAfterCuts() const { 1423 return continuousObjective_; 1424 } 1425 /// Sum of Changes to objective by first solve 1426 inline double sumChangeObjective() const { 1427 return sumChangeObjective1_; 1428 } 1429 /** Number of times global cuts violated. When global cut pool then this 1515 inline int phase() const 1516 { 1517 return phase_; 1518 } 1519 1520 /// Get number of heuristic solutions 1521 inline int getNumberHeuristicSolutions() const 1522 { 1523 return numberHeuristicSolutions_; 1524 } 1525 /// Set number of heuristic solutions 1526 inline void setNumberHeuristicSolutions(int value) 1527 { 1528 numberHeuristicSolutions_ = value; 1529 } 1530 1531 /// Set objective function sense (1 for min (default), 1 for max,) 1532 inline void setObjSense(double s) 1533 { 1534 dblParam_[CbcOptimizationDirection] = s; 1535 solver_>setObjSense(s); 1536 } 1537 1538 /// Value of objective at continuous 1539 inline double getContinuousObjective() const 1540 { 1541 return originalContinuousObjective_; 1542 } 1543 inline void setContinuousObjective(double value) 1544 { 1545 originalContinuousObjective_ = value; 1546 } 1547 /// Number of infeasibilities at continuous 1548 inline int getContinuousInfeasibilities() const 1549 { 1550 return continuousInfeasibilities_; 1551 } 1552 inline void setContinuousInfeasibilities(int value) 1553 { 1554 continuousInfeasibilities_ = value; 1555 } 1556 /// Value of objective after root node cuts added 1557 inline double rootObjectiveAfterCuts() const 1558 { 1559 return continuousObjective_; 1560 } 1561 /// Sum of Changes to objective by first solve 1562 inline double sumChangeObjective() const 1563 { 1564 return sumChangeObjective1_; 1565 } 1566 /** Number of times global cuts violated. When global cut pool then this 1430 1567 should be kept for each cut and type of cut */ 1431 inline int numberGlobalViolations() const { 1432 return numberGlobalViolations_; 1433 } 1434 inline void clearNumberGlobalViolations() { 1435 numberGlobalViolations_ = 0; 1436 } 1437 /// Whether to force a resolve after takeOffCuts 1438 inline bool resolveAfterTakeOffCuts() const { 1439 return resolveAfterTakeOffCuts_; 1440 } 1441 inline void setResolveAfterTakeOffCuts(bool yesNo) { 1442 resolveAfterTakeOffCuts_ = yesNo; 1443 } 1444 /// Maximum number of rows 1445 inline int maximumRows() const { 1446 return maximumRows_; 1447 } 1448 /// Work basis for temporary use 1449 inline CoinWarmStartBasis & workingBasis() { 1450 return workingBasis_; 1451 } 1452 /// Get number of "iterations" to stop after 1453 inline int getStopNumberIterations() const { 1454 return stopNumberIterations_; 1455 } 1456 /// Set number of "iterations" to stop after 1457 inline void setStopNumberIterations(int value) { 1458 stopNumberIterations_ = value; 1459 } 1460 /// A pointer to model from CbcHeuristic 1461 inline CbcModel * heuristicModel() const 1462 { return heuristicModel_;} 1463 /// Set a pointer to model from CbcHeuristic 1464 inline void setHeuristicModel(CbcModel * model) 1465 { heuristicModel_ = model;} 1466 //@} 1467 1468 /** \name Node selection */ 1469 //@{ 1470 // Comparison functions (which may be overridden by inheritance) 1471 inline CbcCompareBase * nodeComparison() const { 1472 return nodeCompare_; 1473 } 1474 void setNodeComparison(CbcCompareBase * compare); 1475 void setNodeComparison(CbcCompareBase & compare); 1476 //@} 1477 1478 /** \name Problem feasibility checking */ 1479 //@{ 1480 // Feasibility functions (which may be overridden by inheritance) 1481 inline CbcFeasibilityBase * problemFeasibility() const { 1482 return problemFeasibility_; 1483 } 1484 void setProblemFeasibility(CbcFeasibilityBase * feasibility); 1485 void setProblemFeasibility(CbcFeasibilityBase & feasibility); 1486 //@} 1487 1488 /** \name Tree methods and subtree methods */ 1489 //@{ 1490 /// Tree method e.g. heap (which may be overridden by inheritance) 1491 inline CbcTree * tree() const { 1492 return tree_; 1493 } 1494 /// For modifying tree handling (original is cloned) 1495 void passInTreeHandler(CbcTree & tree); 1496 /** For passing in an CbcModel to do a sub Tree (with derived tree handlers). 1568 inline int numberGlobalViolations() const 1569 { 1570 return numberGlobalViolations_; 1571 } 1572 inline void clearNumberGlobalViolations() 1573 { 1574 numberGlobalViolations_ = 0; 1575 } 1576 /// Whether to force a resolve after takeOffCuts 1577 inline bool resolveAfterTakeOffCuts() const 1578 { 1579 return resolveAfterTakeOffCuts_; 1580 } 1581 inline void setResolveAfterTakeOffCuts(bool yesNo) 1582 { 1583 resolveAfterTakeOffCuts_ = yesNo; 1584 } 1585 /// Maximum number of rows 1586 inline int maximumRows() const 1587 { 1588 return maximumRows_; 1589 } 1590 /// Work basis for temporary use 1591 inline CoinWarmStartBasis &workingBasis() 1592 { 1593 return workingBasis_; 1594 } 1595 /// Get number of "iterations" to stop after 1596 inline int getStopNumberIterations() const 1597 { 1598 return stopNumberIterations_; 1599 } 1600 /// Set number of "iterations" to stop after 1601 inline void setStopNumberIterations(int value) 1602 { 1603 stopNumberIterations_ = value; 1604 } 1605 /// A pointer to model from CbcHeuristic 1606 inline CbcModel *heuristicModel() const 1607 { 1608 return heuristicModel_; 1609 } 1610 /// Set a pointer to model from CbcHeuristic 1611 inline void setHeuristicModel(CbcModel *model) 1612 { 1613 heuristicModel_ = model; 1614 } 1615 //@} 1616 1617 /** \name Node selection */ 1618 //@{ 1619 // Comparison functions (which may be overridden by inheritance) 1620 inline CbcCompareBase *nodeComparison() const 1621 { 1622 return nodeCompare_; 1623 } 1624 void setNodeComparison(CbcCompareBase *compare); 1625 void setNodeComparison(CbcCompareBase &compare); 1626 //@} 1627 1628 /** \name Problem feasibility checking */ 1629 //@{ 1630 // Feasibility functions (which may be overridden by inheritance) 1631 inline CbcFeasibilityBase *problemFeasibility() const 1632 { 1633 return problemFeasibility_; 1634 } 1635 void setProblemFeasibility(CbcFeasibilityBase *feasibility); 1636 void setProblemFeasibility(CbcFeasibilityBase &feasibility); 1637 //@} 1638 1639 /** \name Tree methods and subtree methods */ 1640 //@{ 1641 /// Tree method e.g. heap (which may be overridden by inheritance) 1642 inline CbcTree *tree() const 1643 { 1644 return tree_; 1645 } 1646 /// For modifying tree handling (original is cloned) 1647 void passInTreeHandler(CbcTree &tree); 1648 /** For passing in an CbcModel to do a sub Tree (with derived tree handlers). 1497 1649 Passed in model must exist for duration of branch and bound 1498 1650 */ 1499 void passInSubTreeModel(CbcModel &model);1500 1651 void passInSubTreeModel(CbcModel &model); 1652 /** For retrieving a copy of subtree model with given OsiSolver. 1501 1653 If no subtree model will use self (up to user to reset cutoff etc). 1502 1654 If solver NULL uses current 1503 1655 */ 1504 CbcModel * subTreeModel(OsiSolverInterface * solver = NULL) const; 1505 /// Returns number of times any subtree stopped on nodes, time etc 1506 inline int numberStoppedSubTrees() const { 1507 return numberStoppedSubTrees_; 1508 } 1509 /// Says a sub tree was stopped 1510 inline void incrementSubTreeStopped() { 1511 numberStoppedSubTrees_++; 1512 } 1513 /** Whether to automatically do presolve before branch and bound (subTrees). 1656 CbcModel *subTreeModel(OsiSolverInterface *solver = NULL) const; 1657 /// Returns number of times any subtree stopped on nodes, time etc 1658 inline int numberStoppedSubTrees() const 1659 { 1660 return numberStoppedSubTrees_; 1661 } 1662 /// Says a sub tree was stopped 1663 inline void incrementSubTreeStopped() 1664 { 1665 numberStoppedSubTrees_++; 1666 } 1667 /** Whether to automatically do presolve before branch and bound (subTrees). 1514 1668 0  no 1515 1669 1  ordinary presolve 1516 1670 2  integer presolve (dodgy) 1517 1671 */ 1518 inline int typePresolve() const { 1519 return presolve_; 1520 } 1521 inline void setTypePresolve(int value) { 1522 presolve_ = value; 1523 } 1524 1525 //@} 1526 1527 /** \name Branching Decisions 1672 inline int typePresolve() const 1673 { 1674 return presolve_; 1675 } 1676 inline void setTypePresolve(int value) 1677 { 1678 presolve_ = value; 1679 } 1680 1681 //@} 1682 1683 /** \name Branching Decisions 1528 1684 1529 1685 See the CbcBranchDecision class for additional information. 1530 1686 */ 1531 //@{ 1532 1533 /// Get the current branching decision method. 1534 inline CbcBranchDecision * branchingMethod() const { 1535 return branchingMethod_; 1536 } 1537 /// Set the branching decision method. 1538 inline void setBranchingMethod(CbcBranchDecision * method) { 1539 delete branchingMethod_; 1540 branchingMethod_ = method>clone(); 1541 } 1542 /** Set the branching method 1687 //@{ 1688 1689 /// Get the current branching decision method. 1690 inline CbcBranchDecision *branchingMethod() const 1691 { 1692 return branchingMethod_; 1693 } 1694 /// Set the branching decision method. 1695 inline void setBranchingMethod(CbcBranchDecision *method) 1696 { 1697 delete branchingMethod_; 1698 branchingMethod_ = method>clone(); 1699 } 1700 /** Set the branching method 1543 1701 1544 1702 \overload 1545 1703 */ 1546 inline void setBranchingMethod(CbcBranchDecision & method) { 1547 delete branchingMethod_; 1548 branchingMethod_ = method.clone(); 1549 } 1550 /// Get the current cut modifier method 1551 inline CbcCutModifier * cutModifier() const { 1552 return cutModifier_; 1553 } 1554 /// Set the cut modifier method 1555 void setCutModifier(CbcCutModifier * modifier); 1556 /** Set the cut modifier method 1704 inline void setBranchingMethod(CbcBranchDecision &method) 1705 { 1706 delete branchingMethod_; 1707 branchingMethod_ = method.clone(); 1708 } 1709 /// Get the current cut modifier method 1710 inline CbcCutModifier *cutModifier() const 1711 { 1712 return cutModifier_; 1713 } 1714 /// Set the cut modifier method 1715 void setCutModifier(CbcCutModifier *modifier); 1716 /** Set the cut modifier method 1557 1717 1558 1718 \overload 1559 1719 */ 1560 void setCutModifier(CbcCutModifier &modifier);1561 1562 1563 1564 1565 1566 1720 void setCutModifier(CbcCutModifier &modifier); 1721 //@} 1722 1723 /** \name Row (constraint) and Column (variable) cut generation */ 1724 //@{ 1725 1726 /** State of search 1567 1727 0  no solution 1568 1728 1  only heuristic solutions … … 1570 1730 3  no solution but many nodes 1571 1731 */ 1572 inline int stateOfSearch() const { 1573 return stateOfSearch_; 1574 } 1575 inline void setStateOfSearch(int state) { 1576 stateOfSearch_ = state; 1577 } 1578 /// Strategy worked out  mainly at root node for use by CbcNode 1579 inline int searchStrategy() const { 1580 return searchStrategy_; 1581 } 1582 /// Set strategy worked out  mainly at root node for use by CbcNode 1583 inline void setSearchStrategy(int value) { 1584 searchStrategy_ = value; 1585 } 1586 /// Stong branching strategy 1587 inline int strongStrategy() const { 1588 return strongStrategy_; 1589 } 1590 /// Set strong branching strategy 1591 inline void setStrongStrategy(int value) { 1592 strongStrategy_ = value; 1593 } 1594 1595 /// Get the number of cut generators 1596 inline int numberCutGenerators() const { 1597 return numberCutGenerators_; 1598 } 1599 /// Get the list of cut generators 1600 inline CbcCutGenerator ** cutGenerators() const { 1601 return generator_; 1602 } 1603 ///Get the specified cut generator 1604 inline CbcCutGenerator * cutGenerator(int i) const { 1605 return generator_[i]; 1606 } 1607 ///Get the specified cut generator before any changes 1608 inline CbcCutGenerator * virginCutGenerator(int i) const { 1609 return virginGenerator_[i]; 1610 } 1611 /** Add one generator  up to user to delete generators. 1732 inline int stateOfSearch() const 1733 { 1734 return stateOfSearch_; 1735 } 1736 inline void setStateOfSearch(int state) 1737 { 1738 stateOfSearch_ = state; 1739 } 1740 /// Strategy worked out  mainly at root node for use by CbcNode 1741 inline int searchStrategy() const 1742 { 1743 return searchStrategy_; 1744 } 1745 /// Set strategy worked out  mainly at root node for use by CbcNode 1746 inline void setSearchStrategy(int value) 1747 { 1748 searchStrategy_ = value; 1749 } 1750 /// Stong branching strategy 1751 inline int strongStrategy() const 1752 { 1753 return strongStrategy_; 1754 } 1755 /// Set strong branching strategy 1756 inline void setStrongStrategy(int value) 1757 { 1758 strongStrategy_ = value; 1759 } 1760 1761 /// Get the number of cut generators 1762 inline int numberCutGenerators() const 1763 { 1764 return numberCutGenerators_; 1765 } 1766 /// Get the list of cut generators 1767 inline CbcCutGenerator **cutGenerators() const 1768 { 1769 return generator_; 1770 } 1771 ///Get the specified cut generator 1772 inline CbcCutGenerator *cutGenerator(int i) const 1773 { 1774 return generator_[i]; 1775 } 1776 ///Get the specified cut generator before any changes 1777 inline CbcCutGenerator *virginCutGenerator(int i) const 1778 { 1779 return virginGenerator_[i]; 1780 } 1781 /** Add one generator  up to user to delete generators. 1612 1782 howoften affects how generator is used. 0 or 1 means always, 1613 1783 >1 means every that number of nodes. Negative values have same … … 1617 1787 If depth >0 overrides how often generator is called (if howOften==1 or >0). 1618 1788 */ 1619 void addCutGenerator(CglCutGenerator *generator,1620 int howOften = 1, const char *name = NULL,1621 1622 1623 1624 //@}1625 1789 void addCutGenerator(CglCutGenerator *generator, 1790 int howOften = 1, const char *name = NULL, 1791 bool normal = true, bool atSolution = false, 1792 bool infeasible = false, int howOftenInSub = 100, 1793 int whatDepth = 1, int whatDepthInSub = 1); 1794 //@} 1795 /** \name Strategy and sub models 1626 1796 1627 1797 See the CbcStrategy class for additional information. 1628 1798 */ 1629 //@{ 1630 1631 /// Get the current strategy 1632 inline CbcStrategy * strategy() const { 1633 return strategy_; 1634 } 1635 /// Set the strategy. Clones 1636 void setStrategy(CbcStrategy & strategy); 1637 /// Set the strategy. assigns 1638 inline void setStrategy(CbcStrategy * strategy) { 1639 strategy_ = strategy; 1640 } 1641 /// Get the current parent model 1642 inline CbcModel * parentModel() const { 1643 return parentModel_; 1644 } 1645 /// Set the parent model 1646 inline void setParentModel(CbcModel & parentModel) { 1647 parentModel_ = &parentModel; 1648 } 1649 //@} 1650 1651 1652 /** \name Heuristics and priorities */ 1653 //@{ 1654 /*! \brief Add one heuristic  up to user to delete 1799 //@{ 1800 1801 /// Get the current strategy 1802 inline CbcStrategy *strategy() const 1803 { 1804 return strategy_; 1805 } 1806 /// Set the strategy. Clones 1807 void setStrategy(CbcStrategy &strategy); 1808 /// Set the strategy. assigns 1809 inline void setStrategy(CbcStrategy *strategy) 1810 { 1811 strategy_ = strategy; 1812 } 1813 /// Get the current parent model 1814 inline CbcModel *parentModel() const 1815 { 1816 return parentModel_; 1817 } 1818 /// Set the parent model 1819 inline void setParentModel(CbcModel &parentModel) 1820 { 1821 parentModel_ = &parentModel; 1822 } 1823 //@} 1824 1825 /** \name Heuristics and priorities */ 1826 //@{ 1827 /*! \brief Add one heuristic  up to user to delete 1655 1828 1656 1829 The name is just used for print messages. 1657 1830 */ 1658 void addHeuristic(CbcHeuristic * generator, const char *name = NULL, 1659 int before = 1); 1660 ///Get the specified heuristic 1661 inline CbcHeuristic * heuristic(int i) const { 1662 return heuristic_[i]; 1663 } 1664 /// Get the number of heuristics 1665 inline int numberHeuristics() const { 1666 return numberHeuristics_; 1667 } 1668 /// Set the number of heuristics 1669 inline void setNumberHeuristics(int value) { 1670 numberHeuristics_ = value; 1671 } 1672 /// Pointer to heuristic solver which found last solution (or NULL) 1673 inline CbcHeuristic * lastHeuristic() const { 1674 return lastHeuristic_; 1675 } 1676 /// set last heuristic which found a solution 1677 inline void setLastHeuristic(CbcHeuristic * last) { 1678 lastHeuristic_ = last; 1679 } 1680 1681 /** Pass in branching priorities. 1831 void addHeuristic(CbcHeuristic *generator, const char *name = NULL, 1832 int before = 1); 1833 ///Get the specified heuristic 1834 inline CbcHeuristic *heuristic(int i) const 1835 { 1836 return heuristic_[i]; 1837 } 1838 /// Get the number of heuristics 1839 inline int numberHeuristics() const 1840 { 1841 return numberHeuristics_; 1842 } 1843 /// Set the number of heuristics 1844 inline void setNumberHeuristics(int value) 1845 { 1846 numberHeuristics_ = value; 1847 } 1848 /// Pointer to heuristic solver which found last solution (or NULL) 1849 inline CbcHeuristic *lastHeuristic() const 1850 { 1851 return lastHeuristic_; 1852 } 1853 /// set last heuristic which found a solution 1854 inline void setLastHeuristic(CbcHeuristic *last) 1855 { 1856 lastHeuristic_ = last; 1857 } 1858 1859 /** Pass in branching priorities. 1682 1860 1683 1861 If ifClique then priorities are on cliques otherwise priorities are … … 1697 1875 \internal Added for Kurt Spielberg. 1698 1876 */ 1699 void passInPriorities(const int * priorities, bool ifNotSimpleIntegers); 1700 1701 /// Returns priority level for an object (or 1000 if no priorities exist) 1702 inline int priority(int sequence) const { 1703 return object_[sequence]>priority(); 1704 } 1705 1706 /*! \brief Set an event handler 1877 void passInPriorities(const int *priorities, bool ifNotSimpleIntegers); 1878 1879 /// Returns priority level for an object (or 1000 if no priorities exist) 1880 inline int priority(int sequence) const 1881 { 1882 return object_[sequence]>priority(); 1883 } 1884 1885 /*! \brief Set an event handler 1707 1886 1708 1887 A clone of the handler passed as a parameter is stored in CbcModel. 1709 1888 */ 1710 void passInEventHandler(const CbcEventHandler *eventHandler) ; 1711 1712 /*! \brief Retrieve a pointer to the event handler */ 1713 inline CbcEventHandler* getEventHandler() const { 1714 return (eventHandler_) ; 1715 } 1716 1717 //@} 1718 1719 /**@name Setting/Accessing application data */ 1720 //@{ 1721 /** Set application data. 1889 void passInEventHandler(const CbcEventHandler *eventHandler); 1890 1891 /*! \brief Retrieve a pointer to the event handler */ 1892 inline CbcEventHandler *getEventHandler() const 1893 { 1894 return (eventHandler_); 1895 } 1896 1897 //@} 1898 1899 /**@name Setting/Accessing application data */ 1900 //@{ 1901 /** Set application data. 1722 1902 1723 1903 This is a pointer that the application can store into and … … 1726 1906 define and use. 1727 1907 */ 1728 void setApplicationData (void *appData);1729 1730 1731 void *getApplicationData() const;1732 1908 void setApplicationData(void *appData); 1909 1910 /// Get application data 1911 void *getApplicationData() const; 1912 /** 1733 1913 For advanced applications you may wish to modify the behavior of Cbc 1734 1914 e.g. if the solver is a NLP solver then you may not have an exact … … 1742 1922 NOTE  characteristics are not cloned 1743 1923 */ 1744 void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics); 1745 /// Get solver characteristics 1746 inline const OsiBabSolver * solverCharacteristics() const { 1747 return solverCharacteristics_; 1748 } 1749 //@} 1750 1751 // 1752 1753 /**@name Message handling etc */ 1754 //@{ 1755 /// Pass in Message handler (not deleted at end) 1756 void passInMessageHandler(CoinMessageHandler * handler); 1757 /// Set language 1758 void newLanguage(CoinMessages::Language language); 1759 inline void setLanguage(CoinMessages::Language language) { 1760 newLanguage(language); 1761 } 1762 /// Return handler 1763 inline CoinMessageHandler * messageHandler() const { 1764 return handler_; 1765 } 1766 /// Return messages 1767 inline CoinMessages & messages() { 1768 return messages_; 1769 } 1770 /// Return pointer to messages 1771 inline CoinMessages * messagesPointer() { 1772 return &messages_; 1773 } 1774 /// Set log level 1775 void setLogLevel(int value); 1776 /// Get log level 1777 inline int logLevel() const { 1778 return handler_>logLevel(); 1779 } 1780 /** Set flag to say if handler_ is the default handler. 1924 void passInSolverCharacteristics(OsiBabSolver *solverCharacteristics); 1925 /// Get solver characteristics 1926 inline const OsiBabSolver *solverCharacteristics() const 1927 { 1928 return solverCharacteristics_; 1929 } 1930 //@} 1931 1932 // 1933 1934 /**@name Message handling etc */ 1935 //@{ 1936 /// Pass in Message handler (not deleted at end) 1937 void passInMessageHandler(CoinMessageHandler *handler); 1938 /// Set language 1939 void newLanguage(CoinMessages::Language language); 1940 inline void setLanguage(CoinMessages::Language language) 1941 { 1942 newLanguage(language); 1943 } 1944 /// Return handler 1945 inline CoinMessageHandler *messageHandler() const 1946 { 1947 return handler_; 1948 } 1949 /// Return messages 1950 inline CoinMessages &messages() 1951 { 1952 return messages_; 1953 } 1954 /// Return pointer to messages 1955 inline CoinMessages *messagesPointer() 1956 { 1957 return &messages_; 1958 } 1959 /// Set log level 1960 void setLogLevel(int value); 1961 /// Get log level 1962 inline int logLevel() const 1963 { 1964 return handler_>logLevel(); 1965 } 1966 /** Set flag to say if handler_ is the default handler. 1781 1967 1782 1968 The default handler is deleted when the model is deleted. Other 1783 1969 handlers (supplied by the client) will not be deleted. 1784 1970 */ 1785 inline void setDefaultHandler(bool yesNo) { 1786 defaultHandler_ = yesNo; 1787 } 1788 /// Check default handler 1789 inline bool defaultHandler() const { 1790 return defaultHandler_; 1791 } 1792 //@} 1793 // 1794 ///@name Specialized 1795 //@{ 1796 1797 /** 1971 inline void setDefaultHandler(bool yesNo) 1972 { 1973 defaultHandler_ = yesNo; 1974 } 1975 /// Check default handler 1976 inline bool defaultHandler() const 1977 { 1978 return defaultHandler_; 1979 } 1980 //@} 1981 // 1982 ///@name Specialized 1983 //@{ 1984 1985 /** 1798 1986 Set special options 1799 1987 0 bit (1)  check if cuts valid (if on debugger list) … … 1824 2012 26 bit (67108864)  child model but going for complete search 1825 2013 */ 1826 inline void setSpecialOptions(int value) { 1827 specialOptions_ = value; 1828 } 1829 /// Get special options 1830 inline int specialOptions() const { 1831 return specialOptions_; 1832 } 1833 /// Set random seed 1834 inline void setRandomSeed(int value) { 1835 randomSeed_ = value; 1836 } 1837 /// Get random seed 1838 inline int getRandomSeed() const { 1839 return randomSeed_; 1840 } 1841 /// Set multiple root tries 1842 inline void setMultipleRootTries(int value) { 1843 multipleRootTries_ = value; 1844 } 1845 /// Get multiple root tries 1846 inline int getMultipleRootTries() const { 1847 return multipleRootTries_; 1848 } 1849 /// Tell model to stop on event 1850 inline void sayEventHappened() 1851 { eventHappened_=true;} 1852 /// Says if normal solver i.e. has well defined CoinPackedMatrix 1853 inline bool normalSolver() const { 1854 return (specialOptions_&16) == 0; 1855 } 1856 /** Says if model is sitting there waiting for mini branch and bound to finish 2014 inline void setSpecialOptions(int value) 2015 { 2016 specialOptions_ = value; 2017 } 2018 /// Get special options 2019 inline int specialOptions() const 2020 { 2021 return specialOptions_; 2022 } 2023 /// Set random seed 2024 inline void setRandomSeed(int value) 2025 { 2026 randomSeed_ = value; 2027 } 2028 /// Get random seed 2029 inline int getRandomSeed() const 2030 { 2031 return randomSeed_; 2032 } 2033 /// Set multiple root tries 2034 inline void setMultipleRootTries(int value) 2035 { 2036 multipleRootTries_ = value; 2037 } 2038 /// Get multiple root tries 2039 inline int getMultipleRootTries() const 2040 { 2041 return multipleRootTries_; 2042 } 2043 /// Tell model to stop on event 2044 inline void sayEventHappened() 2045 { 2046 eventHappened_ = true; 2047 } 2048 /// Says if normal solver i.e. has well defined CoinPackedMatrix 2049 inline bool normalSolver() const 2050 { 2051 return (specialOptions_ & 16) == 0; 2052 } 2053 /** Says if model is sitting there waiting for mini branch and bound to finish 1857 2054 This is because an event handler may only have access to parent model in 1858 2055 mini branch and bound 1859 2056 */ 1860 inline bool waitingForMiniBranchAndBound() const { 1861 return (specialOptions_&1048576) != 0; 1862 } 1863 /** Set more special options 2057 inline bool waitingForMiniBranchAndBound() const 2058 { 2059 return (specialOptions_ & 1048576) != 0; 2060 } 2061 /** Set more special options 1864 2062 at present bottom 6 bits used for shadow price mode 1865 2063 1024 for experimental hotstart … … 1884 2082 30 bit (1073741824)  Funny SOS or similar  be careful 1885 2083 */ 1886 inline void setMoreSpecialOptions(int value) { 1887 moreSpecialOptions_ = value; 1888 } 1889 /// Get more special options 1890 inline int moreSpecialOptions() const { 1891 return moreSpecialOptions_; 1892 } 1893 /** Set more more special options 2084 inline void setMoreSpecialOptions(int value) 2085 { 2086 moreSpecialOptions_ = value; 2087 } 2088 /// Get more special options 2089 inline int moreSpecialOptions() const 2090 { 2091 return moreSpecialOptions_; 2092 } 2093 /** Set more more special options 1894 2094 0 bit (1)  find switching variables 1895 2095 1 bit (2)  using fake objective until solution … … 1906 2106 15 bit 32768  take care of very very small values for Integer/SOS variables 1907 2107 */ 1908 inline void setMoreSpecialOptions2(int value) { 1909 moreSpecialOptions2_ = value; 1910 } 1911 /// Get more special options2 1912 inline int moreSpecialOptions2() const { 1913 return moreSpecialOptions2_; 1914 } 1915 /// Set cutoff as constraint 1916 inline void setCutoffAsConstraint(bool yesNo) { 1917 cutoffRowNumber_ = (yesNo) ? 2 : 1; 1918 } 1919 /// Set time method 1920 inline void setUseElapsedTime(bool yesNo) { 1921 if (yesNo) 1922 moreSpecialOptions_ = 131072; 1923 else 1924 moreSpecialOptions_ &= ~131072; 1925 } 1926 /// Get time method 1927 inline bool useElapsedTime() const { 1928 return (moreSpecialOptions_&131072)!=0; 1929 } 1930 /// Get useful temporary pointer 1931 inline void * temporaryPointer() const 1932 { return temporaryPointer_;} 1933 /// Set useful temporary pointer 1934 inline void setTemporaryPointer(void * pointer) 1935 { temporaryPointer_=pointer;} 1936 /// Go to dantzig pivot selection if easy problem (clp only) 1937 void goToDantzig(int numberNodes, ClpDualRowPivot *& savePivotMethod); 1938 /// Now we may not own objects  just point to solver's objects 1939 inline bool ownObjects() const { 1940 return ownObjects_; 1941 } 1942 /// Check original model before it gets messed up 1943 void checkModel(); 1944 //@} 1945 // 1946 1947 ///@name Constructors and destructors etc 1948 //@{ 1949 /// Default Constructor 1950 CbcModel(); 1951 1952 /// Constructor from solver 1953 CbcModel(const OsiSolverInterface &); 1954 1955 /** Assign a solver to the model (model assumes ownership) 2108 inline void setMoreSpecialOptions2(int value) 2109 { 2110 moreSpecialOptions2_ = value; 2111 } 2112 /// Get more special options2 2113 inline int moreSpecialOptions2() const 2114 { 2115 return moreSpecialOptions2_; 2116 } 2117 /// Set cutoff as constraint 2118 inline void setCutoffAsConstraint(bool yesNo) 2119 { 2120 cutoffRowNumber_ = (yesNo) ? 2 : 1; 2121 } 2122 /// Set time method 2123 inline void setUseElapsedTime(bool yesNo) 2124 { 2125 if (yesNo) 2126 moreSpecialOptions_ = 131072; 2127 else 2128 moreSpecialOptions_ &= ~131072; 2129 } 2130 /// Get time method 2131 inline bool useElapsedTime() const 2132 { 2133 return (moreSpecialOptions_ & 131072) != 0; 2134 } 2135 /// Get useful temporary pointer 2136 inline void *temporaryPointer() const 2137 { 2138 return temporaryPointer_; 2139 } 2140 /// Set useful temporary pointer 2141 inline void setTemporaryPointer(void *pointer) 2142 { 2143 temporaryPointer_ = pointer; 2144 } 2145 /// Go to dantzig pivot selection if easy problem (clp only) 2146 void goToDantzig(int numberNodes, ClpDualRowPivot *&savePivotMethod); 2147 /// Now we may not own objects  just point to solver's objects 2148 inline bool ownObjects() const 2149 { 2150 return ownObjects_; 2151 } 2152 /// Check original model before it gets messed up 2153 void checkModel(); 2154 //@} 2155 // 2156 2157 ///@name Constructors and destructors etc 2158 //@{ 2159 /// Default Constructor 2160 CbcModel(); 2161 2162 /// Constructor from solver 2163 CbcModel(const OsiSolverInterface &); 2164 2165 /** Assign a solver to the model (model assumes ownership) 1956 2166 1957 2167 On return, \p solver will be NULL. … … 1961 2171 the incoming solver. 1962 2172 */ 1963 1964 1965 2173 void assignSolver(OsiSolverInterface *&solver, bool deleteSolver = true); 2174 2175 /** \brief Set ownership of solver 1966 2176 1967 2177 A parameter of false tells CbcModel it does not own the solver and … … 1974 2184 and you want to hang on to the answer). 1975 2185 */ 1976 inline void setModelOwnsSolver (bool ourSolver) { 1977 ownership_ = ourSolver ? (ownership_  0x80000000) : (ownership_ & (~0x80000000)) ; 1978 } 1979 1980 /*! \brief Get ownership of solver 2186 inline void setModelOwnsSolver(bool ourSolver) 2187 { 2188 ownership_ = ourSolver ? (ownership_  0x80000000) : (ownership_ & (~0x80000000)); 2189 } 2190 2191 /*! \brief Get ownership of solver 1981 2192 1982 2193 A return value of true means that CbcModel owns the solver and will 1983 2194 take responsibility for deleting it when that becomes necessary. 1984 2195 */ 1985 inline bool modelOwnsSolver () { 1986 return ((ownership_&0x80000000) != 0) ; 1987 } 1988 1989 /** Copy constructor . 2196 inline bool modelOwnsSolver() 2197 { 2198 return ((ownership_ & 0x80000000) != 0); 2199 } 2200 2201 /** Copy constructor . 1990 2202 If cloneHandler is true then message handler is cloned 1991 2203 */ 1992 CbcModel(const CbcModel & rhs, bool cloneHandler = false); 1993 1994 /** Clone */ 1995 virtual CbcModel *clone (bool cloneHandler); 1996 1997 /// Assignment operator 1998 CbcModel & operator=(const CbcModel& rhs); 1999 2000 /// Destructor 2001 virtual ~CbcModel (); 2002 2003 /// Returns solver  has current state 2004 inline OsiSolverInterface * solver() const { 2005 return solver_; 2006 } 2007 2008 /// Returns current solver  sets new one 2009 inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver) { 2010 OsiSolverInterface * returnSolver = solver_; 2011 solver_ = solver; 2012 return returnSolver; 2013 } 2014 2015 /// Returns solver with continuous state 2016 inline OsiSolverInterface * continuousSolver() const { 2017 return continuousSolver_; 2018 } 2019 2020 /// Create solver with continuous state 2021 inline void createContinuousSolver() { 2022 continuousSolver_ = solver_>clone(); 2023 } 2024 /// Clear solver with continuous state 2025 inline void clearContinuousSolver() { 2026 delete continuousSolver_; 2027 continuousSolver_ = NULL; 2028 } 2029 2030 /// A copy of the solver, taken at constructor or by saveReferenceSolver 2031 inline OsiSolverInterface * referenceSolver() const { 2032 return referenceSolver_; 2033 } 2034 2035 /// Save a copy of the current solver so can be reset to 2036 void saveReferenceSolver(); 2037 2038 /** Uses a copy of reference solver to be current solver. 2204 CbcModel(const CbcModel &rhs, bool cloneHandler = false); 2205 2206 /** Clone */ 2207 virtual CbcModel *clone(bool cloneHandler); 2208 2209 /// Assignment operator 2210 CbcModel &operator=(const CbcModel &rhs); 2211 2212 /// Destructor 2213 virtual ~CbcModel(); 2214 2215 /// Returns solver  has current state 2216 inline OsiSolverInterface *solver() const 2217 { 2218 return solver_; 2219 } 2220 2221 /// Returns current solver  sets new one 2222 inline OsiSolverInterface *swapSolver(OsiSolverInterface *solver) 2223 { 2224 OsiSolverInterface *returnSolver = solver_; 2225 solver_ = solver; 2226 return returnSolver; 2227 } 2228 2229 /// Returns solver with continuous state 2230 inline OsiSolverInterface *continuousSolver() const 2231 { 2232 return continuousSolver_; 2233 } 2234 2235 /// Create solver with continuous state 2236 inline void createContinuousSolver() 2237 { 2238 continuousSolver_ = solver_>clone(); 2239 } 2240 /// Clear solver with continuous state 2241 inline void clearContinuousSolver() 2242 { 2243 delete continuousSolver_; 2244 continuousSolver_ = NULL; 2245 } 2246 2247 /// A copy of the solver, taken at constructor or by saveReferenceSolver 2248 inline OsiSolverInterface *referenceSolver() const 2249 { 2250 return referenceSolver_; 2251 } 2252 2253 /// Save a copy of the current solver so can be reset to 2254 void saveReferenceSolver(); 2255 2256 /** Uses a copy of reference solver to be current solver. 2039 2257 Because of possible mismatches all exotic integer information is loat 2040 2258 (apart from normal information in OsiSolverInterface) 2041 2259 so SOS etc and priorities will have to be redone 2042 2260 */ 2043 2044 2045 2046 2047 2261 void resetToReferenceSolver(); 2262 2263 /// Clears out as much as possible (except solver) 2264 void gutsOfDestructor(); 2265 /** Clears out enough to reset CbcModel as if no branch and bound done 2048 2266 */ 2049 2050 2267 void gutsOfDestructor2(); 2268 /** Clears out enough to reset CbcModel cutoff etc 2051 2269 */ 2052 2053 2270 void resetModel(); 2271 /** Most of copy constructor 2054 2272 mode  0 copy but don't delete before 2055 2273 1 copy and delete before 2056 2274 2 copy and delete before (but use virgin generators) 2057 2275 */ 2058 void gutsOfCopy(const CbcModel & rhs, int mode = 0); 2059 /// Move status, nodes etc etc across 2060 void moveInfo(const CbcModel & rhs); 2061 //@} 2062 2063 ///@name Multithreading 2064 //@{ 2065 /// Indicates whether Cbc library has been compiled with multithreading support 2066 static bool haveMultiThreadSupport(); 2067 /// Get pointer to masterthread 2068 CbcThread * masterThread() const { 2069 return masterThread_; 2070 } 2071 /// Get pointer to walkback 2072 CbcNodeInfo ** walkback() const { 2073 return walkback_; 2074 } 2075 /// Get number of threads 2076 inline int getNumberThreads() const { 2077 return numberThreads_; 2078 } 2079 /// Set number of threads 2080 inline void setNumberThreads(int value) { 2081 numberThreads_ = value; 2082 } 2083 /// Get thread mode 2084 inline int getThreadMode() const { 2085 return threadMode_; 2086 } 2087 /** Set thread mode 2276 void gutsOfCopy(const CbcModel &rhs, int mode = 0); 2277 /// Move status, nodes etc etc across 2278 void moveInfo(const CbcModel &rhs); 2279 //@} 2280 2281 ///@name Multithreading 2282 //@{ 2283 /// Indicates whether Cbc library has been compiled with multithreading support 2284 static bool haveMultiThreadSupport(); 2285 /// Get pointer to masterthread 2286 CbcThread *masterThread() const 2287 { 2288 return masterThread_; 2289 } 2290 /// Get pointer to walkback 2291 CbcNodeInfo **walkback() const 2292 { 2293 return walkback_; 2294 } 2295 /// Get number of threads 2296 inline int getNumberThreads() const 2297 { 2298 return numberThreads_; 2299 } 2300 /// Set number of threads 2301 inline void setNumberThreads(int value) 2302 { 2303 numberThreads_ = value; 2304 } 2305 /// Get thread mode 2306 inline int getThreadMode() const 2307 { 2308 return threadMode_; 2309 } 2310 /** Set thread mode 2088 2311 always use numberThreads for branching 2089 2312 1 set then deterministic … … 2094 2317 default is 0 2095 2318 */ 2096 inline void setThreadMode(int value) { 2097 threadMode_ = value; 2098 } 2099 /** Return 2319 inline void setThreadMode(int value) 2320 { 2321 threadMode_ = value; 2322 } 2323 /** Return 2100 2324 2 if deterministic threaded and main thread 2101 2325 1 if deterministic threaded and serial thread … … 2103 2327 1 if opportunistic threaded 2104 2328 */ 2105 inline int parallelMode() const {2106 if (!numberThreads_){2107 if ((threadMode_&1) == 0)2108 return 0;2109 else2110 return 1;2111 return 0;2112 } else {2113 if ((threadMode_&1) == 0)2114 return 1;2115 else2116 return 2;2117 }2329 inline int parallelMode() const 2330 { 2331 if (!numberThreads_) { 2332 if ((threadMode_ & 1) == 0) 2333 return 0; 2334 else 2335 return 1; 2336 return 0; 2337 } else { 2338 if ((threadMode_ & 1) == 0) 2339 return 1; 2340 else 2341 return 2; 2118 2342 } 2119 /// Thread stuff for master 2120 inline CbcBaseModel * master() const 2121 { return master_;} 2122 /// From here to end of section  code in CbcThread.cpp until class changed 2123 /// Returns true if locked 2124 bool isLocked() const; 2343 } 2344 /// Thread stuff for master 2345 inline CbcBaseModel *master() const 2346 { 2347 return master_; 2348 } 2349 /// From here to end of section  code in CbcThread.cpp until class changed 2350 /// Returns true if locked 2351 bool isLocked() const; 2125 2352 #ifdef CBC_THREAD 2126 2353 /** 2127 2354 Locks a thread if parallel so that stuff like cut pool 2128 2355 can be updated and/or used. 2129 2356 */ 2130 2131 2357 void lockThread(); 2358 /** 2132 2359 Unlocks a thread if parallel to say cut pool stuff not needed 2133 2360 */ 2134 2361 void unlockThread(); 2135 2362 #else 2136 inline void lockThread() {} 2137 inline void unlockThread() {} 2363 inline void lockThread() 2364 { 2365 } 2366 inline void unlockThread() {} 2138 2367 #endif 2139 2368 /** Set information in a child 2140 2369 3 pass pointer to child thread info 2141 2370 2 just stop … … 2144 2373 1 delete deterministic child stuff 2145 2374 */ 2146 void setInfoInChild(int type, CbcThread *info);2147 2375 void setInfoInChild(int type, CbcThread *info); 2376 /** Move/copy information from one model to another 2148 2377 1  initialization 2149 2378 0  from base model … … 2151 2380 2  add in final statistics etc (and reset so can do clean destruction) 2152 2381 */ 2153 void moveToModel(CbcModel * baseModel, int mode); 2154 /// Split up nodes 2155 int splitModel(int numberModels, CbcModel ** model, 2156 int numberNodes); 2157 /// Start threads 2158 void startSplitModel(int numberIterations); 2159 /// Merge models 2160 void mergeModels(int numberModel, CbcModel ** model, 2161 int numberNodes); 2162 //@} 2163 2164 ///@name semiprivate i.e. users should not use 2165 //@{ 2166 /// Get how many Nodes it took to solve the problem. 2167 int getNodeCount2() const { 2168 return numberNodes2_; 2169 } 2170 /// Set pointers for speed 2171 void setPointers(const OsiSolverInterface * solver); 2172 /** Perform reduced cost fixing 2382 void moveToModel(CbcModel *baseModel, int mode); 2383 /// Split up nodes 2384 int splitModel(int numberModels, CbcModel **model, 2385 int numberNodes); 2386 /// Start threads 2387 void startSplitModel(int numberIterations); 2388 /// Merge models 2389 void mergeModels(int numberModel, CbcModel **model, 2390 int numberNodes); 2391 //@} 2392 2393 ///@name semiprivate i.e. users should not use 2394 //@{ 2395 /// Get how many Nodes it took to solve the problem. 2396 int getNodeCount2() const 2397 { 2398 return numberNodes2_; 2399 } 2400 /// Set pointers for speed 2401 void setPointers(const OsiSolverInterface *solver); 2402 /** Perform reduced cost fixing 2173 2403 2174 2404 Fixes integer variables at their current value based on reduced cost 2175 2405 penalties. Returns number fixed 2176 2406 */ 2177 int reducedCostFix();2178 2407 int reducedCostFix(); 2408 /** Makes all handlers same. If makeDefault 1 then makes top level 2179 2409 default and rest point to that. If 2 then each is copy 2180 2410 */ 2181 2182 2183 void saveExtraSolution(const double *solution, double objectiveValue);2184 2185 void saveBestSolution(const double *solution, double objectiveValue);2186 2187 2188 2189 int resolve(OsiSolverInterface *solver);2411 void synchronizeHandlers(int makeDefault); 2412 /// Save a solution to saved list 2413 void saveExtraSolution(const double *solution, double objectiveValue); 2414 /// Save a solution to best and move current to saved 2415 void saveBestSolution(const double *solution, double objectiveValue); 2416 /// Delete best and saved solutions 2417 void deleteSolutions(); 2418 /// Encapsulates solver resolve 2419 int resolve(OsiSolverInterface *solver); 2190 2420 #ifdef CLP_RESOLVE 2191 2192 int resolveClp(OsiClpSolverInterface *solver, int type);2421 /// Special purpose resolve 2422 int resolveClp(OsiClpSolverInterface *solver, int type); 2193 2423 #endif 2194 2424 2195 2425 /** Encapsulates choosing a variable  2196 2426 anyAction 2, infeasible (1 round again), 0 done 2197 2427 */ 2198 int chooseBranch(CbcNode * &newNode, int numberPassesLeft,2199 CbcNode * oldNode, OsiCuts &cuts,2200 bool &resolved, CoinWarmStartBasis *lastws,2201 const double * lowerBefore, const double *upperBefore,2202 OsiSolverBranch * &branches);2203 int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool &resolved);2204 2205 2428 int chooseBranch(CbcNode *&newNode, int numberPassesLeft, 2429 CbcNode *oldNode, OsiCuts &cuts, 2430 bool &resolved, CoinWarmStartBasis *lastws, 2431 const double *lowerBefore, const double *upperBefore, 2432 OsiSolverBranch *&branches); 2433 int chooseBranch(CbcNode *newNode, int numberPassesLeft, bool &resolved); 2434 2435 /** Return an empty basis object of the specified size 2206 2436 2207 2437 A useful utility when constructing a basis for a subproblem from scratch. … … 2209 2439 the solver attached to the model. 2210 2440 */ 2211 CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const;2212 2213 2441 CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const; 2442 2443 /** Remove inactive cuts from the model 2214 2444 2215 2445 An OsiSolverInterface is expected to maintain a valid basis, but not a … … 2222 2452 on exit current cuts will be correct. Returns number dropped 2223 2453 */ 2224 2225 bool allowResolve, OsiCuts *saveCuts,2226 int numberNewCuts = 0, const OsiRowCut ** newCuts = NULL);2227 2228 2454 int takeOffCuts(OsiCuts &cuts, 2455 bool allowResolve, OsiCuts *saveCuts, 2456 int numberNewCuts = 0, const OsiRowCut **newCuts = NULL); 2457 2458 /** Determine and install the active cuts that need to be added for 2229 2459 the current subproblem 2230 2460 … … 2238 2468 2239 2469 */ 2240 int addCuts(CbcNode *node, CoinWarmStartBasis *&lastws);2241 2242 2470 int addCuts(CbcNode *node, CoinWarmStartBasis *&lastws); 2471 2472 /** Traverse the tree from node to root and prep the model 2243 2473 2244 2474 addCuts1() begins the job of prepping the model to match the current … … 2256 2486 bounds and building a basis goes to waste. 2257 2487 */ 2258 bool addCuts1(CbcNode *node, CoinWarmStartBasis *&lastws);2259 2488 bool addCuts1(CbcNode *node, CoinWarmStartBasis *&lastws); 2489 /** Returns bounds just before where  initially original bounds. 2260 2490 Also sets downstream nodes (lower if force 1, upper if 2) 2261 2491 */ 2262 void previousBounds (CbcNode * node, CbcNodeInfo *where, int iColumn,2263 double & lower, double &upper, int force);2264 2492 void previousBounds(CbcNode *node, CbcNodeInfo *where, int iColumn, 2493 double &lower, double &upper, int force); 2494 /** Set objective value in a node. This is separated out so that 2265 2495 odd solvers can use. It may look at extra information in 2266 2496 solverCharacteriscs_ and will also use bound from parent node 2267 2497 */ 2268 void setObjectiveValue(CbcNode * thisNode, const CbcNode *parentNode) const;2269 2270 2498 void setObjectiveValue(CbcNode *thisNode, const CbcNode *parentNode) const; 2499 2500 /** If numberBeforeTrust >0 then we are going to use CbcBranchDynamic. 2271 2501 Scan and convert CbcSimpleInteger objects 2272 2502 */ 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2503 void convertToDynamic(); 2504 /// Set numberBeforeTrust in all objects 2505 void synchronizeNumberBeforeTrust(int type = 0); 2506 /// Zap integer information in problem (may leave object info) 2507 void zapIntegerInformation(bool leaveObjects = true); 2508 /// Use cliques for pseudocost information  return nonzero if infeasible 2509 int cliquePseudoCosts(int doStatistics); 2510 /// Fill in useful estimates 2511 void pseudoShadow(int type); 2512 /** Return pseudo costs 2283 2513 If not all integers or not pseudo costs  returns all zero 2284 2514 Length of arrays are numberIntegers() and entries … … 2286 2516 User must allocate arrays before call 2287 2517 */ 2288 void fillPseudoCosts(double * downCosts, double *upCosts,2289 int *priority = NULL,2290 int * numberDown = NULL, int *numberUp = NULL,2291 int *numberDownInfeasible = NULL,2292 int *numberUpInfeasible = NULL) const;2293 2518 void fillPseudoCosts(double *downCosts, double *upCosts, 2519 int *priority = NULL, 2520 int *numberDown = NULL, int *numberUp = NULL, 2521 int *numberDownInfeasible = NULL, 2522 int *numberUpInfeasible = NULL) const; 2523 /** Do heuristics at root. 2294 2524 0  don't delete 2295 2525 1  delete 2296 2526 2  just delete  don't even use 2297 2527 */ 2298 void doHeuristicsAtRoot(int deleteHeuristicsAfterwards = 0); 2299 /// Adjust heuristics based on model 2300 void adjustHeuristics(); 2301 /// Get the hotstart solution 2302 inline const double * hotstartSolution() const { 2303 return hotstartSolution_; 2304 } 2305 /// Get the hotstart priorities 2306 inline const int * hotstartPriorities() const { 2307 return hotstartPriorities_; 2308 } 2309 2310 /// Return the list of cuts initially collected for this subproblem 2311 inline CbcCountRowCut ** addedCuts() const { 2312 return addedCuts_; 2313 } 2314 /// Number of entries in the list returned by #addedCuts() 2315 inline int currentNumberCuts() const { 2316 return currentNumberCuts_; 2317 } 2318 /// Global cuts 2319 inline CbcRowCuts * globalCuts() { 2320 return &globalCuts_; 2321 } 2322 /// Get rid of global cuts 2323 inline void zapGlobalCuts() { 2324 globalCuts_ = CbcRowCuts(); 2325 } 2326 /// Copy and set a pointer to a row cut which will be added instead of normal branching. 2327 void setNextRowCut(const OsiRowCut & cut); 2328 /// Get a pointer to current node (be careful) 2329 inline CbcNode * currentNode() const { 2330 return currentNode_; 2331 } 2332 /// Get a pointer to probing info 2333 inline CglTreeProbingInfo * probingInfo() const { 2334 return probingInfo_; 2335 } 2336 /// Thread specific random number generator 2337 inline CoinThreadRandom * randomNumberGenerator() { 2338 return &randomNumberGenerator_; 2339 } 2340 /// Set the number of iterations done in strong branching. 2341 inline void setNumberStrongIterations(int number) { 2342 numberStrongIterations_ = number; 2343 } 2344 /// Get the number of iterations done in strong branching. 2345 inline int numberStrongIterations() const { 2346 return numberStrongIterations_; 2347 } 2348 /// Get maximum number of iterations (designed to be used in heuristics) 2349 inline int maximumNumberIterations() const { 2350 return maximumNumberIterations_; 2351 } 2352 /// Set maximum number of iterations (designed to be used in heuristics) 2353 inline void setMaximumNumberIterations(int value) { 2354 maximumNumberIterations_ = value; 2355 } 2528 void doHeuristicsAtRoot(int deleteHeuristicsAfterwards = 0); 2529 /// Adjust heuristics based on model 2530 void adjustHeuristics(); 2531 /// Get the hotstart solution 2532 inline const double *hotstartSolution() const 2533 { 2534 return hotstartSolution_; 2535 } 2536 /// Get the hotstart priorities 2537 inline const int *hotstartPriorities() const 2538 { 2539 return hotstartPriorities_; 2540 } 2541 2542 /// Return the list of cuts initially collected for this subproblem 2543 inline CbcCountRowCut **addedCuts() const 2544 { 2545 return addedCuts_; 2546 } 2547 /// Number of entries in the list returned by #addedCuts() 2548 inline int currentNumberCuts() const 2549 { 2550 return currentNumberCuts_; 2551 } 2552 /// Global cuts 2553 inline CbcRowCuts *globalCuts() 2554 { 2555 return &globalCuts_; 2556 } 2557 /// Get rid of global cuts 2558 inline void zapGlobalCuts() 2559 { 2560 globalCuts_ = CbcRowCuts(); 2561 } 2562 /// Copy and set a pointer to a row cut which will be added instead of normal branching. 2563 void setNextRowCut(const OsiRowCut &cut); 2564 /// Get a pointer to current node (be careful) 2565 inline CbcNode *currentNode() const 2566 { 2567 return currentNode_; 2568 } 2569 /// Get a pointer to probing info 2570 inline CglTreeProbingInfo *probingInfo() const 2571 { 2572 return probingInfo_; 2573 } 2574 /// Thread specific random number generator 2575 inline CoinThreadRandom *randomNumberGenerator() 2576 { 2577 return &randomNumberGenerator_; 2578 } 2579 /// Set the number of iterations done in strong branching. 2580 inline void setNumberStrongIterations(int number) 2581 { 2582 numberStrongIterations_ = number; 2583 } 2584 /// Get the number of iterations done in strong branching. 2585 inline int numberStrongIterations() const 2586 { 2587 return numberStrongIterations_; 2588 } 2589 /// Get maximum number of iterations (designed to be used in heuristics) 2590 inline int maximumNumberIterations() const 2591 { 2592 return maximumNumberIterations_; 2593 } 2594 /// Set maximum number of iterations (designed to be used in heuristics) 2595 inline void setMaximumNumberIterations(int value) 2596 { 2597 maximumNumberIterations_ = value; 2598 } 2356 2599 #ifdef COIN_HAS_NTY 2357 /// Symmetry information 2358 inline CbcSymmetry * symmetryInfo() const 2359 { return symmetryInfo_;} 2360 /// get rid of all 2361 void zapSymmetry(); 2600 /// Symmetry information 2601 inline CbcSymmetry *symmetryInfo() const 2602 { 2603 return symmetryInfo_; 2604 } 2605 /// get rid of all 2606 void zapSymmetry(); 2362 2607 #endif 2363 /// Set depth for fast nodes 2364 inline void setFastNodeDepth(int value) { 2365 fastNodeDepth_ = value; 2366 } 2367 /// Get depth for fast nodes 2368 inline int fastNodeDepth() const { 2369 return fastNodeDepth_; 2370 } 2371 /// Get anything with priority >= this can be treated as continuous 2372 inline int continuousPriority() const { 2373 return continuousPriority_; 2374 } 2375 /// Set anything with priority >= this can be treated as continuous 2376 inline void setContinuousPriority(int value) { 2377 continuousPriority_ = value; 2378 } 2379 inline void incrementExtra(int nodes, int iterations, int fathoms=1) { 2380 numberExtraNodes_ += nodes; 2381 numberExtraIterations_ += iterations; 2382 numberFathoms_ += fathoms; 2383 } 2384 /// Zero extra 2385 inline void zeroExtra() { 2386 numberExtraNodes_ = 0; 2387 numberExtraIterations_ = 0; 2388 numberFathoms_ = 0; 2389 } 2390 /// Number of extra iterations 2391 inline int numberExtraIterations() const { 2392 return numberExtraIterations_; 2393 } 2394 /// Increment strong info 2395 void incrementStrongInfo(int numberTimes, int numberIterations, 2396 int numberFixed, bool ifInfeasible); 2397 /// Return strong info 2398 inline const int * strongInfo() const { 2399 return strongInfo_; 2400 } 2401 2402 /// Return mutable strong info 2403 inline int * mutableStrongInfo() { 2404 return strongInfo_; 2405 } 2406 /// Get stored row cuts for donor/recipient CbcModel 2407 CglStored * storedRowCuts() const { 2408 return storedRowCuts_; 2409 } 2410 /// Set stored row cuts for donor/recipient CbcModel 2411 void setStoredRowCuts(CglStored * cuts) { 2412 storedRowCuts_ = cuts; 2413 } 2414 /// Says whether all dynamic integers 2415 inline bool allDynamic () const { 2416 return ((ownership_&0x40000000) != 0) ; 2417 } 2418 /// Create C++ lines to get to current state 2419 void generateCpp( FILE * fp, int options); 2420 /// Generate an OsiBranchingInformation object 2421 OsiBranchingInformation usefulInformation() const; 2422 /** Warm start object produced by heuristic or strong branching 2608 /// Set depth for fast nodes 2609 inline void setFastNodeDepth(int value) 2610 { 2611 fastNodeDepth_ = value; 2612 } 2613 /// Get depth for fast nodes 2614 inline int fastNodeDepth() const 2615 { 2616 return fastNodeDepth_; 2617 } 2618 /// Get anything with priority >= this can be treated as continuous 2619 inline int continuousPriority() const 2620 { 2621 return continuousPriority_; 2622 } 2623 /// Set anything with priority >= this can be treated as continuous 2624 inline void setContinuousPriority(int value) 2625 { 2626 continuousPriority_ = value; 2627 } 2628 inline void incrementExtra(int nodes, int iterations, int fathoms = 1) 2629 { 2630 numberExtraNodes_ += nodes; 2631 numberExtraIterations_ += iterations; 2632 numberFathoms_ += fathoms; 2633 } 2634 /// Zero extra 2635 inline void zeroExtra() 2636 { 2637 numberExtraNodes_ = 0; 2638 numberExtraIterations_ = 0; 2639 numberFathoms_ = 0; 2640 } 2641 /// Number of extra iterations 2642 inline int numberExtraIterations() const 2643 { 2644 return numberExtraIterations_; 2645 } 2646 /// Increment strong info 2647 void incrementStrongInfo(int numberTimes, int numberIterations, 2648 int numberFixed, bool ifInfeasible); 2649 /// Return strong info 2650 inline const int *strongInfo() const 2651 { 2652 return strongInfo_; 2653 } 2654 2655 /// Return mutable strong info 2656 inline int *mutableStrongInfo() 2657 { 2658 return strongInfo_; 2659 } 2660 /// Get stored row cuts for donor/recipient CbcModel 2661 CglStored *storedRowCuts() const 2662 { 2663 return storedRowCuts_; 2664 } 2665 /// Set stored row cuts for donor/recipient CbcModel 2666 void setStoredRowCuts(CglStored *cuts) 2667 { 2668 storedRowCuts_ = cuts; 2669 } 2670 /// Says whether all dynamic integers 2671 inline bool allDynamic() const 2672 { 2673 return ((ownership_ & 0x40000000) != 0); 2674 } 2675 /// Create C++ lines to get to current state 2676 void generateCpp(FILE *fp, int options); 2677 /// Generate an OsiBranchingInformation object 2678 OsiBranchingInformation usefulInformation() const; 2679 /** Warm start object produced by heuristic or strong branching 2423 2680 2424 2681 If get a valid integer solution outside branch and bound then it can take … … 2426 2683 any size then it will be used in solve. 2427 2684 */ 2428 inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis) { 2429 bestSolutionBasis_ = bestSolutionBasis; 2430 } 2431 /// Redo walkback arrays 2432 void redoWalkBack(); 2433 //@} 2434 2435 void setMIPStart( const std::vector< std::pair< std::string, double > > &mips ) { 2436 this>mipStart_ = mips; 2437 } 2438 2439 /** may be safer to use this overload method: c++ string libraries 2685 inline void setBestSolutionBasis(const CoinWarmStartBasis &bestSolutionBasis) 2686 { 2687 bestSolutionBasis_ = bestSolutionBasis; 2688 } 2689 /// Redo walkback arrays 2690 void redoWalkBack(); 2691 //@} 2692 2693 void setMIPStart(const std::vector<std::pair<std::string, double>> &mips) 2694 { 2695 this>mipStart_ = mips; 2696 } 2697 2698 /** may be safer to use this overload method: c++ string libraries 2440 2699 * implementation may not be binary compatible */ 2441 void setMIPStart( int count, const char **colNames, const double colValues[]);2442 2443 const std::vector< std::pair< std::string, double > > &getMIPStart() {2444 return this>mipStart_;2445 }2446 2447 2448 //2700 void setMIPStart(int count, const char **colNames, const double colValues[]); 2701 2702 const std::vector<std::pair<std::string, double>> &getMIPStart() 2703 { 2704 return this>mipStart_; 2705 } 2706 2707 // 2449 2708 2450 2709 private: 2451 2452 2453 2454 2455 OsiSolverInterface *solver_;2456 2457 2710 ///@name Private member data 2711 //@{ 2712 2713 /// The solver associated with this model. 2714 OsiSolverInterface *solver_; 2715 2716 /** Ownership of objects and other stuff 2458 2717 2459 2718 0x80000000 model owns solver 2460 2719 0x40000000 all variables CbcDynamicPseudoCost 2461 2720 */ 2462 unsigned int ownership_;2463 2464 2465 OsiSolverInterface *continuousSolver_;2466 2467 2468 OsiSolverInterface *referenceSolver_;2469 2470 2471 CoinMessageHandler *handler_;2472 2473 2721 unsigned int ownership_; 2722 2723 /// A copy of the solver, taken at the continuous (root) node. 2724 OsiSolverInterface *continuousSolver_; 2725 2726 /// A copy of the solver, taken at constructor or by saveReferenceSolver 2727 OsiSolverInterface *referenceSolver_; 2728 2729 /// Message handler 2730 CoinMessageHandler *handler_; 2731 2732 /** Flag to say if handler_ is the default handler. 2474 2733 2475 2734 The default handler is deleted when the model is deleted. Other 2476 2735 handlers (supplied by the client) will not be deleted. 2477 2736 */ 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2737 bool defaultHandler_; 2738 2739 /// Cbc messages 2740 CoinMessages messages_; 2741 2742 /// Array for integer parameters 2743 int intParam_[CbcLastIntParam]; 2744 2745 /// Array for double parameters 2746 double dblParam_[CbcLastDblParam]; 2747 2748 /** Pointer to an empty warm start object 2490 2749 2491 2750 It turns out to be useful to have this available as a base from … … 2495 2754 start. See getEmptyBasis for an example of how this field can be used. 2496 2755 */ 2497 mutable CoinWarmStart *emptyWarmStart_;2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 double *bestSolution_;2510 2511 double **savedSolutions_;2512 2513 2756 mutable CoinWarmStart *emptyWarmStart_; 2757 2758 /// Best objective 2759 double bestObjective_; 2760 /// Best possible objective 2761 double bestPossibleObjective_; 2762 /// Sum of Changes to objective by first solve 2763 double sumChangeObjective1_; 2764 /// Sum of Changes to objective by subsequent solves 2765 double sumChangeObjective2_; 2766 2767 /// Array holding the incumbent (best) solution. 2768 double *bestSolution_; 2769 /// Arrays holding other solutions. 2770 double **savedSolutions_; 2771 2772 /** Array holding the current solution. 2514 2773 2515 2774 This array is used more as a temporary. 2516 2775 */ 2517 double *currentSolution_;2518 2776 double *currentSolution_; 2777 /** For testing infeasibilities  will point to 2519 2778 currentSolution_ or solver>getColSolution() 2520 2779 */ 2521 mutable const double *testSolution_;2522 2780 mutable const double *testSolution_; 2781 /** MIPstart values 2523 2782 values for integer variables which will be converted to a complete integer initial feasible solution 2524 2783 */ 2525 std::vector< std::pair< std::string, double >> mipStart_;2526 2784 std::vector<std::pair<std::string, double>> mipStart_; 2785 /** Warm start object produced by heuristic or strong branching 2527 2786 2528 2787 If get a valid integer solution outside branch and bound then it can take … … 2530 2789 any size then it will be used in solve. 2531 2790 */ 2532 CoinWarmStartBasis bestSolutionBasis_;2533 2534 2535 2536 CbcRowCuts *globalConflictCuts_;2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2791 CoinWarmStartBasis bestSolutionBasis_; 2792 /// Global cuts 2793 CbcRowCuts globalCuts_; 2794 /// Global conflict cuts 2795 CbcRowCuts *globalConflictCuts_; 2796 2797 /// Minimum degradation in objective value to continue cut generation 2798 double minimumDrop_; 2799 /// Number of solutions 2800 int numberSolutions_; 2801 /// Number of saved solutions 2802 int numberSavedSolutions_; 2803 /// Maximum number of saved solutions 2804 int maximumSavedSolutions_; 2805 /** State of search 2547 2806 0  no solution 2548 2807 1  only heuristic solutions … … 2550 2809 3  no solution but many nodes 2551 2810 */ 2552 2553 2554 2555 2556 double *hotstartSolution_;2557 2558 int *hotstartPriorities_;2559 2560 2561 2562 2563 2811 int stateOfSearch_; 2812 /// At which depths to do cuts 2813 int whenCuts_; 2814 /// Hotstart solution 2815 double *hotstartSolution_; 2816 /// Hotstart priorities 2817 int *hotstartPriorities_; 2818 /// Number of heuristic solutions 2819 int numberHeuristicSolutions_; 2820 /// Cumulative number of nodes 2821 int numberNodes_; 2822 /** Cumulative number of nodes for statistics. 2564 2823 Must fix to match up 2565 2824 */ 2566 2567 2568 2569 2570 2571 2572 2573 2825 int numberNodes2_; 2826 /// Cumulative number of iterations 2827 int numberIterations_; 2828 /// Cumulative number of solves 2829 int numberSolves_; 2830 /// Status of problem  0 finished, 1 stopped, 2 difficulties 2831 int status_; 2832 /** Secondary status of problem 2574 2833 1 unset (status_ will also be 1) 2575 2834 0 search completed with solution … … 2581 2840 6 stopped on solutions 2582 2841 */ 2583 2584 2585 2586 2587 2588 2842 int secondaryStatus_; 2843 /// Number of integers in problem 2844 int numberIntegers_; 2845 /// Number of rows at continuous 2846 int numberRowsAtContinuous_; 2847 /** 2589 2848 1  cutoff as constraint not activated 2590 2849 2  waiting to activate 2591 2850 >=0  activated 2592 2851 */ 2593 2594 2595 2596 2852 int cutoffRowNumber_; 2853 /// Maximum number of cuts 2854 int maximumNumberCuts_; 2855 /** Current phase (so heuristics etc etc can find out). 2597 2856 0  initial solve 2598 2857 1  solve with cuts at root … … 2602 2861 5  at end of search 2603 2862 */ 2604 2605 2606 2607 2608 2609 2863 int phase_; 2864 2865 /// Number of entries in #addedCuts_ 2866 int currentNumberCuts_; 2867 2868 /** Current limit on search tree depth 2610 2869 2611 2870 The allocated size of #walkback_. Increased as needed. 2612 2871 */ 2613 2614 2872 int maximumDepth_; 2873 /** Array used to assemble the path between a node and the search tree root 2615 2874 2616 2875 The array is resized when necessary. #maximumDepth_ is the current 2617 2876 allocated size. 2618 2877 */ 2619 CbcNodeInfo **walkback_;2620 2621 CglPreProcess *preProcess_;2622 CbcNodeInfo **lastNodeInfo_;2623 const OsiRowCut **lastCut_;2624 2625 2626 2627 int *lastNumberCuts_;2628 2629 2878 CbcNodeInfo **walkback_; 2879 /// preProcess used before branch and bound (optional) 2880 CglPreProcess *preProcess_; 2881 CbcNodeInfo **lastNodeInfo_; 2882 const OsiRowCut **lastCut_; 2883 int lastDepth_; 2884 int lastNumberCuts2_; 2885 int maximumCuts_; 2886 int *lastNumberCuts_; 2887 2888 /** The list of cuts initially collected for this subproblem 2630 2889 2631 2890 When the subproblem at this node is rebuilt, a set of cuts is collected … … 2634 2893 entry is set to NULL. 2635 2894 */ 2636 CbcCountRowCut **addedCuts_;2637 2638 2895 CbcCountRowCut **addedCuts_; 2896 2897 /** A pointer to a row cut which will be added instead of normal branching. 2639 2898 After use it should be set to NULL. 2640 2899 */ 2641 OsiRowCut *nextRowCut_;2642 2643 2644 CbcNode *currentNode_;2645 2646 2647 int *integerVariable_;2648 2649 char *integerInfo_;2650 2651 double *continuousSolution_;2652 2653 int *usedInSolution_;2654 2900 OsiRowCut *nextRowCut_; 2901 2902 /// Current node so can be used elsewhere 2903 CbcNode *currentNode_; 2904 2905 /// Indices of integer variables 2906 int *integerVariable_; 2907 /// Whether of not integer 2908 char *integerInfo_; 2909 /// Holds solution at continuous (after cuts) 2910 double *continuousSolution_; 2911 /// Array marked whenever a solution is found if nonzero 2912 int *usedInSolution_; 2913 /** 2655 2914 Special options 2656 2915 0 bit (1)  check if cuts valid (if on debugger list) … … 2679 2938 24 bit (16777216)  just get feasible if no cutoff 2680 2939 */ 2681 2682 2940 int specialOptions_; 2941 /** More special options 2683 2942 at present bottom 6 bits used for shadow price mode 2684 2943 1024 for experimental hotstart … … 2694 2953 21 bit (2097152)  Reduce sum of infeasibilities after cuts 2695 2954 */ 2696 2697 2955 int moreSpecialOptions_; 2956 /** More more special options 2698 2957 0 bit (1)  find switching variables 2699 2958 1 bit (2)  using fake objective until solution … … 2708 2967 11/12 bit 2048  intermittent cuts 2709 2968 */ 2710 2711 2712 CbcCompareBase *nodeCompare_;2713 2714 CbcFeasibilityBase *problemFeasibility_;2715 2716 CbcTree *tree_;2717 2718 CbcFullNodeInfo *topOfTree_;2719 2720 CbcModel *subTreeModel_;2721 2722 CbcModel *heuristicModel_;2723 2724 2725 2726 CbcBranchDecision *branchingMethod_;2727 2728 CbcCutModifier *cutModifier_;2729 2730 CbcStrategy *strategy_;2731 2732 CbcModel *parentModel_;2733 2969 int moreSpecialOptions2_; 2970 /// User node comparison function 2971 CbcCompareBase *nodeCompare_; 2972 /// User feasibility function (see CbcFeasibleBase.hpp) 2973 CbcFeasibilityBase *problemFeasibility_; 2974 /// Tree 2975 CbcTree *tree_; 2976 /// Pointer to top of tree 2977 CbcFullNodeInfo *topOfTree_; 2978 /// A pointer to model to be used for subtrees 2979 CbcModel *subTreeModel_; 2980 /// A pointer to model from CbcHeuristic 2981 CbcModel *heuristicModel_; 2982 /// Number of times any subtree stopped on nodes, time etc 2983 int numberStoppedSubTrees_; 2984 /// Variable selection function 2985 CbcBranchDecision *branchingMethod_; 2986 /// Cut modifier function 2987 CbcCutModifier *cutModifier_; 2988 /// Strategy 2989 CbcStrategy *strategy_; 2990 /// Parent model 2991 CbcModel *parentModel_; 2992 /** Whether to automatically do presolve before branch and bound. 2734 2993 0  no 2735 2994 1  ordinary presolve 2736 2995 2  integer presolve (dodgy) 2737 2996 */ 2738 2739 const double *cbcColLower_;2740 2741 const double *cbcColUpper_;2742 2743 const double *cbcRowLower_;2744 2745 const double *cbcRowUpper_;2746 2747 const double *cbcColSolution_;2748 2749 const double *cbcRowPrice_;2750 2751 const double *cbcReducedCost_;2752 2753 const double *cbcRowActivity_;2754 2755 void *appData_;2756 2757 2758 2997 /// Pointer to array[getNumCols()] (for speed) of column lower bounds 2998 const double *cbcColLower_; 2999 /// Pointer to array[getNumCols()] (for speed) of column upper bounds 3000 const double *cbcColUpper_; 3001 /// Pointer to array[getNumRows()] (for speed) of row lower bounds 3002 const double *cbcRowLower_; 3003 /// Pointer to array[getNumRows()] (for speed) of row upper bounds 3004 const double *cbcRowUpper_; 3005 /// Pointer to array[getNumCols()] (for speed) of primal solution vector 3006 const double *cbcColSolution_; 3007 /// Pointer to array[getNumRows()] (for speed) of dual prices 3008 const double *cbcRowPrice_; 3009 /// Get a pointer to array[getNumCols()] (for speed) of reduced costs 3010 const double *cbcReducedCost_; 3011 /// Pointer to array[getNumRows()] (for speed) of row activity levels. 3012 const double *cbcRowActivity_; 3013 /// Pointer to userdefined data structure 3014 void *appData_; 3015 /// Presolve for CbcTreeLocal 3016 int presolve_; 3017 /** Maximum number of candidates to consider for strong branching. 2759 3018 To disable strong branching, set this to 0. 2760 3019 */ 2761 2762 3020 int numberStrong_; 3021 /** \brief The number of branches before pseudo costs believed 2763 3022 in dynamic strong branching. 2764 3023 2765 3024 A value of 0 is off. 2766 3025 */ 2767 2768 3026 int numberBeforeTrust_; 3027 /** \brief The number of variables for which to compute penalties 2769 3028 in dynamic strong branching. 2770 3029 */ 2771 2772 2773 2774 3030 int numberPenalties_; 3031 /// For threads  stop after this many "iterations" 3032 int stopNumberIterations_; 3033 /** Scale factor to make penalties match strong. 2775 3034 Should/will be computed */ 2776 2777 2778 2779 2780 double *analyzeResults_;2781 2782 void *temporaryPointer_;2783 2784 2785 3035 double penaltyScaleFactor_; 3036 /// Number of analyze iterations to do 3037 int numberAnalyzeIterations_; 3038 /// Arrays with analysis results 3039 double *analyzeResults_; 3040 /// Useful temporary pointer 3041 void *temporaryPointer_; 3042 /// Number of nodes infeasible by normal branching (before cuts) 3043 int numberInfeasibleNodes_; 3044 /** Problem type as set by user or found by analysis. This will be extended 2786 3045 0  not known 2787 3046 1  Set partitioning <= … … 2789 3048 3  Set covering 2790 3049 */ 2791 2792 2793 2794 2795 2796 2797 CbcCutGenerator **generator_;2798 2799 CbcCutGenerator **virginGenerator_;2800 2801 2802 2803 CbcHeuristic **heuristic_;2804 2805 CbcHeuristic *lastHeuristic_;2806 2807 2808 2809 # 2810 ClpEventHandler *eventHandler_;2811 # 2812 CbcEventHandler *eventHandler_;2813 # 2814 2815 CbcSymmetry *symmetryInfo_;2816 2817 2818 2819 3050 int problemType_; 3051 /// Print frequency 3052 int printFrequency_; 3053 /// Number of cut generators 3054 int numberCutGenerators_; 3055 // Cut generators 3056 CbcCutGenerator **generator_; 3057 // Cut generators before any changes 3058 CbcCutGenerator **virginGenerator_; 3059 /// Number of heuristics 3060 int numberHeuristics_; 3061 /// Heuristic solvers 3062 CbcHeuristic **heuristic_; 3063 /// Pointer to heuristic solver which found last solution (or NULL) 3064 CbcHeuristic *lastHeuristic_; 3065 /// Depth for fast nodes 3066 int fastNodeDepth_; 3067 /*! Pointer to the event handler */ 3068 #ifdef CBC_ONLY_CLP 3069 ClpEventHandler *eventHandler_; 3070 #else 3071 CbcEventHandler *eventHandler_; 3072 #endif 3073 /// Symmetry information 3074 CbcSymmetry *symmetryInfo_; 3075 /// Total number of objects 3076 int numberObjects_; 3077 3078 /** \brief Integer and Clique and ... information 2820 3079 2821 3080 \note The code assumes that the first objects on the list will be … … 2827 3086 objects. 2828 3087 */ 2829 OsiObject **object_;2830 2831 2832 2833 2834 int *originalColumns_;2835 2836 2837 3088 OsiObject **object_; 3089 /// Now we may not own objects  just point to solver's objects 3090 bool ownObjects_; 3091 3092 /// Original columns as created by integerPresolve or preprocessing 3093 int *originalColumns_; 3094 /// How often to scan global cuts 3095 int howOftenGlobalScan_; 3096 /** Number of times global cuts violated. When global cut pool then this 2838 3097 should be kept for each cut and type of cut */ 2839 2840 2841 2842 2843 2844 2845 2846 3098 int numberGlobalViolations_; 3099 /// Number of extra iterations in fast lp 3100 int numberExtraIterations_; 3101 /// Number of extra nodes in fast lp 3102 int numberExtraNodes_; 3103 /// Number of times fast lp entered 3104 int numberFathoms_; 3105 /** Value of objective at continuous 2847 3106 (Well actually after initial round of cuts) 2848 3107 */ 2849 2850 2851 */ 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 int *whichGenerator_;2879 2880 2881 2882 CbcStatistics **statistics_;2883 2884 2885 2886 2887 2888 CglTreeProbingInfo *probingInfo_;2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 3108 double continuousObjective_; 3109 /** Value of objective before root node cuts added 3110 */ 3111 double originalContinuousObjective_; 3112 /// Number of infeasibilities at continuous 3113 int continuousInfeasibilities_; 3114 /// Maximum number of cut passes at root 3115 int maximumCutPassesAtRoot_; 3116 /// Maximum number of cut passes 3117 int maximumCutPasses_; 3118 /// Preferred way of branching 3119 int preferredWay_; 3120 /// Current cut pass number 3121 int currentPassNumber_; 3122 /// Maximum number of cuts (for whichGenerator_) 3123 int maximumWhich_; 3124 /// Maximum number of rows 3125 int maximumRows_; 3126 /// Random seed 3127 int randomSeed_; 3128 /// Multiple root tries 3129 int multipleRootTries_; 3130 /// Current depth 3131 int currentDepth_; 3132 /// Thread specific random number generator 3133 mutable CoinThreadRandom randomNumberGenerator_; 3134 /// Work basis for temporary use 3135 CoinWarmStartBasis workingBasis_; 3136 /// Which cut generator generated this cut 3137 int *whichGenerator_; 3138 /// Maximum number of statistics 3139 int maximumStatistics_; 3140 /// statistics 3141 CbcStatistics **statistics_; 3142 /// Maximum depth reached 3143 int maximumDepthActual_; 3144 /// Number of reduced cost fixings 3145 double numberDJFixed_; 3146 /// Probing info 3147 CglTreeProbingInfo *probingInfo_; 3148 /// Number of fixed by analyze at root 3149 int numberFixedAtRoot_; 3150 /// Number fixed by analyze so far 3151 int numberFixedNow_; 3152 /// Whether stopping on gap 3153 bool stoppedOnGap_; 3154 /// Whether event happened 3155 mutable bool eventHappened_; 3156 /// Number of long strong goes 3157 int numberLongStrong_; 3158 /// Number of old active cuts 3159 int numberOldActiveCuts_; 3160 /// Number of new cuts 3161 int numberNewCuts_; 3162 /// Strategy worked out  mainly at root node 3163 int searchStrategy_; 3164 /** Strategy for strong branching 2906 3165 0  normal 2907 3166 when to do all fractional … … 2914 3173 If >=100 then do when depth <= strategy/100 (otherwise 5) 2915 3174 */ 2916 2917 2918 2919 3175 int strongStrategy_; 3176 /// Number of iterations in strong branching 3177 int numberStrongIterations_; 3178 /** 0  number times strong branching done, 1  number fixed, 2  number infeasible 2920 3179 Second group of three is a snapshot at node [6] */ 2921 2922 3180 int strongInfo_[7]; 3181 /** 2923 3182 For advanced applications you may wish to modify the behavior of Cbc 2924 3183 e.g. if the solver is a NLP solver then you may not have an exact … … 2926 3185 For actually saving/restoring a solution you need the actual solver one. 2927 3186 */ 2928 OsiBabSolver *solverCharacteristics_;2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 CbcObjectUpdateData *updateItems_;2941 2942 CglStored *storedRowCuts_;2943 3187 OsiBabSolver *solverCharacteristics_; 3188 /// Whether to force a resolve after takeOffCuts 3189 bool resolveAfterTakeOffCuts_; 3190 /// Maximum number of iterations (designed to be used in heuristics) 3191 int maximumNumberIterations_; 3192 /// Anything with priority >= this can be treated as continuous 3193 int continuousPriority_; 3194 /// Number of outstanding update information items 3195 int numberUpdateItems_; 3196 /// Maximum number of outstanding update information items 3197 int maximumNumberUpdateItems_; 3198 /// Update items 3199 CbcObjectUpdateData *updateItems_; 3200 /// Stored row cuts for donor/recipient CbcModel 3201 CglStored *storedRowCuts_; 3202 /** 2944 3203 Parallel 2945 3204 0  off … … 2948 3207 other special meanings 2949 3208 */ 2950 2951 3209 int numberThreads_; 3210 /** thread mode 2952 3211 always use numberThreads for branching 2953 3212 1 set then deterministic … … 2956 3215 default is 0 2957 3216 */ 2958 2959 2960 2961 2962 CbcBaseModel *master_;2963 2964 CbcThread *masterThread_;2965 //@}3217 int threadMode_; 3218 /// Number of global cuts on entry to a node 3219 int numberGlobalCutsIn_; 3220 /// Thread stuff for master 3221 CbcBaseModel *master_; 3222 /// Pointer to masterthread 3223 CbcThread *masterThread_; 3224 //@} 2966 3225 }; 2967 3226 /// So we can use osiObject or CbcObject during transition 2968 void getIntegerInformation(const OsiObject * object, double &originalLower,2969 double & originalUpper);3227 void getIntegerInformation(const OsiObject *object, double &originalLower, 3228 double &originalUpper); 2970 3229 // So we can call from other programs 2971 3230 // Real main program 2972 3231 class OsiClpSolverInterface; 2973 int CbcMain (int argc, const char *argv[], OsiClpSolverInterface & solver, CbcModel **babSolver);2974 int CbcMain (int argc, const char *argv[], CbcModel &babSolver);3232 int CbcMain(int argc, const char *argv[], OsiClpSolverInterface &solver, CbcModel **babSolver); 3233 int CbcMain(int argc, const char *argv[], CbcModel &babSolver); 2975 3234 // four ways of calling 2976 int callCbc(const char * input2, OsiClpSolverInterface&solver1);2977 int callCbc(const char * 2978 int callCbc(const std::string input2, OsiClpSolverInterface &solver1);2979 int callCbc(const std::string input2) 3235 int callCbc(const char *input2, OsiClpSolverInterface &solver1); 3236 int callCbc(const char *input2); 3237 int callCbc(const std::string input2, OsiClpSolverInterface &solver1); 3238 int callCbc(const std::string input2); 2980 3239 // When we want to load up CbcModel with options first 2981 void CbcMain0 (CbcModel &babSolver);2982 int CbcMain1 (int argc, const char *argv[], CbcModel &babSolver);3240 void CbcMain0(CbcModel &babSolver); 3241 int CbcMain1(int argc, const char *argv[], CbcModel &babSolver); 2983 3242 // two ways of calling 2984 int callCbc(const char * input2, CbcModel &babSolver);2985 int callCbc(const std::string input2, CbcModel & 3243 int callCbc(const char *input2, CbcModel &babSolver); 3244 int callCbc(const std::string input2, CbcModel &babSolver); 2986 3245 // And when CbcMain0 already called to initialize 2987 int callCbc1(const char * input2, CbcModel &babSolver);2988 int callCbc1(const std::string input2, CbcModel & 3246 int callCbc1(const char *input2, CbcModel &babSolver); 3247 int callCbc1(const std::string input2, CbcModel &babSolver); 2989 3248 // And when CbcMain0 already called to initialize (with call back) (see CbcMain1 for whereFrom) 2990 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel *currentSolver, int whereFrom));2991 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel *currentSolver, int whereFrom));2992 int CbcMain1 (int argc, const char *argv[], CbcModel & babSolver, int (CbcModel *currentSolver, int whereFrom));3249 int callCbc1(const char *input2, CbcModel &babSolver, int(CbcModel *currentSolver, int whereFrom)); 3250 int callCbc1(const std::string input2, CbcModel &babSolver, int(CbcModel *currentSolver, int whereFrom)); 3251 int CbcMain1(int argc, const char *argv[], CbcModel &babSolver, int(CbcModel *currentSolver, int whereFrom)); 2993 3252 // For uniform setting of cut and heuristic options 2994 void setCutAndHeuristicOptions(CbcModel & 3253 void setCutAndHeuristicOptions(CbcModel &model); 2995 3254 #endif 2996
Note: See TracChangeset
for help on using the changeset viewer.