117 i!=expr.data.end(); ++i) { |
118 i!=expr.data.end(); ++i) { |
118 os << (*i).second << "*" << (*i).first << " "; |
119 os << (*i).second << "*" << (*i).first << " "; |
119 } |
120 } |
120 return os; |
121 return os; |
121 } |
122 } |
|
123 |
|
124 template <typename _Col, typename _Value> |
|
125 class LConstr { |
|
126 // protected: |
|
127 public: |
|
128 Expr<_Col, _Value> expr; |
|
129 _Value lo; |
|
130 public: |
|
131 LConstr(const Expr<_Col, _Value>& _expr, _Value _lo) : |
|
132 expr(_expr), lo(_lo) { } |
|
133 }; |
|
134 |
|
135 template <typename _Col, typename _Value> |
|
136 LConstr<_Col, _Value> |
|
137 operator<=(_Value lo, const Expr<_Col, _Value>& expr) { |
|
138 return LConstr<_Col, _Value>(expr, lo); |
|
139 } |
|
140 |
|
141 template <typename _Col, typename _Value> |
|
142 class UConstr { |
|
143 // protected: |
|
144 public: |
|
145 Expr<_Col, _Value> expr; |
|
146 _Value up; |
|
147 public: |
|
148 UConstr(const Expr<_Col, _Value>& _expr, _Value _up) : |
|
149 expr(_expr), up(_up) { } |
|
150 }; |
|
151 |
|
152 template <typename _Col, typename _Value> |
|
153 UConstr<_Col, _Value> |
|
154 operator<=(const Expr<_Col, _Value>& expr, _Value up) { |
|
155 return UConstr<_Col, _Value>(expr, up); |
|
156 } |
|
157 |
|
158 template <typename _Col, typename _Value> |
|
159 class Constr { |
|
160 // protected: |
|
161 public: |
|
162 Expr<_Col, _Value> expr; |
|
163 _Value lo, up; |
|
164 public: |
|
165 Constr(const Expr<_Col, _Value>& _expr, _Value _lo, _Value _up) : |
|
166 expr(_expr), lo(_lo), up(_up) { } |
|
167 Constr(const LConstr<_Col, _Value>& _lconstr) : |
|
168 expr(_lconstr.expr), |
|
169 lo(_lconstr.lo), |
|
170 up(std::numeric_limits<_Value>::infinity()) { } |
|
171 Constr(const UConstr<_Col, _Value>& _uconstr) : |
|
172 expr(_uconstr.expr), |
|
173 lo(-std::numeric_limits<_Value>::infinity()), |
|
174 up(_uconstr.up) { } |
|
175 }; |
|
176 |
|
177 template <typename _Col, typename _Value> |
|
178 Constr<_Col, _Value> |
|
179 operator<=(const LConstr<_Col, _Value>& lconstr, _Value up) { |
|
180 return Constr<_Col, _Value>(lconstr.expr, lconstr.lo, up); |
|
181 } |
|
182 |
|
183 template <typename _Col, typename _Value> |
|
184 Constr<_Col, _Value> |
|
185 operator<=(_Value lo, const UConstr<_Col, _Value>& uconstr) { |
|
186 return Constr<_Col, _Value>(uconstr.expr, lo, uconstr.up); |
|
187 } |
|
188 |
|
189 template <typename _Col, typename _Value> |
|
190 Constr<_Col, _Value> |
|
191 operator==(const Expr<_Col, _Value>& expr, _Value value) { |
|
192 return Constr<_Col, _Value>(expr, value, value); |
|
193 } |
122 |
194 |
123 } //namespace lemon |
195 } //namespace lemon |
124 |
196 |
125 #endif //LEMON_EXPRESSION_H |
197 #endif //LEMON_EXPRESSION_H |