# HG changeset patch
# User Balazs Dezso <deba@inf.elte.hu>
# Date 1239311347 -7200
# Node ID 0cad57c38b5257a63834d4ba4bcd6f44006c61f7
# Parent d61d725c3959cbf22c4e0a04e22f5d7d2349ac76
Unified message handling for LP and MIP solvers (#9)
diff -r d61d725c3959 -r 0cad57c38b52 lemon/cbc.cc
|
a
|
b
|
|
| 55 | 55 | _prob->setProblemName("LEMON"); |
| 56 | 56 | _osi_solver = 0; |
| 57 | 57 | _cbc_model = 0; |
| 58 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 58 | messageLevel(MESSAGE_NOTHING); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | CbcMip::CbcMip(const CbcMip& other) { |
| 62 | 62 | _prob = new CoinModel(*other._prob); |
| | 63 | _prob->setProblemName("LEMON"); |
| 63 | 64 | _osi_solver = 0; |
| 64 | 65 | _cbc_model = 0; |
| 65 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 66 | messageLevel(MESSAGE_NOTHING); |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | 69 | CbcMip::~CbcMip() { |
| … |
… |
|
| 272 | 273 | } |
| 273 | 274 | _cbc_model= new CbcModel(*_osi_solver); |
| 274 | 275 | |
| 275 | | switch (_message_level) { |
| 276 | | case MESSAGE_NO_OUTPUT: |
| 277 | | _osi_solver->messageHandler()->setLogLevel(0); |
| 278 | | _cbc_model->setLogLevel(0); |
| 279 | | break; |
| 280 | | case MESSAGE_ERROR_MESSAGE: |
| 281 | | _osi_solver->messageHandler()->setLogLevel(1); |
| 282 | | _cbc_model->setLogLevel(1); |
| 283 | | break; |
| 284 | | case MESSAGE_NORMAL_OUTPUT: |
| 285 | | _osi_solver->messageHandler()->setLogLevel(2); |
| 286 | | _cbc_model->setLogLevel(2); |
| 287 | | break; |
| 288 | | case MESSAGE_FULL_OUTPUT: |
| 289 | | _osi_solver->messageHandler()->setLogLevel(3); |
| 290 | | _cbc_model->setLogLevel(3); |
| 291 | | break; |
| 292 | | } |
| | 276 | _osi_solver->messageHandler()->setLogLevel(_message_level); |
| | 277 | _cbc_model->setLogLevel(_message_level); |
| 293 | 278 | |
| 294 | 279 | _cbc_model->initialSolve(); |
| 295 | 280 | _cbc_model->solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry); |
| … |
… |
|
| 455 | 440 | cols.clear(); |
| 456 | 441 | } |
| 457 | 442 | |
| 458 | | void CbcMip::messageLevel(MessageLevel m) { |
| 459 | | _message_level = m; |
| | 443 | void CbcMip::_messageLevel(MessageLevel level) { |
| | 444 | switch (level) { |
| | 445 | case MESSAGE_NOTHING: |
| | 446 | _message_level = 0; |
| | 447 | break; |
| | 448 | case MESSAGE_ERROR: |
| | 449 | _message_level = 1; |
| | 450 | break; |
| | 451 | case MESSAGE_WARNING: |
| | 452 | _message_level = 1; |
| | 453 | break; |
| | 454 | case MESSAGE_NORMAL: |
| | 455 | _message_level = 2; |
| | 456 | break; |
| | 457 | case MESSAGE_VERBOSE: |
| | 458 | _message_level = 3; |
| | 459 | break; |
| | 460 | } |
| 460 | 461 | } |
| 461 | 462 | |
| 462 | 463 | } //END OF NAMESPACE LEMON |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/cbc.h
|
a
|
b
|
|
| 115 | 115 | |
| 116 | 116 | virtual void _clear(); |
| 117 | 117 | |
| 118 | | public: |
| | 118 | virtual void _messageLevel(MessageLevel level); |
| | 119 | void _applyMessageLevel(); |
| 119 | 120 | |
| 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 | | }; |
| | 121 | int _message_level; |
| 131 | 122 | |
| 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 | | |
| | 123 | |
| 145 | 124 | |
| 146 | 125 | }; |
| 147 | 126 | |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/clp.cc
|
a
|
b
|
|
| 24 | 24 | ClpLp::ClpLp() { |
| 25 | 25 | _prob = new ClpSimplex(); |
| 26 | 26 | _init_temporals(); |
| 27 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 27 | messageLevel(MESSAGE_NOTHING); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | ClpLp::ClpLp(const ClpLp& other) { |
| … |
… |
|
| 32 | 32 | rows = other.rows; |
| 33 | 33 | cols = other.cols; |
| 34 | 34 | _init_temporals(); |
| 35 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 35 | messageLevel(MESSAGE_NOTHING); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | ClpLp::~ClpLp() { |
| … |
… |
|
| 430 | 430 | _clear_temporals(); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | | void ClpLp::messageLevel(MessageLevel m) { |
| 434 | | _prob->setLogLevel(static_cast<int>(m)); |
| | 433 | void ClpLp::_messageLevel(MessageLevel level) { |
| | 434 | switch (level) { |
| | 435 | case MESSAGE_NOTHING: |
| | 436 | _prob->setLogLevel(0); |
| | 437 | break; |
| | 438 | case MESSAGE_ERROR: |
| | 439 | _prob->setLogLevel(1); |
| | 440 | break; |
| | 441 | case MESSAGE_WARNING: |
| | 442 | _prob->setLogLevel(2); |
| | 443 | break; |
| | 444 | case MESSAGE_NORMAL: |
| | 445 | _prob->setLogLevel(3); |
| | 446 | break; |
| | 447 | case MESSAGE_VERBOSE: |
| | 448 | _prob->setLogLevel(4); |
| | 449 | break; |
| | 450 | } |
| 435 | 451 | } |
| 436 | 452 | |
| 437 | 453 | } //END OF NAMESPACE LEMON |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/clp.h
|
a
|
b
|
|
| 136 | 136 | |
| 137 | 137 | virtual void _clear(); |
| 138 | 138 | |
| | 139 | virtual void _messageLevel(MessageLevel); |
| | 140 | |
| 139 | 141 | public: |
| 140 | 142 | |
| 141 | 143 | ///Solves LP with primal simplex method. |
| … |
… |
|
| 153 | 155 | ///Returns the variable identifier understood by CLP. |
| 154 | 156 | int clpCol(Col c) const { return cols(id(c)); } |
| 155 | 157 | |
| 156 | | ///Enum for \c messageLevel() parameter |
| 157 | | enum MessageLevel { |
| 158 | | /// no output (default value) |
| 159 | | MESSAGE_NO_OUTPUT = 0, |
| 160 | | /// print final solution |
| 161 | | MESSAGE_FINAL_SOLUTION = 1, |
| 162 | | /// print factorization |
| 163 | | MESSAGE_FACTORIZATION = 2, |
| 164 | | /// normal output |
| 165 | | MESSAGE_NORMAL_OUTPUT = 3, |
| 166 | | /// verbose output |
| 167 | | MESSAGE_VERBOSE_OUTPUT = 4 |
| 168 | | }; |
| 169 | | ///Set the verbosity of the messages |
| 170 | | |
| 171 | | ///Set the verbosity of the messages |
| 172 | | /// |
| 173 | | ///\param m is the level of the messages output by the solver routines. |
| 174 | | void messageLevel(MessageLevel m); |
| 175 | | |
| 176 | 158 | }; |
| 177 | 159 | |
| 178 | 160 | } //END OF NAMESPACE LEMON |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/cplex.cc
|
a
|
b
|
|
| 72 | 72 | CplexBase::CplexBase() : LpBase() { |
| 73 | 73 | int status; |
| 74 | 74 | _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem"); |
| 75 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 75 | messageLevel(MESSAGE_NOTHING); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | CplexBase::CplexBase(const CplexEnv& env) |
| 79 | 79 | : LpBase(), _env(env) { |
| 80 | 80 | int status; |
| 81 | 81 | _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem"); |
| 82 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 82 | messageLevel(MESSAGE_NOTHING); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | CplexBase::CplexBase(const CplexBase& cplex) |
| … |
… |
|
| 88 | 88 | _prob = CPXcloneprob(cplexEnv(), cplex._prob, &status); |
| 89 | 89 | rows = cplex.rows; |
| 90 | 90 | cols = cplex.cols; |
| 91 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 91 | messageLevel(MESSAGE_NOTHING); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | CplexBase::~CplexBase() { |
| … |
… |
|
| 441 | 441 | cols.clear(); |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | | void CplexBase::messageLevel(MessageLevel m) { |
| 445 | | _message_level = m; |
| | 444 | void CplexBase::_messageLevel(MessageLevel level) { |
| | 445 | switch (level) { |
| | 446 | case MESSAGE_NOTHING: |
| | 447 | _message_enabled = false; |
| | 448 | break; |
| | 449 | case MESSAGE_ERROR: |
| | 450 | case MESSAGE_WARNING: |
| | 451 | case MESSAGE_NORMAL: |
| | 452 | case MESSAGE_VERBOSE: |
| | 453 | _message_enabled = true; |
| | 454 | break; |
| | 455 | } |
| 446 | 456 | } |
| 447 | 457 | |
| 448 | | void CplexBase::setMessageLevel() { |
| 449 | | switch (_message_level) { |
| 450 | | case MESSAGE_NO_OUTPUT: |
| 451 | | CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, CPX_OFF); |
| 452 | | break; |
| 453 | | case MESSAGE_NORMAL_OUTPUT: |
| 454 | | CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, CPX_ON); |
| 455 | | break; |
| 456 | | } |
| | 458 | void CplexBase::_applyMessageLevel() { |
| | 459 | CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, |
| | 460 | _message_enabled ? CPX_ON : CPX_OFF); |
| 457 | 461 | } |
| 458 | 462 | |
| 459 | 463 | // CplexLp members |
| … |
… |
|
| 525 | 529 | |
| 526 | 530 | CplexLp::SolveExitStatus CplexLp::_solve() { |
| 527 | 531 | _clear_temporals(); |
| 528 | | setMessageLevel(); |
| | 532 | _applyMessageLevel(); |
| 529 | 533 | return convertStatus(CPXlpopt(cplexEnv(), _prob)); |
| 530 | 534 | } |
| 531 | 535 | |
| 532 | 536 | CplexLp::SolveExitStatus CplexLp::solvePrimal() { |
| 533 | 537 | _clear_temporals(); |
| 534 | | setMessageLevel(); |
| | 538 | _applyMessageLevel(); |
| 535 | 539 | return convertStatus(CPXprimopt(cplexEnv(), _prob)); |
| 536 | 540 | } |
| 537 | 541 | |
| 538 | 542 | CplexLp::SolveExitStatus CplexLp::solveDual() { |
| 539 | 543 | _clear_temporals(); |
| 540 | | setMessageLevel(); |
| | 544 | _applyMessageLevel(); |
| 541 | 545 | return convertStatus(CPXdualopt(cplexEnv(), _prob)); |
| 542 | 546 | } |
| 543 | 547 | |
| 544 | 548 | CplexLp::SolveExitStatus CplexLp::solveBarrier() { |
| 545 | 549 | _clear_temporals(); |
| 546 | | setMessageLevel(); |
| | 550 | _applyMessageLevel(); |
| 547 | 551 | return convertStatus(CPXbaropt(cplexEnv(), _prob)); |
| 548 | 552 | } |
| 549 | 553 | |
| … |
… |
|
| 885 | 889 | |
| 886 | 890 | CplexMip::SolveExitStatus CplexMip::_solve() { |
| 887 | 891 | int status; |
| 888 | | setMessageLevel(); |
| | 892 | _applyMessageLevel(); |
| 889 | 893 | status = CPXmipopt (cplexEnv(), _prob); |
| 890 | 894 | if (status==0) |
| 891 | 895 | return SOLVED; |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/cplex.h
|
a
|
b
|
|
| 144 | 144 | |
| 145 | 145 | virtual void _clear(); |
| 146 | 146 | |
| 147 | | public: |
| | 147 | virtual void _messageLevel(MessageLevel level); |
| | 148 | void _applyMessageLevel(); |
| 148 | 149 | |
| 149 | | ///Enum for \c messageLevel() parameter |
| 150 | | enum MessageLevel { |
| 151 | | /// no output (default value) |
| 152 | | MESSAGE_NO_OUTPUT, |
| 153 | | /// normal output |
| 154 | | MESSAGE_NORMAL_OUTPUT, |
| 155 | | }; |
| 156 | | |
| 157 | | protected: |
| 158 | | |
| 159 | | MessageLevel _message_level; |
| 160 | | |
| 161 | | void setMessageLevel(); |
| | 150 | bool _message_enabled; |
| 162 | 151 | |
| 163 | 152 | public: |
| 164 | 153 | |
| 165 | | ///Set the verbosity of the messages |
| 166 | | |
| 167 | | ///Set the verbosity of the messages |
| 168 | | /// |
| 169 | | ///\param m is the level of the messages output by the solver routines. |
| 170 | | void messageLevel(MessageLevel m); |
| 171 | | |
| 172 | 154 | /// Returns the used \c CplexEnv instance |
| 173 | 155 | const CplexEnv& env() const { return _env; } |
| 174 | 156 | |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/glpk.cc
|
a
|
b
|
|
| 31 | 31 | GlpkBase::GlpkBase() : LpBase() { |
| 32 | 32 | lp = glp_create_prob(); |
| 33 | 33 | glp_create_index(lp); |
| 34 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 34 | messageLevel(MESSAGE_NOTHING); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | GlpkBase::GlpkBase(const GlpkBase &other) : LpBase() { |
| … |
… |
|
| 40 | 40 | glp_create_index(lp); |
| 41 | 41 | rows = other.rows; |
| 42 | 42 | cols = other.cols; |
| 43 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 43 | messageLevel(MESSAGE_NOTHING); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | GlpkBase::~GlpkBase() { |
| … |
… |
|
| 528 | 528 | glp_free_env(); |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | | void GlpkBase::messageLevel(MessageLevel m) { |
| 532 | | _message_level = m; |
| | 531 | void GlpkBase::_messageLevel(MessageLevel level) { |
| | 532 | switch (level) { |
| | 533 | case MESSAGE_NOTHING: |
| | 534 | _message_level = GLP_MSG_OFF; |
| | 535 | break; |
| | 536 | case MESSAGE_ERROR: |
| | 537 | _message_level = GLP_MSG_ERR; |
| | 538 | break; |
| | 539 | case MESSAGE_WARNING: |
| | 540 | _message_level = GLP_MSG_ERR; |
| | 541 | break; |
| | 542 | case MESSAGE_NORMAL: |
| | 543 | _message_level = GLP_MSG_ON; |
| | 544 | break; |
| | 545 | case MESSAGE_VERBOSE: |
| | 546 | _message_level = GLP_MSG_ALL; |
| | 547 | break; |
| | 548 | } |
| 533 | 549 | } |
| 534 | 550 | |
| 535 | 551 | GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper; |
| … |
… |
|
| 566 | 582 | glp_smcp smcp; |
| 567 | 583 | glp_init_smcp(&smcp); |
| 568 | 584 | |
| 569 | | switch (_message_level) { |
| 570 | | case MESSAGE_NO_OUTPUT: |
| 571 | | smcp.msg_lev = GLP_MSG_OFF; |
| 572 | | break; |
| 573 | | case MESSAGE_ERROR_MESSAGE: |
| 574 | | smcp.msg_lev = GLP_MSG_ERR; |
| 575 | | break; |
| 576 | | case MESSAGE_NORMAL_OUTPUT: |
| 577 | | smcp.msg_lev = GLP_MSG_ON; |
| 578 | | break; |
| 579 | | case MESSAGE_FULL_OUTPUT: |
| 580 | | smcp.msg_lev = GLP_MSG_ALL; |
| 581 | | break; |
| 582 | | } |
| | 585 | smcp.msg_lev = _message_level; |
| 583 | 586 | smcp.presolve = _presolve; |
| 584 | 587 | |
| 585 | 588 | // If the basis is not valid we get an error return value. |
| … |
… |
|
| 608 | 611 | glp_smcp smcp; |
| 609 | 612 | glp_init_smcp(&smcp); |
| 610 | 613 | |
| 611 | | switch (_message_level) { |
| 612 | | case MESSAGE_NO_OUTPUT: |
| 613 | | smcp.msg_lev = GLP_MSG_OFF; |
| 614 | | break; |
| 615 | | case MESSAGE_ERROR_MESSAGE: |
| 616 | | smcp.msg_lev = GLP_MSG_ERR; |
| 617 | | break; |
| 618 | | case MESSAGE_NORMAL_OUTPUT: |
| 619 | | smcp.msg_lev = GLP_MSG_ON; |
| 620 | | break; |
| 621 | | case MESSAGE_FULL_OUTPUT: |
| 622 | | smcp.msg_lev = GLP_MSG_ALL; |
| 623 | | break; |
| 624 | | } |
| | 614 | smcp.msg_lev = _message_level; |
| 625 | 615 | smcp.meth = GLP_DUAL; |
| 626 | 616 | smcp.presolve = _presolve; |
| 627 | 617 | |
| … |
… |
|
| 898 | 888 | glp_smcp smcp; |
| 899 | 889 | glp_init_smcp(&smcp); |
| 900 | 890 | |
| 901 | | switch (_message_level) { |
| 902 | | case MESSAGE_NO_OUTPUT: |
| 903 | | smcp.msg_lev = GLP_MSG_OFF; |
| 904 | | break; |
| 905 | | case MESSAGE_ERROR_MESSAGE: |
| 906 | | smcp.msg_lev = GLP_MSG_ERR; |
| 907 | | break; |
| 908 | | case MESSAGE_NORMAL_OUTPUT: |
| 909 | | smcp.msg_lev = GLP_MSG_ON; |
| 910 | | break; |
| 911 | | case MESSAGE_FULL_OUTPUT: |
| 912 | | smcp.msg_lev = GLP_MSG_ALL; |
| 913 | | break; |
| 914 | | } |
| | 891 | smcp.msg_lev = _message_level; |
| 915 | 892 | smcp.meth = GLP_DUAL; |
| 916 | 893 | |
| 917 | 894 | // If the basis is not valid we get an error return value. |
| … |
… |
|
| 936 | 913 | glp_iocp iocp; |
| 937 | 914 | glp_init_iocp(&iocp); |
| 938 | 915 | |
| 939 | | switch (_message_level) { |
| 940 | | case MESSAGE_NO_OUTPUT: |
| 941 | | iocp.msg_lev = GLP_MSG_OFF; |
| 942 | | break; |
| 943 | | case MESSAGE_ERROR_MESSAGE: |
| 944 | | iocp.msg_lev = GLP_MSG_ERR; |
| 945 | | break; |
| 946 | | case MESSAGE_NORMAL_OUTPUT: |
| 947 | | iocp.msg_lev = GLP_MSG_ON; |
| 948 | | break; |
| 949 | | case MESSAGE_FULL_OUTPUT: |
| 950 | | iocp.msg_lev = GLP_MSG_ALL; |
| 951 | | break; |
| 952 | | } |
| | 916 | iocp.msg_lev = _message_level; |
| 953 | 917 | |
| 954 | 918 | if (glp_intopt(lp, &iocp) != 0) return UNSOLVED; |
| 955 | 919 | return SOLVED; |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/glpk.h
|
a
|
b
|
|
| 100 | 100 | |
| 101 | 101 | virtual void _clear(); |
| 102 | 102 | |
| | 103 | virtual void _messageLevel(MessageLevel level); |
| | 104 | |
| 103 | 105 | private: |
| 104 | 106 | |
| 105 | 107 | static void freeEnv(); |
| … |
… |
|
| 111 | 113 | }; |
| 112 | 114 | |
| 113 | 115 | static FreeEnvHelper freeEnvHelper; |
| | 116 | |
| | 117 | protected: |
| | 118 | |
| | 119 | int _message_level; |
| 114 | 120 | |
| 115 | 121 | public: |
| 116 | 122 | |
| 117 | | ///Enum for \c messageLevel() parameter |
| 118 | | enum MessageLevel { |
| 119 | | /// no output (default value) |
| 120 | | MESSAGE_NO_OUTPUT = 0, |
| 121 | | /// error messages only |
| 122 | | MESSAGE_ERROR_MESSAGE = 1, |
| 123 | | /// normal output |
| 124 | | MESSAGE_NORMAL_OUTPUT = 2, |
| 125 | | /// full output (includes informational messages) |
| 126 | | MESSAGE_FULL_OUTPUT = 3 |
| 127 | | }; |
| 128 | | |
| 129 | | protected: |
| 130 | | |
| 131 | | MessageLevel _message_level; |
| 132 | | |
| 133 | | public: |
| 134 | | |
| 135 | | ///Set the verbosity of the messages |
| 136 | | |
| 137 | | ///Set the verbosity of the messages |
| 138 | | /// |
| 139 | | ///\param m is the level of the messages output by the solver routines. |
| 140 | | void messageLevel(MessageLevel m); |
| 141 | | |
| 142 | 123 | ///Pointer to the underlying GLPK data structure. |
| 143 | 124 | LPX *lpx() {return lp;} |
| 144 | 125 | ///Const pointer to the underlying GLPK data structure. |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/lp_base.h
|
a
|
b
|
|
| 69 | 69 | MAX |
| 70 | 70 | }; |
| 71 | 71 | |
| | 72 | ///Enum for \c messageLevel() parameter |
| | 73 | enum MessageLevel { |
| | 74 | /// no output (default value) |
| | 75 | MESSAGE_NOTHING, |
| | 76 | /// error messages only |
| | 77 | MESSAGE_ERROR, |
| | 78 | /// warnings |
| | 79 | MESSAGE_WARNING, |
| | 80 | /// normal output |
| | 81 | MESSAGE_NORMAL, |
| | 82 | /// verbose output |
| | 83 | MESSAGE_VERBOSE |
| | 84 | }; |
| | 85 | |
| | 86 | |
| 72 | 87 | ///The floating point type used by the solver |
| 73 | 88 | typedef double Value; |
| 74 | 89 | ///The infinity constant |
| … |
… |
|
| 973 | 988 | |
| 974 | 989 | virtual const char* _solverName() const = 0; |
| 975 | 990 | |
| | 991 | virtual void _messageLevel(MessageLevel level) = 0; |
| | 992 | |
| 976 | 993 | //Own protected stuff |
| 977 | 994 | |
| 978 | 995 | //Constant component of the objective function |
| … |
… |
|
| 1527 | 1544 | ///Clears the problem |
| 1528 | 1545 | void clear() { _clear(); } |
| 1529 | 1546 | |
| | 1547 | /// Sets the message level of the solver |
| | 1548 | void messageLevel(MessageLevel level) { _messageLevel(level); } |
| | 1549 | |
| 1530 | 1550 | ///@} |
| 1531 | 1551 | |
| 1532 | 1552 | }; |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/lp_skeleton.cc
|
a
|
b
|
|
| 84 | 84 | row_num = col_num = 0; |
| 85 | 85 | } |
| 86 | 86 | |
| | 87 | void SkeletonSolverBase::_messageLevel(MessageLevel) {} |
| | 88 | |
| 87 | 89 | LpSkeleton::SolveExitStatus LpSkeleton::_solve() { return SOLVED; } |
| 88 | 90 | |
| 89 | 91 | LpSkeleton::Value LpSkeleton::_getPrimal(int) const { return 0; } |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/lp_skeleton.h
|
a
|
b
|
|
| 140 | 140 | ///\e |
| 141 | 141 | virtual void _clear(); |
| 142 | 142 | |
| | 143 | ///\e |
| | 144 | virtual void _messageLevel(MessageLevel); |
| 143 | 145 | }; |
| 144 | 146 | |
| 145 | 147 | /// \brief Skeleton class for an LP solver interface |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/soplex.cc
|
a
|
b
|
|
| 29 | 29 | |
| 30 | 30 | SoplexLp::SoplexLp() { |
| 31 | 31 | soplex = new soplex::SoPlex; |
| 32 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 32 | messageLevel(MESSAGE_NOTHING); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | SoplexLp::~SoplexLp() { |
| … |
… |
|
| 49 | 49 | _row_names = lp._row_names; |
| 50 | 50 | _row_names_ref = lp._row_names_ref; |
| 51 | 51 | |
| 52 | | messageLevel(MESSAGE_NO_OUTPUT); |
| | 52 | messageLevel(MESSAGE_NOTHING); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | void SoplexLp::_clear_temporals() { |
| … |
… |
|
| 275 | 275 | |
| 276 | 276 | _clear_temporals(); |
| 277 | 277 | |
| 278 | | setMessageLevel(); |
| | 278 | _applyMessageLevel(); |
| 279 | 279 | |
| 280 | 280 | soplex::SPxSolver::Status status = soplex->solve(); |
| 281 | 281 | |
| … |
… |
|
| 424 | 424 | _clear_temporals(); |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | | void SoplexLp::messageLevel(MessageLevel m) { |
| 428 | | _message_level = m; |
| 429 | | } |
| 430 | | |
| 431 | | void SoplexLp::setMessageLevel() { |
| 432 | | switch (_message_level) { |
| 433 | | case MESSAGE_NO_OUTPUT: |
| 434 | | soplex::Param::setVerbose(-1); |
| | 427 | void SoplexLp::_messageLevel(MessageLevel level) { |
| | 428 | switch (level) { |
| | 429 | case MESSAGE_NOTHING: |
| | 430 | _message_level = -1; |
| 435 | 431 | break; |
| 436 | | case MESSAGE_ERROR_MESSAGE: |
| 437 | | soplex::Param::setVerbose(soplex::SPxOut::ERROR); |
| | 432 | case MESSAGE_ERROR: |
| | 433 | _message_level = soplex::SPxOut::ERROR; |
| 438 | 434 | break; |
| 439 | 435 | case MESSAGE_WARNING: |
| 440 | | soplex::Param::setVerbose(soplex::SPxOut::WARNING); |
| | 436 | _message_level = soplex::SPxOut::WARNING; |
| 441 | 437 | break; |
| 442 | | case MESSAGE_INFO_01: |
| 443 | | soplex::Param::setVerbose(soplex::SPxOut::INFO1); |
| | 438 | case MESSAGE_NORMAL: |
| | 439 | _message_level = soplex::SPxOut::INFO2; |
| 444 | 440 | break; |
| 445 | | case MESSAGE_INFO_02: |
| 446 | | soplex::Param::setVerbose(soplex::SPxOut::INFO2); |
| 447 | | break; |
| 448 | | case MESSAGE_INFO_03: |
| 449 | | soplex::Param::setVerbose(soplex::SPxOut::INFO3); |
| 450 | | break; |
| 451 | | case MESSAGE_DEBUG_INFO: |
| 452 | | soplex::Param::setVerbose(soplex::SPxOut::DEBUG); |
| | 441 | case MESSAGE_VERBOSE: |
| | 442 | _message_level = soplex::SPxOut::DEBUG; |
| 453 | 443 | break; |
| 454 | 444 | } |
| 455 | 445 | } |
| 456 | 446 | |
| | 447 | void SoplexLp::_applyMessageLevel() { |
| | 448 | soplex::Param::setVerbose(_message_level); |
| | 449 | } |
| | 450 | |
| 457 | 451 | } //namespace lemon |
| 458 | 452 | |
diff -r d61d725c3959 -r 0cad57c38b52 lemon/soplex.h
|
a
|
b
|
|
| 144 | 144 | |
| 145 | 145 | virtual void _clear(); |
| 146 | 146 | |
| 147 | | public: |
| | 147 | void _messageLevel(MessageLevel m); |
| | 148 | void _applyMessageLevel(); |
| 148 | 149 | |
| 149 | | ///Enum for \c messageLevel() parameter |
| 150 | | enum MessageLevel { |
| 151 | | /// no output (default value) |
| 152 | | MESSAGE_NO_OUTPUT, |
| 153 | | /// error messages only |
| 154 | | MESSAGE_ERROR_MESSAGE, |
| 155 | | /// warnings |
| 156 | | MESSAGE_WARNING, |
| 157 | | /// first level informations |
| 158 | | MESSAGE_INFO_01, |
| 159 | | /// second level informations |
| 160 | | MESSAGE_INFO_02, |
| 161 | | /// third level informations |
| 162 | | MESSAGE_INFO_03, |
| 163 | | /// debug informations |
| 164 | | MESSAGE_DEBUG_INFO |
| 165 | | }; |
| 166 | | |
| 167 | | protected: |
| 168 | | |
| 169 | | MessageLevel _message_level; |
| 170 | | |
| 171 | | void setMessageLevel(); |
| 172 | | |
| 173 | | public: |
| 174 | | |
| 175 | | ///Set the verbosity of the messages |
| 176 | | |
| 177 | | ///Set the verbosity of the messages |
| 178 | | /// |
| 179 | | ///\param m is the level of the messages output by the solver routines. |
| 180 | | void messageLevel(MessageLevel m); |
| | 150 | int _message_level; |
| 181 | 151 | |
| 182 | 152 | }; |
| 183 | 153 | |