gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Make CBC interface compatible with latest CBC releases CBC now uses the CLP backend unconditionally
0 2 0
default
2 files changed with 22 insertions and 16 deletions:
↑ Collapse diff ↑
Ignore white space 50331648 line context
1 1
SET(COIN_ROOT_DIR "" CACHE PATH "COIN root directory")
2 2

	
3 3
FIND_PATH(COIN_INCLUDE_DIR coin/CoinUtilsConfig.h
4 4
  HINTS ${COIN_ROOT_DIR}/include
5 5
)
6 6
FIND_LIBRARY(COIN_CBC_LIBRARY
7 7
  NAMES Cbc libCbc
8 8
  HINTS ${COIN_ROOT_DIR}/lib/coin
9 9
  HINTS ${COIN_ROOT_DIR}/lib
10 10
)
11 11
FIND_LIBRARY(COIN_CBC_SOLVER_LIBRARY
12 12
  NAMES CbcSolver libCbcSolver
13 13
  HINTS ${COIN_ROOT_DIR}/lib/coin
14 14
  HINTS ${COIN_ROOT_DIR}/lib
15 15
)
16 16
FIND_LIBRARY(COIN_CGL_LIBRARY
17 17
  NAMES Cgl libCgl
18 18
  HINTS ${COIN_ROOT_DIR}/lib/coin
19 19
  HINTS ${COIN_ROOT_DIR}/lib
20 20
)
21 21
FIND_LIBRARY(COIN_CLP_LIBRARY
22 22
  NAMES Clp libClp
23 23
  HINTS ${COIN_ROOT_DIR}/lib/coin
24 24
  HINTS ${COIN_ROOT_DIR}/lib
25 25
)
26 26
FIND_LIBRARY(COIN_COIN_UTILS_LIBRARY
27 27
  NAMES CoinUtils libCoinUtils
28 28
  HINTS ${COIN_ROOT_DIR}/lib/coin
29 29
  HINTS ${COIN_ROOT_DIR}/lib
30 30
)
31 31
FIND_LIBRARY(COIN_OSI_LIBRARY
32 32
  NAMES Osi libOsi
33 33
  HINTS ${COIN_ROOT_DIR}/lib/coin
34 34
  HINTS ${COIN_ROOT_DIR}/lib
35 35
)
36 36
FIND_LIBRARY(COIN_OSI_CBC_LIBRARY
37 37
  NAMES OsiCbc libOsiCbc
38 38
  HINTS ${COIN_ROOT_DIR}/lib/coin
39 39
  HINTS ${COIN_ROOT_DIR}/lib
40 40
)
41 41
FIND_LIBRARY(COIN_OSI_CLP_LIBRARY
42 42
  NAMES OsiClp libOsiClp
43 43
  HINTS ${COIN_ROOT_DIR}/lib/coin
44 44
  HINTS ${COIN_ROOT_DIR}/lib
45 45
)
46 46
FIND_LIBRARY(COIN_OSI_VOL_LIBRARY
47 47
  NAMES OsiVol libOsiVol
48 48
  HINTS ${COIN_ROOT_DIR}/lib/coin
49 49
  HINTS ${COIN_ROOT_DIR}/lib
50 50
)
51 51
FIND_LIBRARY(COIN_VOL_LIBRARY
52 52
  NAMES Vol libVol
53 53
  HINTS ${COIN_ROOT_DIR}/lib/coin
54 54
  HINTS ${COIN_ROOT_DIR}/lib
55 55
)
56 56

	
57
FIND_LIBRARY(COIN_ZLIB_LIBRARY
58
  NAMES z libz
59
  HINTS ${COIN_ROOT_DIR}/lib/coin
60
  HINTS ${COIN_ROOT_DIR}/lib
61
)
62
FIND_LIBRARY(COIN_BZ2_LIBRARY
63
  NAMES bz2 libbz2
64
  HINTS ${COIN_ROOT_DIR}/lib/coin
65
  HINTS ${COIN_ROOT_DIR}/lib
66
)
67

	
57 68
INCLUDE(FindPackageHandleStandardArgs)
58 69
FIND_PACKAGE_HANDLE_STANDARD_ARGS(COIN DEFAULT_MSG
59 70
  COIN_INCLUDE_DIR
60 71
  COIN_CBC_LIBRARY
61 72
  COIN_CBC_SOLVER_LIBRARY
62 73
  COIN_CGL_LIBRARY
63 74
  COIN_CLP_LIBRARY
64 75
  COIN_COIN_UTILS_LIBRARY
65 76
  COIN_OSI_LIBRARY
66 77
  COIN_OSI_CBC_LIBRARY
67 78
  COIN_OSI_CLP_LIBRARY
68 79
  # COIN_OSI_VOL_LIBRARY
69 80
  # COIN_VOL_LIBRARY
70 81
)
71 82

	
72 83
IF(COIN_FOUND)
73 84
  SET(COIN_INCLUDE_DIRS ${COIN_INCLUDE_DIR})
74
  SET(COIN_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY}")
75
  SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY}")
76
  SET(COIN_CBC_LIBRARIES ${COIN_LIBRARIES})
85
  SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY};${COIN_ZLIB_LIBRARY};${COIN_BZ2_LIBRARY}")
86
  IF(COIN_ZLIB_LIBRARY)
87
    SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_ZLIB_LIBRARY}")
88
  ENDIF(COIN_ZLIB_LIBRARY)
89
   IF(COIN_BZ2_LIBRARY)
90
    SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_BZ2_LIBRARY}")
91
  ENDIF(COIN_BZ2_LIBRARY)
92
  SET(COIN_CBC_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_ZLIB_LIBRARY};${COIN_BZ2_LIBRARY};${COIN_CLP_LIBRARIES}")
93
  SET(COIN_LIBRARIES ${COIN_CBC_LIBRARIES})
77 94
ENDIF(COIN_FOUND)
78 95

	
79 96
MARK_AS_ADVANCED(
80 97
  COIN_INCLUDE_DIR
81 98
  COIN_CBC_LIBRARY
82 99
  COIN_CBC_SOLVER_LIBRARY
83 100
  COIN_CGL_LIBRARY
84 101
  COIN_CLP_LIBRARY
85 102
  COIN_COIN_UTILS_LIBRARY
86 103
  COIN_OSI_LIBRARY
87 104
  COIN_OSI_CBC_LIBRARY
88 105
  COIN_OSI_CLP_LIBRARY
89 106
  COIN_OSI_VOL_LIBRARY
90 107
  COIN_VOL_LIBRARY
108
  COIN_ZLIB_LIBRARY
109
  COIN_BZ2_LIBRARY
91 110
)
92 111

	
93 112
IF(COIN_FOUND)
94 113
  SET(LEMON_HAVE_LP TRUE)
95 114
  SET(LEMON_HAVE_MIP TRUE)
96 115
  SET(LEMON_HAVE_CLP TRUE)
97 116
  SET(LEMON_HAVE_CBC TRUE)
