Skip to content

Commit

Permalink
fix(expl): fix bug in an optional optimization in MARCO (greedy corre…
Browse files Browse the repository at this point in the history
…ction sets)
  • Loading branch information
nrealus committed Jan 3, 2025
1 parent 41b18d9 commit c2137d8
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions explainability/src/musmcs_enumeration/marco/simple_marco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,40 +262,34 @@ impl<Lbl: Label> Marco<Lbl> for SimpleMarco<Lbl> {
self.map_solver.block_down(&mss);
mcses.push(mcs.unwrap());
} else {
// from Ignace Bleukx's implementation:
// find more MCSes, **disjoint** from this one, similar to "optimal_mus" in mus.py
// can only be done when MCSes do not have to be returned as there is no guarantee
// the MCSes encountered during enumeration are "new" MCSes
let mut sat_subset_lits: BTreeSet<Lit> = self.soft_constrs_reif_lits
.iter()
.filter(|&&l| self.subset_solver.s.model.entails(!l))
.cloned()
.collect();
self.map_solver
// Small optimization inspired by the implementation of Ignace Bleukx (in python).
// If we are not going to return MCSes, we can try to greedily search for
// more correction subsets, disjoint from this one (the seed).

let mut sat_subset = self.seed.clone();
self.map_solver.block_down(&sat_subset);

while self
.subset_solver
.s
.enforce(or(
sat_subset_lits
.iter()
.map(|&l| self.map_solver.lits_translate_in[&l])
.collect_vec()
), []);
while self.subset_solver.check_seed_sat(&sat_subset_lits) {
let s2: BTreeSet<Lit> = self
.solve_with_assumptions(sat_subset.iter().cloned())
.expect("Solver interrupted...")
.is_ok()
{
let new_sat_subset: BTreeSet<Lit> = self
.soft_constrs_reif_lits
.iter()
.filter(|&&l| self.subset_solver.s.model.entails(l))
.cloned()
.collect();
let new_mcs = self.soft_constrs_reif_lits.difference(&s2).cloned();
sat_subset_lits.extend(new_mcs.clone());
self.map_solver.s
.enforce(or(
new_mcs
.map(|l| self.map_solver.lits_translate_in[&l])
.collect_vec()
), []);
self.map_solver.block_down(&new_sat_subset);

let new_corr_subset = self.soft_constrs_reif_lits.difference(&new_sat_subset);
sat_subset.extend(new_corr_subset);

self.subset_solver.s.reset();
}
self.subset_solver.s.reset();
}
}

Expand Down

0 comments on commit c2137d8

Please sign in to comment.