#pragma once
#include <utility>
#include "math/lp/lp_settings.h"
#include "math/lp/lar_constraints.h"
namespace lp {
class implied_bound {
public:
mpq m_bound;
unsigned m_j;
bool m_is_lower_bound;
bool m_strict;
using weighted_consumer = std::function<void(mpq const&, u_dependency*)>;
using weighted_explain = std::function<void(weighted_consumer const&)>;
using dependency_explain = std::function<u_dependency*()>;
private:
dependency_explain m_explain_bound = nullptr;
weighted_explain m_explain_weighted = nullptr;
public:
u_dependency* explain_implied() const { return m_explain_bound(); }
void explain_weighted(weighted_consumer const& consume) const { m_explain_weighted(consume); }
void set_explain(dependency_explain f, weighted_explain w) { m_explain_bound = std::move(f); m_explain_weighted = std::move(w); }
lconstraint_kind kind() const {
lconstraint_kind k = m_is_lower_bound? GE : LE;
if (m_strict)
k = static_cast<lconstraint_kind>(k / 2);
return k;
}
implied_bound() = default;
implied_bound(const mpq & a,
unsigned j,
bool is_lower_bound,
bool is_strict,
dependency_explain get_dep,
weighted_explain get_weighted):
m_bound(a),
m_j(j),
m_is_lower_bound(is_lower_bound),
m_strict(is_strict),
m_explain_bound(std::move(get_dep)),
m_explain_weighted(std::move(get_weighted)) {
}
};
}