gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Add CBC support (#204)
0 5 3
default
8 files changed with 722 insertions and 10 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2
 *
3
 * This file is a part of LEMON, a generic C++ optimization library.
4
 *
5
 * Copyright (C) 2003-2009
6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8
 *
9
 * Permission to use, modify and distribute this software is granted
10
 * provided that this copyright notice appears in all copies. For
11
 * precise terms see the accompanying LICENSE file.
12
 *
13
 * This software is provided "AS IS" with no warranty of any kind,
14
 * express or implied, and with no claim as to its suitability for any
15
 * purpose.
16
 *
17
 */
18

	
19
///\file
20
///\brief Implementation of the CBC MIP solver interface.
21

	
22
#include "cbc.h"
23

	
24
#include <coin/CoinModel.hpp>
25
#include <coin/CbcModel.hpp>
26
#include <coin/OsiSolverInterface.hpp>
27

	
28
#ifdef COIN_HAS_CLP
29
#include "coin/OsiClpSolverInterface.hpp"
30
#endif
31
#ifdef COIN_HAS_OSL
32
#include "coin/OsiOslSolverInterface.hpp"
33
#endif
34

	
35
#include "coin/CbcCutGenerator.hpp"
36
#include "coin/CbcHeuristicLocal.hpp"
37
#include "coin/CbcHeuristicGreedy.hpp"
38
#include "coin/CbcHeuristicFPump.hpp"
39
#include "coin/CbcHeuristicRINS.hpp"
40

	
41
#include "coin/CglGomory.hpp"
42
#include "coin/CglProbing.hpp"
43
#include "coin/CglKnapsackCover.hpp"
44
#include "coin/CglOddHole.hpp"
45
#include "coin/CglClique.hpp"
46
#include "coin/CglFlowCover.hpp"
47
#include "coin/CglMixedIntegerRounding.hpp"
48

	
49
#include "coin/CbcHeuristic.hpp"
50

	
51
namespace lemon {
52

	
53
  CbcMip::CbcMip() {
54
    _prob = new CoinModel();
55
    _prob->setProblemName("LEMON");
56
    _osi_solver = 0;
57
    _cbc_model = 0;
58
  }
59

	
60
  CbcMip::CbcMip(const CbcMip& other) {
61
    _prob = new CoinModel(*other._prob);
62
    _osi_solver = 0;
63
    _cbc_model = 0;
64
  }
65

	
66
  CbcMip::~CbcMip() {
67
    delete _prob;
68
    if (_osi_solver) delete _osi_solver;
69
    if (_cbc_model) delete _cbc_model;
70
  }
71

	
72
  const char* CbcMip::_solverName() const { return "CbcMip"; }
73

	
74
  int CbcMip::_addCol() {
75
    _prob->addColumn(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX, 0.0, 0, false);
76
    return _prob->numberColumns() - 1;
77
  }
78

	
79
  CbcMip* CbcMip::newSolver() const {
80
    CbcMip* newlp = new CbcMip;
81
    return newlp;
82
  }
83

	
84
  CbcMip* CbcMip::cloneSolver() const {
85
    CbcMip* copylp = new CbcMip(*this);
86
    return copylp;
87
  }
88

	
89
  int CbcMip::_addRow() {
90
    _prob->addRow(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX);
91
    return _prob->numberRows() - 1;
92
  }
93

	
94

	
95
  void CbcMip::_eraseCol(int i) {
96
    _prob->deleteColumn(i);
97
  }
98

	
99
  void CbcMip::_eraseRow(int i) {
100
    _prob->deleteRow(i);
101
  }
102

	
103
  void CbcMip::_eraseColId(int i) {
104
    cols.eraseIndex(i);
105
  }
106

	
107
  void CbcMip::_eraseRowId(int i) {
108
    rows.eraseIndex(i);
109
  }
110

	
111
  void CbcMip::_getColName(int c, std::string& name) const {
112
    name = _prob->getColumnName(c);
113
  }
114

	
115
  void CbcMip::_setColName(int c, const std::string& name) {
116
    _prob->setColumnName(c, name.c_str());
117
  }
118

	
119
  int CbcMip::_colByName(const std::string& name) const {
120
    return _prob->column(name.c_str());
121
  }
122

	
123
  void CbcMip::_getRowName(int r, std::string& name) const {
124
    name = _prob->getRowName(r);
125
  }
126

	
127
  void CbcMip::_setRowName(int r, const std::string& name) {
128
    _prob->setRowName(r, name.c_str());
129
  }
130

	
131
  int CbcMip::_rowByName(const std::string& name) const {
132
    return _prob->row(name.c_str());
133
  }
134

	
135
  void CbcMip::_setRowCoeffs(int i, ExprIterator b, ExprIterator e) {
136
    for (ExprIterator it = b; it != e; ++it) {
137
      _prob->setElement(i, it->first, it->second);
138
    }
139
  }
140

	
141
  void CbcMip::_getRowCoeffs(int ix, InsertIterator b) const {
142
    int length = _prob->numberRows();
143

	
144
    std::vector<int> indices(length);
145
    std::vector<Value> values(length);
146

	
147
    length = _prob->getRow(ix, &indices[0], &values[0]);
148

	
149
    for (int i = 0; i < length; ++i) {
150
      *b = std::make_pair(indices[i], values[i]);
151
      ++b;
152
    }
153
  }
154

	
155
  void CbcMip::_setColCoeffs(int ix, ExprIterator b, ExprIterator e) {
156
    for (ExprIterator it = b; it != e; ++it) {
157
      _prob->setElement(it->first, ix, it->second);
158
    }
159
  }
160

	
161
  void CbcMip::_getColCoeffs(int ix, InsertIterator b) const {
162
    int length = _prob->numberColumns();
163

	
164
    std::vector<int> indices(length);
165
    std::vector<Value> values(length);
166

	
167
    length = _prob->getColumn(ix, &indices[0], &values[0]);
168

	
169
    for (int i = 0; i < length; ++i) {
170
      *b = std::make_pair(indices[i], values[i]);
171
      ++b;
172
    }
173
  }
174

	
175
  void CbcMip::_setCoeff(int ix, int jx, Value value) {
176
    _prob->setElement(ix, jx, value);
177
  }
178

	
179
  CbcMip::Value CbcMip::_getCoeff(int ix, int jx) const {
180
    return _prob->getElement(ix, jx);
181
  }
182

	
183

	
184
  void CbcMip::_setColLowerBound(int i, Value lo) {
185
    LEMON_ASSERT(lo != INF, "Invalid bound");
186
    _prob->setColumnLower(i, lo == - INF ? - COIN_DBL_MAX : lo);
187
  }
188

	
189
  CbcMip::Value CbcMip::_getColLowerBound(int i) const {
190
    double val = _prob->getColumnLower(i);
191
    return val == - COIN_DBL_MAX ? - INF : val;
192
  }
193

	
194
  void CbcMip::_setColUpperBound(int i, Value up) {
195
    LEMON_ASSERT(up != -INF, "Invalid bound");
196
    _prob->setColumnUpper(i, up == INF ? COIN_DBL_MAX : up);
197
  }
198

	
199
  CbcMip::Value CbcMip::_getColUpperBound(int i) const {
200
    double val = _prob->getColumnUpper(i);
201
    return val == COIN_DBL_MAX ? INF : val;
202
  }
203

	
204
  void CbcMip::_setRowLowerBound(int i, Value lo) {
205
    LEMON_ASSERT(lo != INF, "Invalid bound");
206
    _prob->setRowLower(i, lo == - INF ? - COIN_DBL_MAX : lo);
207
  }
208

	
209
  CbcMip::Value CbcMip::_getRowLowerBound(int i) const {
210
    double val = _prob->getRowLower(i);
211
    return val == - COIN_DBL_MAX ? - INF : val;
212
  }
213

	
214
  void CbcMip::_setRowUpperBound(int i, Value up) {
215
    LEMON_ASSERT(up != -INF, "Invalid bound");
216
    _prob->setRowUpper(i, up == INF ? COIN_DBL_MAX : up);
217
  }
218

	
219
  CbcMip::Value CbcMip::_getRowUpperBound(int i) const {
220
    double val = _prob->getRowUpper(i);
221
    return val == COIN_DBL_MAX ? INF : val;
222
  }
223

	
224
  void CbcMip::_setObjCoeffs(ExprIterator b, ExprIterator e) {
225
    int num = _prob->numberColumns();
226
    for (int i = 0; i < num; ++i) {
227
      _prob->setColumnObjective(i, 0.0);
228
    }
229
    for (ExprIterator it = b; it != e; ++it) {
230
      _prob->setColumnObjective(it->first, it->second);
231
    }
232
  }
233

	
234
  void CbcMip::_getObjCoeffs(InsertIterator b) const {
235
    int num = _prob->numberColumns();
236
    for (int i = 0; i < num; ++i) {
237
      Value coef = _prob->getColumnObjective(i);
238
      if (coef != 0.0) {
239
        *b = std::make_pair(i, coef);
240
        ++b;
241
      }
242
    }
243
  }
244

	
245
  void CbcMip::_setObjCoeff(int i, Value obj_coef) {
246
    _prob->setColumnObjective(i, obj_coef);
247
  }
248

	
249
  CbcMip::Value CbcMip::_getObjCoeff(int i) const {
250
    return _prob->getColumnObjective(i);
251
  }
252

	
253
  CbcMip::SolveExitStatus CbcMip::_solve() {
254

	
255
    if (_osi_solver) {
256
      delete _osi_solver;
257
    }
258
#ifdef COIN_HAS_CLP
259
    _osi_solver = new OsiClpSolverInterface();
260
#elif COIN_HAS_OSL
261
    _osi_solver = new OsiOslSolverInterface();
262
#else
263
#error Cannot instantiate Osi solver
264
#endif
265

	
266
    _osi_solver->loadFromCoinModel(*_prob);
267

	
268
    if (_cbc_model) {
269
      delete _cbc_model;
270
    }
271
    _cbc_model= new CbcModel(*_osi_solver);
272

	
273
    switch (_message_level) {
274
    case MESSAGE_NO_OUTPUT:
275
      _osi_solver->messageHandler()->setLogLevel(0);
276
      _cbc_model->setLogLevel(0);
277
      break;
278
    case MESSAGE_ERROR_MESSAGE:
279
      _osi_solver->messageHandler()->setLogLevel(1);
280
      _cbc_model->setLogLevel(1);
281
      break;
282
    case MESSAGE_NORMAL_OUTPUT:
283
      _osi_solver->messageHandler()->setLogLevel(2);
284
      _cbc_model->setLogLevel(2);
285
      break;
286
    case MESSAGE_FULL_OUTPUT:
287
      _osi_solver->messageHandler()->setLogLevel(3);
288
      _cbc_model->setLogLevel(3);
289
      break;
290
    }
291

	
292
    _cbc_model->initialSolve();
293
    _cbc_model->solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry);
294

	
295
    if (!_cbc_model->isInitialSolveAbandoned() &&
296
        _cbc_model->isInitialSolveProvenOptimal() &&
297
        !_cbc_model->isInitialSolveProvenPrimalInfeasible() &&
298
        !_cbc_model->isInitialSolveProvenDualInfeasible()) {
299

	
300
      CglProbing generator1;
301
      generator1.setUsingObjective(true);
302
      generator1.setMaxPass(3);
303
      generator1.setMaxProbe(100);
304
      generator1.setMaxLook(50);
305
      generator1.setRowCuts(3);
306
      _cbc_model->addCutGenerator(&generator1, -1, "Probing");
307

	
308
      CglGomory generator2;
309
      generator2.setLimit(300);
310
      _cbc_model->addCutGenerator(&generator2, -1, "Gomory");
311

	
312
      CglKnapsackCover generator3;
313
      _cbc_model->addCutGenerator(&generator3, -1, "Knapsack");
314

	
315
      CglOddHole generator4;
316
      generator4.setMinimumViolation(0.005);
317
      generator4.setMinimumViolationPer(0.00002);
318
      generator4.setMaximumEntries(200);
319
      _cbc_model->addCutGenerator(&generator4, -1, "OddHole");
320

	
321
      CglClique generator5;
322
      generator5.setStarCliqueReport(false);
323
      generator5.setRowCliqueReport(false);
324
      _cbc_model->addCutGenerator(&generator5, -1, "Clique");
325

	
326
      CglMixedIntegerRounding mixedGen;
327
      _cbc_model->addCutGenerator(&mixedGen, -1, "MixedIntegerRounding");
328

	
329
      CglFlowCover flowGen;
330
      _cbc_model->addCutGenerator(&flowGen, -1, "FlowCover");
331

	
332
#ifdef COIN_HAS_CLP
333
      OsiClpSolverInterface* osiclp =
334
        dynamic_cast<OsiClpSolverInterface*>(_cbc_model->solver());
335
      if (osiclp->getNumRows() < 300 && osiclp->getNumCols() < 500) {
336
        osiclp->setupForRepeatedUse(2, 0);
337
      }
338
#endif
339

	
340
      CbcRounding heuristic1(*_cbc_model);
341
      heuristic1.setWhen(3);
342
      _cbc_model->addHeuristic(&heuristic1);
343

	
344
      CbcHeuristicLocal heuristic2(*_cbc_model);
345
      heuristic2.setWhen(3);
346
      _cbc_model->addHeuristic(&heuristic2);
347

	
348
      CbcHeuristicGreedyCover heuristic3(*_cbc_model);
349
      heuristic3.setAlgorithm(11);
350
      heuristic3.setWhen(3);
351
      _cbc_model->addHeuristic(&heuristic3);
352

	
353
      CbcHeuristicFPump heuristic4(*_cbc_model);
354
      heuristic4.setWhen(3);
355
      _cbc_model->addHeuristic(&heuristic4);
356

	
357
      CbcHeuristicRINS heuristic5(*_cbc_model);
358
      heuristic5.setWhen(3);
359
      _cbc_model->addHeuristic(&heuristic5);
360

	
361
      if (_cbc_model->getNumCols() < 500) {
362
        _cbc_model->setMaximumCutPassesAtRoot(-100);
363
      } else if (_cbc_model->getNumCols() < 5000) {
364
        _cbc_model->setMaximumCutPassesAtRoot(100);
365
      } else {
366
        _cbc_model->setMaximumCutPassesAtRoot(20);
367
      }
368

	
369
      if (_cbc_model->getNumCols() < 5000) {
370
        _cbc_model->setNumberStrong(10);
371
      }
372

	
373
      _cbc_model->solver()->setIntParam(OsiMaxNumIterationHotStart, 100);
374
      _cbc_model->branchAndBound();
375
    }
376

	
377
    if (_cbc_model->isAbandoned()) {
378
      return UNSOLVED;
379
    } else {
380
      return SOLVED;
381
    }
382
  }
383

	
384
  CbcMip::Value CbcMip::_getSol(int i) const {
385
    return _cbc_model->getColSolution()[i];
386
  }
387

	
388
  CbcMip::Value CbcMip::_getSolValue() const {
389
    return _cbc_model->getObjValue();
390
  }
391

	
392
  CbcMip::ProblemType CbcMip::_getType() const {
393
    if (_cbc_model->isProvenOptimal()) {
394
      return OPTIMAL;
395
    } else if (_cbc_model->isContinuousUnbounded()) {
396
      return UNBOUNDED;
397
    }
398
    return FEASIBLE;
399
  }
400

	
401
  void CbcMip::_setSense(Sense sense) {
402
    switch (sense) {
403
    case MIN:
404
      _prob->setOptimizationDirection(1.0);
405
      break;
406
    case MAX:
407
      _prob->setOptimizationDirection(- 1.0);
408
      break;
409
    }
410
  }
411

	
412
  CbcMip::Sense CbcMip::_getSense() const {
413
    if (_prob->optimizationDirection() > 0.0) {
414
      return MIN;
415
    } else if (_prob->optimizationDirection() < 0.0) {
416
      return MAX;
417
    } else {
418
      LEMON_ASSERT(false, "Wrong sense");
419
      return CbcMip::Sense();
420
    }
421
  }
422

	
423
  void CbcMip::_setColType(int i, CbcMip::ColTypes col_type) {
424
    switch (col_type){
425
    case INTEGER:
426
      _prob->setInteger(i);
427
      break;
428
    case REAL:
429
      _prob->setContinuous(i);
430
      break;
431
    default:;
432
      LEMON_ASSERT(false, "Wrong sense");
433
    }
434
  }
435

	
436
  CbcMip::ColTypes CbcMip::_getColType(int i) const {
437
    return _prob->getColumnIsInteger(i) ? INTEGER : REAL;
438
  }
439

	
440
  void CbcMip::_clear() {
441
    delete _prob;
442
    if (_osi_solver) {
443
      delete _osi_solver;
444
      _osi_solver = 0;
445
    }
446
    if (_cbc_model) {
447
      delete _cbc_model;
448
      _cbc_model = 0;
449
    }
450

	
451
    _prob = new CoinModel();
452
    rows.clear();
453
    cols.clear();
454
  }
455

	
456
  void CbcMip::messageLevel(MessageLevel m) {
457
    _message_level = m;
458
  }
459

	
460
} //END OF NAMESPACE LEMON
Ignore white space 6 line context
1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2
 *
