mirror of
https://github.com/Z3Prover/z3
synced 2025-06-27 08:28:44 +00:00
Nits
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
af5d989d6c
commit
03f5020d0b
2 changed files with 29 additions and 28 deletions
|
@ -84,8 +84,7 @@ namespace opt {
|
||||||
// HACK: reuse m_optsmt but add only a single objective each round
|
// HACK: reuse m_optsmt but add only a single objective each round
|
||||||
bool is_max = (obj->get_decl_kind() == OP_MAXIMIZE);
|
bool is_max = (obj->get_decl_kind() == OP_MAXIMIZE);
|
||||||
m_optsmt.add(to_app(obj->get_arg(0)), is_max);
|
m_optsmt.add(to_app(obj->get_arg(0)), is_max);
|
||||||
opt_solver& s = *m_solver.get();
|
lbool result = m_optsmt(get_solver());
|
||||||
lbool result = m_optsmt(s);
|
|
||||||
if (committed) m_optsmt.commit_assignment(0);
|
if (committed) m_optsmt.commit_assignment(0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -93,30 +92,27 @@ namespace opt {
|
||||||
lbool context::execute_maxsat(app* obj, bool committed) {
|
lbool context::execute_maxsat(app* obj, bool committed) {
|
||||||
maxsmt* ms;
|
maxsmt* ms;
|
||||||
VERIFY(m_maxsmts.find(obj->get_decl()->get_name(), ms));
|
VERIFY(m_maxsmts.find(obj->get_decl()->get_name(), ms));
|
||||||
opt_solver& s = *m_solver.get();
|
lbool result = (*ms)(get_solver());
|
||||||
lbool result = (*ms)(s);
|
|
||||||
if (committed) ms->commit_assignment();
|
if (committed) ms->commit_assignment();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
lbool context::execute_lex(app* obj) {
|
lbool context::execute_lex(app* obj) {
|
||||||
lbool result = l_true;
|
lbool r = l_true;
|
||||||
for (unsigned i = 0; i < obj->get_num_args(); ++i) {
|
for (unsigned i = 0; r == l_true && i < obj->get_num_args(); ++i) {
|
||||||
result = execute(obj->get_arg(i), true);
|
r = execute(obj->get_arg(i), true);
|
||||||
if (result != l_true) break;
|
|
||||||
}
|
}
|
||||||
return result;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
lbool context::execute_box(app* obj) {
|
lbool context::execute_box(app* obj) {
|
||||||
lbool result = l_true;
|
lbool r = l_true;
|
||||||
for (unsigned i = 0; i < obj->get_num_args(); ++i) {
|
for (unsigned i = 0; r == l_true && i < obj->get_num_args(); ++i) {
|
||||||
push();
|
push();
|
||||||
result = execute(obj->get_arg(i), false);
|
r = execute(obj->get_arg(i), false);
|
||||||
pop(1);
|
pop(1);
|
||||||
if (result != l_true) break;
|
|
||||||
}
|
}
|
||||||
return result;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
lbool context::execute_pareto(app* obj) {
|
lbool context::execute_pareto(app* obj) {
|
||||||
|
@ -124,18 +120,20 @@ namespace opt {
|
||||||
return execute_lex(obj);
|
return execute_lex(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opt_solver& context::get_solver() {
|
||||||
|
return *m_solver.get();
|
||||||
|
}
|
||||||
|
|
||||||
void context::push() {
|
void context::push() {
|
||||||
opt_solver& s = *m_solver.get();
|
get_solver().push();
|
||||||
s.push();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void context::pop(unsigned sz) {
|
void context::pop(unsigned sz) {
|
||||||
opt_solver& s = *m_solver.get();
|
get_solver().pop(sz);
|
||||||
s.pop(sz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lbool context::optimize(expr* objective) {
|
lbool context::optimize(expr* objective) {
|
||||||
opt_solver& s = *m_solver.get();
|
opt_solver& s = get_solver();
|
||||||
solver::scoped_push _sp(s);
|
solver::scoped_push _sp(s);
|
||||||
|
|
||||||
for (unsigned i = 0; i < m_hard_constraints.size(); ++i) {
|
for (unsigned i = 0; i < m_hard_constraints.size(); ++i) {
|
||||||
|
|
|
@ -53,15 +53,6 @@ namespace opt {
|
||||||
void add_objective(app* t, bool is_max) { m_objs.push_back(t); m_ismaxs.push_back(is_max); }
|
void add_objective(app* t, bool is_max) { m_objs.push_back(t); m_ismaxs.push_back(is_max); }
|
||||||
void add_hard_constraint(expr* f) { m_hard_constraints.push_back(f); }
|
void add_hard_constraint(expr* f) { m_hard_constraints.push_back(f); }
|
||||||
|
|
||||||
lbool execute(expr* obj, bool committed);
|
|
||||||
lbool execute_min_max(app* obj, bool committed);
|
|
||||||
lbool execute_maxsat(app* obj, bool committed);
|
|
||||||
lbool execute_lex(app* obj);
|
|
||||||
lbool execute_box(app* obj);
|
|
||||||
lbool execute_pareto(app* obj);
|
|
||||||
|
|
||||||
void push();
|
|
||||||
void pop(unsigned sz);
|
|
||||||
|
|
||||||
lbool optimize(expr* objective);
|
lbool optimize(expr* objective);
|
||||||
lbool optimize();
|
lbool optimize();
|
||||||
|
@ -76,6 +67,18 @@ namespace opt {
|
||||||
void updt_params(params_ref& p);
|
void updt_params(params_ref& p);
|
||||||
private:
|
private:
|
||||||
void validate_feasibility(maxsmt& ms);
|
void validate_feasibility(maxsmt& ms);
|
||||||
|
|
||||||
|
lbool execute(expr* obj, bool committed);
|
||||||
|
lbool execute_min_max(app* obj, bool committed);
|
||||||
|
lbool execute_maxsat(app* obj, bool committed);
|
||||||
|
lbool execute_lex(app* obj);
|
||||||
|
lbool execute_box(app* obj);
|
||||||
|
lbool execute_pareto(app* obj);
|
||||||
|
|
||||||
|
void push();
|
||||||
|
void pop(unsigned sz);
|
||||||
|
opt_solver& get_solver();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue