3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 11:25:51 +00:00

switch models for multiple box objectives. Feature request at codeplex issue 194, George Karpenov. Usage model is same as Pareto fronts you call check-sat multiple times until retrieving unsat

Signed-off-by: Nikolaj Bjorner <nbjorner@hotmail.com>
This commit is contained in:
Nikolaj Bjorner 2015-04-01 16:21:56 -07:00
parent 52619b9dbb
commit f8d04118d8
6 changed files with 40 additions and 5 deletions

View file

@ -118,6 +118,7 @@ namespace opt {
m_bv(m),
m_hard_constraints(m),
m_solver(0),
m_box_index(UINT_MAX),
m_optsmt(m),
m_scoped_state(m),
m_fm(m),
@ -199,6 +200,9 @@ namespace opt {
if (m_pareto) {
return execute_pareto();
}
if (m_box_index != UINT_MAX) {
return execute_box();
}
init_solver();
import_scoped_state();
normalize();
@ -313,13 +317,31 @@ namespace opt {
}
lbool context::execute_box() {
if (m_box_index < m_objectives.size()) {
m_model = m_box_models[m_box_index];
++m_box_index;
return l_true;
}
if (m_box_index != UINT_MAX && m_box_index >= m_objectives.size()) {
m_box_index = UINT_MAX;
return l_false;
}
m_box_index = 1;
lbool r = m_optsmt.box();
for (unsigned i = 0; r == l_true && i < m_objectives.size(); ++i) {
for (unsigned i = 0, j = 0; r == l_true && i < m_objectives.size(); ++i) {
objective const& obj = m_objectives[i];
if (obj.m_type == O_MAXSMT) {
solver::scoped_push _sp(get_solver());
r = execute(obj, false, false);
if (r == l_true) m_box_models.push_back(m_model.get());
}
else {
m_box_models.push_back(m_optsmt.get_model(j));
++j;
}
}
if (r == l_true && m_objectives.size() > 0) {
m_model = m_box_models[0];
}
return r;
}