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

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

Add Astyle formatting options based on ansi (A1), k&r (A3), stroustrup (A4), and banner (A6)

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