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