Changeset 1895:5b01801efbc0 in lemon0.x for lemon/lp_base.h
 Timestamp:
 01/14/06 09:44:59 (18 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2470
 File:

 1 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();
Note: See TracChangeset
for help on using the changeset viewer.