potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
599 stars 79 forks source link

Adding cardinality constraints through backend #420

Closed RenatoGeh closed 1 year ago

RenatoGeh commented 1 year ago

Hi,

I was wondering if it is possible to add cardinality constraints through a clingo_backend_t. I couldn't find any obvious answers in the docs.

In case there isn't, would the only way to add a cardinality constraint to a clingo_control_t be through clingo_control_add?

Thanks

rkaminsk commented 1 year ago

You can use clingo_backend_weight_rule to add cardinality constraints setting all weights to one. The solver will chose an efficient internal representation automatically. Note that only constraints with lower bounds are supported. Other bounds have to be handled via translation.

RenatoGeh commented 1 year ago

I see. Thanks!