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

Last change on this file since 1112 was 1112, checked in by forrest, 11 years ago

fix for local search

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