/home/coin/SVN-release/Cbc-2.2.0/Cbc/src/CbcTree.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2004, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef CbcTree_H
00004 #define CbcTree_H
00005 
00006 #include <vector>
00007 #include <algorithm>
00008 #include <cmath>
00009 
00010 #include "CoinFinite.hpp"
00011 #include "CoinHelperFunctions.hpp"
00012 
00018 //#define CBC_DUBIOUS_HEAP
00019 #if defined(_MSC_VER) || defined(__MNO_CYGWIN)
00020 //#define CBC_DUBIOUS_HEAP
00021 #endif
00022 #ifndef CBC_DUBIOUS_HEAP 
00023 class CbcTree {
00024 
00025 public:
00026 
00027   // Default Constructor 
00028   CbcTree ();
00029 
00030   // Copy constructor 
00031   CbcTree ( const CbcTree & rhs);
00032   // = operator
00033   CbcTree & operator=(const CbcTree & rhs);
00034    
00035   virtual ~CbcTree();
00036 
00038   virtual CbcTree * clone() const;
00040   virtual void generateCpp( FILE * fp) {}
00041 
00044 
00046   void setComparison(CbcCompareBase  &compare);
00047 
00049   virtual CbcNode * top() const;
00050 
00052   virtual void push(CbcNode * x);
00053 
00055   virtual void pop() ;
00057   virtual CbcNode * bestNode(double cutoff);
00058 
00060 
00062 
00064   virtual bool empty() ;
00065 
00067   virtual int size() const
00068   {return nodes_.size();}
00070   inline CbcNode * operator [] (int i) const
00071   { return nodes_[i];}
00072 
00074   inline CbcNode * nodePointer (int i) const
00075   { return nodes_[i];}
00076 
00077 
00079 
00082 
00091   virtual void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
00092 
00094   CbcNode * bestAlternate();
00095 
00097   virtual void endSearch() {}
00098 
00100   virtual double getBestPossibleObjective();
00102   inline void resetNodeNumbers()
00103   { maximumNodeNumber_=0;}
00105   inline void setNumberBranching(int value)
00106   { numberBranching_=value;}
00108   inline int getNumberBranching() const
00109   { return numberBranching_;}
00111   inline void setMaximumBranching(int value)
00112   { maximumBranching_=value;}
00114   inline int getMaximumBranching() const
00115   { return maximumBranching_;}
00117   inline unsigned int * branched() const
00118   { return branched_;}
00120   inline int * newBounds() const
00121   { return newBound_;}
00123   void addBranchingInformation(const CbcModel * model,const CbcNodeInfo * nodeInfo,
00124                                const double * currentLower,
00125                                const double * currentUpper);
00127   void increaseSpace();
00129 protected:
00130   std::vector <CbcNode *> nodes_;
00131   CbcCompare comparison_;       
00132 
00133   int maximumNodeNumber_;
00135   int numberBranching_;
00137   int maximumBranching_;
00142   unsigned int * branched_;
00144   int * newBound_;
00145 };
00146 
00148 #include "CoinSearchTree.hpp"
00155 class CbcNewTree : public CbcTree, public CoinSearchTreeManager {
00156 
00157 public:
00158 
00159   // Default Constructor 
00160   CbcNewTree ();
00161 
00162   // Copy constructor 
00163   CbcNewTree ( const CbcNewTree & rhs);
00164   // = operator
00165   CbcNewTree & operator=(const CbcNewTree & rhs);
00166    
00167   virtual ~CbcNewTree();
00168 
00170   virtual CbcNewTree * clone() const;
00172   virtual void generateCpp( FILE * fp) {}
00173 
00176 
00178   void setComparison(CbcCompareBase  &compare);
00179 
00181   virtual CbcNode * top() const;
00182 
00184   virtual void push(CbcNode * x);
00185 
00187   virtual void pop() ;
00189   virtual CbcNode * bestNode(double cutoff);
00190 
00192 
00194 
00196   virtual bool empty() ;
00197 
00199   inline int size() const
00200   { return nodes_.size();}
00201 
00203   inline CbcNode * operator [] (int i) const
00204   { return nodes_[i];}
00205 
00207   inline CbcNode * nodePointer (int i) const
00208   { return nodes_[i];}
00209 
00211 
00214 
00223   void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
00224 
00226   CbcNode * bestAlternate();
00227 
00229   virtual void endSearch() {}
00231 protected:
00232 
00233 
00234 };
00235 #else
00236 class CbcTree {
00237 
00238 public:
00239 
00240   // Default Constructor 
00241   CbcTree ();
00242 
00243   // Copy constructor 
00244   CbcTree ( const CbcTree & rhs);
00245   // = operator
00246   CbcTree & operator=(const CbcTree & rhs);
00247    
00248   virtual ~CbcTree();
00249 
00251   virtual CbcTree * clone() const;
00253   virtual void generateCpp( FILE * fp) {}
00254 
00257 
00259   void setComparison(CbcCompareBase  &compare);
00260 
00262   virtual CbcNode * top() const;
00263 
00265   virtual void push(CbcNode * x);
00266 
00268   virtual void pop() ;
00270   virtual CbcNode * bestNode(double cutoff);
00271 
00273 
00275 
00277   //virtual bool empty() ;
00278 
00280   inline int size() const
00281   { return nodes_.size();}
00282 
00284   inline CbcNode * operator [] (int i) const
00285   { return nodes_[i];}
00286 
00288   inline CbcNode * nodePointer (int i) const
00289   { return nodes_[i];}
00290   
00291   virtual bool empty();
00292   //inline int size() const { return size_; }
00293   void realpop();
00295   void fixTop();
00296   void realpush(CbcNode * node);
00298 
00301 
00310   void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
00311 
00313   CbcNode * bestAlternate();
00314 
00316   virtual void endSearch() {}
00318   inline void resetNodeNumbers()
00319   { maximumNodeNumber_=0;}
00321 protected:
00322   std::vector <CbcNode *> nodes_;
00323   CbcCompare comparison_;       
00324 
00325   int maximumNodeNumber_;
00326 
00327 
00328 };
00329 #endif
00330 #endif
00331 

Generated on Thu Sep 18 03:00:40 2008 by  doxygen 1.4.7