• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cyclus / cyclus / 16384544356

19 Jul 2025 03:38AM UTC coverage: 36.53% (-4.7%) from 41.231%
16384544356

push

github

web-flow
Merge pull request #1881 from dean-krueger/clang-format

Clang Format Cyclus src

1517 of 26176 new or added lines in 94 files covered. (5.8%)

309 existing lines in 19 files now uncovered.

51830 of 141883 relevant lines covered (36.53%)

14764.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.84
/src/OsiCbcSolverInterface_2_10.cpp
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
// #############################################################################
50
void OsiCbcSolverInterface::initialSolve() {
1✔
51
  modelPtr_->solver()->initialSolve();
1✔
52
}
1✔
53

54
//-----------------------------------------------------------------------------
NEW
55
void OsiCbcSolverInterface::resolve() {
×
UNCOV
56
  modelPtr_->solver()->resolve();
×
57
}
×
58
// #############################################################################
59
//  Parameter related methods
60
// #############################################################################
61

NEW
62
bool OsiCbcSolverInterface::setIntParam(OsiIntParam key, int value) {
×
NEW
63
  return modelPtr_->solver()->setIntParam(key, value);
×
64
  ;
65
}
66

67
//-----------------------------------------------------------------------------
68

NEW
69
bool OsiCbcSolverInterface::setDblParam(OsiDblParam key, double value) {
×
NEW
70
  return modelPtr_->solver()->setDblParam(key, value);
×
71
}
72

73
//-----------------------------------------------------------------------------
74

NEW
75
bool OsiCbcSolverInterface::setStrParam(OsiStrParam key,
×
76
                                        const std::string& value) {
NEW
77
  return modelPtr_->solver()->setStrParam(key, value);
×
78
}
79

80
//-----------------------------------------------------------------------------
81

NEW
82
bool OsiCbcSolverInterface::getIntParam(OsiIntParam key, int& value) const {
×
NEW
83
  return modelPtr_->solver()->getIntParam(key, value);
×
84
}
85

86
//-----------------------------------------------------------------------------
87

NEW
88
bool OsiCbcSolverInterface::getDblParam(OsiDblParam key, double& value) const {
×
NEW
89
  return modelPtr_->solver()->getDblParam(key, value);
×
90
}
91

92
//-----------------------------------------------------------------------------
93

NEW
94
bool OsiCbcSolverInterface::getStrParam(OsiStrParam key,
×
95
                                        std::string& value) const {
NEW
96
  if (key == OsiSolverName) {
×
97
    std::string value2;
NEW
98
    modelPtr_->solver()->getStrParam(key, value2);
×
NEW
99
    value = "cbc" + value2;
×
100
    return true;
101
  }
NEW
102
  return modelPtr_->solver()->getStrParam(key, value);
×
103
}
104

105
// #############################################################################
106
//  Methods returning info on how the solution process terminated
107
// #############################################################################
108

NEW
109
bool OsiCbcSolverInterface::isAbandoned() const {
×
NEW
110
  if (modelPtr_->status() != -1)
×
UNCOV
111
    return modelPtr_->isAbandoned();
×
112
  else
113
    return modelPtr_->solver()->isAbandoned();
×
114
}
115

NEW
116
bool OsiCbcSolverInterface::isProvenOptimal() const {
×
NEW
117
  if (modelPtr_->status() != -1)
×
UNCOV
118
    return modelPtr_->isProvenOptimal();
×
119
  else
120
    return modelPtr_->solver()->isProvenOptimal();
×
121
}
122

NEW
123
bool OsiCbcSolverInterface::isProvenPrimalInfeasible() const {
×
NEW
124
  if (modelPtr_->status() != -1)
×
UNCOV
125
    return modelPtr_->isProvenInfeasible();
×
126
  else
127
    return modelPtr_->solver()->isProvenPrimalInfeasible();
×
128
}
129

NEW
130
bool OsiCbcSolverInterface::isProvenDualInfeasible() const {
×
NEW
131
  if (modelPtr_->status() != -1)
×
NEW
132
    return modelPtr_->isProvenDualInfeasible();
×
133
  else
NEW
134
    return modelPtr_->solver()->isProvenDualInfeasible();
×
135
}
NEW
136
bool OsiCbcSolverInterface::isPrimalObjectiveLimitReached() const {
×
UNCOV
137
  return modelPtr_->solver()->isPrimalObjectiveLimitReached();
×
138
}
139

NEW
140
bool OsiCbcSolverInterface::isDualObjectiveLimitReached() const {
×
UNCOV
141
  return modelPtr_->solver()->isDualObjectiveLimitReached();
×
142
}
143

NEW
144
bool OsiCbcSolverInterface::isIterationLimitReached() const {
×
NEW
145
  if (modelPtr_->status() != -1)
×
UNCOV
146
    return modelPtr_->isNodeLimitReached();
×
147
  else
148
    return modelPtr_->solver()->isIterationLimitReached();
×
149
}
150

151
// #############################################################################
152
//  WarmStart related methods
153
// #############################################################################
NEW
154
CoinWarmStart* OsiCbcSolverInterface::getEmptyWarmStart() const {
×
UNCOV
155
  return modelPtr_->solver()->getEmptyWarmStart();
×
156
}
157

NEW
158
CoinWarmStart* OsiCbcSolverInterface::getWarmStart() const {
×
UNCOV
159
  return modelPtr_->solver()->getWarmStart();
×
160
}
161

162
//-----------------------------------------------------------------------------
163

NEW
164
bool OsiCbcSolverInterface::setWarmStart(const CoinWarmStart* warmstart) {
×
UNCOV
165
  return modelPtr_->solver()->setWarmStart(warmstart);
×
166
}
167

168
// #############################################################################
169
//  Hotstart related methods (primarily used in strong branching)
170
// #############################################################################
171

NEW
172
void OsiCbcSolverInterface::markHotStart() {
×
UNCOV
173
  modelPtr_->solver()->markHotStart();
×
174
}
×
175

NEW
176
void OsiCbcSolverInterface::solveFromHotStart() {
×
UNCOV
177
  modelPtr_->solver()->solveFromHotStart();
×
178
}
×
179

NEW
180
void OsiCbcSolverInterface::unmarkHotStart() {
×
UNCOV
181
  modelPtr_->solver()->unmarkHotStart();
×
182
}
×
183

184
// #############################################################################
185
//  Problem information methods (original data)
186
// #############################################################################
187

188
//------------------------------------------------------------------
NEW
189
const char* OsiCbcSolverInterface::getRowSense() const {
×
UNCOV
190
  return modelPtr_->solver()->getRowSense();
×
191
}
192
//------------------------------------------------------------------
NEW
193
const double* OsiCbcSolverInterface::getRightHandSide() const {
×
UNCOV
194
  return modelPtr_->solver()->getRightHandSide();
×
195
}
196
//------------------------------------------------------------------
NEW
197
const double* OsiCbcSolverInterface::getRowRange() const {
×
UNCOV
198
  return modelPtr_->solver()->getRowRange();
×
199
}
200
//------------------------------------------------------------------
201
// Return information on integrality
202
//------------------------------------------------------------------
NEW
203
bool OsiCbcSolverInterface::isContinuous(int colNumber) const {
×
UNCOV
204
  return modelPtr_->solver()->isContinuous(colNumber);
×
205
}
206
//------------------------------------------------------------------
207

208
//------------------------------------------------------------------
209
// Row and column copies of the matrix ...
210
//------------------------------------------------------------------
NEW
211
const CoinPackedMatrix* OsiCbcSolverInterface::getMatrixByRow() const {
×
UNCOV
212
  return modelPtr_->solver()->getMatrixByRow();
×
213
}
214

NEW
215
const CoinPackedMatrix* OsiCbcSolverInterface::getMatrixByCol() const {
×
UNCOV
216
  return modelPtr_->solver()->getMatrixByCol();
×
217
}
218

