source: branches/sandbox/Cbc/src/CbcModel_ban.hpp @ 1286

Last change on this file since 1286 was 1286, checked in by EdwinStraver, 10 years ago

Changed formatting using AStyle -A4 -p

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