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

Weightconstraints created with create_only_btb or create_only_bfb do not behave as expected. #55

Closed
rkaminsk opened this issue Feb 5, 2020 · 3 comments

Comments

@rkaminsk
Copy link
Member

rkaminsk commented Feb 5, 2020

We have a project where we need weight constraints to propagate only in one direction. Weight constraints created with create_only_btb or create_only_bfb do not behave as expected. When constraints are created with create_explicit the constraint behaves as expected if only one thread is used.

With explicit disabled the result is as if bfb or btb are not given

  • add_weight_constraint(a, [(b, 1), (c, 1)], 1, bfb)
    • model
    • model a c
    • model a b
    • model a b c
  • add_weight_constraint(a, [(b, 1), (c, 1)], 1, btb)
    • model
    • model a c
    • model a b
    • model a b c

With explicit enabled the result is as expected

  • add_weight_constraint(a, [(b, 1), (c, 1)], 1, explicit+bfb)
    • model
    • model a
    • model a c
    • model a b
    • model a b c
  • add_weight_constraint(a, [(b, 1), (c, 1)], 1, explicit+btb)
    • model
    • model c
    • model b
    • model b c
    • model a b
    • model a c
    • model a b c

With threads and explicit enabled it fails completely

  • add_weight_constraint(a, [(b, 1), (c, 1)], 1, explicit+bfb)
    • random results
  • add_weight_constraint(a, [(b, 1), (c, 1)], 1, explicit+btb)
    • random results

Current workaround

To achieve btb, I currently add an auxiliary literal (bfb can be achieved by inverting l in the weight constraint):

l = add_literal()
add_clause([-a,l])
add_weight_constraint(l, [(b, 1), (c, 1)], 1, 0)

Of course this adds an unnecessary literal...

BenKaufmann added a commit that referenced this issue Feb 9, 2020
* Weight constraints created with flag `create_only_btb` or
  `create_only_bfb` must not be transformed to a set of clauses.

* WeightConstraint::cloneAttach() failed to add watch for constraint
  if original was created with `create_only_btb` or `create_only_bfb`.

* Solver::hasWatch() failed to handle empty watch list correctly.
@BenKaufmann
Copy link
Contributor

@rkaminsk
I addressed two obvious problems in dev. Could you please check whether things now work for you as expected?

@rkaminsk
Copy link
Member Author

rkaminsk commented Feb 9, 2020

Yes, this seems to work. In your commit you wrote that you cannot transform to clauses if only one propagation direction is requested. Wouldn't it be enough to only add "half" of the clauses?

@BenKaufmann
Copy link
Contributor

I'm sure you are right and the commit is probably a little lazy. However, I'm not fully convinced that it's actually worth to complicate the code even further.

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