CYCLUS
OsiCbcSolverInterface_2_5.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  agentPtr_->solver()->initialSolve();
53 }
54 
55 //-----------------------------------------------------------------------------
57 {
58  agentPtr_->solver()->resolve();
59 }
60 //#############################################################################
61 // Parameter related methods
62 //#############################################################################
63 
64 bool
65 OsiCbcSolverInterface::setIntParam(OsiIntParam key, int value)
66 {
67  return agentPtr_->solver()->setIntParam(key,value);;
68 }
69 
70 //-----------------------------------------------------------------------------
71 
72 bool
73 OsiCbcSolverInterface::setDblParam(OsiDblParam key, double value)
74 {
75  return agentPtr_->solver()->setDblParam(key,value);
76 }
77 
78 //-----------------------------------------------------------------------------
79 
80 bool
81 OsiCbcSolverInterface::setStrParam(OsiStrParam key, const std::string & value)
82 {
83  return agentPtr_->solver()->setStrParam(key,value);
84 }
85 
86 
87 //-----------------------------------------------------------------------------
88 
89 bool
90 OsiCbcSolverInterface::getIntParam(OsiIntParam key, int& value) const
91 {
92  return agentPtr_->solver()->getIntParam(key,value);
93 }
94 
95 //-----------------------------------------------------------------------------
96 
97 bool
98 OsiCbcSolverInterface::getDblParam(OsiDblParam key, double& value) const
99 {
100  return agentPtr_->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  agentPtr_->solver()->getStrParam(key,value2);
111  value = "cbc"+value2;
112  return true;
113  }
114  return agentPtr_->solver()->getStrParam(key,value);
115 }
116 
117 
118 //#############################################################################
119 // Methods returning info on how the solution process terminated
120 //#############################################################################
121 
123 {
124  return agentPtr_->solver()->isAbandoned();
125 }
126 
128 {
129  return agentPtr_->solver()->isProvenOptimal();
130 }
131 
133 {
134  return agentPtr_->solver()->isProvenPrimalInfeasible();
135 }
136 
138 {
139  return agentPtr_->solver()->isProvenDualInfeasible();
140 }
142 {
143  return agentPtr_->solver()->isPrimalObjectiveLimitReached();
144 }
145 
147 {
148  return agentPtr_->solver()->isDualObjectiveLimitReached();
149 }
150 
152 {
153  return agentPtr_->solver()->isIterationLimitReached();
154 }
155 
156 //#############################################################################
157 // WarmStart related methods
158 //#############################################################################
160 {
161  return agentPtr_->solver()->getEmptyWarmStart();
162 }
163 
165 {
166  return agentPtr_->solver()->getWarmStart();
167 }
168 
169 //-----------------------------------------------------------------------------
170 
171 bool OsiCbcSolverInterface::setWarmStart(const CoinWarmStart* warmstart)
172 {
173  return agentPtr_->solver()->setWarmStart(warmstart);
174 }
175 
176 //#############################################################################
177 // Hotstart related methods (primarily used in strong branching)
178 //#############################################################################
179 
181 {
182  agentPtr_->solver()->markHotStart();
183 }
184 
186 {
187  agentPtr_->solver()->solveFromHotStart();
188 }
189 
191 {
192  agentPtr_->solver()->unmarkHotStart();
193 }
194 
195 //#############################################################################
196 // Problem information methods (original data)
197 //#############################################################################
198 
199 //------------------------------------------------------------------
201 {
202  return agentPtr_->solver()->getRowSense();
203 }
204 //------------------------------------------------------------------
206 {
207  return agentPtr_->solver()->getRightHandSide();
208 }
209 //------------------------------------------------------------------
211 {
212  return agentPtr_->solver()->getRowRange();
213 }
214 //------------------------------------------------------------------
215 // Return information on integrality
216 //------------------------------------------------------------------
217 bool OsiCbcSolverInterface::isContinuous(int colNumber) const
218 {
219  return agentPtr_->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 agentPtr_->solver()->getMatrixByRow();
229 }
230 
231 const CoinPackedMatrix * OsiCbcSolverInterface::getMatrixByCol() const
232 {
233  return agentPtr_->solver()->getMatrixByCol();
234 }
235 
236 //------------------------------------------------------------------
237 std::vector<double*> OsiCbcSolverInterface::getDualRays(int maxNumRays) const
238 {
239  return agentPtr_->solver()->getDualRays(maxNumRays);
240 }
241 //------------------------------------------------------------------
242 std::vector<double*> OsiCbcSolverInterface::getPrimalRays(int maxNumRays) const
243 {
244  return agentPtr_->solver()->getPrimalRays(maxNumRays);
245 }
246 //#############################################################################
247 void
249 {
250  agentPtr_->solver()->setContinuous(index);
251 }
252 //-----------------------------------------------------------------------------
253 void
255 {
256  agentPtr_->solver()->setInteger(index);
257 }
258 //-----------------------------------------------------------------------------
259 void
260 OsiCbcSolverInterface::setContinuous(const int* indices, int len)
261 {
262  agentPtr_->solver()->setContinuous(indices,len);
263 }
264 //-----------------------------------------------------------------------------
265 void
266 OsiCbcSolverInterface::setInteger(const int* indices, int len)
267 {
268  agentPtr_->solver()->setInteger(indices,len);
269 }
270 //-----------------------------------------------------------------------------
272 {
273  agentPtr_->solver()->setColSolution(cs);
274 }
275 //-----------------------------------------------------------------------------
276 void OsiCbcSolverInterface::setRowPrice(const double * rs)
277 {
278  agentPtr_->solver()->setRowPrice(rs);
279 }
280 
281 //#############################################################################
282 // Problem modifying methods (matrix)
283 //#############################################################################
284 void
285 OsiCbcSolverInterface::addCol(const CoinPackedVectorBase& vec,
286  const double collb, const double colub,
287  const double obj)
288 {
289  agentPtr_->solver()->addCol(vec,collb,colub,obj);
290 }
291 /* Add a column (primal variable) to the problem. */
292 void
293 OsiCbcSolverInterface::addCol(int numberElements, const int * rows, const double * elements,
294  const double collb, const double colub,
295  const double obj)
296 {
297  agentPtr_->solver()->addCol(numberElements, rows, elements,
298  collb,colub,obj);
299 }
300 //-----------------------------------------------------------------------------
301 void
303  const CoinPackedVectorBase * const * cols,
304  const double* collb, const double* colub,
305  const double* obj)
306 {
307  agentPtr_->solver()->addCols(numcols,cols,collb,colub,obj);
308 }
309 //-----------------------------------------------------------------------------
310 void
311 OsiCbcSolverInterface::deleteCols(const int num, const int * columnIndices)
312 {
313  agentPtr_->solver()->deleteCols(num,columnIndices);
314 }
315 //-----------------------------------------------------------------------------
316 void
317 OsiCbcSolverInterface::addRow(const CoinPackedVectorBase& vec,
318  const double rowlb, const double rowub)
319 {
320  agentPtr_->solver()->addRow(vec,rowlb,rowub);
321 }
322 //-----------------------------------------------------------------------------
323 void
324 OsiCbcSolverInterface::addRow(const CoinPackedVectorBase& vec,
325  const char rowsen, const double rowrhs,
326  const double rowrng)
327 {
328  agentPtr_->solver()->addRow(vec,rowsen,rowrhs,rowrng);
329 }
330 //-----------------------------------------------------------------------------
331 void
333  const CoinPackedVectorBase * const * rows,
334  const double* rowlb, const double* rowub)
335 {
336  agentPtr_->solver()->addRows(numrows,rows,rowlb,rowub);
337 }
338 //-----------------------------------------------------------------------------
339 void
341  const CoinPackedVectorBase * const * rows,
342  const char* rowsen, const double* rowrhs,
343  const double* rowrng)
344 {
345  agentPtr_->solver()->addRows(numrows,rows,rowsen,rowrhs,rowrng);
346 }
347 //-----------------------------------------------------------------------------
348 void
349 OsiCbcSolverInterface::deleteRows(const int num, const int * rowIndices)
350 {
351  agentPtr_->solver()->deleteRows(num,rowIndices);
352 }
353 
354 //#############################################################################
355 // Methods to input a problem
356 //#############################################################################
357 
358 void
359 OsiCbcSolverInterface::loadProblem(const CoinPackedMatrix& matrix,
360  const double* collb, const double* colub,
361  const double* obj,
362  const double* rowlb, const double* rowub)
363 {
364  agentPtr_->solver()->loadProblem(matrix,collb,colub,obj,rowlb,rowub);
365 }
366 
367 //-----------------------------------------------------------------------------
368 
369 void
370 OsiCbcSolverInterface::assignProblem(CoinPackedMatrix*& matrix,
371  double*& collb, double*& colub,
372  double*& obj,
373  double*& rowlb, double*& rowub)
374 {
375  agentPtr_->solver()->assignProblem(matrix,collb,colub,obj,rowlb,rowub);
376 }
377 
378 //-----------------------------------------------------------------------------
379 
380 void
381 OsiCbcSolverInterface::loadProblem(const CoinPackedMatrix& matrix,
382  const double* collb, const double* colub,
383  const double* obj,
384  const char* rowsen, const double* rowrhs,
385  const double* rowrng)
386 {
387  agentPtr_->solver()->loadProblem(matrix,collb,colub,obj,rowsen,rowrhs,rowrng);
388 }
389 
390 //-----------------------------------------------------------------------------
391 
392 void
393 OsiCbcSolverInterface::assignProblem(CoinPackedMatrix*& matrix,
394  double*& collb, double*& colub,
395  double*& obj,
396  char*& rowsen, double*& rowrhs,
397  double*& rowrng)
398 {
399  agentPtr_->solver()->assignProblem(matrix,collb,colub,obj,rowsen,rowrhs,rowrng);
400 }
401 
402 //-----------------------------------------------------------------------------
403 
404 void
405 OsiCbcSolverInterface::loadProblem(const int numcols, const int numrows,
406  const CoinBigIndex * start, const int* index,
407  const double* value,
408  const double* collb, const double* colub,
409  const double* obj,
410  const double* rowlb, const double* rowub)
411 {
412  agentPtr_->solver()->loadProblem(numcols,numrows,start,index,value,
413  collb,colub,obj,rowlb,rowub);
414 }
415 //-----------------------------------------------------------------------------
416 
417 void
418 OsiCbcSolverInterface::loadProblem(const int numcols, const int numrows,
419  const CoinBigIndex * start, const int* index,
420  const double* value,
421  const double* collb, const double* colub,
422  const double* obj,
423  const char* rowsen, const double* rowrhs,
424  const double* rowrng)
425 {
426  agentPtr_->solver()->loadProblem(numcols,numrows,start,index,value,
427  collb,colub,obj,rowsen,rowrhs,rowrng);
428 }
429 
430 //-----------------------------------------------------------------------------
431 // Write mps files
432 //-----------------------------------------------------------------------------
433 
434 void OsiCbcSolverInterface::writeMps(const char * filename,
435  const char * extension,
436  double objSense) const
437 {
438  agentPtr_->solver()->writeMps(filename,extension,objSense);
439 }
440 
441 int
443  const char ** rowNames, const char ** columnNames,
444  int formatType,int numberAcross,double objSense) const
445 {
446  return agentPtr_->solver()->writeMpsNative(filename, rowNames, columnNames,
447  formatType, numberAcross,objSense);
448 }
449 
450 //#############################################################################
451 // Constructors, destructors clone and assignment
452 //#############################################################################
453 //-------------------------------------------------------------------
454 // Default Constructor
455 //-------------------------------------------------------------------
456 OsiCbcSolverInterface::OsiCbcSolverInterface (OsiSolverInterface * solver,
457  CbcStrategy * strategy)
458 :
459 OsiSolverInterface()
460 {
461  if (solver) {
462  agentPtr_=new CbcModel(*solver);
463  } else {
464  OSICBC_DFLT_SOLVER solverDflt;
465  agentPtr_=new CbcModel(solverDflt);
466  }
467  if (strategy) {
468  agentPtr_->setStrategy(*strategy);
469  } else {
470  CbcStrategyDefault defaultStrategy;
471  agentPtr_->setStrategy(defaultStrategy);
472  }
473 }
474 
475 //-------------------------------------------------------------------
476 // Clone
477 //-------------------------------------------------------------------
478 OsiSolverInterface * OsiCbcSolverInterface::clone(bool CopyData) const
479 {
480  if (CopyData) {
481  return new OsiCbcSolverInterface(*this);
482  } else {
483  return new OsiCbcSolverInterface();
484  }
485 }
486 
487 
488 //-------------------------------------------------------------------
489 // Copy constructor
490 //-------------------------------------------------------------------
492  const OsiCbcSolverInterface & rhs)
493 :
494 OsiSolverInterface(rhs)
495 {
496  assert (rhs.agentPtr_);
497  agentPtr_ = new CbcModel(*rhs.agentPtr_);
498 }
499 
500 
501 //-------------------------------------------------------------------
502 // Destructor
503 //-------------------------------------------------------------------
505 {
506  delete agentPtr_;
507 }
508 
509 //-------------------------------------------------------------------
510 // Assignment operator
511 //-------------------------------------------------------------------
514 {
515  if (this != &rhs) {
516  OsiSolverInterface::operator=(rhs);
517  delete agentPtr_;
518  agentPtr_=new CbcModel(*rhs.agentPtr_);
519  }
520  return *this;
521 }
522 
523 //#############################################################################
524 // Applying cuts
525 //#############################################################################
526 
527 void OsiCbcSolverInterface::applyRowCut( const OsiRowCut & rowCut )
528 {
529  agentPtr_->solver()->applyRowCuts(1,&rowCut);
530 }
531 /* Apply a collection of row cuts which are all effective.
532  applyCuts seems to do one at a time which seems inefficient.
533 */
534 void
535 OsiCbcSolverInterface::applyRowCuts(int numberCuts, const OsiRowCut * cuts)
536 {
537  agentPtr_->solver()->applyRowCuts(numberCuts,cuts);
538 }
539 /* Apply a collection of row cuts which are all effective.
540  applyCuts seems to do one at a time which seems inefficient.
541 */
542 void
543 OsiCbcSolverInterface::applyRowCuts(int numberCuts, const OsiRowCut ** cuts)
544 {
545  agentPtr_->solver()->applyRowCuts(numberCuts, cuts);
546 }
547 //-----------------------------------------------------------------------------
548 
549 void OsiCbcSolverInterface::applyColCut( const OsiColCut & cc )
550 {
551  const double * lower = agentPtr_->solver()->getColLower();
552  const double * upper = agentPtr_->solver()->getColUpper();
553  const CoinPackedVector & lbs = cc.lbs();
554  const CoinPackedVector & ubs = cc.ubs();
555  int i;
556 
557  for ( i=0; i<lbs.getNumElements(); i++ ) {
558  int iCol = lbs.getIndices()[i];
559  double value = lbs.getElements()[i];
560  if ( value > lower[iCol] )
561  agentPtr_->solver()->setColLower(iCol, value);
562  }
563  for ( i=0; i<ubs.getNumElements(); i++ ) {
564  int iCol = ubs.getIndices()[i];
565  double value = ubs.getElements()[i];
566  if ( value < upper[iCol] )
567  agentPtr_->solver()->setColUpper(iCol, value);
568  }
569 }
570 /* Read an mps file from the given filename (defaults to Osi reader) - returns
571  number of errors (see OsiMpsReader class) */
572 int
573 OsiCbcSolverInterface::readMps(const char *filename,
574  const char *extension )
575 {
576  return agentPtr_->solver()->readMps(filename,extension);
577 }
578 // Get pointer to array[getNumCols()] of primal solution vector
579 const double *
581 {
582  return agentPtr_->solver()->getColSolution();
583 }
584 
585 // Get pointer to array[getNumRows()] of dual prices
586 const double *
588 {
589  return agentPtr_->solver()->getRowPrice();
590 }
591 
592 // Get a pointer to array[getNumCols()] of reduced costs
593 const double *
595 {
596  return agentPtr_->solver()->getReducedCost();
597 }
598 
599 /* Get pointer to array[getNumRows()] of row activity levels (constraint
600  matrix times the solution vector */
601 const double *
603 {
604  return agentPtr_->solver()->getRowActivity();
605 }
606 double
608 {
609  return agentPtr_->solver()->getObjValue();
610 }
611 
612 /* Set an objective function coefficient */
613 void
614 OsiCbcSolverInterface::setObjCoeff( int elementIndex, double elementValue )
615 {
616  agentPtr_->solver()->setObjCoeff(elementIndex,elementValue);
617 }
618 
619 /* Set a single column lower bound<br>
620  Use -DBL_MAX for -infinity. */
621 void
622 OsiCbcSolverInterface::setColLower( int elementIndex, double elementValue )
623 {
624  agentPtr_->solver()->setColLower(elementIndex,elementValue);
625 }
626 
627 /* Set a single column upper bound<br>
628  Use DBL_MAX for infinity. */
629 void
630 OsiCbcSolverInterface::setColUpper( int elementIndex, double elementValue )
631 {
632  agentPtr_->solver()->setColUpper(elementIndex,elementValue);
633 }
634 
635 /* Set a single column lower and upper bound */
636 void
638  double lower, double upper )
639 {
640  agentPtr_->solver()->setColBounds(elementIndex,lower,upper);
641 }
642 void OsiCbcSolverInterface::setColSetBounds(const int* indexFirst,
643  const int* indexLast,
644  const double* boundList)
645 {
646  agentPtr_->solver()->setColSetBounds(indexFirst,indexLast,boundList);
647 }
648 //------------------------------------------------------------------
649 /* Set a single row lower bound<br>
650  Use -DBL_MAX for -infinity. */
651 void
652 OsiCbcSolverInterface::setRowLower( int elementIndex, double elementValue ) {
653  agentPtr_->solver()->setRowLower(elementIndex,elementValue);
654 }
655 
656 /* Set a single row upper bound<br>
657  Use DBL_MAX for infinity. */
658 void
659 OsiCbcSolverInterface::setRowUpper( int elementIndex, double elementValue ) {
660  agentPtr_->solver()->setRowUpper(elementIndex,elementValue);
661 }
662 
663 /* Set a single row lower and upper bound */
664 void
666  double lower, double upper ) {
667  agentPtr_->solver()->setRowBounds(elementIndex,lower,upper);
668 }
669 //-----------------------------------------------------------------------------
670 void
671 OsiCbcSolverInterface::setRowType(int i, char sense, double rightHandSide,
672  double range)
673 {
674  agentPtr_->solver()->setRowType(i,sense,rightHandSide,range);
675 }
676 //-----------------------------------------------------------------------------
677 void OsiCbcSolverInterface::setRowSetBounds(const int* indexFirst,
678  const int* indexLast,
679  const double* boundList)
680 {
681  agentPtr_->solver()->setRowSetBounds(indexFirst,indexLast,boundList);
682 }
683 //-----------------------------------------------------------------------------
684 void
686  const int* indexLast,
687  const char* senseList,
688  const double* rhsList,
689  const double* rangeList)
690 {
691  agentPtr_->solver()->setRowSetTypes(indexFirst,indexLast,senseList,rhsList,rangeList);
692 }
693 // Set a hint parameter
694 bool
695 OsiCbcSolverInterface::setHintParam(OsiHintParam key, bool yesNo,
696  OsiHintStrength strength,
697  void * otherInformation)
698 {
699  return agentPtr_->solver()->setHintParam(key,yesNo, strength, otherInformation);
700 }
701 
702 // Get a hint parameter
703 bool
704 OsiCbcSolverInterface::getHintParam(OsiHintParam key, bool & yesNo,
705  OsiHintStrength & strength,
706  void *& otherInformation) const
707 {
708  return agentPtr_->solver()->getHintParam(key,yesNo, strength, otherInformation);
709 }
710 
711 // Get a hint parameter
712 bool
713 OsiCbcSolverInterface::getHintParam(OsiHintParam key, bool & yesNo,
714  OsiHintStrength & strength) const
715 {
716  return agentPtr_->solver()->getHintParam(key,yesNo, strength);
717 }
718 
719 
720 int
722 {
723  return agentPtr_->solver()->getNumCols();
724 }
725 int
727 {
728  return agentPtr_->solver()->getNumRows();
729 }
730 int
732 {
733  return agentPtr_->solver()->getNumElements();
734 }
735 const double *
737 {
738  return agentPtr_->solver()->getColLower();
739 }
740 const double *
742 {
743  return agentPtr_->solver()->getColUpper();
744 }
745 const double *
747 {
748  return agentPtr_->solver()->getRowLower();
749 }
750 const double *
752 {
753  return agentPtr_->solver()->getRowUpper();
754 }
755 const double *
757 {
758  return agentPtr_->solver()->getObjCoefficients();
759 }
760 double
762 {
763  return agentPtr_->solver()->getObjSense();
764 }
765 double
767 {
768  return agentPtr_->solver()->getInfinity();
769 }
770 int
772 {
773  return agentPtr_->solver()->getIterationCount();
774 }
775 void
777 {
778  agentPtr_->setObjSense(s);
779 }
780 // Invoke solver's built-in enumeration algorithm
781 void
783 {
784  *messageHandler() << "Warning: Use of OsiCbc is deprecated." << CoinMessageEol;
785  *messageHandler() << "To enjoy the full performance of Cbc, use the CbcSolver interface." << CoinMessageEol;
786  agentPtr_->branchAndBound();
787 }
788 
789 /*
790  Name discipline support -- lh, 070328 --
791 
792  For safety, there's really nothing to it but to pass each call of an impure
793  virtual method on to the underlying solver. Otherwise we just can't know if
794  it's been overridden or not.
795 */
796 
798 OsiCbcSolverInterface::dfltRowColName (char rc, int ndx, unsigned digits) const
799 {
800  return (agentPtr_->solver()->dfltRowColName(rc,ndx,digits)) ;
801 }
802 
804 {
805  return (agentPtr_->solver()->getObjName(maxLen)) ;
806 }
807 
808 std::string OsiCbcSolverInterface::getRowName (int ndx, unsigned maxLen) const
809 {
810  return (agentPtr_->solver()->getRowName(ndx,maxLen)) ;
811 }
812 
813 const OsiSolverInterface::OsiNameVec &OsiCbcSolverInterface::getRowNames ()
814 {
815  return (agentPtr_->solver()->getRowNames()) ;
816 }
817 
818 std::string OsiCbcSolverInterface::getColName (int ndx, unsigned maxLen) const
819 {
820  return (agentPtr_->solver()->getColName(ndx,maxLen)) ;
821 }
822 
823 const OsiSolverInterface::OsiNameVec &OsiCbcSolverInterface::getColNames ()
824 {
825  return (agentPtr_->solver()->getColNames()) ;
826 }
827 
828 void OsiCbcSolverInterface::setRowNames (OsiNameVec &srcNames,
829  int srcStart, int len, int tgtStart)
830 {
831  agentPtr_->solver()->setRowNames(srcNames,srcStart,len,tgtStart) ;
832 }
833 
834 void OsiCbcSolverInterface::deleteRowNames (int tgtStart, int len)
835 {
836  agentPtr_->solver()->deleteRowNames(tgtStart,len) ;
837 }
838 
839 void OsiCbcSolverInterface::setColNames (OsiNameVec &srcNames,
840  int srcStart, int len, int tgtStart)
841 {
842  agentPtr_->solver()->setColNames(srcNames,srcStart,len,tgtStart) ;
843 }
844 
845 void OsiCbcSolverInterface::deleteColNames (int tgtStart, int len)
846 {
847  agentPtr_->solver()->deleteColNames(tgtStart,len) ;
848 }
849 
850 /*
851  These last three are the only functions that would normally be overridden.
852 */
853 
854 /*
855  Set objective function name.
856 */
858 {
859  agentPtr_->solver()->setObjName(name) ;
860 }
861 
862 /*
863  Set a row name, to make sure both the solver and OSI see the same name.
864 */
866 
867 {
868  agentPtr_->solver()->setRowName(ndx,name) ;
869 }
870 
871 /*
872  Set a column name, to make sure both the solver and OSI see the same name.
873 */
875 
876 {
877  agentPtr_->solver()->setColName(ndx,name) ;
878 }
879 // Pass in Message handler (not deleted at end)
880 void
881 OsiCbcSolverInterface::passInMessageHandler(CoinMessageHandler * handler)
882 {
883  OsiSolverInterface::passInMessageHandler(handler);
884  if (agentPtr_)
885  agentPtr_->passInMessageHandler(handler);
886 }
887 // So unit test can find out if NDEBUG set
889 {
890 #ifdef NDEBUG
891  return true;
892 #else
893  return false;
894 #endif
895 }
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.
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.
CbcModel * agentPtr_
Cbc agent represented by this class instance.
virtual void setRowLower(int elementIndex, double elementValue)
Set a single row lower bound Use -DBL_MAX for -infinity.
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.
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.
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,)
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.
virtual const OsiNameVec & getRowNames()
Return a pointer to a vector of row names.
virtual void deleteRowNames(int tgtStart, int len)
Delete len row names starting at index tgtStart.
bool OsiCbcHasNDEBUG()
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...
virtual int getNumElements() const
Get number of nonzero elements.
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.
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.
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.
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 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.
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.
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.
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.
#define OSICBC_DFLT_SOLVER
virtual const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.