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

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

for unbounded and gap

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