mirror of
https://github.com/Z3Prover/z3
synced 2025-06-13 17:36:15 +00:00
Add command to set initial value hints for solver in various components
This commit is contained in:
parent
1c163dbad2
commit
a3f35b6830
17 changed files with 82 additions and 8 deletions
|
@ -318,6 +318,25 @@ UNARY_CMD(echo_cmd, "echo", "<string>", "display the given string", CPK_STRING,
|
|||
else
|
||||
ctx.regular_stream() << arg << std::endl;);
|
||||
|
||||
class set_initial_value_cmd : public cmd {
|
||||
expr* m_var = nullptr, *m_value = nullptr;
|
||||
public:
|
||||
set_initial_value_cmd(): cmd("set-initial-value") {}
|
||||
char const* get_usage() const override { return "<var> <value>"; }
|
||||
char const* get_descr(cmd_context& ctx) const { return "set an initial value for search as a hint to the solver"; }
|
||||
unsigned get_arity() const { return 2; }
|
||||
void prepare(cmd_context& ctx) { m_var = m_value = nullptr; }
|
||||
cmd_arg_kind next_arg_kind(cmd_context& ctx) const { return CPK_EXPR; }
|
||||
void set_next_arg(cmd_context& ctx, expr* e) { if (m_var) m_value = e; else m_var = e; }
|
||||
void execute(cmd_context& ctx) {
|
||||
SASSERT(m_var && m_value);
|
||||
if (ctx.get_opt())
|
||||
ctx.get_opt()->initialize_value(m_var, m_value);
|
||||
else if (ctx.get_solver())
|
||||
ctx.get_solver()->user_propagate_initialize_value(m_var, m_value);
|
||||
}
|
||||
};
|
||||
|
||||
class set_get_option_cmd : public cmd {
|
||||
protected:
|
||||
symbol m_true;
|
||||
|
@ -893,6 +912,7 @@ void install_basic_cmds(cmd_context & ctx) {
|
|||
ctx.insert(alloc(get_option_cmd));
|
||||
ctx.insert(alloc(get_info_cmd));
|
||||
ctx.insert(alloc(set_info_cmd));
|
||||
ctx.insert(alloc(set_initial_value_cmd));
|
||||
ctx.insert(alloc(get_consequences_cmd));
|
||||
ctx.insert(alloc(builtin_cmd, "assert", "<term>", "assert term."));
|
||||
ctx.insert(alloc(builtin_cmd, "check-sat", "<boolean-constants>*", "check if the current context is satisfiable. If a list of boolean constants B is provided, then check if the current context is consistent with assigning every constant in B to true."));
|
||||
|
|
|
@ -173,6 +173,8 @@ public:
|
|||
virtual void set_logic(symbol const& s) = 0;
|
||||
virtual void get_box_model(model_ref& mdl, unsigned index) = 0;
|
||||
virtual void updt_params(params_ref const& p) = 0;
|
||||
virtual void initialize_value(expr* var, expr* value) = 0;
|
||||
|
||||
};
|
||||
|
||||
class ast_context_params : public context_params {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue