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

Last change on this file since 2083 was 2083, checked in by forrest, 4 years ago

modify is... meanings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.4 KB
Line 
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
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
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
122bool OsiCbcSolverInterface::isAbandoned() const
123{
124  if (modelPtr_->status()!=-1)
125    return modelPtr_->isAbandoned();
126  else
127    return modelPtr_->solver()->isAbandoned();
128}
129
130bool OsiCbcSolverInterface::isProvenOptimal() const
131{
132  if (modelPtr_->status()!=-1)
133    return modelPtr_->isProvenOptimal();
134  else
135    return modelPtr_->solver()->isProvenOptimal();
136}
137
138bool OsiCbcSolverInterface::isProvenPrimalInfeasible() const
139{
140  if (modelPtr_->status()!=-1)
141    return modelPtr_->isProvenInfeasible();
142  else
143    return modelPtr_->solver()->isProvenPrimalInfeasible();
144}
145
146bool OsiCbcSolverInterface::isProvenDualInfeasible() const
147{
148  if (modelPtr_->status()!=-1)
149  return modelPtr_->isProvenDualInfeasible();
150  else
151  return modelPtr_->solver()->isProvenDualInfeasible();
152}
153bool OsiCbcSolverInterface::isPrimalObjectiveLimitReached() const
154{
155  return modelPtr_->solver()->isPrimalObjectiveLimitReached();
156}
157
158bool OsiCbcSolverInterface::isDualObjectiveLimitReached() const
159{
160  return modelPtr_->solver()->isDualObjectiveLimitReached();
161}
162
163bool OsiCbcSolverInterface::isIterationLimitReached() const
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//#############################################################################
174CoinWarmStart *OsiCbcSolverInterface::getEmptyWarmStart () const
175{
176  return modelPtr_->solver()->getEmptyWarmStart();
177}
178
179CoinWarmStart* OsiCbcSolverInterface::getWarmStart() const
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
195void OsiCbcSolverInterface::markHotStart()
196{
197  modelPtr_->solver()->markHotStart();
198}
199
200void OsiCbcSolverInterface::solveFromHotStart()
201{
202  modelPtr_->solver()->solveFromHotStart();
203}
204
205void OsiCbcSolverInterface::unmarkHotStart()
206{
207  modelPtr_->solver()->unmarkHotStart();
208}
209
210//#############################################################################
211// Problem information methods (original data)
212//#############################################################################
213
214//------------------------------------------------------------------
215const char * OsiCbcSolverInterface::getRowSense() const
216{
217  return modelPtr_->solver()->getRowSense();
218}
219//------------------------------------------------------------------
220const double * OsiCbcSolverInterface::getRightHandSide() const
221{
222  return modelPtr_->solver()->getRightHandSide();
223}
224//------------------------------------------------------------------
225const double * OsiCbcSolverInterface::getRowRange() const
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
264OsiCbcSolverInterface::setContinuous(int index)
265{
266  modelPtr_->solver()->setContinuous(index);
267}
268//-----------------------------------------------------------------------------
269void
270OsiCbcSolverInterface::setInteger(int index)
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//-----------------------------------------------------------------------------
287void OsiCbcSolverInterface::setColSolution(const double * cs) 
288{
289  modelPtr_->solver()->setColSolution(cs);
290}
291//-----------------------------------------------------------------------------
292void OsiCbcSolverInterface::setRowPrice(const double * rs) 
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 
318OsiCbcSolverInterface::addCols(const int numcols,
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 
348OsiCbcSolverInterface::addRows(const int numrows,
349                               const CoinPackedVectorBase * const * rows,
350                               const double* rowlb, const double* rowub)
351{
352  modelPtr_->solver()->addRows(numrows,rows,rowlb,rowub);
353}
354//-----------------------------------------------------------------------------
355void 
356OsiCbcSolverInterface::addRows(const int numrows,
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 
458OsiCbcSolverInterface::writeMpsNative(const char *filename, 
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//-------------------------------------------------------------------
472OsiCbcSolverInterface::OsiCbcSolverInterface (OsiSolverInterface * solver,
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//-------------------------------------------------------------------
507OsiCbcSolverInterface::OsiCbcSolverInterface (
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//-------------------------------------------------------------------
520OsiCbcSolverInterface::~OsiCbcSolverInterface ()
521{
522  delete modelPtr_;
523}
524
525//-------------------------------------------------------------------
526// Assignment operator
527//-------------------------------------------------------------------
528OsiCbcSolverInterface &
529OsiCbcSolverInterface::operator=(const OsiCbcSolverInterface& rhs)
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 
589OsiCbcSolverInterface::readMps(const char *filename,
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 * 
596OsiCbcSolverInterface::getColSolution() const 
597{ 
598  return modelPtr_->solver()->getColSolution();
599}
600 
601// Get pointer to array[getNumRows()] of dual prices
602const double * 
603OsiCbcSolverInterface::getRowPrice() const
604{ 
605  return modelPtr_->solver()->getRowPrice();
606}
607 
608// Get a pointer to array[getNumCols()] of reduced costs
609const double * 
610OsiCbcSolverInterface::getReducedCost() const 
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 * 
618OsiCbcSolverInterface::getRowActivity() const 
619{ 
620  return modelPtr_->solver()->getRowActivity();
621}
622double 
623OsiCbcSolverInterface::getObjValue() const 
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 
653OsiCbcSolverInterface::setColBounds( int elementIndex,
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 
681OsiCbcSolverInterface::setRowBounds( int elementIndex,
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
701OsiCbcSolverInterface::setRowSetTypes(const int* indexFirst,
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 
737OsiCbcSolverInterface::getNumCols() const
738{
739  return modelPtr_->solver()->getNumCols();
740}
741int 
742OsiCbcSolverInterface::getNumRows() const
743{
744  return modelPtr_->solver()->getNumRows();
745}
746int 
747OsiCbcSolverInterface::getNumElements() const
748{
749  return modelPtr_->solver()->getNumElements();
750}
751const double * 
752OsiCbcSolverInterface::getColLower() const
753{
754  return modelPtr_->solver()->getColLower();
755}
756const double * 
757OsiCbcSolverInterface::getColUpper() const
758{
759  return modelPtr_->solver()->getColUpper();
760}
761const double * 
762OsiCbcSolverInterface::getRowLower() const
763{
764  return modelPtr_->solver()->getRowLower();
765}
766const double * 
767OsiCbcSolverInterface::getRowUpper() const
768{
769  return modelPtr_->solver()->getRowUpper();
770}
771const double * 
772OsiCbcSolverInterface::getObjCoefficients() const 
773{
774  return modelPtr_->solver()->getObjCoefficients();
775}
776double 
777OsiCbcSolverInterface::getObjSense() const 
778{
779  return modelPtr_->solver()->getObjSense();
780}
781double 
782OsiCbcSolverInterface::getInfinity() const
783{
784  return modelPtr_->solver()->getInfinity();
785}
786int 
787OsiCbcSolverInterface::getIterationCount() const 
788{
789  return modelPtr_->solver()->getIterationCount();
790}
791void 
792OsiCbcSolverInterface::setObjSense(double s )
793{
794  modelPtr_->setObjSense(s);
795}
796// Invoke solver's built-in enumeration algorithm
797void 
798OsiCbcSolverInterface::branchAndBound()
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*/
873void OsiCbcSolverInterface::setObjName (std::string name)
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 
897OsiCbcSolverInterface::passInMessageHandler(CoinMessageHandler * handler)
898{
899  OsiSolverInterface::passInMessageHandler(handler);
900  if (modelPtr_)
901    modelPtr_->passInMessageHandler(handler);
902}
903// So unit test can find out if NDEBUG set
904bool OsiCbcHasNDEBUG() 
905{
906#ifdef NDEBUG
907  return true;
908#else
909  return false;
910#endif
911}
Note: See TracBrowser for help on using the repository browser.