/home/coin/SVN-release/Cbc-2.0.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();}
00069 
00071 
00074 
00083   virtual void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
00084 
00086   CbcNode * bestAlternate();
00087 
00089   virtual void endSearch() {}
00090 
00092   virtual double getBestPossibleObjective();
00094 protected:
00095   std::vector <CbcNode *> nodes_;
00096   CbcCompare comparison_;       
00097 
00098 
00099 };
00100 
00102 #include "CoinSearchTree.hpp"
00109 class CbcNewTree : public CbcTree, public CoinSearchTreeManager {
00110 
00111 public:
00112 
00113   // Default Constructor 
00114   CbcNewTree ();
00115 
00116   // Copy constructor 
00117   CbcNewTree ( const CbcNewTree & rhs);
00118   // = operator
00119   CbcNewTree & operator=(const CbcNewTree & rhs);
00120    
00121   virtual ~CbcNewTree();
00122 
00124   virtual CbcNewTree * clone() const;
00126   virtual void generateCpp( FILE * fp) {}
00127 
00130 
00132   void setComparison(CbcCompareBase  &compare);
00133 
00135   virtual CbcNode * top() const;
00136 
00138   virtual void push(CbcNode * x);
00139 
00141   virtual void pop() ;
00143   virtual CbcNode * bestNode(double cutoff);
00144 
00146 
00148 
00150   virtual bool empty() ;
00151 
00153   inline int size() const
00154   { return nodes_.size();}
00155 
00157   inline CbcNode * operator [] (int i) const
00158   { return nodes_[i];}
00159 
00161   inline CbcNode * nodePointer (int i) const
00162   { return nodes_[i];}
00163 
00165 
00168 
00177   void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
00178 
00180   CbcNode * bestAlternate();
00181 
00183   virtual void endSearch() {}
00185 protected:
00186 
00187 
00188 };
00189 #else
00190 class CbcTree {
00191 
00192 public:
00193 
00194   // Default Constructor 
00195   CbcTree ();
00196 
00197   // Copy constructor 
00198   CbcTree ( const CbcTree & rhs);
00199   // = operator
00200   CbcTree & operator=(const CbcTree & rhs);
00201    
00202   virtual ~CbcTree();
00203 
00205   virtual CbcTree * clone() const;
00207   virtual void generateCpp( FILE * fp) {}
00208 
00211 
00213   void setComparison(CbcCompareBase  &compare);
00214 
00216   virtual CbcNode * top() const;
00217 
00219   virtual void push(CbcNode * x);
00220 
00222   virtual void pop() ;
00224   virtual CbcNode * bestNode(double cutoff);
00225 
00227 
00229 
00231   //virtual bool empty() ;
00232 
00234   inline int size() const
00235   { return nodes_.size();}
00236 
00238   inline CbcNode * operator [] (int i) const
00239   { return nodes_[i];}
00240 
00242   inline CbcNode * nodePointer (int i) const
00243   { return nodes_[i];}
00244   
00245   virtual bool empty();
00246   //inline int size() const { return size_; }
00247   void realpop();
00249   void fixTop();
00250   void realpush(CbcNode * node);
00252 
00255 
00264   void cleanTree(CbcModel * model, double cutoff, double & bestPossibleObjective);
00265 
00267   CbcNode * bestAlternate();
00268 
00270   virtual void endSearch() {}
00272 protected:
00273   std::vector <CbcNode *> nodes_;
00274   CbcCompare comparison_;       
00275 
00276 
00277 };
00278 #endif
00279 #endif
00280 

Generated on Thu May 15 22:07:39 2008 by  doxygen 1.4.7