1 | /* |
---|
2 | Copyright (C) 2007, Lou Hafer, International Business Machines Corporation |
---|
3 | and others. All Rights Reserved. |
---|
4 | |
---|
5 | This code is licensed under the terms of the Eclipse Public License (EPL). |
---|
6 | |
---|
7 | $Id: CbcGenCtlBlk.hpp 1902 2013-04-10 16:58:16Z forrest $ |
---|
8 | */ |
---|
9 | /* |
---|
10 | This file is part of cbc-generic. |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef CbcGenCtlBlk_H |
---|
14 | #define CbcGenCtlBlk_H |
---|
15 | |
---|
16 | /* \file CbcGenCtlBlk.hpp |
---|
17 | \brief Declarations for parameters of the cbc-generic main program. |
---|
18 | */ |
---|
19 | |
---|
20 | #include "CoinParam.hpp" |
---|
21 | #include "CoinMessageHandler.hpp" |
---|
22 | |
---|
23 | #include "CglCutGenerator.hpp" |
---|
24 | #include "CglProbing.hpp" |
---|
25 | #include "CglClique.hpp" |
---|
26 | #include "CglFlowCover.hpp" |
---|
27 | #include "CglGomory.hpp" |
---|
28 | #include "CglKnapsackCover.hpp" |
---|
29 | #include "CglMixedIntegerRounding2.hpp" |
---|
30 | #include "CglOddHole.hpp" |
---|
31 | #include "CglRedSplit.hpp" |
---|
32 | #include "CglTwomir.hpp" |
---|
33 | |
---|
34 | #include "CbcModel.hpp" |
---|
35 | |
---|
36 | #include "CbcHeuristic.hpp" |
---|
37 | #include "CbcHeuristicFPump.hpp" |
---|
38 | #include "CbcHeuristicGreedy.hpp" |
---|
39 | #include "CbcHeuristicLocal.hpp" |
---|
40 | #include "CbcTreeLocal.hpp" |
---|
41 | |
---|
42 | #include "CbcGenMessages.hpp" |
---|
43 | |
---|
44 | /* |
---|
45 | It turns out that doxygen is not good with anonymous structures. Hence the |
---|
46 | `struct nameCtl_struct' style used for structured fields in CbcGenCtlBlk. |
---|
47 | */ |
---|
48 | |
---|
49 | /* |
---|
50 | $Id: CbcGenCtlBlk.hpp 1902 2013-04-10 16:58:16Z forrest $ |
---|
51 | */ |
---|
52 | |
---|
53 | #define CBC_GENERIC_VERSION "00.01.00" |
---|
54 | |
---|
55 | class CbcGenCtlBlk ; |
---|
56 | namespace CbcGenParamUtils { |
---|
57 | void addCbcGenParams(int &numParams, CoinParamVec ¶mVec, |
---|
58 | CbcGenCtlBlk *ctlBlk) ; |
---|
59 | } |
---|
60 | |
---|
61 | /* \brief cbc-generic algorithm control class |
---|
62 | |
---|
63 | This class defines values and methods used to control the operation of the |
---|
64 | cbc-generic main program. |
---|
65 | */ |
---|
66 | |
---|
67 | class CbcGenCtlBlk { |
---|
68 | |
---|
69 | friend void CbcGenParamUtils::addCbcGenParams(int &numParams, |
---|
70 | CoinParamVec ¶mVec, CbcGenCtlBlk *ctlBlk) ; |
---|
71 | |
---|
72 | public: |
---|
73 | |
---|
74 | /*! \name Enumeration types used for cbc-generic control variables */ |
---|
75 | //@{ |
---|
76 | |
---|
77 | /* |
---|
78 | In order for initialisation to work properly, the order of declaration of |
---|
79 | the enum constants here must match the order of keyword declaration for |
---|
80 | the PREPROCESS parameter in CbcGenParamUtils::addCbcGenParams |
---|
81 | */ |
---|
82 | /*! \brief Codes to control integer preprocessing |
---|
83 | |
---|
84 | - IPPOff: Integer preprocessing is off. |
---|
85 | - IPPOn: Integer preprocessing is on. |
---|
86 | - IPPSave: IPPOn, plus preprocessed system will be saved to presolved.mps. |
---|
87 | - IPPEqual: IPPOn, plus `<=' cliques are converted to `=' cliques. |
---|
88 | - IPPSOS: IPPOn, plus will create SOS sets (see below). |
---|
89 | - IPPTrySOS: IPPOn, plus will create SOS sets (see below). |
---|
90 | - IPPEqualAll: IPPOn, plus turns all valid inequalities into equalities |
---|
91 | with integer slacks. |
---|
92 | - IPPStrategy: look to CbcStrategy object for instructions. |
---|
93 | |
---|
94 | IPPSOS will create SOS sets if all binary variables (except perhaps one) |
---|
95 | can be covered by SOS sets with no overlap between sets. IPPTrySOS will |
---|
96 | allow any number of binary variables to be uncovered. |
---|
97 | */ |
---|
98 | |
---|
99 | typedef enum { IPPOff = 0, IPPOn, IPPSave, IPPEqual, |
---|
100 | IPPSOS, IPPTrySOS, IPPEqualAll, IPPStrategy |
---|
101 | } IPPControl ; |
---|
102 | |
---|
103 | /* |
---|
104 | In order for initialisation to work properly, the order of declaration of |
---|
105 | the enum constants here must match the order of keyword declaration for |
---|
106 | the various cut and heuristic control parameters in |
---|
107 | CbcGenParamUtils::addCbcGenParams |
---|
108 | */ |
---|
109 | /*! \brief Codes to control the use of cut generators and heuristics |
---|
110 | |
---|
111 | - CGOff: the cut generator will not be installed |
---|
112 | - CGOn: the cut generator will be installed; exactly how often it's |
---|
113 | activated depends on the settings at installation |
---|
114 | - CGRoot: the cut generator will be installed with settings that restrict |
---|
115 | it to activation at the root node only. |
---|
116 | - CGIfMove: the cut generator will be installed with settings that allow |
---|
117 | it to remain active only so long as it's generating cuts that |
---|
118 | tighten the relaxation. |
---|
119 | - CGForceOn: the cut generator will be installed with settings that force |
---|
120 | it to be called at every node |
---|
121 | - CGForceBut: the cut generator will be installed with settings that force |
---|
122 | it to be called at every node, but more active at root (probing |
---|
123 | only) |
---|
124 | - CGMarker: a convenience to mark the end of the codes. |
---|
125 | |
---|
126 | The same codes are used for heuristics. |
---|
127 | */ |
---|
128 | |
---|
129 | typedef enum { CGOff, CGOn, CGRoot, CGIfMove, |
---|
130 | CGForceOn, CGForceBut, CGMarker |
---|
131 | } CGControl ; |
---|
132 | |
---|
133 | /*! \brief Codes to specify the assignment of branching priorities |
---|
134 | |
---|
135 | - BPOff: no priorities are passed to cbc |
---|
136 | - BPCost: a priority vector is constructed based on objective coefficients |
---|
137 | - BPOrder: a priority vector is constructed based on column order |
---|
138 | - BPExt: the user has provided a priority vector |
---|
139 | */ |
---|
140 | |
---|
141 | typedef enum { BPOff, BPCost, BPOrder, BPExt } BPControl ; |
---|
142 | |
---|
143 | /*! \brief Major status codes for branch-and-cut |
---|
144 | |
---|
145 | - BACInvalid: status not yet set |
---|
146 | - BACNotRun: branch-and-cut has not yet run for the current problem |
---|
147 | - BACFinish: branch-and-cut has finished normally |
---|
148 | - BACStop: branch-and-cut has stopped on a limit |
---|
149 | - BACAbandon: branch-and-cut abandoned the problem |
---|
150 | - BACUser: branch-and-cut stopped on user signal |
---|
151 | |
---|
152 | Consult minorStatus_ for details. |
---|
153 | |
---|
154 | These codes are (mostly) set to match the codes used by CbcModel. Additions |
---|
155 | to CbcModel codes should be reflected here and in translateMajor. |
---|
156 | */ |
---|
157 | |
---|
158 | typedef enum { BACInvalid = -1, BACFinish = 0, |
---|
159 | BACStop = 1, BACAbandon = 2, BACNotRun, BACUser = 5 |
---|
160 | } BACMajor ; |
---|
161 | |
---|
162 | /*! \brief Minor status codes |
---|
163 | |
---|
164 | - BACmInvalid status not yet set |
---|
165 | - BACmFinish search exhausted the tree; optimal solution found |
---|
166 | - BACmInfeas problem is infeasible |
---|
167 | - BACmUbnd problem is unbounded |
---|
168 | - BACmGap stopped on integrality gap |
---|
169 | - BACmNodeLimit stopped on node limit |
---|
170 | - BACmTimeLimit stopped on time limit |
---|
171 | - BACmSolnLimit stopped on number of solutions limit |
---|
172 | - BACmUser stopped due to user event |
---|
173 | - BACmOther nothing else is appropriate |
---|
174 | |
---|
175 | It's not possible to make these codes agree with CbcModel. The meaning varies |
---|
176 | according to context: if the BACWhere code specifies a relaxation, then the |
---|
177 | minor status reflects the underlying OSI solver. Otherwise, it reflects the |
---|
178 | integer problem. |
---|
179 | */ |
---|
180 | |
---|
181 | typedef enum { BACmInvalid = -1, BACmFinish = 0, BACmInfeas, BACmUbnd, |
---|
182 | BACmGap, BACmNodeLimit, BACmTimeLimit, BACmSolnLimit, |
---|
183 | BACmUser, BACmOther |
---|
184 | } BACMinor ; |
---|
185 | |
---|
186 | /*! \brief Codes to specify where branch-and-cut stopped |
---|
187 | |
---|
188 | - BACwNotStarted stopped before we ever got going |
---|
189 | - BACwBareRoot stopped after initial solve of root relaxation |
---|
190 | - BACwIPP stopped after integer preprocessing |
---|
191 | - BACwIPPRelax stopped after initial solve of preprocessed problem |
---|
192 | - BACwBAC stopped at some point in branch-and-cut |
---|
193 | */ |
---|
194 | |
---|
195 | typedef enum { BACwInvalid = -1, BACwNotStarted = 0, BACwBareRoot, |
---|
196 | BACwIPP, BACwIPPRelax, BACwBAC |
---|
197 | } BACWhere ; |
---|
198 | |
---|
199 | //@} |
---|
200 | |
---|
201 | /*! \name Constructors and destructors */ |
---|
202 | //@{ |
---|
203 | |
---|
204 | /*! \brief Default constructor */ |
---|
205 | |
---|
206 | CbcGenCtlBlk() ; |
---|
207 | |
---|
208 | /*! \brief Destructor */ |
---|
209 | |
---|
210 | ~CbcGenCtlBlk() ; |
---|
211 | //@} |
---|
212 | |
---|
213 | /*! \name Access and Control Functions for Cut Generators and Heuristics |
---|
214 | \brief Control functions, plus lazy creation functions for cut generators |
---|
215 | and heuristics |
---|
216 | |
---|
217 | cbc-generic avoids creating objects for cut generators and heuristics |
---|
218 | unless they're actually used. For cut generators, a prototype is created |
---|
219 | and reused. For heuristics, the default is to create a new object with each |
---|
220 | call, because the model may have changed. The object is returned through |
---|
221 | the reference parameter. The return value of the function is the current |
---|
222 | action state. |
---|
223 | |
---|
224 | Cut generator and heuristic objects created by these calls will be deleted |
---|
225 | with the destruction of the CbcGenCtlBlk object. |
---|
226 | */ |
---|
227 | //@{ |
---|
228 | |
---|
229 | /*! \brief Get cut depth setting |
---|
230 | |
---|
231 | The name is a bit of a misnomer. Essentially, this overrides the |
---|
232 | `every so many nodes' control with `execute when (depth in tree) |
---|
233 | mod (cut depth) == 0'. |
---|
234 | */ |
---|
235 | |
---|
236 | inline int getCutDepth() { |
---|
237 | return cutDepth_ ; |
---|
238 | } |
---|
239 | |
---|
240 | /*! \brief Set cut depth setting. |
---|
241 | |
---|
242 | See comments for getCutDepth(). |
---|
243 | */ |
---|
244 | |
---|
245 | inline void setCutDepth(int cutDepth) { |
---|
246 | cutDepth_ = cutDepth ; |
---|
247 | } |
---|
248 | |
---|
249 | /*1 \brief Get action state for use of integer preprocessing */ |
---|
250 | |
---|
251 | inline IPPControl getIPPAction() { |
---|
252 | return (preProcess_) ; |
---|
253 | } |
---|
254 | |
---|
255 | /*! \brief Set action state for use of integer preprocessing */ |
---|
256 | |
---|
257 | inline void setIPPAction(IPPControl action) { |
---|
258 | preProcess_ = action ; |
---|
259 | } |
---|
260 | |
---|
261 | /*! \brief Obtain a prototype for a probing cut generator. */ |
---|
262 | |
---|
263 | CGControl getProbing(CglCutGenerator *&gen) ; |
---|
264 | |
---|
265 | /*! \brief Set action state for use of probing cut generator. */ |
---|
266 | |
---|
267 | inline void setProbingAction(CGControl action) { |
---|
268 | probing_.action_ = action ; |
---|
269 | } |
---|
270 | |
---|
271 | /*! \brief Obtain a prototype for a clique cut generator. */ |
---|
272 | |
---|
273 | CGControl getClique(CglCutGenerator *&gen) ; |
---|
274 | |
---|
275 | /*! \brief Set action state for use of clique cut generator. */ |
---|
276 | |
---|
277 | inline void setCliqueAction(CGControl action) { |
---|
278 | clique_.action_ = action ; |
---|
279 | } |
---|
280 | |
---|
281 | /*! \brief Obtain a prototype for a flow cover cut generator. */ |
---|
282 | |
---|
283 | CGControl getFlow(CglCutGenerator *&gen) ; |
---|
284 | |
---|
285 | /*! \brief Set action state for use of flow cover cut generator. */ |
---|
286 | |
---|
287 | inline void setFlowAction(CGControl action) { |
---|
288 | flow_.action_ = action ; |
---|
289 | } |
---|
290 | |
---|
291 | /*! \brief Obtain a prototype for a Gomory cut generator. */ |
---|
292 | |
---|
293 | CGControl getGomory(CglCutGenerator *&gen) ; |
---|
294 | |
---|
295 | /*! \brief Set action state for use of Gomory cut generator. */ |
---|
296 | |
---|
297 | inline void setGomoryAction(CGControl action) { |
---|
298 | gomory_.action_ = action ; |
---|
299 | } |
---|
300 | |
---|
301 | /*! \brief Obtain a prototype for a knapsack cover cut generator. */ |
---|
302 | |
---|
303 | CGControl getKnapsack(CglCutGenerator *&gen) ; |
---|
304 | |
---|
305 | /*! \brief Set action state for use of knapsack cut generator. */ |
---|
306 | |
---|
307 | inline void setKnapsackAction(CGControl action) { |
---|
308 | knapsack_.action_ = action ; |
---|
309 | } |
---|
310 | |
---|
311 | /* \brief Obtain a prototype for a lift-and-project cut generator. |
---|
312 | |
---|
313 | CGControl getLandP(CglCutGenerator *&gen) ; |
---|
314 | |
---|
315 | \brief Set action state for use of lift-and-project cut generator. |
---|
316 | |
---|
317 | inline void setLandPAction(CGControl action) |
---|
318 | { landp_.action_ = action ; } |
---|
319 | */ |
---|
320 | |
---|
321 | /*! \brief Obtain a prototype for a mixed integer rounding (MIR) |
---|
322 | cut generator. |
---|
323 | */ |
---|
324 | |
---|
325 | CGControl getMir(CglCutGenerator *&gen) ; |
---|
326 | |
---|
327 | /*! \brief Set action state for use of MIR cut generator. */ |
---|
328 | |
---|
329 | inline void setMirAction(CGControl action) { |
---|
330 | mir_.action_ = action ; |
---|
331 | } |
---|
332 | |
---|
333 | /*! \brief Obtain a prototype for a reduce and split cut generator. */ |
---|
334 | |
---|
335 | CGControl getRedSplit(CglCutGenerator *&gen) ; |
---|
336 | |
---|
337 | /*! \brief Set action state for use of reduce and split cut generator. */ |
---|
338 | |
---|
339 | inline void setRedSplitAction(CGControl action) { |
---|
340 | redSplit_.action_ = action ; |
---|
341 | } |
---|
342 | |
---|
343 | /*! \brief Obtain a prototype for a 2-MIR cut generator. */ |
---|
344 | |
---|
345 | CGControl getTwomir(CglCutGenerator *&gen) ; |
---|
346 | |
---|
347 | /*! \brief Set action state for use of 2-MIR cut generator. */ |
---|
348 | |
---|
349 | inline void setTwomirAction(CGControl action) { |
---|
350 | twomir_.action_ = action ; |
---|
351 | } |
---|
352 | |
---|
353 | |
---|
354 | /*! \brief Obtain a feasibility pump heuristic. |
---|
355 | |
---|
356 | By default, any existing object is deleted and a new object is created and |
---|
357 | loaded with \c model. Set alwaysCreate = false to return an existing object |
---|
358 | if one exists. |
---|
359 | */ |
---|
360 | |
---|
361 | CGControl getFPump(CbcHeuristic *&gen, CbcModel *model, |
---|
362 | bool alwaysCreate = true) ; |
---|
363 | |
---|
364 | /*! \brief Set action state for use of feasibility pump heuristic. */ |
---|
365 | |
---|
366 | inline void setFPumpAction(CGControl action) { |
---|
367 | fpump_.action_ = action ; |
---|
368 | } |
---|
369 | |
---|
370 | /*! \brief Obtain a local search/combine heuristic. |
---|
371 | |
---|
372 | By default, any existing object is deleted and a new object is created and |
---|
373 | loaded with \c model. Set alwaysCreate = false to return an existing object |
---|
374 | if one exists. |
---|
375 | */ |
---|
376 | |
---|
377 | CGControl getCombine(CbcHeuristic *&gen, CbcModel *model, |
---|
378 | bool alwaysCreate = true) ; |
---|
379 | |
---|
380 | /*! \brief Set action state for use of local search/combine heuristic. */ |
---|
381 | |
---|
382 | inline void setCombineAction(CGControl action) { |
---|
383 | combine_.action_ = action ; |
---|
384 | } |
---|
385 | |
---|
386 | /*! \brief Obtain a greedy cover heuristic. |
---|
387 | |
---|
388 | By default, any existing object is deleted and a new object is created and |
---|
389 | loaded with \c model. Set alwaysCreate = false to return an existing object |
---|
390 | if one exists. |
---|
391 | */ |
---|
392 | |
---|
393 | CGControl getGreedyCover(CbcHeuristic *&gen, CbcModel *model, |
---|
394 | bool alwaysCreate = true) ; |
---|
395 | |
---|
396 | /*! \brief Set action state for use of greedy cover heuristic. */ |
---|
397 | |
---|
398 | inline void setGreedyCoverAction(CGControl action) { |
---|
399 | greedyCover_.action_ = action ; |
---|
400 | } |
---|
401 | |
---|
402 | /*! \brief Obtain a greedy equality heuristic. |
---|
403 | |
---|
404 | By default, any existing object is deleted and a new object is created and |
---|
405 | loaded with \c model. Set alwaysCreate = false to return an existing object |
---|
406 | if one exists. |
---|
407 | */ |
---|
408 | |
---|
409 | CGControl getGreedyEquality(CbcHeuristic *&gen, CbcModel *model, |
---|
410 | bool alwaysCreate = true) ; |
---|
411 | |
---|
412 | /*! \brief Set action state for use of greedy equality heuristic. */ |
---|
413 | |
---|
414 | inline void setGreedyEqualityAction(CGControl action) { |
---|
415 | greedyEquality_.action_ = action ; |
---|
416 | } |
---|
417 | |
---|
418 | /*! \brief Obtain a simple rounding heuristic. |
---|
419 | |
---|
420 | By default, any existing object is deleted and a new object is created and |
---|
421 | loaded with \c model. Set alwaysCreate = false to return an existing object |
---|
422 | if one exists. |
---|
423 | */ |
---|
424 | |
---|
425 | CGControl getRounding(CbcHeuristic *&gen, CbcModel *model, |
---|
426 | bool alwaysCreate = true) ; |
---|
427 | |
---|
428 | /*! \brief Set action state for use of simple rounding heuristic. */ |
---|
429 | |
---|
430 | inline void setRoundingAction(CGControl action) { |
---|
431 | rounding_.action_ = action ; |
---|
432 | } |
---|
433 | |
---|
434 | /*! \brief Obtain a local search tree object |
---|
435 | |
---|
436 | By default, any existing object is deleted and a new object is created and |
---|
437 | loaded with \c model. Set alwaysCreate = false to return an existing object |
---|
438 | if one exists. |
---|
439 | */ |
---|
440 | |
---|
441 | CGControl getTreeLocal(CbcTreeLocal *&localTree, CbcModel *model, |
---|
442 | bool alwaysCreate = true) ; |
---|
443 | |
---|
444 | /*! \brief Set action state for use of local tree. */ |
---|
445 | |
---|
446 | inline void setTreeLocalAction(CGControl action) { |
---|
447 | localTree_.action_ = action ; |
---|
448 | } |
---|
449 | |
---|
450 | //@} |
---|
451 | |
---|
452 | /*! \name Status Functions |
---|
453 | \brief Convenience routines for status codes. |
---|
454 | */ |
---|
455 | //@{ |
---|
456 | |
---|
457 | /*! \brief Set the result of branch-and-cut search */ |
---|
458 | |
---|
459 | inline void setBaBStatus(BACMajor majorStatus, BACMinor minorStatus, |
---|
460 | BACWhere where, bool haveAnswer, |
---|
461 | OsiSolverInterface *answerSolver) { |
---|
462 | bab_.majorStatus_ = majorStatus ; |
---|
463 | bab_.minorStatus_ = minorStatus ; |
---|
464 | bab_.where_ = where ; |
---|
465 | bab_.haveAnswer_ = haveAnswer ; |
---|
466 | bab_.answerSolver_ = answerSolver ; |
---|
467 | } |
---|
468 | |
---|
469 | /*! \brief Set the result of branch-and-cut search |
---|
470 | |
---|
471 | This version will extract the necessary information from the CbcModel |
---|
472 | object and set appropriate status based on the value passed for where. |
---|
473 | */ |
---|
474 | void setBaBStatus(const CbcModel *model, BACWhere where, |
---|
475 | bool haveAnswer = false, |
---|
476 | OsiSolverInterface *answerSolver = 0) ; |
---|
477 | |
---|
478 | /*! \brief Translate CbcModel major status to #BACMajor |
---|
479 | |
---|
480 | See the #BACMajor enum for details. |
---|
481 | */ |
---|
482 | BACMajor translateMajor(int status) ; |
---|
483 | |
---|
484 | /*!\brief Translate CbcModel minor status to #BACMinor |
---|
485 | |
---|
486 | See the #BACMinor enum for details. |
---|
487 | */ |
---|
488 | BACMinor translateMinor(int status) ; |
---|
489 | |
---|
490 | /*!\brief Translate OsiSolverInterface status to #BACMinor |
---|
491 | |
---|
492 | See the #BACMinor enum for details. Optimal, infeasible, and unbounded |
---|
493 | get their own codes; everything else maps to BACmOther. |
---|
494 | */ |
---|
495 | BACMinor translateMinor(const OsiSolverInterface *osi) ; |
---|
496 | |
---|
497 | /*! \brief Print the status block */ |
---|
498 | |
---|
499 | void printBaBStatus() ; |
---|
500 | |
---|
501 | //@} |
---|
502 | |
---|
503 | /*! \name Messages and statistics */ |
---|
504 | //@{ |
---|
505 | |
---|
506 | /*! \brief Print a message |
---|
507 | |
---|
508 | Uses the current message handler and messages. |
---|
509 | */ |
---|
510 | CoinMessageHandler &message(CbcGenMsgCode inID) ; |
---|
511 | |
---|
512 | /*! \brief Supply a new message handler. |
---|
513 | |
---|
514 | Replaces the current message handler. The current handler is destroyed |
---|
515 | if ourMsgHandler_ is true, and the call will set ourMsgHandler_ = true. |
---|
516 | */ |
---|
517 | void passInMessageHandler(CoinMessageHandler *handler) ; |
---|
518 | |
---|
519 | /*! \brief Return a pointer to the message handler */ |
---|
520 | inline CoinMessageHandler *messageHandler() const { |
---|
521 | return msgHandler_ ; |
---|
522 | } |
---|
523 | |
---|
524 | /*! \brief Set up messages in the specified language. |
---|
525 | |
---|
526 | Building a set of messages in a given language implies rebuilding the |
---|
527 | whole set of messages, for reasons explained in the body of the code. |
---|
528 | Hence there's no separate setLanguage routine. Use this routine for the |
---|
529 | initial setup of messages and any subsequent change in language. Note |
---|
530 | that the constructor gives you a message handler by default, but \e not |
---|
531 | messages. You need to call setMessages explicitly. |
---|
532 | |
---|
533 | The default value specified here for lang effectively sets the default |
---|
534 | language. |
---|
535 | */ |
---|
536 | void setMessages(CoinMessages::Language lang = CoinMessages::us_en) ; |
---|
537 | |
---|
538 | /*! \brief Set log level */ |
---|
539 | inline void setLogLevel(int lvl) { |
---|
540 | logLvl_ = lvl ; |
---|
541 | if (msgHandler_) msgHandler_->setLogLevel(lvl) ; |
---|
542 | } |
---|
543 | |
---|
544 | /*! \brief Get log level */ |
---|
545 | inline int logLevel() const { |
---|
546 | return (logLvl_) ; |
---|
547 | } |
---|
548 | |
---|
549 | /*! \brief When greater than 0, integer presolve gives more information and |
---|
550 | branch-and-cut provides statistics. |
---|
551 | */ |
---|
552 | int printOpt_ ; |
---|
553 | |
---|
554 | //@} |
---|
555 | |
---|
556 | /*! \name Parameter parsing and input/output. */ |
---|
557 | //@{ |
---|
558 | /*! \brief cbc-generic version */ |
---|
559 | |
---|
560 | std::string version_ ; |
---|
561 | |
---|
562 | /*! \brief Default directory prefix */ |
---|
563 | |
---|
564 | std::string dfltDirectory_ ; |
---|
565 | |
---|
566 | /*! \brief Last MPS input file */ |
---|
567 | |
---|
568 | std::string lastMpsIn_ ; |
---|
569 | |
---|
570 | /*! \brief Allow/disallow errors when importing a model */ |
---|
571 | bool allowImportErrors_ ; |
---|
572 | |
---|
573 | /*! \brief Last solution output file */ |
---|
574 | |
---|
575 | std::string lastSolnOut_ ; |
---|
576 | |
---|
577 | /*! \brief Solution printing mode |
---|
578 | |
---|
579 | Controls the amount of information printed when printing a solution. |
---|
580 | Coding is set by the keyword declarations for the printingOptions |
---|
581 | command. |
---|
582 | */ |
---|
583 | int printMode_ ; |
---|
584 | |
---|
585 | /*! \brief Print mask |
---|
586 | |
---|
587 | Used to specify row/column names to be printed. Not implemented as of |
---|
588 | 060920. |
---|
589 | */ |
---|
590 | std::string printMask_ ; |
---|
591 | |
---|
592 | /*! \brief The parameter vector */ |
---|
593 | |
---|
594 | CoinParamVec *paramVec_ ; |
---|
595 | |
---|
596 | /*! \brief Start and end of cbc-generic parameters in parameter vector */ |
---|
597 | |
---|
598 | struct genParamsInfo_struct { |
---|
599 | int first_ ; |
---|
600 | int last_ ; |
---|
601 | } genParams_ ; |
---|
602 | |
---|
603 | /*! \brief Start and end of CbcModel parameters in parameter vector */ |
---|
604 | |
---|
605 | struct cbcParamsInfo_struct { |
---|
606 | int first_ ; |
---|
607 | int last_ ; |
---|
608 | } cbcParams_ ; |
---|
609 | |
---|
610 | /*! \brief Start and end of OsiSolverInterface parameters in parameter |
---|
611 | vector |
---|
612 | */ |
---|
613 | |
---|
614 | struct osiParamsInfo_struct { |
---|
615 | int first_ ; |
---|
616 | int last_ ; |
---|
617 | } osiParams_ ; |
---|
618 | |
---|
619 | /*! \brief Verbosity level for help messages. |
---|
620 | |
---|
621 | Interpretation is bitwise: |
---|
622 | - (0): short help |
---|
623 | - (1): long help |
---|
624 | - (2): unused (for compatibility with cbc; indicates AMPL) |
---|
625 | - (3): show parameters with display = false. |
---|
626 | */ |
---|
627 | |
---|
628 | int verbose_ ; |
---|
629 | |
---|
630 | /*! \brief Number of parameters processed */ |
---|
631 | |
---|
632 | int paramsProcessed_ ; |
---|
633 | |
---|
634 | /*! \brief Record of parameters changed by user command */ |
---|
635 | |
---|
636 | std::vector<bool> setByUser_ ; |
---|
637 | |
---|
638 | /*! \brief False if the user has made nontrivial modifications to the |
---|
639 | default control settings. |
---|
640 | |
---|
641 | Initially true. Specifying DJFIX, TIGHTENFACTOR, or any cut or heuristic |
---|
642 | parameter will set this to false. |
---|
643 | */ |
---|
644 | bool defaultSettings_ ; |
---|
645 | |
---|
646 | /*! \brief Control debug file creation |
---|
647 | |
---|
648 | At the conclusion of branch-and-cut, dump the full solution in a binary |
---|
649 | format to debug.file in the current directory. When set to |
---|
650 | "createAfterPre", the solution is dumped before integer presolve |
---|
651 | transforms are removed. When set to "create", the solution is dumped |
---|
652 | after integer presolve transforms are backed out. |
---|
653 | */ |
---|
654 | std::string debugCreate_ ; |
---|
655 | |
---|
656 | /*! \brief Last debug input file |
---|
657 | |
---|
658 | The file is expected to be in a binary format understood by |
---|
659 | activateRowCutDebugger. |
---|
660 | */ |
---|
661 | |
---|
662 | std::string debugFile_ ; |
---|
663 | |
---|
664 | /*! \brief Array of primal variable values for debugging |
---|
665 | |
---|
666 | Used to provide a known optimal solution to activateRowCutDebugger(). |
---|
667 | */ |
---|
668 | |
---|
669 | struct debugSolInfo_struct { |
---|
670 | int numCols_ ; |
---|
671 | double *values_ ; |
---|
672 | } debugSol_ ; |
---|
673 | //@} |
---|
674 | |
---|
675 | /* \name Timing */ |
---|
676 | //@{ |
---|
677 | |
---|
678 | /*! \brief Total elapsed time for this run. */ |
---|
679 | |
---|
680 | double totalTime_ ; |
---|
681 | |
---|
682 | //@} |
---|
683 | |
---|
684 | /*! \name Models of various flavours */ |
---|
685 | //@{ |
---|
686 | |
---|
687 | /*! \brief The reference CbcModel object. |
---|
688 | |
---|
689 | This is the CbcModel created when cbc-generic boots up. It holds the |
---|
690 | default solver with the current constraint system. CbcCbcParam parameters |
---|
691 | are applied here, and CbcOsiParam parameters are applied to the solver. |
---|
692 | Major modifications for branch-and-cut (integer preprocessing, |
---|
693 | installation of heuristics and cut generators) are performed on a clone. |
---|
694 | The solution is transferred back into this object. |
---|
695 | */ |
---|
696 | |
---|
697 | CbcModel *model_ ; |
---|
698 | |
---|
699 | /*! \brief The current default LP solver |
---|
700 | |
---|
701 | This is a pointer to a reference copy. If you want the solver associated |
---|
702 | with #model_, ask for it directly. |
---|
703 | */ |
---|
704 | |
---|
705 | OsiSolverInterface *dfltSolver_ ; |
---|
706 | |
---|
707 | /*! \brief True if we have a valid model loaded, false otherwise. */ |
---|
708 | |
---|
709 | bool goodModel_ ; |
---|
710 | |
---|
711 | /*! \brief State of branch-and-cut |
---|
712 | |
---|
713 | Major and minor status codes, and a solver holding the answer, assuming |
---|
714 | we have a valid answer. See the documentation with the BACMajor, |
---|
715 | BACMinor, and BACWhere enums for the meaning of the codes. |
---|
716 | */ |
---|
717 | |
---|
718 | struct babState_struct { |
---|
719 | BACMajor majorStatus_ ; |
---|
720 | BACMinor minorStatus_ ; |
---|
721 | BACWhere where_ ; |
---|
722 | bool haveAnswer_ ; |
---|
723 | OsiSolverInterface *answerSolver_ ; |
---|
724 | } bab_ ; |
---|
725 | |
---|
726 | //@} |
---|
727 | |
---|
728 | /*! \name Various algorithm control variables and settings */ |
---|
729 | //@{ |
---|
730 | |
---|
731 | /*! \brief Control use of reduced cost fixing prior to B&C |
---|
732 | |
---|
733 | This heuristic fixes variables whose reduced cost for the root |
---|
734 | relaxtion exceeds the specified threshold. This is purely a heuristic, |
---|
735 | performed before there's any incumbent solution. It may well fix variables |
---|
736 | at the wrong bound! |
---|
737 | */ |
---|
738 | |
---|
739 | struct djFixCtl_struct { |
---|
740 | bool action_ ; |
---|
741 | double threshold_ ; |
---|
742 | } djFix_ ; |
---|
743 | |
---|
744 | /*! \brief Control the assignment of branching priorities to integer |
---|
745 | variables. |
---|
746 | */ |
---|
747 | BPControl priorityAction_ ; |
---|
748 | |
---|
749 | //@} |
---|
750 | |
---|
751 | /*! \name Branching Method Control |
---|
752 | \brief Usage control and prototypes for branching methods. |
---|
753 | |
---|
754 | Looking to the future, this covers only OsiChoose methods. |
---|
755 | */ |
---|
756 | //@{ |
---|
757 | |
---|
758 | /*! \brief Control variables for a strong branching method. |
---|
759 | |
---|
760 | Consult OsiChooseVariable and CbcModel for details. An artifact of the |
---|
761 | changeover from CbcObjects to OsiObjects is that the number of uses before |
---|
762 | pseudo costs are trusted (numBeforeTrust_) and the number of variables |
---|
763 | evaluated with strong branching (numStrong_) are parameters of CbcModel. |
---|
764 | */ |
---|
765 | struct chooseStrongCtl_struct { |
---|
766 | int numBeforeTrust_ ; |
---|
767 | int numStrong_ ; |
---|
768 | int shadowPriceMode_ ; |
---|
769 | } chooseStrong_ ; |
---|
770 | //@} |
---|
771 | |
---|
772 | private: |
---|
773 | |
---|
774 | /*! \name Cut Generator and Heuristic Control |
---|
775 | \brief Usage control and prototypes for cut generators and heuristics. |
---|
776 | */ |
---|
777 | //@{ |
---|
778 | |
---|
779 | /*! \brief Control integer preprocessing. */ |
---|
780 | |
---|
781 | IPPControl preProcess_ ; |
---|
782 | |
---|
783 | /*! \brief Control cut generator activity |
---|
784 | |
---|
785 | Generators that are active in the tree will be activated when |
---|
786 | (depth) mod (cutDepth) == 0. |
---|
787 | */ |
---|
788 | |
---|
789 | int cutDepth_ ; |
---|
790 | |
---|
791 | /*! \brief Control variable and prototype for probing cut generator */ |
---|
792 | struct probingCtl_struct { |
---|
793 | CGControl action_ ; |
---|
794 | CglProbing *proto_ ; |
---|
795 | bool usingObjective_ ; |
---|
796 | int maxPass_ ; |
---|
797 | int maxPassRoot_ ; |
---|
798 | int maxProbe_ ; |
---|
799 | int maxProbeRoot_ ; |
---|
800 | int maxLook_ ; |
---|
801 | int maxLookRoot_ ; |
---|
802 | int maxElements_ ; |
---|
803 | int rowCuts_ ; |
---|
804 | } probing_ ; |
---|
805 | |
---|
806 | /*! \brief Control variable and prototype for clique cut generator */ |
---|
807 | struct cliqueCtl_struct { |
---|
808 | CGControl action_ ; |
---|
809 | CglClique *proto_ ; |
---|
810 | bool starCliqueReport_ ; |
---|
811 | bool rowCliqueReport_ ; |
---|
812 | double minViolation_ ; |
---|
813 | } clique_ ; |
---|
814 | |
---|
815 | /*! \brief Control variable and prototype for flow cover cut generator */ |
---|
816 | struct flowCtl_struct { |
---|
817 | CGControl action_ ; |
---|
818 | CglFlowCover *proto_ ; |
---|
819 | } flow_ ; |
---|
820 | |
---|
821 | /*! \brief Control variable and prototype for Gomory cut generator */ |
---|
822 | struct gomoryCtl_struct { |
---|
823 | CGControl action_ ; |
---|
824 | CglGomory *proto_ ; |
---|
825 | int limit_ ; |
---|
826 | int limitAtRoot_ ; |
---|
827 | } gomory_ ; |
---|
828 | |
---|
829 | /* \brief Control variable and prototype for lift-and-project cut |
---|
830 | generator |
---|
831 | struct landpCtl_struct |
---|
832 | { CGControl action_ ; |
---|
833 | CglLandP *proto_ ; } landp_ ; |
---|
834 | */ |
---|
835 | |
---|
836 | /*! \brief Control variable and prototype for knapsack cover cut generator */ |
---|
837 | struct knapsackCtl_struct { |
---|
838 | CGControl action_ ; |
---|
839 | CglKnapsackCover *proto_ ; |
---|
840 | } knapsack_ ; |
---|
841 | |
---|
842 | /*! \brief Control variable and prototype for MIR cut generator */ |
---|
843 | struct mirCtl_struct { |
---|
844 | CGControl action_ ; |
---|
845 | CglMixedIntegerRounding2 *proto_ ; |
---|
846 | } mir_ ; |
---|
847 | |
---|
848 | /*! \brief Control variable and prototype for odd hole cut generator */ |
---|
849 | struct oddHoleCtl_struct { |
---|
850 | CGControl action_ ; |
---|
851 | CglOddHole *proto_ ; |
---|
852 | } oddHole_ ; |
---|
853 | |
---|
854 | /*! \brief Control variable and prototype for reduce-and-split |
---|
855 | cut generator |
---|
856 | */ |
---|
857 | struct redSplitCtl_struct { |
---|
858 | CGControl action_ ; |
---|
859 | CglRedSplit *proto_ ; |
---|
860 | } redSplit_ ; |
---|
861 | |
---|
862 | /*! \brief Control variable and prototype for Two-MIR cut generator */ |
---|
863 | struct twomirCtl_struct { |
---|
864 | CGControl action_ ; |
---|
865 | CglTwomir *proto_ ; |
---|
866 | int maxElements_ ; |
---|
867 | } twomir_ ; |
---|
868 | |
---|
869 | /*! \brief Control variable and prototype for feasibility pump heuristic */ |
---|
870 | struct fpumpCtl_struct { |
---|
871 | CGControl action_ ; |
---|
872 | CbcHeuristicFPump *proto_ ; |
---|
873 | int iters_ ; |
---|
874 | } fpump_ ; |
---|
875 | |
---|
876 | /*! \brief Control variable and prototype for combine heuristic */ |
---|
877 | struct combineCtl_struct { |
---|
878 | CGControl action_ ; |
---|
879 | CbcHeuristicLocal *proto_ ; |
---|
880 | int trySwap_ ; |
---|
881 | } combine_ ; |
---|
882 | |
---|
883 | /*! \brief Control variable and prototype for greedy cover heuristic */ |
---|
884 | struct greedyCoverCtl_struct { |
---|
885 | CGControl action_ ; |
---|
886 | CbcHeuristicGreedyCover *proto_ ; |
---|
887 | } greedyCover_ ; |
---|
888 | |
---|
889 | /*! \brief Control variable and prototype for greedy equality heuristic */ |
---|
890 | struct greedyEqualityCtl_struct { |
---|
891 | CGControl action_ ; |
---|
892 | CbcHeuristicGreedyEquality *proto_ ; |
---|
893 | } greedyEquality_ ; |
---|
894 | |
---|
895 | /*! \brief Control variable and prototype for simple rounding heuristic */ |
---|
896 | struct roundingCtl_struct { |
---|
897 | CGControl action_ ; |
---|
898 | CbcRounding *proto_ ; |
---|
899 | } rounding_ ; |
---|
900 | |
---|
901 | |
---|
902 | /*! \brief Control variables for local tree |
---|
903 | |
---|
904 | This is a bit different --- getTreeLocal() takes a CbcModel as a parameter |
---|
905 | and installs a local tree object. But we can keep the parameters here and |
---|
906 | hide the details. Consult CbcTreeLocal.hpp for details. |
---|
907 | */ |
---|
908 | struct localTreeCtl_struct { |
---|
909 | CGControl action_ ; |
---|
910 | CbcTreeLocal *proto_ ; |
---|
911 | double *soln_ ; |
---|
912 | int range_ ; |
---|
913 | int typeCuts_ ; |
---|
914 | int maxDiverge_ ; |
---|
915 | int timeLimit_ ; |
---|
916 | int nodeLimit_ ; |
---|
917 | bool refine_ ; |
---|
918 | } localTree_ ; |
---|
919 | |
---|
920 | //@} |
---|
921 | |
---|
922 | /*! \name Messages and statistics (private) |
---|
923 | \brief Data and objects related to messages and statistics that should be |
---|
924 | protected from direct manipulation. |
---|
925 | */ |
---|
926 | //@{ |
---|
927 | |
---|
928 | /*! \brief Message handler. */ |
---|
929 | CoinMessageHandler *msgHandler_ ; |
---|
930 | |
---|
931 | /*! \brief Ownership of message handler. |
---|
932 | |
---|
933 | If true, the control block owns the message handler and it will be destroyed |
---|
934 | with the control block. If false, the client is responsible for the message |
---|
935 | handler. |
---|
936 | */ |
---|
937 | bool ourMsgHandler_ ; |
---|
938 | |
---|
939 | /*! \brief The current language */ |
---|
940 | CoinMessages::Language cur_lang_ ; |
---|
941 | |
---|
942 | /*! \brief The current set of messages. */ |
---|
943 | CoinMessages *msgs_ ; |
---|
944 | |
---|
945 | /*! \brief The current log level */ |
---|
946 | int logLvl_ ; |
---|
947 | |
---|
948 | //@} |
---|
949 | |
---|
950 | } ; |
---|
951 | |
---|
952 | |
---|
953 | #endif |
---|
954 | |
---|