dReal4
contractor_status.h
1 #pragma once
2 
3 #include <set>
4 #include <vector>
5 
7 #include "dreal/util/box.h"
8 #include "dreal/util/dynamic_bitset.h"
9 
10 namespace dreal {
11 
12 /// Contractor status
14  public:
15  ContractorStatus() = delete;
16 
17  /// Constructs a contractor status with @p box and @p branching_point.
18  explicit ContractorStatus(Box box, int branching_point = -1);
19 
20  /// Returns a const reference of the embedded box.
21  const Box& box() const;
22 
23  /// Returns a mutable reference of the embedded box.
24  Box& mutable_box();
25 
26  /// Returns the branching_point.
27  int branching_point() const;
28 
29  /// Returns a mutable reference of the branching_point.
31 
32  /// Returns a const reference of the output field.
33  const DynamicBitset& output() const;
34 
35  /// Returns a mutable reference of the output field.
36  DynamicBitset& mutable_output();
37 
38  /// Returns explanation, a list of formula responsible for the unsat.
39  std::set<Formula> Explanation() const;
40 
41  /// Add a formula @p f into the used constraints.
42  void AddUsedConstraint(const Formula& f);
43 
44  /// Add a formula @p formulas into the used constraints.
45  void AddUsedConstraint(const std::vector<Formula>& formulas);
46 
47  /// Add a variable @p var which is directly responsible for the unsat.
48  void AddUnsatWitness(const Variable& var);
49 
50  /// Updates the contractor status by taking join with @p contractor_status.
51  ///
52  /// @pre The boxes of this and @p contractor_status have the same variables
53  /// vector.
54  ContractorStatus& InplaceJoin(const ContractorStatus& contractor_status);
55 
56  private:
57  // The current box to prune. Most of contractors are updating
58  // this member.
59  Box box_;
60 
61  // If the nested box is obtained from a branching operation, this field
62  // records the dimension (variable) where the branching occurred. The default
63  // value is -1, which indicates that the box is not obtained by a branching.
64  //
65  // This field is used in worklist-fixpoint contractor.
66  int branching_point_{-1};
67 
68  // "output_[i] == 1" means that the value of the i-th variable is
69  // changed after running the contractor.
70  DynamicBitset output_;
71 
72  // A set of constraints used during pruning processes. This is an
73  // over-approximation of an explanation.
74  std::set<Formula> used_constraints_;
75 
76  // A set of variables directly responsible for the unsat result. This
77  // is used to generate an explanation.
78  Variables unsat_witness_;
79 };
80 
81 /// Returns a join of @p contractor_status1 and @p contractor_status2.
82 ///
83 /// @pre The boxes of the two ContractorStatus should have the same variables
84 /// vector.
85 ContractorStatus Join(ContractorStatus contractor_status1,
86  const ContractorStatus& contractor_status2);
87 
88 } // namespace dreal
Box & mutable_box()
Returns a mutable reference of the embedded box.
Definition: contractor_status.cc:65
int branching_point() const
Returns the branching_point.
Definition: contractor_status.cc:67
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
void AddUsedConstraint(const Formula &f)
Add a formula f into the used constraints.
Definition: contractor_status.cc:75
Represents a symbolic variable.
Definition: symbolic_variable.h:16
void AddUnsatWitness(const Variable &var)
Add a variable var which is directly responsible for the unsat.
Definition: contractor_status.cc:92
DynamicBitset & mutable_output()
Returns a mutable reference of the output field.
Definition: contractor_status.cc:73
int & mutable_branching_point()
Returns a mutable reference of the branching_point.
Definition: contractor_status.cc:69
Represents a n-dimensional interval vector.
Definition: box.h:17
const DynamicBitset & output() const
Returns a const reference of the output field.
Definition: contractor_status.cc:71
std::set< Formula > Explanation() const
Returns explanation, a list of formula responsible for the unsat.
Definition: contractor_status.cc:138
const Box & box() const
Returns a const reference of the embedded box.
Definition: contractor_status.cc:63
ContractorStatus Join(ContractorStatus contractor_status1, const ContractorStatus &contractor_status2)
Returns a join of contractor_status1 and contractor_status2.
Definition: contractor_status.cc:153
This is the header file that we consolidate Drake&#39;s symbolic classes and expose them inside of dreal ...
Represents a set of variables.
Definition: symbolic_variables.h:25
ContractorStatus & InplaceJoin(const ContractorStatus &contractor_status)
Updates the contractor status by taking join with contractor_status.
Definition: contractor_status.cc:142
Contractor status.
Definition: contractor_status.h:13
Represents a symbolic form of a first-order logic formula.
Definition: symbolic_formula.h:101