Esempio n. 1
0
void printModel(const Clasp::SymbolTable& symTab, const Clasp::Model& model) {
    std::cout << "Model " << model.num << ": \n";
    // Print each named atom that is true w.r.t the current model.
    for (Clasp::SymbolTable::const_iterator it = symTab.begin(); it != symTab.end(); ++it) {
        if (model.isTrue(it->second.lit) && !it->second.name.empty()) {
            std::cout << it->second.name.c_str() << " ";
        }
    }
    std::cout << std::endl;
}
Esempio n. 2
0
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;
}