6#include "dlinear/solver/PiecewiseLinearConstraint.h"
8#include "dlinear/util/Config.h"
9#include "dlinear/util/Infinity.h"
10#include "dlinear/util/exception.h"
22 active_var_{
std::move(active_var)},
23 inactive_var_{
std::move(inactive_var)},
24 theory_var_{
std::move(theory_var)},
25 active_soi_{
std::move(active_soi)},
26 inactive_soi_{
std::move(inactive_soi)},
55 DLINEAR_ASSERT(lb <= ub,
"Invalid bounds");
60 DLINEAR_ASSERT(lb ==
nullptr || ub ==
nullptr || *lb <= *ub,
"Invalid bounds");
65 DLINEAR_ASSERT(lb !=
nullptr,
"Invalid lower bound");
67 "New lower bound must be less than or equal to the upper bound. Got {} > {}", *lb, *
upper_bound_);
71 DLINEAR_ASSERT(ub !=
nullptr,
"Invalid upper bound");
73 "New upper bound must be greater than or equal to the lower bound. Got {} < {}", *ub,
@ SOPLEX
Soplex Solver. Default option.
static const mpq_class & ninfinity(const Config &config)
Get the negative infinity value for the given LP solver in the config.
static const mpq_class & infinity(const Config &config)
Get the positive infinity value for the given LP solver in the config.
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.
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.
const Expression inactive_soi_
Expression .
const Expression active_soi_
Expression .
const Expression & soi() const
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.
PiecewiseConstraintState state_
State of the constraint.
const mpq_class & lower_bound() const
Get read-only access to the lower bound of the constraint.
const mpq_class * upper_bound_
Upper bound of the constraint.
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.
mpq_class Evaluate(const Environment &env=Environment{}) const
Evaluates under a given environment (by default, an empty environment).
Represents a symbolic variable.
@ CONTINUOUS
A CONTINUOUS variable takes a mpq_class value.
@ BOOLEAN
A BOOLEAN variable takes a bool value.
bool is_dummy() const
Checks if this is a dummy variable (ID = 0) which is created by the default constructor.
Global namespace for the dlinear library.
PiecewiseConstraintState
State a piecewise constraint can be in.
@ ACTIVE
The constraint is active.
@ INACTIVE
The constraint is inactive.