-
Notifications
You must be signed in to change notification settings - Fork 16
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
Single shot solving without deleting the logic program #64
Comments
* Add API for disabling deletion of logic program also in single-shot solving mode. Clients of ClaspFacade should call keepProgram() if they need (parts of) the logic program after it has been prepared for (single-shot) solving, e.g. in order to access atom mappings or to extract an unsat-core after solving has finished. (NOTE: keepProgram() is implied in multi-shot solving, i.e. if enableProgramUpdates() has been called)
@rkaminsk |
I'll have a look. |
On my small test this seems to be working. We might need additional runtime checks though: from sys import argv
from clingo import Control
ctl = Control(argv[1:])
ctl.add('base', [], '1 {a; b} 1.')
ctl.ground([('base', [])])
print('solving step 1.1')
ctl.solve(on_model=print)
print('solving step 1.2')
ctl.solve(on_model=print)
ctl.add('blub', [], '1 {c; d} 1.')
ctl.ground([('blub', [])])
print('solving step 2')
ctl.solve(on_model=print) The above code produces the following output:
What do you think? Should we already throw a runtime error in step 1.2? In clingo I could only do this by having another state bool. Would it be easier in clasp? |
Actually, I think I could do the check easily in the diff --git a/src/clasp_facade.cpp b/src/clasp_facade.cpp
index c70549e..00b452e 100644
--- a/src/clasp_facade.cpp
+++ b/src/clasp_facade.cpp
@@ -888,6 +888,7 @@ void ClaspFacade::enableSolveInterrupts() {
}
void ClaspFacade::startStep(uint32 n) {
+ POTASSCO_REQUIRE(n == 0 || incremental());
step_.init(*this);
step_.totalTime = RealTime::getTime();
step_.cpuTime = ProcessTime::getTime(); |
* Check for unsupported updates in ClaspFacade::update() and ClaspFacade::prepare(). The former requires real multi-shot mode, while the latter requires at least multi-solve mode. Throw std::logic_error if these requirements are not met.
@rkaminsk I added a slightly different version of the runtime checks - hopefully with the same effect for clingo. While currently not fully implemented, conceptually, clasp supports three different modes:
In order to not break the second case, I added checks to prepare() and update() instead. |
Sounds good. The multi-solve mode would actually be interesting for clingo, too. It just might be tricky to fiddle it in because, currently, solving always starts a new step. |
Currently, the clingo API always uses multi-shot solving. Some users reported that solving performance in this mode is worse compared to single-shot solving. Thus, it would be nice to be able to use the API in single-shot mode, too. The problem is that clasp's facade releases the logic program right after preprocessing in single-shot mode. Since the clingo API relies on having the logic program available even after/during solving, we cannot simply switch to single-shot solving mode. Would it be possible to switch to single-shot solving mode without deleting the logic program?
The text was updated successfully, but these errors were encountered: