| souffle
    2.0.2-371-g6315b36
    | 
 
 
 
Go to the documentation of this file.
   34 template <
typename Id, 
typename PropertySpace>
 
   37 template <
typename Var>
 
   40 template <
typename Var>
 
   43 template <
typename Var>
 
   53 struct default_bottom_factory {
 
   59 template <
typename T, 
typename meet_assign_op>
 
   63         meet_assign_op()(res, 
b);
 
   86 template <
typename T, 
typename meet_assign_op,
 
  101 template <
typename T>
 
  102 struct set_meet_assign_op {
 
  103     bool operator()(std::set<T>& a, 
const std::set<T>& 
b) {
 
  104         bool changed = 
false;
 
  105         for (
const auto& cur : 
b) {
 
  106             changed |= a.insert(cur).second;
 
  116 template <
typename T>
 
  130 template <
typename Id, 
typename PropertySpace>
 
  146         return id == other.
id;
 
  151         return !(*
this == other);
 
  156         return id < other.
id;
 
  160     virtual void print(std::ostream& out)
 const {
 
  184 template <
typename Var>
 
  200     virtual void print(std::ostream& out) 
const = 0;
 
  221 template <
typename Var>
 
  222 std::shared_ptr<Constraint<Var>> 
sub(
const Var& a, 
const Var& 
b, 
const std::string& symbol = 
"⊑") {
 
  227         Sub(Var a, Var 
b, std::string symbol) : a(std::move(a)), 
b(std::move(
b)), symbol(std::move(symbol)) {}
 
  230             typename Var::property_space::meet_assign_op_type meet_assign;
 
  231             return meet_assign(ass[
b], ass[a]);
 
  234         void print(std::ostream& out)
 const override {
 
  235             out << a << 
" " << symbol << 
" " << 
b;
 
  239     return std::make_shared<Sub>(a, 
b, symbol);
 
  250 template <
typename Var, 
typename Val = 
typename Var::property_space::value_type>
 
  251 std::shared_ptr<Constraint<Var>> 
sub(
const Val& a, 
const Var& 
b, 
const std::string& symbol = 
"⊑") {
 
  252     struct Sub : 
public Constraint<Var> {
 
  257         Sub(Val a, Var 
b, std::string symbol) : a(
std::move(a)), 
b(
std::move(
b)), symbol(
std::move(symbol)) {}
 
  260             typename Var::property_space::meet_assign_op_type meet_assign;
 
  261             return meet_assign(ass[
b], a);
 
  264         void print(std::ostream& out)
 const override {
 
  265             out << a << 
" " << symbol << 
" " << 
b;
 
  269     return std::make_shared<Sub>(a, 
b, symbol);
 
  282 template <
typename Var>
 
  289     using data_type = 
typename std::map<Var, value_type>;
 
  298     using iterator = 
typename data_type::const_iterator;
 
  313         auto pos = 
data.find(var);
 
  314         return (pos != 
data.end()) ? pos->second : 
bottom;
 
  327         auto pos = 
data.find(var);
 
  328         if (pos == 
data.end()) {
 
  335     void print(std::ostream& out)
 const {
 
  365 template <
typename Var>
 
  413     void print(std::ostream& out)
 const {
 
  417             out << 
"{\n\t" << 
join(
constraints, 
",\n\t", print_deref<constraint_ptr>()) << 
"\n}";
 
  
friend std::ostream & operator<<(std::ostream &out, const Assignment &ass)
Adds print support.
virtual void print(std::ostream &out) const
Adds print support.
value_type bottom
a copy of the value assigned to all unmapped variables
std::shared_ptr< Constraint< Var > > sub(const Var &a, const Var &b, const std::string &symbol="⊑")
A generic factory for constraints of the form.
bool operator<(const Variable &other) const
Adds support for less-than comparison.
Constraint< Var > constraint
bottom_factory bottom_factory_type
typename property_space::bottom_factory_type bottom_factory_type
virtual void print(std::ostream &out) const =0
Adds print support for constraints (debugging)
A problem is a list of constraints for which a solution is desired.
A variable to be utilized within constraints to be handled by the constraint solver.
Variable & operator=(const Variable &)=default
std::shared_ptr< constraint > constraint_ptr
A generic base class for constraints on variables.
virtual ~Variable()=default
Id id
the underlying value giving this variable its identity
typename data_type::const_iterator iterator
typename Var::property_space property_space
const value_type & operator[](const Var &var) const
Looks up the value associated to the given variable.
detail::joined_sequence< Iter, Printer > join(const Iter &a, const Iter &b, const std::string &sep, const Printer &p)
Creates an object to be forwarded to some output stream for printing sequences of elements interspers...
An assignment maps a list of variables to values of their respective property space.
A property space for set-based properties based on sub-set lattices.
iterator end() const
Allows to iterate over the maplets defining this assignment.
A MPL type for defining a property space.
virtual ~Constraint()=default
A virtual destructor.
meet_assign_op meet_assign_op_type
friend std::ostream & operator<<(std::ostream &out, const Variable &var)
Adds print support.
bool operator()(std::set< T > &a, const std::set< T > &b)
Assignment()
Creates a new, empty assignment.
typename std::map< Var, value_type > data_type
l j a showGridBackground &&c b raw series this eventEmitter b
T operator()(const T &a, const T &b)
bool operator!=(const Variable &other) const
Adds support for inequality comparison.
iterator begin() const
Allows to iterate over the maplets defining this assignment.
typename property_space::value_type value_type
friend std::ostream & operator<<(std::ostream &out, const Constraint &c)
Adds print support for constraints (debugging)
void print(std::ostream &out) const
Enables a problem to be printed (debugging)
bool operator==(const Variable &other) const
Adds support for equality comparison.
virtual bool update(Assignment< Var > &ass) const =0
Requests the given assignment to be updated according to this constraint.
std::vector< constraint_ptr > constraints
The list of covered constraints.
void add(const constraint_ptr &constraint)
Adds another constraint to the internally maintained list of constraints.
void print(std::ostream &out) const
Adds print support.
friend std::ostream & operator<<(std::ostream &out, const Problem &p)
Assignment< Var > solve() const
Computes a solution (minimum fixpoint) for the contained list of constraints.
data_type data
the actual mapping of variables to values
a horizontalBars(j=m=void 0===a.axisX.type?new c.AutoScaleAxis(c.Axis.units.x, b.normalized.series, o, c.extend({}, a.axisX,{highLow:d, referenceValue:0})):a.axisX.type.call(c, c.Axis.units.x, b.normalized.series, o, c.extend({}, a.axisX,{highLow:d, referenceValue:0})), l=n=void 0===a.axisY.type?new c.StepAxis(c.Axis.units.y, b.normalized.series, o,{ticks:k}):a.axisY.type.call(c, c.Axis.units.y, b.normalized.series, o, a.axisY)) var p