/build/buildd/coinor-cbc-2.5.0/debian/tmp/usr/include/coin/CbcNode.hpp
Go to the documentation of this file.
00001 /* $Id: CbcNode.hpp 1400 2009-12-11 14:14:06Z lou $ */
00002 // Copyright (C) 2002, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
00004 #ifndef CbcNode_H
00005 #define CbcNode_H
00006 
00007 #include <string>
00008 #include <vector>
00009 
00010 #include "CoinWarmStartBasis.hpp"
00011 #include "CoinSearchTree.hpp"
00012 #include "CbcBranchBase.hpp"
00013 #include "CbcNodeInfo.hpp"
00014 #include "CbcFullNodeInfo.hpp"
00015 #include "CbcPartialNodeInfo.hpp"
00016 
00017 class OsiSolverInterface;
00018 class OsiSolverBranch;
00019 
00020 class OsiCuts;
00021 class OsiRowCut;
00022 class OsiRowCutDebugger;
00023 class CoinWarmStartBasis;
00024 class CbcCountRowCut;
00025 class CbcModel;
00026 class CbcNode;
00027 class CbcSubProblem;
00028 class CbcGeneralBranchingObject;
00029 
00047 class CbcNode : public CoinTreeNode {
00048 
00049 public:
00050 
00052     CbcNode ();
00053 
00055     CbcNode (CbcModel * model, CbcNode * lastNode);
00056 
00058     CbcNode (const CbcNode &);
00059 
00061     CbcNode & operator= (const CbcNode& rhs);
00062 
00064     ~CbcNode ();
00065 
00081     void
00082     createInfo(CbcModel * model,
00083                CbcNode * lastNode,
00084                const CoinWarmStartBasis *lastws,
00085                const double * lastLower, const double * lastUpper,
00086                int numberOldActiveCuts, int numberNewCuts);
00087 
00108     int chooseBranch (CbcModel * model,
00109                       CbcNode * lastNode,
00110                       int numberPassesLeft);
00136     int chooseDynamicBranch (CbcModel * model,
00137                              CbcNode * lastNode,
00138                              OsiSolverBranch * & branches,
00139                              int numberPassesLeft);
00166     int chooseOsiBranch (CbcModel * model,
00167                          CbcNode * lastNode,
00168                          OsiBranchingInformation * usefulInfo,
00169                          int branchState);
00185     int chooseClpBranch (CbcModel * model,
00186                          CbcNode * lastNode);
00187     int analyze(CbcModel * model, double * results);
00189     void decrementCuts(int change = 1);
00190 
00192     void decrementParentCuts(CbcModel * model, int change = 1);
00193 
00195     void nullNodeInfo();
00204     void initializeInfo();
00205 
00207     int branch(OsiSolverInterface * solver);
00208 
00212     double checkIsCutoff(double cutoff);
00213     // Information to make basis and bounds
00214     inline CbcNodeInfo * nodeInfo() const {
00215         return nodeInfo_;
00216     }
00217 
00218     // Objective value
00219     inline double objectiveValue() const {
00220         return objectiveValue_;
00221     }
00222     inline void setObjectiveValue(double value) {
00223         objectiveValue_ = value;
00224     }
00226     inline int numberBranches() const {
00227         if (branch_)
00228             return (branch_->numberBranches()) ;
00229         else
00230             return (-1) ;
00231     }
00232 
00233     /* Active arm of the attached OsiBranchingObject.
00234 
00235      In the simplest instance, coded -1 for the down arm of the branch, +1 for
00236      the up arm. But see OsiBranchingObject::way()
00237        Use nodeInfo--.numberBranchesLeft_ to see how active
00238     */
00239     int way() const;
00241     inline int depth() const {
00242         return depth_;
00243     }
00245     inline void setDepth(int value) {
00246         depth_ = value;
00247     }
00249     inline int numberUnsatisfied() const {
00250         return numberUnsatisfied_;
00251     }
00253     inline void setNumberUnsatisfied(int value) {
00254         numberUnsatisfied_ = value;
00255     }
00257     inline double sumInfeasibilities() const {
00258         return sumInfeasibilities_;
00259     }
00261     inline void setSumInfeasibilities(double value) {
00262         sumInfeasibilities_ = value;
00263     }
00264     // Guessed objective value (for solution)
00265     inline double guessedObjectiveValue() const {
00266         return guessedObjectiveValue_;
00267     }
00268     inline void setGuessedObjectiveValue(double value) {
00269         guessedObjectiveValue_ = value;
00270     }
00272     inline const OsiBranchingObject * branchingObject() const {
00273         return branch_;
00274     }
00276     inline OsiBranchingObject * modifiableBranchingObject() const {
00277         return branch_;
00278     }
00280     inline void setBranchingObject(OsiBranchingObject * branchingObject) {
00281         branch_ = branchingObject;
00282     }
00284     inline int nodeNumber() const {
00285         return nodeNumber_;
00286     }
00287     inline void setNodeNumber(int node) {
00288         nodeNumber_ = node;
00289     }
00291     inline bool onTree() const {
00292         return (state_&1) != 0;
00293     }
00295     inline void setOnTree(bool yesNo) {
00296         if (yesNo) state_ |= 1;
00297         else state_ &= ~1;
00298     }
00300     inline bool active() const {
00301         return (state_&2) != 0;
00302     }
00304     inline void setActive(bool yesNo) {
00305         if (yesNo) state_ |= 2;
00306         else state_ &= ~2;
00307     }
00309     void print() const;
00311     inline void checkInfo() const {
00312         assert (nodeInfo_->numberBranchesLeft() ==
00313                 branch_->numberBranchesLeft());
00314     }
00315 
00316 private:
00317     // Data
00319     CbcNodeInfo * nodeInfo_;
00321     double objectiveValue_;
00323     double guessedObjectiveValue_;
00325     double sumInfeasibilities_;
00327     OsiBranchingObject * branch_;
00329     int depth_;
00331     int numberUnsatisfied_;
00333     int nodeNumber_;
00338     int state_;
00339 };
00340 
00341 
00342 #endif
00343