TEST_F(DecompositionTest, IsNotRootByDefault) { Decomposition d = {DecompositionNode{{}}, solverFactory}; EXPECT_FALSE(d.isRoot()); d.setRoot(); EXPECT_TRUE(d.isRoot()); }
Solver::Solver(const Decomposition& decomposition, const Application& app, const std::vector<std::string>& encodingFiles, bool tableMode, bool cardinalityCost, bool printStatistics) : ::Solver(decomposition, app) , encodingFiles(encodingFiles) , tableMode(tableMode) , cardinalityCost(cardinalityCost) , printStatistics(printStatistics) { Gringo::message_printer()->disable(Gringo::W_ATOM_UNDEFINED); #ifndef DISABLE_CHECKS // TODO: Implement tables::EncodingChecker if(!tableMode) { // Check the encoding, but only in the decomposition root. // Otherwise we'd probably do checks redundantly. if(decomposition.isRoot()) { std::ofstream dummyStream; std::unique_ptr<Gringo::Output::OutputBase> out(new Gringo::Output::OutputBase({}, dummyStream)); Gringo::Input::Program program; asp_utils::DummyGringoModule module; Gringo::Scripts scripts(module); Gringo::Defines defs; std::unique_ptr<EncodingChecker> encodingChecker{new trees::EncodingChecker(scripts, program, *out, defs)}; Gringo::Input::NonGroundParser parser(*encodingChecker); for(const auto& file : encodingFiles) parser.pushFile(std::string(file)); parser.parse(); encodingChecker->check(); } } #endif }
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; }