219
//------------------------------------------------------------------
220
std::vector<double*> OsiCbcSolverInterface::getDualRays(int maxNumRays,
×
221
                                                        bool fullRay) const {
NEW
222
  return modelPtr_->solver()->getDualRays(maxNumRays, fullRay);
×
223
}
224
//------------------------------------------------------------------
NEW
225
std::vector<double*> OsiCbcSolverInterface::getPrimalRays(
×
226
    int maxNumRays) const {
UNCOV
227
  return modelPtr_->solver()->getPrimalRays(maxNumRays);
×
228
}
229
// #############################################################################
NEW
230
void OsiCbcSolverInterface::setContinuous(int index) {
×
231
  modelPtr_->solver()->setContinuous(index);
×
232
}
×
233
//-----------------------------------------------------------------------------
234
void OsiCbcSolverInterface::setInteger(int index) {
2✔
235
  modelPtr_->solver()->setInteger(index);
2✔
236
}
2✔
237
//-----------------------------------------------------------------------------
NEW
238
void OsiCbcSolverInterface::setContinuous(const int* indices, int len) {
×
NEW
239
  modelPtr_->solver()->setContinuous(indices, len);
×
UNCOV
240
}
×
241
//-----------------------------------------------------------------------------
NEW
242
void OsiCbcSolverInterface::setInteger(const int* indices, int len) {
×
NEW
243
  modelPtr_->solver()->setInteger(indices, len);
×
UNCOV
244
}
×
245
//-----------------------------------------------------------------------------
NEW
246
void OsiCbcSolverInterface::setColSolution(const double* cs) {
×
UNCOV
247
  modelPtr_->solver()->setColSolution(cs);
×
248
}
×
249
//-----------------------------------------------------------------------------
NEW
250
void OsiCbcSolverInterface::setRowPrice(const double* rs) {
×
UNCOV
251
  modelPtr_->solver()->setRowPrice(rs);
×
252
}
×
253

254
// #############################################################################
255
//  Problem modifying methods (matrix)
256
// #############################################################################
NEW
257
void OsiCbcSolverInterface::addCol(const CoinPackedVectorBase& vec,
×
258
                                   const double collb, const double colub,
259
                                   const double obj) {
NEW
260
  modelPtr_->solver()->addCol(vec, collb, colub, obj);
×
UNCOV
261
}
×
262
/* Add a column (primal variable) to the problem. */
NEW
263
void OsiCbcSolverInterface::addCol(int numberElements, const int* rows,
×
264
                                   const double* elements, const double collb,
265
                                   const double colub, const double obj) {
NEW
266
  modelPtr_->solver()->addCol(numberElements, rows, elements, collb, colub,
×
267
                              obj);
UNCOV
268
}
×
269
//-----------------------------------------------------------------------------
NEW
270
void OsiCbcSolverInterface::addCols(const int numcols,
×
271
                                    const CoinPackedVectorBase* const* cols,
272
                                    const double* collb, const double* colub,
273
                                    const double* obj) {
NEW
274
  modelPtr_->solver()->addCols(numcols, cols, collb, colub, obj);
×
UNCOV
275
}
×
276
//-----------------------------------------------------------------------------
NEW
277
void OsiCbcSolverInterface::deleteCols(const int num,
×
278
                                       const int* columnIndices) {
NEW
279
  modelPtr_->solver()->deleteCols(num, columnIndices);
×
UNCOV
280
}
×
281
//-----------------------------------------------------------------------------
NEW
282
void OsiCbcSolverInterface::addRow(const CoinPackedVectorBase& vec,
×
283
                                   const double rowlb, const double rowub) {
NEW
284
  modelPtr_->solver()->addRow(vec, rowlb, rowub);
×
UNCOV
285
}
×
286
//-----------------------------------------------------------------------------
NEW
287
void OsiCbcSolverInterface::addRow(const CoinPackedVectorBase& vec,
×
288
                                   const char rowsen, const double rowrhs,
289
                                   const double rowrng) {
NEW
290
  modelPtr_->solver()->addRow(vec, rowsen, rowrhs, rowrng);
×
UNCOV
291
}
×
292
//-----------------------------------------------------------------------------
NEW
293
void OsiCbcSolverInterface::addRows(const int numrows,
×
294
                                    const CoinPackedVectorBase* const* rows,
295
                                    const double* rowlb, const double* rowub) {
NEW
296
  modelPtr_->solver()->addRows(numrows, rows, rowlb, rowub);
×
UNCOV
297
}
×
298
//-----------------------------------------------------------------------------
NEW
299
void OsiCbcSolverInterface::addRows(const int numrows,
×
300
                                    const CoinPackedVectorBase* const* rows,
301
                                    const char* rowsen, const double* rowrhs,
302
                                    const double* rowrng) {
NEW
303
  modelPtr_->solver()->addRows(numrows, rows, rowsen, rowrhs, rowrng);
×
UNCOV
304
}
×
305
//-----------------------------------------------------------------------------
NEW
306
void OsiCbcSolverInterface::deleteRows(const int num, const int* rowIndices) {
×
NEW
307
  modelPtr_->solver()->deleteRows(num, rowIndices);
×
UNCOV
308
}
×
309