98 117
ENDIF(COIN_FOUND)
Ignore white space 6 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

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

	
22 22
#include "cbc.h"
23 23

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

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

	
35 30
#include "coin/CbcCutGenerator.hpp"
36 31
#include "coin/CbcHeuristicLocal.hpp"
37 32
#include "coin/CbcHeuristicGreedy.hpp"
38 33
#include "coin/CbcHeuristicFPump.hpp"
39 34
#include "coin/CbcHeuristicRINS.hpp"
40 35

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

	
49 44
#include "coin/CbcHeuristic.hpp"
50 45

	
51 46
namespace lemon {
52 47

	
53 48
  CbcMip::CbcMip() {
54 49
    _prob = new CoinModel();
55 50
    _prob->setProblemName("LEMON");
56 51
    _osi_solver = 0;
57 52
    _cbc_model = 0;
58 53
    messageLevel(MESSAGE_NOTHING);
59 54
  }
60 55

	
61 56
  CbcMip::CbcMip(const CbcMip& other) {
62 57
    _prob = new CoinModel(*other._prob);
63 58
    _prob->setProblemName("LEMON");
64 59
    _osi_solver = 0;
65 60
    _cbc_model = 0;
66 61
    messageLevel(MESSAGE_NOTHING);
67 62
  }
68 63

	
69 64
  CbcMip::~CbcMip() {
70 65
    delete _prob;
71 66
    if (_osi_solver) delete _osi_solver;
72 67
    if (_cbc_model) delete _cbc_model;
73 68
  }
74 69

	
75 70
  const char* CbcMip::_solverName() const { return "CbcMip"; }
76 71

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

	
82 77
  CbcMip* CbcMip::newSolver() const {
83 78
    CbcMip* newlp = new CbcMip;
84 79
    return newlp;
85 80
  }
86 81

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

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

	
97 92

	
98 93
  void CbcMip::_eraseCol(int i) {
99 94
    _prob->deleteColumn(i);
100 95
  }
101 96

	
102 97
  void CbcMip::_eraseRow(int i) {
103 98
    _prob->deleteRow(i);
104 99
  }
105 100

	
106 101
  void CbcMip::_eraseColId(int i) {
107 102
    cols.eraseIndex(i);
108 103
  }
109 104

	
110 105
  void CbcMip::_eraseRowId(int i) {
111 106
    rows.eraseIndex(i);
112 107
  }
113 108

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

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

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

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

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

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

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

	
144 139
  void CbcMip::_getRowCoeffs(int ix, InsertIterator b) const {
145 140
    int length = _prob->numberRows();
146 141

	
147 142
    std::vector<int> indices(length);
148 143
    std::vector<Value> values(length);
149 144

	
150 145
    length = _prob->getRow(ix, &indices[0], &values[0]);
151 146

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

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

	
164 159
  void CbcMip::_getColCoeffs(int ix, InsertIterator b) const {
165 160
    int length = _prob->numberColumns();
166 161

	
167 162
    std::vector<int> indices(length);
168 163
    std::vector<Value> values(length);
169 164

	
170 165
    length = _prob->getColumn(ix, &indices[0], &values[0]);
171 166

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

	
178 173
  void CbcMip::_setCoeff(int ix, int jx, Value value) {
179 174
    _prob->setElement(ix, jx, value);
180 175
  }
181 176

	
182 177
  CbcMip::Value CbcMip::_getCoeff(int ix, int jx) const {
183 178
    return _prob->getElement(ix, jx);
184 179
  }
185 180

	
186 181

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

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

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

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

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

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

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

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

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

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

	
248 243
  void CbcMip::_setObjCoeff(int i, Value obj_coef) {
249 244
    _prob->setColumnObjective(i, obj_coef);
250 245
  }
251 246

	
252 247
  CbcMip::Value CbcMip::_getObjCoeff(int i) const {
253 248
    return _prob->getColumnObjective(i);
254 249
  }
255 250

	
256 251
  CbcMip::SolveExitStatus CbcMip::_solve() {
257 252

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

	
269 258
    _osi_solver->loadFromCoinModel(*_prob);
270 259

	
271 260
    if (_cbc_model) {
272 261
      delete _cbc_model;
273 262
    }
274 263
    _cbc_model= new CbcModel(*_osi_solver);
275 264

	
276 265
    _osi_solver->messageHandler()->setLogLevel(_message_level);
277 266
    _cbc_model->setLogLevel(_message_level);
278 267

	
279 268
    _cbc_model->initialSolve();
280 269
    _cbc_model->solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry);
281 270

	
282 271
    if (!_cbc_model->isInitialSolveAbandoned() &&
283 272
        _cbc_model->isInitialSolveProvenOptimal() &&
284 273
        !_cbc_model->isInitialSolveProvenPrimalInfeasible() &&
285 274
        !_cbc_model->isInitialSolveProvenDualInfeasible()) {
286 275

	
287 276
      CglProbing generator1;
288 277
      generator1.setUsingObjective(true);
289 278
      generator1.setMaxPass(3);
290 279
      generator1.setMaxProbe(100);
291 280
      generator1.setMaxLook(50);
292 281
      generator1.setRowCuts(3);
293 282
      _cbc_model->addCutGenerator(&generator1, -1, "Probing");
294 283

	
295 284
      CglGomory generator2;
296 285
      generator2.setLimit(300);
297 286
      _cbc_model->addCutGenerator(&generator2, -1, "Gomory");
298 287

	
299 288
      CglKnapsackCover generator3;
300 289
      _cbc_model->addCutGenerator(&generator3, -1, "Knapsack");
301 290

	
302 291
      CglOddHole generator4;
303 292
      generator4.setMinimumViolation(0.005);
304 293
      generator4.setMinimumViolationPer(0.00002);
305 294
      generator4.setMaximumEntries(200);
306 295
      _cbc_model->addCutGenerator(&generator4, -1, "OddHole");
307 296

	
308 297
      CglClique generator5;
309 298
      generator5.setStarCliqueReport(false);
310 299
      generator5.setRowCliqueReport(false);
311 300
      _cbc_model->addCutGenerator(&generator5, -1, "Clique");
312 301

	
313 302
      CglMixedIntegerRounding mixedGen;
314 303
      _cbc_model->addCutGenerator(&mixedGen, -1, "MixedIntegerRounding");
315 304

	
316 305
      CglFlowCover flowGen;
317 306
      _cbc_model->addCutGenerator(&flowGen, -1, "FlowCover");
318 307

	
319
#ifdef COIN_HAS_CLP
320 308
      OsiClpSolverInterface* osiclp =
321 309
        dynamic_cast<OsiClpSolverInterface*>(_cbc_model->solver());
322 310
      if (osiclp->getNumRows() < 300 && osiclp->getNumCols() < 500) {
323 311
        osiclp->setupForRepeatedUse(2, 0);
324 312
      }
325
#endif
326 313

	
327 314
      CbcRounding heuristic1(*_cbc_model);
328 315
      heuristic1.setWhen(3);
329 316
      _cbc_model->addHeuristic(&heuristic1);
330 317

	
331 318
      CbcHeuristicLocal heuristic2(*_cbc_model);
332 319
      heuristic2.setWhen(3);
333 320
      _cbc_model->addHeuristic(&heuristic2);
334 321

	
335 322
      CbcHeuristicGreedyCover heuristic3(*_cbc_model);
336 323
      heuristic3.setAlgorithm(11);
337 324
      heuristic3.setWhen(3);
338 325
      _cbc_model->addHeuristic(&heuristic3);
339 326

	
340 327
      CbcHeuristicFPump heuristic4(*_cbc_model);
341 328
      heuristic4.setWhen(3);
342 329
      _cbc_model->addHeuristic(&heuristic4);
343 330

	
344 331
      CbcHeuristicRINS heuristic5(*_cbc_model);
345 332
      heuristic5.setWhen(3);
346 333
      _cbc_model->addHeuristic(&heuristic5);
347 334

	
348 335
      if (_cbc_model->getNumCols() < 500) {
349 336
        _cbc_model->setMaximumCutPassesAtRoot(-100);
350 337
      } else if (_cbc_model->getNumCols() < 5000) {
351 338
        _cbc_model->setMaximumCutPassesAtRoot(100);
352 339
      } else {
353 340
        _cbc_model->setMaximumCutPassesAtRoot(20);
354 341
      }
355 342

	
356 343
      if (_cbc_model->getNumCols() < 5000) {
357 344
        _cbc_model->setNumberStrong(10);
358 345
      }
359 346

	
360 347
      _cbc_model->solver()->setIntParam(OsiMaxNumIterationHotStart, 100);
361 348
      _cbc_model->branchAndBound();
362 349
    }
363 350

	
364 351
    if (_cbc_model->isAbandoned()) {
365 352
      return UNSOLVED;
366 353
    } else {
367 354
      return SOLVED;
368 355
    }
369 356
  }
370 357

	
371 358
  CbcMip::Value CbcMip::_getSol(int i) const {
372 359
    return _cbc_model->getColSolution()[i];
373 360
  }
374 361

	
375 362
  CbcMip::Value CbcMip::_getSolValue() const {
376 363
    return _cbc_model->getObjValue();
377 364
  }
378 365

	
379 366
  CbcMip::ProblemType CbcMip::_getType() const {
380 367
    if (_cbc_model->isProvenOptimal()) {
381 368
      return OPTIMAL;
382 369
    } else if (_cbc_model->isContinuousUnbounded()) {
383 370
      return UNBOUNDED;
384 371
    }
385 372
    return FEASIBLE;
386 373
  }
387 374

	
388 375
  void CbcMip::_setSense(Sense sense) {
389 376
    switch (sense) {
390 377
    case MIN:
391 378
      _prob->setOptimizationDirection(1.0);
392 379
      break;
393 380
    case MAX:
394 381
      _prob->setOptimizationDirection(- 1.0);
395 382
      break;
396 383
    }
397 384
  }
398 385

	
399 386
  CbcMip::Sense CbcMip::_getSense() const {
400 387
    if (_prob->optimizationDirection() > 0.0) {
401 388
      return MIN;
402 389
    } else if (_prob->optimizationDirection() < 0.0) {
403 390
      return MAX;
404 391
    } else {
405 392
      LEMON_ASSERT(false, "Wrong sense");
406 393
      return CbcMip::Sense();
407 394
    }
408 395
  }
409 396

	
410 397
  void CbcMip::_setColType(int i, CbcMip::ColTypes col_type) {
411 398
    switch (col_type){
412 399
    case INTEGER:
413 400
      _prob->setInteger(i);
414 401
      break;
415 402
    case REAL:
416 403
      _prob->setContinuous(i);
417 404
      break;
418 405
    default:;
419 406
      LEMON_ASSERT(false, "Wrong sense");
420 407
    }
421 408
  }
422 409

	
423 410
  CbcMip::ColTypes CbcMip::_getColType(int i) const {
424 411
    return _prob->getColumnIsInteger(i) ? INTEGER : REAL;
425 412
  }
426 413

	
427 414
  void CbcMip::_clear() {
428 415
    delete _prob;
429 416
    if (_osi_solver) {
430 417
      delete _osi_solver;
431 418
      _osi_solver = 0;
432 419
    }
433 420
    if (_cbc_model) {
434 421
      delete _cbc_model;
435 422
      _cbc_model = 0;
436 423
    }
437 424

	
438 425
    _prob = new CoinModel();
439 426
    rows.clear();
440 427
    cols.clear();
441 428
  }
442 429

	
443 430
  void CbcMip::_messageLevel(MessageLevel level) {
444 431
    switch (level) {
445 432
    case MESSAGE_NOTHING:
446 433
      _message_level = 0;
447 434
      break;
448 435
    case MESSAGE_ERROR:
449 436
      _message_level = 1;
450 437
      break;
451 438
    case MESSAGE_WARNING:
452 439
      _message_level = 1;
453 440
      break;
454 441
    case MESSAGE_NORMAL:
455 442
      _message_level = 2;
456 443
      break;
457 444
    case MESSAGE_VERBOSE:
458 445
      _message_level = 3;
459 446
      break;
460 447
    }
461 448
  }
462 449

	
463 450
} //END OF NAMESPACE LEMON
0 comments (0 inline)