1 | // Copyright (C) 2002, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | #ifndef CbcModel_H |
---|
4 | #define CbcModel_H |
---|
5 | #include <string> |
---|
6 | #include <vector> |
---|
7 | #include "CoinFinite.hpp" |
---|
8 | #include "CoinMessageHandler.hpp" |
---|
9 | #include "OsiSolverInterface.hpp" |
---|
10 | #include "OsiBranchingObject.hpp" |
---|
11 | #include "OsiCuts.hpp" |
---|
12 | #include "CoinWarmStartBasis.hpp" |
---|
13 | #include "CbcCompareBase.hpp" |
---|
14 | #include "CbcMessage.hpp" |
---|
15 | |
---|
16 | //class OsiSolverInterface; |
---|
17 | |
---|
18 | class CbcCutGenerator; |
---|
19 | class OsiRowCut; |
---|
20 | class OsiBabSolver; |
---|
21 | class OsiRowCutDebugger; |
---|
22 | class CglCutGenerator; |
---|
23 | class CbcCutModifier; |
---|
24 | class CglTreeProbingInfo; |
---|
25 | class CbcHeuristic; |
---|
26 | class OsiObject; |
---|
27 | class CbcTree; |
---|
28 | class CbcStrategy; |
---|
29 | class CbcFeasibilityBase; |
---|
30 | class CbcStatistics; |
---|
31 | class CbcEventHandler ; |
---|
32 | class CglPreProcess; |
---|
33 | |
---|
34 | // #define CBC_CHECK_BASIS 1 |
---|
35 | |
---|
36 | //############################################################################# |
---|
37 | |
---|
38 | /** Simple Branch and bound class |
---|
39 | |
---|
40 | The initialSolve() method solves the initial LP relaxation of the MIP |
---|
41 | problem. The branchAndBound() method can then be called to finish using |
---|
42 | a branch and cut algorithm. |
---|
43 | |
---|
44 | <h3>Search Tree Traversal</h3> |
---|
45 | |
---|
46 | Subproblems (aka nodes) requiring additional evaluation are stored using |
---|
47 | the CbcNode and CbcNodeInfo objects. Ancestry linkage is maintained in the |
---|
48 | CbcNodeInfo object. Evaluation of a subproblem within branchAndBound() |
---|
49 | proceeds as follows: |
---|
50 | <ul> |
---|
51 | <li> The node representing the most promising parent subproblem is popped |
---|
52 | from the heap which holds the set of subproblems requiring further |
---|
53 | evaluation. |
---|
54 | <li> Using branching instructions stored in the node, and information in |
---|
55 | its ancestors, the model and solver are adjusted to create the |
---|
56 | active subproblem. |
---|
57 | <li> If the parent subproblem will require further evaluation |
---|
58 | (<i>i.e.</i>, there are branches remaining) its node is pushed back |
---|
59 | on the heap. Otherwise, the node is deleted. This may trigger |
---|
60 | recursive deletion of ancestors. |
---|
61 | <li> The newly created subproblem is evaluated. |
---|
62 | <li> If the subproblem requires further evaluation, a node is created. |
---|
63 | All information needed to recreate the subproblem (branching |
---|
64 | information, row and column cuts) is placed in the node and the node |
---|
65 | is added to the set of subproblems awaiting further evaluation. |
---|
66 | </ul> |
---|
67 | Note that there is never a node representing the active subproblem; the model |
---|
68 | and solver represent the active subproblem. |
---|
69 | |
---|
70 | <h3>Row (Constraint) Cut Handling</h3> |
---|
71 | |
---|
72 | For a typical subproblem, the sequence of events is as follows: |
---|
73 | <ul> |
---|
74 | <li> The subproblem is rebuilt for further evaluation: One result of a |
---|
75 | call to addCuts() is a traversal of ancestors, leaving a list of all |
---|
76 | cuts used in the ancestors in #addedCuts_. This list is then scanned |
---|
77 | to construct a basis that includes only tight cuts. Entries for |
---|
78 | loose cuts are set to NULL. |
---|
79 | <li> The subproblem is evaluated: One result of a call to solveWithCuts() |
---|
80 | is the return of a set of newly generated cuts for the subproblem. |
---|
81 | #addedCuts_ is also kept up-to-date as old cuts become loose. |
---|
82 | <li> The subproblem is stored for further processing: A call to |
---|
83 | CbcNodeInfo::addCuts() adds the newly generated cuts to the |
---|
84 | CbcNodeInfo object associated with this node. |
---|
85 | </ul> |
---|
86 | See CbcCountRowCut for details of the bookkeeping associated with cut |
---|
87 | management. |
---|
88 | */ |
---|
89 | |
---|
90 | class CbcModel { |
---|
91 | |
---|
92 | public: |
---|
93 | |
---|
94 | enum CbcIntParam { |
---|
95 | /** The maximum number of nodes before terminating */ |
---|
96 | CbcMaxNumNode=0, |
---|
97 | /** The maximum number of solutions before terminating */ |
---|
98 | CbcMaxNumSol, |
---|
99 | /** Fathoming discipline |
---|
100 | |
---|
101 | Controls objective function comparisons for purposes of fathoming by bound |
---|
102 | or determining monotonic variables. |
---|
103 | |
---|
104 | If 1, action is taken only when the current objective is strictly worse |
---|
105 | than the target. Implementation is handled by adding a small tolerance to |
---|
106 | the target. |
---|
107 | */ |
---|
108 | CbcFathomDiscipline, |
---|
109 | /** Adjusts printout |
---|
110 | 1 does different node message with number unsatisfied on last branch |
---|
111 | */ |
---|
112 | CbcPrinting, |
---|
113 | /** Just a marker, so that a static sized array can store parameters. */ |
---|
114 | CbcLastIntParam |
---|
115 | }; |
---|
116 | |
---|
117 | enum CbcDblParam { |
---|
118 | /** The maximum amount the value of an integer variable can vary from |
---|
119 | integer and still be considered feasible. */ |
---|
120 | CbcIntegerTolerance=0, |
---|
121 | /** The objective is assumed to worsen by this amount for each |
---|
122 | integer infeasibility. */ |
---|
123 | CbcInfeasibilityWeight, |
---|
124 | /** The amount by which to tighten the objective function cutoff when |
---|
125 | a new solution is discovered. */ |
---|
126 | CbcCutoffIncrement, |
---|
127 | /** Stop when the gap between the objective value of the best known solution |
---|
128 | and the best bound on the objective of any solution is less than this. |
---|
129 | |
---|
130 | This is an absolute value. Conversion from a percentage is left to the |
---|
131 | client. |
---|
132 | */ |
---|
133 | CbcAllowableGap, |
---|
134 | /** Stop when the gap between the objective value of the best known solution |
---|
135 | and the best bound on the objective of any solution is less than this |
---|
136 | fraction of of the absolute value of best known solution. |
---|
137 | |
---|
138 | Code stops if either this test or CbcAllowableGap test succeeds |
---|
139 | */ |
---|
140 | CbcAllowableFractionGap, |
---|
141 | /** \brief The maximum number of seconds before terminating. |
---|
142 | A double should be adequate! */ |
---|
143 | CbcMaximumSeconds, |
---|
144 | /// Cutoff - stored for speed |
---|
145 | CbcCurrentCutoff, |
---|
146 | /// Optimization direction - stored for speed |
---|
147 | CbcOptimizationDirection, |
---|
148 | /// Current objective value |
---|
149 | CbcCurrentObjectiveValue, |
---|
150 | /// Current minimization objective value |
---|
151 | CbcCurrentMinimizationObjectiveValue, |
---|
152 | /** \brief The time at start of model. |
---|
153 | So that other pieces of code can access */ |
---|
154 | CbcStartSeconds, |
---|
155 | /** Just a marker, so that a static sized array can store parameters. */ |
---|
156 | CbcLastDblParam |
---|
157 | }; |
---|
158 | |
---|
159 | //--------------------------------------------------------------------------- |
---|
160 | |
---|
161 | public: |
---|
162 | ///@name Solve methods |
---|
163 | //@{ |
---|
164 | /** \brief Solve the initial LP relaxation |
---|
165 | |
---|
166 | Invoke the solver's %initialSolve() method. |
---|
167 | */ |
---|
168 | void initialSolve(); |
---|
169 | |
---|
170 | /** \brief Invoke the branch \& cut algorithm |
---|
171 | |
---|
172 | The method assumes that initialSolve() has been called to solve the |
---|
173 | LP relaxation. It processes the root node, then proceeds to explore the |
---|
174 | branch & cut search tree. The search ends when the tree is exhausted or |
---|
175 | one of several execution limits is reached. |
---|
176 | If doStatistics is 1 summary statistics are printed |
---|
177 | if 2 then also the path to best solution (if found by branching) |
---|
178 | if 3 then also one line per node |
---|
179 | */ |
---|
180 | void branchAndBound(int doStatistics=0); |
---|
181 | |
---|
182 | /** \brief create a clean model from partially fixed problem |
---|
183 | |
---|
184 | The method creates a new model with given bounds and with no tree. |
---|
185 | */ |
---|
186 | CbcModel * cleanModel(const double * lower, const double * upper); |
---|
187 | /** \brief Invoke the branch \& cut algorithm on partially fixed problem |
---|
188 | |
---|
189 | The method presolves the given model and does branch and cut. The search |
---|
190 | ends when the tree is exhausted or maximum nodes is reached. |
---|
191 | |
---|
192 | If better solution found then it is saved. |
---|
193 | |
---|
194 | Returns 0 if search completed and solution, 1 if not completed and solution, |
---|
195 | 2 if completed and no solution, 3 if not completed and no solution. |
---|
196 | |
---|
197 | Normally okay to do cleanModel immediately followed by subBranchandBound |
---|
198 | (== other form of subBranchAndBound) |
---|
199 | but may need to get at model for advanced features. |
---|
200 | |
---|
201 | Deletes model2 |
---|
202 | */ |
---|
203 | int subBranchAndBound(CbcModel * model2, |
---|
204 | CbcModel * presolvedModel, |
---|
205 | int maximumNodes); |
---|
206 | /** \brief Invoke the branch \& cut algorithm on partially fixed problem |
---|
207 | |
---|
208 | The method creates a new model with given bounds, presolves it |
---|
209 | then proceeds to explore the branch & cut search tree. The search |
---|
210 | ends when the tree is exhausted or maximum nodes is reached. |
---|
211 | |
---|
212 | If better solution found then it is saved. |
---|
213 | |
---|
214 | Returns 0 if search completed and solution, 1 if not completed and solution, |
---|
215 | 2 if completed and no solution, 3 if not completed and no solution. |
---|
216 | |
---|
217 | This is just subModel immediately followed by other version of |
---|
218 | subBranchandBound. |
---|
219 | |
---|
220 | */ |
---|
221 | int subBranchAndBound(const double * lower, const double * upper, |
---|
222 | int maximumNodes); |
---|
223 | |
---|
224 | /** \brief Process root node and return a strengthened model |
---|
225 | |
---|
226 | The method assumes that initialSolve() has been called to solve the |
---|
227 | LP relaxation. It processes the root node and then returns a pointer |
---|
228 | to the strengthened model (or NULL if infeasible) |
---|
229 | */ |
---|
230 | OsiSolverInterface * strengthenedModel(); |
---|
231 | /** preProcess problem - replacing solver |
---|
232 | If makeEquality true then <= cliques converted to ==. |
---|
233 | Presolve will be done numberPasses times. |
---|
234 | |
---|
235 | Returns NULL if infeasible |
---|
236 | |
---|
237 | If makeEquality is 1 add slacks to get cliques, |
---|
238 | if 2 add slacks to get sos (but only if looks plausible) and keep sos info |
---|
239 | */ |
---|
240 | CglPreProcess * preProcess( int makeEquality=0, int numberPasses=5, |
---|
241 | int tuning=5); |
---|
242 | /** Does postprocessing - original solver back. |
---|
243 | User has to delete process */ |
---|
244 | void postProcess(CglPreProcess * process); |
---|
245 | private: |
---|
246 | /** \brief Evaluate a subproblem using cutting planes and heuristics |
---|
247 | |
---|
248 | The method invokes a main loop which generates cuts, applies heuristics, |
---|
249 | and reoptimises using the solver's native %resolve() method. |
---|
250 | It returns true if the subproblem remains feasible at the end of the |
---|
251 | evaluation. |
---|
252 | */ |
---|
253 | bool solveWithCuts(OsiCuts & cuts, int numberTries,CbcNode * node); |
---|
254 | /** Input one node output N nodes to put on tree and optional solution update |
---|
255 | This should be able to operate in parallel so is given a solver and is const(ish) |
---|
256 | However we will need to keep an array of solver_ and bases and more |
---|
257 | status is 0 for normal, 1 if solution |
---|
258 | Calling code should always push nodes back on tree |
---|
259 | */ |
---|
260 | CbcNode ** solveOneNode(int whichSolver,CbcNode * node, |
---|
261 | int & numberNodesOutput, int & status) ; |
---|
262 | /// Update size of whichGenerator |
---|
263 | void resizeWhichGenerator(int numberNow, int numberAfter); |
---|
264 | public: |
---|
265 | #ifndef CBC_THREAD |
---|
266 | #define NEW_UPDATE_OBJECT 0 |
---|
267 | #else |
---|
268 | #define NEW_UPDATE_OBJECT 2 |
---|
269 | #endif |
---|
270 | #if NEW_UPDATE_OBJECT>1 |
---|
271 | /// Adds an update information object |
---|
272 | void addUpdateInformation(const CbcObjectUpdateData & data); |
---|
273 | #endif |
---|
274 | /** Do one node - broken out for clarity? |
---|
275 | also for parallel (when baseModel!=this) |
---|
276 | Returns 1 if solution found |
---|
277 | node NULL on return if no branches left |
---|
278 | newNode NULL if no new node created |
---|
279 | */ |
---|
280 | int doOneNode(CbcModel * baseModel, CbcNode * & node, CbcNode * & newNode); |
---|
281 | |
---|
282 | /// Returns true if locked |
---|
283 | bool isLocked() const; |
---|
284 | #ifdef CBC_THREAD |
---|
285 | /** |
---|
286 | Locks a thread if parallel so that stuff like cut pool |
---|
287 | can be updated and/or used. |
---|
288 | */ |
---|
289 | void lockThread(); |
---|
290 | /** |
---|
291 | Unlocks a thread if parallel to say cut pool stuff not needed |
---|
292 | */ |
---|
293 | void unlockThread(); |
---|
294 | #else |
---|
295 | inline void lockThread() {}; |
---|
296 | inline void unlockThread() {}; |
---|
297 | #endif |
---|
298 | private: |
---|
299 | /** Move/copy information from one model to another |
---|
300 | -1 - initialization |
---|
301 | 0 - from base model |
---|
302 | 1 - to base model (and reset) |
---|
303 | 2 - add in final statistics etc (and reset so can do clean destruction) |
---|
304 | */ |
---|
305 | void moveToModel(CbcModel * baseModel,int mode); |
---|
306 | public: |
---|
307 | /** \brief Reoptimise an LP relaxation |
---|
308 | |
---|
309 | Invoke the solver's %resolve() method. |
---|
310 | whereFrom - |
---|
311 | 0 - initial continuous |
---|
312 | 1 - resolve on branch (before new cuts) |
---|
313 | 2 - after new cuts |
---|
314 | 3 - obsolete code or something modified problem in unexpected way |
---|
315 | 10 - after strong branching has fixed variables at root |
---|
316 | 11 - after strong branching has fixed variables in tree |
---|
317 | |
---|
318 | returns 1 feasible, 0 infeasible, -1 feasible but skip cuts |
---|
319 | */ |
---|
320 | int resolve(CbcNodeInfo * parent, int whereFrom); |
---|
321 | /// Make given rows (L or G) into global cuts and remove from lp |
---|
322 | void makeGlobalCuts(int numberRows,const int * which); |
---|
323 | /// Make given cut into a global cut |
---|
324 | void makeGlobalCut(const OsiRowCut * cut); |
---|
325 | /// Make given cut into a global cut |
---|
326 | void makeGlobalCut(const OsiRowCut & cut); |
---|
327 | //@} |
---|
328 | |
---|
329 | /** \name Presolve methods */ |
---|
330 | //@{ |
---|
331 | |
---|
332 | /** Identify cliques and construct corresponding objects. |
---|
333 | |
---|
334 | Find cliques with size in the range |
---|
335 | [\p atLeastThisMany, \p lessThanThis] and construct corresponding |
---|
336 | CbcClique objects. |
---|
337 | If \p makeEquality is true then a new model may be returned if |
---|
338 | modifications had to be made, otherwise \c this is returned. |
---|
339 | If the problem is infeasible #numberObjects_ is set to -1. |
---|
340 | A client must use deleteObjects() before a second call to findCliques(). |
---|
341 | If priorities exist, clique priority is set to the default. |
---|
342 | */ |
---|
343 | CbcModel * findCliques(bool makeEquality, int atLeastThisMany, |
---|
344 | int lessThanThis, int defaultValue=1000); |
---|
345 | |
---|
346 | /** Do integer presolve, creating a new (presolved) model. |
---|
347 | |
---|
348 | Returns the new model, or NULL if feasibility is lost. |
---|
349 | If weak is true then just does a normal presolve |
---|
350 | |
---|
351 | \todo It remains to work out the cleanest way of getting a solution to |
---|
352 | the original problem at the end. So this is very preliminary. |
---|
353 | */ |
---|
354 | CbcModel * integerPresolve(bool weak=false); |
---|
355 | |
---|
356 | /** Do integer presolve, modifying the current model. |
---|
357 | |
---|
358 | Returns true if the model remains feasible after presolve. |
---|
359 | */ |
---|
360 | bool integerPresolveThisModel(OsiSolverInterface * originalSolver,bool weak=false); |
---|
361 | |
---|
362 | |
---|
363 | /// Put back information into the original model after integer presolve. |
---|
364 | void originalModel(CbcModel * presolvedModel,bool weak); |
---|
365 | |
---|
366 | /** \brief For variables involved in VUB constraints, see if we can tighten |
---|
367 | bounds by solving lp's |
---|
368 | |
---|
369 | Returns false if feasibility is lost. |
---|
370 | If CglProbing is available, it will be tried as well to see if it can |
---|
371 | tighten bounds. |
---|
372 | This routine is just a front end for tightenVubs(int,const int*,double). |
---|
373 | |
---|
374 | If <tt>type = -1</tt> all variables are processed (could be very slow). |
---|
375 | If <tt>type = 0</tt> only variables involved in VUBs are processed. |
---|
376 | If <tt>type = n > 0</tt>, only the n most expensive VUB variables |
---|
377 | are processed, where it is assumed that x is at its maximum so delta |
---|
378 | would have to go to 1 (if x not at bound). |
---|
379 | |
---|
380 | If \p allowMultipleBinary is true, then a VUB constraint is a row with |
---|
381 | one continuous variable and any number of binary variables. |
---|
382 | |
---|
383 | If <tt>useCutoff < 1.0e30</tt>, the original objective is installed as a |
---|
384 | constraint with \p useCutoff as a bound. |
---|
385 | */ |
---|
386 | bool tightenVubs(int type,bool allowMultipleBinary=false, |
---|
387 | double useCutoff=1.0e50); |
---|
388 | |
---|
389 | /** \brief For variables involved in VUB constraints, see if we can tighten |
---|
390 | bounds by solving lp's |
---|
391 | |
---|
392 | This version is just handed a list of variables to be processed. |
---|
393 | */ |
---|
394 | bool tightenVubs(int numberVubs, const int * which, |
---|
395 | double useCutoff=1.0e50); |
---|
396 | /** |
---|
397 | Analyze problem to find a minimum change in the objective function. |
---|
398 | */ |
---|
399 | void analyzeObjective(); |
---|
400 | |
---|
401 | |
---|
402 | //@} |
---|
403 | |
---|
404 | /** \name Object manipulation routines |
---|
405 | |
---|
406 | See OsiObject for an explanation of `object' in the context of CbcModel. |
---|
407 | */ |
---|
408 | //@{ |
---|
409 | |
---|
410 | /// Get the number of objects |
---|
411 | inline int numberObjects() const { return numberObjects_;}; |
---|
412 | /// Set the number of objects |
---|
413 | inline void setNumberObjects(int number) |
---|
414 | { numberObjects_=number;}; |
---|
415 | |
---|
416 | /// Get the array of objects |
---|
417 | inline OsiObject ** objects() const { return object_;}; |
---|
418 | |
---|
419 | /// Get the specified object |
---|
420 | const inline OsiObject * object(int which) const { return object_[which];}; |
---|
421 | /// Get the specified object |
---|
422 | inline OsiObject * modifiableObject(int which) const { return object_[which];}; |
---|
423 | |
---|
424 | /// Delete all object information (and just back to integers if true) |
---|
425 | void deleteObjects(bool findIntegers=true); |
---|
426 | |
---|
427 | /** Add in object information. |
---|
428 | |
---|
429 | Objects are cloned; the owner can delete the originals. |
---|
430 | */ |
---|
431 | void addObjects(int numberObjects, OsiObject ** objects); |
---|
432 | |
---|
433 | /** Add in object information. |
---|
434 | |
---|
435 | Objects are cloned; the owner can delete the originals. |
---|
436 | */ |
---|
437 | void addObjects(int numberObjects, CbcObject ** objects); |
---|
438 | |
---|
439 | /// Ensure attached objects point to this model. |
---|
440 | void synchronizeModel() ; |
---|
441 | |
---|
442 | /** \brief Identify integer variables and create corresponding objects. |
---|
443 | |
---|
444 | Record integer variables and create an CbcSimpleInteger object for each |
---|
445 | one. |
---|
446 | If \p startAgain is true, a new scan is forced, overwriting any existing |
---|
447 | integer variable information. |
---|
448 | If type > 0 then 1==PseudoCost |
---|
449 | */ |
---|
450 | |
---|
451 | void findIntegers(bool startAgain,int type=0); |
---|
452 | |
---|
453 | //@} |
---|
454 | |
---|
455 | //--------------------------------------------------------------------------- |
---|
456 | |
---|
457 | /**@name Parameter set/get methods |
---|
458 | |
---|
459 | The set methods return true if the parameter was set to the given value, |
---|
460 | false if the value of the parameter is out of range. |
---|
461 | |
---|
462 | The get methods return the value of the parameter. |
---|
463 | |
---|
464 | */ |
---|
465 | //@{ |
---|
466 | /// Set an integer parameter |
---|
467 | inline bool setIntParam(CbcIntParam key, int value) { |
---|
468 | intParam_[key] = value; |
---|
469 | return true; |
---|
470 | } |
---|
471 | /// Set a double parameter |
---|
472 | inline bool setDblParam(CbcDblParam key, double value) { |
---|
473 | dblParam_[key] = value; |
---|
474 | return true; |
---|
475 | } |
---|
476 | /// Get an integer parameter |
---|
477 | inline int getIntParam(CbcIntParam key) const { |
---|
478 | return intParam_[key]; |
---|
479 | } |
---|
480 | /// Get a double parameter |
---|
481 | inline double getDblParam(CbcDblParam key) const { |
---|
482 | return dblParam_[key]; |
---|
483 | } |
---|
484 | /*! \brief Set cutoff bound on the objective function. |
---|
485 | |
---|
486 | When using strict comparison, the bound is adjusted by a tolerance to |
---|
487 | avoid accidentally cutting off the optimal solution. |
---|
488 | */ |
---|
489 | void setCutoff(double value) ; |
---|
490 | |
---|
491 | /// Get the cutoff bound on the objective function - always as minimize |
---|
492 | inline double getCutoff() const |
---|
493 | { //double value ; |
---|
494 | //solver_->getDblParam(OsiDualObjectiveLimit,value) ; |
---|
495 | //assert( dblParam_[CbcCurrentCutoff]== value * solver_->getObjSense()); |
---|
496 | return dblParam_[CbcCurrentCutoff]; |
---|
497 | } |
---|
498 | |
---|
499 | /// Set the \link CbcModel::CbcMaxNumNode maximum node limit \endlink |
---|
500 | inline bool setMaximumNodes( int value) |
---|
501 | { return setIntParam(CbcMaxNumNode,value); } |
---|
502 | |
---|
503 | /// Get the \link CbcModel::CbcMaxNumNode maximum node limit \endlink |
---|
504 | inline int getMaximumNodes() const |
---|
505 | { return getIntParam(CbcMaxNumNode); } |
---|
506 | |
---|
507 | /** Set the |
---|
508 | \link CbcModel::CbcMaxNumSol maximum number of solutions \endlink |
---|
509 | desired. |
---|
510 | */ |
---|
511 | inline bool setMaximumSolutions( int value) { |
---|
512 | return setIntParam(CbcMaxNumSol,value); |
---|
513 | } |
---|
514 | /** Get the |
---|
515 | \link CbcModel::CbcMaxNumSol maximum number of solutions \endlink |
---|
516 | desired. |
---|
517 | */ |
---|
518 | inline int getMaximumSolutions() const { |
---|
519 | return getIntParam(CbcMaxNumSol); |
---|
520 | } |
---|
521 | /// Set the printing mode |
---|
522 | inline bool setPrintingMode( int value) |
---|
523 | { return setIntParam(CbcPrinting,value); } |
---|
524 | |
---|
525 | /// Get the printing mode |
---|
526 | inline int getPrintingMode() const |
---|
527 | { return getIntParam(CbcPrinting); } |
---|
528 | |
---|
529 | /** Set the |
---|
530 | \link CbcModel::CbcMaximumSeconds maximum number of seconds \endlink |
---|
531 | desired. |
---|
532 | */ |
---|
533 | inline bool setMaximumSeconds( double value) { |
---|
534 | return setDblParam(CbcMaximumSeconds,value); |
---|
535 | } |
---|
536 | /** Get the |
---|
537 | \link CbcModel::CbcMaximumSeconds maximum number of seconds \endlink |
---|
538 | desired. |
---|
539 | */ |
---|
540 | inline double getMaximumSeconds() const { |
---|
541 | return getDblParam(CbcMaximumSeconds); |
---|
542 | } |
---|
543 | /// Current time since start of branchAndbound |
---|
544 | double getCurrentSeconds() const ; |
---|
545 | |
---|
546 | /** Set the |
---|
547 | \link CbcModel::CbcIntegerTolerance integrality tolerance \endlink |
---|
548 | */ |
---|
549 | inline bool setIntegerTolerance( double value) { |
---|
550 | return setDblParam(CbcIntegerTolerance,value); |
---|
551 | } |
---|
552 | /** Get the |
---|
553 | \link CbcModel::CbcIntegerTolerance integrality tolerance \endlink |
---|
554 | */ |
---|
555 | inline double getIntegerTolerance() const { |
---|
556 | return getDblParam(CbcIntegerTolerance); |
---|
557 | } |
---|
558 | |
---|
559 | /** Set the |
---|
560 | \link CbcModel::CbcInfeasibilityWeight |
---|
561 | weight per integer infeasibility \endlink |
---|
562 | */ |
---|
563 | inline bool setInfeasibilityWeight( double value) { |
---|
564 | return setDblParam(CbcInfeasibilityWeight,value); |
---|
565 | } |
---|
566 | /** Get the |
---|
567 | \link CbcModel::CbcInfeasibilityWeight |
---|
568 | weight per integer infeasibility \endlink |
---|
569 | */ |
---|
570 | inline double getInfeasibilityWeight() const { |
---|
571 | return getDblParam(CbcInfeasibilityWeight); |
---|
572 | } |
---|
573 | |
---|
574 | /** Set the \link CbcModel::CbcAllowableGap allowable gap \endlink |
---|
575 | between the best known solution and the best possible solution. |
---|
576 | */ |
---|
577 | inline bool setAllowableGap( double value) { |
---|
578 | return setDblParam(CbcAllowableGap,value); |
---|
579 | } |
---|
580 | /** Get the \link CbcModel::CbcAllowableGap allowable gap \endlink |
---|
581 | between the best known solution and the best possible solution. |
---|
582 | */ |
---|
583 | inline double getAllowableGap() const { |
---|
584 | return getDblParam(CbcAllowableGap); |
---|
585 | } |
---|
586 | |
---|
587 | /** Set the \link CbcModel::CbcAllowableFractionGap fraction allowable gap \endlink |
---|
588 | between the best known solution and the best possible solution. |
---|
589 | */ |
---|
590 | inline bool setAllowableFractionGap( double value) { |
---|
591 | return setDblParam(CbcAllowableFractionGap,value); |
---|
592 | } |
---|
593 | /** Get the \link CbcModel::CbcAllowableFractionGap fraction allowable gap \endlink |
---|
594 | between the best known solution and the best possible solution. |
---|
595 | */ |
---|
596 | inline double getAllowableFractionGap() const { |
---|
597 | return getDblParam(CbcAllowableFractionGap); |
---|
598 | } |
---|
599 | /** Set the \link CbcModel::CbcAllowableFractionGap percentage allowable gap \endlink |
---|
600 | between the best known solution and the best possible solution. |
---|
601 | */ |
---|
602 | inline bool setAllowablePercentageGap( double value) { |
---|
603 | return setDblParam(CbcAllowableFractionGap,value*0.01); |
---|
604 | } |
---|
605 | /** Get the \link CbcModel::CbcAllowableFractionGap percentage allowable gap \endlink |
---|
606 | between the best known solution and the best possible solution. |
---|
607 | */ |
---|
608 | inline double getAllowablePercentageGap() const { |
---|
609 | return 100.0*getDblParam(CbcAllowableFractionGap); |
---|
610 | } |
---|
611 | /** Set the |
---|
612 | \link CbcModel::CbcCutoffIncrement \endlink |
---|
613 | desired. |
---|
614 | */ |
---|
615 | inline bool setCutoffIncrement( double value) { |
---|
616 | return setDblParam(CbcCutoffIncrement,value); |
---|
617 | } |
---|
618 | /** Get the |
---|
619 | \link CbcModel::CbcCutoffIncrement \endlink |
---|
620 | desired. |
---|
621 | */ |
---|
622 | inline double getCutoffIncrement() const { |
---|
623 | return getDblParam(CbcCutoffIncrement); |
---|
624 | } |
---|
625 | |
---|
626 | /** Pass in target solution and optional priorities. |
---|
627 | If priorities then >0 means only branch if incorrect |
---|
628 | while <0 means branch even if correct. +1 or -1 are |
---|
629 | highest priority */ |
---|
630 | void setHotstartSolution(const double * solution, const int * priorities=NULL) ; |
---|
631 | |
---|
632 | /// Set the minimum drop to continue cuts |
---|
633 | inline void setMinimumDrop(double value) |
---|
634 | {minimumDrop_=value;}; |
---|
635 | /// Get the minimum drop to continue cuts |
---|
636 | inline double getMinimumDrop() const |
---|
637 | { return minimumDrop_;}; |
---|
638 | |
---|
639 | /** Set the maximum number of cut passes at root node (default 20) |
---|
640 | Minimum drop can also be used for fine tuning */ |
---|
641 | inline void setMaximumCutPassesAtRoot(int value) |
---|
642 | {maximumCutPassesAtRoot_=value;}; |
---|
643 | /** Get the maximum number of cut passes at root node */ |
---|
644 | inline int getMaximumCutPassesAtRoot() const |
---|
645 | { return maximumCutPassesAtRoot_;}; |
---|
646 | |
---|
647 | /** Set the maximum number of cut passes at other nodes (default 10) |
---|
648 | Minimum drop can also be used for fine tuning */ |
---|
649 | inline void setMaximumCutPasses(int value) |
---|
650 | {maximumCutPasses_=value;}; |
---|
651 | /** Get the maximum number of cut passes at other nodes (default 10) */ |
---|
652 | inline int getMaximumCutPasses() const |
---|
653 | { return maximumCutPasses_;}; |
---|
654 | /** Get current cut pass number in this round of cuts. |
---|
655 | (1 is first pass) */ |
---|
656 | inline int getCurrentPassNumber() const |
---|
657 | { return currentPassNumber_;}; |
---|
658 | |
---|
659 | /** Set the maximum number of candidates to be evaluated for strong |
---|
660 | branching. |
---|
661 | |
---|
662 | A value of 0 disables strong branching. |
---|
663 | */ |
---|
664 | void setNumberStrong(int number); |
---|
665 | /** Get the maximum number of candidates to be evaluated for strong |
---|
666 | branching. |
---|
667 | */ |
---|
668 | inline int numberStrong() const |
---|
669 | { return numberStrong_;}; |
---|
670 | /** Set global preferred way to branch |
---|
671 | -1 down, +1 up, 0 no preference */ |
---|
672 | inline void setPreferredWay(int value) |
---|
673 | {preferredWay_=value;}; |
---|
674 | /** Get the preferred way to branch (default 0) */ |
---|
675 | inline int getPreferredWay() const |
---|
676 | { return preferredWay_;}; |
---|
677 | /** Set size of mini - tree. If > 1 then does total enumeration of |
---|
678 | tree given by this best variables to branch on |
---|
679 | */ |
---|
680 | inline void setSizeMiniTree(int value) |
---|
681 | { sizeMiniTree_=value;}; |
---|
682 | inline int sizeMiniTree() const |
---|
683 | { return sizeMiniTree_;}; |
---|
684 | |
---|
685 | /** Set the number of branches before pseudo costs believed |
---|
686 | in dynamic strong branching. |
---|
687 | |
---|
688 | A value of 0 disables dynamic strong branching. |
---|
689 | */ |
---|
690 | void setNumberBeforeTrust(int number); |
---|
691 | /** get the number of branches before pseudo costs believed |
---|
692 | in dynamic strong branching. */ |
---|
693 | inline int numberBeforeTrust() const |
---|
694 | { return numberBeforeTrust_;}; |
---|
695 | /** Set the number of variables for which to compute penalties |
---|
696 | in dynamic strong branching. |
---|
697 | |
---|
698 | A value of 0 disables penalties. |
---|
699 | */ |
---|
700 | void setNumberPenalties(int number); |
---|
701 | /** get the number of variables for which to compute penalties |
---|
702 | in dynamic strong branching. */ |
---|
703 | inline int numberPenalties() const |
---|
704 | { return numberPenalties_;}; |
---|
705 | /// Number of analyze iterations to do |
---|
706 | inline void setNumberAnalyzeIterations(int number) |
---|
707 | { numberAnalyzeIterations_=number;}; |
---|
708 | inline int numberAnalyzeIterations() const |
---|
709 | { return numberAnalyzeIterations_;}; |
---|
710 | /** Get scale factor to make penalties match strong. |
---|
711 | Should/will be computed */ |
---|
712 | inline double penaltyScaleFactor() const |
---|
713 | { return penaltyScaleFactor_;}; |
---|
714 | /** Set scale factor to make penalties match strong. |
---|
715 | Should/will be computed */ |
---|
716 | void setPenaltyScaleFactor(double value); |
---|
717 | /** Problem type as set by user or found by analysis. This will be extended |
---|
718 | 0 - not known |
---|
719 | 1 - Set partitioning <= |
---|
720 | 2 - Set partitioning == |
---|
721 | 3 - Set covering |
---|
722 | 4 - all +- 1 or all +1 and odd |
---|
723 | */ |
---|
724 | void inline setProblemType(int number) |
---|
725 | { problemType_=number;}; |
---|
726 | inline int problemType() const |
---|
727 | { return problemType_;}; |
---|
728 | |
---|
729 | /// Set how often to scan global cuts |
---|
730 | void setHowOftenGlobalScan(int number); |
---|
731 | /// Get how often to scan global cuts |
---|
732 | inline int howOftenGlobalScan() const |
---|
733 | { return howOftenGlobalScan_;}; |
---|
734 | /// Original columns as created by integerPresolve |
---|
735 | inline int * originalColumns() const |
---|
736 | { return originalColumns_;}; |
---|
737 | |
---|
738 | /** Set the print frequency. |
---|
739 | |
---|
740 | Controls the number of nodes evaluated between status prints. |
---|
741 | If <tt>number <=0</tt> the print frequency is set to 100 nodes for large |
---|
742 | problems, 1000 for small problems. |
---|
743 | Print frequency has very slight overhead if small. |
---|
744 | */ |
---|
745 | inline void setPrintFrequency(int number) |
---|
746 | { printFrequency_=number;}; |
---|
747 | /// Get the print frequency |
---|
748 | inline int printFrequency() const |
---|
749 | { return printFrequency_;}; |
---|
750 | //@} |
---|
751 | |
---|
752 | //--------------------------------------------------------------------------- |
---|
753 | ///@name Methods returning info on how the solution process terminated |
---|
754 | //@{ |
---|
755 | /// Are there a numerical difficulties? |
---|
756 | bool isAbandoned() const; |
---|
757 | /// Is optimality proven? |
---|
758 | bool isProvenOptimal() const; |
---|
759 | /// Is infeasiblity proven (or none better than cutoff)? |
---|
760 | bool isProvenInfeasible() const; |
---|
761 | /// Was continuous solution unbounded |
---|
762 | bool isContinuousUnbounded() const; |
---|
763 | /// Was continuous solution unbounded |
---|
764 | bool isProvenDualInfeasible() const; |
---|
765 | /// Node limit reached? |
---|
766 | bool isNodeLimitReached() const; |
---|
767 | /// Time limit reached? |
---|
768 | bool isSecondsLimitReached() const; |
---|
769 | /// Solution limit reached? |
---|
770 | bool isSolutionLimitReached() const; |
---|
771 | /// Get how many iterations it took to solve the problem. |
---|
772 | inline int getIterationCount() const |
---|
773 | { return numberIterations_;}; |
---|
774 | /// Get how many Nodes it took to solve the problem. |
---|
775 | inline int getNodeCount() const |
---|
776 | { return numberNodes_;}; |
---|
777 | /** Final status of problem |
---|
778 | Some of these can be found out by is...... functions |
---|
779 | -1 before branchAndBound |
---|
780 | 0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found |
---|
781 | (or check value of best solution) |
---|
782 | 1 stopped - on maxnodes, maxsols, maxtime |
---|
783 | 2 difficulties so run was abandoned |
---|
784 | (5 event user programmed event occurred) |
---|
785 | */ |
---|
786 | inline int status() const |
---|
787 | { return status_;}; |
---|
788 | inline void setProblemStatus(int value) |
---|
789 | { status_=value;}; |
---|
790 | /** Secondary status of problem |
---|
791 | -1 unset (status_ will also be -1) |
---|
792 | 0 search completed with solution |
---|
793 | 1 linear relaxation not feasible (or worse than cutoff) |
---|
794 | 2 stopped on gap |
---|
795 | 3 stopped on nodes |
---|
796 | 4 stopped on time |
---|
797 | 5 stopped on user event |
---|
798 | 6 stopped on solutions |
---|
799 | 7 linear relaxation unbounded |
---|
800 | */ |
---|
801 | inline int secondaryStatus() const |
---|
802 | { return secondaryStatus_;}; |
---|
803 | inline void setSecondaryStatus(int value) |
---|
804 | { secondaryStatus_=value;}; |
---|
805 | /// Are there numerical difficulties (for initialSolve) ? |
---|
806 | bool isInitialSolveAbandoned() const ; |
---|
807 | /// Is optimality proven (for initialSolve) ? |
---|
808 | bool isInitialSolveProvenOptimal() const ; |
---|
809 | /// Is primal infeasiblity proven (for initialSolve) ? |
---|
810 | bool isInitialSolveProvenPrimalInfeasible() const ; |
---|
811 | /// Is dual infeasiblity proven (for initialSolve) ? |
---|
812 | bool isInitialSolveProvenDualInfeasible() const ; |
---|
813 | |
---|
814 | //@} |
---|
815 | |
---|
816 | //--------------------------------------------------------------------------- |
---|
817 | /**@name Problem information methods |
---|
818 | |
---|
819 | These methods call the solver's query routines to return |
---|
820 | information about the problem referred to by the current object. |
---|
821 | Querying a problem that has no data associated with it result in |
---|
822 | zeros for the number of rows and columns, and NULL pointers from |
---|
823 | the methods that return vectors. |
---|
824 | |
---|
825 | Const pointers returned from any data-query method are valid as |
---|
826 | long as the data is unchanged and the solver is not called. |
---|
827 | */ |
---|
828 | //@{ |
---|
829 | /// Number of rows in continuous (root) problem. |
---|
830 | inline int numberRowsAtContinuous() const |
---|
831 | { return numberRowsAtContinuous_;}; |
---|
832 | |
---|
833 | /// Get number of columns |
---|
834 | inline int getNumCols() const |
---|
835 | { return solver_->getNumCols();}; |
---|
836 | |
---|
837 | /// Get number of rows |
---|
838 | inline int getNumRows() const |
---|
839 | { return solver_->getNumRows();}; |
---|
840 | |
---|
841 | /// Get number of nonzero elements |
---|
842 | inline CoinBigIndex getNumElements() const |
---|
843 | { return solver_->getNumElements();}; |
---|
844 | |
---|
845 | /// Number of integers in problem |
---|
846 | inline int numberIntegers() const |
---|
847 | { return numberIntegers_;}; |
---|
848 | // Integer variables |
---|
849 | inline const int * integerVariable() const |
---|
850 | { return integerVariable_;}; |
---|
851 | /// Whether or not integer |
---|
852 | inline const char integerType(int i) const |
---|
853 | { return integerInfo_[i];}; |
---|
854 | /// Whether or not integer |
---|
855 | inline const char * integerType() const |
---|
856 | { return integerInfo_;}; |
---|
857 | |
---|
858 | /// Get pointer to array[getNumCols()] of column lower bounds |
---|
859 | inline const double * getColLower() const |
---|
860 | { return solver_->getColLower();}; |
---|
861 | |
---|
862 | /// Get pointer to array[getNumCols()] of column upper bounds |
---|
863 | inline const double * getColUpper() const |
---|
864 | { return solver_->getColUpper();}; |
---|
865 | |
---|
866 | /** Get pointer to array[getNumRows()] of row constraint senses. |
---|
867 | <ul> |
---|
868 | <li>'L': <= constraint |
---|
869 | <li>'E': = constraint |
---|
870 | <li>'G': >= constraint |
---|
871 | <li>'R': ranged constraint |
---|
872 | <li>'N': free constraint |
---|
873 | </ul> |
---|
874 | */ |
---|
875 | inline const char * getRowSense() const |
---|
876 | { return solver_->getRowSense();}; |
---|
877 | |
---|
878 | /** Get pointer to array[getNumRows()] of rows right-hand sides |
---|
879 | <ul> |
---|
880 | <li> if rowsense()[i] == 'L' then rhs()[i] == rowupper()[i] |
---|
881 | <li> if rowsense()[i] == 'G' then rhs()[i] == rowlower()[i] |
---|
882 | <li> if rowsense()[i] == 'R' then rhs()[i] == rowupper()[i] |
---|
883 | <li> if rowsense()[i] == 'N' then rhs()[i] == 0.0 |
---|
884 | </ul> |
---|
885 | */ |
---|
886 | inline const double * getRightHandSide() const |
---|
887 | { return solver_->getRightHandSide();}; |
---|
888 | |
---|
889 | /** Get pointer to array[getNumRows()] of row ranges. |
---|
890 | <ul> |
---|
891 | <li> if rowsense()[i] == 'R' then |
---|
892 | rowrange()[i] == rowupper()[i] - rowlower()[i] |
---|
893 | <li> if rowsense()[i] != 'R' then |
---|
894 | rowrange()[i] is 0.0 |
---|
895 | </ul> |
---|
896 | */ |
---|
897 | inline const double * getRowRange() const |
---|
898 | { return solver_->getRowRange();}; |
---|
899 | |
---|
900 | /// Get pointer to array[getNumRows()] of row lower bounds |
---|
901 | inline const double * getRowLower() const |
---|
902 | { return solver_->getRowLower();}; |
---|
903 | |
---|
904 | /// Get pointer to array[getNumRows()] of row upper bounds |
---|
905 | inline const double * getRowUpper() const |
---|
906 | { return solver_->getRowUpper();}; |
---|
907 | |
---|
908 | /// Get pointer to array[getNumCols()] of objective function coefficients |
---|
909 | inline const double * getObjCoefficients() const |
---|
910 | { return solver_->getObjCoefficients();}; |
---|
911 | |
---|
912 | /// Get objective function sense (1 for min (default), -1 for max) |
---|
913 | inline double getObjSense() const |
---|
914 | { |
---|
915 | //assert (dblParam_[CbcOptimizationDirection]== solver_->getObjSense()); |
---|
916 | return dblParam_[CbcOptimizationDirection];}; |
---|
917 | |
---|
918 | /// Return true if variable is continuous |
---|
919 | inline bool isContinuous(int colIndex) const |
---|
920 | { return solver_->isContinuous(colIndex);}; |
---|
921 | |
---|
922 | /// Return true if variable is binary |
---|
923 | inline bool isBinary(int colIndex) const |
---|
924 | { return solver_->isBinary(colIndex);}; |
---|
925 | |
---|
926 | /** Return true if column is integer. |
---|
927 | Note: This function returns true if the the column |
---|
928 | is binary or a general integer. |
---|
929 | */ |
---|
930 | inline bool isInteger(int colIndex) const |
---|
931 | { return solver_->isInteger(colIndex);}; |
---|
932 | |
---|
933 | /// Return true if variable is general integer |
---|
934 | inline bool isIntegerNonBinary(int colIndex) const |
---|
935 | { return solver_->isIntegerNonBinary(colIndex);}; |
---|
936 | |
---|
937 | /// Return true if variable is binary and not fixed at either bound |
---|
938 | inline bool isFreeBinary(int colIndex) const |
---|
939 | { return solver_->isFreeBinary(colIndex) ;}; |
---|
940 | |
---|
941 | /// Get pointer to row-wise copy of matrix |
---|
942 | inline const CoinPackedMatrix * getMatrixByRow() const |
---|
943 | { return solver_->getMatrixByRow();}; |
---|
944 | |
---|
945 | /// Get pointer to column-wise copy of matrix |
---|
946 | inline const CoinPackedMatrix * getMatrixByCol() const |
---|
947 | { return solver_->getMatrixByCol();}; |
---|
948 | |
---|
949 | /// Get solver's value for infinity |
---|
950 | inline double getInfinity() const |
---|
951 | { return solver_->getInfinity();}; |
---|
952 | /// Get pointer to array[getNumCols()] (for speed) of column lower bounds |
---|
953 | inline const double * getCbcColLower() const |
---|
954 | { return cbcColLower_;}; |
---|
955 | /// Get pointer to array[getNumCols()] (for speed) of column upper bounds |
---|
956 | inline const double * getCbcColUpper() const |
---|
957 | { return cbcColUpper_;}; |
---|
958 | /// Get pointer to array[getNumRows()] (for speed) of row lower bounds |
---|
959 | inline const double * getCbcRowLower() const |
---|
960 | { return cbcRowLower_;}; |
---|
961 | /// Get pointer to array[getNumRows()] (for speed) of row upper bounds |
---|
962 | inline const double * getCbcRowUpper() const |
---|
963 | { return cbcRowUpper_;}; |
---|
964 | /// Get pointer to array[getNumCols()] (for speed) of primal solution vector |
---|
965 | inline const double * getCbcColSolution() const |
---|
966 | { return cbcColSolution_;}; |
---|
967 | /// Get pointer to array[getNumRows()] (for speed) of dual prices |
---|
968 | inline const double * getCbcRowPrice() const |
---|
969 | { return cbcRowPrice_;}; |
---|
970 | /// Get a pointer to array[getNumCols()] (for speed) of reduced costs |
---|
971 | inline const double * getCbcReducedCost() const |
---|
972 | { return cbcReducedCost_;}; |
---|
973 | /// Get pointer to array[getNumRows()] (for speed) of row activity levels. |
---|
974 | inline const double * getCbcRowActivity() const |
---|
975 | { return cbcRowActivity_;}; |
---|
976 | //@} |
---|
977 | |
---|
978 | |
---|
979 | /**@name Methods related to querying the solution */ |
---|
980 | //@{ |
---|
981 | /// Holds solution at continuous (after cuts if branchAndBound called) |
---|
982 | inline double * continuousSolution() const |
---|
983 | { return continuousSolution_;}; |
---|
984 | /** Array marked whenever a solution is found if non-zero. |
---|
985 | Code marks if heuristic returns better so heuristic |
---|
986 | need only mark if it wants to on solutions which |
---|
987 | are worse than current */ |
---|
988 | inline int * usedInSolution() const |
---|
989 | { return usedInSolution_;}; |
---|
990 | /// Increases usedInSolution for nonzeros |
---|
991 | void incrementUsed(const double * solution); |
---|
992 | /// Record a new incumbent solution and update objectiveValue |
---|
993 | void setBestSolution(CBC_Message how, |
---|
994 | double & objectiveValue, const double *solution, |
---|
995 | bool fixVariables=false); |
---|
996 | /// Just update objectiveValue |
---|
997 | void setBestObjectiveValue( double objectiveValue); |
---|
998 | |
---|
999 | /** Call this to really test if a valid solution can be feasible |
---|
1000 | Solution is number columns in size. |
---|
1001 | If fixVariables true then bounds of continuous solver updated. |
---|
1002 | Returns objective value (worse than cutoff if not feasible) |
---|
1003 | Previously computed objective value is now passed in (in case user does not do solve) |
---|
1004 | */ |
---|
1005 | double checkSolution(double cutoff, const double * solution, |
---|
1006 | bool fixVariables, double originalObjValue); |
---|
1007 | /** Test the current solution for feasiblility. |
---|
1008 | |
---|
1009 | Scan all objects for indications of infeasibility. This is broken down |
---|
1010 | into simple integer infeasibility (\p numberIntegerInfeasibilities) |
---|
1011 | and all other reports of infeasibility (\p numberObjectInfeasibilities). |
---|
1012 | */ |
---|
1013 | bool feasibleSolution(int & numberIntegerInfeasibilities, |
---|
1014 | int & numberObjectInfeasibilities) const; |
---|
1015 | |
---|
1016 | /** Solution to the most recent lp relaxation. |
---|
1017 | |
---|
1018 | The solver's solution to the most recent lp relaxation. |
---|
1019 | */ |
---|
1020 | |
---|
1021 | inline double * currentSolution() const |
---|
1022 | { return currentSolution_;}; |
---|
1023 | /** For testing infeasibilities - will point to |
---|
1024 | currentSolution_ or solver-->getColSolution() |
---|
1025 | */ |
---|
1026 | inline const double * testSolution() const |
---|
1027 | { return testSolution_;}; |
---|
1028 | inline void setTestSolution(const double * solution) |
---|
1029 | { testSolution_ = solution;}; |
---|
1030 | /// Make sure region there and optionally copy solution |
---|
1031 | void reserveCurrentSolution(const double * solution=NULL); |
---|
1032 | |
---|
1033 | /// Get pointer to array[getNumCols()] of primal solution vector |
---|
1034 | inline const double * getColSolution() const |
---|
1035 | { return solver_->getColSolution();}; |
---|
1036 | |
---|
1037 | /// Get pointer to array[getNumRows()] of dual prices |
---|
1038 | inline const double * getRowPrice() const |
---|
1039 | { return solver_->getRowPrice();}; |
---|
1040 | |
---|
1041 | /// Get a pointer to array[getNumCols()] of reduced costs |
---|
1042 | inline const double * getReducedCost() const |
---|
1043 | { return solver_->getReducedCost();}; |
---|
1044 | |
---|
1045 | /// Get pointer to array[getNumRows()] of row activity levels. |
---|
1046 | inline const double * getRowActivity() const |
---|
1047 | { return solver_->getRowActivity();}; |
---|
1048 | |
---|
1049 | /// Get current objective function value |
---|
1050 | inline double getCurrentObjValue() const |
---|
1051 | { return dblParam_[CbcCurrentObjectiveValue]; } |
---|
1052 | /// Get current minimization objective function value |
---|
1053 | inline double getCurrentMinimizationObjValue() const |
---|
1054 | { return dblParam_[CbcCurrentMinimizationObjectiveValue];} |
---|
1055 | |
---|
1056 | /// Get best objective function value as minimization |
---|
1057 | inline double getMinimizationObjValue() const |
---|
1058 | { return bestObjective_;}; |
---|
1059 | /// Set best objective function value as minimization |
---|
1060 | inline void setMinimizationObjValue(double value) |
---|
1061 | { bestObjective_=value;}; |
---|
1062 | |
---|
1063 | /// Get best objective function value |
---|
1064 | inline double getObjValue() const |
---|
1065 | { return bestObjective_ * solver_->getObjSense() ; } ; |
---|
1066 | /** Get best possible objective function value. |
---|
1067 | This is better of best possible left on tree |
---|
1068 | and best solution found. |
---|
1069 | If called from within branch and cut may be optimistic. |
---|
1070 | */ |
---|
1071 | double getBestPossibleObjValue() const; |
---|
1072 | /// Set best objective function value |
---|
1073 | inline void setObjValue(double value) |
---|
1074 | { bestObjective_=value * solver_->getObjSense() ;}; |
---|
1075 | |
---|
1076 | /** The best solution to the integer programming problem. |
---|
1077 | |
---|
1078 | The best solution to the integer programming problem found during |
---|
1079 | the search. If no solution is found, the method returns null. |
---|
1080 | */ |
---|
1081 | |
---|
1082 | inline double * bestSolution() const |
---|
1083 | { return bestSolution_;}; |
---|
1084 | void setBestSolution(const double * solution,int numberColumns,double objectiveValue); |
---|
1085 | |
---|
1086 | /// Get number of solutions |
---|
1087 | inline int getSolutionCount() const |
---|
1088 | { return numberSolutions_;}; |
---|
1089 | |
---|
1090 | /// Set number of solutions (so heuristics will be different) |
---|
1091 | inline void setSolutionCount(int value) |
---|
1092 | { numberSolutions_=value;}; |
---|
1093 | /** Current phase (so heuristics etc etc can find out). |
---|
1094 | 0 - initial solve |
---|
1095 | 1 - solve with cuts at root |
---|
1096 | 2 - solve with cuts |
---|
1097 | 3 - other e.g. strong branching |
---|
1098 | 4 - trying to validate a solution |
---|
1099 | 5 - at end of search |
---|
1100 | */ |
---|
1101 | inline int phase() const |
---|
1102 | { return phase_;}; |
---|
1103 | |
---|
1104 | /// Get number of heuristic solutions |
---|
1105 | inline int getNumberHeuristicSolutions() const { return numberHeuristicSolutions_;}; |
---|
1106 | |
---|
1107 | /// Set objective function sense (1 for min (default), -1 for max,) |
---|
1108 | inline void setObjSense(double s) { dblParam_[CbcOptimizationDirection]=s; |
---|
1109 | solver_->setObjSense(s);}; |
---|
1110 | |
---|
1111 | /// Value of objective at continuous |
---|
1112 | inline double getContinuousObjective() const |
---|
1113 | { return originalContinuousObjective_;}; |
---|
1114 | inline void setContinuousObjective(double value) |
---|
1115 | { originalContinuousObjective_=value;}; |
---|
1116 | /// Number of infeasibilities at continuous |
---|
1117 | inline int getContinuousInfeasibilities() const |
---|
1118 | { return continuousInfeasibilities_;}; |
---|
1119 | inline void setContinuousInfeasibilities(int value) |
---|
1120 | { continuousInfeasibilities_=value;}; |
---|
1121 | /// Value of objective after root node cuts added |
---|
1122 | inline double rootObjectiveAfterCuts() const |
---|
1123 | { return continuousObjective_;}; |
---|
1124 | /// Sum of Changes to objective by first solve |
---|
1125 | inline double sumChangeObjective() const |
---|
1126 | { return sumChangeObjective1_;}; |
---|
1127 | /** Number of times global cuts violated. When global cut pool then this |
---|
1128 | should be kept for each cut and type of cut */ |
---|
1129 | inline int numberGlobalViolations() const |
---|
1130 | { return numberGlobalViolations_;}; |
---|
1131 | inline void clearNumberGlobalViolations() |
---|
1132 | { numberGlobalViolations_=0;}; |
---|
1133 | /// Whether to force a resolve after takeOffCuts |
---|
1134 | inline bool resolveAfterTakeOffCuts() const |
---|
1135 | { return resolveAfterTakeOffCuts_;}; |
---|
1136 | inline void setResolveAfterTakeOffCuts(bool yesNo) |
---|
1137 | { resolveAfterTakeOffCuts_=yesNo;}; |
---|
1138 | /// Get number of threads |
---|
1139 | inline int getNumberThreads() const |
---|
1140 | { return numberThreads_;}; |
---|
1141 | /// Set number of threads |
---|
1142 | inline void setNumberThreads(int value) |
---|
1143 | { numberThreads_=value;}; |
---|
1144 | /// Get thread mode |
---|
1145 | inline int getThreadMode() const |
---|
1146 | { return threadMode_;}; |
---|
1147 | /** Set thread mode |
---|
1148 | always use numberThreads for branching |
---|
1149 | 1 set then use numberThreads in root mini branch and bound |
---|
1150 | 2 set then use numberThreads for root cuts |
---|
1151 | default is 0 |
---|
1152 | */ |
---|
1153 | inline void setThreadMode(int value) |
---|
1154 | { threadMode_=value;}; |
---|
1155 | //@} |
---|
1156 | |
---|
1157 | /** \name Node selection */ |
---|
1158 | //@{ |
---|
1159 | // Comparison functions (which may be overridden by inheritance) |
---|
1160 | inline CbcCompareBase * nodeComparison() const |
---|
1161 | { return nodeCompare_;}; |
---|
1162 | void setNodeComparison(CbcCompareBase * compare); |
---|
1163 | void setNodeComparison(CbcCompareBase & compare); |
---|
1164 | //@} |
---|
1165 | |
---|
1166 | /** \name Problem feasibility checking */ |
---|
1167 | //@{ |
---|
1168 | // Feasibility functions (which may be overridden by inheritance) |
---|
1169 | inline CbcFeasibilityBase * problemFeasibility() const |
---|
1170 | { return problemFeasibility_;}; |
---|
1171 | void setProblemFeasibility(CbcFeasibilityBase * feasibility); |
---|
1172 | void setProblemFeasibility(CbcFeasibilityBase & feasibility); |
---|
1173 | //@} |
---|
1174 | |
---|
1175 | /** \name Tree methods and subtree methods */ |
---|
1176 | //@{ |
---|
1177 | /// Tree method e.g. heap (which may be overridden by inheritance) |
---|
1178 | inline CbcTree * tree() const |
---|
1179 | { return tree_;}; |
---|
1180 | /// For modifying tree handling (original is cloned) |
---|
1181 | void passInTreeHandler(CbcTree & tree); |
---|
1182 | /** For passing in an CbcModel to do a sub Tree (with derived tree handlers). |
---|
1183 | Passed in model must exist for duration of branch and bound |
---|
1184 | */ |
---|
1185 | void passInSubTreeModel(CbcModel & model); |
---|
1186 | /** For retrieving a copy of subtree model with given OsiSolver. |
---|
1187 | If no subtree model will use self (up to user to reset cutoff etc). |
---|
1188 | If solver NULL uses current |
---|
1189 | */ |
---|
1190 | CbcModel * subTreeModel(OsiSolverInterface * solver=NULL) const; |
---|
1191 | /// Returns number of times any subtree stopped on nodes, time etc |
---|
1192 | inline int numberStoppedSubTrees() const |
---|
1193 | { return numberStoppedSubTrees_;} |
---|
1194 | /// Says a sub tree was stopped |
---|
1195 | inline void incrementSubTreeStopped() |
---|
1196 | { numberStoppedSubTrees_++;}; |
---|
1197 | /** Whether to automatically do presolve before branch and bound (subTrees). |
---|
1198 | 0 - no |
---|
1199 | 1 - ordinary presolve |
---|
1200 | 2 - integer presolve (dodgy) |
---|
1201 | */ |
---|
1202 | inline int typePresolve() const |
---|
1203 | { return presolve_;}; |
---|
1204 | inline void setTypePresolve(int value) |
---|
1205 | { presolve_=value;}; |
---|
1206 | |
---|
1207 | //@} |
---|
1208 | |
---|
1209 | /** \name Branching Decisions |
---|
1210 | |
---|
1211 | See the CbcBranchDecision class for additional information. |
---|
1212 | */ |
---|
1213 | //@{ |
---|
1214 | |
---|
1215 | /// Get the current branching decision method. |
---|
1216 | inline CbcBranchDecision * branchingMethod() const |
---|
1217 | { return branchingMethod_;}; |
---|
1218 | /// Set the branching decision method. |
---|
1219 | inline void setBranchingMethod(CbcBranchDecision * method) |
---|
1220 | { delete branchingMethod_; branchingMethod_ = method->clone();}; |
---|
1221 | /** Set the branching method |
---|
1222 | |
---|
1223 | \overload |
---|
1224 | */ |
---|
1225 | inline void setBranchingMethod(CbcBranchDecision & method) |
---|
1226 | { delete branchingMethod_; branchingMethod_ = method.clone();}; |
---|
1227 | /// Get the current cut modifier method |
---|
1228 | inline CbcCutModifier * cutModifier() const |
---|
1229 | { return cutModifier_;}; |
---|
1230 | /// Set the cut modifier method |
---|
1231 | void setCutModifier(CbcCutModifier * modifier); |
---|
1232 | /** Set the cut modifier method |
---|
1233 | |
---|
1234 | \overload |
---|
1235 | */ |
---|
1236 | void setCutModifier(CbcCutModifier & modifier); |
---|
1237 | //@} |
---|
1238 | |
---|
1239 | /** \name Row (constraint) and Column (variable) cut generation */ |
---|
1240 | //@{ |
---|
1241 | |
---|
1242 | /** State of search |
---|
1243 | 0 - no solution |
---|
1244 | 1 - only heuristic solutions |
---|
1245 | 2 - branched to a solution |
---|
1246 | 3 - no solution but many nodes |
---|
1247 | */ |
---|
1248 | inline int stateOfSearch() const |
---|
1249 | { return stateOfSearch_;}; |
---|
1250 | inline void setStateOfSearch(int state) |
---|
1251 | { stateOfSearch_=state;}; |
---|
1252 | /// Strategy worked out - mainly at root node for use by CbcNode |
---|
1253 | inline int searchStrategy() const |
---|
1254 | { return searchStrategy_;}; |
---|
1255 | /// Set strategy worked out - mainly at root node for use by CbcNode |
---|
1256 | inline void setSearchStrategy(int value) |
---|
1257 | { searchStrategy_ = value; }; |
---|
1258 | |
---|
1259 | /// Get the number of cut generators |
---|
1260 | inline int numberCutGenerators() const |
---|
1261 | { return numberCutGenerators_;}; |
---|
1262 | /// Get the list of cut generators |
---|
1263 | inline CbcCutGenerator ** cutGenerators() const |
---|
1264 | { return generator_;}; |
---|
1265 | ///Get the specified cut generator |
---|
1266 | inline CbcCutGenerator * cutGenerator(int i) const |
---|
1267 | { return generator_[i];}; |
---|
1268 | ///Get the specified cut generator before any changes |
---|
1269 | inline CbcCutGenerator * virginCutGenerator(int i) const |
---|
1270 | { return virginGenerator_[i];}; |
---|
1271 | /** Add one generator - up to user to delete generators. |
---|
1272 | howoften affects how generator is used. 0 or 1 means always, |
---|
1273 | >1 means every that number of nodes. Negative values have same |
---|
1274 | meaning as positive but they may be switched off (-> -100) by code if |
---|
1275 | not many cuts generated at continuous. -99 is just done at root. |
---|
1276 | Name is just for printout. |
---|
1277 | If depth >0 overrides how often generator is called (if howOften==-1 or >0). |
---|
1278 | */ |
---|
1279 | void addCutGenerator(CglCutGenerator * generator, |
---|
1280 | int howOften=1, const char * name=NULL, |
---|
1281 | bool normal=true, bool atSolution=false, |
---|
1282 | bool infeasible=false,int howOftenInSub=-100, |
---|
1283 | int whatDepth=-1, int whatDepthInSub=-1); |
---|
1284 | //@} |
---|
1285 | /** \name Strategy and sub models |
---|
1286 | |
---|
1287 | See the CbcStrategy class for additional information. |
---|
1288 | */ |
---|
1289 | //@{ |
---|
1290 | |
---|
1291 | /// Get the current strategy |
---|
1292 | inline CbcStrategy * strategy() const |
---|
1293 | { return strategy_;}; |
---|
1294 | /// Set the strategy. Clones |
---|
1295 | void setStrategy(CbcStrategy & strategy); |
---|
1296 | /// Get the current parent model |
---|
1297 | inline CbcModel * parentModel() const |
---|
1298 | { return parentModel_;}; |
---|
1299 | /// Set the parent model |
---|
1300 | inline void setParentModel(CbcModel & parentModel) |
---|
1301 | { parentModel_ = &parentModel;}; |
---|
1302 | //@} |
---|
1303 | |
---|
1304 | |
---|
1305 | /** \name Heuristics and priorities */ |
---|
1306 | //@{ |
---|
1307 | /*! \brief Add one heuristic - up to user to delete |
---|
1308 | |
---|
1309 | The name is just used for print messages. |
---|
1310 | */ |
---|
1311 | void addHeuristic(CbcHeuristic * generator, const char *name = NULL); |
---|
1312 | ///Get the specified heuristic |
---|
1313 | inline CbcHeuristic * heuristic(int i) const |
---|
1314 | { return heuristic_[i];}; |
---|
1315 | /// Get the number of heuristics |
---|
1316 | inline int numberHeuristics() const |
---|
1317 | { return numberHeuristics_;}; |
---|
1318 | /// Pointer to heuristic solver which found last solution (or NULL) |
---|
1319 | inline CbcHeuristic * lastHeuristic() const |
---|
1320 | { return lastHeuristic_;}; |
---|
1321 | /// set last heuristic which found a solution |
---|
1322 | inline void setLastHeuristic(CbcHeuristic * last) |
---|
1323 | { lastHeuristic_=last;}; |
---|
1324 | |
---|
1325 | /** Pass in branching priorities. |
---|
1326 | |
---|
1327 | If ifClique then priorities are on cliques otherwise priorities are |
---|
1328 | on integer variables. |
---|
1329 | Other type (if exists set to default) |
---|
1330 | 1 is highest priority. (well actually -INT_MAX is but that's ugly) |
---|
1331 | If hotstart > 0 then branches are created to force |
---|
1332 | the variable to the value given by best solution. This enables a |
---|
1333 | sort of hot start. The node choice should be greatest depth |
---|
1334 | and hotstart should normally be switched off after a solution. |
---|
1335 | |
---|
1336 | If ifNotSimpleIntegers true then appended to normal integers |
---|
1337 | |
---|
1338 | This is now deprecated except for simple usage. If user |
---|
1339 | creates Cbcobjects then set priority in them |
---|
1340 | |
---|
1341 | \internal Added for Kurt Spielberg. |
---|
1342 | */ |
---|
1343 | void passInPriorities(const int * priorities, bool ifNotSimpleIntegers); |
---|
1344 | |
---|
1345 | /// Returns priority level for an object (or 1000 if no priorities exist) |
---|
1346 | inline int priority(int sequence) const |
---|
1347 | { return object_[sequence]->priority();}; |
---|
1348 | |
---|
1349 | /*! \brief Set an event handler |
---|
1350 | |
---|
1351 | A clone of the handler passed as a parameter is stored in CbcModel. |
---|
1352 | */ |
---|
1353 | void passInEventHandler(const CbcEventHandler *eventHandler) ; |
---|
1354 | |
---|
1355 | /*! \brief Retrieve a pointer to the event handler */ |
---|
1356 | inline CbcEventHandler* getEventHandler() const |
---|
1357 | { return (eventHandler_) ; } ; |
---|
1358 | |
---|
1359 | //@} |
---|
1360 | |
---|
1361 | /**@name Setting/Accessing application data */ |
---|
1362 | //@{ |
---|
1363 | /** Set application data. |
---|
1364 | |
---|
1365 | This is a pointer that the application can store into and |
---|
1366 | retrieve from the solver interface. |
---|
1367 | This field is available for the application to optionally |
---|
1368 | define and use. |
---|
1369 | */ |
---|
1370 | void setApplicationData (void * appData); |
---|
1371 | |
---|
1372 | /// Get application data |
---|
1373 | void * getApplicationData() const; |
---|
1374 | /** |
---|
1375 | For advanced applications you may wish to modify the behavior of Cbc |
---|
1376 | e.g. if the solver is a NLP solver then you may not have an exact |
---|
1377 | optimum solution at each step. Information could be built into |
---|
1378 | OsiSolverInterface but this is an alternative so that that interface |
---|
1379 | does not have to be changed. If something similar is useful to |
---|
1380 | enough solvers then it could be migrated |
---|
1381 | You can also pass in by using solver->setAuxiliaryInfo. |
---|
1382 | You should do that if solver is odd - if solver is normal simplex |
---|
1383 | then use this. |
---|
1384 | NOTE - characteristics are not cloned |
---|
1385 | */ |
---|
1386 | void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics); |
---|
1387 | /// Get solver characteristics |
---|
1388 | inline const OsiBabSolver * solverCharacteristics() const |
---|
1389 | { return solverCharacteristics_;}; |
---|
1390 | //@} |
---|
1391 | |
---|
1392 | //--------------------------------------------------------------------------- |
---|
1393 | |
---|
1394 | /**@name Message handling */ |
---|
1395 | //@{ |
---|
1396 | /// Pass in Message handler (not deleted at end) |
---|
1397 | void passInMessageHandler(CoinMessageHandler * handler); |
---|
1398 | /// Set language |
---|
1399 | void newLanguage(CoinMessages::Language language); |
---|
1400 | inline void setLanguage(CoinMessages::Language language) |
---|
1401 | {newLanguage(language);}; |
---|
1402 | /// Return handler |
---|
1403 | inline CoinMessageHandler * messageHandler() const |
---|
1404 | {return handler_;}; |
---|
1405 | /// Return messages |
---|
1406 | inline CoinMessages & messages() |
---|
1407 | {return messages_;}; |
---|
1408 | /// Return pointer to messages |
---|
1409 | inline CoinMessages * messagesPointer() |
---|
1410 | {return &messages_;}; |
---|
1411 | /// Set log level |
---|
1412 | void setLogLevel(int value); |
---|
1413 | /// Get log level |
---|
1414 | inline int logLevel() const |
---|
1415 | { return handler_->logLevel();}; |
---|
1416 | //@} |
---|
1417 | //--------------------------------------------------------------------------- |
---|
1418 | ///@name Specialized |
---|
1419 | //@{ |
---|
1420 | |
---|
1421 | /** |
---|
1422 | Set special options |
---|
1423 | 0 bit (1) - check if cuts valid (if on debugger list) |
---|
1424 | 1 bit (2) - use current basis to check integer solution (rather than all slack) |
---|
1425 | 2 bit (4) - don't check integer solution (by solving LP) |
---|
1426 | 3 bit (8) - fast analyze |
---|
1427 | 4 bit (16) - non-linear model - so no well defined CoinPackedMatrix |
---|
1428 | 5 bit (32) - keep names |
---|
1429 | 6 bit (64) - try for dominated columns |
---|
1430 | */ |
---|
1431 | /// Set special options |
---|
1432 | inline void setSpecialOptions(int value) |
---|
1433 | { specialOptions_=value;}; |
---|
1434 | /// Get special options |
---|
1435 | inline int specialOptions() const |
---|
1436 | { return specialOptions_;}; |
---|
1437 | /// Says if normal solver i.e. has well defined CoinPackedMatrix |
---|
1438 | inline bool normalSolver() const |
---|
1439 | { return (specialOptions_&16)==0;}; |
---|
1440 | /// Now we may not own objects - just point to solver's objects |
---|
1441 | inline bool ownObjects() const |
---|
1442 | { return ownObjects_;}; |
---|
1443 | /// Pointer to a mutex |
---|
1444 | inline void * mutex() |
---|
1445 | { return mutex_;}; |
---|
1446 | //@} |
---|
1447 | //--------------------------------------------------------------------------- |
---|
1448 | |
---|
1449 | ///@name Constructors and destructors etc |
---|
1450 | //@{ |
---|
1451 | /// Default Constructor |
---|
1452 | CbcModel(); |
---|
1453 | |
---|
1454 | /// Constructor from solver |
---|
1455 | CbcModel(const OsiSolverInterface &); |
---|
1456 | |
---|
1457 | /** Assign a solver to the model (model assumes ownership) |
---|
1458 | |
---|
1459 | On return, \p solver will be NULL. |
---|
1460 | If deleteSolver then current solver deleted (if model owned) |
---|
1461 | |
---|
1462 | \note Parameter settings in the outgoing solver are not inherited by |
---|
1463 | the incoming solver. |
---|
1464 | */ |
---|
1465 | void assignSolver(OsiSolverInterface *&solver,bool deleteSolver=true); |
---|
1466 | |
---|
1467 | /** \brief Set ownership of solver |
---|
1468 | |
---|
1469 | A parameter of false tells CbcModel it does not own the solver and |
---|
1470 | should not delete it. Once you claim ownership of the solver, you're |
---|
1471 | responsible for eventually deleting it. Note that CbcModel clones |
---|
1472 | solvers with abandon. Unless you have a deep understanding of the |
---|
1473 | workings of CbcModel, the only time you want to claim ownership is when |
---|
1474 | you're about to delete the CbcModel object but want the solver to |
---|
1475 | continue to exist (as, for example, when branchAndBound has finished |
---|
1476 | and you want to hang on to the answer). |
---|
1477 | */ |
---|
1478 | inline void setModelOwnsSolver (bool ourSolver) |
---|
1479 | { ourSolver_ = ourSolver ; } ; |
---|
1480 | |
---|
1481 | /*! \brief Get ownership of solver |
---|
1482 | |
---|
1483 | A return value of true means that CbcModel owns the solver and will |
---|
1484 | take responsibility for deleting it when that becomes necessary. |
---|
1485 | */ |
---|
1486 | inline bool modelOwnsSolver () { return (ourSolver_) ; } ; |
---|
1487 | |
---|
1488 | /** Copy constructor . |
---|
1489 | If noTree is true then tree and cuts are not copied |
---|
1490 | */ |
---|
1491 | CbcModel(const CbcModel & rhs, bool noTree=false); |
---|
1492 | |
---|
1493 | /// Assignment operator |
---|
1494 | CbcModel & operator=(const CbcModel& rhs); |
---|
1495 | |
---|
1496 | /// Destructor |
---|
1497 | ~CbcModel (); |
---|
1498 | |
---|
1499 | /// Returns solver - has current state |
---|
1500 | inline OsiSolverInterface * solver() const |
---|
1501 | { return solver_;}; |
---|
1502 | |
---|
1503 | /// Returns solver with continuous state |
---|
1504 | inline OsiSolverInterface * continuousSolver() const |
---|
1505 | { return continuousSolver_;}; |
---|
1506 | |
---|
1507 | /// A copy of the solver, taken at constructor or by saveReferenceSolver |
---|
1508 | inline OsiSolverInterface * referenceSolver() const |
---|
1509 | { return referenceSolver_;}; |
---|
1510 | |
---|
1511 | /// Save a copy of the current solver so can be reset to |
---|
1512 | void saveReferenceSolver(); |
---|
1513 | |
---|
1514 | /** Uses a copy of reference solver to be current solver. |
---|
1515 | Because of possible mismatches all exotic integer information is loat |
---|
1516 | (apart from normal information in OsiSolverInterface) |
---|
1517 | so SOS etc and priorities will have to be redone |
---|
1518 | */ |
---|
1519 | void resetToReferenceSolver(); |
---|
1520 | |
---|
1521 | /// Clears out as much as possible (except solver) |
---|
1522 | void gutsOfDestructor(); |
---|
1523 | /** Clears out enough to reset CbcModel as if no branch and bound done |
---|
1524 | */ |
---|
1525 | void gutsOfDestructor2(); |
---|
1526 | /** Clears out enough to reset CbcModel cutoff etc |
---|
1527 | */ |
---|
1528 | void resetModel(); |
---|
1529 | //@} |
---|
1530 | |
---|
1531 | ///@semi-private i.e. users should not use |
---|
1532 | //@{ |
---|
1533 | /// Get how many Nodes it took to solve the problem. |
---|
1534 | int getNodeCount2() const |
---|
1535 | { return numberNodes2_;}; |
---|
1536 | /// Set pointers for speed |
---|
1537 | void setPointers(const OsiSolverInterface * solver); |
---|
1538 | /** Perform reduced cost fixing |
---|
1539 | |
---|
1540 | Fixes integer variables at their current value based on reduced cost |
---|
1541 | penalties. Returns number fixed |
---|
1542 | */ |
---|
1543 | int reducedCostFix() ; |
---|
1544 | /// Encapsulates solver resolve |
---|
1545 | int resolve(OsiSolverInterface * solver); |
---|
1546 | |
---|
1547 | /** Encapsulates choosing a variable - |
---|
1548 | anyAction -2, infeasible (-1 round again), 0 done |
---|
1549 | */ |
---|
1550 | int chooseBranch(CbcNode * newNode, int numberPassesLeft, |
---|
1551 | CbcNode * oldNode, OsiCuts & cuts, |
---|
1552 | bool & resolved, CoinWarmStartBasis *lastws, |
---|
1553 | const double * lowerBefore,const double * upperBefore, |
---|
1554 | OsiSolverBranch * & branches); |
---|
1555 | int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved); |
---|
1556 | |
---|
1557 | /** Return an empty basis object of the specified size |
---|
1558 | |
---|
1559 | A useful utility when constructing a basis for a subproblem from scratch. |
---|
1560 | The object returned will be of the requested capacity and appropriate for |
---|
1561 | the solver attached to the model. |
---|
1562 | */ |
---|
1563 | CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ; |
---|
1564 | |
---|
1565 | /** Remove inactive cuts from the model |
---|
1566 | |
---|
1567 | An OsiSolverInterface is expected to maintain a valid basis, but not a |
---|
1568 | valid solution, when loose cuts are deleted. Restoring a valid solution |
---|
1569 | requires calling the solver to reoptimise. If it's certain the solution |
---|
1570 | will not be required, set allowResolve to false to suppress |
---|
1571 | reoptimisation. |
---|
1572 | If saveCuts then slack cuts will be saved |
---|
1573 | */ |
---|
1574 | void takeOffCuts(OsiCuts &cuts, |
---|
1575 | bool allowResolve,OsiCuts * saveCuts) ; |
---|
1576 | |
---|
1577 | /** Determine and install the active cuts that need to be added for |
---|
1578 | the current subproblem |
---|
1579 | |
---|
1580 | The whole truth is a bit more complicated. The first action is a call to |
---|
1581 | addCuts1(). addCuts() then sorts through the list, installs the tight |
---|
1582 | cuts in the model, and does bookkeeping (adjusts reference counts). |
---|
1583 | The basis returned from addCuts1() is adjusted accordingly. |
---|
1584 | |
---|
1585 | If it turns out that the node should really be fathomed by bound, |
---|
1586 | addCuts() simply treats all the cuts as loose as it does the bookkeeping. |
---|
1587 | |
---|
1588 | canFix true if extra information being passed |
---|
1589 | */ |
---|
1590 | int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws,bool canFix); |
---|
1591 | |
---|
1592 | /** Traverse the tree from node to root and prep the model |
---|
1593 | |
---|
1594 | addCuts1() begins the job of prepping the model to match the current |
---|
1595 | subproblem. The model is stripped of all cuts, and the search tree is |
---|
1596 | traversed from node to root to determine the changes required. Appropriate |
---|
1597 | bounds changes are installed, a list of cuts is collected but not |
---|
1598 | installed, and an appropriate basis (minus the cuts, but big enough to |
---|
1599 | accommodate them) is constructed. |
---|
1600 | |
---|
1601 | \todo addCuts1() is called in contexts where it's known in advance that |
---|
1602 | all that's desired is to determine a list of cuts and do the |
---|
1603 | bookkeeping (adjust the reference counts). The work of installing |
---|
1604 | bounds and building a basis goes to waste. |
---|
1605 | */ |
---|
1606 | void addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws); |
---|
1607 | /** Set objective value in a node. This is separated out so that |
---|
1608 | odd solvers can use. It may look at extra information in |
---|
1609 | solverCharacteriscs_ and will also use bound from parent node |
---|
1610 | */ |
---|
1611 | void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const; |
---|
1612 | |
---|
1613 | /** If numberBeforeTrust >0 then we are going to use CbcBranchDynamic. |
---|
1614 | Scan and convert CbcSimpleInteger objects |
---|
1615 | */ |
---|
1616 | void convertToDynamic(); |
---|
1617 | /// Use cliques for pseudocost information - return nonzero if infeasible |
---|
1618 | int cliquePseudoCosts(int doStatistics); |
---|
1619 | /// Fill in useful estimates |
---|
1620 | void pseudoShadow(double * down, double * up); |
---|
1621 | |
---|
1622 | /// Get the hotstart solution |
---|
1623 | inline const double * hotstartSolution() const |
---|
1624 | { return hotstartSolution_;}; |
---|
1625 | /// Get the hotstart priorities |
---|
1626 | inline const int * hotstartPriorities() const |
---|
1627 | { return hotstartPriorities_;}; |
---|
1628 | |
---|
1629 | /// Return the list of cuts initially collected for this subproblem |
---|
1630 | inline CbcCountRowCut ** addedCuts() const |
---|
1631 | { return addedCuts_;}; |
---|
1632 | /// Number of entries in the list returned by #addedCuts() |
---|
1633 | inline int currentNumberCuts() const |
---|
1634 | { return currentNumberCuts_;}; |
---|
1635 | /// Global cuts |
---|
1636 | inline OsiCuts * globalCuts() |
---|
1637 | { return &globalCuts_;}; |
---|
1638 | /// Copy and set a pointer to a row cut which will be added instead of normal branching. |
---|
1639 | void setNextRowCut(const OsiRowCut & cut); |
---|
1640 | /// Get a pointer to current node (be careful) |
---|
1641 | inline CbcNode * currentNode() const |
---|
1642 | { return currentNode_;}; |
---|
1643 | /// Get a pointer to probing info |
---|
1644 | inline CglTreeProbingInfo * probingInfo() const |
---|
1645 | { return probingInfo_;}; |
---|
1646 | /// Set the number of iterations done in strong branching. |
---|
1647 | inline void setNumberStrongIterations(int number) |
---|
1648 | { numberStrongIterations_ = number;}; |
---|
1649 | /// Get the number of iterations done in strong branching. |
---|
1650 | inline int numberStrongIterations() const |
---|
1651 | { return numberStrongIterations_;}; |
---|
1652 | /// Increment strong info |
---|
1653 | void incrementStrongInfo(int numberTimes, int numberIterations, |
---|
1654 | int numberFixed, bool ifInfeasible); |
---|
1655 | /// Create C++ lines to get to current state |
---|
1656 | void generateCpp( FILE * fp,int options); |
---|
1657 | /// Generate an OsiBranchingInformation object |
---|
1658 | OsiBranchingInformation usefulInformation() const; |
---|
1659 | //@} |
---|
1660 | |
---|
1661 | //--------------------------------------------------------------------------- |
---|
1662 | |
---|
1663 | private: |
---|
1664 | ///@name Private member data |
---|
1665 | //@{ |
---|
1666 | |
---|
1667 | /// The solver associated with this model. |
---|
1668 | OsiSolverInterface * solver_; |
---|
1669 | |
---|
1670 | /** Ownership of the solver object |
---|
1671 | |
---|
1672 | The convention is that CbcModel owns the null solver. Currently there |
---|
1673 | is no public method to give CbcModel a solver without giving ownership, |
---|
1674 | but the hook is here. |
---|
1675 | */ |
---|
1676 | bool ourSolver_ ; |
---|
1677 | |
---|
1678 | /// A copy of the solver, taken at the continuous (root) node. |
---|
1679 | OsiSolverInterface * continuousSolver_; |
---|
1680 | |
---|
1681 | /// A copy of the solver, taken at constructor or by saveReferenceSolver |
---|
1682 | OsiSolverInterface * referenceSolver_; |
---|
1683 | |
---|
1684 | /// Message handler |
---|
1685 | CoinMessageHandler * handler_; |
---|
1686 | |
---|
1687 | /** Flag to say if handler_ is the default handler. |
---|
1688 | |
---|
1689 | The default handler is deleted when the model is deleted. Other |
---|
1690 | handlers (supplied by the client) will not be deleted. |
---|
1691 | */ |
---|
1692 | bool defaultHandler_; |
---|
1693 | |
---|
1694 | /// Cbc messages |
---|
1695 | CoinMessages messages_; |
---|
1696 | |
---|
1697 | /// Array for integer parameters |
---|
1698 | int intParam_[CbcLastIntParam]; |
---|
1699 | |
---|
1700 | /// Array for double parameters |
---|
1701 | double dblParam_[CbcLastDblParam]; |
---|
1702 | |
---|
1703 | /** Pointer to an empty warm start object |
---|
1704 | |
---|
1705 | It turns out to be useful to have this available as a base from |
---|
1706 | which to build custom warm start objects. This is typed as CoinWarmStart |
---|
1707 | rather than CoinWarmStartBasis to allow for the possibility that a |
---|
1708 | client might want to apply a solver that doesn't use a basis-based warm |
---|
1709 | start. See getEmptyBasis for an example of how this field can be used. |
---|
1710 | */ |
---|
1711 | mutable CoinWarmStart *emptyWarmStart_ ; |
---|
1712 | |
---|
1713 | /// Best objective |
---|
1714 | double bestObjective_; |
---|
1715 | /// Best possible objective |
---|
1716 | double bestPossibleObjective_; |
---|
1717 | /// Sum of Changes to objective by first solve |
---|
1718 | double sumChangeObjective1_; |
---|
1719 | /// Sum of Changes to objective by subsequent solves |
---|
1720 | double sumChangeObjective2_; |
---|
1721 | |
---|
1722 | /// Array holding the incumbent (best) solution. |
---|
1723 | double * bestSolution_; |
---|
1724 | |
---|
1725 | /** Array holding the current solution. |
---|
1726 | |
---|
1727 | This array is used more as a temporary. |
---|
1728 | */ |
---|
1729 | double * currentSolution_; |
---|
1730 | /** For testing infeasibilities - will point to |
---|
1731 | currentSolution_ or solver-->getColSolution() |
---|
1732 | */ |
---|
1733 | mutable const double * testSolution_; |
---|
1734 | /// Global cuts |
---|
1735 | OsiCuts globalCuts_; |
---|
1736 | |
---|
1737 | /// Minimum degradation in objective value to continue cut generation |
---|
1738 | double minimumDrop_; |
---|
1739 | /// Number of solutions |
---|
1740 | int numberSolutions_; |
---|
1741 | /** State of search |
---|
1742 | 0 - no solution |
---|
1743 | 1 - only heuristic solutions |
---|
1744 | 2 - branched to a solution |
---|
1745 | 3 - no solution but many nodes |
---|
1746 | */ |
---|
1747 | int stateOfSearch_; |
---|
1748 | /// Hotstart solution |
---|
1749 | double * hotstartSolution_; |
---|
1750 | /// Hotstart priorities |
---|
1751 | int * hotstartPriorities_; |
---|
1752 | /// Number of heuristic solutions |
---|
1753 | int numberHeuristicSolutions_; |
---|
1754 | /// Cumulative number of nodes |
---|
1755 | int numberNodes_; |
---|
1756 | /** Cumulative number of nodes for statistics. |
---|
1757 | Must fix to match up |
---|
1758 | */ |
---|
1759 | int numberNodes2_; |
---|
1760 | /// Cumulative number of iterations |
---|
1761 | int numberIterations_; |
---|
1762 | /// Status of problem - 0 finished, 1 stopped, 2 difficulties |
---|
1763 | int status_; |
---|
1764 | /** Secondary status of problem |
---|
1765 | -1 unset (status_ will also be -1) |
---|
1766 | 0 search completed with solution |
---|
1767 | 1 linear relaxation not feasible (or worse than cutoff) |
---|
1768 | 2 stopped on gap |
---|
1769 | 3 stopped on nodes |
---|
1770 | 4 stopped on time |
---|
1771 | 5 stopped on user event |
---|
1772 | 6 stopped on solutions |
---|
1773 | */ |
---|
1774 | int secondaryStatus_; |
---|
1775 | /// Number of integers in problem |
---|
1776 | int numberIntegers_; |
---|
1777 | /// Number of rows at continuous |
---|
1778 | int numberRowsAtContinuous_; |
---|
1779 | /// Maximum number of cuts |
---|
1780 | int maximumNumberCuts_; |
---|
1781 | /** Current phase (so heuristics etc etc can find out). |
---|
1782 | 0 - initial solve |
---|
1783 | 1 - solve with cuts at root |
---|
1784 | 2 - solve with cuts |
---|
1785 | 3 - other e.g. strong branching |
---|
1786 | 4 - trying to validate a solution |
---|
1787 | 5 - at end of search |
---|
1788 | */ |
---|
1789 | int phase_; |
---|
1790 | |
---|
1791 | /// Number of entries in #addedCuts_ |
---|
1792 | int currentNumberCuts_; |
---|
1793 | |
---|
1794 | /** Current limit on search tree depth |
---|
1795 | |
---|
1796 | The allocated size of #walkback_. Increased as needed. |
---|
1797 | */ |
---|
1798 | int maximumDepth_; |
---|
1799 | /** Array used to assemble the path between a node and the search tree root |
---|
1800 | |
---|
1801 | The array is resized when necessary. #maximumDepth_ is the current |
---|
1802 | allocated size. |
---|
1803 | */ |
---|
1804 | CbcNodeInfo ** walkback_; |
---|
1805 | |
---|
1806 | /** The list of cuts initially collected for this subproblem |
---|
1807 | |
---|
1808 | When the subproblem at this node is rebuilt, a set of cuts is collected |
---|
1809 | for inclusion in the constraint system. If any of these cuts are |
---|
1810 | subsequently removed because they have become loose, the corresponding |
---|
1811 | entry is set to NULL. |
---|
1812 | */ |
---|
1813 | CbcCountRowCut ** addedCuts_; |
---|
1814 | |
---|
1815 | /** A pointer to a row cut which will be added instead of normal branching. |
---|
1816 | After use it should be set to NULL. |
---|
1817 | */ |
---|
1818 | OsiRowCut * nextRowCut_; |
---|
1819 | |
---|
1820 | /// Current node so can be used elsewhere |
---|
1821 | CbcNode * currentNode_; |
---|
1822 | |
---|
1823 | /// Indices of integer variables |
---|
1824 | int * integerVariable_; |
---|
1825 | /// Whether of not integer |
---|
1826 | char * integerInfo_; |
---|
1827 | /// Holds solution at continuous (after cuts) |
---|
1828 | double * continuousSolution_; |
---|
1829 | /// Array marked whenever a solution is found if non-zero |
---|
1830 | int * usedInSolution_; |
---|
1831 | /** |
---|
1832 | 0 bit (1) - check if cuts valid (if on debugger list) |
---|
1833 | 1 bit (2) - use current basis to check integer solution (rather than all slack) |
---|
1834 | 2 bit (4) - don't check integer solution |
---|
1835 | 3 bit (8) - Strong is doing well - keep on |
---|
1836 | */ |
---|
1837 | int specialOptions_; |
---|
1838 | /// User node comparison function |
---|
1839 | CbcCompareBase * nodeCompare_; |
---|
1840 | /// User feasibility function (see CbcFeasibleBase.hpp) |
---|
1841 | CbcFeasibilityBase * problemFeasibility_; |
---|
1842 | /// Tree |
---|
1843 | CbcTree * tree_; |
---|
1844 | /// A pointer to model to be used for subtrees |
---|
1845 | CbcModel * subTreeModel_; |
---|
1846 | /// Number of times any subtree stopped on nodes, time etc |
---|
1847 | int numberStoppedSubTrees_; |
---|
1848 | /// Variable selection function |
---|
1849 | CbcBranchDecision * branchingMethod_; |
---|
1850 | /// Cut modifier function |
---|
1851 | CbcCutModifier * cutModifier_; |
---|
1852 | /// Strategy |
---|
1853 | CbcStrategy * strategy_; |
---|
1854 | /// Parent model |
---|
1855 | CbcModel * parentModel_; |
---|
1856 | /** Whether to automatically do presolve before branch and bound. |
---|
1857 | 0 - no |
---|
1858 | 1 - ordinary presolve |
---|
1859 | 2 - integer presolve (dodgy) |
---|
1860 | */ |
---|
1861 | /// Pointer to array[getNumCols()] (for speed) of column lower bounds |
---|
1862 | const double * cbcColLower_; |
---|
1863 | /// Pointer to array[getNumCols()] (for speed) of column upper bounds |
---|
1864 | const double * cbcColUpper_; |
---|
1865 | /// Pointer to array[getNumRows()] (for speed) of row lower bounds |
---|
1866 | const double * cbcRowLower_; |
---|
1867 | /// Pointer to array[getNumRows()] (for speed) of row upper bounds |
---|
1868 | const double * cbcRowUpper_; |
---|
1869 | /// Pointer to array[getNumCols()] (for speed) of primal solution vector |
---|
1870 | const double * cbcColSolution_; |
---|
1871 | /// Pointer to array[getNumRows()] (for speed) of dual prices |
---|
1872 | const double * cbcRowPrice_; |
---|
1873 | /// Get a pointer to array[getNumCols()] (for speed) of reduced costs |
---|
1874 | const double * cbcReducedCost_; |
---|
1875 | /// Pointer to array[getNumRows()] (for speed) of row activity levels. |
---|
1876 | const double * cbcRowActivity_; |
---|
1877 | /// Pointer to user-defined data structure |
---|
1878 | void * appData_; |
---|
1879 | /// Pointer to a mutex |
---|
1880 | void * mutex_; |
---|
1881 | /// Presolve for CbcTreeLocal |
---|
1882 | int presolve_; |
---|
1883 | /** Maximum number of candidates to consider for strong branching. |
---|
1884 | To disable strong branching, set this to 0. |
---|
1885 | */ |
---|
1886 | int numberStrong_; |
---|
1887 | /** \brief The number of branches before pseudo costs believed |
---|
1888 | in dynamic strong branching. |
---|
1889 | |
---|
1890 | A value of 0 is off. |
---|
1891 | */ |
---|
1892 | int numberBeforeTrust_; |
---|
1893 | /** \brief The number of variables for which to compute penalties |
---|
1894 | in dynamic strong branching. |
---|
1895 | */ |
---|
1896 | int numberPenalties_; |
---|
1897 | /** Scale factor to make penalties match strong. |
---|
1898 | Should/will be computed */ |
---|
1899 | double penaltyScaleFactor_; |
---|
1900 | /// Number of analyze iterations to do |
---|
1901 | int numberAnalyzeIterations_; |
---|
1902 | /// Arrays with analysis results |
---|
1903 | double * analyzeResults_; |
---|
1904 | /// Number of nodes infeasible by normal branching (before cuts) |
---|
1905 | int numberInfeasibleNodes_; |
---|
1906 | /** Problem type as set by user or found by analysis. This will be extended |
---|
1907 | 0 - not known |
---|
1908 | 1 - Set partitioning <= |
---|
1909 | 2 - Set partitioning == |
---|
1910 | 3 - Set covering |
---|
1911 | */ |
---|
1912 | int problemType_; |
---|
1913 | /// Print frequency |
---|
1914 | int printFrequency_; |
---|
1915 | /// Number of cut generators |
---|
1916 | int numberCutGenerators_; |
---|
1917 | // Cut generators |
---|
1918 | CbcCutGenerator ** generator_; |
---|
1919 | // Cut generators before any changes |
---|
1920 | CbcCutGenerator ** virginGenerator_; |
---|
1921 | /// Number of heuristics |
---|
1922 | int numberHeuristics_; |
---|
1923 | /// Heuristic solvers |
---|
1924 | CbcHeuristic ** heuristic_; |
---|
1925 | /// Pointer to heuristic solver which found last solution (or NULL) |
---|
1926 | CbcHeuristic * lastHeuristic_; |
---|
1927 | /*! Pointer to the event handler */ |
---|
1928 | # ifdef CBC_ONLY_CLP |
---|
1929 | ClpEventHandler *eventHandler_ ; |
---|
1930 | # else |
---|
1931 | CbcEventHandler *eventHandler_ ; |
---|
1932 | # endif |
---|
1933 | |
---|
1934 | /// Total number of objects |
---|
1935 | int numberObjects_; |
---|
1936 | |
---|
1937 | /** \brief Integer and Clique and ... information |
---|
1938 | |
---|
1939 | \note The code assumes that the first objects on the list will be |
---|
1940 | SimpleInteger objects for each integer variable, followed by |
---|
1941 | Clique objects. Portions of the code that understand Clique objects |
---|
1942 | will fail if they do not immediately follow the SimpleIntegers. |
---|
1943 | Large chunks of the code will fail if the first objects are not |
---|
1944 | SimpleInteger. As of 2003.08, SimpleIntegers and Cliques are the only |
---|
1945 | objects. |
---|
1946 | */ |
---|
1947 | OsiObject ** object_; |
---|
1948 | /// Now we may not own objects - just point to solver's objects |
---|
1949 | bool ownObjects_; |
---|
1950 | |
---|
1951 | /// Original columns as created by integerPresolve |
---|
1952 | int * originalColumns_; |
---|
1953 | /// How often to scan global cuts |
---|
1954 | int howOftenGlobalScan_; |
---|
1955 | /** Number of times global cuts violated. When global cut pool then this |
---|
1956 | should be kept for each cut and type of cut */ |
---|
1957 | int numberGlobalViolations_; |
---|
1958 | /** Value of objective at continuous |
---|
1959 | (Well actually after initial round of cuts) |
---|
1960 | */ |
---|
1961 | double continuousObjective_; |
---|
1962 | /** Value of objective before root node cuts added |
---|
1963 | */ |
---|
1964 | double originalContinuousObjective_; |
---|
1965 | /// Number of infeasibilities at continuous |
---|
1966 | int continuousInfeasibilities_; |
---|
1967 | /// Maximum number of cut passes at root |
---|
1968 | int maximumCutPassesAtRoot_; |
---|
1969 | /// Maximum number of cut passes |
---|
1970 | int maximumCutPasses_; |
---|
1971 | /// Preferred way of branching |
---|
1972 | int preferredWay_; |
---|
1973 | /// Current cut pass number |
---|
1974 | int currentPassNumber_; |
---|
1975 | /// Maximum number of cuts (for whichGenerator_) |
---|
1976 | int maximumWhich_; |
---|
1977 | /// Which cut generator generated this cut |
---|
1978 | int * whichGenerator_; |
---|
1979 | /// Maximum number of statistics |
---|
1980 | int maximumStatistics_; |
---|
1981 | /// statistics |
---|
1982 | CbcStatistics ** statistics_; |
---|
1983 | /// Maximum depth reached |
---|
1984 | int maximumDepthActual_; |
---|
1985 | /// Number of reduced cost fixings |
---|
1986 | double numberDJFixed_; |
---|
1987 | /// Probing info |
---|
1988 | CglTreeProbingInfo * probingInfo_; |
---|
1989 | /// Number of fixed by analyze at root |
---|
1990 | int numberFixedAtRoot_; |
---|
1991 | /// Number fixed by analyze so far |
---|
1992 | int numberFixedNow_; |
---|
1993 | /// Whether stopping on gap |
---|
1994 | bool stoppedOnGap_; |
---|
1995 | /// Whether event happened |
---|
1996 | bool eventHappened_; |
---|
1997 | /// Number of long strong goes |
---|
1998 | int numberLongStrong_; |
---|
1999 | /// Number of old active cuts |
---|
2000 | int numberOldActiveCuts_; |
---|
2001 | /// Number of new cuts |
---|
2002 | int numberNewCuts_; |
---|
2003 | /// Size of mini - tree |
---|
2004 | int sizeMiniTree_; |
---|
2005 | /// Strategy worked out - mainly at root node |
---|
2006 | int searchStrategy_; |
---|
2007 | /// Number of iterations in strong branching |
---|
2008 | int numberStrongIterations_; |
---|
2009 | /** 0 - number times strong branching done, 1 - number fixed, 2 - number infeasible */ |
---|
2010 | int strongInfo_[3]; |
---|
2011 | /** |
---|
2012 | For advanced applications you may wish to modify the behavior of Cbc |
---|
2013 | e.g. if the solver is a NLP solver then you may not have an exact |
---|
2014 | optimum solution at each step. This gives characteristics - just for one BAB. |
---|
2015 | For actually saving/restoring a solution you need the actual solver one. |
---|
2016 | */ |
---|
2017 | OsiBabSolver * solverCharacteristics_; |
---|
2018 | /// Whether to force a resolve after takeOffCuts |
---|
2019 | bool resolveAfterTakeOffCuts_; |
---|
2020 | #if NEW_UPDATE_OBJECT>1 |
---|
2021 | /// Number of outstanding update information items |
---|
2022 | int numberUpdateItems_; |
---|
2023 | /// Maximum number of outstanding update information items |
---|
2024 | int maximumNumberUpdateItems_; |
---|
2025 | /// Update items |
---|
2026 | CbcObjectUpdateData * updateItems_; |
---|
2027 | #endif |
---|
2028 | /** |
---|
2029 | Parallel |
---|
2030 | 0 - off |
---|
2031 | 1 - testing |
---|
2032 | 2-99 threads |
---|
2033 | other special meanings |
---|
2034 | */ |
---|
2035 | int numberThreads_; |
---|
2036 | /** thread mode |
---|
2037 | always use numberThreads for branching |
---|
2038 | 1 set then use numberThreads in root mini branch and bound |
---|
2039 | 2 set then use numberThreads for root cuts |
---|
2040 | default is 0 |
---|
2041 | */ |
---|
2042 | int threadMode_; |
---|
2043 | //@} |
---|
2044 | }; |
---|
2045 | /// So we can use osiObject or CbcObject during transition |
---|
2046 | void getIntegerInformation(const OsiObject * object, double & originalLower, |
---|
2047 | double & originalUpper) ; |
---|
2048 | // So we can call from other programs |
---|
2049 | // Real main program |
---|
2050 | class OsiClpSolverInterface; |
---|
2051 | int CbcMain (int argc, const char *argv[],OsiClpSolverInterface & solver,CbcModel ** babSolver); |
---|
2052 | int CbcMain (int argc, const char *argv[],CbcModel & babSolver); |
---|
2053 | // four ways of calling |
---|
2054 | int callCbc(const char * input2, OsiClpSolverInterface& solver1); |
---|
2055 | int callCbc(const char * input2); |
---|
2056 | int callCbc(const std::string input2, OsiClpSolverInterface& solver1); |
---|
2057 | int callCbc(const std::string input2) ; |
---|
2058 | // When we want to load up CbcModel with options first |
---|
2059 | void CbcMain0 (CbcModel & babSolver); |
---|
2060 | int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver); |
---|
2061 | // two ways of calling |
---|
2062 | int callCbc(const char * input2, CbcModel & babSolver); |
---|
2063 | int callCbc(const std::string input2, CbcModel & babSolver); |
---|
2064 | // And when CbcMain0 already called to initialize |
---|
2065 | int callCbc1(const char * input2, CbcModel & babSolver); |
---|
2066 | int callCbc1(const std::string input2, CbcModel & babSolver); |
---|
2067 | #endif |
---|