1 | // Edwin 11/10/2009-- carved out of CbcBranchActual |
---|
2 | #ifndef CbcGeneralBranchingObject_H |
---|
3 | #define CbcGeneralBranchingObject_H |
---|
4 | |
---|
5 | #include "CbcBranchBase.hpp" |
---|
6 | #include "CbcSubProblem.hpp" |
---|
7 | |
---|
8 | /** Branching object for general objects |
---|
9 | |
---|
10 | */ |
---|
11 | class CbcNode; |
---|
12 | class CbcGeneralBranchingObject : public CbcBranchingObject { |
---|
13 | |
---|
14 | public: |
---|
15 | |
---|
16 | // Default Constructor |
---|
17 | CbcGeneralBranchingObject (); |
---|
18 | |
---|
19 | // Useful constructor |
---|
20 | CbcGeneralBranchingObject (CbcModel * model); |
---|
21 | |
---|
22 | // Copy constructor |
---|
23 | CbcGeneralBranchingObject ( const CbcGeneralBranchingObject &); |
---|
24 | |
---|
25 | // Assignment operator |
---|
26 | CbcGeneralBranchingObject & operator=( const CbcGeneralBranchingObject& rhs); |
---|
27 | |
---|
28 | /// Clone |
---|
29 | virtual CbcBranchingObject * clone() const; |
---|
30 | |
---|
31 | // Destructor |
---|
32 | virtual ~CbcGeneralBranchingObject (); |
---|
33 | |
---|
34 | using CbcBranchingObject::branch ; |
---|
35 | /// Does next branch and updates state |
---|
36 | virtual double branch(); |
---|
37 | /** Double checks in case node can change its mind! |
---|
38 | Can change objective etc */ |
---|
39 | virtual void checkIsCutoff(double cutoff); |
---|
40 | |
---|
41 | using CbcBranchingObject::print ; |
---|
42 | /** \brief Print something about branch - only if log level high |
---|
43 | */ |
---|
44 | virtual void print(); |
---|
45 | /// Fill in current objective etc |
---|
46 | void state(double & objectiveValue, double & sumInfeasibilities, |
---|
47 | int & numberUnsatisfied, int which) const; |
---|
48 | /// Set CbcNode |
---|
49 | inline void setNode(CbcNode * node) { |
---|
50 | node_ = node; |
---|
51 | } |
---|
52 | /** Return the type (an integer identifier) of \c this */ |
---|
53 | virtual int type() const { |
---|
54 | return 108; |
---|
55 | } |
---|
56 | |
---|
57 | /** Compare the original object of \c this with the original object of \c |
---|
58 | brObj. Assumes that there is an ordering of the original objects. |
---|
59 | This method should be invoked only if \c this and brObj are of the same |
---|
60 | type. |
---|
61 | Return negative/0/positive depending on whether \c this is |
---|
62 | smaller/same/larger than the argument. |
---|
63 | */ |
---|
64 | virtual int compareOriginalObject(const CbcBranchingObject* brObj) const; |
---|
65 | |
---|
66 | /** Compare the \c this with \c brObj. \c this and \c brObj must be os the |
---|
67 | same type and must have the same original object, but they may have |
---|
68 | different feasible regions. |
---|
69 | Return the appropriate CbcRangeCompare value (first argument being the |
---|
70 | sub/superset if that's the case). In case of overlap (and if \c |
---|
71 | replaceIfOverlap is true) replace the current branching object with one |
---|
72 | whose feasible region is the overlap. |
---|
73 | */ |
---|
74 | virtual CbcRangeCompare compareBranchingObject |
---|
75 | (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false); |
---|
76 | /// Number of subproblems |
---|
77 | inline int numberSubProblems() const { |
---|
78 | return numberSubProblems_; |
---|
79 | } |
---|
80 | /// Decrement number left and return number |
---|
81 | inline int decrementNumberLeft() { |
---|
82 | numberSubLeft_--; |
---|
83 | return numberSubLeft_; |
---|
84 | } |
---|
85 | /// Which node we want to use |
---|
86 | inline int whichNode() const { |
---|
87 | return whichNode_; |
---|
88 | } |
---|
89 | /// Set which node we want to use |
---|
90 | inline void setWhichNode(int value) { |
---|
91 | whichNode_ = value; |
---|
92 | } |
---|
93 | // Sub problem |
---|
94 | const CbcSubProblem * subProblem(int which) const { |
---|
95 | return subProblems_ + which; |
---|
96 | } |
---|
97 | |
---|
98 | public: |
---|
99 | /// data |
---|
100 | // Sub problems |
---|
101 | CbcSubProblem * subProblems_; |
---|
102 | /// Node |
---|
103 | CbcNode * node_; |
---|
104 | /// Number of subproblems |
---|
105 | int numberSubProblems_; |
---|
106 | /// Number of subproblems left |
---|
107 | int numberSubLeft_; |
---|
108 | /// Which node we want to use (-1 for default) |
---|
109 | int whichNode_; |
---|
110 | /// Number of rows |
---|
111 | int numberRows_; |
---|
112 | }; |
---|
113 | |
---|
114 | #endif |
---|