Location: LEMON/LEMON-official/lemon/cbc.cc - annotation
Load file history
Unify sources
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r623:745e182d0139 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r623:745e182d0139 r614:3314f58e7b25 r614:3314f58e7b25 r623:745e182d0139 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r623:745e182d0139 r623:745e182d0139 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r623:745e182d0139 r614:3314f58e7b25 r614:3314f58e7b25 r614:3314f58e7b25 | /* -*- mode: C++; indent-tabs-mode: nil; -*-
*
* This file is a part of LEMON, a generic C++ optimization library.
*
* Copyright (C) 2003-2009
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
*
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
*
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
* purpose.
*
*/
///\file
///\brief Implementation of the CBC MIP solver interface.
#include "cbc.h"
#include <coin/CoinModel.hpp>
#include <coin/CbcModel.hpp>
#include <coin/OsiSolverInterface.hpp>
#ifdef COIN_HAS_CLP
#include "coin/OsiClpSolverInterface.hpp"
#endif
#ifdef COIN_HAS_OSL
#include "coin/OsiOslSolverInterface.hpp"
#endif
#include "coin/CbcCutGenerator.hpp"
#include "coin/CbcHeuristicLocal.hpp"
#include "coin/CbcHeuristicGreedy.hpp"
#include "coin/CbcHeuristicFPump.hpp"
#include "coin/CbcHeuristicRINS.hpp"
#include "coin/CglGomory.hpp"
#include "coin/CglProbing.hpp"
#include "coin/CglKnapsackCover.hpp"
#include "coin/CglOddHole.hpp"
#include "coin/CglClique.hpp"
#include "coin/CglFlowCover.hpp"
#include "coin/CglMixedIntegerRounding.hpp"
#include "coin/CbcHeuristic.hpp"
namespace lemon {
CbcMip::CbcMip() {
_prob = new CoinModel();
_prob->setProblemName("LEMON");
_osi_solver = 0;
_cbc_model = 0;
messageLevel(MESSAGE_NOTHING);
}
CbcMip::CbcMip(const CbcMip& other) {
_prob = new CoinModel(*other._prob);
_prob->setProblemName("LEMON");
_osi_solver = 0;
_cbc_model = 0;
messageLevel(MESSAGE_NOTHING);
}
CbcMip::~CbcMip() {
delete _prob;
if (_osi_solver) delete _osi_solver;
if (_cbc_model) delete _cbc_model;
}
const char* CbcMip::_solverName() const { return "CbcMip"; }
int CbcMip::_addCol() {
_prob->addColumn(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX, 0.0, 0, false);
return _prob->numberColumns() - 1;
}
CbcMip* CbcMip::newSolver() const {
CbcMip* newlp = new CbcMip;
return newlp;
}
CbcMip* CbcMip::cloneSolver() const {
CbcMip* copylp = new CbcMip(*this);
return copylp;
}
int CbcMip::_addRow() {
_prob->addRow(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX);
return _prob->numberRows() - 1;
}
void CbcMip::_eraseCol(int i) {
_prob->deleteColumn(i);
}
void CbcMip::_eraseRow(int i) {
_prob->deleteRow(i);
}
void CbcMip::_eraseColId(int i) {
cols.eraseIndex(i);
}
void CbcMip::_eraseRowId(int i) {
rows.eraseIndex(i);
}
void CbcMip::_getColName(int c, std::string& name) const {
name = _prob->getColumnName(c);
}
void CbcMip::_setColName(int c, const std::string& name) {
_prob->setColumnName(c, name.c_str());
}
int CbcMip::_colByName(const std::string& name) const {
return _prob->column(name.c_str());
}
void CbcMip::_getRowName(int r, std::string& name) const {
name = _prob->getRowName(r);
}
void CbcMip::_setRowName(int r, const std::string& name) {
_prob->setRowName(r, name.c_str());
}
int CbcMip::_rowByName(const std::string& name) const {
return _prob->row(name.c_str());
}
void CbcMip::_setRowCoeffs(int i, ExprIterator b, ExprIterator e) {
for (ExprIterator it = b; it != e; ++it) {
_prob->setElement(i, it->first, it->second);
}
}
void CbcMip::_getRowCoeffs(int ix, InsertIterator b) const {
int length = _prob->numberRows();
std::vector<int> indices(length);
std::vector<Value> values(length);
length = _prob->getRow(ix, &indices[0], &values[0]);
for (int i = 0; i < length; ++i) {
*b = std::make_pair(indices[i], values[i]);
++b;
}
}
void CbcMip::_setColCoeffs(int ix, ExprIterator b, ExprIterator e) {
for (ExprIterator it = b; it != e; ++it) {
_prob->setElement(it->first, ix, it->second);
}
}
void CbcMip::_getColCoeffs(int ix, InsertIterator b) const {
int length = _prob->numberColumns();
std::vector<int> indices(length);
std::vector<Value> values(length);
length = _prob->getColumn(ix, &indices[0], &values[0]);
for (int i = 0; i < length; ++i) {
*b = std::make_pair(indices[i], values[i]);
++b;
}
}
void CbcMip::_setCoeff(int ix, int jx, Value value) {
_prob->setElement(ix, jx, value);
}
CbcMip::Value CbcMip::_getCoeff(int ix, int jx) const {
return _prob->getElement(ix, jx);
}
void CbcMip::_setColLowerBound(int i, Value lo) {
LEMON_ASSERT(lo != INF, "Invalid bound");
_prob->setColumnLower(i, lo == - INF ? - COIN_DBL_MAX : lo);
}
CbcMip::Value CbcMip::_getColLowerBound(int i) const {
double val = _prob->getColumnLower(i);
return val == - COIN_DBL_MAX ? - INF : val;
}
void CbcMip::_setColUpperBound(int i, Value up) {
LEMON_ASSERT(up != -INF, "Invalid bound");
_prob->setColumnUpper(i, up == INF ? COIN_DBL_MAX : up);
}
CbcMip::Value CbcMip::_getColUpperBound(int i) const {
double val = _prob->getColumnUpper(i);
return val == COIN_DBL_MAX ? INF : val;
}
void CbcMip::_setRowLowerBound(int i, Value lo) {
LEMON_ASSERT(lo != INF, "Invalid bound");
_prob->setRowLower(i, lo == - INF ? - COIN_DBL_MAX : lo);
}
CbcMip::Value CbcMip::_getRowLowerBound(int i) const {
double val = _prob->getRowLower(i);
return val == - COIN_DBL_MAX ? - INF : val;
}
void CbcMip::_setRowUpperBound(int i, Value up) {
LEMON_ASSERT(up != -INF, "Invalid bound");
_prob->setRowUpper(i, up == INF ? COIN_DBL_MAX : up);
}
CbcMip::Value CbcMip::_getRowUpperBound(int i) const {
double val = _prob->getRowUpper(i);
return val == COIN_DBL_MAX ? INF : val;
}
void CbcMip::_setObjCoeffs(ExprIterator b, ExprIterator e) {
int num = _prob->numberColumns();
for (int i = 0; i < num; ++i) {
_prob->setColumnObjective(i, 0.0);
}
for (ExprIterator it = b; it != e; ++it) {
_prob->setColumnObjective(it->first, it->second);
}
}
void CbcMip::_getObjCoeffs(InsertIterator b) const {
int num = _prob->numberColumns();
for (int i = 0; i < num; ++i) {
Value coef = _prob->getColumnObjective(i);
if (coef != 0.0) {
*b = std::make_pair(i, coef);
++b;
}
}
}
void CbcMip::_setObjCoeff(int i, Value obj_coef) {
_prob->setColumnObjective(i, obj_coef);
}
CbcMip::Value CbcMip::_getObjCoeff(int i) const {
return _prob->getColumnObjective(i);
}
CbcMip::SolveExitStatus CbcMip::_solve() {
if (_osi_solver) {
delete _osi_solver;
}
#ifdef COIN_HAS_CLP
_osi_solver = new OsiClpSolverInterface();
#elif COIN_HAS_OSL
_osi_solver = new OsiOslSolverInterface();
#else
#error Cannot instantiate Osi solver
#endif
_osi_solver->loadFromCoinModel(*_prob);
if (_cbc_model) {
delete _cbc_model;
}
_cbc_model= new CbcModel(*_osi_solver);
_osi_solver->messageHandler()->setLogLevel(_message_level);
_cbc_model->setLogLevel(_message_level);
_cbc_model->initialSolve();
_cbc_model->solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry);
if (!_cbc_model->isInitialSolveAbandoned() &&
_cbc_model->isInitialSolveProvenOptimal() &&
!_cbc_model->isInitialSolveProvenPrimalInfeasible() &&
!_cbc_model->isInitialSolveProvenDualInfeasible()) {
CglProbing generator1;
generator1.setUsingObjective(true);
generator1.setMaxPass(3);
generator1.setMaxProbe(100);
generator1.setMaxLook(50);
generator1.setRowCuts(3);
_cbc_model->addCutGenerator(&generator1, -1, "Probing");
CglGomory generator2;
generator2.setLimit(300);
_cbc_model->addCutGenerator(&generator2, -1, "Gomory");
CglKnapsackCover generator3;
_cbc_model->addCutGenerator(&generator3, -1, "Knapsack");
CglOddHole generator4;
generator4.setMinimumViolation(0.005);
generator4.setMinimumViolationPer(0.00002);
generator4.setMaximumEntries(200);
_cbc_model->addCutGenerator(&generator4, -1, "OddHole");
CglClique generator5;
generator5.setStarCliqueReport(false);
generator5.setRowCliqueReport(false);
_cbc_model->addCutGenerator(&generator5, -1, "Clique");
CglMixedIntegerRounding mixedGen;
_cbc_model->addCutGenerator(&mixedGen, -1, "MixedIntegerRounding");
CglFlowCover flowGen;
_cbc_model->addCutGenerator(&flowGen, -1, "FlowCover");
#ifdef COIN_HAS_CLP
OsiClpSolverInterface* osiclp =
dynamic_cast<OsiClpSolverInterface*>(_cbc_model->solver());
if (osiclp->getNumRows() < 300 && osiclp->getNumCols() < 500) {
osiclp->setupForRepeatedUse(2, 0);
}
#endif
CbcRounding heuristic1(*_cbc_model);
heuristic1.setWhen(3);
_cbc_model->addHeuristic(&heuristic1);
CbcHeuristicLocal heuristic2(*_cbc_model);
heuristic2.setWhen(3);
_cbc_model->addHeuristic(&heuristic2);
CbcHeuristicGreedyCover heuristic3(*_cbc_model);
heuristic3.setAlgorithm(11);
heuristic3.setWhen(3);
_cbc_model->addHeuristic(&heuristic3);
CbcHeuristicFPump heuristic4(*_cbc_model);
heuristic4.setWhen(3);
_cbc_model->addHeuristic(&heuristic4);
CbcHeuristicRINS heuristic5(*_cbc_model);
heuristic5.setWhen(3);
_cbc_model->addHeuristic(&heuristic5);
if (_cbc_model->getNumCols() < 500) {
_cbc_model->setMaximumCutPassesAtRoot(-100);
} else if (_cbc_model->getNumCols() < 5000) {
_cbc_model->setMaximumCutPassesAtRoot(100);
} else {
_cbc_model->setMaximumCutPassesAtRoot(20);
}
if (_cbc_model->getNumCols() < 5000) {
_cbc_model->setNumberStrong(10);
}
_cbc_model->solver()->setIntParam(OsiMaxNumIterationHotStart, 100);
_cbc_model->branchAndBound();
}
if (_cbc_model->isAbandoned()) {
return UNSOLVED;
} else {
return SOLVED;
}
}
CbcMip::Value CbcMip::_getSol(int i) const {
return _cbc_model->getColSolution()[i];
}
CbcMip::Value CbcMip::_getSolValue() const {
return _cbc_model->getObjValue();
}
CbcMip::ProblemType CbcMip::_getType() const {
if (_cbc_model->isProvenOptimal()) {
return OPTIMAL;
} else if (_cbc_model->isContinuousUnbounded()) {
return UNBOUNDED;
}
return FEASIBLE;
}
void CbcMip::_setSense(Sense sense) {
switch (sense) {
case MIN:
_prob->setOptimizationDirection(1.0);
break;
case MAX:
_prob->setOptimizationDirection(- 1.0);
break;
}
}
CbcMip::Sense CbcMip::_getSense() const {
if (_prob->optimizationDirection() > 0.0) {
return MIN;
} else if (_prob->optimizationDirection() < 0.0) {
return MAX;
} else {
LEMON_ASSERT(false, "Wrong sense");
return CbcMip::Sense();
}
}
void CbcMip::_setColType(int i, CbcMip::ColTypes col_type) {
switch (col_type){
case INTEGER:
_prob->setInteger(i);
break;
case REAL:
_prob->setContinuous(i);
break;
default:;
LEMON_ASSERT(false, "Wrong sense");
}
}
CbcMip::ColTypes CbcMip::_getColType(int i) const {
return _prob->getColumnIsInteger(i) ? INTEGER : REAL;
}
void CbcMip::_clear() {
delete _prob;
if (_osi_solver) {
delete _osi_solver;
_osi_solver = 0;
}
if (_cbc_model) {
delete _cbc_model;
_cbc_model = 0;
}
_prob = new CoinModel();
rows.clear();
cols.clear();
}
void CbcMip::_messageLevel(MessageLevel level) {
switch (level) {
case MESSAGE_NOTHING:
_message_level = 0;
break;
case MESSAGE_ERROR:
_message_level = 1;
break;
case MESSAGE_WARNING:
_message_level = 1;
break;
case MESSAGE_NORMAL:
_message_level = 2;
break;
case MESSAGE_VERBOSE:
_message_level = 3;
break;
}
}
} //END OF NAMESPACE LEMON
|