/home/coin/SVN-release/CoinAll-1.1.0/Cbc/src/CbcTreeLocal.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2004, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef CbcTreeLocal_H
00004 #define CbcTreeLocal_H
00005 
00006 //#############################################################################
00007 /*  This implements (approximately) local branching as in the 2002 paper by
00008     Matteo Fischetti and Andrea Lodi.
00009 
00010     The very simple version of the algorithm for problems with 
00011     0-1 variables and continuous is as follows:
00012 
00013     Obtain a feasible solution (one can be passed in).
00014 
00015     Add a cut which limits search to a k neighborhood of this solution.
00016     (At most k 0-1 variables may change value)
00017     Do branch and bound on this problem.
00018 
00019     If finished search and proven optimal then we can reverse cut so
00020     any solutions must be at least k+1 away from solution and we can 
00021     add a new cut limiting search to a k neighborhood of new solution
00022     repeat.
00023 
00024     If finished search and no new solution then the simplest version
00025     would reverse last cut and complete search.  The version implemented 
00026     here can use time and node limits and can widen search (increase effective k)
00027     .... and more
00028 
00029 */
00030 
00031 #include "CbcTree.hpp"
00032 #include "CbcNode.hpp"
00033 #include "OsiRowCut.hpp"
00034 class CbcModel;
00035 
00036 
00037 class CbcTreeLocal : public CbcTree {
00038 
00039 public:
00040 
00041   // Default Constructor 
00042   CbcTreeLocal ();
00043 
00044   /* Constructor with solution.
00045      If solution NULL no solution, otherwise must be integer
00046      range is initial upper bound (k) on difference from given solution.
00047      typeCuts -
00048               0 means just 0-1 cuts and will need to refine 0-1 solution
00049               1 uses weaker cuts on all integer variables
00050      maxDiversification is maximum number of range widenings to try
00051      timeLimit is seconds in subTree
00052      nodeLimit is nodes in subTree
00053      refine is whether to see if we can prove current solution is optimal
00054      when we fix all 0-1 (in case typeCuts==0 and there are general integer variables)
00055      if false then no refinement but reverse cuts weaker
00056   */
00057   CbcTreeLocal (CbcModel * model,const double * solution ,int range=10,
00058                    int typeCuts=0,int maxDiversification=0,
00059                    int timeLimit=1000000, int nodeLimit=1000000,bool refine=true);
00060   // Copy constructor 
00061   CbcTreeLocal ( const CbcTreeLocal & rhs);
00062 
00063   // = operator
00064   CbcTreeLocal & operator=(const CbcTreeLocal & rhs);
00065    
00066   virtual ~CbcTreeLocal();
00067 
00069   virtual CbcTree * clone() const;
00071   virtual void generateCpp( FILE * fp) ;
00072 
00075 
00077   virtual CbcNode * top() const;
00078 
00080   virtual void push(CbcNode * x);
00081 
00083   virtual void pop() ;
00084 
00086 
00088 
00090   int createCut(const double * solution, OsiRowCut & cut);
00091 
00093   virtual bool empty() ;
00094 
00096   virtual void endSearch() ;
00098   void reverseCut(int state, double bias=0.0);
00100   void deleteCut(OsiRowCut & cut);
00102   void passInSolution(const double * solution, double solutionValue);
00103   // range i.e. k
00104   inline int range() const
00105   { return range_;}
00106   // setrange i.e. k
00107   inline void setRange(int value)
00108   { range_ = value;}
00109   // Type of cuts - 0=just 0-1, 1=all
00110   inline int typeCuts() const
00111   { return typeCuts_;}
00112   // Type of cuts - 0=just 0-1, 1=all
00113   inline void setTypeCuts(int value)
00114   { typeCuts_ = value;}
00115   // maximum number of diversifications
00116   inline int maxDiversification() const
00117   { return maxDiversification_;}
00118   // maximum number of diversifications
00119   inline void setMaxDiversification(int value)
00120   { maxDiversification_ = value;}
00121   // time limit per subtree
00122   inline int timeLimit() const
00123   { return timeLimit_;}
00124   // time limit per subtree
00125   inline void setTimeLimit(int value)
00126   { timeLimit_ = value;}
00127   // node limit for subtree
00128   inline int nodeLimit() const
00129   { return nodeLimit_;}
00130   // node limit for subtree
00131   inline void setNodeLimit(int value)
00132   { nodeLimit_ = value;}
00133   // Whether to do refinement step
00134   inline bool refine() const
00135   { return refine_;}
00136   // Whether to do refinement step
00137   inline void setRefine(bool yesNo)
00138     { refine_ = yesNo;}
00139 
00141 private:
00142   // Node for local cuts
00143   CbcNode * localNode_;
00144   // best solution
00145   double * bestSolution_;
00146   // saved solution
00147   double * savedSolution_;
00148   // solution number at start of pass
00149   int saveNumberSolutions_;
00150   /* Cut.  If zero size then no solution yet.  Otherwise is left hand branch */
00151   OsiRowCut cut_;
00152   // This cut fixes all 0-1 variables
00153   OsiRowCut fixedCut_;
00154   // Model
00155   CbcModel * model_;
00156   // Original lower bounds
00157   double * originalLower_;
00158   // Original upper bounds
00159   double * originalUpper_;
00160   // range i.e. k
00161   int range_;
00162   // Type of cuts - 0=just 0-1, 1=all
00163   int typeCuts_;
00164   // maximum number of diversifications
00165   int maxDiversification_;
00166   // current diversification
00167   int diversification_;
00168   // Whether next will be strong diversification
00169   bool nextStrong_;
00170   // Current rhs
00171   double rhs_;
00172   // Save allowable gap
00173   double savedGap_;
00174   // Best solution
00175   double bestCutoff_;
00176   // time limit per subtree
00177   int timeLimit_;
00178   // time when subtree started
00179   int startTime_;
00180   // node limit for subtree
00181   int nodeLimit_;
00182   // node count when subtree started
00183   int startNode_;
00184   // -1 not started, 0 == stop on first solution, 1 don't stop on first, 2 refinement step
00185   int searchType_;
00186   // Whether to do refinement step
00187   bool refine_;
00188 
00189 };
00190 #endif
00191 

Generated on Sun Nov 14 14:06:31 2010 for Coin-All by  doxygen 1.4.7