6 #include <gtest/gtest.h>
8 #include "knowrob/Logger.h"
9 #include "knowrob/queries/QueryTree.h"
10 #include "knowrob/formulas/Top.h"
16 : rootNode_(new
Node(nullptr, query, false)) {
24 std::list<Node *> fifo;
26 while (!fifo.empty()) {
27 Node *next = fifo.front();
51 return isNegated ? 0 : 1;
54 return isNegated ? 1 : 0;
62 if (priority_a != priority_b) {
63 return priority_a < priority_b;
70 std::list<Node *> out;
71 std::list<Node *> fifo;
73 while (!fifo.empty()) {
74 Node *next = fifo.front();
88 Node *newNode =
new Node(parent, phi, isNegated);
97 if (parent->
isOpen)
return false;
109 path.
nodes_.push_back(std::make_shared<Negation>(parent->
formula));
120 next->isOpen =
false;
123 switch (next->formula->type()) {
129 auto &path =
paths_.back();
137 if (next->isNegated) {
139 for (
auto &phi:
formula->formulae()) {
146 for (
auto &phi:
formula->formulae()) {
156 if (next->isNegated) {
159 for (
auto &phi:
formula->formulae()) {
165 for (
auto &phi:
formula->formulae()) {
175 if (next->isNegated) {
201 if (nodes_.empty()) {
203 }
else if (nodes_.size() == 1) {
204 return nodes_.front();
206 return std::make_shared<Conjunction>(nodes_);
Node(Node *parent, FormulaPtr formula, bool isNegated)
std::list< Node * > successors
std::vector< FormulaPtr > nodes_
std::shared_ptr< Formula > toFormula() const
std::priority_queue< Node *, std::vector< Node * >, NodeComparator > openNodes_
Node * createNode(Node *parent, const FormulaPtr &phi, bool isNegated)
static bool hasCompletePath(Node *leaf)
static void constructPath(Node *leaf, Path &path)
static std::list< QueryTree::Node * > getLeafs(Node *n)
QueryTree(const FormulaPtr &query)
static const std::shared_ptr< Top > & get()
std::shared_ptr< Formula > FormulaPtr
bool operator()(const Node *a, const Node *b) const