310
// #############################################################################
311
//  Methods to input a problem
312
// #############################################################################
313

314
void OsiCbcSolverInterface::loadProblem(const CoinPackedMatrix& matrix,
1✔
315
                                        const double* collb,
316
                                        const double* colub, const double* obj,
317
                                        const double* rowlb,
318
                                        const double* rowub) {
319
  modelPtr_->solver()->loadProblem(matrix, collb, colub, obj, rowlb, rowub);
1✔
320
}
1✔
321

322
//-----------------------------------------------------------------------------
323

NEW
324
void OsiCbcSolverInterface::assignProblem(CoinPackedMatrix*& matrix,
×
325
                                          double*& collb, double*& colub,
326
                                          double*& obj, double*& rowlb,
327
                                          double*& rowub) {
NEW
328
  modelPtr_->solver()->assignProblem(matrix, collb, colub, obj, rowlb, rowub);
×
UNCOV
329
}
×
330

331
//-----------------------------------------------------------------------------
332

NEW
333
void OsiCbcSolverInterface::loadProblem(const CoinPackedMatrix& matrix,
×
334
                                        const double* collb,
335
                                        const double* colub, const double* obj,
336
                                        const char* rowsen,
337
                                        const double* rowrhs,
338
                                        const double* rowrng) {
NEW
339
  modelPtr_->solver()->loadProblem(matrix, collb, colub, obj, rowsen, rowrhs,
×
340
                                   rowrng);
UNCOV
341
}
×
342

343
//-----------------------------------------------------------------------------
344

NEW
345
void OsiCbcSolverInterface::assignProblem(CoinPackedMatrix*& matrix,
×
346
                                          double*& collb, double*& colub,
347
                                          double*& obj, char*& rowsen,
348
                                          double*& rowrhs, double*& rowrng) {
NEW
349
  modelPtr_->solver()->assignProblem(matrix, collb, colub, obj, rowsen, rowrhs,
×
350
                                     rowrng);
UNCOV
351
}
×
352

353
//-----------------------------------------------------------------------------
354

NEW
355
void OsiCbcSolverInterface::loadProblem(const int numcols, const int numrows,
×
356
                                        const CoinBigIndex* start,
357
                                        const int* index, const double* value,
358
                                        const double* collb,
359
                                        const double* colub, const double* obj,
360
                                        const double* rowlb,
361
                                        const double* rowub) {
NEW
362
  modelPtr_->solver()->loadProblem(numcols, numrows, start, index, value, collb,
×
363
                                   colub, obj, rowlb, rowub);
UNCOV
364
}
×
365
//-----------------------------------------------------------------------------
366

NEW
367
void OsiCbcSolverInterface::loadProblem(
×
368
    const int numcols, const int numrows, const CoinBigIndex* start,
369
    const int* index, const double* value, const double* collb,
370
    const double* colub, const double* obj, const char* rowsen,
371
    const double* rowrhs, const double* rowrng) {
NEW
372
  modelPtr_->solver()->loadProblem(numcols, numrows, start, index, value, collb,
×
373
                                   colub, obj, rowsen, rowrhs, rowrng);
UNCOV
374
}
×
375

376
//-----------------------------------------------------------------------------
377
// Write mps files
378
//-----------------------------------------------------------------------------
379

NEW
380
void OsiCbcSolverInterface::writeMps(const char* filename,
×
381
                                     const char* extension,
382
                                     double objSense) const {
NEW
383
  modelPtr_->solver()->writeMps(filename, extension, objSense);
×
UNCOV
384
}
×
385

NEW
386
int OsiCbcSolverInterface::writeMpsNative(const char* filename,
×
387
                                          const char** rowNames,
388
                                          const char** columnNames,
389
                                          int formatType, int numberAcross,
390
                                          double objSense) const {
NEW
391
  return modelPtr_->solver()->writeMpsNative(
×
NEW
392
      filename, rowNames, columnNames, formatType, numberAcross, objSense);
×
393
}
394

395
// #############################################################################
396
//  Constructors, destructors clone and assignment
397
// #############################################################################
398
//-------------------------------------------------------------------
399
//  Default Constructor
400
//-------------------------------------------------------------------
401
OsiCbcSolverInterface::OsiCbcSolverInterface(OsiSolverInterface* solver,
1✔
402
                                             CbcStrategy* strategy)
1✔
403
    : OsiSolverInterface() {
1✔
404
  if (solver) {
1✔
NEW
405
    modelPtr_ = new CbcModel(*solver);
×
406
  } else {
407
    OSICBC_DFLT_SOLVER solverDflt;
1✔
408
    modelPtr_ = new CbcModel(solverDflt);
1✔
409
  }
1✔
410
  if (strategy) {
1✔
411
    modelPtr_->setStrategy(*strategy);
×
412
  } else {
413
    CbcStrategyDefault defaultStrategy;
1✔
414
    modelPtr_->setStrategy(defaultStrategy);
1✔
415
  }
1✔
416
}
1✔
417

418
//-------------------------------------------------------------------
419
// Clone
420
//-------------------------------------------------------------------
NEW
421
OsiSolverInterface* OsiCbcSolverInterface::clone(bool CopyData) const {
×
NEW
422
  if (CopyData) {
×
NEW
423
    return new OsiCbcSolverInterface(*this);
×
424
  } else {
NEW
425
    return new OsiCbcSolverInterface();
×
426
  }
427
}
428

429
//-------------------------------------------------------------------
430
// Copy constructor
431
//-------------------------------------------------------------------
NEW
432
OsiCbcSolverInterface::OsiCbcSolverInterface(const OsiCbcSolverInterface& rhs)
×
NEW
433
    : OsiSolverInterface(rhs) {
×
434
  assert(rhs.modelPtr_);
435
  modelPtr_ = new CbcModel(*rhs.modelPtr_);
×
436
}
×
437

438
//-------------------------------------------------------------------
439
// Destructor
440
//-------------------------------------------------------------------
441
OsiCbcSolverInterface::~OsiCbcSolverInterface() {
1✔
442
  delete modelPtr_;
1✔
443
}
1✔
444

445
//-------------------------------------------------------------------
446
// Assignment operator
447
//-------------------------------------------------------------------
NEW
448
OsiCbcSolverInterface& OsiCbcSolverInterface::operator=(
×
449
    const OsiCbcSolverInterface& rhs) {
450
  if (this != &rhs) {
×
451
    OsiSolverInterface::operator=(rhs);
×
452
    delete modelPtr_;
×
NEW
453
    modelPtr_ = new CbcModel(*rhs.modelPtr_);
×
454
  }
455
  return *this;
×
456
}
457

458
// #############################################################################
459
//  Applying cuts
460
// #############################################################################
461

NEW
462
void OsiCbcSolverInterface::applyRowCut(const OsiRowCut& rowCut) {
×
NEW
463
  modelPtr_->solver()->applyRowCuts(1, &rowCut);
×
UNCOV
464
}
×
465
/* Apply a collection of row cuts which are all effective.
466
   applyCuts seems to do one at a time which seems inefficient.
467
*/
NEW
468
void OsiCbcSolverInterface::applyRowCuts(int numberCuts,
×
469
                                         const OsiRowCut* cuts) {
NEW
470
  modelPtr_->solver()->applyRowCuts(numberCuts, cuts);
×
UNCOV
471
}
×
472
/* Apply a collection of row cuts which are all effective.
473
   applyCuts seems to do one at a time which seems inefficient.
474
*/
NEW
475
void OsiCbcSolverInterface::applyRowCuts(int numberCuts,
×
476
                                         const OsiRowCut** cuts) {
477
  modelPtr_->solver()->applyRowCuts(numberCuts, cuts);
×
478
}
×
479
//-----------------------------------------------------------------------------
480

NEW
481
void OsiCbcSolverInterface::applyColCut(const OsiColCut& cc) {
×
NEW
482
  const double* lower = modelPtr_->solver()->getColLower();
×
NEW
483
  const double* upper = modelPtr_->solver()->getColUpper();
×
484
  const CoinPackedVector& lbs = cc.lbs();
485
  const CoinPackedVector& ubs = cc.ubs();
486
  int i;
487

NEW
488
  for (i = 0; i < lbs.getNumElements(); i++) {
×
489
    int iCol = lbs.getIndices()[i];
×
490
    double value = lbs.getElements()[i];
×
NEW
491
    if (value > lower[iCol]) modelPtr_->solver()->setColLower(iCol, value);
×
492
  }
NEW
493
  for (i = 0; i < ubs.getNumElements(); i++) {
×
494
    int iCol = ubs.getIndices()[i];
×
495
    double value = ubs.getElements()[i];
×
NEW
496
    if (value < upper[iCol]) modelPtr_->solver()->setColUpper(iCol, value);
×
497
  }
498
}
×
499
/* Read an mps file from the given filename (defaults to Osi reader) - returns
500
   number of errors (see OsiMpsReader class) */
