1 | // Edwin 11/9/2009-- carved out of CbcBranchActual |
---|
2 | #ifndef CbcClique_H |
---|
3 | #define CbcClique_H |
---|
4 | |
---|
5 | /// Define a clique class |
---|
6 | |
---|
7 | class CbcClique : public CbcObject { |
---|
8 | |
---|
9 | public: |
---|
10 | |
---|
11 | // Default Constructor |
---|
12 | CbcClique (); |
---|
13 | |
---|
14 | /** Useful constructor (which are integer indices) |
---|
15 | slack can denote a slack in set. |
---|
16 | If type == NULL then as if 1 |
---|
17 | */ |
---|
18 | CbcClique (CbcModel * model, int cliqueType, int numberMembers, |
---|
19 | const int * which, const char * type, |
---|
20 | int identifier, int slack = -1); |
---|
21 | |
---|
22 | // Copy constructor |
---|
23 | CbcClique ( const CbcClique &); |
---|
24 | |
---|
25 | /// Clone |
---|
26 | virtual CbcObject * clone() const; |
---|
27 | |
---|
28 | // Assignment operator |
---|
29 | CbcClique & operator=( const CbcClique& rhs); |
---|
30 | |
---|
31 | // Destructor |
---|
32 | virtual ~CbcClique (); |
---|
33 | |
---|
34 | /// Infeasibility - large is 0.5 |
---|
35 | virtual double infeasibility(const OsiBranchingInformation * info, |
---|
36 | int &preferredWay) const; |
---|
37 | |
---|
38 | using CbcObject::feasibleRegion ; |
---|
39 | /// This looks at solution and sets bounds to contain solution |
---|
40 | virtual void feasibleRegion(); |
---|
41 | |
---|
42 | /// Creates a branching object |
---|
43 | virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ; |
---|
44 | /// Number of members |
---|
45 | inline int numberMembers() const { |
---|
46 | return numberMembers_; |
---|
47 | } |
---|
48 | |
---|
49 | /// Number of Non SOS members i.e. fixing to zero is strong |
---|
50 | inline int numberNonSOSMembers() const { |
---|
51 | return numberNonSOSMembers_; |
---|
52 | } |
---|
53 | |
---|
54 | /// Members (indices in range 0 ... numberIntegers_-1) |
---|
55 | inline const int * members() const { |
---|
56 | return members_; |
---|
57 | } |
---|
58 | |
---|
59 | /** Type of each member i.e. which way is strong 0=non SOS, 1 =SOS, |
---|
60 | index is 0 ... numberMembers_-1 */ |
---|
61 | inline char type(int index) const { |
---|
62 | if (type_) return type_[index]; |
---|
63 | else return 1; |
---|
64 | } |
---|
65 | |
---|
66 | /// Clique type - 0 <=, 1 == |
---|
67 | inline int cliqueType() const { |
---|
68 | return cliqueType_; |
---|
69 | } |
---|
70 | /// Redoes data when sequence numbers change |
---|
71 | virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns); |
---|
72 | |
---|
73 | protected: |
---|
74 | /// data |
---|
75 | /// Number of members |
---|
76 | int numberMembers_; |
---|
77 | |
---|
78 | /// Number of Non SOS members i.e. fixing to zero is strong |
---|
79 | int numberNonSOSMembers_; |
---|
80 | |
---|
81 | /// Members (indices in range 0 ... numberIntegers_-1) |
---|
82 | int * members_; |
---|
83 | |
---|
84 | /// Type of each member 0=SOS, 1 =clique |
---|
85 | char * type_; |
---|
86 | |
---|
87 | /// Clique type - 0 <=, 1 == |
---|
88 | int cliqueType_; |
---|
89 | |
---|
90 | /// Which one is slack (if any) sequence within this set |
---|
91 | int slack_; |
---|
92 | }; |
---|
93 | |
---|
94 | /** Branching object for unordered cliques |
---|
95 | |
---|
96 | Intended for cliques which are long enough to make it worthwhile |
---|
97 | but <= 64 members. There will also be ones for long cliques. |
---|
98 | |
---|
99 | Variable_ is the clique id number (redundant, as the object also holds a |
---|
100 | pointer to the clique. |
---|
101 | */ |
---|
102 | class CbcCliqueBranchingObject : public CbcBranchingObject { |
---|
103 | |
---|
104 | public: |
---|
105 | |
---|
106 | // Default Constructor |
---|
107 | CbcCliqueBranchingObject (); |
---|
108 | |
---|
109 | // Useful constructor |
---|
110 | CbcCliqueBranchingObject (CbcModel * model, const CbcClique * clique, |
---|
111 | int way, |
---|
112 | int numberOnDownSide, const int * down, |
---|
113 | int numberOnUpSide, const int * up); |
---|
114 | |
---|
115 | // Copy constructor |
---|
116 | CbcCliqueBranchingObject ( const CbcCliqueBranchingObject &); |
---|
117 | |
---|
118 | // Assignment operator |
---|
119 | CbcCliqueBranchingObject & operator=( const CbcCliqueBranchingObject& rhs); |
---|
120 | |
---|
121 | /// Clone |
---|
122 | virtual CbcBranchingObject * clone() const; |
---|
123 | |
---|
124 | // Destructor |
---|
125 | virtual ~CbcCliqueBranchingObject (); |
---|
126 | |
---|
127 | using CbcBranchingObject::branch ; |
---|
128 | /// Does next branch and updates state |
---|
129 | virtual double branch(); |
---|
130 | |
---|
131 | #if 0 |
---|
132 | // No need to override. Default works fine. |
---|
133 | /** Reset every information so that the branching object appears to point to |
---|
134 | the previous child. This method does not need to modify anything in any |
---|
135 | solver. */ |
---|
136 | virtual void previousBranch(); |
---|
137 | #endif |
---|
138 | |
---|
139 | using CbcBranchingObject::print ; |
---|
140 | /** \brief Print something about branch - only if log level high |
---|
141 | */ |
---|
142 | virtual void print(); |
---|
143 | |
---|
144 | /** Return the type (an integer identifier) of \c this */ |
---|
145 | virtual int type() const { |
---|
146 | return 102; |
---|
147 | } |
---|
148 | |
---|
149 | /** Compare the original object of \c this with the original object of \c |
---|
150 | brObj. Assumes that there is an ordering of the original objects. |
---|
151 | This method should be invoked only if \c this and brObj are of the same |
---|
152 | type. |
---|
153 | Return negative/0/positive depending on whether \c this is |
---|
154 | smaller/same/larger than the argument. |
---|
155 | */ |
---|
156 | virtual int compareOriginalObject(const CbcBranchingObject* brObj) const; |
---|
157 | |
---|
158 | /** Compare the \c this with \c brObj. \c this and \c brObj must be os the |
---|
159 | same type and must have the same original object, but they may have |
---|
160 | different feasible regions. |
---|
161 | Return the appropriate CbcRangeCompare value (first argument being the |
---|
162 | sub/superset if that's the case). In case of overlap (and if \c |
---|
163 | replaceIfOverlap is true) replace the current branching object with one |
---|
164 | whose feasible region is the overlap. |
---|
165 | */ |
---|
166 | virtual CbcRangeCompare compareBranchingObject |
---|
167 | (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false); |
---|
168 | |
---|
169 | private: |
---|
170 | /// data |
---|
171 | const CbcClique * clique_; |
---|
172 | /// downMask - bit set to fix to weak bounds, not set to leave unfixed |
---|
173 | unsigned int downMask_[2]; |
---|
174 | /// upMask - bit set to fix to weak bounds, not set to leave unfixed |
---|
175 | unsigned int upMask_[2]; |
---|
176 | }; |
---|
177 | |
---|
178 | /** Unordered Clique Branching Object class. |
---|
179 | These are for cliques which are > 64 members |
---|
180 | Variable is number of clique. |
---|
181 | */ |
---|
182 | class CbcLongCliqueBranchingObject : public CbcBranchingObject { |
---|
183 | |
---|
184 | public: |
---|
185 | |
---|
186 | // Default Constructor |
---|
187 | CbcLongCliqueBranchingObject (); |
---|
188 | |
---|
189 | // Useful constructor |
---|
190 | CbcLongCliqueBranchingObject (CbcModel * model, const CbcClique * clique, |
---|
191 | int way, |
---|
192 | int numberOnDownSide, const int * down, |
---|
193 | int numberOnUpSide, const int * up); |
---|
194 | |
---|
195 | // Copy constructor |
---|
196 | CbcLongCliqueBranchingObject ( const CbcLongCliqueBranchingObject &); |
---|
197 | |
---|
198 | // Assignment operator |
---|
199 | CbcLongCliqueBranchingObject & operator=( const CbcLongCliqueBranchingObject& rhs); |
---|
200 | |
---|
201 | /// Clone |
---|
202 | virtual CbcBranchingObject * clone() const; |
---|
203 | |
---|
204 | // Destructor |
---|
205 | virtual ~CbcLongCliqueBranchingObject (); |
---|
206 | |
---|
207 | using CbcBranchingObject::branch ; |
---|
208 | /// Does next branch and updates state |
---|
209 | virtual double branch(); |
---|
210 | |
---|
211 | #if 0 |
---|
212 | // No need to override. Default works fine. |
---|
213 | /** Reset every information so that the branching object appears to point to |
---|
214 | the previous child. This method does not need to modify anything in any |
---|
215 | solver. */ |
---|
216 | virtual void previousBranch(); |
---|
217 | #endif |
---|
218 | |
---|
219 | using CbcBranchingObject::print ; |
---|
220 | /** \brief Print something about branch - only if log level high |
---|
221 | */ |
---|
222 | virtual void print(); |
---|
223 | |
---|
224 | /** Return the type (an integer identifier) of \c this */ |
---|
225 | virtual int type() const { |
---|
226 | return 103; |
---|
227 | } |
---|
228 | |
---|
229 | /** Compare the original object of \c this with the original object of \c |
---|
230 | brObj. Assumes that there is an ordering of the original objects. |
---|
231 | This method should be invoked only if \c this and brObj are of the same |
---|
232 | type. |
---|
233 | Return negative/0/positive depending on whether \c this is |
---|
234 | smaller/same/larger than the argument. |
---|
235 | */ |
---|
236 | virtual int compareOriginalObject(const CbcBranchingObject* brObj) const; |
---|
237 | |
---|
238 | /** Compare the \c this with \c brObj. \c this and \c brObj must be os the |
---|
239 | same type and must have the same original object, but they may have |
---|
240 | different feasible regions. |
---|
241 | Return the appropriate CbcRangeCompare value (first argument being the |
---|
242 | sub/superset if that's the case). In case of overlap (and if \c |
---|
243 | replaceIfOverlap is true) replace the current branching object with one |
---|
244 | whose feasible region is the overlap. |
---|
245 | */ |
---|
246 | virtual CbcRangeCompare compareBranchingObject |
---|
247 | (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false); |
---|
248 | |
---|
249 | private: |
---|
250 | /// data |
---|
251 | const CbcClique * clique_; |
---|
252 | /// downMask - bit set to fix to weak bounds, not set to leave unfixed |
---|
253 | unsigned int * downMask_; |
---|
254 | /// upMask - bit set to fix to weak bounds, not set to leave unfixed |
---|
255 | unsigned int * upMask_; |
---|
256 | }; |
---|
257 | |
---|
258 | #endif |
---|