source: trunk/include/CbcModel.hpp @ 268

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

for nonlinear

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