NEW
501
int OsiCbcSolverInterface::readMps(const char* filename,
×
502
                                   const char* extension) {
NEW
503
  return modelPtr_->solver()->readMps(filename, extension);
×
504
}
505
// Get pointer to array[getNumCols()] of primal solution vector
506
const double* OsiCbcSolverInterface::getColSolution() const {
1✔
507
  return modelPtr_->solver()->getColSolution();
1✔
508
}
509

510
// Get pointer to array[getNumRows()] of dual prices
NEW
511
const double* OsiCbcSolverInterface::getRowPrice() const {
×
512
  return modelPtr_->solver()->getRowPrice();
×
513
}
514

515
// Get a pointer to array[getNumCols()] of reduced costs
NEW
516
const double* OsiCbcSolverInterface::getReducedCost() const {
×
517
  return modelPtr_->solver()->getReducedCost();
×
518
}
519

520
/* Get pointer to array[getNumRows()] of row activity levels (constraint
521
   matrix times the solution vector */
NEW
522
const double* OsiCbcSolverInterface::getRowActivity() const {
×
523
  return modelPtr_->solver()->getRowActivity();
×
524
}
NEW
525
double OsiCbcSolverInterface::getObjValue() const {
×
526
  return modelPtr_->solver()->getObjValue();
×
527
}
528

529
/* Set an objective function coefficient */
NEW
530
void OsiCbcSolverInterface::setObjCoeff(int elementIndex, double elementValue) {
×
NEW
531
  modelPtr_->solver()->setObjCoeff(elementIndex, elementValue);
×
UNCOV
532
}
×
533

534
/* Set a single column lower bound<br>
535
   Use -DBL_MAX for -infinity. */
NEW
536
void OsiCbcSolverInterface::setColLower(int elementIndex, double elementValue) {
×
NEW
537
  modelPtr_->solver()->setColLower(elementIndex, elementValue);
×
UNCOV
538
}
×
539

540
/* Set a single column upper bound<br>
541
   Use DBL_MAX for infinity. */
NEW
542
void OsiCbcSolverInterface::setColUpper(int elementIndex, double elementValue) {
×
NEW
543
  modelPtr_->solver()->setColUpper(elementIndex, elementValue);
×
UNCOV
544
}
×
545

546
/* Set a single column lower and upper bound */
NEW
547
void OsiCbcSolverInterface::setColBounds(int elementIndex, double lower,
×
548
                                         double upper) {
NEW
549
  modelPtr_->solver()->setColBounds(elementIndex, lower, upper);
×
550
}
×
551
void OsiCbcSolverInterface::setColSetBounds(const int* indexFirst,
×
552
                                            const int* indexLast,
553
                                            const double* boundList) {
NEW
554
  modelPtr_->solver()->setColSetBounds(indexFirst, indexLast, boundList);
×
UNCOV
555
}
×
556
//------------------------------------------------------------------
557
/* Set a single row lower bound<br>
558
   Use -DBL_MAX for -infinity. */
NEW
559
void OsiCbcSolverInterface::setRowLower(int elementIndex, double elementValue) {
×
NEW
560
  modelPtr_->solver()->setRowLower(elementIndex, elementValue);
×
UNCOV
561
}
×
562

563
/* Set a single row upper bound<br>
564
   Use DBL_MAX for infinity. */
NEW
565
void OsiCbcSolverInterface::setRowUpper(int elementIndex, double elementValue) {
×
NEW
566
  modelPtr_->solver()->setRowUpper(elementIndex, elementValue);
×
UNCOV
567
}
×
568

