Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching for BDDs Enabled Although Documented as Erroneous #45

Open
pmbittner opened this issue Dec 16, 2020 · 4 comments
Open

Caching for BDDs Enabled Although Documented as Erroneous #45

pmbittner opened this issue Dec 16, 2020 · 4 comments

Comments

@pmbittner
Copy link

Hi @ckaestne and TypeChef devs,

on the master branch, in the SATBDDSolver the CACHING is activated although there is a comment indicating that this may yield incorrect results:

/**
* caching can reuse SAT solver instances, but experience
* has shown that it can lead to incorrect results,
* hence caching is currently disabled
*/
val CACHING = true

So I wonder if caching shouldn't be deactivated here as stated by the comment?
Could I obtain wrong results when running TypeChef and having CACHING set to true here?

Thanks for any help!

@ckaestne
Copy link
Owner

Sorry, this has been too long. I vaguely remember that there were some issues, but I suspect that it has been fixed and the comment is outdated. I think this was a weird nondeterministic problem but unloading clauses from the solver in early attempts to use it.

@pmbittner
Copy link
Author

Ok, thank you very much for the fast reply! I will leave this set to true then.

Interestingly, the CACHING is deactivated for the SatSolver (for propositional formulas instead of BDDs) with the very same comment:

/**
* caching can reuse SAT solver instances, but experience
* has shown that it can lead to incorrect results,
* hence caching is currently disabled
*/
val CACHING = false

So maybe this should be activated then, too.

@ckaestne
Copy link
Owner

So this is way too long ago to trust anything that I say (and I don't even remember how much of it I wrote myself), but:

The implementation of how constraints are removed differ slightly:

for (constr <- constraintGroup.filter(_ != null)) {
try {
val succeeded = solver.removeConstr(constr)
if (!succeeded)
invalidateCache()
} catch {
case e: AssertionError => invalidateCache()
case e: NullPointerException => invalidateCache()
}
}

vs

for (constr <- constraintGroup)
assert(solver.removeConstr(constr))

which may very well be responsible for this differences. It could be that one is fixed for an issue in the other.

The key idea of caching is to add all clauses from the feature model only once and then add and remove the clauses from the individual expressions on every satisfiability check. At some point there were issues that removing clauses didn't work as intended. I don't remember whether and how it got fixed, but I assume it works as in the repo. It may work with caching in the Sat implementation or not or only after adding and removing clauses the same way.

Sorry to not be of more help and good luck!

@pmbittner
Copy link
Author

Interesting and sounds reasonable. This is already a big help, thank you! We will leave things as is then for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants