Changeset 1895:5b01801efbc0 in lemon-0.x
- Timestamp:
- 01/14/06 09:44:59 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2470
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/lp_base.h
r1875 r1895 573 573 virtual void _eraseCol(int col) = 0; 574 574 virtual void _eraseRow(int row) = 0; 575 virtual void _getColName(int col, std::string & name) = 0; 576 virtual void _setColName(int col, const std::string & name) = 0; 575 577 virtual void _setRowCoeffs(int i, 576 578 int length, … … 809 811 ///\todo Option to control whether a constraint with a single variable is 810 812 ///added or not. 811 void setRow(Row r, Value l,const Expr &e, Value u) {813 void row(Row r, Value l,const Expr &e, Value u) { 812 814 std::vector<int> indices; 813 815 std::vector<Value> values; … … 830 832 ///\param r is the row to be modified 831 833 ///\param c is a linear expression (see \ref Constr) 832 void setRow(Row r, const Constr &c) {833 setRow(r,834 void row(Row r, const Constr &c) { 835 row(r, 834 836 c.lowerBounded()?c.lowerBound():-INF, 835 837 c.expr(), … … 847 849 Row addRow(Value l,const Expr &e, Value u) { 848 850 Row r=addRow(); 849 setRow(r,l,e,u);851 row(r,l,e,u); 850 852 return r; 851 853 } … … 857 859 Row addRow(const Constr &c) { 858 860 Row r=addRow(); 859 setRow(r,c);861 row(r,c); 860 862 return r; 861 863 } … … 877 879 } 878 880 879 ///Set an element of the coefficient matrix of the LP 881 /// Get the name of a column 882 883 ///\param c is the coresponding coloumn 884 ///\return The name of the colunm 885 std::string ColName(Col c){ 886 std::string name; 887 _getColName(cols.floatingId(c.id), name); 888 return name; 889 } 890 891 /// Set the name of a column 892 893 ///\param c is the coresponding coloumn 894 ///\param name The name to be given 895 void ColName(Col c, const std::string & name){ 896 _setColName(cols.floatingId(c.id), name); 897 } 898 899 /// Set an element of the coefficient matrix of the LP 880 900 881 901 ///\param r is the row of the element to be modified 882 902 ///\param c is the coloumn of the element to be modified 883 903 ///\param val is the new value of the coefficient 884 void setCoeff(Row r, Col c, Value val){ 904 905 void Coeff(Row r, Col c, Value val){ 885 906 _setCoeff(rows.floatingId(r.id),cols.floatingId(c.id), val); 886 907 } … … 888 909 /// Set the lower bound of a column (i.e a variable) 889 910 890 /// The upper bound of a variable (column) has to be given by an911 /// The lower bound of a variable (column) has to be given by an 891 912 /// extended number of type Value, i.e. a finite number of type 892 913 /// Value or -\ref INF. … … 894 915 _setColLowerBound(cols.floatingId(c.id),value); 895 916 } 917 918 ///\brief Set the lower bound of several columns 919 ///(i.e a variables) at once 920 /// 921 ///This magic function takes a container as its argument 922 ///and applies the function on all of its elements. 923 /// The lower bound of a variable (column) has to be given by an 924 /// extended number of type Value, i.e. a finite number of type 925 /// Value or -\ref INF. 926 #ifdef DOXYGEN 927 template<class T> 928 void colLowerBound(T &t, Value value) { return 0;} 929 #else 930 template<class T> 931 typename enable_if<typename T::value_type::LpSolverCol,void>::type 932 colLowerBound(T &t, Value value,dummy<0> = 0) { 933 for(typename T::iterator i=t.begin();i!=t.end();++i) { 934 colLowerBound(*i, value); 935 } 936 } 937 template<class T> 938 typename enable_if<typename T::value_type::second_type::LpSolverCol, 939 void>::type 940 colLowerBound(T &t, Value value,dummy<1> = 1) { 941 for(typename T::iterator i=t.begin();i!=t.end();++i) { 942 colLowerBound(i->second, value); 943 } 944 } 945 template<class T> 946 typename enable_if<typename T::MapIt::Value::LpSolverCol, 947 void>::type 948 colLowerBound(T &t, Value value,dummy<2> = 2) { 949 for(typename T::MapIt i(t); i!=INVALID; ++i){ 950 colLowerBound(*i, value); 951 } 952 } 953 #endif 954 896 955 /// Set the upper bound of a column (i.e a variable) 897 956 … … 902 961 _setColUpperBound(cols.floatingId(c.id),value); 903 962 }; 963 964 ///\brief Set the lower bound of several columns 965 ///(i.e a variables) at once 966 /// 967 ///This magic function takes a container as its argument 968 ///and applies the function on all of its elements. 969 /// The upper bound of a variable (column) has to be given by an 970 /// extended number of type Value, i.e. a finite number of type 971 /// Value or \ref INF. 972 #ifdef DOXYGEN 973 template<class T> 974 void colUpperBound(T &t, Value value) { return 0;} 975 #else 976 template<class T> 977 typename enable_if<typename T::value_type::LpSolverCol,void>::type 978 colUpperBound(T &t, Value value,dummy<0> = 0) { 979 for(typename T::iterator i=t.begin();i!=t.end();++i) { 980 colUpperBound(*i, value); 981 } 982 } 983 template<class T> 984 typename enable_if<typename T::value_type::second_type::LpSolverCol, 985 void>::type 986 colUpperBound(T &t, Value value,dummy<1> = 1) { 987 for(typename T::iterator i=t.begin();i!=t.end();++i) { 988 colUpperBound(i->second, value); 989 } 990 } 991 template<class T> 992 typename enable_if<typename T::MapIt::Value::LpSolverCol, 993 void>::type 994 colUpperBound(T &t, Value value,dummy<2> = 2) { 995 for(typename T::MapIt i(t); i!=INVALID; ++i){ 996 colUpperBound(*i, value); 997 } 998 } 999 #endif 1000 904 1001 /// Set the lower and the upper bounds of a column (i.e a variable) 905 1002 … … 913 1010 } 914 1011 1012 ///\brief Set the lower and the upper bound of several columns 1013 ///(i.e a variables) at once 1014 /// 1015 ///This magic function takes a container as its argument 1016 ///and applies the function on all of its elements. 1017 /// The lower and the upper bounds of 1018 /// a variable (column) have to be given by an 1019 /// extended number of type Value, i.e. a finite number of type 1020 /// Value, -\ref INF or \ref INF. 1021 #ifdef DOXYGEN 1022 template<class T> 1023 void colBounds(T &t, Value lower, Value upper) { return 0;} 1024 #else 1025 template<class T> 1026 typename enable_if<typename T::value_type::LpSolverCol,void>::type 1027 colBounds(T &t, Value lower, Value upper,dummy<0> = 0) { 1028 for(typename T::iterator i=t.begin();i!=t.end();++i) { 1029 colBounds(*i, lower, upper); 1030 } 1031 } 1032 template<class T> 1033 typename enable_if<typename T::value_type::second_type::LpSolverCol, 1034 void>::type 1035 colBounds(T &t, Value lower, Value upper,dummy<1> = 1) { 1036 for(typename T::iterator i=t.begin();i!=t.end();++i) { 1037 colBounds(i->second, lower, upper); 1038 } 1039 } 1040 template<class T> 1041 typename enable_if<typename T::MapIt::Value::LpSolverCol, 1042 void>::type 1043 colBounds(T &t, Value lower, Value upper,dummy<2> = 2) { 1044 for(typename T::MapIt i(t); i!=INVALID; ++i){ 1045 colBounds(*i, lower, upper); 1046 } 1047 } 1048 #endif 1049 915 1050 // /// Set the lower bound of a row (i.e a constraint) 916 1051 … … 946 1081 947 1082 ///\param e is a linear expression of type \ref Expr. 1083 ///\bug Is should be called obj() 948 1084 void setObj(Expr e) { 949 1085 _clearObj(); -
lemon/lp_cplex.cc
r1875 r1895 81 81 CPXdelrows(env, lp, i, i); 82 82 } 83 83 84 void LpCplex::_getColName(int col, std::string &name) 85 { 86 ///\bug Unimplemented 87 } 88 89 void LpCplex::_setColName(int col, const std::string &name) 90 { 91 ///\bug Untested 92 CPXchgcolname(env, lp, 1, &col, const_cast<char*>(name.c_str())); 93 } 84 94 85 95 ///\warning Data at index 0 is ignored in the arrays. -
lemon/lp_cplex.h
r1875 r1895 58 58 virtual void _eraseCol(int i); 59 59 virtual void _eraseRow(int i); 60 virtual void _getColName(int col, std::string & name); 61 virtual void _setColName(int col, const std::string & name); 60 62 virtual void _setRowCoeffs(int i, 61 63 int length, -
lemon/lp_glpk.cc
r1875 r1895 105 105 } 106 106 107 void LpGlpk::_getColName(int col, std::string & name) 108 { 109 110 char *n = lpx_get_col_name(lp,col); 111 name = n?n:""; 112 } 113 114 115 void LpGlpk::_setColName(int col, const std::string & name) 116 { 117 lpx_set_col_name(lp,col,const_cast<char*>(name.c_str())); 118 } 119 107 120 void LpGlpk::_setRowCoeffs(int i, 108 121 int length, -
lemon/lp_glpk.h
r1875 r1895 53 53 virtual void _eraseCol(int i); 54 54 virtual void _eraseRow(int i); 55 55 virtual void _getColName(int col, std::string & name); 56 virtual void _setColName(int col, const std::string & name); 56 57 virtual void _setRowCoeffs(int i, 57 58 int length, -
lemon/lp_skeleton.cc
r1875 r1895 49 49 } 50 50 51 void LpSkeleton::_getColName(int, std::string &) { 52 } 53 54 55 void LpSkeleton::_setColName(int, const std::string &) { 56 } 57 58 51 59 void LpSkeleton::_setRowCoeffs(int, 52 60 int, -
lemon/lp_skeleton.h
r1875 r1895 41 41 /// \e 42 42 virtual void _eraseRow(int i); 43 /// \e 44 virtual void _getColName(int col, std::string & name); 45 /// \e 46 virtual void _setColName(int col, const std::string & name); 47 43 48 /// \e 44 49 -
test/lp_test.cc
r1797 r1895 28 28 // for(int i=0;i<10;i++) x.push_back(lp.addCol()); 29 29 lp.addColSet(x); 30 30 lp.colLowerBound(x,1); 31 lp.colUpperBound(x,1); 32 lp.colBounds(x,1,2); 31 33 #ifndef GYORSITAS 32 34 33 35 std::vector<LP::Col> y(10); 34 36 lp.addColSet(y); 37 38 lp.colLowerBound(y,1); 39 lp.colUpperBound(y,1); 40 lp.colBounds(y,1,2); 35 41 36 42 std::map<int,LP::Col> z; … … 40 46 z.insert(std::make_pair(7,INVALID)); 41 47 z.insert(std::make_pair(5,INVALID)); 42 48 43 49 lp.addColSet(z); 50 51 lp.colLowerBound(z,1); 52 lp.colUpperBound(z,1); 53 lp.colBounds(z,1,2); 44 54 45 55 {
Note: See TracChangeset
for help on using the changeset viewer.