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

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

chnages to try and make faster

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 81.7 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 deterministic
1201      2 set then use numberThreads for root cuts
1202      4 set then use numberThreads in root mini branch and bound
1203      default is 0
1204  */
1205  inline void setThreadMode(int value) 
1206  { threadMode_=value;}
1207  /** Return
1208      -2 if deterministic threaded and main thread
1209      -1 if deterministic threaded and serial thread
1210      0 if serial
1211      1 if opportunistic threaded
1212  */
1213  inline int parallelMode() const
1214  { if (!numberThreads_) {
1215      if ((threadMode_&1)==0) 
1216        return 0;
1217      else
1218        return -1;
1219      return 0;
1220    } else {
1221      if ((threadMode_&1)==0) 
1222        return 1;
1223      else
1224        return -2;
1225    }
1226  }
1227  /// Get number of "iterations" to stop after
1228  inline int getStopNumberIterations() const
1229  { return stopNumberIterations_;}
1230  /// Set number of "iterations" to stop after
1231  inline void setStopNumberIterations(int value) 
1232  { stopNumberIterations_=value;}
1233  //@}
1234
1235  /** \name Node selection */
1236  //@{
1237  // Comparison functions (which may be overridden by inheritance)
1238  inline CbcCompareBase * nodeComparison() const
1239  { return nodeCompare_;}
1240  void setNodeComparison(CbcCompareBase * compare);
1241  void setNodeComparison(CbcCompareBase & compare);
1242  //@}
1243
1244  /** \name Problem feasibility checking */
1245  //@{
1246  // Feasibility functions (which may be overridden by inheritance)
1247  inline CbcFeasibilityBase * problemFeasibility() const
1248  { return problemFeasibility_;}
1249  void setProblemFeasibility(CbcFeasibilityBase * feasibility);
1250  void setProblemFeasibility(CbcFeasibilityBase & feasibility);
1251  //@}
1252
1253  /** \name Tree methods and subtree methods */
1254  //@{
1255  /// Tree method e.g. heap (which may be overridden by inheritance)
1256  inline CbcTree * tree() const
1257  { return tree_;}
1258  /// For modifying tree handling (original is cloned)
1259  void passInTreeHandler(CbcTree & tree);
1260  /** For passing in an CbcModel to do a sub Tree (with derived tree handlers).
1261      Passed in model must exist for duration of branch and bound
1262  */
1263  void passInSubTreeModel(CbcModel & model);
1264  /** For retrieving a copy of subtree model with given OsiSolver.
1265      If no subtree model will use self (up to user to reset cutoff etc).
1266      If solver NULL uses current
1267  */
1268  CbcModel * subTreeModel(OsiSolverInterface * solver=NULL) const;
1269  /// Returns number of times any subtree stopped on nodes, time etc
1270  inline int numberStoppedSubTrees() const
1271  { return numberStoppedSubTrees_;}
1272  /// Says a sub tree was stopped
1273  inline void incrementSubTreeStopped()
1274  { numberStoppedSubTrees_++;}
1275  /** Whether to automatically do presolve before branch and bound (subTrees).
1276      0 - no
1277      1 - ordinary presolve
1278      2 - integer presolve (dodgy)
1279  */
1280  inline int typePresolve() const
1281  { return presolve_;}
1282  inline void setTypePresolve(int value)
1283  { presolve_=value;}
1284 
1285  //@}
1286
1287  /** \name Branching Decisions
1288 
1289    See the CbcBranchDecision class for additional information.
1290  */
1291  //@{
1292
1293  /// Get the current branching decision method.
1294  inline CbcBranchDecision * branchingMethod() const
1295  { return branchingMethod_;}
1296  /// Set the branching decision method.
1297  inline void setBranchingMethod(CbcBranchDecision * method)
1298  { delete branchingMethod_; branchingMethod_ = method->clone();}
1299  /** Set the branching method
1300 
1301    \overload
1302  */
1303  inline void setBranchingMethod(CbcBranchDecision & method)
1304  { delete branchingMethod_; branchingMethod_ = method.clone();}
1305  /// Get the current cut modifier method
1306  inline CbcCutModifier * cutModifier() const
1307  { return cutModifier_;}
1308  /// Set the cut modifier method
1309  void setCutModifier(CbcCutModifier * modifier);
1310  /** Set the cut modifier method
1311 
1312    \overload
1313  */
1314  void setCutModifier(CbcCutModifier & modifier);
1315  //@}
1316
1317  /** \name Row (constraint) and Column (variable) cut generation */
1318  //@{
1319
1320  /** State of search
1321      0 - no solution
1322      1 - only heuristic solutions
1323      2 - branched to a solution
1324      3 - no solution but many nodes
1325  */
1326  inline int stateOfSearch() const
1327  { return stateOfSearch_;}
1328  inline void setStateOfSearch(int state)
1329  { stateOfSearch_=state;}
1330  /// Strategy worked out - mainly at root node for use by CbcNode
1331  inline int searchStrategy() const
1332  { return searchStrategy_;}
1333  /// Set strategy worked out - mainly at root node for use by CbcNode
1334  inline void setSearchStrategy(int value)
1335  { searchStrategy_ = value; }
1336
1337  /// Get the number of cut generators
1338  inline int numberCutGenerators() const
1339  { return numberCutGenerators_;}
1340  /// Get the list of cut generators
1341  inline CbcCutGenerator ** cutGenerators() const
1342  { return generator_;}
1343  ///Get the specified cut generator
1344  inline CbcCutGenerator * cutGenerator(int i) const
1345  { return generator_[i];}
1346  ///Get the specified cut generator before any changes
1347  inline CbcCutGenerator * virginCutGenerator(int i) const
1348  { return virginGenerator_[i];}
1349  /** Add one generator - up to user to delete generators.
1350      howoften affects how generator is used. 0 or 1 means always,
1351      >1 means every that number of nodes.  Negative values have same
1352      meaning as positive but they may be switched off (-> -100) by code if
1353      not many cuts generated at continuous.  -99 is just done at root.
1354      Name is just for printout.
1355      If depth >0 overrides how often generator is called (if howOften==-1 or >0).
1356  */
1357  void addCutGenerator(CglCutGenerator * generator,
1358                       int howOften=1, const char * name=NULL,
1359                       bool normal=true, bool atSolution=false, 
1360                       bool infeasible=false,int howOftenInSub=-100,
1361                       int whatDepth=-1, int whatDepthInSub=-1);
1362//@}
1363  /** \name Strategy and sub models
1364 
1365    See the CbcStrategy class for additional information.
1366  */
1367  //@{
1368
1369  /// Get the current strategy
1370  inline CbcStrategy * strategy() const
1371  { return strategy_;}
1372  /// Set the strategy. Clones
1373  void setStrategy(CbcStrategy & strategy);
1374  /// Get the current parent model
1375  inline CbcModel * parentModel() const
1376  { return parentModel_;}
1377  /// Set the parent model
1378  inline void setParentModel(CbcModel & parentModel)
1379  { parentModel_ = &parentModel;}
1380  //@}
1381
1382
1383  /** \name Heuristics and priorities */
1384  //@{
1385  /*! \brief Add one heuristic - up to user to delete
1386
1387    The name is just used for print messages.
1388  */
1389  void addHeuristic(CbcHeuristic * generator, const char *name = NULL,
1390                    int before=-1);
1391  ///Get the specified heuristic
1392  inline CbcHeuristic * heuristic(int i) const
1393  { return heuristic_[i];}
1394  /// Get the number of heuristics
1395  inline int numberHeuristics() const
1396  { return numberHeuristics_;}
1397  /// Pointer to heuristic solver which found last solution (or NULL)
1398  inline CbcHeuristic * lastHeuristic() const
1399  { return lastHeuristic_;}
1400  /// set last heuristic which found a solution
1401  inline void setLastHeuristic(CbcHeuristic * last)
1402  { lastHeuristic_=last;}
1403
1404  /** Pass in branching priorities.
1405 
1406      If ifClique then priorities are on cliques otherwise priorities are
1407      on integer variables. 
1408      Other type (if exists set to default)
1409      1 is highest priority. (well actually -INT_MAX is but that's ugly)
1410      If hotstart > 0 then branches are created to force
1411      the variable to the value given by best solution.  This enables a
1412      sort of hot start.  The node choice should be greatest depth
1413      and hotstart should normally be switched off after a solution.
1414
1415      If ifNotSimpleIntegers true then appended to normal integers
1416
1417      This is now deprecated except for simple usage.  If user
1418      creates Cbcobjects then set priority in them
1419
1420      \internal Added for Kurt Spielberg.
1421  */
1422  void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
1423
1424  /// Returns priority level for an object (or 1000 if no priorities exist)
1425  inline int priority(int sequence) const
1426  { return object_[sequence]->priority();}
1427
1428  /*! \brief Set an event handler
1429 
1430    A clone of the handler passed as a parameter is stored in CbcModel.
1431  */
1432  void passInEventHandler(const CbcEventHandler *eventHandler) ;
1433
1434  /*! \brief Retrieve a pointer to the event handler */
1435  inline CbcEventHandler* getEventHandler() const
1436  { return (eventHandler_) ; } 
1437
1438  //@}
1439   
1440  /**@name Setting/Accessing application data */
1441  //@{
1442    /** Set application data.
1443
1444        This is a pointer that the application can store into and
1445        retrieve from the solver interface.
1446        This field is available for the application to optionally
1447        define and use.
1448    */
1449    void setApplicationData (void * appData);
1450
1451    /// Get application data
1452    void * getApplicationData() const;
1453  /**
1454      For advanced applications you may wish to modify the behavior of Cbc
1455      e.g. if the solver is a NLP solver then you may not have an exact
1456      optimum solution at each step.  Information could be built into
1457      OsiSolverInterface but this is an alternative so that that interface
1458      does not have to be changed.  If something similar is useful to
1459      enough solvers then it could be migrated
1460      You can also pass in by using solver->setAuxiliaryInfo.
1461      You should do that if solver is odd - if solver is normal simplex
1462      then use this.
1463      NOTE - characteristics are not cloned
1464  */
1465  void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics);
1466  /// Get solver characteristics
1467  inline const OsiBabSolver * solverCharacteristics() const
1468  { return solverCharacteristics_;}
1469  //@}
1470 
1471  //---------------------------------------------------------------------------
1472
1473  /**@name Message handling */
1474  //@{
1475  /// Pass in Message handler (not deleted at end)
1476  void passInMessageHandler(CoinMessageHandler * handler);
1477  /// Set language
1478  void newLanguage(CoinMessages::Language language);
1479  inline void setLanguage(CoinMessages::Language language)
1480  {newLanguage(language);}
1481  /// Return handler
1482  inline CoinMessageHandler * messageHandler() const
1483  {return handler_;}
1484  /// Return messages
1485  inline CoinMessages & messages() 
1486  {return messages_;}
1487  /// Return pointer to messages
1488  inline CoinMessages * messagesPointer() 
1489  {return &messages_;}
1490  /// Set log level
1491  void setLogLevel(int value);
1492  /// Get log level
1493  inline int logLevel() const
1494  { return handler_->logLevel();}
1495  //@}
1496  //---------------------------------------------------------------------------
1497  ///@name Specialized
1498  //@{
1499
1500  /**
1501      Set special options
1502      0 bit (1) - check if cuts valid (if on debugger list)
1503      1 bit (2) - use current basis to check integer solution (rather than all slack)
1504      2 bit (4) - don't check integer solution (by solving LP)
1505      3 bit (8) - fast analyze
1506      4 bit (16) - non-linear model - so no well defined CoinPackedMatrix
1507      5 bit (32) - keep names
1508      6 bit (64) - try for dominated columns
1509      7 bit (128) - SOS type 1 but all declared integer
1510      8 bit (256) - Set to say solution just found, unset by doing cuts
1511      9 bit (512) - Try reduced model after 100 nodes
1512      10 bit (1024) - Switch on some heuristics even if seems unlikely
1513      11 bit (2048) - Mark as in small branch and bound
1514      12 bit (4096) - Funny cuts so do slow way (in some places)
1515      13 bit (8192) - Funny cuts so do slow way (in other places)
1516      14 bit (16384) - Use Cplex! for fathoming
1517      15 bit (32768) - Try reduced model after 0 nodes
1518  */
1519  /// Set special options
1520  inline void setSpecialOptions(int value)
1521  { specialOptions_=value;}
1522  /// Get special options
1523  inline int specialOptions() const
1524  { return specialOptions_;}
1525  /// Says if normal solver i.e. has well defined CoinPackedMatrix
1526  inline bool normalSolver() const
1527  { return (specialOptions_&16)==0;}
1528  /// Now we may not own objects - just point to solver's objects
1529  inline bool ownObjects() const
1530  { return ownObjects_;}
1531  /// Pointer to a mutex
1532  inline void * mutex()
1533  { return mutex_;}
1534  /// Split up nodes
1535  int splitModel(int numberModels, CbcModel ** model,
1536                  int numberNodes);
1537  /// Start threads
1538  void startSplitModel(int numberIterations);
1539  /// Merge models
1540  void mergeModels(int numberModel, CbcModel ** model,
1541                   int numberNodes);
1542  //@}
1543  //---------------------------------------------------------------------------
1544
1545  ///@name Constructors and destructors etc
1546  //@{
1547    /// Default Constructor
1548    CbcModel(); 
1549   
1550    /// Constructor from solver
1551    CbcModel(const OsiSolverInterface &);
1552 
1553    /** Assign a solver to the model (model assumes ownership)
1554
1555      On return, \p solver will be NULL.
1556      If deleteSolver then current solver deleted (if model owned)
1557
1558      \note Parameter settings in the outgoing solver are not inherited by
1559            the incoming solver.
1560    */
1561    void assignSolver(OsiSolverInterface *&solver,bool deleteSolver=true);
1562
1563    /** \brief Set ownership of solver
1564
1565      A parameter of false tells CbcModel it does not own the solver and
1566      should not delete it. Once you claim ownership of the solver, you're
1567      responsible for eventually deleting it. Note that CbcModel clones
1568      solvers with abandon.  Unless you have a deep understanding of the
1569      workings of CbcModel, the only time you want to claim ownership is when
1570      you're about to delete the CbcModel object but want the solver to
1571      continue to exist (as, for example, when branchAndBound has finished
1572      and you want to hang on to the answer).
1573    */
1574    inline void setModelOwnsSolver (bool ourSolver)
1575  { ownership_ = ourSolver ? (ownership_ |0x80000000) : (ownership_ & (~0x80000000)) ; } 
1576
1577    /*! \brief Get ownership of solver
1578   
1579      A return value of true means that CbcModel owns the solver and will
1580      take responsibility for deleting it when that becomes necessary.
1581    */
1582  inline bool modelOwnsSolver () { return ((ownership_&0x80000000)!=0) ; } 
1583 
1584    /** Copy constructor .
1585      If cloneHandler is true then message handler is cloned
1586    */ 
1587    CbcModel(const CbcModel & rhs, bool cloneHandler=false);
1588 
1589    /// Assignment operator
1590    CbcModel & operator=(const CbcModel& rhs);
1591 
1592    /// Destructor
1593     ~CbcModel ();
1594
1595    /// Returns solver - has current state
1596    inline OsiSolverInterface * solver() const
1597    { return solver_;}
1598
1599    /// Returns current solver - sets new one
1600    inline OsiSolverInterface * swapSolver(OsiSolverInterface * solver) 
1601    { OsiSolverInterface * returnSolver = solver_; solver_ = solver; return returnSolver;}
1602
1603    /// Returns solver with continuous state
1604    inline OsiSolverInterface * continuousSolver() const
1605    { return continuousSolver_;}
1606
1607    /// Create solver with continuous state
1608    inline void createContinuousSolver()
1609    { continuousSolver_ = solver_->clone();}
1610    /// Clear solver with continuous state
1611    inline void clearContinuousSolver()
1612    { delete continuousSolver_; continuousSolver_ = NULL;}
1613
1614  /// A copy of the solver, taken at constructor or by saveReferenceSolver
1615  inline OsiSolverInterface * referenceSolver() const
1616  { return referenceSolver_;}
1617
1618  /// Save a copy of the current solver so can be reset to
1619  void saveReferenceSolver();
1620
1621  /** Uses a copy of reference solver to be current solver.
1622      Because of possible mismatches all exotic integer information is loat
1623      (apart from normal information in OsiSolverInterface)
1624      so SOS etc and priorities will have to be redone
1625  */
1626  void resetToReferenceSolver();
1627
1628  /// Clears out as much as possible (except solver)
1629  void gutsOfDestructor();
1630  /** Clears out enough to reset CbcModel as if no branch and bound done
1631   */
1632  void gutsOfDestructor2();
1633  /** Clears out enough to reset CbcModel cutoff etc
1634   */
1635  void resetModel();
1636  /** Most of copy constructor
1637      mode - 0 copy but don't delete before
1638             1 copy and delete before
1639             2 copy and delete before (but use virgin generators)
1640  */
1641  void gutsOfCopy(const CbcModel & rhs,int mode=0);
1642  /// Move status, nodes etc etc across
1643  void moveInfo(const CbcModel & rhs);
1644  //@}
1645
1646  ///@semi-private i.e. users should not use
1647  //@{
1648    /// Get how many Nodes it took to solve the problem.
1649    int getNodeCount2() const
1650    { return numberNodes2_;}
1651  /// Set pointers for speed
1652  void setPointers(const OsiSolverInterface * solver);
1653  /** Perform reduced cost fixing
1654
1655    Fixes integer variables at their current value based on reduced cost
1656    penalties.  Returns number fixed
1657  */
1658  int reducedCostFix() ;
1659  /** Makes all handlers same.  If makeDefault 1 then makes top level
1660      default and rest point to that.  If 2 then each is copy
1661  */
1662  void synchronizeHandlers(int makeDefault);
1663     
1664  /// Encapsulates solver resolve
1665  int resolve(OsiSolverInterface * solver);
1666
1667  /** Encapsulates choosing a variable -
1668      anyAction -2, infeasible (-1 round again), 0 done
1669  */
1670  int chooseBranch(CbcNode * & newNode, int numberPassesLeft,
1671                   CbcNode * oldNode, OsiCuts & cuts,
1672                   bool & resolved, CoinWarmStartBasis *lastws,
1673                   const double * lowerBefore,const double * upperBefore,
1674                   OsiSolverBranch * & branches);
1675  int chooseBranch(CbcNode * newNode, int numberPassesLeft, bool & resolved);
1676
1677  /** Return an empty basis object of the specified size
1678
1679    A useful utility when constructing a basis for a subproblem from scratch.
1680    The object returned will be of the requested capacity and appropriate for
1681    the solver attached to the model.
1682  */
1683  CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
1684
1685  /** Remove inactive cuts from the model
1686
1687    An OsiSolverInterface is expected to maintain a valid basis, but not a
1688    valid solution, when loose cuts are deleted. Restoring a valid solution
1689    requires calling the solver to reoptimise. If it's certain the solution
1690    will not be required, set allowResolve to false to suppress
1691    reoptimisation.
1692    If saveCuts then slack cuts will be saved
1693    On input current cuts are cuts and newCuts
1694    on exit current cuts will be correct.  Returns number dropped
1695  */
1696  int takeOffCuts(OsiCuts &cuts, 
1697                   bool allowResolve,OsiCuts * saveCuts,
1698                   int numberNewCuts=0, const OsiRowCut ** newCuts=NULL) ;
1699
1700  /** Determine and install the active cuts that need to be added for
1701    the current subproblem
1702
1703    The whole truth is a bit more complicated. The first action is a call to
1704    addCuts1(). addCuts() then sorts through the list, installs the tight
1705    cuts in the model, and does bookkeeping (adjusts reference counts).
1706    The basis returned from addCuts1() is adjusted accordingly.
1707   
1708    If it turns out that the node should really be fathomed by bound,
1709    addCuts() simply treats all the cuts as loose as it does the bookkeeping.
1710
1711    canFix true if extra information being passed
1712  */
1713  int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws,bool canFix);
1714
1715  /** Traverse the tree from node to root and prep the model
1716
1717    addCuts1() begins the job of prepping the model to match the current
1718    subproblem. The model is stripped of all cuts, and the search tree is
1719    traversed from node to root to determine the changes required. Appropriate
1720    bounds changes are installed, a list of cuts is collected but not
1721    installed, and an appropriate basis (minus the cuts, but big enough to
1722    accommodate them) is constructed.
1723
1724    Returns true if new problem similar to old
1725
1726    \todo addCuts1() is called in contexts where it's known in advance that
1727          all that's desired is to determine a list of cuts and do the
1728          bookkeeping (adjust the reference counts). The work of installing
1729          bounds and building a basis goes to waste.
1730  */
1731  bool addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
1732  /** Returns bounds just before where - initially original bounds.
1733      Also sets downstream nodes (lower if force 1, upper if 2)
1734  */
1735  void previousBounds (CbcNode * node, CbcNodeInfo * where,int iColumn,
1736                       double & lower, double & upper,int force);
1737  /** Set objective value in a node.  This is separated out so that
1738     odd solvers can use.  It may look at extra information in
1739     solverCharacteriscs_ and will also use bound from parent node
1740  */
1741  void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
1742
1743  /** If numberBeforeTrust >0 then we are going to use CbcBranchDynamic.
1744      Scan and convert CbcSimpleInteger objects
1745  */
1746  void convertToDynamic();
1747  /// Set numberBeforeTrust in all objects
1748  void synchronizeNumberBeforeTrust(int type=0);
1749  /// Zap integer information in problem (may leave object info)
1750  void zapIntegerInformation(bool leaveObjects=true);
1751  /// Use cliques for pseudocost information - return nonzero if infeasible
1752  int cliquePseudoCosts(int doStatistics);
1753  /// Fill in useful estimates
1754  void pseudoShadow(double * down, double * up);
1755  /** Return pseudo costs
1756      If not all integers or not pseudo costs - returns all zero
1757      Length of arrays are numberIntegers() and entries
1758      correspond to integerVariable()[i]
1759      User must allocate arrays before call
1760  */
1761  void fillPseudoCosts(double * downCosts, double * upCosts,
1762                       int * numberDown=NULL, int * numberUp=NULL,
1763                       int * numberDownInfeasible=NULL,
1764                       int * numberUpInfeasible=NULL) const;
1765  /** Do heuristics at root.
1766      0 - don't delete
1767      1 - delete
1768      2 - just delete - don't even use
1769  */
1770  void doHeuristicsAtRoot(int deleteHeuristicsAfterwards=0);
1771  /// Adjust heuristics based on model
1772  void adjustHeuristics();
1773  /// Get the hotstart solution
1774  inline const double * hotstartSolution() const
1775  { return hotstartSolution_;}
1776  /// Get the hotstart priorities
1777  inline const int * hotstartPriorities() const
1778  { return hotstartPriorities_;}
1779
1780  /// Return the list of cuts initially collected for this subproblem
1781  inline CbcCountRowCut ** addedCuts() const
1782  { return addedCuts_;}
1783  /// Number of entries in the list returned by #addedCuts()
1784  inline int currentNumberCuts() const
1785  { return currentNumberCuts_;}
1786  /// Global cuts
1787  inline OsiCuts * globalCuts() 
1788  { return &globalCuts_;}
1789  /// Copy and set a pointer to a row cut which will be added instead of normal branching.
1790  void setNextRowCut(const OsiRowCut & cut);
1791  /// Get a pointer to current node (be careful)
1792  inline CbcNode * currentNode() const
1793  { return currentNode_;}
1794  /// Get a pointer to probing info
1795  inline CglTreeProbingInfo * probingInfo() const
1796  { return probingInfo_;}
1797  /// Thread specific random number generator
1798  inline CoinThreadRandom * randomNumberGenerator()
1799  { return &randomNumberGenerator_;}
1800  /// Set the number of iterations done in strong branching.
1801  inline void setNumberStrongIterations(int number)
1802  { numberStrongIterations_ = number;}
1803  /// Get the number of iterations done in strong branching.
1804  inline int numberStrongIterations() const
1805  { return numberStrongIterations_;}
1806  /// Get maximum number of iterations (designed to be used in heuristics)
1807  inline int maximumNumberIterations() const
1808  { return maximumNumberIterations_;}
1809  /// Set maximum number of iterations (designed to be used in heuristics)
1810  inline void setMaximumNumberIterations(int value)
1811  { maximumNumberIterations_ = value;}
1812# ifdef COIN_HAS_CLP
1813  /// Set depth for fast nodes
1814  inline void setFastNodeDepth(int value) 
1815  { fastNodeDepth_ = value;}
1816  /// Get depth for fast nodes
1817  inline int fastNodeDepth() const
1818  { return fastNodeDepth_;}
1819  inline void incrementExtra(int nodes, int iterations)
1820  { numberExtraNodes_ += nodes; numberExtraIterations_ += iterations;}
1821#endif
1822  /// Number of extra iterations
1823  inline int numberExtraIterations() const
1824  { return numberExtraIterations_;}
1825  /// Increment strong info
1826  void incrementStrongInfo(int numberTimes, int numberIterations,
1827                           int numberFixed, bool ifInfeasible);
1828  /// Return strong info
1829  inline const int * strongInfo() const
1830  { return strongInfo_;}
1831
1832  /// Return mutable strong info
1833  inline int * mutableStrongInfo()
1834  { return strongInfo_;}
1835
1836  /// Says whether all dynamic integers
1837  inline bool allDynamic () const { return ((ownership_&0x40000000)!=0) ; } 
1838  /// Create C++ lines to get to current state
1839  void generateCpp( FILE * fp,int options);
1840  /// Generate an OsiBranchingInformation object
1841  OsiBranchingInformation usefulInformation() const;
1842  /** Warm start object produced by heuristic or strong branching
1843
1844      If get a valid integer solution outside branch and bound then it can take
1845      a reasonable time to solve LP which produces clean solution.  If this object has
1846      any size then it will be used in solve.
1847  */
1848  inline void setBestSolutionBasis(const CoinWarmStartBasis & bestSolutionBasis)
1849  { bestSolutionBasis_ = bestSolutionBasis;}
1850  /// Redo walkback arrays
1851  void redoWalkBack();
1852  //@}
1853
1854//---------------------------------------------------------------------------
1855
1856private:
1857  ///@name Private member data
1858  //@{
1859
1860  /// The solver associated with this model.
1861  OsiSolverInterface * solver_;
1862
1863  /** Ownership of objects and other stuff
1864
1865      0x80000000 model owns solver
1866      0x40000000 all variables CbcDynamicPseudoCost
1867  */
1868  unsigned int ownership_ ;
1869
1870  /// A copy of the solver, taken at the continuous (root) node.
1871  OsiSolverInterface * continuousSolver_;
1872
1873  /// A copy of the solver, taken at constructor or by saveReferenceSolver
1874  OsiSolverInterface * referenceSolver_;
1875
1876   /// Message handler
1877  CoinMessageHandler * handler_;
1878
1879  /** Flag to say if handler_ is the default handler.
1880 
1881    The default handler is deleted when the model is deleted. Other
1882    handlers (supplied by the client) will not be deleted.
1883  */
1884  bool defaultHandler_;
1885
1886  /// Cbc messages
1887  CoinMessages messages_;
1888
1889  /// Array for integer parameters
1890  int intParam_[CbcLastIntParam];
1891
1892  /// Array for double parameters
1893  double dblParam_[CbcLastDblParam];
1894
1895  /** Pointer to an empty warm start object
1896
1897    It turns out to be useful to have this available as a base from
1898    which to build custom warm start objects. This is typed as CoinWarmStart
1899    rather than CoinWarmStartBasis to allow for the possibility that a
1900    client might want to apply a solver that doesn't use a basis-based warm
1901    start. See getEmptyBasis for an example of how this field can be used.
1902  */
1903  mutable CoinWarmStart *emptyWarmStart_ ;
1904
1905  /// Best objective
1906  double bestObjective_;
1907  /// Best possible objective
1908  double bestPossibleObjective_;
1909  /// Sum of Changes to objective by first solve
1910  double sumChangeObjective1_;
1911  /// Sum of Changes to objective by subsequent solves
1912  double sumChangeObjective2_;
1913
1914  /// Array holding the incumbent (best) solution.
1915  double * bestSolution_;
1916
1917  /** Array holding the current solution.
1918
1919    This array is used more as a temporary.
1920  */
1921  double * currentSolution_;
1922  /** For testing infeasibilities - will point to
1923      currentSolution_ or solver-->getColSolution()
1924  */
1925  mutable const double * testSolution_;
1926  /** Warm start object produced by heuristic or strong branching
1927
1928      If get a valid integer solution outside branch and bound then it can take
1929      a reasonable time to solve LP which produces clean solution.  If this object has
1930      any size then it will be used in solve.
1931  */
1932  CoinWarmStartBasis bestSolutionBasis_ ;
1933  /// Global cuts
1934  OsiCuts globalCuts_;
1935
1936  /// Minimum degradation in objective value to continue cut generation
1937  double minimumDrop_;
1938  /// Number of solutions
1939  int numberSolutions_;
1940  /** State of search
1941      0 - no solution
1942      1 - only heuristic solutions
1943      2 - branched to a solution
1944      3 - no solution but many nodes
1945  */
1946  int stateOfSearch_;
1947  /// At which depths to do cuts
1948  int whenCuts_;
1949  /// Hotstart solution
1950  double * hotstartSolution_;
1951  /// Hotstart priorities
1952  int * hotstartPriorities_;
1953  /// Number of heuristic solutions
1954  int numberHeuristicSolutions_;
1955  /// Cumulative number of nodes
1956  int numberNodes_;
1957  /** Cumulative number of nodes for statistics.
1958      Must fix to match up
1959  */
1960  int numberNodes2_;
1961  /// Cumulative number of iterations
1962  int numberIterations_;
1963  /// Cumulative number of solves
1964  int numberSolves_;
1965  /// Status of problem - 0 finished, 1 stopped, 2 difficulties
1966  int status_;
1967  /** Secondary status of problem
1968      -1 unset (status_ will also be -1)
1969      0 search completed with solution
1970      1 linear relaxation not feasible (or worse than cutoff)
1971      2 stopped on gap
1972      3 stopped on nodes
1973      4 stopped on time
1974      5 stopped on user event
1975      6 stopped on solutions
1976   */
1977  int secondaryStatus_;
1978  /// Number of integers in problem
1979  int numberIntegers_;
1980  /// Number of rows at continuous
1981  int numberRowsAtContinuous_;
1982  /// Maximum number of cuts
1983  int maximumNumberCuts_;
1984  /** Current phase (so heuristics etc etc can find out).
1985      0 - initial solve
1986      1 - solve with cuts at root
1987      2 - solve with cuts
1988      3 - other e.g. strong branching
1989      4 - trying to validate a solution
1990      5 - at end of search
1991  */
1992  int phase_;
1993
1994  /// Number of entries in #addedCuts_
1995  int currentNumberCuts_;
1996
1997  /** Current limit on search tree depth
1998
1999    The allocated size of #walkback_. Increased as needed.
2000  */
2001  int maximumDepth_;
2002  /** Array used to assemble the path between a node and the search tree root
2003
2004    The array is resized when necessary. #maximumDepth_  is the current
2005    allocated size.
2006  */
2007  CbcNodeInfo ** walkback_;
2008#define NODE_LAST
2009#ifdef NODE_LAST
2010  CbcNodeInfo ** lastNodeInfo_;
2011  const OsiRowCut ** lastCut_;
2012  int lastDepth_;
2013  int lastNumberCuts2_;
2014  int maximumCuts_;
2015  int * lastNumberCuts_;
2016#endif
2017
2018  /** The list of cuts initially collected for this subproblem
2019
2020    When the subproblem at this node is rebuilt, a set of cuts is collected
2021    for inclusion in the constraint system. If any of these cuts are
2022    subsequently removed because they have become loose, the corresponding
2023    entry is set to NULL.
2024  */
2025  CbcCountRowCut ** addedCuts_;
2026
2027  /** A pointer to a row cut which will be added instead of normal branching.
2028      After use it should be set to NULL.
2029  */
2030  OsiRowCut * nextRowCut_;
2031
2032  /// Current node so can be used elsewhere
2033  CbcNode * currentNode_;
2034
2035  /// Indices of integer variables
2036  int * integerVariable_;
2037  /// Whether of not integer
2038  char * integerInfo_;
2039  /// Holds solution at continuous (after cuts)
2040  double * continuousSolution_;
2041  /// Array marked whenever a solution is found if non-zero
2042  int * usedInSolution_;
2043  /**
2044      0 bit (1) - check if cuts valid (if on debugger list)
2045      1 bit (2) - use current basis to check integer solution (rather than all slack)
2046      2 bit (4) - don't check integer solution
2047      3 bit (8) - Strong is doing well - keep on
2048  */
2049  int specialOptions_;
2050  /// User node comparison function
2051  CbcCompareBase * nodeCompare_;
2052  /// User feasibility function (see CbcFeasibleBase.hpp)
2053  CbcFeasibilityBase * problemFeasibility_;
2054  /// Tree
2055  CbcTree * tree_;
2056  /// A pointer to model to be used for subtrees
2057  CbcModel * subTreeModel_;
2058  /// Number of times any subtree stopped on nodes, time etc
2059  int numberStoppedSubTrees_;
2060  /// Variable selection function
2061  CbcBranchDecision * branchingMethod_;
2062  /// Cut modifier function
2063  CbcCutModifier * cutModifier_;
2064  /// Strategy
2065  CbcStrategy * strategy_;
2066  /// Parent model
2067  CbcModel * parentModel_;
2068  /** Whether to automatically do presolve before branch and bound.
2069      0 - no
2070      1 - ordinary presolve
2071      2 - integer presolve (dodgy)
2072  */
2073  /// Pointer to array[getNumCols()] (for speed) of column lower bounds
2074  const double * cbcColLower_;
2075  /// Pointer to array[getNumCols()] (for speed) of column upper bounds
2076  const double * cbcColUpper_;
2077  /// Pointer to array[getNumRows()] (for speed) of row lower bounds
2078  const double * cbcRowLower_;
2079  /// Pointer to array[getNumRows()] (for speed) of row upper bounds
2080  const double * cbcRowUpper_;
2081  /// Pointer to array[getNumCols()] (for speed) of primal solution vector
2082  const double * cbcColSolution_;
2083  /// Pointer to array[getNumRows()] (for speed) of dual prices
2084  const double * cbcRowPrice_;
2085  /// Get a pointer to array[getNumCols()] (for speed) of reduced costs
2086  const double * cbcReducedCost_;
2087  /// Pointer to array[getNumRows()] (for speed) of row activity levels.
2088  const double * cbcRowActivity_;
2089  /// Pointer to user-defined data structure
2090  void * appData_;
2091  /// Pointer to a mutex
2092  void * mutex_;
2093  /// Presolve for CbcTreeLocal
2094  int presolve_;
2095  /** Maximum number of candidates to consider for strong branching.
2096    To disable strong branching, set this to 0.
2097  */
2098  int numberStrong_;
2099  /** \brief The number of branches before pseudo costs believed
2100             in dynamic strong branching.
2101     
2102    A value of 0 is  off.
2103  */
2104  int numberBeforeTrust_;
2105  /** \brief The number of variables for which to compute penalties
2106             in dynamic strong branching.
2107  */
2108  int numberPenalties_;
2109  /// For threads - stop after this many "iterations"
2110  int stopNumberIterations_;
2111  /** Scale factor to make penalties match strong.
2112      Should/will be computed */
2113  double penaltyScaleFactor_;
2114  /// Number of analyze iterations to do
2115  int numberAnalyzeIterations_;
2116  /// Arrays with analysis results
2117  double * analyzeResults_;
2118  /// Number of nodes infeasible by normal branching (before cuts)
2119  int numberInfeasibleNodes_;
2120  /** Problem type as set by user or found by analysis.  This will be extended
2121      0 - not known
2122      1 - Set partitioning <=
2123      2 - Set partitioning ==
2124      3 - Set covering
2125  */
2126  int problemType_;
2127  /// Print frequency
2128  int printFrequency_;
2129  /// Number of cut generators
2130  int numberCutGenerators_;
2131  // Cut generators
2132  CbcCutGenerator ** generator_;
2133  // Cut generators before any changes
2134  CbcCutGenerator ** virginGenerator_;
2135  /// Number of heuristics
2136  int numberHeuristics_;
2137  /// Heuristic solvers
2138  CbcHeuristic ** heuristic_;
2139  /// Pointer to heuristic solver which found last solution (or NULL)
2140  CbcHeuristic * lastHeuristic_;
2141# ifdef COIN_HAS_CLP
2142  /// Depth for fast nodes
2143  int fastNodeDepth_;
2144#endif
2145  /*! Pointer to the event handler */
2146# ifdef CBC_ONLY_CLP
2147  ClpEventHandler *eventHandler_ ;
2148# else
2149  CbcEventHandler *eventHandler_ ;
2150# endif
2151
2152  /// Total number of objects
2153  int numberObjects_;
2154
2155  /** \brief Integer and Clique and ... information
2156
2157    \note The code assumes that the first objects on the list will be
2158          SimpleInteger objects for each integer variable, followed by
2159          Clique objects. Portions of the code that understand Clique objects
2160          will fail if they do not immediately follow the SimpleIntegers.
2161          Large chunks of the code will fail if the first objects are not
2162          SimpleInteger. As of 2003.08, SimpleIntegers and Cliques are the only
2163          objects.
2164  */
2165  OsiObject ** object_;
2166  /// Now we may not own objects - just point to solver's objects
2167  bool ownObjects_;
2168 
2169  /// Original columns as created by integerPresolve or preprocessing
2170  int * originalColumns_;
2171  /// How often to scan global cuts
2172  int howOftenGlobalScan_;
2173  /** Number of times global cuts violated.  When global cut pool then this
2174      should be kept for each cut and type of cut */
2175  int numberGlobalViolations_;
2176  /// Number of extra iterations in fast lp
2177  int numberExtraIterations_;
2178  /// Number of extra nodes in fast lp
2179  int numberExtraNodes_;
2180  /** Value of objective at continuous
2181      (Well actually after initial round of cuts)
2182  */
2183  double continuousObjective_;
2184  /** Value of objective before root node cuts added
2185  */
2186  double originalContinuousObjective_;
2187  /// Number of infeasibilities at continuous
2188  int continuousInfeasibilities_;
2189  /// Maximum number of cut passes at root
2190  int maximumCutPassesAtRoot_;
2191  /// Maximum number of cut passes
2192  int maximumCutPasses_;
2193  /// Preferred way of branching
2194  int preferredWay_;
2195  /// Current cut pass number
2196  int currentPassNumber_;
2197  /// Maximum number of cuts (for whichGenerator_)
2198  int maximumWhich_;
2199  /// Maximum number of rows
2200  int maximumRows_;
2201  /// Current depth
2202  int currentDepth_;
2203  /// Thread specific random number generator
2204  mutable CoinThreadRandom randomNumberGenerator_;
2205  /// Work basis for temporary use
2206  CoinWarmStartBasis workingBasis_;
2207  /// Which cut generator generated this cut
2208  int * whichGenerator_;
2209  /// Maximum number of statistics
2210  int maximumStatistics_;
2211  /// statistics
2212  CbcStatistics ** statistics_;
2213  /// Maximum depth reached
2214  int maximumDepthActual_;
2215  /// Number of reduced cost fixings
2216  double numberDJFixed_;
2217  /// Probing info
2218  CglTreeProbingInfo * probingInfo_;
2219  /// Number of fixed by analyze at root
2220  int numberFixedAtRoot_;
2221  /// Number fixed by analyze so far
2222  int numberFixedNow_;
2223  /// Whether stopping on gap
2224  bool stoppedOnGap_;
2225  /// Whether event happened
2226  bool eventHappened_;
2227  /// Number of long strong goes
2228  int numberLongStrong_;
2229  /// Number of old active cuts
2230  int numberOldActiveCuts_;
2231  /// Number of new cuts
2232  int numberNewCuts_;
2233  /// Size of mini - tree
2234  int sizeMiniTree_;
2235  /// Strategy worked out - mainly at root node
2236  int searchStrategy_;
2237  /// Number of iterations in strong branching
2238  int numberStrongIterations_;
2239  /** 0 - number times strong branching done, 1 - number fixed, 2 - number infeasible
2240      Second group of three is a snapshot at node [6] */
2241  int strongInfo_[7];
2242  /**
2243      For advanced applications you may wish to modify the behavior of Cbc
2244      e.g. if the solver is a NLP solver then you may not have an exact
2245      optimum solution at each step.  This gives characteristics - just for one BAB.
2246      For actually saving/restoring a solution you need the actual solver one.
2247  */
2248  OsiBabSolver * solverCharacteristics_;
2249  /// Whether to force a resolve after takeOffCuts
2250  bool resolveAfterTakeOffCuts_;
2251  /// Maximum number of iterations (designed to be used in heuristics)
2252  int maximumNumberIterations_;
2253#if NEW_UPDATE_OBJECT>1
2254  /// Number of outstanding update information items
2255  int numberUpdateItems_;
2256  /// Maximum number of outstanding update information items
2257  int maximumNumberUpdateItems_;
2258  /// Update items
2259  CbcObjectUpdateData * updateItems_;
2260#endif
2261  /**
2262     Parallel
2263     0 - off
2264     1 - testing
2265     2-99 threads
2266     other special meanings
2267  */
2268  int numberThreads_;
2269  /** thread mode
2270      always use numberThreads for branching
2271      1 set then deterministic
2272      2 set then use numberThreads for root cuts
2273      4 set then use numberThreads in root mini branch and bound
2274      default is 0
2275  */
2276  int threadMode_;
2277 //@}
2278};
2279/// So we can use osiObject or CbcObject during transition
2280void getIntegerInformation(const OsiObject * object, double & originalLower,
2281                           double & originalUpper) ;
2282// So we can call from other programs
2283// Real main program
2284class OsiClpSolverInterface;
2285int CbcMain (int argc, const char *argv[],OsiClpSolverInterface & solver,CbcModel ** babSolver);
2286int CbcMain (int argc, const char *argv[],CbcModel & babSolver);
2287// four ways of calling
2288int callCbc(const char * input2, OsiClpSolverInterface& solver1); 
2289int callCbc(const char * input2);
2290int callCbc(const std::string input2, OsiClpSolverInterface& solver1); 
2291int callCbc(const std::string input2) ;
2292// When we want to load up CbcModel with options first
2293void CbcMain0 (CbcModel & babSolver);
2294int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver);
2295// two ways of calling
2296int callCbc(const char * input2, CbcModel & babSolver); 
2297int callCbc(const std::string input2, CbcModel & babSolver); 
2298// And when CbcMain0 already called to initialize
2299int callCbc1(const char * input2, CbcModel & babSolver); 
2300int callCbc1(const std::string input2, CbcModel & babSolver); 
2301// And when CbcMain0 already called to initialize (with call back) (see CbcMain1 for whereFrom)
2302int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom)); 
2303int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom)); 
2304int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom));
2305// For uniform setting of cut and heuristic options
2306void setCutAndHeuristicOptions(CbcModel & model);
2307#endif
Note: See TracBrowser for help on using the repository browser.