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

Last change on this file since 1290 was 1290, checked in by bjarni, 10 years ago

Extract classes CbcCompare? and CbcChooseVariable? from CbcCompareBase?.hpp to their own .hpp files

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