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

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

changes for heuristic clone

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