source: branches/devel/Cbc/src/CbcModel.hpp @ 477

Last change on this file since 477 was 477, checked in by forrest, 13 years ago

for nonlinear and start moving to OsiTree?
afor n

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