569
/* Set a single row lower and upper bound */
NEW
570
void OsiCbcSolverInterface::setRowBounds(int elementIndex, double lower,
×
571
                                         double upper) {
NEW
572
  modelPtr_->solver()->setRowBounds(elementIndex, lower, upper);
×
UNCOV
573
}
×
574
//-----------------------------------------------------------------------------
NEW
575
void OsiCbcSolverInterface::setRowType(int i, char sense, double rightHandSide,
×
576
                                       double range) {
NEW
577
  modelPtr_->solver()->setRowType(i, sense, rightHandSide, range);
×
UNCOV
578
}
×
579
//-----------------------------------------------------------------------------
580
void OsiCbcSolverInterface::setRowSetBounds(const int* indexFirst,
×
581
                                            const int* indexLast,
582
                                            const double* boundList) {
NEW
583
  modelPtr_->solver()->setRowSetBounds(indexFirst, indexLast, boundList);
×
UNCOV
584
}
×
585
//-----------------------------------------------------------------------------
NEW
586
void OsiCbcSolverInterface::setRowSetTypes(const int* indexFirst,
×
587
                                           const int* indexLast,
588
                                           const char* senseList,
589
                                           const double* rhsList,
590
                                           const double* rangeList) {
NEW
591
  modelPtr_->solver()->setRowSetTypes(indexFirst, indexLast, senseList, rhsList,
×
592
                                      rangeList);
UNCOV
593
}
×
594
// Set a hint parameter
NEW
595
bool OsiCbcSolverInterface::setHintParam(OsiHintParam key, bool yesNo,
×
596
                                         OsiHintStrength strength,
597
                                         void* otherInformation) {
NEW
598
  return modelPtr_->solver()->setHintParam(key, yesNo, strength,
×
NEW
599
                                           otherInformation);
×
600
}
601

602
// Get a hint parameter
NEW
603
bool OsiCbcSolverInterface::getHintParam(OsiHintParam key, bool& yesNo,
×
604
                                         OsiHintStrength& strength,
605
                                         void*& otherInformation) const {
NEW
606
  return modelPtr_->solver()->getHintParam(key, yesNo, strength,
×
NEW
607
                                           otherInformation);
×
608
}
609

610
// Get a hint parameter
NEW
611
bool OsiCbcSolverInterface::getHintParam(OsiHintParam key, bool& yesNo,
×
612
                                         OsiHintStrength& strength) const {
NEW
613
  return modelPtr_->solver()->getHintParam(key, yesNo, strength);
×
614
}
615

NEW
616
int OsiCbcSolverInterface::getNumCols() const {
×
UNCOV
617
  return modelPtr_->solver()->getNumCols();
×
618
}
NEW
619
int OsiCbcSolverInterface::getNumRows() const {
×
620
  return modelPtr_->solver()->getNumRows();
×
621
}
NEW
622
int OsiCbcSolverInterface::getNumElements() const {
×
623
  return modelPtr_->solver()->getNumElements();
×
624
}
NEW
625
const double* OsiCbcSolverInterface::getColLower() const {
×
626
  return modelPtr_->solver()->getColLower();
×
627
}
NEW
628
const double* OsiCbcSolverInterface::getColUpper() const {
×
629
  return modelPtr_->solver()->getColUpper();
×
630
}
NEW
631
const double* OsiCbcSolverInterface::getRowLower() const {
×
632
  return modelPtr_->solver()->getRowLower();
×
633
}
NEW
634
const double* OsiCbcSolverInterface::getRowUpper() const {
×
635
  return modelPtr_->solver()->getRowUpper();
×
636
}
NEW
637
const double* OsiCbcSolverInterface::getObjCoefficients() const {
×
638
  return modelPtr_->solver()->getObjCoefficients();
×
639
}
NEW
640
double OsiCbcSolverInterface::getObjSense() const {
×
641
  return modelPtr_->solver()->getObjSense();
×
642
}
643
double OsiCbcSolverInterface::getInfinity() const {
1✔
644
  return modelPtr_->solver()->getInfinity();
1✔
645
}
NEW
646
int OsiCbcSolverInterface::getIterationCount() const {
×
647
  return modelPtr_->solver()->getIterationCount();
×
648
}
649
void OsiCbcSolverInterface::setObjSense(double s) {
1✔
650
  modelPtr_->setObjSense(s);
1✔
651
}
1✔
652
// Invoke solver's built-in enumeration algorithm
653
void OsiCbcSolverInterface::branchAndBound() {
1✔
654
  *messageHandler() << "Warning: Use of OsiCbc is deprecated."
1✔
655
                    << CoinMessageEol;
1✔
656
  *messageHandler()
657
      << "To enjoy the full performance of Cbc, use the CbcSolver interface."
1✔
658
      << CoinMessageEol;
1✔
659
  modelPtr_->branchAndBound();
1✔
660
}
1✔
661

