|
|
dlinear
0.0.1
Delta-complete SMT solver for linear programming
|
A piecewise linear constraint is a constraint that assumes different linear functions depending on the truth assignment of a literal. More...
#include <PiecewiseLinearConstraint.h>
Public Member Functions | |
| 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. | |
| 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 active or inactive. | |
| virtual std::ostream & | Print (std::ostream &os) const =0 |
| Print the constraint on the standard output. | |
| virtual LiteralSet | Assumptions () const =0 |
| The assumptions used to guide the SAT solver towards the most promising sub-problems. | |
| virtual LiteralSet | LearnedClauses () const =0 |
| Produce some learned clauses the SAT solver will use to prune the sub-problems this piecewise constraint will not be satisfied in. | |
| void | UpdateBounds (const mpq_class &lb, const mpq_class &ub) |
| Update the bounds of the constraint. | |
| void | UpdateBounds (const mpq_class *lb, const mpq_class *ub) |
| Update the bounds of the constraint. | |
| 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. | |
| mpq_class | Cost (const Environment &env) const |
| Calculate the cost of the violation of the constraint. | |
| mpq_class | Cost (const Environment &env, bool active) const |
| Calculate the cost of the violation of the constraint forcing a specific state. | |
| bool | has_lower_bound () const |
| Check whether the constraint is lower bounded. | |
| bool | has_upper_bound () const |
| Check whether the constraint is upper bounded. | |
| bool | fixed () const |
| Check whether the constraint is fixed. | |
| const mpq_class & | lower_bound () const |
| Get read-only access to the lower bound of the constraint. | |
| const mpq_class & | upper_bound () const |
| Get read-only access to the upper bound of the constraint. | |
| const Variable & | active_var () const |
| Get read-only access to the boolean variable associated with the \( y = f_\text{active}(x) \) theory literal of the constraint. | |
| const Variable & | inactive_var () const |
| Get read-only access to the boolean variable associated with the \( y = f_\text{inactive}(x) \) theory literal of the constraint. | |
| const Variable & | theory_var () const |
| Get read-only access to the theory variable \( y \) of the constraint. | |
| const Expression & | active_soi () const |
| Get read-only access to the expression \( y - f_\text{active}(x) \) of the constraint. | |
| const Expression & | inactive_soi () const |
| Get read-only access to the expression \( y - f_\text{inactive}(x) \) of the constraint. | |
| const Expression & | soi () const |
| PiecewiseConstraintState | state () const |
| Get read-only access to the state of the constraint. | |
Static Public Attributes | |
| static const Expression | zero_soi {0} |
| Expression \( 0 \) used as a soi if the constraint is not fixed yet. | |
Protected Attributes | |
| const mpq_class * | lower_bound_ |
| Lower bound of the constraint. | |
| const mpq_class * | upper_bound_ |
| Upper bound of the constraint. | |
| const Variable | active_var_ |
| Boolean variable associated with the \( y = f_\text{active}(x) \) theory literal. | |
| const Variable | inactive_var_ |
| Boolean variable associated with the \( y = f_\text{inactive}(x) \) theory literal. | |
| const Variable | theory_var_ |
| Theory variable \( y \). | |
| const Expression | active_soi_ |
| Expression \( y - f_\text{active}(x) \). | |
| const Expression | inactive_soi_ |
| Expression \( y - f_\text{inactive}(x) \). | |
| PiecewiseConstraintState | state_ |
| State of the constraint. | |
A piecewise linear constraint is a constraint that assumes different linear functions depending on the truth assignment of a literal.
This kind of constraints are in the form:
\[ y = \begin{cases} f_\text{active}(x) & \text{if } l \\ f_\text{inactive}(x) & \text{otherwise} \end{cases} \]
where \( f_\text{active}, f_\text{inactive} \) are linear functions of \( x \) and \( l \) is the literal that determines which of the two is assigned to \( y \). To prune some trivial cases, the class keeps a bound on the value of \( y \).
Definition at line 35 of file PiecewiseLinearConstraint.h.
|
explicit |
Construct a new Piecewise Linear Constraint object.
| lb | lower bound of the constraint. If not specified, the constraint is unbounded from below (-inf) |
| ub | upper bound of the constraint. If not specified, the constraint is unbounded from above (+inf) |
| active_var | boolean variable associated with the \( y = f_\text{active}(x) \) theory literal |
| inactive_var | boolean variable associated with the \( y = f_\text{inactive}(x) \) theory literal |
| theory_var | theory variable \( y \) |
| active_soi | expression \( y - f_\text{active}(x) \) |
| inactive_soi | expression \( y - f_\text{inactive}(x) \) |
| state | state of the constraint |
Definition at line 16 of file PiecewiseLinearConstraint.cpp.
|
inlinenodiscard |
Get read-only access to the expression \( y - f_\text{active}(x) \) of the constraint.
Definition at line 156 of file PiecewiseLinearConstraint.h.
|
inlinenodiscard |
Get read-only access to the boolean variable associated with the \( y = f_\text{active}(x) \) theory literal of the constraint.
Definition at line 150 of file PiecewiseLinearConstraint.h.
|
nodiscardpure virtual |
The assumptions used to guide the SAT solver towards the most promising sub-problems.
Implemented in dlinear::LeakyReluConstraint, and dlinear::ReluConstraint.
|
nodiscard |
Calculate the cost of the violation of the constraint.
Given a feasible solution of the LP problems where this constraint contributes to the objective function as a Sum Of Infeasibilities, calculate the amount of violation caused by its presence in the current state. If the constraint is not fixed yet, return \( 0 \).
| env | current assignment to all the theory variables |
Definition at line 77 of file PiecewiseLinearConstraint.cpp.
|
nodiscard |
Calculate the cost of the violation of the constraint forcing a specific state.
Given a feasible solution of the LP problems where this constraint contributes to the objective function as a Sum Of Infeasibilities, calculate the amount of violation caused by its presence in the current state.
| env | current assignment to all the theory variables |
| active | whether to consider the constraint as active or inactive |
Definition at line 87 of file PiecewiseLinearConstraint.cpp.
|
inlinenodiscard |
Check whether the constraint is fixed.
Definition at line 142 of file PiecewiseLinearConstraint.h.
|
inlinenodiscard |
Check whether the constraint is lower bounded.
Definition at line 138 of file PiecewiseLinearConstraint.h.
|
inlinenodiscard |
Check whether the constraint is upper bounded.
Definition at line 140 of file PiecewiseLinearConstraint.h.
|
inlinenodiscard |
Get read-only access to the expression \( y - f_\text{inactive}(x) \) of the constraint.
Definition at line 158 of file PiecewiseLinearConstraint.h.
|
inlinenodiscard |
Get read-only access to the boolean variable associated with the \( y = f_\text{inactive}(x) \) theory literal of the constraint.
Definition at line 152 of file PiecewiseLinearConstraint.h.
|
nodiscardpure virtual |
Produce some learned clauses the SAT solver will use to prune the sub-problems this piecewise constraint will not be satisfied in.
Implemented in dlinear::LeakyReluConstraint, and dlinear::ReluConstraint.
|
nodiscard |
Get read-only access to the lower bound of the constraint.
If the constraint does not have a lower bound
Definition at line 36 of file PiecewiseLinearConstraint.cpp.
|
pure virtual |
Print the constraint on the standard output.
| os | standard output |
Implemented in dlinear::LeakyReluConstraint, and dlinear::ReluConstraint.
|
nodiscard |
Get read-only access to the current Sum of Infeatsibilities expression based on the state of the constraint.
If the constraint is not fixed yet, return the expression \( 0 \)
Definition at line 43 of file PiecewiseLinearConstraint.cpp.
|
inlinenodiscard |
Get read-only access to the state of the constraint.
Definition at line 165 of file PiecewiseLinearConstraint.h.
|
inlinenodiscard |
Get read-only access to the theory variable \( y \) of the constraint.
Definition at line 154 of file PiecewiseLinearConstraint.h.
|
pure virtual |
Use the preprocessor to tighten the bounds of the constraint and hopefully fix its state to either active or inactive.
| preprocessor | preprocessor to use to tighten the bounds |
Implemented in dlinear::LeakyReluConstraint, and dlinear::ReluConstraint.
| void dlinear::PiecewiseLinearConstraint::UpdateBounds | ( | const mpq_class & | lb, |
| const mpq_class & | ub ) |
Update the bounds of the constraint.
| lb | lower bound of the constraint |
| ub | upper bound of the constraint |
Definition at line 54 of file PiecewiseLinearConstraint.cpp.
| void dlinear::PiecewiseLinearConstraint::UpdateBounds | ( | const mpq_class * | lb, |
| const mpq_class * | ub ) |
Update the bounds of the constraint.
If any of the bounds is not specified, the corresponding bound is not updated.
| lb | lower bound of the constraint |
| ub | upper bound of the constraint |
Definition at line 59 of file PiecewiseLinearConstraint.cpp.
|
virtual |
Update the lower bounds of the constraint.
| lb | lower bound of the constraint |
Reimplemented in dlinear::LeakyReluConstraint, and dlinear::ReluConstraint.
Definition at line 64 of file PiecewiseLinearConstraint.cpp.
|
virtual |
Update the upper bounds of the constraint.
| ub | upper bound of the constraint |
Reimplemented in dlinear::LeakyReluConstraint, and dlinear::ReluConstraint.
Definition at line 70 of file PiecewiseLinearConstraint.cpp.
|
nodiscard |
Get read-only access to the upper bound of the constraint.
If the constraint does not have an upper bound
Definition at line 39 of file PiecewiseLinearConstraint.cpp.