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

Last change on this file since 1493 was 1493, checked in by lou, 9 years ago

Change signature of getDualRays from (int) to (int,bool) to allow choice of
partial (row components) or full (row and column components) dual ray. Matches
Osi trunk revision 1551.

File size: 29.4 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      The first getNumRows() ray components will always be associated with
260      the row duals (as returned by getRowPrice()). If \c fullRay is true,
261      the final getNumCols() entries will correspond to the ray components
262      associated with the nonbasic variables. If the full ray is requested
263      and the method cannot provide it, it will throw an exception.
264
265      <strong>NOTE for implementers of solver interfaces:</strong> <br>
266      The double pointers in the vector should point to arrays of length
267      getNumRows() and they should be allocated via new[]. <br>
268     
269      <strong>NOTE for users of solver interfaces:</strong> <br>
270      It is the user's responsibility to free the double pointers in the
271      vector using delete[].
272  */
273  virtual std::vector<double*> getDualRays(int maxNumRays,
274                                           bool fullRay = false) const;
275  /** Get as many primal rays as the solver can provide. (In case of proven
276      dual infeasibility there should be at least one.)
277     
278      <strong>NOTE for implementers of solver interfaces:</strong> <br>
279      The double pointers in the vector should point to arrays of length
280      getNumCols() and they should be allocated via new[]. <br>
281     
282      <strong>NOTE for users of solver interfaces:</strong> <br>
283      It is the user's responsibility to free the double pointers in the
284      vector using delete[].
285  */
286  virtual std::vector<double*> getPrimalRays(int maxNumRays) const;
287 
288  //@}
289
290  /*! \name Methods for row and column names.
291
292    Because OsiCbc is a pass-through class, it's necessary to override any
293    virtual method in order to be sure we catch an override by the underlying
294    solver. See the OsiSolverInterface class documentation for detailed
295    descriptions.
296  */
297  //@{
298
299    /*! \brief Generate a standard name of the form Rnnnnnnn or Cnnnnnnn */
300
301    virtual std::string dfltRowColName(char rc,
302                                 int ndx, unsigned digits = 7) const ;
303
304    /*! \brief Return the name of the objective function */
305
306    virtual std::string getObjName (unsigned maxLen = std::string::npos) const ;
307
308    /*! \brief Set the name of the objective function */
309
310    virtual void setObjName (std::string name) ;
311
312    /*! \brief Return the name of the row.  */
313
314    virtual std::string getRowName(int rowIndex,
315                                   unsigned maxLen = std::string::npos) const ;
316
317    /*! \brief Return a pointer to a vector of row names */
318
319    virtual const OsiNameVec &getRowNames() ;
320
321    /*! \brief Set a row name */
322
323    virtual void setRowName(int ndx, std::string name) ;
324
325    /*! \brief Set multiple row names */
326
327    virtual void setRowNames(OsiNameVec &srcNames,
328                     int srcStart, int len, int tgtStart) ;
329
330    /*! \brief Delete len row names starting at index tgtStart */
331
332    virtual void deleteRowNames(int tgtStart, int len) ;
333 
334    /*! \brief Return the name of the column */
335
336    virtual std::string getColName(int colIndex,
337                                   unsigned maxLen = std::string::npos) const ;
338
339    /*! \brief Return a pointer to a vector of column names */
340
341    virtual const OsiNameVec &getColNames() ;
342
343    /*! \brief Set a column name */
344
345    virtual void setColName(int ndx, std::string name) ;
346
347    /*! \brief Set multiple column names */
348
349    virtual void setColNames(OsiNameVec &srcNames,
350                     int srcStart, int len, int tgtStart) ;
351
352    /*! \brief Delete len column names starting at index tgtStart */
353    virtual void deleteColNames(int tgtStart, int len) ;
354
355  //@}
356
357  //@}
358 
359  //---------------------------------------------------------------------------
360 
361  /**@name Problem modifying methods */
362  //@{
363  //-------------------------------------------------------------------------
364  /**@name Changing bounds on variables and constraints */
365  //@{
366  /** Set an objective function coefficient */
367  virtual void setObjCoeff( int elementIndex, double elementValue );
368
369  using OsiSolverInterface::setColLower ;
370  /** Set a single column lower bound<br>
371      Use -DBL_MAX for -infinity. */
372  virtual void setColLower( int elementIndex, double elementValue );
373 
374  using OsiSolverInterface::setColUpper ;
375  /** Set a single column upper bound<br>
376      Use DBL_MAX for infinity. */
377  virtual void setColUpper( int elementIndex, double elementValue );
378 
379  /** Set a single column lower and upper bound */
380  virtual void setColBounds( int elementIndex,
381                             double lower, double upper );
382 
383  /** Set the bounds on a number of columns simultaneously<br>
384      The default implementation just invokes setColLower() and
385      setColUpper() over and over again.
386      @param indexFirst,indexLast pointers to the beginning and after the
387      end of the array of the indices of the variables whose
388      <em>either</em> bound changes
389      @param boundList the new lower/upper bound pairs for the variables
390  */
391  virtual void setColSetBounds(const int* indexFirst,
392                               const int* indexLast,
393                               const double* boundList);
394 
395  /** Set a single row lower bound<br>
396      Use -DBL_MAX for -infinity. */
397  virtual void setRowLower( int elementIndex, double elementValue );
398 
399  /** Set a single row upper bound<br>
400      Use DBL_MAX for infinity. */
401  virtual void setRowUpper( int elementIndex, double elementValue ) ;
402 
403  /** Set a single row lower and upper bound */
404  virtual void setRowBounds( int elementIndex,
405                             double lower, double upper ) ;
406 
407  /** Set the type of a single row<br> */
408  virtual void setRowType(int index, char sense, double rightHandSide,
409                          double range);
410 
411  /** Set the bounds on a number of rows simultaneously<br>
412      The default implementation just invokes setRowLower() and
413      setRowUpper() over and over again.
414      @param indexFirst,indexLast pointers to the beginning and after the
415      end of the array of the indices of the constraints whose
416      <em>either</em> bound changes
417      @param boundList the new lower/upper bound pairs for the constraints
418  */
419  virtual void setRowSetBounds(const int* indexFirst,
420                               const int* indexLast,
421                               const double* boundList);
422 
423  /** Set the type of a number of rows simultaneously<br>
424      The default implementation just invokes setRowType()
425      over and over again.
426      @param indexFirst,indexLast pointers to the beginning and after the
427      end of the array of the indices of the constraints whose
428      <em>any</em> characteristics changes
429      @param senseList the new senses
430      @param rhsList   the new right hand sides
431      @param rangeList the new ranges
432  */
433  virtual void setRowSetTypes(const int* indexFirst,
434                              const int* indexLast,
435                              const char* senseList,
436                              const double* rhsList,
437                              const double* rangeList);
438  //@}
439 
440  //-------------------------------------------------------------------------
441  /**@name Integrality related changing methods */
442  //@{
443  /** Set the index-th variable to be a continuous variable */
444  virtual void setContinuous(int index);
445  /** Set the index-th variable to be an integer variable */
446  virtual void setInteger(int index);
447  /** Set the variables listed in indices (which is of length len) to be
448      continuous variables */
449  virtual void setContinuous(const int* indices, int len);
450  /** Set the variables listed in indices (which is of length len) to be
451      integer variables */
452  virtual void setInteger(const int* indices, int len);
453  //@}
454 
455  //-------------------------------------------------------------------------
456  /// Set objective function sense (1 for min (default), -1 for max,)
457  virtual void setObjSense(double s ); 
458 
459  /** Set the primal solution column values
460     
461  colsol[numcols()] is an array of values of the problem column
462  variables. These values are copied to memory owned by the
463  solver object or the solver.  They will be returned as the
464  result of colsol() until changed by another call to
465  setColsol() or by a call to any solver routine.  Whether the
466  solver makes use of the solution in any way is
467  solver-dependent.
468  */
469  virtual void setColSolution(const double * colsol);
470 
471  /** Set dual solution vector
472     
473  rowprice[numrows()] is an array of values of the problem row
474  dual variables. These values are copied to memory owned by the
475  solver object or the solver.  They will be returned as the
476  result of rowprice() until changed by another call to
477  setRowprice() or by a call to any solver routine.  Whether the
478  solver makes use of the solution in any way is
479  solver-dependent.
480  */
481  virtual void setRowPrice(const double * rowprice);
482 
483  //-------------------------------------------------------------------------
484  /**@name Methods to expand a problem.<br>
485     Note that if a column is added then by default it will correspond to a
486     continuous variable. */
487  //@{
488  using OsiSolverInterface::addCol ;
489  /** */
490  virtual void addCol(const CoinPackedVectorBase& vec,
491                      const double collb, const double colub,   
492                      const double obj);
493  /** Add a column (primal variable) to the problem. */
494  virtual void addCol(int numberElements, const int * rows, const double * elements,
495                      const double collb, const double colub,   
496                      const double obj) ;
497
498  using OsiSolverInterface::addCols ;
499  /** */
500  virtual void addCols(const int numcols,
501                       const CoinPackedVectorBase * const * cols,
502                       const double* collb, const double* colub,   
503                       const double* obj);
504  /** */
505  virtual void deleteCols(const int num, const int * colIndices);
506 
507  using OsiSolverInterface::addRow ;
508  /** */
509  virtual void addRow(const CoinPackedVectorBase& vec,
510                      const double rowlb, const double rowub);
511  /** */
512  virtual void addRow(const CoinPackedVectorBase& vec,
513                      const char rowsen, const double rowrhs,   
514                      const double rowrng);
515
516  using OsiSolverInterface::addRows ;
517  /** */
518  virtual void addRows(const int numrows,
519                       const CoinPackedVectorBase * const * rows,
520                       const double* rowlb, const double* rowub);
521  /** */
522  virtual void addRows(const int numrows,
523                       const CoinPackedVectorBase * const * rows,
524                       const char* rowsen, const double* rowrhs,   
525                       const double* rowrng);
526  /** */
527  virtual void deleteRows(const int num, const int * rowIndices);
528 
529  //-----------------------------------------------------------------------
530  /** Apply a collection of row cuts which are all effective.
531      applyCuts seems to do one at a time which seems inefficient.
532  */
533  virtual void applyRowCuts(int numberCuts, const OsiRowCut * cuts);
534  /** Apply a collection of row cuts which are all effective.
535      applyCuts seems to do one at a time which seems inefficient.
536      This uses array of pointers
537  */
538  virtual void applyRowCuts(int numberCuts, const OsiRowCut ** cuts);
539  //@}
540  //@}
541 
542  //---------------------------------------------------------------------------
543 
544public:
545 
546  /**@name Methods to input a problem */
547  //@{
548  /** Load in an problem by copying the arguments (the constraints on the
549      rows are given by lower and upper bounds). If a pointer is 0 then the
550      following values are the default:
551      <ul>
552      <li> <code>colub</code>: all columns have upper bound infinity
553      <li> <code>collb</code>: all columns have lower bound 0
554      <li> <code>rowub</code>: all rows have upper bound infinity
555      <li> <code>rowlb</code>: all rows have lower bound -infinity
556      <li> <code>obj</code>: all variables have 0 objective coefficient
557      </ul>
558  */
559  virtual void loadProblem(const CoinPackedMatrix& matrix,
560                           const double* collb, const double* colub,   
561                           const double* obj,
562                           const double* rowlb, const double* rowub);
563 
564  /** Load in an problem by assuming ownership of the arguments (the
565      constraints on the rows are given by lower and upper bounds). For
566      default values see the previous method.  <br>
567      <strong>WARNING</strong>: The arguments passed to this method will be
568      freed using the C++ <code>delete</code> and <code>delete[]</code>
569      functions.
570  */
571  virtual void assignProblem(CoinPackedMatrix*& matrix,
572                             double*& collb, double*& colub, double*& obj,
573                             double*& rowlb, double*& rowub);
574 
575  /** Load in an problem by copying the arguments (the constraints on the
576      rows are given by sense/rhs/range triplets). If a pointer is 0 then the
577      following values are the default:
578      <ul>
579      <li> <code>colub</code>: all columns have upper bound infinity
580      <li> <code>collb</code>: all columns have lower bound 0
581      <li> <code>obj</code>: all variables have 0 objective coefficient
582      <li> <code>rowsen</code>: all rows are >=
583      <li> <code>rowrhs</code>: all right hand sides are 0
584      <li> <code>rowrng</code>: 0 for the ranged rows
585      </ul>
586  */
587  virtual void loadProblem(const CoinPackedMatrix& matrix,
588                           const double* collb, const double* colub,
589                           const double* obj,
590                           const char* rowsen, const double* rowrhs,   
591                           const double* rowrng);
592 
593  /** Load in an problem by assuming ownership of the arguments (the
594      constraints on the rows are given by sense/rhs/range triplets). For
595      default values see the previous method. <br>
596      <strong>WARNING</strong>: The arguments passed to this method will be
597      freed using the C++ <code>delete</code> and <code>delete[]</code>
598      functions.
599  */
600  virtual void assignProblem(CoinPackedMatrix*& matrix,
601                             double*& collb, double*& colub, double*& obj,
602                             char*& rowsen, double*& rowrhs,
603                             double*& rowrng);
604 
605  /** Just like the other loadProblem() methods except that the matrix is
606      given in a standard column major ordered format (without gaps). */
607  virtual void loadProblem(const int numcols, const int numrows,
608                           const CoinBigIndex * start, const int* index,
609                           const double* value,
610                           const double* collb, const double* colub,   
611                           const double* obj,
612                           const double* rowlb, const double* rowub);
613 
614  /** Just like the other loadProblem() methods except that the matrix is
615      given in a standard column major ordered format (without gaps). */
616  virtual void loadProblem(const int numcols, const int numrows,
617                           const CoinBigIndex * start, const int* index,
618                           const double* value,
619                           const double* collb, const double* colub,   
620                           const double* obj,
621                           const char* rowsen, const double* rowrhs,   
622                           const double* rowrng);
623
624  using OsiSolverInterface::readMps ;
625  /** Read an mps file from the given filename (defaults to Osi reader) - returns
626      number of errors (see OsiMpsReader class) */
627  virtual int readMps(const char *filename,
628                      const char *extension = "mps") ;
629 
630  /** Write the problem into an mps file of the given filename.
631      If objSense is non zero then -1.0 forces the code to write a
632      maximization objective and +1.0 to write a minimization one.
633      If 0.0 then solver can do what it wants */
634  virtual void writeMps(const char *filename,
635                        const char *extension = "mps",
636                        double objSense=0.0) const;
637  /** Write the problem into an mps file of the given filename,
638      names may be null.  formatType is
639      0 - normal
640      1 - extra accuracy
641      2 - IEEE hex (later)
642     
643      Returns non-zero on I/O error
644  */
645  virtual int writeMpsNative(const char *filename, 
646                             const char ** rowNames, const char ** columnNames,
647                             int formatType=0,int numberAcross=2,
648                             double objSense=0.0) const ;
649  //@}
650 
651  /**@name Message handling (extra for Cbc messages).
652     Normally I presume you would want the same language.
653     If not then you could use underlying model pointer */
654  //@{
655  /// Set language
656  void newLanguage(CoinMessages::Language language);
657  void setLanguage(CoinMessages::Language language)
658  {newLanguage(language);}
659  //@}
660  //---------------------------------------------------------------------------
661 
662  /**@name Cbc specific public interfaces */
663  //@{
664  /// Get pointer to Cbc model
665  inline CbcModel * getModelPtr() const 
666  { return modelPtr_;}
667  /// Get pointer to underlying solver
668  inline OsiSolverInterface * getRealSolverPtr() const 
669  { return modelPtr_->solver();}
670  /// Set cutoff bound on the objective function.
671  inline void setCutoff(double value) 
672  { modelPtr_->setCutoff(value);}
673  /// Get the cutoff bound on the objective function - always as minimize
674  inline double getCutoff() const
675  { return modelPtr_->getCutoff();}
676  /// Set the CbcModel::CbcMaxNumNode maximum node limit
677  inline void setMaximumNodes( int value)
678  { modelPtr_->setMaximumNodes(value);}
679  /// Get the CbcModel::CbcMaxNumNode maximum node limit
680  inline int getMaximumNodes() const
681  { return modelPtr_->getMaximumNodes();}
682  /// Set the CbcModel::CbcMaxNumSol maximum number of solutions
683  inline void setMaximumSolutions( int value) 
684  { modelPtr_->setMaximumSolutions(value);}
685  /// Get the CbcModel::CbcMaxNumSol maximum number of solutions
686  inline int getMaximumSolutions() const 
687  { return modelPtr_->getMaximumSolutions();}
688  /// Set the CbcModel::CbcMaximumSeconds maximum number of seconds
689  inline void setMaximumSeconds( double value) 
690  { modelPtr_->setMaximumSeconds(value);}
691  /// Get the CbcModel::CbcMaximumSeconds maximum number of seconds
692  inline double getMaximumSeconds() const 
693  { return modelPtr_->getMaximumSeconds();}
694  /// Node limit reached?
695  inline bool isNodeLimitReached() const
696  { return modelPtr_->isNodeLimitReached();}
697  /// Solution limit reached?
698  inline bool isSolutionLimitReached() const
699  { return modelPtr_->isSolutionLimitReached();}
700  /// Get how many Nodes it took to solve the problem.
701  inline int getNodeCount() const
702  { return modelPtr_->getNodeCount();}
703    /// Final status of problem - 0 finished, 1 stopped, 2 difficulties
704    inline int status() const
705  { return modelPtr_->status();}
706  /** Pass in a message handler
707 
708    It is the client's responsibility to destroy a message handler installed
709    by this routine; it will not be destroyed when the solver interface is
710    destroyed.
711  */
712  virtual void passInMessageHandler(CoinMessageHandler * handler);
713  //@}
714 
715  //---------------------------------------------------------------------------
716 
717  /**@name Constructors and destructors */
718  //@{
719  /// Default Constructor
720  OsiCbcSolverInterface (OsiSolverInterface * solver=NULL,
721                         CbcStrategy * strategy=NULL);
722 
723  /// Clone
724  virtual OsiSolverInterface * clone(bool copyData = true) const;
725 
726  /// Copy constructor
727  OsiCbcSolverInterface (const OsiCbcSolverInterface &);
728#if 0   
729  /// Borrow constructor - only delete one copy
730  OsiCbcSolverInterface (CbcModel * rhs, bool reallyOwn=false);
731 
732  /// Releases so won't error
733  void releaseCbc();
734#endif   
735  /// Assignment operator
736  OsiCbcSolverInterface & operator=(const OsiCbcSolverInterface& rhs);
737 
738  /// Destructor
739  virtual ~OsiCbcSolverInterface ();
740 
741  //@}
742  //---------------------------------------------------------------------------
743 
744protected:
745  ///@name Protected methods
746  //@{
747  /** Apply a row cut (append to constraint matrix). */
748  virtual void applyRowCut(const OsiRowCut& rc);
749 
750  /** Apply a column cut (adjust one or more bounds). */
751  virtual void applyColCut(const OsiColCut& cc);
752  //@}
753  /**@name Protected member data */
754  //@{
755  /// Cbc model represented by this class instance
756  mutable CbcModel * modelPtr_;
757  //@}
758};
759// So unit test can find out if NDEBUG set
760bool OsiCbcHasNDEBUG();
761
762//#############################################################################
763/** A function that tests the methods in the OsiCbcSolverInterface class. The
764    only reason for it not to be a member method is that this way it doesn't
765    have to be compiled into the library. And that's a gain, because the
766    library should be compiled with optimization on, but this method should be
767    compiled with debugging. Also, if this method is compiled with
768    optimization, the compilation takes 10-15 minutes and the machine pages
769    (has 256M core memory!)... */
770int
771OsiCbcSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir);
772
773#endif
Note: See TracBrowser for help on using the repository browser.