source: stable/2.4/Cbc/src/CbcModel.hpp @ 1271

Last change on this file since 1271 was 1271, checked in by forrest, 10 years ago

Creating new stable branch 2.4 from trunk (rev 1270)

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