CYCLUS
OsiCbcSolverInterface_2_8.cpp
Go to the documentation of this file.
1 // $Id: OsiCbcSolverInterface.cpp 1902 2013-04-10 16:58:16Z stefan $
2 // Copyright (C) 2002, 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 #include <cassert>
7 
8 #include "OsiConfig.h"
9 #include "CoinTime.hpp"
10 
11 #include "CoinHelperFunctions.hpp"
12 #include "CoinIndexedVector.hpp"
13 
14 /*
15  Default solver configuration: In any environment, clp is the default if you
16  do nothing.
17 
18  The necessary definitions will be handled by the configure script (based on
19  the value specified for --with-osicbc-default-solver) in any environment
20  where configure is available. The results can be found in inc/config_osi.h,
21  which is created during configuration from config_osi.h.in and placed
22  in the build directory.
23 
24  In an environment which does not use configure (MS Visual Studio, for example)
25  the preferred method is to edit the definitions in inc/OsiConfig.h. The
26  symbols are left undefined by default because some older environments (e.g.,
27  MS Visual Studio v7 or earlier) will not accept an #include directive which
28  uses a macro to specify the file. In such an environment, if you want to use
29  a solver other than OsiClp, you'll need to make the changes here.
30 */
31 
32 #ifndef OSICBC_DFLT_SOLVER
33 #define OSICBC_DFLT_SOLVER OsiClpSolverInterface
34 #define OSICBC_CLP_DFLT_SOLVER
35 #include "OsiClpSolverInterface.hpp"
36 #else
37 #include OSICBC_DFLT_SOLVER_HPP
38 #endif
39 
41 #include "OsiCuts.hpp"
42 #include "OsiRowCut.hpp"
43 #include "OsiColCut.hpp"
44 #ifdef OSICBC_CLP_DFLT_SOLVER
45 #include "ClpPresolve.hpp"
46 #endif
47 //#############################################################################
48 // Solve methods
49 //#############################################################################
51 {
52  modelPtr_->solver()->initialSolve();
53 }
54 
55 //-----------------------------------------------------------------------------
57 {
58  modelPtr_->solver()->resolve();
59 }
60 //#############################################################################
61 // Parameter related methods
62 //#############################################################################
63 
64 bool
65 OsiCbcSolverInterface::setIntParam(OsiIntParam key, int value)
66 {
67  return modelPtr_->solver()->setIntParam(key,value);;
68 }
69 
70 //-----------------------------------------------------------------------------
71 
72 bool
73 OsiCbcSolverInterface::setDblParam(OsiDblParam key, double value)
74 {
75  return modelPtr_->solver()->setDblParam(key,value);
76 }
77 
78 //-----------------------------------------------------------------------------
79 
80 bool
81 OsiCbcSolverInterface::setStrParam(OsiStrParam key, const std::string & value)
82 {
83  return modelPtr_->solver()->setStrParam(key,value);
84 }
85 
86 
87 //-----------------------------------------------------------------------------
88 
89 bool
90 OsiCbcSolverInterface::getIntParam(OsiIntParam key, int& value) const
91 {
92  return modelPtr_->solver()->getIntParam(key,value);
93 }
94 
95 //-----------------------------------------------------------------------------
96 
97 bool
98 OsiCbcSolverInterface::getDblParam(OsiDblParam key, double& value) const
99 {
100  return modelPtr_->solver()->getDblParam(key,value);
101 }
102 
103 //-----------------------------------------------------------------------------
104 
105 bool
106 OsiCbcSolverInterface::getStrParam(OsiStrParam key, std::string & value) const
107 {
108  if ( key==OsiSolverName ) {
109  std::string value2;
110  modelPtr_->solver()->getStrParam(key,value2);
111  value = "cbc"+value2;
112  return true;
113  }
114  return modelPtr_->solver()->getStrParam(key,value);
115 }
116 
117 
118 //#############################################################################
119 // Methods returning info on how the solution process terminated
120 //#############################################################################
121 
123 {
124  return modelPtr_->solver()->isAbandoned();
125 }
126 
128 {
129  return modelPtr_->solver()->isProvenOptimal();
130 }
131 
133 {
134  return modelPtr_->solver()->isProvenPrimalInfeasible();
135 }
136 
138 {
139  return modelPtr_->solver()->isProvenDualInfeasible();
140 }
142 {
143  return modelPtr_->solver()->isPrimalObjectiveLimitReached();
144 }
145 
147 {
148  return modelPtr_->solver()->isDualObjectiveLimitReached();
149 }
150 
152 {
153  return modelPtr_->solver()->isIterationLimitReached();
154 }
155 
156 //#############################################################################
157 // WarmStart related methods
158 //#############################################################################
159 CoinWarmStart *OsiCbcSolverInterface::getEmptyWarmStart () const
160 {
161  return modelPtr_->solver()->getEmptyWarmStart();
162 }
163 
164 CoinWarmStart* OsiCbcSolverInterface::getWarmStart() const
165 {
166  return modelPtr_->solver()->getWarmStart();
167 }
168 
169 //-----------------------------------------------------------------------------
170 
171 bool OsiCbcSolverInterface::setWarmStart(const CoinWarmStart* warmstart)
172 {
173  return modelPtr_->solver()->setWarmStart(warmstart);
174 }
175 
176 //#############################################################################
177 // Hotstart related methods (primarily used in strong branching)
178 //#############################################################################
179 
181 {
182  modelPtr_->solver()->markHotStart();
183 }
184 
186 {
187  modelPtr_->solver()->solveFromHotStart();
188 }
189 
191 {
192  modelPtr_->solver()->unmarkHotStart();
193 }
194 
195 //#############################################################################
196 // Problem information methods (original data)
197 //#############################################################################
198 
199 //------------------------------------------------------------------
200 const char * OsiCbcSolverInterface::getRowSense() const
201 {
202  return modelPtr_->solver()->getRowSense();
203 }
204 //------------------------------------------------------------------
205 const double * OsiCbcSolverInterface::getRightHandSide() const
206 {
207  return modelPtr_->solver()->getRightHandSide();
208 }
209 //------------------------------------------------------------------
210 const double * OsiCbcSolverInterface::getRowRange() const
211 {
212  return modelPtr_->solver()->getRowRange();
213 }
214 //------------------------------------------------------------------
215 // Return information on integrality
216 //------------------------------------------------------------------
217 bool OsiCbcSolverInterface::isContinuous(int colNumber) const
218 {
219  return modelPtr_->solver()->isContinuous(colNumber);
220 }
221 //------------------------------------------------------------------
222 
223 //------------------------------------------------------------------
224 // Row and column copies of the matrix ...
225 //------------------------------------------------------------------
226 const CoinPackedMatrix * OsiCbcSolverInterface::getMatrixByRow() const
227 {
228  return modelPtr_->solver()->getMatrixByRow();
229 }
230 
231 const CoinPackedMatrix * OsiCbcSolverInterface::getMatrixByCol() const
232 {
233  return modelPtr_->solver()->getMatrixByCol();
234 }
235 
236 //------------------------------------------------------------------
237 std::vector<double*> OsiCbcSolverInterface::getDualRays(int maxNumRays,
238  bool fullRay) const
239 {
240  return modelPtr_->solver()->getDualRays(maxNumRays,fullRay);
241 }
242 //------------------------------------------------------------------
243 std::vector<double*> OsiCbcSolverInterface::getPrimalRays(int maxNumRays) const
244 {
245  return modelPtr_->solver()->getPrimalRays(maxNumRays);
246 }
247 //#############################################################################
248 void
250 {
251  modelPtr_->solver()->setContinuous(index);
252 }
253 //-----------------------------------------------------------------------------
254 void
256 {
257  modelPtr_->solver()->setInteger(index);
258 }
259 //-----------------------------------------------------------------------------
260 void
261 OsiCbcSolverInterface::setContinuous(const int* indices, int len)
262 {
263  modelPtr_->solver()->setContinuous(indices,len);
264 }
265 //-----------------------------------------------------------------------------
266 void
267 OsiCbcSolverInterface::setInteger(const int* indices, int len)
268 {
269  modelPtr_->solver()->setInteger(indices,len);
270 }
271 //-----------------------------------------------------------------------------
272 void OsiCbcSolverInterface::setColSolution(const double * cs)
273 {
274  modelPtr_->solver()->setColSolution(cs);
275 }
276 //-----------------------------------------------------------------------------
277 void OsiCbcSolverInterface::setRowPrice(const double * rs)
278 {
279  modelPtr_->solver()->setRowPrice(rs);
280 }
281 
282 //#############################################################################
283 // Problem modifying methods (matrix)
284 //#############################################################################
285 void
286 OsiCbcSolverInterface::addCol(const CoinPackedVectorBase& vec,
287  const double collb, const double colub,
288  const double obj)
289 {
290  modelPtr_->solver()->addCol(vec,collb,colub,obj);
291 }
292 /* Add a column (primal variable) to the problem. */
293 void
294 OsiCbcSolverInterface::addCol(int numberElements, const int * rows, const double * elements,
295  const double collb, const double colub,
296  const double obj)
297 {
298  modelPtr_->solver()->addCol(numberElements, rows, elements,
299  collb,colub,obj);
300 }
301 //-----------------------------------------------------------------------------
302 void
303 OsiCbcSolverInterface::addCols(const int numcols,
304  const CoinPackedVectorBase * const * cols,
305  const double* collb, const double* colub,
306  const double* obj)
307 {
308  modelPtr_->solver()->addCols(numcols,cols,collb,colub,obj);
309 }
310 //-----------------------------------------------------------------------------
311 void
312 OsiCbcSolverInterface::deleteCols(const int num, const int * columnIndices)
313 {
314  modelPtr_->solver()->deleteCols(num,columnIndices);
315 }
316 //-----------------------------------------------------------------------------
317 void
318 OsiCbcSolverInterface::addRow(const CoinPackedVectorBase& vec,
319  const double rowlb, const double rowub)
320 {
321  modelPtr_->solver()->addRow(vec,rowlb,rowub);
322 }
323 //-----------------------------------------------------------------------------
324 void
325 OsiCbcSolverInterface::addRow(const CoinPackedVectorBase& vec,
326  const char rowsen, const double rowrhs,
327  const double rowrng)
328 {
329  modelPtr_->solver()->addRow(vec,rowsen,rowrhs,rowrng);
330 }
331 //-----------------------------------------------------------------------------
332 void
333 OsiCbcSolverInterface::addRows(const int numrows,
334  const CoinPackedVectorBase * const * rows,
335  const double* rowlb, const double* rowub)
336 {
337  modelPtr_->solver()->addRows(numrows,rows,rowlb,rowub);
338 }
339 //-----------------------------------------------------------------------------
340 void
341 OsiCbcSolverInterface::addRows(const int numrows,
342  const CoinPackedVectorBase * const * rows,
343  const char* rowsen, const double* rowrhs,
344  const double* rowrng)
345 {
346  modelPtr_->solver()->addRows(numrows,rows,rowsen,rowrhs,rowrng);
347 }
348 //-----------------------------------------------------------------------------
349 void
350 OsiCbcSolverInterface::deleteRows(const int num, const int * rowIndices)
351 {
352  modelPtr_->solver()->deleteRows(num,rowIndices);
353 }
354 
355 //#############################################################################
356 // Methods to input a problem
357 //#############################################################################
358 
359 void
360 OsiCbcSolverInterface::loadProblem(const CoinPackedMatrix& matrix,
361  const double* collb, const double* colub,
362  const double* obj,
363  const double* rowlb, const double* rowub)
364 {
365  modelPtr_->solver()->loadProblem(matrix,collb,colub,obj,rowlb,rowub);
366 }
367 
368 //-----------------------------------------------------------------------------
369 
370 void
371 OsiCbcSolverInterface::assignProblem(CoinPackedMatrix*& matrix,
372  double*& collb, double*& colub,
373  double*& obj,
374  double*& rowlb, double*& rowub)
375 {
376  modelPtr_->solver()->assignProblem(matrix,collb,colub,obj,rowlb,rowub);
377 }
378 
379 //-----------------------------------------------------------------------------
380 
381 void
382 OsiCbcSolverInterface::loadProblem(const CoinPackedMatrix& matrix,
383  const double* collb, const double* colub,
384  const double* obj,
385  const char* rowsen, const double* rowrhs,
386  const double* rowrng)
387 {
388  modelPtr_->solver()->loadProblem(matrix,collb,colub,obj,rowsen,rowrhs,rowrng);
389 }
390 
391 //-----------------------------------------------------------------------------
392 
393 void
394 OsiCbcSolverInterface::assignProblem(CoinPackedMatrix*& matrix,
395  double*& collb, double*& colub,
396  double*& obj,
397  char*& rowsen, double*& rowrhs,
398  double*& rowrng)
399 {
400  modelPtr_->solver()->assignProblem(matrix,collb,colub,obj,rowsen,rowrhs,rowrng);
401 }
402 
403 //-----------------------------------------------------------------------------
404 
405 void
406 OsiCbcSolverInterface::loadProblem(const int numcols, const int numrows,
407  const CoinBigIndex * start, const int* index,
408  const double* value,
409  const double* collb, const double* colub,
410  const double* obj,
411  const double* rowlb, const double* rowub)
412 {
413  modelPtr_->solver()->loadProblem(numcols,numrows,start,index,value,
414  collb,colub,obj,rowlb,rowub);
415 }
416 //-----------------------------------------------------------------------------
417 
418 void
419 OsiCbcSolverInterface::loadProblem(const int numcols, const int numrows,
420  const CoinBigIndex * start, const int* index,
421  const double* value,
422  const double* collb, const double* colub,
423  const double* obj,
424  const char* rowsen, const double* rowrhs,
425  const double* rowrng)
426 {
427  modelPtr_->solver()->loadProblem(numcols,numrows,start,index,value,
428  collb,colub,obj,rowsen,rowrhs,rowrng);
429 }
430 
431 //-----------------------------------------------------------------------------
432 // Write mps files
433 //-----------------------------------------------------------------------------
434 
435 void OsiCbcSolverInterface::writeMps(const char * filename,
436  const char * extension,
437  double objSense) const
438 {
439  modelPtr_->solver()->writeMps(filename,extension,objSense);
440 }
441 
442 int
443 OsiCbcSolverInterface::writeMpsNative(const char *filename,
444  const char ** rowNames, const char ** columnNames,
445  int formatType,int numberAcross,double objSense) const
446 {
447  return modelPtr_->solver()->writeMpsNative(filename, rowNames, columnNames,
448  formatType, numberAcross,objSense);
449 }
450 
451 //#############################################################################
452 // Constructors, destructors clone and assignment
453 //#############################################################################
454 //-------------------------------------------------------------------
455 // Default Constructor
456 //-------------------------------------------------------------------
457 OsiCbcSolverInterface::OsiCbcSolverInterface (OsiSolverInterface * solver,
458  CbcStrategy * strategy)
459 :
460 OsiSolverInterface()
461 {
462  if (solver) {
463  modelPtr_=new CbcModel(*solver);
464  } else {
465  OSICBC_DFLT_SOLVER solverDflt;
466  modelPtr_=new CbcModel(solverDflt);
467  }
468  if (strategy) {
469  modelPtr_->setStrategy(*strategy);
470  } else {
471  CbcStrategyDefault defaultStrategy;
472  modelPtr_->setStrategy(defaultStrategy);
473  }
474 }
475 
476 //-------------------------------------------------------------------
477 // Clone
478 //-------------------------------------------------------------------
479 OsiSolverInterface * OsiCbcSolverInterface::clone(bool CopyData) const
480 {
481  if (CopyData) {
482  return new OsiCbcSolverInterface(*this);
483  } else {
484  return new OsiCbcSolverInterface();
485  }
486 }
487 
488 
489 //-------------------------------------------------------------------
490 // Copy constructor
491 //-------------------------------------------------------------------
493  const OsiCbcSolverInterface & rhs)
494 :
495 OsiSolverInterface(rhs)
496 {
497  assert (rhs.modelPtr_);
498  modelPtr_ = new CbcModel(*rhs.modelPtr_);
499 }
500 
501 
502 //-------------------------------------------------------------------
503 // Destructor
504 //-------------------------------------------------------------------
506 {
507  delete modelPtr_;
508 }
509 
510 //-------------------------------------------------------------------
511 // Assignment operator
512 //-------------------------------------------------------------------
515 {
516  if (this != &rhs) {
517  OsiSolverInterface::operator=(rhs);
518  delete modelPtr_;
519  modelPtr_=new CbcModel(*rhs.modelPtr_);
520  }
521  return *this;
522 }
523 
524 //#############################################################################
525 // Applying cuts
526 //#############################################################################
527 
528 void OsiCbcSolverInterface::applyRowCut( const OsiRowCut & rowCut )
529 {
530  modelPtr_->solver()->applyRowCuts(1,&rowCut);
531 }
532 /* Apply a collection of row cuts which are all effective.
533  applyCuts seems to do one at a time which seems inefficient.
534 */
535 void
536 OsiCbcSolverInterface::applyRowCuts(int numberCuts, const OsiRowCut * cuts)
537 {
538  modelPtr_->solver()->applyRowCuts(numberCuts,cuts);
539 }
540 /* Apply a collection of row cuts which are all effective.
541  applyCuts seems to do one at a time which seems inefficient.
542 */
543 void
544 OsiCbcSolverInterface::applyRowCuts(int numberCuts, const OsiRowCut ** cuts)
545 {
546  modelPtr_->solver()->applyRowCuts(numberCuts, cuts);
547 }
548 //-----------------------------------------------------------------------------
549 
550 void OsiCbcSolverInterface::applyColCut( const OsiColCut & cc )
551 {
552  const double * lower = modelPtr_->solver()->getColLower();
553  const double * upper = modelPtr_->solver()->getColUpper();
554  const CoinPackedVector & lbs = cc.lbs();
555  const CoinPackedVector & ubs = cc.ubs();
556  int i;
557 
558  for ( i=0; i<lbs.getNumElements(); i++ ) {
559  int iCol = lbs.getIndices()[i];
560  double value = lbs.getElements()[i];
561  if ( value > lower[iCol] )
562  modelPtr_->solver()->setColLower(iCol, value);
563  }
564  for ( i=0; i<ubs.getNumElements(); i++ ) {
565  int iCol = ubs.getIndices()[i];
566  double value = ubs.getElements()[i];
567  if ( value < upper[iCol] )
568  modelPtr_->solver()->setColUpper(iCol, value);
569  }
570 }
571 /* Read an mps file from the given filename (defaults to Osi reader) - returns
572  number of errors (see OsiMpsReader class) */
573 int
574 OsiCbcSolverInterface::readMps(const char *filename,
575  const char *extension )
576 {
577  return modelPtr_->solver()->readMps(filename,extension);
578 }
579 // Get pointer to array[getNumCols()] of primal solution vector
580 const double *
582 {
583  return modelPtr_->solver()->getColSolution();
584 }
585 
586 // Get pointer to array[getNumRows()] of dual prices
587 const double *
589 {
590  return modelPtr_->solver()->getRowPrice();
591 }
592 
593 // Get a pointer to array[getNumCols()] of reduced costs
594 const double *
596 {
597  return modelPtr_->solver()->getReducedCost();
598 }
599 
600 /* Get pointer to array[getNumRows()] of row activity levels (constraint
601  matrix times the solution vector */
602 const double *
604 {
605  return modelPtr_->solver()->getRowActivity();
606 }
607 double
609 {
610  return modelPtr_->solver()->getObjValue();
611 }
612 
613 /* Set an objective function coefficient */
614 void
615 OsiCbcSolverInterface::setObjCoeff( int elementIndex, double elementValue )
616 {
617  modelPtr_->solver()->setObjCoeff(elementIndex,elementValue);
618 }
619 
620 /* Set a single column lower bound<br>
621  Use -DBL_MAX for -infinity. */
622 void
623 OsiCbcSolverInterface::setColLower( int elementIndex, double elementValue )
624 {
625  modelPtr_->solver()->setColLower(elementIndex,elementValue);
626 }
627 
628 /* Set a single column upper bound<br>
629  Use DBL_MAX for infinity. */
630 void
631 OsiCbcSolverInterface::setColUpper( int elementIndex, double elementValue )
632 {
633  modelPtr_->solver()->setColUpper(elementIndex,elementValue);
634 }
635 
636 /* Set a single column lower and upper bound */
637 void
638 OsiCbcSolverInterface::setColBounds( int elementIndex,
639  double lower, double upper )
640 {
641  modelPtr_->solver()->setColBounds(elementIndex,lower,upper);
642 }
643 void OsiCbcSolverInterface::setColSetBounds(const int* indexFirst,
644  const int* indexLast,
645  const double* boundList)
646 {
647  modelPtr_->solver()->setColSetBounds(indexFirst,indexLast,boundList);
648 }
649 //------------------------------------------------------------------
650 /* Set a single row lower bound<br>
651  Use -DBL_MAX for -infinity. */
652 void
653 OsiCbcSolverInterface::setRowLower( int elementIndex, double elementValue ) {
654  modelPtr_->solver()->setRowLower(elementIndex,elementValue);
655 }
656 
657 /* Set a single row upper bound<br>
658  Use DBL_MAX for infinity. */
659 void
660 OsiCbcSolverInterface::setRowUpper( int elementIndex, double elementValue ) {
661  modelPtr_->solver()->setRowUpper(elementIndex,elementValue);
662 }
663 
664 /* Set a single row lower and upper bound */
665 void
666 OsiCbcSolverInterface::setRowBounds( int elementIndex,
667  double lower, double upper ) {
668  modelPtr_->solver()->setRowBounds(elementIndex,lower,upper);
669 }
670 //-----------------------------------------------------------------------------
671 void
672 OsiCbcSolverInterface::setRowType(int i, char sense, double rightHandSide,
673  double range)
674 {
675  modelPtr_->solver()->setRowType(i,sense,rightHandSide,range);
676 }
677 //-----------------------------------------------------------------------------
678 void OsiCbcSolverInterface::setRowSetBounds(const int* indexFirst,
679  const int* indexLast,
680  const double* boundList)
681 {
682  modelPtr_->solver()->setRowSetBounds(indexFirst,indexLast,boundList);
683 }
684 //-----------------------------------------------------------------------------
685 void
686 OsiCbcSolverInterface::setRowSetTypes(const int* indexFirst,
687  const int* indexLast,
688  const char* senseList,
689  const double* rhsList,
690  const double* rangeList)
691 {
692  modelPtr_->solver()->setRowSetTypes(indexFirst,indexLast,senseList,rhsList,rangeList);
693 }
694 // Set a hint parameter
695 bool
696 OsiCbcSolverInterface::setHintParam(OsiHintParam key, bool yesNo,
697  OsiHintStrength strength,
698  void * otherInformation)
699 {
700  return modelPtr_->solver()->setHintParam(key,yesNo, strength, otherInformation);
701 }
702 
703 // Get a hint parameter
704 bool
705 OsiCbcSolverInterface::getHintParam(OsiHintParam key, bool & yesNo,
706  OsiHintStrength & strength,
707  void *& otherInformation) const
708 {
709  return modelPtr_->solver()->getHintParam(key,yesNo, strength, otherInformation);
710 }
711 
712 // Get a hint parameter
713 bool
714 OsiCbcSolverInterface::getHintParam(OsiHintParam key, bool & yesNo,
715  OsiHintStrength & strength) const
716 {
717  return modelPtr_->solver()->getHintParam(key,yesNo, strength);
718 }
719 
720 
721 int
723 {
724  return modelPtr_->solver()->getNumCols();
725 }
726 int
728 {
729  return modelPtr_->solver()->getNumRows();
730 }
731 int
733 {
734  return modelPtr_->solver()->getNumElements();
735 }
736 const double *
738 {
739  return modelPtr_->solver()->getColLower();
740 }
741 const double *
743 {
744  return modelPtr_->solver()->getColUpper();
745 }
746 const double *
748 {
749  return modelPtr_->solver()->getRowLower();
750 }
751 const double *
753 {
754  return modelPtr_->solver()->getRowUpper();
755 }
756 const double *
758 {
759  return modelPtr_->solver()->getObjCoefficients();
760 }
761 double
763 {
764  return modelPtr_->solver()->getObjSense();
765 }
766 double
768 {
769  return modelPtr_->solver()->getInfinity();
770 }
771 int
773 {
774  return modelPtr_->solver()->getIterationCount();
775 }
776 void
778 {
779  modelPtr_->setObjSense(s);
780 }
781 // Invoke solver's built-in enumeration algorithm
782 void
784 {
785  *messageHandler() << "Warning: Use of OsiCbc is deprecated." << CoinMessageEol;
786  *messageHandler() << "To enjoy the full performance of Cbc, use the CbcSolver interface." << CoinMessageEol;
787  modelPtr_->branchAndBound();
788 }
789 
790 /*
791  Name discipline support -- lh, 070328 --
792 
793  For safety, there's really nothing to it but to pass each call of an impure
794  virtual method on to the underlying solver. Otherwise we just can't know if
795  it's been overridden or not.
796 */
797 
798 std::string
799 OsiCbcSolverInterface::dfltRowColName (char rc, int ndx, unsigned digits) const
800 {
801  return (modelPtr_->solver()->dfltRowColName(rc,ndx,digits)) ;
802 }
803 
804 std::string OsiCbcSolverInterface::getObjName (unsigned maxLen) const
805 {
806  return (modelPtr_->solver()->getObjName(maxLen)) ;
807 }
808 
809 std::string OsiCbcSolverInterface::getRowName (int ndx, unsigned maxLen) const
810 {
811  return (modelPtr_->solver()->getRowName(ndx,maxLen)) ;
812 }
813 
814 const OsiSolverInterface::OsiNameVec &OsiCbcSolverInterface::getRowNames ()
815 {
816  return (modelPtr_->solver()->getRowNames()) ;
817 }
818 
819 std::string OsiCbcSolverInterface::getColName (int ndx, unsigned maxLen) const
820 {
821  return (modelPtr_->solver()->getColName(ndx,maxLen)) ;
822 }
823 
824 const OsiSolverInterface::OsiNameVec &OsiCbcSolverInterface::getColNames ()
825 {
826  return (modelPtr_->solver()->getColNames()) ;
827 }
828 
829 void OsiCbcSolverInterface::setRowNames (OsiNameVec &srcNames,
830  int srcStart, int len, int tgtStart)
831 {
832  modelPtr_->solver()->setRowNames(srcNames,srcStart,len,tgtStart) ;
833 }
834 
835 void OsiCbcSolverInterface::deleteRowNames (int tgtStart, int len)
836 {
837  modelPtr_->solver()->deleteRowNames(tgtStart,len) ;
838 }
839 
840 void OsiCbcSolverInterface::setColNames (OsiNameVec &srcNames,
841  int srcStart, int len, int tgtStart)
842 {
843  modelPtr_->solver()->setColNames(srcNames,srcStart,len,tgtStart) ;
844 }
845 
846 void OsiCbcSolverInterface::deleteColNames (int tgtStart, int len)
847 {
848  modelPtr_->solver()->deleteColNames(tgtStart,len) ;
849 }
850 
851 /*
852  These last three are the only functions that would normally be overridden.
853 */
854 
855 /*
856  Set objective function name.
857 */
858 void OsiCbcSolverInterface::setObjName (std::string name)
859 {
860  modelPtr_->solver()->setObjName(name) ;
861 }
862 
863 /*
864  Set a row name, to make sure both the solver and OSI see the same name.
865 */
866 void OsiCbcSolverInterface::setRowName (int ndx, std::string name)
867 
868 {
869  modelPtr_->solver()->setRowName(ndx,name) ;
870 }
871 
872 /*
873  Set a column name, to make sure both the solver and OSI see the same name.
874 */
875 void OsiCbcSolverInterface::setColName (int ndx, std::string name)
876 
877 {
878  modelPtr_->solver()->setColName(ndx,name) ;
879 }
880 // Pass in Message handler (not deleted at end)
881 void
882 OsiCbcSolverInterface::passInMessageHandler(CoinMessageHandler * handler)
883 {
884  OsiSolverInterface::passInMessageHandler(handler);
885  if (modelPtr_)
886  modelPtr_->passInMessageHandler(handler);
887 }
888 // So unit test can find out if NDEBUG set
890 {
891 #ifdef NDEBUG
892  return true;
893 #else
894  return false;
895 #endif
896 }
bool getIntParam(OsiIntParam key, int &value) const
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 CoinWarmStart * getWarmStart() const
Get warmstarting information.
virtual double getObjSense() const
Get objective function sense (1 for min (default), -1 for max)
virtual void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound Use DBL_MAX for infinity.
virtual const double * getRightHandSide() const
Get pointer to array[getNumRows()] of rows right-hand sides.
virtual void resolve()
Resolve an LP relaxation after problem modification.
#define OSICBC_DFLT_SOLVER
virtual bool isPrimalObjectiveLimitReached() const
Is the given primal objective limit reached?
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.
virtual double getInfinity() const
Get solver&#39;s value for infinity.
virtual int getNumCols() const
Get number of columns.
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 bool isContinuous(int colNumber) const
Return true if column is continuous.
virtual bool isAbandoned() const
Are there a numerical difficulties?
virtual void addRows(const int numrows, const CoinPackedVectorBase *const *rows, const double *rowlb, const double *rowub)
virtual std::vector< double * > getDualRays(int maxNumRays) const
Get as many dual rays as the solver can provide.
virtual const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
virtual void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)
virtual void deleteCols(const int num, const int *colIndices)
virtual bool isProvenDualInfeasible() const
Is dual infeasiblity proven?
virtual std::string getColName(int colIndex, unsigned maxLen=std::string::npos) const
Return the name of the column.
virtual void markHotStart()
Create a hotstart point of the optimization process.
virtual const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
virtual bool setHintParam(OsiHintParam key, bool yesNo=true, OsiHintStrength strength=OsiHintTry, void *otherInformation=NULL)
virtual void initialSolve()
Solve initial LP relaxation.
virtual void setColBounds(int elementIndex, double lower, double upper)
Set a single column lower and upper bound.
virtual bool isIterationLimitReached() const
Iteration limit reached?
virtual void passInMessageHandler(CoinMessageHandler *handler)
Pass in a message handler.
virtual void setRowPrice(const double *rowprice)
Set dual solution vector.
virtual std::string getObjName(unsigned maxLen=std::string::npos) const
Return the name of the objective function.
virtual const double * getRowActivity() const
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vecto...
virtual void setRowType(int index, char sense, double rightHandSide, double range)
Set the type of a single row
virtual std::vector< double * > getPrimalRays(int maxNumRays) const
Get as many primal rays as the solver can provide.
std::string name(int nuc)
Definition: pyne.cc:2940
virtual const double * getRowPrice() const
Get pointer to array[getNumRows()] of dual prices.
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,)
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)
virtual CoinWarmStart * getEmptyWarmStart() const
Get an empty warm start object.
virtual const char * getRowSense() const
Get pointer to array[getNumRows()] of row constraint senses.
virtual const double * getReducedCost() const
Get a pointer to array[getNumCols()] of reduced costs.
virtual const OsiNameVec & getRowNames()
Return a pointer to a vector of row names.
virtual int getNumRows() const
Get number of rows.
virtual void deleteRowNames(int tgtStart, int len)
Delete len row names starting at index tgtStart.
virtual int getNumElements() const
Get number of nonzero elements.
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...
virtual bool isProvenPrimalInfeasible() const
Is primal infeasiblity proven?
virtual std::string getRowName(int rowIndex, unsigned maxLen=std::string::npos) const
Return the name of the row.
virtual void applyRowCut(const OsiRowCut &rc)
Apply a row cut (append to constraint matrix).
bool OsiCbcHasNDEBUG()
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 void applyColCut(const OsiColCut &cc)
Apply a column cut (adjust one or more bounds).
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
virtual const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of matrix.
virtual double getObjValue() const
Get objective function value.
virtual ~OsiCbcSolverInterface()
Destructor.
bool setStrParam(OsiStrParam key, const std::string &value)
virtual void solveFromHotStart()
Optimize starting from the hotstart.
virtual const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
virtual void deleteColNames(int tgtStart, int len)
Delete len column names starting at index tgtStart.
virtual bool isDualObjectiveLimitReached() const
Is the given dual objective limit reached?
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...
bool getStrParam(OsiStrParam key, std::string &value) const
OsiCbcSolverInterface(OsiSolverInterface *solver=NULL, CbcStrategy *strategy=NULL)
Default Constructor.
virtual bool setWarmStart(const CoinWarmStart *warmstart)
Set warmstarting information.
virtual void branchAndBound()
Invoke solver&#39;s built-in enumeration algorithm.
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.
virtual OsiSolverInterface * clone(bool copyData=true) const
Clone.
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...
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 void addCols(const int numcols, const CoinPackedVectorBase *const *cols, const double *collb, const double *colub, const double *obj)
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 const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
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 void setRowUpper(int elementIndex, double elementValue)
Set a single row upper bound Use DBL_MAX for infinity.
virtual std::string dfltRowColName(char rc, int ndx, unsigned digits=7) const
Generate a standard name of the form Rnnnnnnn or Cnnnnnnn.
bool setIntParam(OsiIntParam key, int value)
virtual bool isProvenOptimal() const
Is optimality proven?
virtual void unmarkHotStart()
Delete the snapshot.
virtual void setObjCoeff(int elementIndex, double elementValue)
Set an objective function coefficient.
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.
virtual void setColName(int ndx, std::string name)
Set a column name.
virtual void setInteger(int index)
Set the index-th variable to be an integer variable.
virtual const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
bool getDblParam(OsiDblParam key, double &value) const
virtual int getIterationCount() const
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver...
virtual const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of matrix.
OsiCbcSolverInterface & operator=(const OsiCbcSolverInterface &rhs)
Assignment operator.
bool setDblParam(OsiDblParam key, double value)
virtual void setContinuous(int index)
Set the index-th variable to be a continuous variable.
virtual const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.