Changeset 485:9b082b3fb33f in lemon for lemon/glpk.cc
 Timestamp:
 01/12/09 13:26:02 (14 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/glpk.cc
r484 r485 523 523 } 524 524 525 // LpGlpkmembers526 527 LpGlpk::LpGlpk()525 // GlpkLp members 526 527 GlpkLp::GlpkLp() 528 528 : LpBase(), GlpkBase(), LpSolver() { 529 529 messageLevel(MESSAGE_NO_OUTPUT); 530 530 } 531 531 532 LpGlpk::LpGlpk(const LpGlpk& other)532 GlpkLp::GlpkLp(const GlpkLp& other) 533 533 : LpBase(other), GlpkBase(other), LpSolver(other) { 534 534 messageLevel(MESSAGE_NO_OUTPUT); 535 535 } 536 536 537 LpGlpk* LpGlpk::_newSolver() const { return new LpGlpk; }538 LpGlpk* LpGlpk::_cloneSolver() const { return new LpGlpk(*this); }539 540 const char* LpGlpk::_solverName() const { return "LpGlpk"; }541 542 void LpGlpk::_clear_temporals() {537 GlpkLp* GlpkLp::_newSolver() const { return new GlpkLp; } 538 GlpkLp* GlpkLp::_cloneSolver() const { return new GlpkLp(*this); } 539 540 const char* GlpkLp::_solverName() const { return "GlpkLp"; } 541 542 void GlpkLp::_clear_temporals() { 543 543 _primal_ray.clear(); 544 544 _dual_ray.clear(); 545 545 } 546 546 547 LpGlpk::SolveExitStatus LpGlpk::_solve() {547 GlpkLp::SolveExitStatus GlpkLp::_solve() { 548 548 return solvePrimal(); 549 549 } 550 550 551 LpGlpk::SolveExitStatus LpGlpk::solvePrimal() {551 GlpkLp::SolveExitStatus GlpkLp::solvePrimal() { 552 552 _clear_temporals(); 553 553 … … 574 574 } 575 575 576 LpGlpk::SolveExitStatus LpGlpk::solveDual() {576 GlpkLp::SolveExitStatus GlpkLp::solveDual() { 577 577 _clear_temporals(); 578 578 … … 600 600 } 601 601 602 LpGlpk::Value LpGlpk::_getPrimal(int i) const {602 GlpkLp::Value GlpkLp::_getPrimal(int i) const { 603 603 return glp_get_col_prim(lp, i); 604 604 } 605 605 606 LpGlpk::Value LpGlpk::_getDual(int i) const {606 GlpkLp::Value GlpkLp::_getDual(int i) const { 607 607 return glp_get_row_dual(lp, i); 608 608 } 609 609 610 LpGlpk::Value LpGlpk::_getPrimalValue() const {610 GlpkLp::Value GlpkLp::_getPrimalValue() const { 611 611 return glp_get_obj_val(lp); 612 612 } 613 613 614 LpGlpk::VarStatus LpGlpk::_getColStatus(int i) const {614 GlpkLp::VarStatus GlpkLp::_getColStatus(int i) const { 615 615 switch (glp_get_col_stat(lp, i)) { 616 616 case GLP_BS: … … 626 626 default: 627 627 LEMON_ASSERT(false, "Wrong column status"); 628 return LpGlpk::VarStatus();629 } 630 } 631 632 LpGlpk::VarStatus LpGlpk::_getRowStatus(int i) const {628 return GlpkLp::VarStatus(); 629 } 630 } 631 632 GlpkLp::VarStatus GlpkLp::_getRowStatus(int i) const { 633 633 switch (glp_get_row_stat(lp, i)) { 634 634 case GLP_BS: … … 644 644 default: 645 645 LEMON_ASSERT(false, "Wrong row status"); 646 return LpGlpk::VarStatus();647 } 648 } 649 650 LpGlpk::Value LpGlpk::_getPrimalRay(int i) const {646 return GlpkLp::VarStatus(); 647 } 648 } 649 650 GlpkLp::Value GlpkLp::_getPrimalRay(int i) const { 651 651 if (_primal_ray.empty()) { 652 652 int row_num = glp_get_num_rows(lp); … … 700 700 } 701 701 702 LpGlpk::Value LpGlpk::_getDualRay(int i) const {702 GlpkLp::Value GlpkLp::_getDualRay(int i) const { 703 703 if (_dual_ray.empty()) { 704 704 int row_num = glp_get_num_rows(lp); … … 772 772 } 773 773 774 LpGlpk::ProblemType LpGlpk::_getPrimalType() const {774 GlpkLp::ProblemType GlpkLp::_getPrimalType() const { 775 775 if (glp_get_status(lp) == GLP_OPT) 776 776 return OPTIMAL; … … 789 789 default: 790 790 LEMON_ASSERT(false, "Wrong primal type"); 791 return LpGlpk::ProblemType();792 } 793 } 794 795 LpGlpk::ProblemType LpGlpk::_getDualType() const {791 return GlpkLp::ProblemType(); 792 } 793 } 794 795 GlpkLp::ProblemType GlpkLp::_getDualType() const { 796 796 if (glp_get_status(lp) == GLP_OPT) 797 797 return OPTIMAL; … … 810 810 default: 811 811 LEMON_ASSERT(false, "Wrong primal type"); 812 return LpGlpk::ProblemType();813 } 814 } 815 816 void LpGlpk::presolver(bool b) {812 return GlpkLp::ProblemType(); 813 } 814 } 815 816 void GlpkLp::presolver(bool b) { 817 817 lpx_set_int_parm(lp, LPX_K_PRESOL, b ? 1 : 0); 818 818 } 819 819 820 void LpGlpk::messageLevel(MessageLevel m) {820 void GlpkLp::messageLevel(MessageLevel m) { 821 821 _message_level = m; 822 822 } 823 823 824 // MipGlpkmembers825 826 MipGlpk::MipGlpk()824 // GlpkMip members 825 826 GlpkMip::GlpkMip() 827 827 : LpBase(), GlpkBase(), MipSolver() { 828 828 messageLevel(MESSAGE_NO_OUTPUT); 829 829 } 830 830 831 MipGlpk::MipGlpk(const MipGlpk& other)831 GlpkMip::GlpkMip(const GlpkMip& other) 832 832 : LpBase(), GlpkBase(other), MipSolver() { 833 833 messageLevel(MESSAGE_NO_OUTPUT); 834 834 } 835 835 836 void MipGlpk::_setColType(int i, MipGlpk::ColTypes col_type) {836 void GlpkMip::_setColType(int i, GlpkMip::ColTypes col_type) { 837 837 switch (col_type) { 838 838 case INTEGER: … … 845 845 } 846 846 847 MipGlpk::ColTypes MipGlpk::_getColType(int i) const {847 GlpkMip::ColTypes GlpkMip::_getColType(int i) const { 848 848 switch (glp_get_col_kind(lp, i)) { 849 849 case GLP_IV: … … 856 856 } 857 857 858 MipGlpk::SolveExitStatus MipGlpk::_solve() {858 GlpkMip::SolveExitStatus GlpkMip::_solve() { 859 859 glp_smcp smcp; 860 860 glp_init_smcp(&smcp); … … 902 902 903 903 904 MipGlpk::ProblemType MipGlpk::_getType() const {904 GlpkMip::ProblemType GlpkMip::_getType() const { 905 905 switch (glp_get_status(lp)) { 906 906 case GLP_OPT: … … 916 916 default: 917 917 LEMON_ASSERT(false, "Wrong problem type."); 918 return MipGlpk::ProblemType();918 return GlpkMip::ProblemType(); 919 919 } 920 920 case GLP_NOFEAS: … … 929 929 default: 930 930 LEMON_ASSERT(false, "Wrong problem type."); 931 return MipGlpk::ProblemType();932 } 933 } 934 935 MipGlpk::Value MipGlpk::_getSol(int i) const {931 return GlpkMip::ProblemType(); 932 } 933 } 934 935 GlpkMip::Value GlpkMip::_getSol(int i) const { 936 936 return glp_mip_col_val(lp, i); 937 937 } 938 938 939 MipGlpk::Value MipGlpk::_getSolValue() const {939 GlpkMip::Value GlpkMip::_getSolValue() const { 940 940 return glp_mip_obj_val(lp); 941 941 } 942 942 943 MipGlpk* MipGlpk::_newSolver() const { return new MipGlpk; }944 MipGlpk* MipGlpk::_cloneSolver() const {return new MipGlpk(*this); }945 946 const char* MipGlpk::_solverName() const { return "MipGlpk"; }947 948 void MipGlpk::messageLevel(MessageLevel m) {943 GlpkMip* GlpkMip::_newSolver() const { return new GlpkMip; } 944 GlpkMip* GlpkMip::_cloneSolver() const {return new GlpkMip(*this); } 945 946 const char* GlpkMip::_solverName() const { return "GlpkMip"; } 947 948 void GlpkMip::messageLevel(MessageLevel m) { 949 949 _message_level = m; 950 950 }
Note: See TracChangeset
for help on using the changeset viewer.