source: trunk/include/CbcModel.hpp @ 271

Last change on this file since 271 was 271, checked in by forrest, 14 years ago

for Pierre (and to annoy Lou:-)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 63.2 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 "OsiCuts.hpp"
11#include "CoinWarmStartBasis.hpp"
12#include "CbcCompareBase.hpp"
13#include "CbcMessage.hpp"
14#ifdef COIN_USE_CLP
15#include "ClpEventHandler.hpp"
16#endif
17
18//class OsiSolverInterface;
19
20class CbcCutGenerator;
21class OsiRowCut;
22class OsiBabSolver;
23class OsiRowCutDebugger;
24class CglCutGenerator;
25class CbcHeuristic;
26class CbcObject;
27class CbcTree;
28class CbcStrategy;
29class CbcFeasibilityBase;
30class CbcStatistics;
31
32//#############################################################################
33
34/** Simple Branch and bound class
35
36  The initialSolve() method solves the initial LP relaxation of the MIP
37  problem. The branchAndBound() method can then be called to finish using
38  a branch and cut algorithm.
39
40  <h3>Search Tree Traversal</h3>
41
42  Subproblems (aka nodes) requiring additional evaluation are stored using
43  the CbcNode and CbcNodeInfo objects. Ancestry linkage is maintained in the
44  CbcNodeInfo object. Evaluation of a subproblem within branchAndBound()
45  proceeds as follows:
46  <ul>
47    <li> The node representing the most promising parent subproblem is popped
48         from the heap which holds the set of subproblems requiring further
49         evaluation.
50    <li> Using branching instructions stored in the node, and information in
51         its ancestors, the model and solver are adjusted to create the
52         active subproblem.
53    <li> If the parent subproblem will require further evaluation
54         (<i>i.e.</i>, there are branches remaining) its node is pushed back
55         on the heap. Otherwise, the node is deleted.  This may trigger
56         recursive deletion of ancestors.
57    <li> The newly created subproblem is evaluated.
58    <li> If the subproblem requires further evaluation, a node is created.
59         All information needed to recreate the subproblem (branching
60         information, row and column cuts) is placed in the node and the node
61         is added to the set of subproblems awaiting further evaluation.
62  </ul>
63  Note that there is never a node representing the active subproblem; the model
64  and solver represent the active subproblem.
65
66  <h3>Row (Constraint) Cut Handling</h3>
67
68  For a typical subproblem, the sequence of events is as follows:
69  <ul>
70    <li> The subproblem is rebuilt for further evaluation: One result of a
71         call to addCuts() is a traversal of ancestors, leaving a list of all
72         cuts used in the ancestors in #addedCuts_. This list is then scanned
73         to construct a basis that includes only tight cuts. Entries for
74         loose cuts are set to NULL.
75    <li> The subproblem is evaluated: One result of a call to solveWithCuts()
76         is the return of a set of newly generated cuts for the subproblem.
77         #addedCuts_ is also kept up-to-date as old cuts become loose.
78    <li> The subproblem is stored for further processing: A call to
79         CbcNodeInfo::addCuts() adds the newly generated cuts to the
80         CbcNodeInfo object associated with this node.
81  </ul>
82  See CbcCountRowCut for details of the bookkeeping associated with cut
83  management.
84*/
85
86class CbcModel  {
87 
88public:
89
90enum CbcIntParam {
91  /** The maximum number of nodes before terminating */
92  CbcMaxNumNode=0,
93  /** The maximum number of solutions before terminating */
94  CbcMaxNumSol,
95  /** Fathoming discipline
96
97    Controls objective function comparisons for purposes of fathoming by bound
98    or determining monotonic variables.
99
100    If 1, action is taken only when the current objective is strictly worse
101    than the target. Implementation is handled by adding a small tolerance to
102    the target.
103  */
104  CbcFathomDiscipline,
105  /** Just a marker, so that a static sized array can store parameters. */
106  CbcLastIntParam
107};
108
109enum CbcDblParam {
110  /** The maximum amount the value of an integer variable can vary from
111      integer and still be considered feasible. */
112  CbcIntegerTolerance=0,
113  /** The objective is assumed to worsen by this amount for each
114      integer infeasibility. */
115  CbcInfeasibilityWeight,
116  /** The amount by which to tighten the objective function cutoff when
117      a new solution is discovered. */
118  CbcCutoffIncrement,
119  /** Stop when the gap between the objective value of the best known solution
120    and the best bound on the objective of any solution is less than this.
121 
122    This is an absolute value. Conversion from a percentage is left to the
123    client.
124  */
125  CbcAllowableGap,
126  /** Stop when the gap between the objective value of the best known solution
127    and the best bound on the objective of any solution is less than this
128    fraction of of the absolute value of best known solution.
129 
130    Code stops if either this test or CbcAllowableGap test succeeds
131  */
132  CbcAllowableFractionGap,
133  /** \brief The maximum number of seconds before terminating.
134             A double should be adequate! */
135  CbcMaximumSeconds,
136  /// Cutoff - stored for speed
137  CbcCurrentCutoff,
138  /// Optimization direction - stored for speed
139  CbcOptimizationDirection,
140  /// Current objective value
141  CbcCurrentObjectiveValue,
142  /// Current minimization objective value
143  CbcCurrentMinimizationObjectiveValue,
144  /** \brief The time at start of model.
145             So that other pieces of code can access */
146  CbcStartSeconds,
147  /** Just a marker, so that a static sized array can store parameters. */
148  CbcLastDblParam
149};
150
151  //---------------------------------------------------------------------------
152
153public:
154  ///@name Solve methods
155  //@{
156    /** \brief Solve the initial LP relaxation
157
158      Invoke the solver's %initialSolve() method.
159    */
160    void initialSolve(); 
161
162    /** \brief Invoke the branch \& cut algorithm
163
164      The method assumes that initialSolve() has been called to solve the
165      LP relaxation. It processes the root node, then proceeds to explore the
166      branch & cut search tree. The search ends when the tree is exhausted or
167      one of several execution limits is reached.
168      If doStatistics is 1 summary statistics are printed
169      if 2 then also the path to best solution (if found by branching)
170      if 3 then also one line per node
171    */
172     void branchAndBound(int doStatistics=0);
173
174    /** \brief create a clean model from partially fixed problem
175
176      The method creates a new model with given bounds and with no tree.
177    */
178     CbcModel *  cleanModel(const double * lower, const double * upper);
179    /** \brief Invoke the branch \& cut algorithm on partially fixed problem
180
181      The method presolves the given model and does branch and cut. The search
182      ends when the tree is exhausted or maximum nodes is reached.
183
184      If better solution found then it is saved.
185
186      Returns 0 if search completed and solution, 1 if not completed and solution,
187      2 if completed and no solution, 3 if not completed and no solution.
188
189      Normally okay to do cleanModel immediately followed by subBranchandBound
190      (== other form of subBranchAndBound)
191      but may need to get at model for advanced features.
192
193      Deletes model2
194    */
195     int subBranchAndBound(CbcModel * model2,
196                           CbcModel * presolvedModel,
197                           int maximumNodes);
198    /** \brief Invoke the branch \& cut algorithm on partially fixed problem
199
200      The method creates a new model with given bounds, presolves it
201      then proceeds to explore the branch & cut search tree. The search
202      ends when the tree is exhausted or maximum nodes is reached.
203
204      If better solution found then it is saved.
205
206      Returns 0 if search completed and solution, 1 if not completed and solution,
207      2 if completed and no solution, 3 if not completed and no solution.
208
209      This is just subModel immediately followed by other version of
210      subBranchandBound.
211
212    */
213     int subBranchAndBound(const double * lower, const double * upper,
214                            int maximumNodes);
215
216    /** \brief Process root node and return a strengthened model
217
218      The method assumes that initialSolve() has been called to solve the
219      LP relaxation. It processes the root node and then returns a pointer
220      to the strengthened model (or NULL if infeasible)
221    */
222     OsiSolverInterface *  strengthenedModel();
223private:
224    /** \brief Evaluate a subproblem using cutting planes and heuristics
225
226      The method invokes a main loop which generates cuts, applies heuristics,
227      and reoptimises using the solver's native %resolve() method.
228      It returns true if the subproblem remains feasible at the end of the
229      evaluation.
230    */
231  bool solveWithCuts(OsiCuts & cuts, int numberTries,CbcNode * node);
232  /** Input one node output N nodes to put on tree and optional solution update
233      This should be able to operate in parallel so is given a solver and is const(ish)
234      However we will need to keep an array of solver_ and bases and more
235      status is 0 for normal, 1 if solution
236      Calling code should always push nodes back on tree
237  */
238  CbcNode ** solveOneNode(int whichSolver,CbcNode * node, 
239                          int & numberNodesOutput, int & status) ;
240  /// Update size of whichGenerator
241  void resizeWhichGenerator(int numberNow, int numberAfter);
242public:
243    /** \brief Reoptimise an LP relaxation
244   
245      Invoke the solver's %resolve() method.
246      whereFrom -
247      0 - initial continuous
248      1 - resolve on branch (before new cuts)
249      2 - after new cuts
250      3  - obsolete code or something modified problem in unexpected way
251      10 - after strong branching has fixed variables at root
252      11 - after strong branching has fixed variables in tree
253
254      returns 1 feasible, 0 infeasible, -1 feasible but skip cuts
255    */
256    int resolve(CbcNodeInfo * parent, int whereFrom);
257    /// Make given rows (L or G) into global cuts and remove from lp
258    void makeGlobalCuts(int numberRows,const int * which); 
259  //@}
260
261  /** \name Presolve methods */
262  //@{
263
264  /** Identify cliques and construct corresponding objects.
265
266      Find cliques with size in the range
267      [\p atLeastThisMany, \p lessThanThis] and construct corresponding
268      CbcClique objects.
269      If \p makeEquality is true then a new model may be returned if
270      modifications had to be made, otherwise \c this is returned.
271      If the problem is infeasible #numberObjects_ is set to -1.
272      A client must use deleteObjects() before a second call to findCliques().
273      If priorities exist, clique priority is set to the default.
274  */
275  CbcModel * findCliques(bool makeEquality, int atLeastThisMany,
276                         int lessThanThis, int defaultValue=1000);
277
278  /** Do integer presolve, creating a new (presolved) model.
279
280    Returns the new model, or NULL if feasibility is lost.
281    If weak is true then just does a normal presolve
282 
283    \todo It remains to work out the cleanest way of getting a solution to
284          the original problem at the end. So this is very preliminary.
285   */
286  CbcModel * integerPresolve(bool weak=false);
287
288  /** Do integer presolve, modifying the current model.
289
290      Returns true if the model remains feasible after presolve.
291  */
292  bool integerPresolveThisModel(OsiSolverInterface * originalSolver,bool weak=false);
293
294
295  /// Put back information into the original model after integer presolve.
296  void originalModel(CbcModel * presolvedModel,bool weak);
297
298  /** \brief For variables involved in VUB constraints, see if we can tighten
299             bounds by solving lp's
300
301      Returns false if feasibility is lost.
302      If CglProbing is available, it will be tried as well to see if it can
303      tighten bounds.
304      This routine is just a front end for tightenVubs(int,const int*,double).
305
306      If <tt>type = -1</tt> all variables are processed (could be very slow).
307      If <tt>type = 0</tt> only variables involved in VUBs are processed.
308      If <tt>type = n > 0</tt>, only the n most expensive VUB variables
309      are processed, where it is assumed that x is at its maximum so delta
310      would have to go to 1 (if x not at bound).
311
312      If \p allowMultipleBinary is true, then a VUB constraint is a row with
313      one continuous variable and any number of binary variables.
314
315      If <tt>useCutoff < 1.0e30</tt>, the original objective is installed as a
316      constraint with \p useCutoff as a bound.
317  */
318  bool tightenVubs(int type,bool allowMultipleBinary=false,
319                   double useCutoff=1.0e50);
320 
321  /** \brief For variables involved in VUB constraints, see if we can tighten
322             bounds by solving lp's
323
324    This version is just handed a list of variables to be processed.
325  */
326  bool tightenVubs(int numberVubs, const int * which,
327                   double useCutoff=1.0e50);
328  /**
329    Analyze problem to find a minimum change in the objective function.
330  */
331  void analyzeObjective();
332
333
334  //@}
335
336  /** \name Object manipulation routines
337 
338    See CbcObject for an explanation of `object' in the context of CbcModel.
339  */
340  //@{
341
342  /// Get the number of objects
343  inline int numberObjects() const { return numberObjects_;};
344  /// Set the number of objects
345  inline void setNumberObjects(int number) 
346  {  numberObjects_=number;};
347
348  /// Get the array of objects
349  inline CbcObject ** objects() const { return object_;};
350
351  /// Get the specified object
352  const inline CbcObject * object(int which) const { return object_[which];};
353  /// Get the specified object
354  inline CbcObject * modifiableObject(int which) const { return object_[which];};
355
356  /// Delete all object information
357  void deleteObjects();
358
359  /** Add in object information.
360 
361    Objects are cloned; the owner can delete the originals.
362  */
363  void addObjects(int numberObjects, CbcObject ** objects);
364
365  /// Ensure attached objects point to this model.
366  void synchronizeModel() ;
367
368  /** \brief Identify integer variables and create corresponding objects.
369 
370    Record integer variables and create an CbcSimpleInteger object for each
371    one.
372    If \p startAgain is true, a new scan is forced, overwriting any existing
373    integer variable information.
374  */
375
376  void findIntegers(bool startAgain);
377
378  //@}
379
380  //---------------------------------------------------------------------------
381
382  /**@name Parameter set/get methods
383
384     The set methods return true if the parameter was set to the given value,
385     false if the value of the parameter is out of range.
386
387     The get methods return the value of the parameter.
388
389  */
390  //@{
391  /// Set an integer parameter
392  inline bool setIntParam(CbcIntParam key, int value) {
393    intParam_[key] = value;
394    return true;
395  }
396  /// Set a double parameter
397  inline bool setDblParam(CbcDblParam key, double value) {
398    dblParam_[key] = value;
399    return true;
400  }
401  /// Get an integer parameter
402  inline int getIntParam(CbcIntParam key) const {
403    return intParam_[key];
404  }
405  /// Get a double parameter
406  inline double getDblParam(CbcDblParam key) const {
407    return dblParam_[key];
408  }
409  /*! \brief Set cutoff bound on the objective function.
410
411    When using strict comparison, the bound is adjusted by a tolerance to
412    avoid accidentally cutting off the optimal solution.
413  */
414  void setCutoff(double value) ;
415
416  /// Get the cutoff bound on the objective function - always as minimize
417  inline double getCutoff() const
418  { //double value ;
419    //solver_->getDblParam(OsiDualObjectiveLimit,value) ;
420    //assert( dblParam_[CbcCurrentCutoff]== value * solver_->getObjSense());
421    return dblParam_[CbcCurrentCutoff];
422  }
423
424  /// Set the \link CbcModel::CbcMaxNumNode maximum node limit \endlink
425  inline bool setMaximumNodes( int value)
426  { return setIntParam(CbcMaxNumNode,value); }
427
428  /// Get the \link CbcModel::CbcMaxNumNode maximum node limit \endlink
429  inline int getMaximumNodes() const
430  { return getIntParam(CbcMaxNumNode); }
431
432  /** Set the
433      \link CbcModel::CbcMaxNumSol maximum number of solutions \endlink
434      desired.
435  */
436  inline bool setMaximumSolutions( int value) {
437    return setIntParam(CbcMaxNumSol,value);
438  }
439  /** Get the
440      \link CbcModel::CbcMaxNumSol maximum number of solutions \endlink
441      desired.
442  */
443  inline int getMaximumSolutions() const {
444    return getIntParam(CbcMaxNumSol);
445  }
446
447  /** Set the
448      \link CbcModel::CbcMaximumSeconds maximum number of seconds \endlink
449      desired.
450  */
451  inline bool setMaximumSeconds( double value) {
452    return setDblParam(CbcMaximumSeconds,value);
453  }
454  /** Get the
455      \link CbcModel::CbcMaximumSeconds maximum number of seconds \endlink
456      desired.
457  */
458  inline double getMaximumSeconds() const {
459    return getDblParam(CbcMaximumSeconds);
460  }
461
462  /** Set the
463    \link CbcModel::CbcIntegerTolerance integrality tolerance \endlink
464  */
465  inline bool setIntegerTolerance( double value) {
466    return setDblParam(CbcIntegerTolerance,value);
467  }
468  /** Get the
469    \link CbcModel::CbcIntegerTolerance integrality tolerance \endlink
470  */
471  inline double getIntegerTolerance() const {
472    return getDblParam(CbcIntegerTolerance);
473  }
474
475  /** Set the
476      \link CbcModel::CbcInfeasibilityWeight
477            weight per integer infeasibility \endlink
478  */
479  inline bool setInfeasibilityWeight( double value) {
480    return setDblParam(CbcInfeasibilityWeight,value);
481  }
482  /** Get the
483      \link CbcModel::CbcInfeasibilityWeight
484            weight per integer infeasibility \endlink
485  */
486  inline double getInfeasibilityWeight() const {
487    return getDblParam(CbcInfeasibilityWeight);
488  }
489
490  /** Set the \link CbcModel::CbcAllowableGap allowable gap \endlink
491      between the best known solution and the best possible solution.
492  */
493  inline bool setAllowableGap( double value) {
494    return setDblParam(CbcAllowableGap,value);
495  }
496  /** Get the \link CbcModel::CbcAllowableGap allowable gap \endlink
497      between the best known solution and the best possible solution.
498  */
499  inline double getAllowableGap() const {
500    return getDblParam(CbcAllowableGap);
501  }
502
503  /** Set the \link CbcModel::CbcAllowableFractionGap fraction allowable gap \endlink
504      between the best known solution and the best possible solution.
505  */
506  inline bool setAllowableFractionGap( double value) {
507    return setDblParam(CbcAllowableFractionGap,value);
508  }
509  /** Get the \link CbcModel::CbcAllowableFractionGap fraction allowable gap \endlink
510      between the best known solution and the best possible solution.
511  */
512  inline double getAllowableFractionGap() const {
513    return getDblParam(CbcAllowableFractionGap);
514  }
515  /** Set the \link CbcModel::CbcAllowableFractionGap percentage allowable gap \endlink
516      between the best known solution and the best possible solution.
517  */
518  inline bool setAllowablePercentageGap( double value) {
519    return setDblParam(CbcAllowableFractionGap,value*0.01);
520  }
521  /** Get the \link CbcModel::CbcAllowableFractionGap percentage allowable gap \endlink
522      between the best known solution and the best possible solution.
523  */
524  inline double getAllowablePercentageGap() const {
525    return 100.0*getDblParam(CbcAllowableFractionGap);
526  }
527  /** Set the
528      \link CbcModel::CbcCutoffIncrement  \endlink
529      desired.
530  */
531  inline bool setCutoffIncrement( double value) {
532    return setDblParam(CbcCutoffIncrement,value);
533  }
534  /** Get the
535      \link CbcModel::CbcCutoffIncrement  \endlink
536      desired.
537  */
538  inline double getCutoffIncrement() const {
539    return getDblParam(CbcCutoffIncrement);
540  }
541
542  /** Pass in target solution and optional priorities.
543      If priorities then >0 means only branch if incorrect
544      while <0 means branch even if correct. +1 or -1 are
545      highest priority */
546  void setHotstartSolution(const double * solution, const int * priorities=NULL) ;
547 
548  /// Set the minimum drop to continue cuts
549  inline void setMinimumDrop(double value)
550  {minimumDrop_=value;};
551  /// Get the minimum drop to continue cuts
552  inline double getMinimumDrop() const
553  { return minimumDrop_;};
554
555  /** Set the maximum number of cut passes at root node (default 20)
556      Minimum drop can also be used for fine tuning */
557  inline void setMaximumCutPassesAtRoot(int value)
558  {maximumCutPassesAtRoot_=value;};
559  /** Get the maximum number of cut passes at root node */
560  inline int getMaximumCutPassesAtRoot() const
561  { return maximumCutPassesAtRoot_;};
562
563  /** Set the maximum number of cut passes at other nodes (default 10)
564      Minimum drop can also be used for fine tuning */
565  inline void setMaximumCutPasses(int value)
566  {maximumCutPasses_=value;};
567  /** Get the maximum number of cut passes at other nodes (default 10) */
568  inline int getMaximumCutPasses() const
569  { return maximumCutPasses_;};
570  /** Get current cut pass number in this round of cuts.
571      (1 is first pass) */
572  inline int getCurrentPassNumber() const
573  { return currentPassNumber_;};
574
575  /** Set the maximum number of candidates to be evaluated for strong
576    branching.
577
578    A value of 0 disables strong branching.
579  */
580  void setNumberStrong(int number);
581  /** Get the maximum number of candidates to be evaluated for strong
582    branching.
583  */
584  inline int numberStrong() const
585  { return numberStrong_;};
586  /** Set size of mini - tree.  If > 1 then does total enumeration of
587      tree given by this best variables to branch on
588  */
589  inline void setSizeMiniTree(int value)
590  { sizeMiniTree_=value;};
591  inline int sizeMiniTree() const
592  { return sizeMiniTree_;};
593
594  /** Set the number of branches before pseudo costs believed
595      in dynamic strong branching.
596
597    A value of 0 disables dynamic strong branching.
598  */
599  void setNumberBeforeTrust(int number);
600  /** get the number of branches before pseudo costs believed
601      in dynamic strong branching. */
602  inline int numberBeforeTrust() const
603  { return numberBeforeTrust_;};
604  /** Set the number of variables for which to compute penalties
605      in dynamic strong branching.
606
607    A value of 0 disables penalties.
608  */
609  void setNumberPenalties(int number);
610  /** get the number of variables for which to compute penalties
611      in dynamic strong branching. */
612  inline int numberPenalties() const
613  { return numberPenalties_;};
614  /// Number of analyze iterations to do
615  inline void setNumberAnalyzeIterations(int number)
616  { numberAnalyzeIterations_=number;};
617  inline int numberAnalyzeIterations() const
618  { return numberAnalyzeIterations_;};
619  /** Get scale factor to make penalties match strong.
620      Should/will be computed */
621  inline double penaltyScaleFactor() const
622  { return penaltyScaleFactor_;};
623  /** Set scale factor to make penalties match strong.
624      Should/will be computed */
625  void setPenaltyScaleFactor(double value);
626  /** Problem type as set by user or found by analysis.  This will be extended
627      0 - not known
628      1 - Set partitioning <=
629      2 - Set partitioning ==
630      3 - Set covering
631      4 - all +- 1 or all +1 and odd
632  */
633  void inline setProblemType(int number)
634  { problemType_=number;};
635  inline int problemType() const
636  { return problemType_;};
637
638  /// Set how often to scan global cuts
639  void setHowOftenGlobalScan(int number);
640  /// Get how often to scan global cuts
641  inline int howOftenGlobalScan() const
642  { return howOftenGlobalScan_;};
643  /// Original columns as created by integerPresolve
644  inline int * originalColumns() const
645  { return originalColumns_;};
646
647  /** Set the print frequency.
648 
649    Controls the number of nodes evaluated between status prints.
650    If <tt>number <=0</tt> the print frequency is set to 100 nodes for large
651    problems, 1000 for small problems.
652    Print frequency has very slight overhead if small.
653  */
654  inline void setPrintFrequency(int number)
655  { printFrequency_=number;};
656  /// Get the print frequency
657  inline int printFrequency() const
658  { return printFrequency_;};
659  //@}
660
661  //---------------------------------------------------------------------------
662  ///@name Methods returning info on how the solution process terminated
663  //@{
664    /// Are there a numerical difficulties?
665    bool isAbandoned() const;
666    /// Is optimality proven?
667    bool isProvenOptimal() const;
668    /// Is  infeasiblity proven (or none better than cutoff)?
669    bool isProvenInfeasible() const;
670    /// Node limit reached?
671    bool isNodeLimitReached() const;
672    /// Time limit reached?
673    bool isSecondsLimitReached() const;
674    /// Solution limit reached?
675    bool isSolutionLimitReached() const;
676    /// Get how many iterations it took to solve the problem.
677    inline int getIterationCount() const
678    { return numberIterations_;};
679    /// Get how many Nodes it took to solve the problem.
680    inline int getNodeCount() const
681    { return numberNodes_;};
682    /** Final status of problem
683        Some of these can be found out by is...... functions
684        -1 before branchAndBound
685        0 finished - check isProvenOptimal or isProvenInfeasible to see if solution found
686        (or check value of best solution)
687        1 stopped - on maxnodes, maxsols, maxtime
688        2 difficulties so run was abandoned
689        (5 event user programmed event occurred)
690    */
691    inline int status() const
692    { return status_;};
693    /** Secondary status of problem
694        -1 unset (status_ will also be -1)
695        0 search completed with solution
696        1 linear relaxation not feasible (or worse than cutoff)
697        2 stopped on gap
698        3 stopped on nodes
699        4 stopped on time
700        5 stopped on user event
701        6 stopped on solutions
702    */
703    inline int secondaryStatus() const
704    { return secondaryStatus_;};
705    /// Are there numerical difficulties (for initialSolve) ?
706    bool isInitialSolveAbandoned() const ;
707    /// Is optimality proven (for initialSolve) ?
708    bool isInitialSolveProvenOptimal() const ;
709    /// Is primal infeasiblity proven (for initialSolve) ?
710    bool isInitialSolveProvenPrimalInfeasible() const ;
711    /// Is dual infeasiblity proven (for initialSolve) ?
712    bool isInitialSolveProvenDualInfeasible() const ;
713
714  //@}
715
716  //---------------------------------------------------------------------------
717  /**@name Problem information methods
718     
719     These methods call the solver's query routines to return
720     information about the problem referred to by the current object.
721     Querying a problem that has no data associated with it result in
722     zeros for the number of rows and columns, and NULL pointers from
723     the methods that return vectors.
724     
725     Const pointers returned from any data-query method are valid as
726     long as the data is unchanged and the solver is not called.
727  */
728  //@{
729  /// Number of rows in continuous (root) problem.
730  inline int numberRowsAtContinuous() const
731  { return numberRowsAtContinuous_;};
732
733  /// Get number of columns
734  inline int getNumCols() const
735  { return solver_->getNumCols();};
736 
737  /// Get number of rows
738  inline int getNumRows() const
739  { return solver_->getNumRows();};
740 
741  /// Get number of nonzero elements
742  inline CoinBigIndex getNumElements() const
743  { return solver_->getNumElements();};
744
745  /// Number of integers in problem
746  inline int numberIntegers() const
747  { return numberIntegers_;};
748  // Integer variables
749  inline const int * integerVariable() const 
750  { return integerVariable_;};
751  /// Whether or not integer
752  inline const char integerType(int i) const
753  { return integerInfo_[i];};
754  /// Whether or not integer
755  inline const char * integerType() const
756  { return integerInfo_;};
757
758  /// Get pointer to array[getNumCols()] of column lower bounds
759  inline const double * getColLower() const
760  { return solver_->getColLower();};
761 
762  /// Get pointer to array[getNumCols()] of column upper bounds
763  inline const double * getColUpper() const
764  { return solver_->getColUpper();};
765 
766  /** Get pointer to array[getNumRows()] of row constraint senses.
767      <ul>
768      <li>'L': <= constraint
769      <li>'E': =  constraint
770      <li>'G': >= constraint
771      <li>'R': ranged constraint
772      <li>'N': free constraint
773      </ul>
774  */
775  inline const char * getRowSense() const
776  { return solver_->getRowSense();};
777 
778  /** Get pointer to array[getNumRows()] of rows right-hand sides
779      <ul>
780      <li> if rowsense()[i] == 'L' then rhs()[i] == rowupper()[i]
781      <li> if rowsense()[i] == 'G' then rhs()[i] == rowlower()[i]
782      <li> if rowsense()[i] == 'R' then rhs()[i] == rowupper()[i]
783      <li> if rowsense()[i] == 'N' then rhs()[i] == 0.0
784      </ul>
785  */
786  inline const double * getRightHandSide() const
787  { return solver_->getRightHandSide();};
788 
789  /** Get pointer to array[getNumRows()] of row ranges.
790      <ul>
791      <li> if rowsense()[i] == 'R' then
792      rowrange()[i] == rowupper()[i] - rowlower()[i]
793      <li> if rowsense()[i] != 'R' then
794      rowrange()[i] is 0.0
795      </ul>
796  */
797  inline const double * getRowRange() const
798  { return solver_->getRowRange();};
799 
800  /// Get pointer to array[getNumRows()] of row lower bounds
801  inline const double * getRowLower() const
802  { return solver_->getRowLower();};
803 
804  /// Get pointer to array[getNumRows()] of row upper bounds
805  inline const double * getRowUpper() const
806  { return solver_->getRowUpper();};
807 
808  /// Get pointer to array[getNumCols()] of objective function coefficients
809  inline const double * getObjCoefficients() const
810  { return solver_->getObjCoefficients();};
811 
812  /// Get objective function sense (1 for min (default), -1 for max)
813  inline double getObjSense() const
814  {
815    //assert (dblParam_[CbcOptimizationDirection]== solver_->getObjSense());
816    return dblParam_[CbcOptimizationDirection];};
817 
818  /// Return true if variable is continuous
819  inline bool isContinuous(int colIndex) const
820  { return solver_->isContinuous(colIndex);};
821 
822  /// Return true if variable is binary
823  inline bool isBinary(int colIndex) const
824  { return solver_->isBinary(colIndex);};
825 
826  /** Return true if column is integer.
827      Note: This function returns true if the the column
828      is binary or a general integer.
829  */
830  inline bool isInteger(int colIndex) const
831  { return solver_->isInteger(colIndex);};
832 
833  /// Return true if variable is general integer
834  inline bool isIntegerNonBinary(int colIndex) const
835  { return solver_->isIntegerNonBinary(colIndex);};
836 
837  /// Return true if variable is binary and not fixed at either bound
838  inline bool isFreeBinary(int colIndex) const
839  { return solver_->isFreeBinary(colIndex) ;};
840 
841  /// Get pointer to row-wise copy of matrix
842  inline const CoinPackedMatrix * getMatrixByRow() const
843  { return solver_->getMatrixByRow();};
844 
845  /// Get pointer to column-wise copy of matrix
846  inline const CoinPackedMatrix * getMatrixByCol() const
847  { return solver_->getMatrixByCol();};
848 
849  /// Get solver's value for infinity
850  inline double getInfinity() const
851  { return solver_->getInfinity();};
852  /// Get pointer to array[getNumCols()] (for speed) of column lower bounds
853  inline const double * getCbcColLower() const
854  { return cbcColLower_;};
855  /// Get pointer to array[getNumCols()] (for speed) of column upper bounds
856  inline const double * getCbcColUpper() const
857  { return cbcColUpper_;};
858  /// Get pointer to array[getNumRows()] (for speed) of row lower bounds
859  inline const double * getCbcRowLower() const
860  { return cbcRowLower_;};
861  /// Get pointer to array[getNumRows()] (for speed) of row upper bounds
862  inline const double * getCbcRowUpper() const
863  { return cbcRowUpper_;};
864  /// Get pointer to array[getNumCols()] (for speed) of primal solution vector
865  inline const double * getCbcColSolution() const
866  { return cbcColSolution_;};
867  /// Get pointer to array[getNumRows()] (for speed) of dual prices
868  inline const double * getCbcRowPrice() const
869  { return cbcRowPrice_;};
870  /// Get a pointer to array[getNumCols()] (for speed) of reduced costs
871  inline const double * getCbcReducedCost() const
872  { return cbcReducedCost_;};
873  /// Get pointer to array[getNumRows()] (for speed) of row activity levels.
874  inline const double * getCbcRowActivity() const
875  { return cbcRowActivity_;};
876  //@}
877 
878 
879  /**@name Methods related to querying the solution */
880  //@{
881  /// Holds solution at continuous (after cuts if branchAndBound called)
882  inline double * continuousSolution() const
883  { return continuousSolution_;};
884  /** Array marked whenever a solution is found if non-zero.
885      Code marks if heuristic returns better so heuristic
886      need only mark if it wants to on solutions which
887      are worse than current */
888  inline int * usedInSolution() const
889  { return usedInSolution_;};
890  /// Increases usedInSolution for nonzeros
891  void incrementUsed(const double * solution);
892  /// Record a new incumbent solution and update objectiveValue
893  void setBestSolution(CBC_Message how,
894                       double & objectiveValue, const double *solution,
895                       bool fixVariables=false);
896  /// Just update objectiveValue
897  void setBestObjectiveValue( double objectiveValue);
898
899  /** Call this to really test if a valid solution can be feasible
900      Solution is number columns in size.
901      If fixVariables true then bounds of continuous solver updated.
902      Returns objective value (worse than cutoff if not feasible)
903 */
904  double checkSolution(double cutoff, const double * solution,
905                       bool fixVariables);
906  /** Test the current solution for feasiblility.
907
908    Scan all objects for indications of infeasibility. This is broken down
909    into simple integer infeasibility (\p numberIntegerInfeasibilities)
910    and all other reports of infeasibility (\p numberObjectInfeasibilities).
911  */
912  bool feasibleSolution(int & numberIntegerInfeasibilities,
913                        int & numberObjectInfeasibilities) const;
914
915  /** Solution to the most recent lp relaxation.
916
917    The solver's solution to the most recent lp relaxation.
918  */
919   
920  inline double * currentSolution() const
921  { return currentSolution_;};
922  /** For testing infeasibilities - will point to
923      currentSolution_ or solver-->getColSolution()
924  */
925  inline const double * testSolution() const
926  { return testSolution_;};
927  inline void setTestSolution(const double * solution)
928  { testSolution_ = solution;};
929  /// Make sure region there and optionally copy solution
930  void reserveCurrentSolution(const double * solution=NULL);
931
932  /// Get pointer to array[getNumCols()] of primal solution vector
933  inline const double * getColSolution() const
934  { return solver_->getColSolution();};
935 
936  /// Get pointer to array[getNumRows()] of dual prices
937  inline const double * getRowPrice() const
938  { return solver_->getRowPrice();};
939 
940  /// Get a pointer to array[getNumCols()] of reduced costs
941  inline const double * getReducedCost() const
942  { return solver_->getReducedCost();};
943 
944  /// Get pointer to array[getNumRows()] of row activity levels.
945  inline const double * getRowActivity() const
946  { return solver_->getRowActivity();};
947 
948  /// Get current objective function value
949  inline double getCurrentObjValue() const
950  { return dblParam_[CbcCurrentObjectiveValue]; }
951  /// Get current minimization objective function value
952  inline double getCurrentMinimizationObjValue() const
953  { return dblParam_[CbcCurrentMinimizationObjectiveValue];}
954 
955  /// Get best objective function value as minimization
956  inline double getMinimizationObjValue() const
957  { return bestObjective_;};
958  /// Set best objective function value as minimization
959  inline void setMinimizationObjValue(double value) 
960  { bestObjective_=value;};
961 
962  /// Get best objective function value
963  inline double getObjValue() const
964  { return bestObjective_ * solver_->getObjSense() ; } ;
965  /** Get best possible objective function value.
966      This is better of best possible left on tree
967      and best solution found.
968      If called from within branch and cut may be optimistic.
969  */
970  double getBestPossibleObjValue() const;
971  /// Set best objective function value
972  inline void setObjValue(double value) 
973  { bestObjective_=value * solver_->getObjSense() ;};
974 
975  /** The best solution to the integer programming problem.
976
977    The best solution to the integer programming problem found during
978    the search. If no solution is found, the method returns null.
979  */
980
981  inline double * bestSolution() const
982  { return bestSolution_;};
983 
984  /// Get number of solutions
985  inline int getSolutionCount() const
986  { return numberSolutions_;};
987 
988  /// Set number of solutions (so heuristics will be different)
989  inline void setSolutionCount(int value) 
990  { numberSolutions_=value;};
991  /** Current phase (so heuristics etc etc can find out).
992      0 - initial solve
993      1 - solve with cuts at root
994      2 - solve with cuts
995      3 - other e.g. strong branching
996      4 - trying to validate a solution
997      5 - at end of search
998  */
999  inline int phase() const
1000  { return phase_;};
1001 
1002  /// Get number of heuristic solutions
1003  inline int getNumberHeuristicSolutions() const { return numberHeuristicSolutions_;};
1004
1005  /// Set objective function sense (1 for min (default), -1 for max,)
1006  inline void setObjSense(double s) { dblParam_[CbcOptimizationDirection]=s;
1007  solver_->setObjSense(s);};
1008
1009  /// Value of objective at continuous
1010  inline double getContinuousObjective() const
1011  { return originalContinuousObjective_;};
1012  inline void setContinuousObjective(double value)
1013  { originalContinuousObjective_=value;};
1014  /// Number of infeasibilities at continuous
1015  inline int getContinuousInfeasibilities() const
1016  { return continuousInfeasibilities_;};
1017  inline void setContinuousInfeasibilities(int value)
1018  { continuousInfeasibilities_=value;};
1019  /// Value of objective after root node cuts added
1020  inline double rootObjectiveAfterCuts() const
1021  { return continuousObjective_;};
1022  /// Sum of Changes to objective by first solve
1023  inline double sumChangeObjective() const
1024  { return sumChangeObjective1_;};
1025  /** Number of times global cuts violated.  When global cut pool then this
1026      should be kept for each cut and type of cut */
1027  inline int numberGlobalViolations() const
1028  { return numberGlobalViolations_;};
1029  inline void clearNumberGlobalViolations()
1030  { numberGlobalViolations_=0;};
1031  /// Whether to force a resolve after takeOffCuts
1032  inline bool resolveAfterTakeOffCuts() const
1033  { return resolveAfterTakeOffCuts_;};
1034  inline void setResolveAfterTakeOffCuts(bool yesNo)
1035  { resolveAfterTakeOffCuts_=yesNo;};
1036  //@}
1037
1038  /** \name Node selection */
1039  //@{
1040  // Comparison functions (which may be overridden by inheritance)
1041  inline CbcCompareBase * nodeComparison() const
1042  { return nodeCompare_;};
1043  void setNodeComparison(CbcCompareBase * compare);
1044  void setNodeComparison(CbcCompareBase & compare);
1045  //@}
1046
1047  /** \name Problem feasibility checking */
1048  //@{
1049  // Feasibility functions (which may be overridden by inheritance)
1050  inline CbcFeasibilityBase * problemFeasibility() const
1051  { return problemFeasibility_;};
1052  void setProblemFeasibility(CbcFeasibilityBase * feasibility);
1053  void setProblemFeasibility(CbcFeasibilityBase & feasibility);
1054  //@}
1055
1056  /** \name Tree methods and subtree methods */
1057  //@{
1058  /// Tree method e.g. heap (which may be overridden by inheritance)
1059  inline CbcTree * tree() const
1060  { return tree_;};
1061  /// For modifying tree handling (original is cloned)
1062  void passInTreeHandler(CbcTree & tree);
1063  /** For passing in an CbcModel to do a sub Tree (with derived tree handlers).
1064      Passed in model must exist for duration of branch and bound
1065  */
1066  void passInSubTreeModel(CbcModel & model);
1067  /** For retrieving a copy of subtree model with given OsiSolver.
1068      If no subtree model will use self (up to user to reset cutoff etc).
1069      If solver NULL uses current
1070  */
1071  CbcModel * subTreeModel(OsiSolverInterface * solver=NULL) const;
1072  /// Returns number of times any subtree stopped on nodes, time etc
1073  inline int numberStoppedSubTrees() const
1074  { return numberStoppedSubTrees_;}
1075  /// Says a sub tree was stopped
1076  inline void incrementSubTreeStopped()
1077  { numberStoppedSubTrees_++;};
1078  /** Whether to automatically do presolve before branch and bound (subTrees).
1079      0 - no
1080      1 - ordinary presolve
1081      2 - integer presolve (dodgy)
1082  */
1083  inline int typePresolve() const
1084  { return presolve_;};
1085  inline void setTypePresolve(int value)
1086  { presolve_=value;};
1087  //@}
1088
1089  /** \name Branching Decisions
1090 
1091    See the CbcBranchDecision class for additional information.
1092  */
1093  //@{
1094
1095  /// Get the current branching decision method.
1096  inline CbcBranchDecision * branchingMethod() const
1097  { return branchingMethod_;};
1098  /// Set the branching decision method.
1099  inline void setBranchingMethod(CbcBranchDecision * method)
1100  { branchingMethod_ = method;};
1101  /** Set the branching method
1102 
1103    \overload
1104  */
1105  inline void setBranchingMethod(CbcBranchDecision & method)
1106  { branchingMethod_ = &method;};
1107  //@}
1108
1109  /** \name Row (constraint) and Column (variable) cut generation */
1110  //@{
1111
1112  /** State of search
1113      0 - no solution
1114      1 - only heuristic solutions
1115      2 - branched to a solution
1116      3 - no solution but many nodes
1117  */
1118  inline int stateOfSearch() const
1119  { return stateOfSearch_;};
1120  inline void setStateOfSearch(int state)
1121  { stateOfSearch_=state;};
1122  /// Strategy worked out - mainly at root node for use by CbcNode
1123  inline int searchStrategy() const
1124  { return searchStrategy_;};
1125  /// Set strategy worked out - mainly at root node for use by CbcNode
1126  inline void setSearchStrategy(int value)
1127  { searchStrategy_ = value; };
1128
1129  /// Get the number of cut generators
1130  inline int numberCutGenerators() const
1131  { return numberCutGenerators_;};
1132  /// Get the list of cut generators
1133  inline CbcCutGenerator ** cutGenerators() const
1134  { return generator_;};
1135  ///Get the specified cut generator
1136  inline CbcCutGenerator * cutGenerator(int i) const
1137  { return generator_[i];};
1138  ///Get the specified cut generator before any changes
1139  inline CbcCutGenerator * virginCutGenerator(int i) const
1140  { return virginGenerator_[i];};
1141  /** Add one generator - up to user to delete generators.
1142      howoften affects how generator is used. 0 or 1 means always,
1143      >1 means every that number of nodes.  Negative values have same
1144      meaning as positive but they may be switched off (-> -100) by code if
1145      not many cuts generated at continuous.  -99 is just done at root.
1146      Name is just for printout.
1147      If depth >0 overrides how often generator is called (if howOften==-1 or >0).
1148  */
1149  void addCutGenerator(CglCutGenerator * generator,
1150                       int howOften=1, const char * name=NULL,
1151                       bool normal=true, bool atSolution=false, 
1152                       bool infeasible=false,int howOftenInSub=-100,
1153                       int whatDepth=-1, int whatDepthInSub=-1);
1154//@}
1155  /** \name Strategy and sub models
1156 
1157    See the CbcStrategy class for additional information.
1158  */
1159  //@{
1160
1161  /// Get the current strategy
1162  inline CbcStrategy * strategy() const
1163  { return strategy_;};
1164  /// Set the strategy. Clones
1165  void setStrategy(CbcStrategy & strategy);
1166  /// Get the current parent model
1167  inline CbcModel * parentModel() const
1168  { return parentModel_;};
1169  /// Set the parent model
1170  inline void setParentModel(CbcModel & parentModel)
1171  { parentModel_ = &parentModel;};
1172  //@}
1173
1174
1175  /** \name Heuristics and priorities */
1176  //@{
1177  /// Add one heuristic - up to user to delete
1178  void addHeuristic(CbcHeuristic * generator);
1179  ///Get the specified heuristic
1180  inline CbcHeuristic * heuristic(int i) const
1181  { return heuristic_[i];};
1182  /// Get the number of heuristics
1183  inline int numberHeuristics() const
1184  { return numberHeuristics_;};
1185  /// Pointer to heuristic solver which found last solution (or NULL)
1186  inline CbcHeuristic * lastHeuristic() const
1187  { return lastHeuristic_;};
1188  /// set last heuristic which found a solution
1189  inline void setLastHeuristic(CbcHeuristic * last)
1190  { lastHeuristic_=last;};
1191
1192  /** Pass in branching priorities.
1193 
1194      If ifClique then priorities are on cliques otherwise priorities are
1195      on integer variables. 
1196      Other type (if exists set to default)
1197      1 is highest priority. (well actually -INT_MAX is but that's ugly)
1198      If hotstart > 0 then branches are created to force
1199      the variable to the value given by best solution.  This enables a
1200      sort of hot start.  The node choice should be greatest depth
1201      and hotstart should normally be switched off after a solution.
1202
1203      If ifNotSimpleIntegers true then appended to normal integers
1204
1205      This is now deprecated except for simple usage.  If user
1206      creates Cbcobjects then set priority in them
1207
1208      \internal Added for Kurt Spielberg.
1209  */
1210  void passInPriorities(const int * priorities, bool ifNotSimpleIntegers);
1211
1212  /// Returns priority level for an object (or 1000 if no priorities exist)
1213  inline int priority(int sequence) const
1214  { return object_[sequence]->priority();}; 
1215  //@}
1216   
1217  /**@name Setting/Accessing application data */
1218  //@{
1219    /** Set application data.
1220
1221        This is a pointer that the application can store into and
1222        retrieve from the solver interface.
1223        This field is available for the application to optionally
1224        define and use.
1225    */
1226    void setApplicationData (void * appData);
1227
1228    /// Get application data
1229    void * getApplicationData() const;
1230  /**
1231      For advanced applications you may wish to modify the behavior of Cbc
1232      e.g. if the solver is a NLP solver then you may not have an exact
1233      optimum solution at each step.  Information could be built into
1234      OsiSolverInterface but this is an alternative so that that interface
1235      does not have to be changed.  If something similar is useful to
1236      enough solvers then it could be migrated
1237  */
1238  void passInSolverCharacteristics(OsiBabSolver * solverCharacteristics);
1239  //@}
1240 
1241  //---------------------------------------------------------------------------
1242
1243  /**@name Message handling */
1244  //@{
1245  /// Pass in Message handler (not deleted at end)
1246  void passInMessageHandler(CoinMessageHandler * handler);
1247  /// Set language
1248  void newLanguage(CoinMessages::Language language);
1249  inline void setLanguage(CoinMessages::Language language)
1250  {newLanguage(language);};
1251  /// Return handler
1252  inline CoinMessageHandler * messageHandler() const
1253  {return handler_;};
1254  /// Return messages
1255  inline CoinMessages messages() 
1256  {return messages_;};
1257  /// Return pointer to messages
1258  inline CoinMessages * messagesPointer() 
1259  {return &messages_;};
1260  /// Set log level
1261  void setLogLevel(int value);
1262  /// Get log level
1263  inline int logLevel() const
1264  { return handler_->logLevel();};
1265#ifdef COIN_USE_CLP
1266   /// Pass in Event handler (cloned and deleted at end)
1267   void passInEventHandler(const ClpEventHandler * eventHandler);
1268   /// Event handler
1269  ClpEventHandler * eventHandler() const;
1270#endif
1271  //@}
1272  //---------------------------------------------------------------------------
1273  ///@name Specialized
1274  //@{
1275
1276  /**
1277      Set special options
1278      0 bit (1) - check if cuts valid (if on debugger list)
1279      1 bit (2) - use current basis to check integer solution (rather than all slack)
1280      2 bit (4) - don't check integer solution (by solving LP)
1281      3 bit (8) - fast analyze
1282      4 bit (16) - non-linear model and someone too lazy to code "times" correctly - so skip row check
1283  */
1284  /// Set special options
1285  inline void setSpecialOptions(int value)
1286  { specialOptions_=value;};
1287  /// Get special options
1288  inline int specialOptions() const
1289  { return specialOptions_;};
1290  //@}
1291  //---------------------------------------------------------------------------
1292
1293  ///@name Constructors and destructors etc
1294  //@{
1295    /// Default Constructor
1296    CbcModel(); 
1297   
1298    /// Constructor from solver
1299    CbcModel(const OsiSolverInterface &);
1300 
1301    /** Assign a solver to the model (model assumes ownership)
1302
1303      On return, \p solver will be NULL.
1304      If deleteSolver then current solver deleted (if model owned)
1305
1306      \note Parameter settings in the outgoing solver are not inherited by
1307            the incoming solver.
1308    */
1309    void assignSolver(OsiSolverInterface *&solver,bool deleteSolver=true);
1310 
1311    /** Copy constructor .
1312      If noTree is true then tree and cuts are not copied
1313    */ 
1314    CbcModel(const CbcModel & rhs, bool noTree=false);
1315 
1316    /// Assignment operator
1317    CbcModel & operator=(const CbcModel& rhs);
1318 
1319    /// Destructor
1320     ~CbcModel ();
1321
1322    /// Returns solver - has current state
1323    inline OsiSolverInterface * solver() const
1324    { return solver_;};
1325
1326    /// Returns solver with continuous state
1327    inline OsiSolverInterface * continuousSolver() const
1328    { return continuousSolver_;};
1329
1330  /// A copy of the solver, taken at constructor or by saveReferenceSolver
1331  inline OsiSolverInterface * referenceSolver() const
1332  { return referenceSolver_;};
1333
1334  /// Save a copy of the current solver so can be reset to
1335  void saveReferenceSolver();
1336
1337  /** Uses a copy of reference solver to be current solver.
1338      Because of possible mismatches all exotic integer information is loat
1339      (apart from normal information in OsiSolverInterface)
1340      so SOS etc and priorities will have to be redone
1341  */
1342  void resetToReferenceSolver();
1343
1344  /// Clears out as much as possible (except solver)
1345  void gutsOfDestructor();
1346  /** Clears out enough to reset CbcModel as if no branch and bound done
1347   */
1348  void gutsOfDestructor2();
1349  //@}
1350
1351  ///@semi-private i.e. users should not use
1352  //@{
1353    /// Get how many Nodes it took to solve the problem.
1354    int getNodeCount2() const
1355    { return numberNodes2_;};
1356  /// Set pointers for speed
1357  void setPointers(const OsiSolverInterface * solver);
1358  /** Perform reduced cost fixing
1359
1360    Fixes integer variables at their current value based on reduced cost
1361    penalties.  Returns number fixed
1362  */
1363  int reducedCostFix() ;
1364
1365  /** Return an empty basis object of the specified size
1366
1367    A useful utility when constructing a basis for a subproblem from scratch.
1368    The object returned will be of the requested capacity and appropriate for
1369    the solver attached to the model.
1370  */
1371  CoinWarmStartBasis *getEmptyBasis(int ns = 0, int na = 0) const ;
1372
1373  /** Remove inactive cuts from the model
1374
1375    An OsiSolverInterface is expected to maintain a valid basis, but not a
1376    valid solution, when loose cuts are deleted. Restoring a valid solution
1377    requires calling the solver to reoptimise. If it's certain the solution
1378    will not be required, set allowResolve to false to suppress
1379    reoptimisation.
1380    If saveCuts then slack cuts will be saved
1381  */
1382  void takeOffCuts(OsiCuts &cuts, 
1383                     bool allowResolve,OsiCuts * saveCuts) ;
1384
1385  /** Determine and install the active cuts that need to be added for
1386    the current subproblem
1387
1388    The whole truth is a bit more complicated. The first action is a call to
1389    addCuts1(). addCuts() then sorts through the list, installs the tight
1390    cuts in the model, and does bookkeeping (adjusts reference counts).
1391    The basis returned from addCuts1() is adjusted accordingly.
1392   
1393    If it turns out that the node should really be fathomed by bound,
1394    addCuts() simply treats all the cuts as loose as it does the bookkeeping.
1395
1396    canFix true if extra information being passed
1397  */
1398  int addCuts(CbcNode * node, CoinWarmStartBasis *&lastws,bool canFix);
1399
1400  /** Traverse the tree from node to root and prep the model
1401
1402    addCuts1() begins the job of prepping the model to match the current
1403    subproblem. The model is stripped of all cuts, and the search tree is
1404    traversed from node to root to determine the changes required. Appropriate
1405    bounds changes are installed, a list of cuts is collected but not
1406    installed, and an appropriate basis (minus the cuts, but big enough to
1407    accommodate them) is constructed.
1408
1409    \todo addCuts1() is called in contexts where it's known in advance that
1410          all that's desired is to determine a list of cuts and do the
1411          bookkeeping (adjust the reference counts). The work of installing
1412          bounds and building a basis goes to waste.
1413  */
1414  void addCuts1(CbcNode * node, CoinWarmStartBasis *&lastws);
1415  /** Set objective value in a node.  This is separated out so that
1416     odd solvers can use.  It may look at extra information in
1417     solverCharacteriscs_ and will also use bound from parent node
1418  */
1419  void setObjectiveValue(CbcNode * thisNode, const CbcNode * parentNode) const;
1420
1421  /** If numberBeforeTrust >0 then we are going to use CbcBranchDynamic.
1422      Scan and convert CbcSimpleInteger objects
1423  */
1424  void convertToDynamic();
1425  /// Use cliques for pseudocost information - return nonzero if infeasible
1426  int cliquePseudoCosts(int doStatistics);
1427  /// Fill in useful estimates
1428  void pseudoShadow(double * down, double * up);
1429
1430  /// Get the hotstart solution
1431  inline const double * hotstartSolution() const
1432  { return hotstartSolution_;};
1433  /// Get the hotstart priorities
1434  inline const int * hotstartPriorities() const
1435  { return hotstartPriorities_;};
1436
1437  /// Return the list of cuts initially collected for this subproblem
1438  inline CbcCountRowCut ** addedCuts() const
1439  { return addedCuts_;};
1440  /// Number of entries in the list returned by #addedCuts()
1441  inline int currentNumberCuts() const
1442  { return currentNumberCuts_;};
1443  /// Global cuts
1444  inline OsiCuts * globalCuts() 
1445  { return &globalCuts_;};
1446  /// Copy and set a pointer to a row cut which will be added instead of normal branching.
1447  void setNextRowCut(const OsiRowCut & cut);
1448  /// Get a pointer to current node (be careful)
1449  inline CbcNode * currentNode() const
1450  { return currentNode_;};
1451  /// Set the number of iterations done in strong branching.
1452  inline void setNumberStrongIterations(int number)
1453  { numberStrongIterations_ = number;};
1454  /// Get the number of iterations done in strong branching.
1455  inline int numberStrongIterations() const
1456  { return numberStrongIterations_;};
1457  /// Increment strong info
1458  void incrementStrongInfo(int numberTimes, int numberIterations,
1459                           int numberFixed, bool ifInfeasible);
1460  //@}
1461
1462//---------------------------------------------------------------------------
1463
1464private:
1465  ///@name Private member data
1466  //@{
1467
1468  /// The solver associated with this model.
1469  OsiSolverInterface * solver_;
1470
1471  /** Ownership of the solver object
1472
1473    The convention is that CbcModel owns the null solver. Currently there
1474    is no public method to give CbcModel a solver without giving ownership,
1475    but the hook is here.
1476  */
1477  bool ourSolver_ ;
1478
1479  /// A copy of the solver, taken at the continuous (root) node.
1480  OsiSolverInterface * continuousSolver_;
1481
1482  /// A copy of the solver, taken at constructor or by saveReferenceSolver
1483  OsiSolverInterface * referenceSolver_;
1484
1485   /// Message handler
1486  CoinMessageHandler * handler_;
1487
1488  /** Flag to say if handler_ is the default handler.
1489 
1490    The default handler is deleted when the model is deleted. Other
1491    handlers (supplied by the client) will not be deleted.
1492  */
1493  bool defaultHandler_;
1494
1495  /// Cbc messages
1496  CoinMessages messages_;
1497
1498  /// Array for integer parameters
1499  int intParam_[CbcLastIntParam];
1500
1501  /// Array for double parameters
1502  double dblParam_[CbcLastDblParam];
1503
1504  /** Pointer to an empty warm start object
1505
1506    It turns out to be useful to have this available as a base from
1507    which to build custom warm start objects. This is typed as CoinWarmStart
1508    rather than CoinWarmStartBasis to allow for the possibility that a
1509    client might want to apply a solver that doesn't use a basis-based warm
1510    start. See getEmptyBasis for an example of how this field can be used.
1511  */
1512  mutable CoinWarmStart *emptyWarmStart_ ;
1513
1514  /// Best objective
1515  double bestObjective_;
1516  /// Best possible objective
1517  double bestPossibleObjective_;
1518  /// Sum of Changes to objective by first solve
1519  double sumChangeObjective1_;
1520  /// Sum of Changes to objective by subsequent solves
1521  double sumChangeObjective2_;
1522
1523  /// Array holding the incumbent (best) solution.
1524  double * bestSolution_;
1525
1526  /** Array holding the current solution.
1527
1528    This array is used more as a temporary.
1529  */
1530  double * currentSolution_;
1531  /** For testing infeasibilities - will point to
1532      currentSolution_ or solver-->getColSolution()
1533  */
1534  mutable const double * testSolution_;
1535  /// Global cuts
1536  OsiCuts globalCuts_;
1537
1538  /// Minimum degradation in objective value to continue cut generation
1539  double minimumDrop_;
1540  /// Number of solutions
1541  int numberSolutions_;
1542  /** State of search
1543      0 - no solution
1544      1 - only heuristic solutions
1545      2 - branched to a solution
1546      3 - no solution but many nodes
1547  */
1548  int stateOfSearch_;
1549  /// Hotstart solution
1550  double * hotstartSolution_;
1551  /// Hotstart priorities
1552  int * hotstartPriorities_;
1553  /// Number of heuristic solutions
1554  int numberHeuristicSolutions_;
1555  /// Cumulative number of nodes
1556  int numberNodes_;
1557  /** Cumulative number of nodes for statistics.
1558      Must fix to match up
1559  */
1560  int numberNodes2_;
1561  /// Cumulative number of iterations
1562  int numberIterations_;
1563  /// Status of problem - 0 finished, 1 stopped, 2 difficulties
1564  int status_;
1565  /** Secondary status of problem
1566      -1 unset (status_ will also be -1)
1567      0 search completed with solution
1568      1 linear relaxation not feasible (or worse than cutoff)
1569      2 stopped on gap
1570      3 stopped on nodes
1571      4 stopped on time
1572      5 stopped on user event
1573      6 stopped on solutions
1574   */
1575  int secondaryStatus_;
1576  /// Number of integers in problem
1577  int numberIntegers_;
1578  /// Number of rows at continuous
1579  int numberRowsAtContinuous_;
1580  /// Maximum number of cuts
1581  int maximumNumberCuts_;
1582  /** Current phase (so heuristics etc etc can find out).
1583      0 - initial solve
1584      1 - solve with cuts at root
1585      2 - solve with cuts
1586      3 - other e.g. strong branching
1587      4 - trying to validate a solution
1588      5 - at end of search
1589  */
1590  int phase_;
1591
1592  /// Number of entries in #addedCuts_
1593  int currentNumberCuts_;
1594
1595  /** Current limit on search tree depth
1596
1597    The allocated size of #walkback_. Increased as needed.
1598  */
1599  int maximumDepth_;
1600  /** Array used to assemble the path between a node and the search tree root
1601
1602    The array is resized when necessary. #maximumDepth_  is the current
1603    allocated size.
1604  */
1605  CbcNodeInfo ** walkback_;
1606
1607  /** The list of cuts initially collected for this subproblem
1608
1609    When the subproblem at this node is rebuilt, a set of cuts is collected
1610    for inclusion in the constraint system. If any of these cuts are
1611    subsequently removed because they have become loose, the corresponding
1612    entry is set to NULL.
1613  */
1614  CbcCountRowCut ** addedCuts_;
1615
1616  /** A pointer to a row cut which will be added instead of normal branching.
1617      After use it should be set to NULL.
1618  */
1619  OsiRowCut * nextRowCut_;
1620
1621  /// Current node so can be used elsewhere
1622  CbcNode * currentNode_;
1623
1624  /// Indices of integer variables
1625  int * integerVariable_;
1626  /// Whether of not integer
1627  char * integerInfo_;
1628  /// Holds solution at continuous (after cuts)
1629  double * continuousSolution_;
1630  /// Array marked whenever a solution is found if non-zero
1631  int * usedInSolution_;
1632  /**
1633      0 bit (1) - check if cuts valid (if on debugger list)
1634      1 bit (2) - use current basis to check integer solution (rather than all slack)
1635      2 bit (4) - don't check integer solution
1636      3 bit (8) - Strong is doing well - keep on
1637  */
1638  int specialOptions_;
1639  /// User node comparison function
1640  CbcCompareBase * nodeCompare_;
1641  /// User feasibility function (see CbcFeasibleBase.hpp)
1642  CbcFeasibilityBase * problemFeasibility_;
1643  /// Tree
1644  CbcTree * tree_;
1645  /// A pointer to model to be used for subtrees
1646  CbcModel * subTreeModel_;
1647  /// Number of times any subtree stopped on nodes, time etc
1648  int numberStoppedSubTrees_;
1649  /// Variable selection function
1650  CbcBranchDecision * branchingMethod_;
1651  /// Strategy
1652  CbcStrategy * strategy_;
1653  /// Parent model
1654  CbcModel * parentModel_;
1655  /** Whether to automatically do presolve before branch and bound.
1656      0 - no
1657      1 - ordinary presolve
1658      2 - integer presolve (dodgy)
1659  */
1660  /// Pointer to array[getNumCols()] (for speed) of column lower bounds
1661  const double * cbcColLower_;
1662  /// Pointer to array[getNumCols()] (for speed) of column upper bounds
1663  const double * cbcColUpper_;
1664  /// Pointer to array[getNumRows()] (for speed) of row lower bounds
1665  const double * cbcRowLower_;
1666  /// Pointer to array[getNumRows()] (for speed) of row upper bounds
1667  const double * cbcRowUpper_;
1668  /// Pointer to array[getNumCols()] (for speed) of primal solution vector
1669  const double * cbcColSolution_;
1670  /// Pointer to array[getNumRows()] (for speed) of dual prices
1671  const double * cbcRowPrice_;
1672  /// Get a pointer to array[getNumCols()] (for speed) of reduced costs
1673  const double * cbcReducedCost_;
1674  /// Pointer to array[getNumRows()] (for speed) of row activity levels.
1675  const double * cbcRowActivity_;
1676  /// Pointer to user-defined data structure
1677  void * appData_;
1678  /// Pointer to
1679  int presolve_;
1680  /** Maximum number of candidates to consider for strong branching.
1681    To disable strong branching, set this to 0.
1682  */
1683  int numberStrong_;
1684  /** The number of branches before pseudo costs believed
1685      in dynamic strong branching. (0 off) */
1686  int numberBeforeTrust_;
1687  /** The number of variable sfor which to compute penalties
1688      in dynamic strong branching. (0 off) */
1689  int numberPenalties_;
1690  /** Scale factor to make penalties match strong.
1691      Should/will be computed */
1692  double penaltyScaleFactor_;
1693  /// Number of analyze iterations to do
1694  int numberAnalyzeIterations_;
1695  /// Arrays with analysis results
1696  double * analyzeResults_;
1697  /// Number of nodes infeasible by normal branching (before cuts)
1698  int numberInfeasibleNodes_;
1699  /** Problem type as set by user or found by analysis.  This will be extended
1700      0 - not known
1701      1 - Set partitioning <=
1702      2 - Set partitioning ==
1703      3 - Set covering
1704  */
1705  int problemType_;
1706  /// Print frequency
1707  int printFrequency_;
1708  /// Number of cut generators
1709  int numberCutGenerators_;
1710  // Cut generators
1711  CbcCutGenerator ** generator_;
1712  // Cut generators before any changes
1713  CbcCutGenerator ** virginGenerator_;
1714  /// Number of heuristics
1715  int numberHeuristics_;
1716  /// Heuristic solvers
1717  CbcHeuristic ** heuristic_;
1718  /// Pointer to heuristic solver which found last solution (or NULL)
1719  CbcHeuristic * lastHeuristic_;
1720
1721  /// Total number of objects
1722  int numberObjects_;
1723
1724  /** \brief Integer and Clique and ... information
1725
1726    \note The code assumes that the first objects on the list will be
1727          SimpleInteger objects for each integer variable, followed by
1728          Clique objects. Portions of the code that understand Clique objects
1729          will fail if they do not immediately follow the SimpleIntegers.
1730          Large chunks of the code will fail if the first objects are not
1731          SimpleInteger. As of 2003.08, SimpleIntegers and Cliques are the only
1732          objects.
1733  */
1734  CbcObject ** object_;
1735
1736 
1737  /// Original columns as created by integerPresolve
1738  int * originalColumns_;
1739  /// How often to scan global cuts
1740  int howOftenGlobalScan_;
1741  /** Number of times global cuts violated.  When global cut pool then this
1742      should be kept for each cut and type of cut */
1743  int numberGlobalViolations_;
1744  /** Value of objective at continuous
1745      (Well actually after initial round of cuts)
1746  */
1747  double continuousObjective_;
1748  /** Value of objective before root node cuts added
1749  */
1750  double originalContinuousObjective_;
1751  /// Number of infeasibilities at continuous
1752  int continuousInfeasibilities_;
1753  /// Maximum number of cut passes at root
1754  int maximumCutPassesAtRoot_;
1755  /// Maximum number of cut passes
1756  int maximumCutPasses_;
1757  /// Current cut pass number
1758  int currentPassNumber_;
1759  /// Maximum number of cuts (for whichGenerator_)
1760  int maximumWhich_;
1761  /// Which cut generator generated this cut
1762  int * whichGenerator_;
1763  /// Maximum number of statistics
1764  int maximumStatistics_;
1765  /// statistics
1766  CbcStatistics ** statistics_;
1767  /// Number of fixed by analyze at root
1768  int numberFixedAtRoot_;
1769  /// Number fixed by analyze so far
1770  int numberFixedNow_;
1771  /// Whether stopping on gap
1772  bool stoppedOnGap_;
1773  /// Whether event happened
1774  bool eventHappened_;
1775  /// Number of long strong goes
1776  int numberLongStrong_;
1777  /// Number of old active cuts
1778  int numberOldActiveCuts_;
1779  /// Number of new cuts
1780  int numberNewCuts_;
1781  /// Size of mini - tree
1782  int sizeMiniTree_;
1783  /// Strategy worked out - mainly at root node
1784  int searchStrategy_;
1785  /// Number of iterations in strong branching
1786  int numberStrongIterations_;
1787  /** 0 - number times strong branching done, 1 - number fixed, 2 - number infeasible */
1788  int strongInfo_[3];
1789  /**
1790      For advanced applications you may wish to modify the behavior of Cbc
1791      e.g. if the solver is a NLP solver then you may not have an exact
1792      optimum solution at each step.  This gives characteristics - just for one BAB.
1793      For actually saving/restoring a solution you need the actual solver one.
1794  */
1795  OsiBabSolver * solverCharacteristics_;
1796  /// Whether to force a resolve after takeOffCuts
1797  bool resolveAfterTakeOffCuts_;
1798 //@}
1799};
1800
1801#endif
Note: See TracBrowser for help on using the repository browser.