mirror of
https://github.com/Z3Prover/z3
synced 2025-06-13 09:26:15 +00:00
adding maxlex, throttle use of asymmetric literal addition
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
ad81fee118
commit
b4f4a1f316
1 changed files with 13 additions and 11 deletions
|
@ -55,6 +55,7 @@ namespace opt {
|
||||||
model_ref mdl;
|
model_ref mdl;
|
||||||
s().get_model(mdl);
|
s().get_model(mdl);
|
||||||
if (mdl) {
|
if (mdl) {
|
||||||
|
m_model = mdl;
|
||||||
m_c.model_updated(mdl.get());
|
m_c.model_updated(mdl.get());
|
||||||
update_assignment(mdl);
|
update_assignment(mdl);
|
||||||
}
|
}
|
||||||
|
@ -79,16 +80,16 @@ namespace opt {
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_assignment(model_ref & mdl) {
|
void update_assignment(model_ref & mdl) {
|
||||||
|
bool prefix_defined = true;
|
||||||
for (auto & soft : m_soft) {
|
for (auto & soft : m_soft) {
|
||||||
|
if (!prefix_defined) {
|
||||||
|
set_value(soft, l_undef);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch (soft.value) {
|
switch (soft.value) {
|
||||||
case l_undef:
|
case l_undef:
|
||||||
if (mdl->is_true(soft.s)) {
|
prefix_defined = mdl->is_true(soft.s);
|
||||||
set_value(soft, l_true);
|
set_value(soft, prefix_defined ? l_true : l_undef);
|
||||||
}
|
|
||||||
else {
|
|
||||||
update_bounds();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case l_true:
|
case l_true:
|
||||||
break;
|
break;
|
||||||
|
@ -130,17 +131,18 @@ namespace opt {
|
||||||
update_assignment(mdl);
|
update_assignment(mdl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
maxlex(maxsat_context& c, unsigned id, weights_t & ws, expr_ref_vector const& s):
|
maxlex(maxsat_context& c, unsigned id, weights_t & ws, expr_ref_vector const& s):
|
||||||
maxsmt_solver_base(c, ws, s),
|
maxsmt_solver_base(c, ws, s),
|
||||||
m(c.get_manager()),
|
m(c.get_manager()),
|
||||||
m_c(c) {
|
m_c(c) {
|
||||||
|
// ensure that soft constraints are sorted with largest soft constraints first.
|
||||||
cmp_soft cmp;
|
cmp_soft cmp;
|
||||||
std::sort(m_soft.begin(), m_soft.end(), cmp);
|
std::sort(m_soft.begin(), m_soft.end(), cmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lbool operator()() override {
|
lbool operator()() override {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
@ -167,6 +169,7 @@ namespace opt {
|
||||||
return l_true;
|
return l_true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void commit_assignment() override {
|
void commit_assignment() override {
|
||||||
for (auto & soft : m_soft) {
|
for (auto & soft : m_soft) {
|
||||||
if (soft.value == l_undef) {
|
if (soft.value == l_undef) {
|
||||||
|
@ -175,7 +178,6 @@ namespace opt {
|
||||||
assert_value(soft);
|
assert_value(soft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
maxsmt_solver_base* mk_maxlex(maxsat_context& c, unsigned id, weights_t & ws, expr_ref_vector const& soft) {
|
maxsmt_solver_base* mk_maxlex(maxsat_context& c, unsigned id, weights_t & ws, expr_ref_vector const& soft) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue