source: trunk/Cbc/src/OsiCbc/OsiCbcSolverInterface.hpp @ 1572

Last change on this file since 1572 was 1572, checked in by lou, 8 years ago

Change to EPL license notice.

File size: 29.5 KB
Line 
1// $Id$
2// Copyright (C) 2000, International Business Machines
3// Corporation and others.  All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6#ifndef OsiCbcSolverInterface_H
7#define OsiCbcSolverInterface_H
8
9#include <string>
10#include <cfloat>
11#include <map>
12#include "CbcModel.hpp"
13#include "CoinPackedMatrix.hpp"
14#include "OsiSolverInterface.hpp"
15#include "CbcStrategy.hpp"
16#include "CoinWarmStartBasis.hpp"
17
18class OsiRowCut;
19class OsiClpSolverInterface;
20#ifndef COIN_DBL_MAX
21static const double OsiCbcInfinity = DBL_MAX;
22#else
23static const double OsiCbcInfinity = COIN_DBL_MAX;
24#endif
25
26//#############################################################################
27
28/** Cbc Solver Interface
29   
30Instantiation of OsiCbcSolverInterface for the Model Algorithm.
31
32*/
33
34class OsiCbcSolverInterface :
35  virtual public OsiSolverInterface {
36  friend int OsiCbcSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
37 
38public:
39  //---------------------------------------------------------------------------
40  /**@name Solve methods */
41  //@{
42  /// Solve initial LP relaxation
43  virtual void initialSolve();
44 
45  /// Resolve an LP relaxation after problem modification
46  virtual void resolve();
47 
48  /// Invoke solver's built-in enumeration algorithm
49  virtual void branchAndBound();
50  //@}
51 
52  //---------------------------------------------------------------------------
53  /**@name Parameter set/get methods
54     
55  The set methods return true if the parameter was set to the given value,
56  false otherwise. There can be various reasons for failure: the given
57  parameter is not applicable for the solver (e.g., refactorization
58  frequency for the cbc algorithm), the parameter is not yet implemented
59  for the solver or simply the value of the parameter is out of the range
60  the solver accepts. If a parameter setting call returns false check the
61  details of your solver.
62 
63  The get methods return true if the given parameter is applicable for the
64  solver and is implemented. In this case the value of the parameter is
65  returned in the second argument. Otherwise they return false.
66  */
67  //@{
68  // Set an integer parameter
69  bool setIntParam(OsiIntParam key, int value);
70  // Set an double parameter
71  bool setDblParam(OsiDblParam key, double value);
72  // Set a string parameter
73  bool setStrParam(OsiStrParam key, const std::string & value);
74  // Get an integer parameter
75  bool getIntParam(OsiIntParam key, int& value) const;
76  // Get an double parameter
77  bool getDblParam(OsiDblParam key, double& value) const;
78  // Get a string parameter
79  bool getStrParam(OsiStrParam key, std::string& value) const;
80  // Set a hint parameter - overrides OsiSolverInterface
81  virtual bool setHintParam(OsiHintParam key, bool yesNo=true,
82                            OsiHintStrength strength=OsiHintTry,
83                            void * otherInformation=NULL);
84  /// Get a hint parameter
85    virtual bool getHintParam(OsiHintParam key, bool& yesNo,
86                              OsiHintStrength& strength,
87                              void *& otherInformation) const;
88
89  using OsiSolverInterface::getHintParam ;
90  /// Get a hint parameter
91    virtual bool getHintParam(OsiHintParam key, bool& yesNo,
92                              OsiHintStrength& strength) const;
93  //@}
94 
95  //---------------------------------------------------------------------------
96  ///@name Methods returning info on how the solution process terminated
97  //@{
98  /// Are there a numerical difficulties?
99  virtual bool isAbandoned() const;
100  /// Is optimality proven?
101  virtual bool isProvenOptimal() const;
102  /// Is primal infeasiblity proven?
103  virtual bool isProvenPrimalInfeasible() const;
104  /// Is dual infeasiblity proven?
105  virtual bool isProvenDualInfeasible() const;
106  /// Is the given primal objective limit reached?
107  virtual bool isPrimalObjectiveLimitReached() const;
108  /// Is the given dual objective limit reached?
109  virtual bool isDualObjectiveLimitReached() const;
110  /// Iteration limit reached?
111  virtual bool isIterationLimitReached() const;
112  //@}
113 
114  //---------------------------------------------------------------------------
115  /**@name WarmStart related methods */
116  //@{
117 
118  /*! \brief Get an empty warm start object
119   
120  This routine returns an empty CoinWarmStartBasis object. Its purpose is
121  to provide a way to give a client a warm start basis object of the
122  appropriate type, which can resized and modified as desired.
123  */
124 
125  virtual CoinWarmStart *getEmptyWarmStart () const;
126 
127  /// Get warmstarting information
128  virtual CoinWarmStart* getWarmStart() const;
129  /** Set warmstarting information. Return true/false depending on whether
130      the warmstart information was accepted or not. */
131  virtual bool setWarmStart(const CoinWarmStart* warmstart);
132  //@}
133 
134  //---------------------------------------------------------------------------
135  /**@name Hotstart related methods (primarily used in strong branching). <br>
136     The user can create a hotstart (a snapshot) of the optimization process
137     then reoptimize over and over again always starting from there.<br>
138     <strong>NOTE</strong>: between hotstarted optimizations only
139     bound changes are allowed. */
140  //@{
141  /// Create a hotstart point of the optimization process
142  virtual void markHotStart();
143  /// Optimize starting from the hotstart
144  virtual void solveFromHotStart();
145  /// Delete the snapshot
146  virtual void unmarkHotStart();
147  //@}
148 
149  //---------------------------------------------------------------------------
150  /**@name Problem information methods
151     
152  These methods call the solver's query routines to return
153  information about the problem referred to by the current object.
154  Querying a problem that has no data associated with it result in
155  zeros for the number of rows and columns, and NULL pointers from
156  the methods that return vectors.
157 
158  Const pointers returned from any data-query method are valid as
159  long as the data is unchanged and the solver is not called.
160  */
161  //@{
162  /**@name Methods related to querying the input data */
163  //@{
164  /// Get number of columns
165  virtual int getNumCols() const;
166 
167  /// Get number of rows
168  virtual int getNumRows() const;
169 
170  /// Get number of nonzero elements
171  virtual int getNumElements() const ;
172 
173  /// Get pointer to array[getNumCols()] of column lower bounds
174  virtual const double * getColLower() const;
175 
176  /// Get pointer to array[getNumCols()] of column upper bounds
177  virtual const double * getColUpper() const;
178 
179  /** Get pointer to array[getNumRows()] of row constraint senses.
180      <ul>
181      <li>'L' <= constraint
182      <li>'E' =  constraint
183      <li>'G' >= constraint
184      <li>'R' ranged constraint
185      <li>'N' free constraint
186      </ul>
187  */
188  virtual const char * getRowSense() const;
189 
190  /** Get pointer to array[getNumRows()] of rows right-hand sides
191      <ul>
192      <li> if rowsense()[i] == 'L' then rhs()[i] == rowupper()[i]
193      <li> if rowsense()[i] == 'G' then rhs()[i] == rowlower()[i]
194      <li> if rowsense()[i] == 'R' then rhs()[i] == rowupper()[i]
195      <li> if rowsense()[i] == 'N' then rhs()[i] == 0.0
196      </ul>
197  */
198  virtual const double * getRightHandSide() const ;
199 
200  /** Get pointer to array[getNumRows()] of row ranges.
201      <ul>
202      <li> if rowsense()[i] == 'R' then
203      rowrange()[i] == rowupper()[i] - rowlower()[i]
204      <li> if rowsense()[i] != 'R' then
205      rowrange()[i] is undefined
206      </ul>
207  */
208  virtual const double * getRowRange() const ;
209 
210  /// Get pointer to array[getNumRows()] of row lower bounds
211  virtual const double * getRowLower() const ;
212 
213  /// Get pointer to array[getNumRows()] of row upper bounds
214  virtual const double * getRowUpper() const ;
215 
216  /// Get pointer to array[getNumCols()] of objective function coefficients
217  virtual const double * getObjCoefficients() const; 
218 
219  /// Get objective function sense (1 for min (default), -1 for max)
220  virtual double getObjSense() const ;
221 
222  /// Return true if column is continuous
223  virtual bool isContinuous(int colNumber) const;
224 
225 
226  /// Get pointer to row-wise copy of matrix
227  virtual const CoinPackedMatrix * getMatrixByRow() const;
228 
229  /// Get pointer to column-wise copy of matrix
230  virtual const CoinPackedMatrix * getMatrixByCol() const;
231 
232  /// Get solver's value for infinity
233  virtual double getInfinity() const;
234  //@}
235 
236  /**@name Methods related to querying the solution */
237  //@{
238  /// Get pointer to array[getNumCols()] of primal solution vector
239  virtual const double * getColSolution() const; 
240 
241  /// Get pointer to array[getNumRows()] of dual prices
242  virtual const double * getRowPrice() const;
243 
244  /// Get a pointer to array[getNumCols()] of reduced costs
245  virtual const double * getReducedCost() const; 
246 
247  /** Get pointer to array[getNumRows()] of row activity levels (constraint
248      matrix times the solution vector */
249  virtual const double * getRowActivity() const; 
250 
251  /// Get objective function value
252  virtual double getObjValue() const;
253 
254  /** Get how many iterations it took to solve the problem (whatever
255      "iteration" mean to the solver. */
256  virtual int getIterationCount() const ;
257 
258  /** Get as many dual rays as the solver can provide. (In case of proven
259      primal infeasibility there should be at least one.)
260
261      The first getNumRows() ray components will always be associated with
262      the row duals (as returned by getRowPrice()). If \c fullRay is true,
263      the final getNumCols() entries will correspond to the ray components
264      associated with the nonbasic variables. If the full ray is requested
265      and the method cannot provide it, it will throw an exception.
266
267      <strong>NOTE for implementers of solver interfaces:</strong> <br>
268      The double pointers in the vector should point to arrays of length
269      getNumRows() and they should be allocated via new[]. <br>
270     
271      <strong>NOTE for users of solver interfaces:</strong> <br>
272      It is the user's responsibility to free the double pointers in the
273      vector using delete[].
274  */
275  virtual std::vector<double*> getDualRays(int maxNumRays,
276                                           bool fullRay = false) const;
277  /** Get as many primal rays as the solver can provide. (In case of proven
278      dual infeasibility there should be at least one.)
279     
280      <strong>NOTE for implementers of solver interfaces:</strong> <br>
281      The double pointers in the vector should point to arrays of length
282      getNumCols() and they should be allocated via new[]. <br>
283     
284      <strong>NOTE for users of solver interfaces:</strong> <br>
285      It is the user's responsibility to free the double pointers in the
286      vector using delete[].
287  */
288  virtual std::vector<double*> getPrimalRays(int maxNumRays) const;
289 
290  //@}
291
292  /*! \name Methods for row and column names.
293
294    Because OsiCbc is a pass-through class, it's necessary to override any
295    virtual method in order to be sure we catch an override by the underlying
296    solver. See the OsiSolverInterface class documentation for detailed
297    descriptions.
298  */
299  //@{
300
301    /*! \brief Generate a standard name of the form Rnnnnnnn or Cnnnnnnn */
302
303    virtual std::string dfltRowColName(char rc,
304                                 int ndx, unsigned digits = 7) const ;
305
306    /*! \brief Return the name of the objective function */
307
308    virtual std::string getObjName (unsigned maxLen = std::string::npos) const ;
309
310    /*! \brief Set the name of the objective function */
311
312    virtual void setObjName (std::string name) ;
313
314    /*! \brief Return the name of the row.  */
315
316    virtual std::string getRowName(int rowIndex,
317                                   unsigned maxLen = std::string::npos) const ;
318
319    /*! \brief Return a pointer to a vector of row names */
320
321    virtual const OsiNameVec &getRowNames() ;
322
323    /*! \brief Set a row name */
324
325    virtual void setRowName(int ndx, std::string name) ;
326
327    /*! \brief Set multiple row names */
328
329    virtual void setRowNames(OsiNameVec &srcNames,
330                     int srcStart, int len, int tgtStart) ;
331
332    /*! \brief Delete len row names starting at index tgtStart */
333
334    virtual void deleteRowNames(int tgtStart, int len) ;
335 
336    /*! \brief Return the name of the column */
337
338    virtual std::string getColName(int colIndex,
339                                   unsigned maxLen = std::string::npos) const ;
340
341    /*! \brief Return a pointer to a vector of column names */
342
343    virtual const OsiNameVec &getColNames() ;
344
345    /*! \brief Set a column name */
346
347    virtual void setColName(int ndx, std::string name) ;
348
349    /*! \brief Set multiple column names */
350
351    virtual void setColNames(OsiNameVec &srcNames,
352                     int srcStart, int len, int tgtStart) ;
353
354    /*! \brief Delete len column names starting at index tgtStart */
355    virtual void deleteColNames(int tgtStart, int len) ;
356
357  //@}
358
359  //@}
360 
361  //---------------------------------------------------------------------------
362 
363  /**@name Problem modifying methods */
364  //@{
365  //-------------------------------------------------------------------------
366  /**@name Changing bounds on variables and constraints */
367  //@{
368  /** Set an objective function coefficient */
369  virtual void setObjCoeff( int elementIndex, double elementValue );
370
371  using OsiSolverInterface::setColLower ;
372  /** Set a single column lower bound<br>
373      Use -DBL_MAX for -infinity. */
374  virtual void setColLower( int elementIndex, double elementValue );
375 
376  using OsiSolverInterface::setColUpper ;
377  /** Set a single column upper bound<br>
378      Use DBL_MAX for infinity. */
379  virtual void setColUpper( int elementIndex, double elementValue );
380 
381  /** Set a single column lower and upper bound */
382  virtual void setColBounds( int elementIndex,
383                             double lower, double upper );
384 
385  /** Set the bounds on a number of columns simultaneously<br>
386      The default implementation just invokes setColLower() and
387      setColUpper() over and over again.
388      @param indexFirst,indexLast pointers to the beginning and after the
389      end of the array of the indices of the variables whose
390      <em>either</em> bound changes
391      @param boundList the new lower/upper bound pairs for the variables
392  */
393  virtual void setColSetBounds(const int* indexFirst,
394                               const int* indexLast,
395                               const double* boundList);
396 
397  /** Set a single row lower bound<br>
398      Use -DBL_MAX for -infinity. */
399  virtual void setRowLower( int elementIndex, double elementValue );
400 
401  /** Set a single row upper bound<br>
402      Use DBL_MAX for infinity. */
403  virtual void setRowUpper( int elementIndex, double elementValue ) ;
404 
405  /** Set a single row lower and upper bound */
406  virtual void setRowBounds( int elementIndex,
407                             double lower, double upper ) ;
408 
409  /** Set the type of a single row<br> */
410  virtual void setRowType(int index, char sense, double rightHandSide,
411                          double range);
412 
413  /** Set the bounds on a number of rows simultaneously<br>
414      The default implementation just invokes setRowLower() and
415      setRowUpper() over and over again.
416      @param indexFirst,indexLast pointers to the beginning and after the
417      end of the array of the indices of the constraints whose
418      <em>either</em> bound changes
419      @param boundList the new lower/upper bound pairs for the constraints
420  */
421  virtual void setRowSetBounds(const int* indexFirst,
422                               const int* indexLast,
423                               const double* boundList);
424 
425  /** Set the type of a number of rows simultaneously<br>
426      The default implementation just invokes setRowType()
427      over and over again.
428      @param indexFirst,indexLast pointers to the beginning and after the
429      end of the array of the indices of the constraints whose
430      <em>any</em> characteristics changes
431      @param senseList the new senses
432      @param rhsList   the new right hand sides
433      @param rangeList the new ranges
434  */
435  virtual void setRowSetTypes(const int* indexFirst,
436                              const int* indexLast,
437                              const char* senseList,
438                              const double* rhsList,
439                              const double* rangeList);
440  //@}
441 
442  //-------------------------------------------------------------------------
443  /**@name Integrality related changing methods */
444  //@{
445  /** Set the index-th variable to be a continuous variable */
446  virtual void setContinuous(int index);
447  /** Set the index-th variable to be an integer variable */
448  virtual void setInteger(int index);
449  /** Set the variables listed in indices (which is of length len) to be
450      continuous variables */
451  virtual void setContinuous(const int* indices, int len);
452  /** Set the variables listed in indices (which is of length len) to be
453      integer variables */
454  virtual void setInteger(const int* indices, int len);
455  //@}
456 
457  //-------------------------------------------------------------------------
458  /// Set objective function sense (1 for min (default), -1 for max,)
459  virtual void setObjSense(double s ); 
460 
461  /** Set the primal solution column values
462     
463  colsol[numcols()] is an array of values of the problem column
464  variables. These values are copied to memory owned by the
465  solver object or the solver.  They will be returned as the
466  result of colsol() until changed by another call to
467  setColsol() or by a call to any solver routine.  Whether the
468  solver makes use of the solution in any way is
469  solver-dependent.
470  */
471  virtual void setColSolution(const double * colsol);
472 
473  /** Set dual solution vector
474     
475  rowprice[numrows()] is an array of values of the problem row
476  dual variables. These values are copied to memory owned by the
477  solver object or the solver.  They will be returned as the
478  result of rowprice() until changed by another call to
479  setRowprice() or by a call to any solver routine.  Whether the
480  solver makes use of the solution in any way is
481  solver-dependent.
482  */
483  virtual void setRowPrice(const double * rowprice);
484 
485  //-------------------------------------------------------------------------
486  /**@name Methods to expand a problem.<br>
487     Note that if a column is added then by default it will correspond to a
488     continuous variable. */
489  //@{
490  using OsiSolverInterface::addCol ;
491  /** */
492  virtual void addCol(const CoinPackedVectorBase& vec,
493                      const double collb, const double colub,   
494                      const double obj);
495  /** Add a column (primal variable) to the problem. */
496  virtual void addCol(int numberElements, const int * rows, const double * elements,
497                      const double collb, const double colub,   
498                      const double obj) ;
499
500  using OsiSolverInterface::addCols ;
501  /** */
502  virtual void addCols(const int numcols,
503                       const CoinPackedVectorBase * const * cols,
504                       const double* collb, const double* colub,   
505                       const double* obj);
506  /** */
507  virtual void deleteCols(const int num, const int * colIndices);
508 
509  using OsiSolverInterface::addRow ;
510  /** */
511  virtual void addRow(const CoinPackedVectorBase& vec,
512                      const double rowlb, const double rowub);
513  /** */
514  virtual void addRow(const CoinPackedVectorBase& vec,
515                      const char rowsen, const double rowrhs,   
516                      const double rowrng);
517
518  using OsiSolverInterface::addRows ;
519  /** */
520  virtual void addRows(const int numrows,
521                       const CoinPackedVectorBase * const * rows,
522                       const double* rowlb, const double* rowub);
523  /** */
524  virtual void addRows(const int numrows,
525                       const CoinPackedVectorBase * const * rows,
526                       const char* rowsen, const double* rowrhs,   
527                       const double* rowrng);
528  /** */
529  virtual void deleteRows(const int num, const int * rowIndices);
530 
531  //-----------------------------------------------------------------------
532  /** Apply a collection of row cuts which are all effective.
533      applyCuts seems to do one at a time which seems inefficient.
534  */
535  virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
536  /** Apply a collection of row cuts which are all effective.
537      applyCuts seems to do one at a time which seems inefficient.
538      This uses array of pointers
539  */
540  virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
541  //@}
542  //@}
543 
544  //---------------------------------------------------------------------------
545 
546public:
547 
548  /**@name Methods to input a problem */
549  //@{
550  /** Load in an problem by copying the arguments (the constraints on the
551      rows are given by lower and upper bounds). If a pointer is 0 then the
552      following values are the default:
553      <ul>
554      <li> <code>colub</code>: all columns have upper bound infinity
555      <li> <code>collb</code>: all columns have lower bound 0
556      <li> <code>rowub</code>: all rows have upper bound infinity
557      <li> <code>rowlb</code>: all rows have lower bound -infinity
558      <li> <code>obj</code>: all variables have 0 objective coefficient
559      </ul>
560  */
561  virtual void loadProblem(const CoinPackedMatrix& matrix,
562                           const double* collb, const double* colub,   
563                           const double* obj,
564                           const double* rowlb, const double* rowub);
565 
566  /** Load in an problem by assuming ownership of the arguments (the
567      constraints on the rows are given by lower and upper bounds). For
568      default values see the previous method.  <br>
569      <strong>WARNING</strong>: The arguments passed to this method will be
570      freed using the C++ <code>delete</code> and <code>delete[]</code>
571      functions.
572  */
573  virtual void assignProblem(CoinPackedMatrix*& matrix,
574                             double*& collb, double*& colub, double*& obj,
575                             double*& rowlb, double*& rowub);
576 
577  /** Load in an problem by copying the arguments (the constraints on the
578      rows are given by sense/rhs/range triplets). If a pointer is 0 then the
579      following values are the default:
580      <ul>
581      <li> <code>colub</code>: all columns have upper bound infinity
582      <li> <code>collb</code>: all columns have lower bound 0
583      <li> <code>obj</code>: all variables have 0 objective coefficient
584      <li> <code>rowsen</code>: all rows are >=
585      <li> <code>rowrhs</code>: all right hand sides are 0
586      <li> <code>rowrng</code>: 0 for the ranged rows
587      </ul>
588  */
589  virtual void loadProblem(const CoinPackedMatrix& matrix,
590                           const double* collb, const double* colub,
591                           const double* obj,
592                           const char* rowsen, const double* rowrhs,   
593                           const double* rowrng);
594 
595  /** Load in an problem by assuming ownership of the arguments (the
596      constraints on the rows are given by sense/rhs/range triplets). For
597      default values see the previous method. <br>
598      <strong>WARNING</strong>: The arguments passed to this method will be
599      freed using the C++ <code>delete</code> and <code>delete[]</code>
600      functions.
601  */
602  virtual void assignProblem(CoinPackedMatrix*& matrix,
603                             double*& collb, double*& colub, double*& obj,
604                             char*& rowsen, double*& rowrhs,
605                             double*& rowrng);
606 
607  /** Just like the other loadProblem() methods except that the matrix is
608      given in a standard column major ordered format (without gaps). */
609  virtual void loadProblem(const int numcols, const int numrows,
610                           const CoinBigIndex * start, const int* index,
611                           const double* value,
612                           const double* collb, const double* colub,   
613                           const double* obj,
614                           const double* rowlb, const double* rowub);
615 
616  /** Just like the other loadProblem() methods except that the matrix is
617      given in a standard column major ordered format (without gaps). */
618  virtual void loadProblem(const int numcols, const int numrows,
619                           const CoinBigIndex * start, const int* index,
620                           const double* value,
621                           const double* collb, const double* colub,   
622                           const double* obj,
623                           const char* rowsen, const double* rowrhs,   
624                           const double* rowrng);
625
626  using OsiSolverInterface::readMps ;
627  /** Read an mps file from the given filename (defaults to Osi reader) - returns
628      number of errors (see OsiMpsReader class) */
629  virtual int readMps(const char *filename,
630                      const char *extension = "mps") ;
631 
632  /** Write the problem into an mps file of the given filename.
633      If objSense is non zero then -1.0 forces the code to write a
634      maximization objective and +1.0 to write a minimization one.
635      If 0.0 then solver can do what it wants */
636  virtual void writeMps(const char *filename,
637                        const char *extension = "mps",
638                        double objSense=0.0) const;
639  /** Write the problem into an mps file of the given filename,
640      names may be null.  formatType is
641      0 - normal
642      1 - extra accuracy
643      2 - IEEE hex (later)
644     
645      Returns non-zero on I/O error
646  */
647  virtual int writeMpsNative(const char *filename, 
648                             const char ** rowNames, const char ** columnNames,
649                             int formatType=0,int numberAcross=2,
650                             double objSense=0.0) const ;
651  //@}
652 
653  /**@name Message handling (extra for Cbc messages).
654     Normally I presume you would want the same language.
655     If not then you could use underlying model pointer */
656  //@{
657  /// Set language
658  void newLanguage(CoinMessages::Language language);
659  void setLanguage(CoinMessages::Language language)
660  {newLanguage(language);}
661  //@}
662  //---------------------------------------------------------------------------
663 
664  /**@name Cbc specific public interfaces */
665  //@{
666  /// Get pointer to Cbc model
667  inline CbcModel * getModelPtr() const 
668  { return modelPtr_;}
669  /// Get pointer to underlying solver
670  inline OsiSolverInterface * getRealSolverPtr() const 
671  { return modelPtr_->solver();}
672  /// Set cutoff bound on the objective function.
673  inline void setCutoff(double value) 
674  { modelPtr_->setCutoff(value);}
675  /// Get the cutoff bound on the objective function - always as minimize
676  inline double getCutoff() const
677  { return modelPtr_->getCutoff();}
678  /// Set the CbcModel::CbcMaxNumNode maximum node limit
679  inline void setMaximumNodes( int value)
680  { modelPtr_->setMaximumNodes(value);}
681  /// Get the CbcModel::CbcMaxNumNode maximum node limit
682  inline int getMaximumNodes() const
683  { return modelPtr_->getMaximumNodes();}
684  /// Set the CbcModel::CbcMaxNumSol maximum number of solutions
685  inline void setMaximumSolutions( int value) 
686  { modelPtr_->setMaximumSolutions(value);}
687  /// Get the CbcModel::CbcMaxNumSol maximum number of solutions
688  inline int getMaximumSolutions() const 
689  { return modelPtr_->getMaximumSolutions();}
690  /// Set the CbcModel::CbcMaximumSeconds maximum number of seconds
691  inline void setMaximumSeconds( double value) 
692  { modelPtr_->setMaximumSeconds(value);}
693  /// Get the CbcModel::CbcMaximumSeconds maximum number of seconds
694  inline double getMaximumSeconds() const 
695  { return modelPtr_->getMaximumSeconds();}
696  /// Node limit reached?
697  inline bool isNodeLimitReached() const
698  { return modelPtr_->isNodeLimitReached();}
699  /// Solution limit reached?
700  inline bool isSolutionLimitReached() const
701  { return modelPtr_->isSolutionLimitReached();}
702  /// Get how many Nodes it took to solve the problem.
703  inline int getNodeCount() const
704  { return modelPtr_->getNodeCount();}
705    /// Final status of problem - 0 finished, 1 stopped, 2 difficulties
706    inline int status() const
707  { return modelPtr_->status();}
708  /** Pass in a message handler
709 
710    It is the client's responsibility to destroy a message handler installed
711    by this routine; it will not be destroyed when the solver interface is
712    destroyed.
713  */
714  virtual void passInMessageHandler(CoinMessageHandler * handler);
715  //@}
716 
717  //---------------------------------------------------------------------------
718 
719  /**@name Constructors and destructors */
720  //@{
721  /// Default Constructor
722  OsiCbcSolverInterface (OsiSolverInterface * solver=NULL,
723                         CbcStrategy * strategy=NULL);
724 
725  /// Clone
726  virtual OsiSolverInterface * clone(bool copyData = true) const;
727 
728  /// Copy constructor
729  OsiCbcSolverInterface (const OsiCbcSolverInterface &);
730#if 0   
731  /// Borrow constructor - only delete one copy
732  OsiCbcSolverInterface (CbcModel * rhs, bool reallyOwn=false);
733 
734  /// Releases so won't error
735  void releaseCbc();
736#endif   
737  /// Assignment operator
738  OsiCbcSolverInterface & operator=(const OsiCbcSolverInterface& rhs);
739 
740  /// Destructor
741  virtual ~OsiCbcSolverInterface ();
742 
743  //@}
744  //---------------------------------------------------------------------------
745 
746protected:
747  ///@name Protected methods
748  //@{
749  /** Apply a row cut (append to constraint matrix). */
750  virtual void applyRowCut(const OsiRowCut& rc);
751 
752  /** Apply a column cut (adjust one or more bounds). */
753  virtual void applyColCut(const OsiColCut& cc);
754  //@}
755  /**@name Protected member data */
756  //@{
757  /// Cbc model represented by this class instance
758  mutable CbcModel * modelPtr_;
759  //@}
760};
761// So unit test can find out if NDEBUG set
762bool OsiCbcHasNDEBUG();
763
764//#############################################################################
765/** A function that tests the methods in the OsiCbcSolverInterface class. The
766    only reason for it not to be a member method is that this way it doesn't
767    have to be compiled into the library. And that's a gain, because the
768    library should be compiled with optimization on, but this method should be
769    compiled with debugging. Also, if this method is compiled with
770    optimization, the compilation takes 10-15 minutes and the machine pages
771    (has 256M core memory!)... */
772int
773OsiCbcSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
774
775#endif
Note: See TracBrowser for help on using the repository browser.