Changeset 1241:dadc9987c537 in lemon-0.x for src/work/athos
- Timestamp:
- 03/22/05 13:02:29 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1668
- Location:
- src/work/athos/lp
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/athos/lp/lp_solver_base.h
r1240 r1241 13 13 // #include <stdio> 14 14 //#include <stdlib> 15 extern "C" {16 #include "glpk.h"17 }18 15 19 16 #include <iostream> … … 200 197 */ 201 198 template <typename _Value> 202 class L PSolverBase {199 class LpSolverBase { 203 200 204 201 /*! @name Uncategorized functions and types (public members) … … 233 230 const int INVALID_CLASS; 234 231 /// \e 235 static const _Value INF;236 public: 237 /// \e 238 L PSolverBase() : row_iter_map(2),232 static const Value INF; 233 public: 234 /// \e 235 LpSolverBase() : row_iter_map(2), 239 236 col_iter_map(2), 240 237 VALID_CLASS(0), INVALID_CLASS(1) { } 241 238 /// \e 242 virtual ~L PSolverBase() { }239 virtual ~LpSolverBase() { } 243 240 //@} 244 241 … … 273 270 274 271 /// \e 275 virtual _Value getObjVal() = 0;272 virtual Value getObjVal() = 0; 276 273 277 274 //OTHER FUNCTIONS … … 322 319 /// \e 323 320 virtual void _setRowCoeffs(int i, 324 const std::vector<std::pair<int, _Value> >& coeffs) = 0;321 const std::vector<std::pair<int, Value> >& coeffs) = 0; 325 322 /// \e 326 323 /// This routine modifies \c coeffs only by the \c push_back method. 327 324 virtual void _getRowCoeffs(int i, 328 std::vector<std::pair<int, _Value> >& coeffs) = 0;325 std::vector<std::pair<int, Value> >& coeffs) = 0; 329 326 /// \e 330 327 virtual void _setColCoeffs(int i, 331 const std::vector<std::pair<int, _Value> >& coeffs) = 0;328 const std::vector<std::pair<int, Value> >& coeffs) = 0; 332 329 /// \e 333 330 /// This routine modifies \c coeffs only by the \c push_back method. 334 331 virtual void _getColCoeffs(int i, 335 std::vector<std::pair<int, _Value> >& coeffs) = 0;336 /// \e 337 virtual void _setCoeff(int col, int row, _Value value) = 0;338 /// \e 339 virtual _Value _getCoeff(int col, int row) = 0;332 std::vector<std::pair<int, Value> >& coeffs) = 0; 333 /// \e 334 virtual void _setCoeff(int col, int row, Value value) = 0; 335 /// \e 336 virtual Value _getCoeff(int col, int row) = 0; 340 337 // public: 341 338 // /// \e … … 344 341 /// \e 345 342 /// The lower bound of a variable (column) have to be given by an 346 /// extended number of type _Value, i.e. a finite number of type347 /// _Value or -INF.348 virtual void _setColLowerBound(int i, _Value value) = 0;343 /// extended number of type Value, i.e. a finite number of type 344 /// Value or -INF. 345 virtual void _setColLowerBound(int i, Value value) = 0; 349 346 /// \e 350 347 /// The lower bound of a variable (column) is an 351 /// extended number of type _Value, i.e. a finite number of type352 /// _Value or -INF.353 virtual _Value _getColLowerBound(int i) = 0;348 /// extended number of type Value, i.e. a finite number of type 349 /// Value or -INF. 350 virtual Value _getColLowerBound(int i) = 0; 354 351 /// \e 355 352 /// The upper bound of a variable (column) have to be given by an 356 /// extended number of type _Value, i.e. a finite number of type357 /// _Value or INF.358 virtual void _setColUpperBound(int i, _Value value) = 0;353 /// extended number of type Value, i.e. a finite number of type 354 /// Value or INF. 355 virtual void _setColUpperBound(int i, Value value) = 0; 359 356 /// \e 360 357 /// The upper bound of a variable (column) is an 361 /// extended number of type _Value, i.e. a finite number of type362 /// _Value or INF.363 virtual _Value _getColUpperBound(int i) = 0;358 /// extended number of type Value, i.e. a finite number of type 359 /// Value or INF. 360 virtual Value _getColUpperBound(int i) = 0; 364 361 /// \e 365 362 /// The lower bound of a linear expression (row) have to be given by an 366 /// extended number of type _Value, i.e. a finite number of type367 /// _Value or -INF.368 virtual void _setRowLowerBound(int i, _Value value) = 0;363 /// extended number of type Value, i.e. a finite number of type 364 /// Value or -INF. 365 virtual void _setRowLowerBound(int i, Value value) = 0; 369 366 /// \e 370 367 /// The lower bound of a linear expression (row) is an 371 /// extended number of type _Value, i.e. a finite number of type372 /// _Value or -INF.373 virtual _Value _getRowLowerBound(int i) = 0;368 /// extended number of type Value, i.e. a finite number of type 369 /// Value or -INF. 370 virtual Value _getRowLowerBound(int i) = 0; 374 371 /// \e 375 372 /// The upper bound of a linear expression (row) have to be given by an 376 /// extended number of type _Value, i.e. a finite number of type377 /// _Value or INF.378 virtual void _setRowUpperBound(int i, _Value value) = 0;373 /// extended number of type Value, i.e. a finite number of type 374 /// Value or INF. 375 virtual void _setRowUpperBound(int i, Value value) = 0; 379 376 /// \e 380 377 /// The upper bound of a linear expression (row) is an 381 /// extended number of type _Value, i.e. a finite number of type382 /// _Value or INF.383 virtual _Value _getRowUpperBound(int i) = 0;384 /// \e 385 virtual void _setObjCoeff(int i, _Value obj_coef) = 0;386 /// \e 387 virtual _Value _getObjCoeff(int i) = 0;378 /// extended number of type Value, i.e. a finite number of type 379 /// Value or INF. 380 virtual Value _getRowUpperBound(int i) = 0; 381 /// \e 382 virtual void _setObjCoeff(int i, Value obj_coef) = 0; 383 /// \e 384 virtual Value _getObjCoeff(int i) = 0; 388 385 389 386 //SOLUTION RETRIEVING 390 387 391 388 /// \e 392 virtual _Value _getPrimal(int i) = 0;389 virtual Value _getPrimal(int i) = 0; 393 390 //@} 394 391 … … 458 455 } 459 456 /// \e 460 void setCoeff(Col col, Row row, _Value value) {457 void setCoeff(Col col, Row row, Value value) { 461 458 _setCoeff(col_iter_map[col], row_iter_map[row], value); 462 459 } 463 460 /// \e 464 _Value getCoeff(Col col, Row row) {461 Value getCoeff(Col col, Row row) { 465 462 return _getCoeff(col_iter_map[col], row_iter_map[row], value); 466 463 } 467 464 /// \e 468 void setColLowerBound(Col col, _Value lo) {465 void setColLowerBound(Col col, Value lo) { 469 466 _setColLowerBound(col_iter_map[col], lo); 470 467 } 471 468 /// \e 472 _Value getColLowerBound(Col col) {469 Value getColLowerBound(Col col) { 473 470 return _getColLowerBound(col_iter_map[col]); 474 471 } 475 472 /// \e 476 void setColUpperBound(Col col, _Value up) {473 void setColUpperBound(Col col, Value up) { 477 474 _setColUpperBound(col_iter_map[col], up); 478 475 } 479 476 /// \e 480 _Value getColUpperBound(Col col) {477 Value getColUpperBound(Col col) { 481 478 return _getColUpperBound(col_iter_map[col]); 482 479 } 483 480 /// \e 484 void setRowLowerBound(Row row, _Value lo) {481 void setRowLowerBound(Row row, Value lo) { 485 482 _setRowLowerBound(row_iter_map[row], lo); 486 483 } 487 484 /// \e 488 _Value getRowLowerBound(Row row) {485 Value getRowLowerBound(Row row) { 489 486 return _getRowLowerBound(row_iter_map[row]); 490 487 } 491 488 /// \e 492 void setRowUpperBound(Row row, _Value up) {489 void setRowUpperBound(Row row, Value up) { 493 490 _setRowUpperBound(row_iter_map[row], up); 494 491 } 495 492 /// \e 496 _Value getRowUpperBound(Row row) {493 Value getRowUpperBound(Row row) { 497 494 return _getRowUpperBound(row_iter_map[row]); 498 495 } 499 496 /// \e 500 void setObjCoeff(const Col& col, _Value obj_coef) {497 void setObjCoeff(const Col& col, Value obj_coef) { 501 498 _setObjCoeff(col_iter_map[col], obj_coef); 502 499 } 503 500 /// \e 504 _Value getObjCoeff(const Col& col) {501 Value getObjCoeff(const Col& col) { 505 502 return _getObjCoeff(col_iter_map[col]); 506 503 } … … 509 506 510 507 /// \e 511 _Value getPrimal(const Col& col) {508 Value getPrimal(const Col& col) { 512 509 return _getPrimal(col_iter_map[col]); 513 510 } … … 523 520 524 521 /// \e 525 typedef Expr<Col, _Value> Expression;526 /// \e 527 typedef Expr<Row, _Value> DualExpression;528 /// \e 529 typedef Constr<Col, _Value> Constraint;522 typedef Expr<Col, Value> Expression; 523 /// \e 524 typedef Expr<Row, Value> DualExpression; 525 /// \e 526 typedef Constr<Col, Value> Constraint; 530 527 531 528 //MATRIX MANIPULATING FUNCTIONS … … 533 530 /// \e 534 531 void setRowCoeffs(Row row, const Expression& expr) { 535 std::vector<std::pair<int, _Value> > row_coeffs;532 std::vector<std::pair<int, Value> > row_coeffs; 536 533 for(typename Expression::Data::const_iterator i=expr.data.begin(); 537 534 i!=expr.data.end(); ++i) { … … 558 555 /// This routine modifies \c expr by only adding to it. 559 556 void getRowCoeffs(Row row, Expression& expr) { 560 std::vector<std::pair<int, _Value> > row_coeffs;557 std::vector<std::pair<int, Value> > row_coeffs; 561 558 _getRowCoeffs(row_iter_map[row], row_coeffs); 562 for(typename std::vector<std::pair<int, _Value> >::const_iterator559 for(typename std::vector<std::pair<int, Value> >::const_iterator 563 560 i=row_coeffs.begin(); i!=row_coeffs.end(); ++i) { 564 561 expr+= (*i).second*int_col_map[(*i).first]; … … 567 564 /// \e 568 565 void setColCoeffs(Col col, const DualExpression& expr) { 569 std::vector<std::pair<int, _Value> > col_coeffs;566 std::vector<std::pair<int, Value> > col_coeffs; 570 567 for(typename DualExpression::Data::const_iterator i=expr.data.begin(); 571 568 i!=expr.data.end(); ++i) { … … 578 575 /// This routine modifies \c expr by only adding to it. 579 576 void getColCoeffs(Col col, DualExpression& expr) { 580 std::vector<std::pair<int, _Value> > col_coeffs;577 std::vector<std::pair<int, Value> > col_coeffs; 581 578 _getColCoeffs(col_iter_map[col], col_coeffs); 582 for(typename std::vector<std::pair<int, _Value> >::const_iterator579 for(typename std::vector<std::pair<int, Value> >::const_iterator 583 580 i=col_coeffs.begin(); i!=col_coeffs.end(); ++i) { 584 581 expr+= (*i).second*int_row_map[(*i).first]; … … 621 618 virtual void _setColInt(int i) = 0; 622 619 /// \e 623 virtual _Value _getMIPPrimal(int i) = 0;620 virtual Value _getMIPPrimal(int i) = 0; 624 621 public: 625 622 /// \e … … 632 629 } 633 630 /// \e 634 _Value getMIPPrimal(Col col) {631 Value getMIPPrimal(Col col) { 635 632 return _getMIPPrimal(col_iter_map[col]); 636 633 } 637 634 //@} 638 635 }; 639 640 template <typename _Value>641 const _Value LPSolverBase<_Value>::INF=std::numeric_limits<_Value>::infinity();642 643 644 /// \brief Wrapper for GLPK solver645 ///646 /// This class implements a lemon wrapper for GLPK.647 class LPGLPK : public LPSolverBase<double> {648 public:649 typedef LPSolverBase<double> Parent;650 651 public:652 /// \e653 LPX* lp;654 655 public:656 /// \e657 LPGLPK() : Parent(),658 lp(lpx_create_prob()) {659 int_row_map.push_back(Row());660 int_col_map.push_back(Col());661 lpx_set_int_parm(lp, LPX_K_DUAL, 1);662 }663 /// \e664 ~LPGLPK() {665 lpx_delete_prob(lp);666 }667 668 //MATRIX INDEPEDENT MANIPULATING FUNCTIONS669 670 /// \e671 void setMinimize() {672 lpx_set_obj_dir(lp, LPX_MIN);673 }674 /// \e675 void setMaximize() {676 lpx_set_obj_dir(lp, LPX_MAX);677 }678 679 //LOW LEVEL INTERFACE, MATRIX MANIPULATING FUNCTIONS680 681 protected:682 /// \e683 int _addCol() {684 int i=lpx_add_cols(lp, 1);685 _setColLowerBound(i, -INF);686 _setColUpperBound(i, INF);687 return i;688 }689 /// \e690 int _addRow() {691 int i=lpx_add_rows(lp, 1);692 return i;693 }694 /// \e695 virtual void _setRowCoeffs(int i,696 const std::vector<std::pair<int, double> >& coeffs) {697 int mem_length=1+colNum();698 int* indices = new int[mem_length];699 double* doubles = new double[mem_length];700 int length=0;701 for (std::vector<std::pair<int, double> >::702 const_iterator it=coeffs.begin(); it!=coeffs.end(); ++it) {703 ++length;704 indices[length]=it->first;705 doubles[length]=it->second;706 }707 lpx_set_mat_row(lp, i, length, indices, doubles);708 delete [] indices;709 delete [] doubles;710 }711 /// \e712 virtual void _getRowCoeffs(int i,713 std::vector<std::pair<int, double> >& coeffs) {714 int mem_length=1+colNum();715 int* indices = new int[mem_length];716 double* doubles = new double[mem_length];717 int length=lpx_get_mat_row(lp, i, indices, doubles);718 for (int i=1; i<=length; ++i) {719 coeffs.push_back(std::make_pair(indices[i], doubles[i]));720 }721 delete [] indices;722 delete [] doubles;723 }724 /// \e725 virtual void _setColCoeffs(int i,726 const std::vector<std::pair<int, double> >& coeffs) {727 int mem_length=1+rowNum();728 int* indices = new int[mem_length];729 double* doubles = new double[mem_length];730 int length=0;731 for (std::vector<std::pair<int, double> >::732 const_iterator it=coeffs.begin(); it!=coeffs.end(); ++it) {733 ++length;734 indices[length]=it->first;735 doubles[length]=it->second;736 }737 lpx_set_mat_col(lp, i, length, indices, doubles);738 delete [] indices;739 delete [] doubles;740 }741 /// \e742 virtual void _getColCoeffs(int i,743 std::vector<std::pair<int, double> >& coeffs) {744 int mem_length=1+rowNum();745 int* indices = new int[mem_length];746 double* doubles = new double[mem_length];747 int length=lpx_get_mat_col(lp, i, indices, doubles);748 for (int i=1; i<=length; ++i) {749 coeffs.push_back(std::make_pair(indices[i], doubles[i]));750 }751 delete [] indices;752 delete [] doubles;753 }754 /// \e755 virtual void _eraseCol(int i) {756 int cols[2];757 cols[1]=i;758 lpx_del_cols(lp, 1, cols);759 }760 virtual void _eraseRow(int i) {761 int rows[2];762 rows[1]=i;763 lpx_del_rows(lp, 1, rows);764 }765 void _setCoeff(int col, int row, double value) {766 /// FIXME not yet implemented767 }768 double _getCoeff(int col, int row) {769 /// FIXME not yet implemented770 return 0.0;771 }772 virtual void _setColLowerBound(int i, double lo) {773 if (lo==INF) {774 //FIXME error775 }776 int b=lpx_get_col_type(lp, i);777 double up=lpx_get_col_ub(lp, i);778 if (lo==-INF) {779 switch (b) {780 case LPX_FR:781 case LPX_LO:782 lpx_set_col_bnds(lp, i, LPX_FR, lo, up);783 break;784 case LPX_UP:785 break;786 case LPX_DB:787 case LPX_FX:788 lpx_set_col_bnds(lp, i, LPX_UP, lo, up);789 break;790 default: ;791 //FIXME error792 }793 } else {794 switch (b) {795 case LPX_FR:796 case LPX_LO:797 lpx_set_col_bnds(lp, i, LPX_LO, lo, up);798 break;799 case LPX_UP:800 case LPX_DB:801 case LPX_FX:802 if (lo==up)803 lpx_set_col_bnds(lp, i, LPX_FX, lo, up);804 else805 lpx_set_col_bnds(lp, i, LPX_DB, lo, up);806 break;807 default: ;808 //FIXME error809 }810 }811 }812 virtual double _getColLowerBound(int i) {813 int b=lpx_get_col_type(lp, i);814 switch (b) {815 case LPX_FR:816 return -INF;817 case LPX_LO:818 return lpx_get_col_lb(lp, i);819 case LPX_UP:820 return -INF;821 case LPX_DB:822 case LPX_FX:823 return lpx_get_col_lb(lp, i);824 default: ;825 //FIXME error826 return 0.0;827 }828 }829 virtual void _setColUpperBound(int i, double up) {830 if (up==-INF) {831 //FIXME error832 }833 int b=lpx_get_col_type(lp, i);834 double lo=lpx_get_col_lb(lp, i);835 if (up==INF) {836 switch (b) {837 case LPX_FR:838 case LPX_LO:839 break;840 case LPX_UP:841 lpx_set_col_bnds(lp, i, LPX_FR, lo, up);842 break;843 case LPX_DB:844 case LPX_FX:845 lpx_set_col_bnds(lp, i, LPX_LO, lo, up);846 break;847 default: ;848 //FIXME error849 }850 } else {851 switch (b) {852 case LPX_FR:853 lpx_set_col_bnds(lp, i, LPX_UP, lo, up);854 case LPX_LO:855 if (lo==up)856 lpx_set_col_bnds(lp, i, LPX_FX, lo, up);857 else858 lpx_set_col_bnds(lp, i, LPX_DB, lo, up);859 break;860 case LPX_UP:861 lpx_set_col_bnds(lp, i, LPX_UP, lo, up);862 break;863 case LPX_DB:864 case LPX_FX:865 if (lo==up)866 lpx_set_col_bnds(lp, i, LPX_FX, lo, up);867 else868 lpx_set_col_bnds(lp, i, LPX_DB, lo, up);869 break;870 default: ;871 //FIXME error872 }873 }874 }875 virtual double _getColUpperBound(int i) {876 int b=lpx_get_col_type(lp, i);877 switch (b) {878 case LPX_FR:879 case LPX_LO:880 return INF;881 case LPX_UP:882 case LPX_DB:883 case LPX_FX:884 return lpx_get_col_ub(lp, i);885 default: ;886 //FIXME error887 return 0.0;888 }889 }890 virtual void _setRowLowerBound(int i, double lo) {891 if (lo==INF) {892 //FIXME error893 }894 int b=lpx_get_row_type(lp, i);895 double up=lpx_get_row_ub(lp, i);896 if (lo==-INF) {897 switch (b) {898 case LPX_FR:899 case LPX_LO:900 lpx_set_row_bnds(lp, i, LPX_FR, lo, up);901 break;902 case LPX_UP:903 break;904 case LPX_DB:905 case LPX_FX:906 lpx_set_row_bnds(lp, i, LPX_UP, lo, up);907 break;908 default: ;909 //FIXME error910 }911 } else {912 switch (b) {913 case LPX_FR:914 case LPX_LO:915 lpx_set_row_bnds(lp, i, LPX_LO, lo, up);916 break;917 case LPX_UP:918 case LPX_DB:919 case LPX_FX:920 if (lo==up)921 lpx_set_row_bnds(lp, i, LPX_FX, lo, up);922 else923 lpx_set_row_bnds(lp, i, LPX_DB, lo, up);924 break;925 default: ;926 //FIXME error927 }928 }929 }930 virtual double _getRowLowerBound(int i) {931 int b=lpx_get_row_type(lp, i);932 switch (b) {933 case LPX_FR:934 return -INF;935 case LPX_LO:936 return lpx_get_row_lb(lp, i);937 case LPX_UP:938 return -INF;939 case LPX_DB:940 case LPX_FX:941 return lpx_get_row_lb(lp, i);942 default: ;943 //FIXME error944 return 0.0;945 }946 }947 virtual void _setRowUpperBound(int i, double up) {948 if (up==-INF) {949 //FIXME error950 }951 int b=lpx_get_row_type(lp, i);952 double lo=lpx_get_row_lb(lp, i);953 if (up==INF) {954 switch (b) {955 case LPX_FR:956 case LPX_LO:957 break;958 case LPX_UP:959 lpx_set_row_bnds(lp, i, LPX_FR, lo, up);960 break;961 case LPX_DB:962 case LPX_FX:963 lpx_set_row_bnds(lp, i, LPX_LO, lo, up);964 break;965 default: ;966 //FIXME error967 }968 } else {969 switch (b) {970 case LPX_FR:971 lpx_set_row_bnds(lp, i, LPX_UP, lo, up);972 case LPX_LO:973 if (lo==up)974 lpx_set_row_bnds(lp, i, LPX_FX, lo, up);975 else976 lpx_set_row_bnds(lp, i, LPX_DB, lo, up);977 break;978 case LPX_UP:979 lpx_set_row_bnds(lp, i, LPX_UP, lo, up);980 break;981 case LPX_DB:982 case LPX_FX:983 if (lo==up)984 lpx_set_row_bnds(lp, i, LPX_FX, lo, up);985 else986 lpx_set_row_bnds(lp, i, LPX_DB, lo, up);987 break;988 default: ;989 //FIXME error990 }991 }992 }993 virtual double _getRowUpperBound(int i) {994 int b=lpx_get_row_type(lp, i);995 switch (b) {996 case LPX_FR:997 case LPX_LO:998 return INF;999 case LPX_UP:1000 case LPX_DB:1001 case LPX_FX:1002 return lpx_get_row_ub(lp, i);1003 default: ;1004 //FIXME error1005 return 0.0;1006 }1007 }1008 /// \e1009 virtual double _getObjCoeff(int i) {1010 return lpx_get_obj_coef(lp, i);1011 }1012 /// \e1013 virtual void _setObjCoeff(int i, double obj_coef) {1014 lpx_set_obj_coef(lp, i, obj_coef);1015 }1016 public:1017 /// \e1018 void solveSimplex() { lpx_simplex(lp); }1019 /// \e1020 void solvePrimalSimplex() { lpx_simplex(lp); }1021 /// \e1022 void solveDualSimplex() { lpx_simplex(lp); }1023 protected:1024 virtual double _getPrimal(int i) {1025 return lpx_get_col_prim(lp, i);1026 }1027 public:1028 /// \e1029 double getObjVal() { return lpx_get_obj_val(lp); }1030 /// \e1031 int rowNum() const { return lpx_get_num_rows(lp); }1032 /// \e1033 int colNum() const { return lpx_get_num_cols(lp); }1034 /// \e1035 int warmUp() { return lpx_warm_up(lp); }1036 /// \e1037 void printWarmUpStatus(int i) {1038 switch (i) {1039 case LPX_E_OK: cout << "LPX_E_OK" << endl; break;1040 case LPX_E_EMPTY: cout << "LPX_E_EMPTY" << endl; break;1041 case LPX_E_BADB: cout << "LPX_E_BADB" << endl; break;1042 case LPX_E_SING: cout << "LPX_E_SING" << endl; break;1043 }1044 }1045 /// \e1046 int getPrimalStatus() { return lpx_get_prim_stat(lp); }1047 /// \e1048 void printPrimalStatus(int i) {1049 switch (i) {1050 case LPX_P_UNDEF: cout << "LPX_P_UNDEF" << endl; break;1051 case LPX_P_FEAS: cout << "LPX_P_FEAS" << endl; break;1052 case LPX_P_INFEAS: cout << "LPX_P_INFEAS" << endl; break;1053 case LPX_P_NOFEAS: cout << "LPX_P_NOFEAS" << endl; break;1054 }1055 }1056 /// \e1057 int getDualStatus() { return lpx_get_dual_stat(lp); }1058 /// \e1059 void printDualStatus(int i) {1060 switch (i) {1061 case LPX_D_UNDEF: cout << "LPX_D_UNDEF" << endl; break;1062 case LPX_D_FEAS: cout << "LPX_D_FEAS" << endl; break;1063 case LPX_D_INFEAS: cout << "LPX_D_INFEAS" << endl; break;1064 case LPX_D_NOFEAS: cout << "LPX_D_NOFEAS" << endl; break;1065 }1066 }1067 /// Returns the status of the slack variable assigned to row \c row.1068 int getRowStat(const Row& row) {1069 return lpx_get_row_stat(lp, row_iter_map[row]);1070 }1071 /// \e1072 void printRowStatus(int i) {1073 switch (i) {1074 case LPX_BS: cout << "LPX_BS" << endl; break;1075 case LPX_NL: cout << "LPX_NL" << endl; break;1076 case LPX_NU: cout << "LPX_NU" << endl; break;1077 case LPX_NF: cout << "LPX_NF" << endl; break;1078 case LPX_NS: cout << "LPX_NS" << endl; break;1079 }1080 }1081 /// Returns the status of the variable assigned to column \c col.1082 int getColStat(const Col& col) {1083 return lpx_get_col_stat(lp, col_iter_map[col]);1084 }1085 /// \e1086 void printColStatus(int i) {1087 switch (i) {1088 case LPX_BS: cout << "LPX_BS" << endl; break;1089 case LPX_NL: cout << "LPX_NL" << endl; break;1090 case LPX_NU: cout << "LPX_NU" << endl; break;1091 case LPX_NF: cout << "LPX_NF" << endl; break;1092 case LPX_NS: cout << "LPX_NS" << endl; break;1093 }1094 }1095 1096 // MIP1097 /// \e1098 void solveBandB() { lpx_integer(lp); }1099 /// \e1100 void setLP() { lpx_set_class(lp, LPX_LP); }1101 /// \e1102 void setMIP() { lpx_set_class(lp, LPX_MIP); }1103 protected:1104 /// \e1105 void _setColCont(int i) { lpx_set_col_kind(lp, i, LPX_CV); }1106 /// \e1107 void _setColInt(int i) { lpx_set_col_kind(lp, i, LPX_IV); }1108 /// \e1109 double _getMIPPrimal(int i) { return lpx_mip_col_val(lp, i); }1110 };1111 1112 /// @}1113 636 1114 637 } //namespace lemon -
src/work/athos/lp/magic_square.cc
r1240 r1241 4 4 5 5 #include <lemon/time_measure.h> 6 #include <lp_solver_ base.h>6 #include <lp_solver_glpk.h> 7 7 8 8 using std::cout; … … 22 22 Timer ts; 23 23 ts.reset(); 24 typedef L PGLPKLPSolver;24 typedef LpGlpk LPSolver; 25 25 typedef LPSolver::Col Col; 26 26 LPSolver lp; -
src/work/athos/lp/makefile
r1240 r1241 6 6 LDFLAGS = -lglpk#-lcplex -lm -lpthread -lilocplex -L/usr/local/cplex/cplex75/lib/i86_linux2_glibc2.2_gcc3.0/static_mt# -L$(GLPKROOT)/lib 7 7 8 BINARIES = magic_square max_flow_expression expression_test max_flow_by_lp# sample sample2 sample11 sample158 BINARIES = magic_square max_flow_expression #expression_test max_flow_by_lp# sample sample2 sample11 sample15 9 9 10 10 #include ../makefile -
src/work/athos/lp/max_flow_expression.cc
r1240 r1241 8 8 #include <lemon/dimacs.h> 9 9 #include <lemon/time_measure.h> 10 #include <lp_solver_ base.h>10 #include <lp_solver_glpk.h> 11 11 12 12 using std::cout; … … 17 17 class PrimalMap { 18 18 protected: 19 L PGLPK* lp;19 LpGlpk* lp; 20 20 EdgeIndexMap* edge_index_map; 21 21 public: 22 PrimalMap(L PGLPK& _lp, EdgeIndexMap& _edge_index_map) :22 PrimalMap(LpGlpk& _lp, EdgeIndexMap& _edge_index_map) : 23 23 lp(&_lp), edge_index_map(&_edge_index_map) { } 24 24 double operator[](Edge e) const { … … 44 44 Timer ts; 45 45 46 typedef L PGLPKLPSolver;46 typedef LpGlpk LPSolver; 47 47 LPSolver lp; 48 48 lp.setMaximize();
Note: See TracChangeset
for help on using the changeset viewer.