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

Last change on this file since 1899 was 1899, checked in by stefan, 5 years ago

fixup svn properties

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