3.2.15.1. rule/Composer.hpp¶
3.2.15.1.1. Class rule::Composer
¶
-
class rule::Composer¶
This class can evaluate rule composition expressions. During evaluation an expression graph is recorded.
The expression graph is a directed hypergraph \((V, E)\), with each vertex representing a rule. Each edge represent all compositions calculated for a unique input. That is every edge \(e\in E\) is on the form \(((u, v), R_e)\) with \((u, v)\in V\times V\) as an ordered pair of rules and \(R_e\subseteq V\) is the set of all resulting rules found.
The graph is visualised as a bipartite graph with point-shaped vertices representing the hyperedges. The in-edges to these hyperedge vertices are labelled with 1 and 2.
3.2.15.1.1.1. Synopsis¶
-
const std::unordered_set<std::shared_ptr<Rule>> &getRuleDatabase() const
-
const std::unordered_set<std::shared_ptr<Rule>> &getProducts() const
-
std::vector<std::shared_ptr<Rule>> eval(const RCExp::Expression &exp, int verbosity)
-
void print() const
-
static std::shared_ptr<Composer> create(const std::unordered_set<std::shared_ptr<Rule>> &database, LabelSettings labelSettings)
3.2.15.1.1.2. Details¶
-
const std::unordered_set<std::shared_ptr<Rule>> &getRuleDatabase() const¶
- Returns
the set of unique rules known by the evaluator.
-
const std::unordered_set<std::shared_ptr<Rule>> &getProducts() const¶
- Returns
the set of unique rules this evaluator has constructed.
-
std::vector<std::shared_ptr<Rule>> eval(const RCExp::Expression &exp, int verbosity)¶
Evaluates a rule composition expression. Any created rule is replaced by a rule in the database if they are isomorphic.
A rule may appear multiple times in the result if multiple overlaps resulted in the same composed rule.
The
verbosity
has the following meaning:0 (or less): no information is printed.
10: Print information about morphism generation for rule composition.
20: Print rule composition information.
- Returns
the result of the expression.
-
void print() const¶
Print the graph representing all expressions evaluated so far.
- Returns
a new instance of an evaluator with its database initialised with the given rules.
Note
The caller is responsible for ensuring the given rules are unique.