source: trunk/Cbc/src/OsiCbc/OsiCbcSolverInterface.cpp

Last change on this file was 2531, checked in by stefan, 7 months ago

fix some serious warnings, closes #197

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