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

Eliminate identical constraints #156

Open
pvdz opened this issue Oct 20, 2016 · 0 comments
Open

Eliminate identical constraints #156

pvdz opened this issue Oct 20, 2016 · 0 comments

Comments

@pvdz
Copy link
Contributor

pvdz commented Oct 20, 2016

C = solver.isEq(A, B);
D = solver.isEq(A, B);

The constraint is identical because whatever the value of C or D (or A and B for that matter), the state will be propagated across them all eventually, regardless. And at the end of it C == D in any case.

We should be able to detect these constraints, add a hidden mapping from D to C. This way we can eliminate the second constraint AND the second anonymous variable D from the system.

Note that this same scrubbing should be done for any constraint, especially those with more than two vars or those where the constraint is commutative (a @bergie b == b @ a). In those cases sort the var index, if commutative, and drop the result vars to detect equivalent constraints. Use a string on an object (or Trie, if that turns out to be slow) to "color" them.

Another case to check is whether vars are already solved since any constraint that uses the same variables but different constants can also be considered the same. This case should not happen very frequent since it's most likely that they result in a reject. But for all intentions and purposes, any "solved" var as well as any constant should be considered "the same variable" in this context.

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

1 participant