-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup() removes theory atoms ? #169
Comments
Cleanup is meant to be called after solving. It is not meant to and cannot be used for preprocessing by calling it in-between grounding calls. The program you wrote should not crash though. I actually intended it to be a noop. Looking through this I discovered another bug. The theory is passed unnecessarily often. Even turning your #include <clingo.hh>
#include <sstream>
using namespace Clingo;
class Observer : public Clingo::GroundProgramObserver {
void theory_atom(id_t atom_id_or_zero, id_t , IdSpan ) override {
std::cerr << "atom: " << atom_id_or_zero << std::endl;
}
};
class TestApp : public Clingo::Application, private SolveEventHandler {
public:
void main(Control &ctl, StringSpan) override {
Observer o;
ctl.register_observer(o);
ctl.add("base",{}, R"(#theory csp {
dom_term {};
&dom/0 : dom_term, any}.)");
ctl.add("base",{}, "&dom {0}. &dom {1}.");
ctl.add("acid",{}, "&dom {1}. &dom {2}.");
std::cerr << "ground base" << std::endl;
ctl.ground({{"base", {}}});
std::cerr << "ground acid" << std::endl;
ctl.ground({{"acid", {}}});
ctl.cleanup();
std::cerr << "backend" << std::endl;
{ ctl.backend(); }
std::cerr << "backend" << std::endl;
{ ctl.backend(); }
}
};
int main(int argc, char *argv[]) {
TestApp app;
return Clingo::clingo_main(app, {argv + 1, static_cast<size_t>(argc - 1)});
} The program gives the following output:
It should give the following output:
This will be fixed in the next release. |
thanks. Maybe you can add a short notice in the documentation. |
I can recommend to call it after solve. The system is in best state to simplify then. In other circumstances it might still be possible to simplify but when exactly very much depends on the implementation. In principle it should always be possible to simplify; it is just difficult to implement. Future clingo versions might also be able to always simplify right after grounding. (Right now no simplification will happen if a theory is used.) |
Just some comments for myself how to fix this (no need to answer 😉). Quite involved actually. At the moment cleanup calls
|
The cleanup function should no longer cause runtime errors. Furthermore, the backend can now be used to add facts known to the grounder (at the cost of slightly increased memory consumption).
Given this weird looking little example program, I do get an unexpected
during the creation of the backend
The text was updated successfully, but these errors were encountered: