source: trunk/Cbc/src/CbcModel.hpp @ 2076

Last change on this file since 2076 was 2048, checked in by forrest, 5 years ago

First try at orbital branching

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