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

Last change on this file since 2076 was 2076, checked in by forrest, 5 years ago

modify isProven

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