3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-19 20:33:38 +00:00

add API for setting variable activity

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-02-15 12:05:24 -08:00
parent e4c6dcd84c
commit 89bf2d4368
22 changed files with 125 additions and 1 deletions

View file

@ -431,6 +431,15 @@ extern "C" {
Z3_CATCH;
}
void Z3_API Z3_solver_set_activity(Z3_context c, Z3_solver s, Z3_ast a, double activity) {
Z3_TRY;
LOG_Z3_solver_set_activity(c, s, a, activity);
RESET_ERROR_CODE();
init_solver(c, s);
to_solver_ref(s)->set_activity(to_expr(a), activity);
Z3_CATCH;
}
Z3_ast_vector Z3_API Z3_solver_get_trail(Z3_context c, Z3_solver s) {
Z3_TRY;
LOG_Z3_solver_get_trail(c, s);

View file

@ -2245,6 +2245,7 @@ namespace z3 {
check_error();
return result;
}
void set_activity(expr const& lit, double act) { Z3_solver_set_activity(ctx(), m_solver, lit, act); }
expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
friend std::ostream & operator<<(std::ostream & out, solver const & s);

View file

@ -6744,6 +6744,12 @@ class Solver(Z3PPObject):
"""
return AstVector(Z3_solver_get_trail(self.ctx.ref(), self.solver), self.ctx)
def set_activity(self, lit, act):
"""Set activity of literal on solver object.
This influences the case split order of the variable.
"""
Z3_solver_set_activity(self.ctx.ref(), self.solver, lit.ast, act)
def statistics(self):
"""Return statistics for the last `check()`.

View file

@ -6236,6 +6236,12 @@ extern "C" {
*/
void Z3_API Z3_solver_get_levels(Z3_context c, Z3_solver s, Z3_ast_vector literals, unsigned sz, unsigned levels[]);
/**
\brief set activity score associated with literal.
def_API('Z3_solver_set_activity', VOID, (_in(CONTEXT), _in(SOLVER), _in(AST), _in(DOUBLE)))
*/
void Z3_API Z3_solver_set_activity(Z3_context c, Z3_solver s, Z3_ast l, double activity);
/**
\brief Check whether the assertions in a given solver are consistent or not.