source: trunk/include/CbcModel.hpp @ 279

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

for timing

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