potassco / clasp

⚙️ A conflict-driven nogood learning answer set solver
https://potassco.org/clasp/
MIT License
117 stars 16 forks source link

User Statistics are only printed if the statistics are "accessed". #30

Closed rkaminsk closed 6 years ago

rkaminsk commented 6 years ago

Just calling ClaspFacade::addStatisticsCallback is not enough to make user statistics appear in the text output. When the (read-only) statistics are traversed at some point, then they will appear also in the textoutput with --stats.

rkaminsk commented 6 years ago

One way to fix this could be

diff --git a/src/clasp_facade.cpp b/src/clasp_facade.cpp
index c99ed7d..f07cea2 100644
--- a/src/clasp_facade.cpp
+++ b/src/clasp_facade.cpp
@@ -637,6 +637,7 @@ void ClaspFacade::Statistics::initLevel(uint32 level) {
        }
 }
 void ClaspFacade::Statistics::addExternal(StatsCallback cb, void* data) {
+       getClingo();
        sources_.push_back(UserSource(cb, data));
 }
rkaminsk commented 6 years ago

Here it would probably be better to store the sources in the ClingoView in the first place.

BenKaufmann commented 6 years ago

Thanks. Fixed in dev.