source: branches/split/Cbc/src/OsiCbc/OsiCbcSolverInterface.hpp @ 1439

Last change on this file since 1439 was 1439, checked in by stefan, 10 years ago

add OsiCbc?

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