Ignore:
Timestamp:
Jun 26, 2007 5:17:15 AM (13 years ago)
Author:
forrest
Message:

trunk from branches/devel

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:externals
      •  

        old new  
        1 MSVisualStudio   https://projects.coin-or.org/svn/MSVisualStudio/trunk/ExternalsDirs/Cbc
        2 BuildTools    https://projects.coin-or.org/svn/BuildTools/stable/0.5
         1MSVisualStudio   https://projects.coin-or.org/svn/MSVisualStudio/branches/devel/ExternalsDirs/Cbc
         2BuildTools    https://projects.coin-or.org/svn/BuildTools/trunk
        33ThirdParty/ASL https://projects.coin-or.org/svn/BuildTools/ThirdParty/ASL/stable/1.0
         4ThirdParty/Blas https://projects.coin-or.org/svn/BuildTools/ThirdParty/Blas/stable/1.0
         5ThirdParty/Lapack https://projects.coin-or.org/svn/BuildTools/ThirdParty/Lapack/stable/1.0
        46Data/Netlib   https://projects.coin-or.org/svn/Data/stable/1.0/Netlib
        57Data/Sample   https://projects.coin-or.org/svn/Data/stable/1.0/Sample
  • trunk/Cbc/src/CbcBranchBase.hpp

    r356 r640  
    66#include <string>
    77#include <vector>
    8 
     8#include "OsiBranchingObject.hpp"
    99class OsiSolverInterface;
    1010class OsiSolverBranch;
     
    1414class CbcNodeInfo;
    1515class CbcBranchingObject;
     16class OsiChooseVariable;
    1617
    1718//#############################################################################
    1819
    1920/** Abstract base class for `objects'.
     21    It now just has stuff that OsiObject does not have
    2022
    2123  The branching model used in Cbc is based on the idea of an <i>object</i>.
     
    5860  } CbcStrongInfo;
    5961
    60 class CbcObject {
     62class CbcObject : public OsiObject {
    6163
    6264public:
     
    9597  */
    9698  virtual double infeasibility(int &preferredWay) const = 0;
     99  /// Dummy one for compatibility
     100  virtual double infeasibility(const OsiBranchingInformation * info,
     101                               int &preferredWay) const;
    97102
    98103  /** For the variable(s) referenced by the object,
     
    100105  */
    101106  virtual void feasibleRegion() = 0;
     107  /// Dummy one for compatibility
     108  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
    102109
    103110  /** Create a branching object and indicate which way to branch first.
     
    108115  virtual CbcBranchingObject * createBranch(int way) = 0;
    109116 
     117  /** Infeasibility of the object
     118     
     119    This is some measure of the infeasibility of the object. 0.0
     120    indicates that the object is satisfied.
     121 
     122    The preferred branching direction is returned in way,
     123 
     124    This is used to prepare for strong branching but should also think of
     125    case when no strong branching
     126 
     127    The object may also compute an estimate of cost of going "up" or "down".
     128    This will probably be based on pseudo-cost ideas
     129
     130    This should also set mutable infeasibility_ and whichWay_
     131    This is for instant re-use for speed
     132  */
     133  virtual double infeasibility(const OsiSolverInterface * solver,int &preferredWay) const;
     134 
     135  /** For the variable(s) referenced by the object,
     136      look at the current solution and set bounds to match the solution.
     137      Returns measure of how much it had to move solution to make feasible
     138  */
     139  virtual double feasibleRegion(OsiSolverInterface * solver) const ;
     140 
     141  /** Create a branching object and indicate which way to branch first.
     142     
     143      The branching object has to know how to create branches (fix
     144      variables, etc.)
     145  */
     146  virtual OsiBranchingObject * createBranch(OsiSolverInterface * solver, int way) const;
     147  /** Create a branching object and indicate which way to branch first.
     148     
     149      The branching object has to know how to create branches (fix
     150      variables, etc.)
     151  */
     152  virtual OsiBranchingObject * createBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) const;
    110153  /** Create an OsiSolverBranch object
    111154
     
    138181  /** Reset variable bounds to their original values.
    139182 
    140     Bounds may be tightened, so it may be good to be able to reset them to
    141     their original values.
     183    Bounds may be tightened, so it may be good to be able to set this info in object.
    142184   */
    143   virtual void resetBounds() {};
    144  
    145   /** \brief Return true if branch created by object should fix variables
    146   */
    147   virtual bool boundBranch() const
    148   {return true;};
     185  virtual void resetBounds(const OsiSolverInterface * solver) {};
     186 
    149187  /** Returns floor and ceiling i.e. closest valid points
    150188  */
     
    155193  inline int id() const
    156194  { return id_;};
    157   /// Return Priority
    158   inline int priority() const
    159   { return priority_;};
    160   /// Set priority
    161   inline void setPriority(int priority)
    162   { priority_ = priority;};
    163  
    164   /// Column number if single column object -1 otherwise
    165   virtual int columnNumber() const;
    166 
    167195 
    168196   /// update model
     
    174202  {return  model_;};
    175203
    176   /// Return "up" estimate (default 1.0e-5)
    177   virtual double upEstimate() const;
    178   /// Return "down" estimate (default 1.0e-5)
    179   virtual double downEstimate() const;
    180204  /// If -1 down always chosen first, +1 up always, 0 normal
    181205  inline int preferredWay() const
     
    194218  /// Identifier (normally column number in matrix)
    195219  int id_;
    196   /// Priority
    197   int priority_;
    198220  /// If -1 down always chosen first, +1 up always, 0 normal
    199221  int preferredWay_;
     
    202224
    203225/** \brief Abstract branching object base class
     226    Now just difference with OsiBranchingObject
    204227
    205228  In the abstract, an CbcBranchingObject contains instructions for how to
     
    218241*/
    219242
    220 class CbcBranchingObject {
     243class CbcBranchingObject : public OsiBranchingObject {
    221244
    222245public:
     
    245268      Returns nonzero if skip is wanted */
    246269  virtual int fillStrongInfo( CbcStrongInfo & info) {return 0;};
    247   /** The number of branch arms created for this branching object
    248 
    249     \todo The hardwired `2' has to be changed before cbc can do branches with
    250           more than two arms.
    251   */
    252   virtual int numberBranches() const
    253   {return 2;};
    254 
    255   /// The number of branch arms left to be evaluated
    256   virtual int numberBranchesLeft() const
    257   {return numberBranchesLeft_;};
    258270  /// Reset number of branches left to original
    259271  inline void resetNumberBranchesLeft()
    260   { numberBranchesLeft_ = numberBranches();};
     272  { branchIndex_=0;};
    261273
    262274  /** \brief Execute the actions required to branch, as specified by the
     
    266278             Returns change in guessed objective on next branch
    267279  */
    268   virtual double branch(bool normalBranch=false)=0;
     280  virtual double branch()=0;
     281  /** \brief Execute the actions required to branch, as specified by the
     282             current state of the branching object, and advance the object's
     283             state.  Mainly for diagnostics, whether it is true branch or
     284             strong branching is also passed.
     285             Returns change in guessed objective on next branch
     286  */
     287  virtual double branch(OsiSolverInterface * solver)
     288  { return branch();};
    269289
    270290  /** \brief Print something about branch - only if log level high
    271291  */
    272   virtual void print(bool normalBranch) {};
    273 
    274   /** \brief Return true if branch should fix variables
    275   */
    276   virtual bool boundBranch() const
    277   {return true;};
     292  virtual void print() const {};
    278293
    279294  /** \brief Index identifying the associated CbcObject within its class.
     
    308323  {way_=way;};
    309324
    310   /// Current value
    311   inline double value() const
    312   {return value_;};
    313  
    314325  /// Return model
    315326  inline CbcModel * model() const
     
    318329  /// Return pointer back to object which created
    319330  inline CbcObject * object() const
    320   {return  originalObject_;};
     331  {return  originalCbcObject_;};
    321332  /// Set pointer back to object which created
    322333  inline void setOriginalObject(CbcObject * object)
    323   {originalObject_=object;};
     334  {originalCbcObject_=object;};
    324335
    325336protected:
     
    328339  CbcModel * model_;
    329340  /// Pointer back to object which created
    330   CbcObject * originalObject_;
     341  CbcObject * originalCbcObject_;
    331342
    332343  /// Branching variable (0 is first integer)
     
    342353  int way_;
    343354
    344   /// Current value
    345   double value_;
    346 
    347   /** Number of arms remaining to be evaluated
    348 
    349     \todo Compare with CbcNodeInfo::numberBranchesLeft_, and check for
    350           redundancy.
    351   */
    352   int numberBranchesLeft_;
    353 
    354355};
    355356
     
    373374  CbcBranchDecision ();
    374375
     376  // Copy constructor
     377  CbcBranchDecision ( const CbcBranchDecision &);
     378   
    375379  /// Destructor
    376380  virtual ~CbcBranchDecision();
     
    415419  /** Saves a clone of current branching object.  Can be used to update
    416420      information on object causing branch - after branch */
    417   virtual void saveBranchingObject(CbcBranchingObject * object) {};
     421  virtual void saveBranchingObject(OsiBranchingObject * object) {};
    418422  /** Pass in information on branch just done.
    419423      assumes object can get information from solver */
     
    425429  /// Create C++ lines to get to current state
    426430  virtual void generateCpp( FILE * fp) {};
     431  /// Model
     432  inline CbcModel * cbcModel() const
     433  { return model_;}
     434  /* If chooseMethod_ id non-null then the rest is fairly pointless
     435     as choosemethod_ will be doing all work
     436  */
     437  OsiChooseVariable * chooseMethod() const
     438  { return chooseMethod_;};
     439  /// Set (clone) chooseMethod
     440  void setChooseMethod(const OsiChooseVariable & method);
    427441
    428442protected:
     
    430444  // Clone of branching object
    431445  CbcBranchingObject * object_;
     446  /// Pointer to model
     447  CbcModel * model_;
     448  /* If chooseMethod_ id non-null then the rest is fairly pointless
     449     as choosemethod_ will be doing all work
     450  */
     451  OsiChooseVariable * chooseMethod_;
    432452private:
    433453  /// Assignment is illegal
Note: See TracChangeset for help on using the changeset viewer.