16 #ifndef PAAL_CONSTRAINTS_HPP
17 #define PAAL_CONSTRAINTS_HPP
21 #include <type_traits>
36 static const double PLUS_INF;
37 static const double MINUS_INF;
40 const double lp_traits::PLUS_INF = std::numeric_limits<double>::infinity();
41 const double lp_traits::MINUS_INF = -std::numeric_limits<double>::infinity();
47 template <
typename BoundTypeTag,
typename BoundDirectionTag>
52 : m_lb(lb), m_expr(std::move(expr)) {
53 assert_bound_type_tag<LowerBoundTag>();
58 : m_ub(ub), m_expr(std::move(expr)) {
59 assert_bound_type_tag<UpperBoundTag>();
67 assert_bound_type_tag<LowerBoundTag>();
73 assert_bound_type_tag<UpperBoundTag>();
78 static_assert(std::is_same<BoundDirectionTag, LeftBoundTag>::value ||
79 std::is_same<BoundDirectionTag, RightBoundTag>::value,
80 "Incorrect BoundDirectionTag");
82 template <
typename CorrectTag>
void assert_bound_type_tag()
const {
83 static_assert(std::is_same<BoundTypeTag, CorrectTag>::value,
84 "Incorrect BoundTypeTag");
89 linear_expression m_expr;
93 template <
typename Stream,
typename BoundDirection>
102 template <
typename Stream,
typename BoundDirection>
117 : m_lb(lp_traits::MINUS_INF), m_ub(lp_traits::PLUS_INF) {}
121 : m_lb(lp_traits::MINUS_INF), m_ub(lp_traits::PLUS_INF), m_expr(expr) {}
125 double lb = lp_traits::MINUS_INF,
126 double ub = lp_traits::PLUS_INF)
127 : m_lb(lb), m_ub(ub), m_expr(expr) {}
130 template <
typename BoundDirection>
133 double ub = lp_traits::PLUS_INF)
138 template <
typename BoundDirection>
141 double lb = lp_traits::MINUS_INF)
161 template <
typename Stream,
typename Pr
intCol>
162 void print_double_bounded_expression(Stream &o,
163 const double_bounded_expression &expr,
164 PrintCol print_col) {
165 o << expr.get_lower_bound() <<
" <= ";
166 print_expression(o, expr.get_expression(), print_col);
167 o <<
" <= " << expr.get_upper_bound();
172 template <
typename Stream>
174 detail::print_double_bounded_expression(o, expr, detail::col_id_to_string);
245 #endif // PAAL_CONSTRAINTS_HPP
single_bounded_expression< LowerBoundTag, RightBoundTag > operator>=(const linear_expression &expr, double val)
linear_expression >= double operator.
double get_upper_bound() const
Upper bound getter.
double_bounded_expression(const linear_expression &expr, double lb=lp_traits::MINUS_INF, double ub=lp_traits::PLUS_INF)
Constructor from expression, lower and upper bound.
double get_upper_bound() const
Upper bound getter.
linear_expression get_expression() const
Expression getter.
double_bounded_expression(const single_bounded_expression< UpperBoundTag, BoundDirection > &expr, double lb=lp_traits::MINUS_INF)
Constructor from upper bound expression and a lower bound.
single_bounded_expression(double lb, linear_expression expr)
Constructor from expression and lower bound.
double_bounded_expression(const single_bounded_expression< LowerBoundTag, BoundDirection > &expr, double ub=lp_traits::PLUS_INF)
Constructor from lower bound expression and an upper bound.
double get_lower_bound() const
Lower bound getter.
double_bounded_expression operator==(double val, const linear_expression &expr)
double == linear_expression operator.
double_bounded_expression(const col_id &expr)
Constructor from a single column expression.
linear_expression get_expression() const
Expression getter.
double_bounded_expression()
Constructor.
Stream & operator<<(Stream &o, const single_bounded_expression< LowerBoundTag, BoundDirection > &expr)
operator<< for Lower Bound
single_bounded_expression< LowerBoundTag, LeftBoundTag > operator<=(double val, const linear_expression &expr)
double <= linear_expression operator.
single_bounded_expression(linear_expression expr, double ub)
Constructor from expression and upper bound.
double get_lower_bound() const
Lower bound getter.