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