12#include "dlinear/libs/libgmp.h"
13#include "dlinear/solver/BoundPreprocessor.h"
14#include "dlinear/solver/PiecewiseConstraintState.h"
15#include "dlinear/symbolic/literal.h"
16#include "dlinear/symbolic/symbolic.h"
54 virtual ~PiecewiseLinearConstraint() =
default;
69 virtual std::ostream&
Print(std::ostream& os)
const = 0;
91 void UpdateBounds(
const mpq_class& lb,
const mpq_class& ub);
102 void UpdateBounds(
const mpq_class* lb,
const mpq_class* ub);
135 [[nodiscard]] mpq_class
Cost(
const Environment& env,
bool active)
const;
146 [[nodiscard]]
const mpq_class&
lower_bound()
const;
148 [[nodiscard]]
const mpq_class&
upper_bound()
const;
186#ifdef DLINEAR_INCLUDE_FMT
188#include "dlinear/util/logging.h"
This class uses some basic algebraic operations to preprocess the constraints and identify violations...
A piecewise linear constraint is a constraint that assumes different linear functions depending on th...
virtual void UpdateLowerBound(const mpq_class *lb)
Update the lower bounds of the constraint.
virtual void UpdateUpperBound(const mpq_class *ub)
Update the upper bounds of the constraint.
bool fixed() const
Check whether the constraint is fixed.
PiecewiseLinearConstraint(const mpq_class *lb=nullptr, const mpq_class *ub=nullptr, Variable active_var={}, Variable inactive_var={}, Variable theory_var={}, Expression active_soi={0}, Expression inactive_soi={0}, PiecewiseConstraintState state=PiecewiseConstraintState::NOT_FIXED)
Construct a new Piecewise Linear Constraint object.
bool has_lower_bound() const
Check whether the constraint is lower bounded.
const Expression inactive_soi_
Expression .
const Variable & inactive_var() const
Get read-only access to the boolean variable associated with the theory literal of the constraint.
const Variable & active_var() const
Get read-only access to the boolean variable associated with the theory literal of the constraint.
const Expression active_soi_
Expression .
const Expression & soi() const
const Variable & theory_var() const
Get read-only access to the theory variable of the constraint.
void UpdateBounds(const mpq_class &lb, const mpq_class &ub)
Update the bounds of the constraint.
const mpq_class * lower_bound_
Lower bound of the constraint.
const Variable theory_var_
Theory variable .
static const Expression zero_soi
Expression used as a soi if the constraint is not fixed yet.
virtual std::ostream & Print(std::ostream &os) const =0
Print the constraint on the standard output.
const Variable active_var_
Boolean variable associated with the theory literal.
mpq_class Cost(const Environment &env) const
Calculate the cost of the violation of the constraint.
virtual LiteralSet Assumptions() const =0
The assumptions used to guide the SAT solver towards the most promising sub-problems.
PiecewiseConstraintState state_
State of the constraint.
bool has_upper_bound() const
Check whether the constraint is upper bounded.
const Expression & active_soi() const
Get read-only access to the expression of the constraint.
PiecewiseConstraintState state() const
Get read-only access to the state of the constraint.
const Expression & inactive_soi() const
Get read-only access to the expression of the constraint.
const mpq_class & lower_bound() const
Get read-only access to the lower bound of the constraint.
virtual LiteralSet LearnedClauses() const =0
Produce some learned clauses the SAT solver will use to prune the sub-problems this piecewise constra...
const mpq_class * upper_bound_
Upper bound of the constraint.
virtual std::set< LiteralSet > TightenBounds(BoundPreprocessor &preprocessor)=0
Use the preprocessor to tighten the bounds of the constraint and hopefully fix its state to either ac...
const Variable inactive_var_
Boolean variable associated with the theory literal.
const mpq_class & upper_bound() const
Get read-only access to the upper bound of the constraint.
Represents a symbolic environment (mapping from a variable to a value).
Represents a symbolic form of an expression.
Represents a symbolic variable.
Global namespace for the dlinear library.
PiecewiseConstraintState
State a piecewise constraint can be in.
@ ACTIVE
The constraint is active.
@ INACTIVE
The constraint is inactive.
@ NOT_FIXED
The constraint is not fixed yet.
std::set< Literal > LiteralSet
A set of literals.