source: trunk/Cbc/src/CbcBranchDecision.hpp @ 1557

Last change on this file since 1557 was 1432, checked in by bjarni, 10 years ago

Added extra return at end of each source file where needed, to remove possible linefeed conflicts (NightlyBuild? errors)

File size: 4.1 KB
Line 
1// Edwin 11/12/2009 carved from CbcBranchBase
2#ifndef CbcBranchDecision_H
3#define CbcBranchDecision_H
4
5#include "CbcBranchBase.hpp"
6
7/** Abstract branching decision base class
8
9  In the abstract, an CbcBranchDecision object is expected to be able to
10  compare two possible branching choices.
11
12  The #betterBranch() method is the crucial routine. It is expected to be able
13  to compare two \link CbcBranchingObject CbcBranchingObjects \endlink.
14
15  See CbcObject for an overview of the three classes (CbcObject,
16  CbcBranchingObject, and CbcBranchDecision) which make up cbc's branching
17  model.
18*/
19class CbcModel;
20class OsiChooseVariable;
21
22class CbcBranchDecision {
23public:
24    /// Default Constructor
25    CbcBranchDecision ();
26
27    // Copy constructor
28    CbcBranchDecision ( const CbcBranchDecision &);
29
30    /// Destructor
31    virtual ~CbcBranchDecision();
32
33/// Clone
34    virtual CbcBranchDecision * clone() const = 0;
35
36    /// Initialize <i>e.g.</i> before starting to choose a branch at a node
37    virtual void initialize(CbcModel * model) = 0;
38
39    /** \brief Compare two branching objects. Return nonzero if branching
40           using \p thisOne is better than branching using \p bestSoFar.
41
42      If \p bestSoFar is NULL, the routine should return a nonzero value.
43      This routine is used only after strong branching.
44      Either this or bestBranch is used depending which user wants.
45
46    */
47
48    virtual int
49    betterBranch (CbcBranchingObject * thisOne,
50                  CbcBranchingObject * bestSoFar,
51                  double changeUp, int numberInfeasibilitiesUp,
52                  double changeDown, int numberInfeasibilitiesDown) = 0 ;
53
54    /** \brief Compare N branching objects. Return index of best
55        and sets way of branching in chosen object.
56
57      Either this or betterBranch is used depending which user wants.
58    */
59
60    virtual int
61    bestBranch (CbcBranchingObject ** objects, int numberObjects, int numberUnsatisfied,
62                double * changeUp, int * numberInfeasibilitiesUp,
63                double * changeDown, int * numberInfeasibilitiesDown,
64                double objectiveValue) ;
65
66    /** Says whether this method can handle both methods -
67        1 better, 2 best, 3 both */
68    virtual int whichMethod() {
69        return 2;
70    }
71
72    /** Saves a clone of current branching object.  Can be used to update
73        information on object causing branch - after branch */
74    virtual void saveBranchingObject(OsiBranchingObject * ) {}
75    /** Pass in information on branch just done.
76        assumes object can get information from solver */
77    virtual void updateInformation(OsiSolverInterface * ,
78                                   const CbcNode * ) {}
79    /** Sets or gets best criterion so far */
80    virtual void setBestCriterion(double ) {}
81    virtual double getBestCriterion() const {
82        return 0.0;
83    }
84    /// Create C++ lines to get to current state
85    virtual void generateCpp( FILE * ) {}
86    /// Model
87    inline CbcModel * cbcModel() const {
88        return model_;
89    }
90    /* If chooseMethod_ id non-null then the rest is fairly pointless
91       as choosemethod_ will be doing all work
92     This comment makes more sense if you realise that there's a conversion in
93     process from the Cbc branching classes to Osi branching classes. The test
94     for use of the Osi branching classes is CbcModel::branchingMethod_
95     non-null (i.e., it points to one of these CbcBranchDecision objects) and
96     that branch decision object has an OsiChooseVariable method set. In which
97     case, we'll use it, rather than the choose[*]Variable methods defined in
98     CbcNode.
99        */
100
101    OsiChooseVariable * chooseMethod() const {
102        return chooseMethod_;
103    }
104    /// Set (clone) chooseMethod
105    void setChooseMethod(const OsiChooseVariable & method);
106
107protected:
108
109    // Clone of branching object
110    CbcBranchingObject * object_;
111    /// Pointer to model
112    CbcModel * model_;
113    /* If chooseMethod_ id non-null then the rest is fairly pointless
114       as choosemethod_ will be doing all work
115    */
116    OsiChooseVariable * chooseMethod_;
117private:
118    /// Assignment is illegal
119    CbcBranchDecision & operator=(const CbcBranchDecision& rhs);
120
121};
122#endif
123
Note: See TracBrowser for help on using the repository browser.