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 modelPtr_->solver()->initialSolve();
52}
53
54//-----------------------------------------------------------------------------
56 modelPtr_->solver()->resolve();
57}
58// #############################################################################
59// Parameter related methods
60// #############################################################################
61
62bool OsiCbcSolverInterface::setIntParam(OsiIntParam key, int value) {
63 return modelPtr_->solver()->setIntParam(key, value);
64 ;
65}
66
67//-----------------------------------------------------------------------------
68
69bool OsiCbcSolverInterface::setDblParam(OsiDblParam key, double value) {
70 return modelPtr_->solver()->setDblParam(key, value);
71}
72
73//-----------------------------------------------------------------------------
74
76 const std::string& value) {
77 return modelPtr_->solver()->setStrParam(key, value);
78}
79
80//-----------------------------------------------------------------------------
81
82bool OsiCbcSolverInterface::getIntParam(OsiIntParam key, int& value) const {
83 return modelPtr_->solver()->getIntParam(key, value);
84}
85
86//-----------------------------------------------------------------------------
87
88bool OsiCbcSolverInterface::getDblParam(OsiDblParam key, double& value) const {
89 return modelPtr_->solver()->getDblParam(key, value);
90}
91
92//-----------------------------------------------------------------------------
93
95 std::string& value) const {
96 if (key == OsiSolverName) {
97 std::string value2;
98 modelPtr_->solver()->getStrParam(key, value2);
99 value = "cbc" + value2;
100 return true;
101 }
102 return modelPtr_->solver()->getStrParam(key, value);
103}
104
105// #############################################################################
106// Methods returning info on how the solution process terminated
107// #############################################################################
108
110 if (modelPtr_->status() != -1)
111 return modelPtr_->isAbandoned();
112 else
113 return modelPtr_->solver()->isAbandoned();
114}
115
117 if (modelPtr_->status() != -1)
118 return modelPtr_->isProvenOptimal();
119 else
120 return modelPtr_->solver()->isProvenOptimal();
121}
122
124 if (modelPtr_->status() != -1)
125 return modelPtr_->isProvenInfeasible();
126 else
127 return modelPtr_->solver()->isProvenPrimalInfeasible();
128}
129
131 if (modelPtr_->status() != -1)
132 return modelPtr_->isProvenDualInfeasible();
133 else
134 return modelPtr_->solver()->isProvenDualInfeasible();
135}
137 return modelPtr_->solver()->isPrimalObjectiveLimitReached();
138}
139
141 return modelPtr_->solver()->isDualObjectiveLimitReached();
142}
143
145 if (modelPtr_->status() != -1)
146 return modelPtr_->isNodeLimitReached();
147 else
148 return modelPtr_->solver()->isIterationLimitReached();
149}
150
151// #############################################################################
152// WarmStart related methods
153// #############################################################################
155 return modelPtr_->solver()->getEmptyWarmStart();
156}
157
159 return modelPtr_->solver()->getWarmStart();
160}
161
162//-----------------------------------------------------------------------------
163
164bool OsiCbcSolverInterface::setWarmStart(const CoinWarmStart* warmstart) {
165 return modelPtr_->solver()->setWarmStart(warmstart);
166}
167
168// #############################################################################
169// Hotstart related methods (primarily used in strong branching)
170// #############################################################################
171
173 modelPtr_->solver()->markHotStart();
174}
175
177 modelPtr_->solver()->solveFromHotStart();
178}
179
181 modelPtr_->solver()->unmarkHotStart();
182}
183
184// #############################################################################
185// Problem information methods (original data)
186// #############################################################################
187
188//------------------------------------------------------------------
190 return modelPtr_->solver()->getRowSense();
191}
192//------------------------------------------------------------------
194 return modelPtr_->solver()->getRightHandSide();
195}
196//------------------------------------------------------------------
198 return modelPtr_->solver()->getRowRange();
199}
200//------------------------------------------------------------------
201// Return information on integrality
202//------------------------------------------------------------------
203bool OsiCbcSolverInterface::isContinuous(int colNumber) const {
204 return modelPtr_->solver()->isContinuous(colNumber);
205}
206//------------------------------------------------------------------
207
208//------------------------------------------------------------------
209// Row and column copies of the matrix ...
210//------------------------------------------------------------------
211const CoinPackedMatrix* OsiCbcSolverInterface::getMatrixByRow() const {
212 return modelPtr_->solver()->getMatrixByRow();
213}
214
215const CoinPackedMatrix* OsiCbcSolverInterface::getMatrixByCol() const {
216 return modelPtr_->solver()->getMatrixByCol();
217}
218
219//------------------------------------------------------------------
220std::vector<double*> OsiCbcSolverInterface::getDualRays(int maxNumRays,
221 bool fullRay) const {
222 return modelPtr_->solver()->getDualRays(maxNumRays, fullRay);
223}
224//------------------------------------------------------------------
226 int maxNumRays) const {
227 return modelPtr_->solver()->getPrimalRays(maxNumRays);
228}
229// #############################################################################
231 modelPtr_->solver()->setContinuous(index);
232}
233//-----------------------------------------------------------------------------
235 modelPtr_->solver()->setInteger(index);
236}
237//-----------------------------------------------------------------------------
238void OsiCbcSolverInterface::setContinuous(const int* indices, int len) {
239 modelPtr_->solver()->setContinuous(indices, len);
240}
241//-----------------------------------------------------------------------------
242void OsiCbcSolverInterface::setInteger(const int* indices, int len) {
243 modelPtr_->solver()->setInteger(indices, len);
244}
245//-----------------------------------------------------------------------------
247 modelPtr_->solver()->setColSolution(cs);
248}
249//-----------------------------------------------------------------------------
251 modelPtr_->solver()->setRowPrice(rs);
252}
253
254// #############################################################################
255// Problem modifying methods (matrix)
256// #############################################################################
257void OsiCbcSolverInterface::addCol(const CoinPackedVectorBase& vec,
258 const double collb, const double colub,
259 const double obj) {
260 modelPtr_->solver()->addCol(vec, collb, colub, obj);
261}
262/* Add a column (primal variable) to the problem. */
263void OsiCbcSolverInterface::addCol(int numberElements, const int* rows,
264 const double* elements, const double collb,
265 const double colub, const double obj) {
266 modelPtr_->solver()->addCol(numberElements, rows, elements, collb, colub,
267 obj);
268}
269//-----------------------------------------------------------------------------
270void OsiCbcSolverInterface::addCols(const int numcols,
271 const CoinPackedVectorBase* const* cols,
272 const double* collb, const double* colub,
273 const double* obj) {
274 modelPtr_->solver()->addCols(numcols, cols, collb, colub, obj);
275}
276//-----------------------------------------------------------------------------
278 const int* columnIndices) {
279 modelPtr_->solver()->deleteCols(num, columnIndices);
280}
281//-----------------------------------------------------------------------------
282void OsiCbcSolverInterface::addRow(const CoinPackedVectorBase& vec,
283 const double rowlb, const double rowub) {
284 modelPtr_->solver()->addRow(vec, rowlb, rowub);
285}
286//-----------------------------------------------------------------------------
287void OsiCbcSolverInterface::addRow(const CoinPackedVectorBase& vec,
288 const char rowsen, const double rowrhs,
289 const double rowrng) {
290 modelPtr_->solver()->addRow(vec, rowsen, rowrhs, rowrng);
291}
292//-----------------------------------------------------------------------------
293void OsiCbcSolverInterface::addRows(const int numrows,
294 const CoinPackedVectorBase* const* rows,
295 const double* rowlb, const double* rowub) {
296 modelPtr_->solver()->addRows(numrows, rows, rowlb, rowub);
297}
298//-----------------------------------------------------------------------------
299void OsiCbcSolverInterface::addRows(const int numrows,
300 const CoinPackedVectorBase* const* rows,
301 const char* rowsen, const double* rowrhs,
302 const double* rowrng) {
303 modelPtr_->solver()->addRows(numrows, rows, rowsen, rowrhs, rowrng);
304}
305//-----------------------------------------------------------------------------
306void OsiCbcSolverInterface::deleteRows(const int num, const int* rowIndices) {
307 modelPtr_->solver()->deleteRows(num, rowIndices);
308}
309
310// #############################################################################
311// Methods to input a problem
312// #############################################################################
313
314void OsiCbcSolverInterface::loadProblem(const CoinPackedMatrix& matrix,
315 const double* collb,
316 const double* colub, const double* obj,
317 const double* rowlb,
318 const double* rowub) {
319 modelPtr_->solver()->loadProblem(matrix, collb, colub, obj, rowlb, rowub);
320}
321
322//-----------------------------------------------------------------------------
323
324void OsiCbcSolverInterface::assignProblem(CoinPackedMatrix*& matrix,
325 double*& collb, double*& colub,
326 double*& obj, double*& rowlb,
327 double*& rowub) {
328 modelPtr_->solver()->assignProblem(matrix, collb, colub, obj, rowlb, rowub);
329}
330
331//-----------------------------------------------------------------------------
332
333void OsiCbcSolverInterface::loadProblem(const CoinPackedMatrix& matrix,
334 const double* collb,
335 const double* colub, const double* obj,
336 const char* rowsen,
337 const double* rowrhs,
338 const double* rowrng) {
339 modelPtr_->solver()->loadProblem(matrix, collb, colub, obj, rowsen, rowrhs,
340 rowrng);
341}
342
343//-----------------------------------------------------------------------------
344
345void OsiCbcSolverInterface::assignProblem(CoinPackedMatrix*& matrix,
346 double*& collb, double*& colub,
347 double*& obj, char*& rowsen,
348 double*& rowrhs, double*& rowrng) {
349 modelPtr_->solver()->assignProblem(matrix, collb, colub, obj, rowsen, rowrhs,
350 rowrng);
351}
352
353//-----------------------------------------------------------------------------
354
355void OsiCbcSolverInterface::loadProblem(const int numcols, const int numrows,
356 const CoinBigIndex* start,
357 const int* index, const double* value,
358 const double* collb,
359 const double* colub, const double* obj,
360 const double* rowlb,
361 const double* rowub) {
362 modelPtr_->solver()->loadProblem(numcols, numrows, start, index, value, collb,
363 colub, obj, rowlb, rowub);
364}
365//-----------------------------------------------------------------------------
366
368 const int numcols, const int numrows, const CoinBigIndex* start,
369 const int* index, const double* value, const double* collb,
370 const double* colub, const double* obj, const char* rowsen,
371 const double* rowrhs, const double* rowrng) {
372 modelPtr_->solver()->loadProblem(numcols, numrows, start, index, value, collb,
373 colub, obj, rowsen, rowrhs, rowrng);
374}
375
376//-----------------------------------------------------------------------------
377// Write mps files
378//-----------------------------------------------------------------------------
379
380void OsiCbcSolverInterface::writeMps(const char* filename,
381 const char* extension,
382 double objSense) const {
383 modelPtr_->solver()->writeMps(filename, extension, objSense);
384}
385
387 const char** rowNames,
388 const char** columnNames,
389 int formatType, int numberAcross,
390 double objSense) const {
391 return modelPtr_->solver()->writeMpsNative(
392 filename, rowNames, columnNames, formatType, numberAcross, objSense);
393}
394
395// #############################################################################
396// Constructors, destructors clone and assignment
397// #############################################################################
398//-------------------------------------------------------------------
399// Default Constructor
400//-------------------------------------------------------------------
402 CbcStrategy* strategy)
403 : OsiSolverInterface() {
404 if (solver) {
405 modelPtr_ = new CbcModel(*solver);
406 } else {
407 OSICBC_DFLT_SOLVER solverDflt;
408 modelPtr_ = new CbcModel(solverDflt);
409 }
410 if (strategy) {
411 modelPtr_->setStrategy(*strategy);
412 } else {
413 CbcStrategyDefault defaultStrategy;
414 modelPtr_->setStrategy(defaultStrategy);
415 }
416}
417
418//-------------------------------------------------------------------
419// Clone
420//-------------------------------------------------------------------
421OsiSolverInterface* OsiCbcSolverInterface::clone(bool CopyData) const {
422 if (CopyData) {
423 return new OsiCbcSolverInterface(*this);
424 } else {
425 return new OsiCbcSolverInterface();
426 }
427}
428
429//-------------------------------------------------------------------
430// Copy constructor
431//-------------------------------------------------------------------
433 : OsiSolverInterface(rhs) {
434 assert(rhs.modelPtr_);
435 modelPtr_ = new CbcModel(*rhs.modelPtr_);
436}
437
438//-------------------------------------------------------------------
439// Destructor
440//-------------------------------------------------------------------
444
445//-------------------------------------------------------------------
446// Assignment operator
447//-------------------------------------------------------------------
449 const OsiCbcSolverInterface& rhs) {
450 if (this != &rhs) {
451 OsiSolverInterface::operator=(rhs);
452 delete modelPtr_;
453 modelPtr_ = new CbcModel(*rhs.modelPtr_);
454 }
455 return *this;
456}
457
458// #############################################################################
459// Applying cuts
460// #############################################################################
461
462void OsiCbcSolverInterface::applyRowCut(const OsiRowCut& rowCut) {
463 modelPtr_->solver()->applyRowCuts(1, &rowCut);
464}
465/* Apply a collection of row cuts which are all effective.
466 applyCuts seems to do one at a time which seems inefficient.
467*/
469 const OsiRowCut* cuts) {
470 modelPtr_->solver()->applyRowCuts(numberCuts, cuts);
471}
472/* Apply a collection of row cuts which are all effective.
473 applyCuts seems to do one at a time which seems inefficient.
474*/
476 const OsiRowCut** cuts) {
477 modelPtr_->solver()->applyRowCuts(numberCuts, cuts);
478}
479//-----------------------------------------------------------------------------
480
481void OsiCbcSolverInterface::applyColCut(const OsiColCut& cc) {
482 const double* lower = modelPtr_->solver()->getColLower();
483 const double* upper = modelPtr_->solver()->getColUpper();
484 const CoinPackedVector& lbs = cc.lbs();
485 const CoinPackedVector& ubs = cc.ubs();
486 int i;
487
488 for (i = 0; i < lbs.getNumElements(); i++) {
489 int iCol = lbs.getIndices()[i];
490 double value = lbs.getElements()[i];
491 if (value > lower[iCol]) modelPtr_->solver()->setColLower(iCol, value);
492 }
493 for (i = 0; i < ubs.getNumElements(); i++) {
494 int iCol = ubs.getIndices()[i];
495 double value = ubs.getElements()[i];
496 if (value < upper[iCol]) modelPtr_->solver()->setColUpper(iCol, value);
497 }
498}
499/* Read an mps file from the given filename (defaults to Osi reader) - returns
500 number of errors (see OsiMpsReader class) */
501int OsiCbcSolverInterface::readMps(const char* filename,
502 const char* extension) {
503 return modelPtr_->solver()->readMps(filename, extension);
504}
505// Get pointer to array[getNumCols()] of primal solution vector
507 return modelPtr_->solver()->getColSolution();
508}
509
510// Get pointer to array[getNumRows()] of dual prices
512 return modelPtr_->solver()->getRowPrice();
513}
514
515// Get a pointer to array[getNumCols()] of reduced costs
517 return modelPtr_->solver()->getReducedCost();
518}
519
520/* Get pointer to array[getNumRows()] of row activity levels (constraint
521 matrix times the solution vector */
523 return modelPtr_->solver()->getRowActivity();
524}
526 return modelPtr_->solver()->getObjValue();
527}
528
529/* Set an objective function coefficient */
530void OsiCbcSolverInterface::setObjCoeff(int elementIndex, double elementValue) {
531 modelPtr_->solver()->setObjCoeff(elementIndex, elementValue);
532}
533
534/* Set a single column lower bound<br>
535 Use -DBL_MAX for -infinity. */
536void OsiCbcSolverInterface::setColLower(int elementIndex, double elementValue) {
537 modelPtr_->solver()->setColLower(elementIndex, elementValue);
538}
539
540/* Set a single column upper bound<br>
541 Use DBL_MAX for infinity. */
542void OsiCbcSolverInterface::setColUpper(int elementIndex, double elementValue) {
543 modelPtr_->solver()->setColUpper(elementIndex, elementValue);
544}
545
546/* Set a single column lower and upper bound */
547void OsiCbcSolverInterface::setColBounds(int elementIndex, double lower,
548 double upper) {
549 modelPtr_->solver()->setColBounds(elementIndex, lower, upper);
550}
551void OsiCbcSolverInterface::setColSetBounds(const int* indexFirst,
552 const int* indexLast,
553 const double* boundList) {
554 modelPtr_->solver()->setColSetBounds(indexFirst, indexLast, boundList);
555}
556//------------------------------------------------------------------
557/* Set a single row lower bound<br>
558 Use -DBL_MAX for -infinity. */
559void OsiCbcSolverInterface::setRowLower(int elementIndex, double elementValue) {
560 modelPtr_->solver()->setRowLower(elementIndex, elementValue);
561}
562
563/* Set a single row upper bound<br>
564 Use DBL_MAX for infinity. */
565void OsiCbcSolverInterface::setRowUpper(int elementIndex, double elementValue) {
566 modelPtr_->solver()->setRowUpper(elementIndex, elementValue);
567}
568
569/* Set a single row lower and upper bound */
570void OsiCbcSolverInterface::setRowBounds(int elementIndex, double lower,
571 double upper) {
572 modelPtr_->solver()->setRowBounds(elementIndex, lower, upper);
573}
574//-----------------------------------------------------------------------------
575void OsiCbcSolverInterface::setRowType(int i, char sense, double rightHandSide,
576 double range) {
577 modelPtr_->solver()->setRowType(i, sense, rightHandSide, range);
578}
579//-----------------------------------------------------------------------------
580void OsiCbcSolverInterface::setRowSetBounds(const int* indexFirst,
581 const int* indexLast,
582 const double* boundList) {
583 modelPtr_->solver()->setRowSetBounds(indexFirst, indexLast, boundList);
584}
585//-----------------------------------------------------------------------------
586void OsiCbcSolverInterface::setRowSetTypes(const int* indexFirst,
587 const int* indexLast,
588 const char* senseList,
589 const double* rhsList,
590 const double* rangeList) {
591 modelPtr_->solver()->setRowSetTypes(indexFirst, indexLast, senseList, rhsList,
592 rangeList);
593}
594// Set a hint parameter
595bool OsiCbcSolverInterface::setHintParam(OsiHintParam key, bool yesNo,
596 OsiHintStrength strength,
597 void* otherInformation) {
598 return modelPtr_->solver()->setHintParam(key, yesNo, strength,
599 otherInformation);
600}
601
602// Get a hint parameter
603bool OsiCbcSolverInterface::getHintParam(OsiHintParam key, bool& yesNo,
604 OsiHintStrength& strength,
605 void*& otherInformation) const {
606 return modelPtr_->solver()->getHintParam(key, yesNo, strength,
607 otherInformation);
608}
609
610// Get a hint parameter
611bool OsiCbcSolverInterface::getHintParam(OsiHintParam key, bool& yesNo,
612 OsiHintStrength& strength) const {
613 return modelPtr_->solver()->getHintParam(key, yesNo, strength);
614}
615
617 return modelPtr_->solver()->getNumCols();
618}
620 return modelPtr_->solver()->getNumRows();
621}
623 return modelPtr_->solver()->getNumElements();
624}
626 return modelPtr_->solver()->getColLower();
627}
629 return modelPtr_->solver()->getColUpper();
630}
632 return modelPtr_->solver()->getRowLower();
633}
635 return modelPtr_->solver()->getRowUpper();
636}
638 return modelPtr_->solver()->getObjCoefficients();
639}
641 return modelPtr_->solver()->getObjSense();
642}
644 return modelPtr_->solver()->getInfinity();
645}
647 return modelPtr_->solver()->getIterationCount();
648}
650 modelPtr_->setObjSense(s);
651}
652// Invoke solver's built-in enumeration algorithm
654 *messageHandler() << "Warning: Use of OsiCbc is deprecated."
655 << CoinMessageEol;
656 *messageHandler()
657 << "To enjoy the full performance of Cbc, use the CbcSolver interface."
658 << CoinMessageEol;
659 modelPtr_->branchAndBound();
660}
661
662/*
663 Name discipline support -- lh, 070328 --
664
665 For safety, there's really nothing to it but to pass each call of an impure
666 virtual method on to the underlying solver. Otherwise we just can't know if
667 it's been overridden or not.
668*/
669
670std::string OsiCbcSolverInterface::dfltRowColName(char rc, int ndx,
671 unsigned digits) const {
672 return (modelPtr_->solver()->dfltRowColName(rc, ndx, digits));
673}
674
675std::string OsiCbcSolverInterface::getObjName(unsigned maxLen) const {
676 return (modelPtr_->solver()->getObjName(maxLen));
677}
678
679std::string OsiCbcSolverInterface::getRowName(int ndx, unsigned maxLen) const {
680 return (modelPtr_->solver()->getRowName(ndx, maxLen));
681}
682
683const OsiSolverInterface::OsiNameVec& OsiCbcSolverInterface::getRowNames() {
684 return (modelPtr_->solver()->getRowNames());
685}
686
687std::string OsiCbcSolverInterface::getColName(int ndx, unsigned maxLen) const {
688 return (modelPtr_->solver()->getColName(ndx, maxLen));
689}
690
691const OsiSolverInterface::OsiNameVec& OsiCbcSolverInterface::getColNames() {
692 return (modelPtr_->solver()->getColNames());
693}
694
695void OsiCbcSolverInterface::setRowNames(OsiNameVec& srcNames, int srcStart,
696 int len, int tgtStart) {
697 modelPtr_->solver()->setRowNames(srcNames, srcStart, len, tgtStart);
698}
699
700void OsiCbcSolverInterface::deleteRowNames(int tgtStart, int len) {
701 modelPtr_->solver()->deleteRowNames(tgtStart, len);
702}
703
704void OsiCbcSolverInterface::setColNames(OsiNameVec& srcNames, int srcStart,
705 int len, int tgtStart) {
706 modelPtr_->solver()->setColNames(srcNames, srcStart, len, tgtStart);
707}
708
709void OsiCbcSolverInterface::deleteColNames(int tgtStart, int len) {
710 modelPtr_->solver()->deleteColNames(tgtStart, len);
711}
712
713/*
714 These last three are the only functions that would normally be overridden.
715*/
716
717/*
718 Set objective function name.
719*/
720void OsiCbcSolverInterface::setObjName(std::string name) {
721 modelPtr_->solver()->setObjName(name);
722}
723
724/*
725 Set a row name, to make sure both the solver and OSI see the same name.
726*/
727void OsiCbcSolverInterface::setRowName(int ndx, std::string name)
728
729{
730 modelPtr_->solver()->setRowName(ndx, name);
731}
732
733/*
734 Set a column name, to make sure both the solver and OSI see the same name.
735*/
736void OsiCbcSolverInterface::setColName(int ndx, std::string name)
737
738{
739 modelPtr_->solver()->setColName(ndx, name);
740}
741// Pass in Message handler (not deleted at end)
742void OsiCbcSolverInterface::passInMessageHandler(CoinMessageHandler* handler) {
743 OsiSolverInterface::passInMessageHandler(handler);
744 if (modelPtr_) modelPtr_->passInMessageHandler(handler);
745}
746// So unit test can find out if NDEBUG set
748#ifdef NDEBUG
749 return true;
750#else
751 return false;
752#endif
753}
#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.