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

Last change on this file since 1493 was 1493, checked in by lou, 9 years ago

Change signature of getDualRays from (int) to (int,bool) to allow choice of
partial (row components) or full (row and column components) dual ray. Matches
Osi trunk revision 1551.

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