/home/coin/SVN-release/Cbc-2.4.0/Cbc/src/CbcCompareActual.hpp

Go to the documentation of this file.
00001 /* $Id: CbcCompareActual.hpp 1271 2009-11-05 15:57:25Z forrest $ */
00002 // Copyright (C) 2002, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
00004 #ifndef CbcCompareActual_H
00005 #define CbcCompareActual_H
00006 
00007 
00008 //#############################################################################
00009 /*  These are alternative strategies for node traversal.  
00010     They can take data etc for fine tuning 
00011 
00012     At present the node list is stored as a heap and the "test"
00013     comparison function returns true if node y is better than node x.
00014 
00015 */
00016 #include "CbcNode.hpp"
00017 #include "CbcCompareBase.hpp"
00018 class CbcModel;
00019 // This is default before first solution
00020 class CbcCompareDepth : public CbcCompareBase{
00021 public:
00022   // Default Constructor 
00023   CbcCompareDepth () ;
00024 
00025   ~CbcCompareDepth();
00026   // Copy constructor 
00027   CbcCompareDepth ( const CbcCompareDepth &rhs);
00028    
00029   // Assignment operator 
00030   CbcCompareDepth & operator=( const CbcCompareDepth& rhs);
00031 
00033   virtual CbcCompareBase * clone() const;
00035   virtual void generateCpp( FILE * fp);
00036 
00037   // This returns true if the depth of node y is greater than depth of node x
00038   virtual bool test (CbcNode * x, CbcNode * y);
00039 };
00040 class CbcCompareObjective  : public CbcCompareBase {
00041 public:
00042   // Default Constructor 
00043   CbcCompareObjective ();
00044 
00045   virtual ~CbcCompareObjective();
00046   // Copy constructor 
00047   CbcCompareObjective ( const CbcCompareObjective &rhs);
00048    
00049   // Assignment operator 
00050   CbcCompareObjective & operator=( const CbcCompareObjective& rhs);
00051 
00053   virtual CbcCompareBase * clone() const;
00055   virtual void generateCpp( FILE * fp);
00056 
00057   /* This returns true if objective value of node y is less than
00058      objective value of node x */
00059   virtual bool test (CbcNode * x, CbcNode * y);
00060 };
00061 /* This is an example of a more complex rule with data
00062    It is default after first solution
00063    If weight is 0.0 then it is computed to hit first solution
00064    less 5%
00065 */
00066 class CbcCompareDefault  : public CbcCompareBase {
00067 public:
00068   // Default Constructor 
00069   CbcCompareDefault () ;
00070   // Constructor with weight
00071   CbcCompareDefault (double weight);
00072 
00073   // Copy constructor 
00074   CbcCompareDefault ( const CbcCompareDefault &rhs);
00075    
00076   // Assignment operator 
00077   CbcCompareDefault & operator=( const CbcCompareDefault& rhs);
00078 
00080   virtual CbcCompareBase * clone() const;
00082   virtual void generateCpp( FILE * fp);
00083 
00084   ~CbcCompareDefault() ;
00085   /* This returns true if weighted value of node y is less than
00086      weighted value of node x */
00087   virtual bool test (CbcNode * x, CbcNode * y) ;
00088 
00089   using CbcCompareBase::newSolution ;
00090   // This allows method to change behavior as it is called
00091   // after each solution
00092   virtual void newSolution(CbcModel * model,
00093                            double objectiveAtContinuous,
00094                            int numberInfeasibilitiesAtContinuous) ;
00095   // This allows method to change behavior 
00096   // Return true if want tree re-sorted
00097   virtual bool every1000Nodes(CbcModel * model,int numberNodes);
00098 
00099   /* if weight == -1.0 then fewest infeasibilities (before solution)
00100      if -2.0 then do breadth first just for first 1000 nodes
00101      if -3.0 then depth first before solution
00102   */
00103   inline double getWeight() const
00104   { return weight_;}
00105   inline void setWeight(double weight)
00106   { weight_ = weight;}
00108   inline double getCutoff() const
00109   { return cutoff_;}
00110   inline void setCutoff(double cutoff)
00111   { cutoff_ = cutoff;}
00113   inline double getBestPossible() const
00114   { return bestPossible_;}
00115   inline void setBestPossible(double bestPossible)
00116   { bestPossible_ = bestPossible;}
00117   // Depth above which want to explore first
00118   inline void setBreadthDepth(int value)
00119   {  breadthDepth_ = value;}
00120 protected:
00121   // Weight for each infeasibility
00122   double weight_;
00123   // Weight for each infeasibility - computed from solution
00124   double saveWeight_;
00126   double cutoff_;
00128   double bestPossible_;
00129   // Number of solutions
00130   int numberSolutions_;
00131   // Tree size (at last check)
00132   int treeSize_;
00133   // Depth above which want to explore first
00134   int breadthDepth_;
00135 };
00136 
00137 /* This is when rounding is being done
00138 */
00139 class CbcCompareEstimate  : public CbcCompareBase {
00140 public:
00141   // Default Constructor 
00142   CbcCompareEstimate () ;
00143   ~CbcCompareEstimate() ;
00144   // Copy constructor 
00145   CbcCompareEstimate ( const CbcCompareEstimate &rhs);
00146    
00147   // Assignment operator 
00148   CbcCompareEstimate & operator=( const CbcCompareEstimate& rhs);
00149 
00151   virtual CbcCompareBase * clone() const;
00153   virtual void generateCpp( FILE * fp);
00154 
00155   virtual bool test (CbcNode * x, CbcNode * y) ;
00156 };
00157 
00158 #endif

Generated on Tue Jan 19 03:02:15 2010 by  doxygen 1.4.7