void AspOutPrinter::reportModel(const Clasp::Solver& s, const Clasp::Enumerator& e) { std::cout << "Model " << e.enumerated << ": \n"; // get the symbol table from the solver const Clasp::SymbolTable& symTab = s.sharedContext()->symTab(); for (Clasp::SymbolTable::const_iterator it = symTab.begin(); it != symTab.end(); ++it) { // print each named atom that is true w.r.t the current assignment if (s.isTrue(it->second.lit) && !it->second.name.empty()) { std::cout << it->second.name.c_str() << " "; } } std::cout << std::endl; }
bool ClaspCallback::onModel(const Clasp::Solver& s, const Clasp::Model& m) { if(app.getPrinter().listensForSolverEvents()) { Clasp::SymbolTable& symbolTable = s.sharedContext()->symbolTable(); std::ostringstream msg; msg << "Model: "; for(Clasp::SymbolTable::const_iterator it = symbolTable.begin(); it != symbolTable.end(); ++it) { if(m.isTrue(it->second.lit) && !it->second.name.empty()) msg << it->second.name.c_str() << ' '; } app.getPrinter().solverEvent(msg.str()); } return true; }