Exemple #1
0
void declareDecomposition(const Decomposition& decomposition, std::ostream& out)
{
	out << "% Decomposition facts" << std::endl;
	out << "currentNode(" << decomposition.getNode().getGlobalId() << ")." << std::endl;
	for(const auto& v : decomposition.getNode().getBag()) {
		out << "bag(" << decomposition.getNode().getGlobalId() << ',' << v << "). ";
		out << "current(" << v << ")." << std::endl;
	}

	out << "#const numChildNodes=" << decomposition.getChildren().size() << '.' << std::endl;
	if(decomposition.getChildren().empty())
		out << "initial." << std::endl;
	else {
		for(const auto& child : decomposition.getChildren()) {
			out << "childNode(" << child->getNode().getGlobalId() << ")." << std::endl;
			for(const auto& v : child->getNode().getBag()) {
				out << "bag(" << child->getNode().getGlobalId() << ',' << v << "). ";
				out << "-introduced(" << v << ")." << std::endl; // Redundant
			}
		}
	}

	if(decomposition.isRoot())
		out << "final." << std::endl;

	if(decomposition.isPostJoinNode())
		out << "postJoin." << std::endl;

	// Redundant predicates for convenience...
	out << "introduced(X) :- current(X), not -introduced(X)." << std::endl;
	out << "removed(X) :- childNode(N), bag(N,X), not current(X)." << std::endl;
}
Exemple #2
0
TEST_F(DecompositionTest, SetsParent)
{
	Decomposition d = {DecompositionNode{{}}, solverFactory};
	EXPECT_EQ(nullptr, d.getParent());
	DecompositionPtr c{new Decomposition{DecompositionNode{{}}, solverFactory}};
	c->setParent(&d);
	d.addChild(std::move(c));
	EXPECT_EQ(&d, (*d.getChildren().begin())->getParent());
}