Skip to content

Commit

Permalink
Add number of blocked restarts to stats.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenKaufmann committed Apr 4, 2024
1 parent ec05889 commit 67f1793
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions clasp/solver_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ struct CoreStats {
STAT(uint64 choices; DOXY(number of choices) , "choices" , VALUE(choices) , LHS.choices += RHS.choices )\
STAT(uint64 conflicts; DOXY(number of conflicts) , "conflicts" , VALUE(conflicts) , LHS.conflicts += RHS.conflicts )\
STAT(uint64 analyzed; DOXY(number of conflicts analyzed), "conflicts_analyzed", VALUE(analyzed) , LHS.analyzed += RHS.analyzed )\
STAT(uint64 restarts; DOXY(number of restarts) , "restarts" , VALUE(restarts) , LHS.restarts += RHS.restarts )\
STAT(uint64 lastRestart;DOXY(length of last restart), "restarts_last" , VALUE(lastRestart), LHS.lastRestart = std::max(LHS.lastRestart, RHS.lastRestart))
STAT(uint64 restarts; DOXY(number of restarts) , "restarts" , VALUE(restarts) , LHS.restarts += RHS.restarts )\
STAT(uint64 lastRestart;DOXY(length of last restart) , "restarts_last" , VALUE(lastRestart), LHS.lastRestart = std::max(LHS.lastRestart, RHS.lastRestart)) \
STAT(uint64 blRestarts; DOXY(number of blocked restarts), "restarts_blocked", VALUE(blRestarts), LHS.blRestarts = std::max(LHS.blRestarts, RHS.blRestarts))

CoreStats() { reset(); }
void reset();
Expand Down
4 changes: 2 additions & 2 deletions src/clasp_output.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2009-2017 Benjamin Kaufmann
// Copyright (c) 2009-present Benjamin Kaufmann
//
// This file is part of Clasp. See http://www.cs.uni-potsdam.de/clasp/
//
Expand Down Expand Up @@ -1188,7 +1188,7 @@ void TextOutput::printStats(const Clasp::SolverStats& st) const {
printf(" (Analyzed: %" PRIu64")\n", st.backjumps());
printKeyValue("Restarts", "%-8" PRIu64"", st.restarts);
if (st.restarts) {
printf(" (Average: %.2f Last: %" PRIu64")", st.avgRestart(), st.lastRestart);
printf(" (Average: %.2f Last: %" PRIu64" Blocked: %" PRIu64")", st.avgRestart(), st.lastRestart, st.blRestarts);
}
printf("\n");
if (!st.extra) return;
Expand Down
3 changes: 2 additions & 1 deletion src/solver.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2006-2017 Benjamin Kaufmann
// Copyright (c) 2006-present Benjamin Kaufmann
//
// This file is part of Clasp. See http://www.cs.uni-potsdam.de/clasp/
//
Expand Down Expand Up @@ -1833,6 +1833,7 @@ ValueRep Solver::search(SearchLimits& limit, double rf) {
if (limit.restart.dynamic) { limit.restart.dynamic->resetBlock(); }
else { limit.restart.conflicts += block->inc; }
block->next = block->n + block->inc;
++stats.blRestarts;
}
} while (resolveConflict() && !propagate() && (++n, true));
limit.used += n;
Expand Down
4 changes: 2 additions & 2 deletions tests/facade_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ TEST_CASE("Facade statistics", "[facade]") {
REQUIRE(result == stats->get(r, it->c_str()));
REQUIRE(stats->type(result) == Potassco::Statistics_t::Value);
}
REQUIRE(keys.size() == 238);
REQUIRE(keys.size() == 242);

Key_t result;
REQUIRE(stats->find(r, "problem.lp", &result));
Expand Down Expand Up @@ -1598,7 +1598,7 @@ TEST_CASE("Facade statistics", "[facade]") {
REQUIRE(stats->find(r, it->c_str(), 0));
REQUIRE(stats->type(stats->get(r, it->c_str())) == Potassco::Statistics_t::Value);
}
REQUIRE(keys.size() == 256);
REQUIRE(keys.size() == 260);
}
}
namespace {
Expand Down

0 comments on commit 67f1793

Please sign in to comment.