mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 00:55:31 +00:00
fix issues #581: nested timeouts canceled each-other
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
a020b13f10
commit
e29adbf304
12 changed files with 96 additions and 87 deletions
|
@ -968,32 +968,34 @@ namespace qe {
|
|||
|
||||
|
||||
opt::inf_eps maximize(expr_ref_vector const& fmls, model& mdl, app* t, expr_ref& bound) {
|
||||
SASSERT(a.is_real(t));
|
||||
opt::model_based_opt mbo;
|
||||
opt::inf_eps value;
|
||||
obj_map<expr, rational> ts;
|
||||
obj_map<expr, unsigned> tids;
|
||||
|
||||
// extract objective function.
|
||||
vars coeffs;
|
||||
rational c(0), mul(1);
|
||||
linearize(mdl, mul, t, c, ts);
|
||||
extract_coefficients(ts, tids, coeffs);
|
||||
mbo.set_objective(coeffs, c);
|
||||
|
||||
// extract linear constraints
|
||||
for (unsigned i = 0; i < fmls.size(); ++i) {
|
||||
linearize(mdl, mbo, fmls[i], tids);
|
||||
}
|
||||
|
||||
|
||||
// find optimal value
|
||||
value = mbo.maximize();
|
||||
|
||||
|
||||
|
||||
expr_ref val(a.mk_numeral(value.get_rational(), false), m);
|
||||
if (!value.is_finite()) {
|
||||
bound = m.mk_false();
|
||||
return value;
|
||||
}
|
||||
|
||||
// update model
|
||||
// update model to use new values that satisfy optimality
|
||||
ptr_vector<expr> vars;
|
||||
obj_map<expr, unsigned>::iterator it = tids.begin(), end = tids.end();
|
||||
for (; it != end; ++it) {
|
||||
|
@ -1009,6 +1011,7 @@ namespace qe {
|
|||
}
|
||||
}
|
||||
|
||||
// update the predicate 'bound' which forces larger values.
|
||||
if (value.get_infinitesimal().is_neg()) {
|
||||
bound = a.mk_le(val, t);
|
||||
}
|
||||
|
|
|
@ -1285,7 +1285,7 @@ namespace qe {
|
|||
opt::inf_eps m_value;
|
||||
bool m_was_sat;
|
||||
|
||||
lbool maximize(expr_ref_vector const& fmls, app* t, opt::inf_eps& value) {
|
||||
lbool maximize(expr_ref_vector const& fmls, app* t, model_ref& mdl, opt::inf_eps& value) {
|
||||
expr_ref_vector defs(m);
|
||||
expr_ref fml = negate_core(fmls);
|
||||
hoist(fml);
|
||||
|
@ -1299,6 +1299,7 @@ namespace qe {
|
|||
m_ex.assert_expr(fml);
|
||||
m_fa.assert_expr(m.mk_not(fml));
|
||||
lbool is_sat = check_sat();
|
||||
mdl = m_model.get();
|
||||
switch (is_sat) {
|
||||
case l_false:
|
||||
if (!m_was_sat) {
|
||||
|
@ -1329,10 +1330,10 @@ namespace qe {
|
|||
|
||||
};
|
||||
|
||||
lbool maximize(expr_ref_vector const& fmls, app* t, opt::inf_eps& value, params_ref const& p) {
|
||||
lbool maximize(expr_ref_vector const& fmls, app* t, opt::inf_eps& value, model_ref& mdl, params_ref const& p) {
|
||||
ast_manager& m = fmls.get_manager();
|
||||
qsat qs(m, p, qsat_maximize);
|
||||
return qs.maximize(fmls, t, value);
|
||||
return qs.maximize(fmls, t, mdl, value);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace qe {
|
|||
void collect_statistics(statistics& st) const;
|
||||
};
|
||||
|
||||
lbool maximize(expr_ref_vector const& fmls, app* t, opt::inf_eps& value, params_ref const& p);
|
||||
lbool maximize(expr_ref_vector const& fmls, app* t, opt::inf_eps& value, model_ref& mdl, params_ref const& p);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue