source: branches/sandbox/Cbc/src/CbcModel.hpp @ 1340

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

Fixed yesterday's bugs

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