3
 * This file is a part of LEMON, a generic C++ optimization library.
4
 *
5
 * Copyright (C) 2003-2009
6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8
 *
9
 * Permission to use, modify and distribute this software is granted
10
 * provided that this copyright notice appears in all copies. For
11
 * precise terms see the accompanying LICENSE file.
12
 *
13
 * This software is provided "AS IS" with no warranty of any kind,
14
 * express or implied, and with no claim as to its suitability for any
15
 * purpose.
16
 *
17
 */
18

	
19
// -*- C++ -*-
20
#ifndef LEMON_CBC_H
21
#define LEMON_CBC_H
22

	
23
///\file
24
///\brief Header of the LEMON-CBC mip solver interface.
25
///\ingroup lp_group
26

	
27
#include <lemon/lp_base.h>
28

	
29
class CoinModel;
30
class OsiSolverInterface;
31
class CbcModel;
32

	
33
namespace lemon {
34

	
35
  /// \brief Interface for the CBC MIP solver
36
  ///
37
  /// This class implements an interface for the CBC MIP solver.
38
  ///\ingroup lp_group
39
  class CbcMip : public MipSolver {
40
  protected:
41

	
42
    CoinModel *_prob;
43
    OsiSolverInterface *_osi_solver;
44
    CbcModel *_cbc_model;
45

	
46
  public:
47

	
48
    /// \e
49
    CbcMip();
50
    /// \e
51
    CbcMip(const CbcMip&);
52
    /// \e
53
    ~CbcMip();
54
    /// \e
55
    virtual CbcMip* newSolver() const;
56
    /// \e
57
    virtual CbcMip* cloneSolver() const;
58

	
59
  protected:
60

	
61
    virtual const char* _solverName() const;
62

	
63
    virtual int _addCol();
64
    virtual int _addRow();
65

	
66
    virtual void _eraseCol(int i);
67
    virtual void _eraseRow(int i);
68

	
69
    virtual void _eraseColId(int i);
70
    virtual void _eraseRowId(int i);
71

	
72
    virtual void _getColName(int col, std::string& name) const;
73
    virtual void _setColName(int col, const std::string& name);
74
    virtual int _colByName(const std::string& name) const;
75

	
76
    virtual void _getRowName(int row, std::string& name) const;
77
    virtual void _setRowName(int row, const std::string& name);
78
    virtual int _rowByName(const std::string& name) const;
79

	
80
    virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
81
    virtual void _getRowCoeffs(int i, InsertIterator b) const;
82

	
83
    virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
84
    virtual void _getColCoeffs(int i, InsertIterator b) const;
85

	
86
    virtual void _setCoeff(int row, int col, Value value);
87
    virtual Value _getCoeff(int row, int col) const;
88

	
89
    virtual void _setColLowerBound(int i, Value value);
90
    virtual Value _getColLowerBound(int i) const;
91
    virtual void _setColUpperBound(int i, Value value);
92
    virtual Value _getColUpperBound(int i) const;
93

	
94
    virtual void _setRowLowerBound(int i, Value value);
95
    virtual Value _getRowLowerBound(int i) const;
96
    virtual void _setRowUpperBound(int i, Value value);
97
    virtual Value _getRowUpperBound(int i) const;
98

	
99
    virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
100
    virtual void _getObjCoeffs(InsertIterator b) const;
101

	
102
    virtual void _setObjCoeff(int i, Value obj_coef);
103
    virtual Value _getObjCoeff(int i) const;
104

	
105
    virtual void _setSense(Sense sense);
106
    virtual Sense _getSense() const;
107

	
108
    virtual ColTypes _getColType(int col) const;
109
    virtual void _setColType(int col, ColTypes col_type);
110

	
111
    virtual SolveExitStatus _solve();
112
    virtual ProblemType _getType() const;
113
    virtual Value _getSol(int i) const;
114
    virtual Value _getSolValue() const;
115

	
116
    virtual void _clear();
117

	
118
  public:
119

	
120
    ///Enum for \c messageLevel() parameter
121
    enum MessageLevel {
122
      /// no output (default value)
123
      MESSAGE_NO_OUTPUT = 0,
124
      /// error messages only
125
      MESSAGE_ERROR_MESSAGE = 1,
126
      /// normal output
127
      MESSAGE_NORMAL_OUTPUT = 2,
128
      /// full output (includes informational messages)
129
      MESSAGE_FULL_OUTPUT = 3
130
    };
131

	
132
  private:
133

	
134
    MessageLevel _message_level;
135

	
136
  public:
137

	
138
    ///Set the verbosity of the messages
139

	
140
    ///Set the verbosity of the messages
141
    ///
142
    ///\param m is the level of the messages output by the solver routines.
143
    void messageLevel(MessageLevel m);
144

	
145

	
146
  };
147

	
148
}
149

	
150
#endif
Ignore white space 6 line context
1
AC_DEFUN([LX_CHECK_CBC],
2
[
3
  AC_ARG_WITH([cbc],
4
AS_HELP_STRING([--with-cbc@<:@=PREFIX@:>@], [search for CBC under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
5
AS_HELP_STRING([--without-cbc], [disable checking for CBC]),
6
              [], [with_cbc=yes])
7

	
8
  AC_ARG_WITH([cbc-includedir],
9
AS_HELP_STRING([--with-cbc-includedir=DIR], [search for CBC headers in DIR]),
10
              [], [with_cbc_includedir=no])
11

	
12
  AC_ARG_WITH([cbc-libdir],
13
AS_HELP_STRING([--with-cbc-libdir=DIR], [search for CBC libraries in DIR]),
14
              [], [with_cbc_libdir=no])
15

	
16
  lx_cbc_found=no
17
  if test x"$with_cbc" != x"no"; then
18
    AC_MSG_CHECKING([for CBC])
19

	
20
    if test x"$with_cbc_includedir" != x"no"; then
21
      CBC_CXXFLAGS="-I$with_cbc_includedir"
22
    elif test x"$with_cbc" != x"yes"; then
23
      CBC_CXXFLAGS="-I$with_cbc/include"
24
    fi
25

	
26
    if test x"$with_cbc_libdir" != x"no"; then
27
      CBC_LDFLAGS="-L$with_cbc_libdir"
28
    elif test x"$with_cbc" != x"yes"; then
29
      CBC_LDFLAGS="-L$with_cbc/lib"
30
    fi
31
    CBC_LIBS="-lOsi -lCbc -lOsiCbc -lCbcSolver -lClp -lOsiClp -lCoinUtils -lVol -lOsiVol -lCgl -lm -llapack -lblas"
32

	
33
    lx_save_cxxflags="$CXXFLAGS"
34
    lx_save_ldflags="$LDFLAGS"
35
    lx_save_libs="$LIBS"
36
    CXXFLAGS="$CBC_CXXFLAGS"
37
    LDFLAGS="$CBC_LDFLAGS"
38
    LIBS="$CBC_LIBS"
39

	
40
    lx_cbc_test_prog='
41
      #include <coin/CbcModel.hpp>
42

	
43
      int main(int argc, char** argv)
44
      {
45
        CbcModel cbc;
46
        return 0;
47
      }'
48

	
49
    AC_LANG_PUSH(C++)
50
    AC_LINK_IFELSE([$lx_cbc_test_prog], [lx_cbc_found=yes], [lx_cbc_found=no])
51
    AC_LANG_POP(C++)
52

	
53
    CXXFLAGS="$lx_save_cxxflags"
54
    LDFLAGS="$lx_save_ldflags"
55
    LIBS="$lx_save_libs"
56

	
57
    if test x"$lx_cbc_found" = x"yes"; then
58
      AC_DEFINE([HAVE_CBC], [1], [Define to 1 if you have CBC.])
59
      lx_lp_found=yes
60
      AC_DEFINE([HAVE_LP], [1], [Define to 1 if you have any LP solver.])
61
      AC_MSG_RESULT([yes])
62
    else
63
      CBC_CXXFLAGS=""
64
      CBC_LDFLAGS=""
65
      CBC_LIBS=""
66
      AC_MSG_RESULT([no])
67
    fi
68
  fi
69
  CBC_LIBS="$CBC_LDFLAGS $CBC_LIBS"
70
  AC_SUBST(CBC_CXXFLAGS)
71
  AC_SUBST(CBC_LIBS)
72
  AM_CONDITIONAL([HAVE_CBC], [test x"$lx_cbc_found" = x"yes"])
73
])
Show white space 6 line context
... ...
@@ -13,2 +13,4 @@
13 13
	m4/lx_check_soplex.m4 \
14
	m4/lx_check_clp.m4 \
15
	m4/lx_check_cbc.m4 \
14 16
	CMakeLists.txt \
Ignore white space 6 line context
... ...
@@ -62,2 +62,3 @@
62 62
LX_CHECK_CLP
63
LX_CHECK_CBC
63 64

	
... ...
@@ -121,2 +122,3 @@
121 122
echo CLP support................... : $lx_clp_found
123
echo CBC support................... : $lx_cbc_found
122 124
echo
Ignore white space 6 line context
... ...
@@ -14,3 +14,3 @@
14 14
	lemon/lp_skeleton.cc \
15
        lemon/random.cc \
15
	lemon/random.cc \
16 16
	lemon/bits/windows.cc
... ...
@@ -23,3 +23,4 @@
23 23
	$(SOPLEX_CXXFLAGS) \
24
	$(CLP_CXXFLAGS)
24
	$(CLP_CXXFLAGS) \
25
	$(CBC_CXXFLAGS)
25 26

	
... ...
@@ -29,3 +30,4 @@
29 30
	$(SOPLEX_LIBS) \
30
	$(CLP_LIBS)
31
	$(CLP_LIBS) \
32
	$(CBC_LIBS)
31 33

	
... ...
@@ -47,2 +49,6 @@
47 49

	
50
if HAVE_CBC
51
lemon_libemon_la_SOURCES += lemon/cbc.cc
52
endif
53

	
48 54
lemon_HEADERS += \
Ignore white space 6 line context
... ...
@@ -20,1 +20,4 @@
20 20
#undef HAVE_CLP
21

	
22
/* Define to 1 if you have CBC */
23
#undef HAVE_CBC
Ignore white space 6 line context
... ...
@@ -20,3 +20,2 @@
20 20

	
21

	
22 21
#ifdef HAVE_CONFIG_H
... ...
@@ -33,2 +32,6 @@
33 32

	
33
#ifdef HAVE_CBC
34
#include <lemon/cbc.h>
35
#endif
36

	
34 37

	
... ...
@@ -59,3 +62,3 @@
59 62
{
60
 //The following example is very simple
63
  //The following example is very simple
61 64

	
... ...
@@ -66,3 +69,2 @@
66 69

	
67

	
68 70
  Col x1 = mip.addCol();
... ...
@@ -76,3 +78,2 @@
76 78

	
77

	
78 79
  //Unconstrained optimization
... ...
@@ -82,4 +83,4 @@
82 83
  //Constraints
83
  mip.addRow(2*x1+x2 <=2);
84
  mip.addRow(x1-2*x2 <=0);
84
  mip.addRow(2 * x1 + x2 <= 2);
85
  Row y2 = mip.addRow(x1 - 2 * x2 <= 0);
85 86

	
... ...
@@ -88,2 +89,3 @@
88 89

	
90

	
89 91
  //Maximization of x1
... ...
@@ -93,2 +95,3 @@
93 95

	
96

	
94 97
  //Restrict x2 to integer
... ...
@@ -104,3 +107,7 @@
104 107

	
105

	
108
  //Erase a variable
109
  mip.erase(x2);
110
  mip.rowUpperBound(y2, 8);
111
  expected_opt=1;
112
  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
106 113

	
... ...
@@ -108,2 +115,3 @@
108 115

	
116

	
109 117
template<class MIP>
... ...
@@ -146,2 +154,10 @@
146 154

	
155
#ifdef HAVE_CBC
156
  {
157
    CbcMip mip1;
158
    aTest(mip1);
159
    cloneTest<CbcMip>();
160
  }
161
#endif
162

	
147 163
  return 0;
0 comments (0 inline)