662
/*
663
  Name discipline support   -- lh, 070328 --
664

665
  For safety, there's really nothing to it but to pass each call of an impure
666
  virtual method on to the underlying solver. Otherwise we just can't know if
667
  it's been overridden or not.
668
*/
669

NEW
670
std::string OsiCbcSolverInterface::dfltRowColName(char rc, int ndx,
×
671
                                                  unsigned digits) const {
NEW
672
  return (modelPtr_->solver()->dfltRowColName(rc, ndx, digits));
×
673
}
674

NEW
675
std::string OsiCbcSolverInterface::getObjName(unsigned maxLen) const {
×
NEW
676
  return (modelPtr_->solver()->getObjName(maxLen));
×
677
}
678

NEW
679
std::string OsiCbcSolverInterface::getRowName(int ndx, unsigned maxLen) const {
×
NEW
680
  return (modelPtr_->solver()->getRowName(ndx, maxLen));
×
681
}
682

NEW
683
const OsiSolverInterface::OsiNameVec& OsiCbcSolverInterface::getRowNames() {
×
NEW
684
  return (modelPtr_->solver()->getRowNames());
×
685
}
686

NEW
687
std::string OsiCbcSolverInterface::getColName(int ndx, unsigned maxLen) const {
×
NEW
688
  return (modelPtr_->solver()->getColName(ndx, maxLen));
×
689
}
690

NEW
691
const OsiSolverInterface::OsiNameVec& OsiCbcSolverInterface::getColNames() {
×
NEW
692
  return (modelPtr_->solver()->getColNames());
×
693
}
694

NEW
695
void OsiCbcSolverInterface::setRowNames(OsiNameVec& srcNames, int srcStart,
×
696
                                        int len, int tgtStart) {
NEW
697
  modelPtr_->solver()->setRowNames(srcNames, srcStart, len, tgtStart);
×
UNCOV
698
}
×
699

NEW
700
void OsiCbcSolverInterface::deleteRowNames(int tgtStart, int len) {
×
NEW
701
  modelPtr_->solver()->deleteRowNames(tgtStart, len);
×
UNCOV
702
}
×
703

NEW
704
void OsiCbcSolverInterface::setColNames(OsiNameVec& srcNames, int srcStart,
×
705
                                        int len, int tgtStart) {
NEW
706
  modelPtr_->solver()->setColNames(srcNames, srcStart, len, tgtStart);
×
UNCOV
707
}
×
708

NEW
709
void OsiCbcSolverInterface::deleteColNames(int tgtStart, int len) {
×
NEW
710
  modelPtr_->solver()->deleteColNames(tgtStart, len);
×
UNCOV
711
}
×
712

713
/*
714
  These last three are the only functions that would normally be overridden.
715
*/
716

717
/*
718
  Set objective function name.
719
*/
NEW
720
void OsiCbcSolverInterface::setObjName(std::string name) {
×
NEW
721
  modelPtr_->solver()->setObjName(name);
×
UNCOV
722
}
×
723

724
/*
725
  Set a row name, to make sure both the solver and OSI see the same name.
726
*/
NEW
727
void OsiCbcSolverInterface::setRowName(int ndx, std::string name)
×
728

729
{
NEW
730
  modelPtr_->solver()->setRowName(ndx, name);
×
731
}
×
732

733
/*
734
  Set a column name, to make sure both the solver and OSI see the same name.
735
*/
NEW
736
void OsiCbcSolverInterface::setColName(int ndx, std::string name)
×
737

738
{
NEW
739
  modelPtr_->solver()->setColName(ndx, name);
×
740
}
×
741
// Pass in Message handler (not deleted at end)
NEW
742
void OsiCbcSolverInterface::passInMessageHandler(CoinMessageHandler* handler) {
×
743
  OsiSolverInterface::passInMessageHandler(handler);
×
NEW
744
  if (modelPtr_) modelPtr_->passInMessageHandler(handler);
×
745
}
×
746
// So unit test can find out if NDEBUG set
NEW
747
bool OsiCbcHasNDEBUG() {
×
748
#ifdef NDEBUG
749
  return true;
×
750
#else
751
  return false;
752
#endif
753
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc