3.2.13.1. rule/Composer.hpp¶
-
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 visualized as a bipartite graph with point-shaped vertices representing the hyperedges. The in-edges to these hyperedge vertices are labelled with 1 and 2.
Note
The caller is responsible for ensuring the given rules are unique.
-
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>> &getCreatedRules() const¶
- Returns:
the set of unique rules this evaluator has constructed.
-
std::vector<std::shared_ptr<Rule>> eval(const RCExp::Expression &exp, bool onlyUnique, int verbosity)¶
Evaluates a rule composition expression. Any created rule is replaced by a rule in the database if they are isomorphic.
The onlyUnique parameter controls whether each composition (sub-)result may contain duplicates or not. Unless you need to count possibilities, prefer passing true to avoid accidental combinatorial explosion.
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.