lemon/cbc.cc
changeset 993 ad40f7d32846
parent 746 e4554cd6b2bf
parent 955 8d281761dea4
child 966 08712a8c3afe
equal deleted inserted replaced
2:d215b9987f23 7:a9828933c3d5
    23 
    23 
    24 #include <coin/CoinModel.hpp>
    24 #include <coin/CoinModel.hpp>
    25 #include <coin/CbcModel.hpp>
    25 #include <coin/CbcModel.hpp>
    26 #include <coin/OsiSolverInterface.hpp>
    26 #include <coin/OsiSolverInterface.hpp>
    27 
    27 
    28 #ifdef COIN_HAS_CLP
       
    29 #include "coin/OsiClpSolverInterface.hpp"
    28 #include "coin/OsiClpSolverInterface.hpp"
    30 #endif
       
    31 #ifdef COIN_HAS_OSL
       
    32 #include "coin/OsiOslSolverInterface.hpp"
       
    33 #endif
       
    34 
    29 
    35 #include "coin/CbcCutGenerator.hpp"
    30 #include "coin/CbcCutGenerator.hpp"
    36 #include "coin/CbcHeuristicLocal.hpp"
    31 #include "coin/CbcHeuristicLocal.hpp"
    37 #include "coin/CbcHeuristicGreedy.hpp"
    32 #include "coin/CbcHeuristicGreedy.hpp"
    38 #include "coin/CbcHeuristicFPump.hpp"
    33 #include "coin/CbcHeuristicFPump.hpp"
   268   CbcMip::SolveExitStatus CbcMip::_solve() {
   263   CbcMip::SolveExitStatus CbcMip::_solve() {
   269 
   264 
   270     if (_osi_solver) {
   265     if (_osi_solver) {
   271       delete _osi_solver;
   266       delete _osi_solver;
   272     }
   267     }
   273 #ifdef COIN_HAS_CLP
       
   274     _osi_solver = new OsiClpSolverInterface();
   268     _osi_solver = new OsiClpSolverInterface();
   275 #elif COIN_HAS_OSL
       
   276     _osi_solver = new OsiOslSolverInterface();
       
   277 #else
       
   278 #error Cannot instantiate Osi solver
       
   279 #endif
       
   280 
   269 
   281     _osi_solver->loadFromCoinModel(*_prob);
   270     _osi_solver->loadFromCoinModel(*_prob);
   282 
   271 
   283     if (_cbc_model) {
   272     if (_cbc_model) {
   284       delete _cbc_model;
   273       delete _cbc_model;
   326       _cbc_model->addCutGenerator(&mixedGen, -1, "MixedIntegerRounding");
   315       _cbc_model->addCutGenerator(&mixedGen, -1, "MixedIntegerRounding");
   327 
   316 
   328       CglFlowCover flowGen;
   317       CglFlowCover flowGen;
   329       _cbc_model->addCutGenerator(&flowGen, -1, "FlowCover");
   318       _cbc_model->addCutGenerator(&flowGen, -1, "FlowCover");
   330 
   319 
   331 #ifdef COIN_HAS_CLP
       
   332       OsiClpSolverInterface* osiclp =
   320       OsiClpSolverInterface* osiclp =
   333         dynamic_cast<OsiClpSolverInterface*>(_cbc_model->solver());
   321         dynamic_cast<OsiClpSolverInterface*>(_cbc_model->solver());
   334       if (osiclp->getNumRows() < 300 && osiclp->getNumCols() < 500) {
   322       if (osiclp->getNumRows() < 300 && osiclp->getNumCols() < 500) {
   335         osiclp->setupForRepeatedUse(2, 0);
   323         osiclp->setupForRepeatedUse(2, 0);
   336       }
   324       }
   337 #endif
       
   338 
   325 
   339       CbcRounding heuristic1(*_cbc_model);
   326       CbcRounding heuristic1(*_cbc_model);
   340       heuristic1.setWhen(3);
   327       heuristic1.setWhen(3);
   341       _cbc_model->addHeuristic(&heuristic1);
   328       _cbc_model->addHeuristic(&heuristic1);
   342 
   329 
   446       delete _cbc_model;
   433       delete _cbc_model;
   447       _cbc_model = 0;
   434       _cbc_model = 0;
   448     }
   435     }
   449 
   436 
   450     _prob = new CoinModel();
   437     _prob = new CoinModel();
   451     rows.clear();
       
   452     cols.clear();
       
   453   }
   438   }
   454 
   439 
   455   void CbcMip::_messageLevel(MessageLevel level) {
   440   void CbcMip::_messageLevel(MessageLevel level) {
   456     switch (level) {
   441     switch (level) {
   457     case MESSAGE_NOTHING:
   442     case MESSAGE_NOTHING: