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

Last change on this file since 2365 was 2365, checked in by forrest, 3 years ago

fix memory leaks with sos and improve checkSolution

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