scipopt / russcip

Rust interface for SCIP
https://crates.io/crates/russcip
Apache License 2.0
41 stars 11 forks source link

Is it possible to include SCIP disjunctive constraints? Thanks #161

Open brucelit opened 1 month ago

brucelit commented 1 month ago

Hi Mr. Ghannam,

Thank you for this wonderful crate. I wonder whether you plan to support the disjunctive constraints of SCIP (https://scipopt.org/doc/html/cons__disjunction_8h.php) soon?

My LP problem requires satisfying at least one of the constraints, and I hope to implement a solution in Rust. For now, SCIP seems to be the only available choice.

A disjunction constraint 𝐢 is a constraint of the form

𝐢=𝐢1βˆ¨β‹―βˆ¨πΆπ‘›

where all the 𝐢𝑖 are individual constraints themselves.

Best regards,

Bruce

mmghannam commented 1 month ago

Hi Bruce, Happy to hear you found the crate useful! I'm not sure I would be able to work on this soon. But if you need it, it should not be too much work to include it, you can already call the direct C bindings using the ffi module and the raw feature. If you decide to contribute an add_cons_disjunction method you should take a look at the other add_cons_* methods for inspiration :)

brucelit commented 1 month ago

Hi Mr. Ghannam,

thank you for your reply and hints. I will try to solve it myself and hopefully contribute to this repo.

mmghannam commented 1 month ago

Hi again :) First of all, please not so formal. Just Mo works πŸ˜„

Thinking about this again I realized it's not as simple as I first thought. One would need first to create methods that create a constraint but not add it to the model. Then use these constraints to add them to a disjunction constraint.

brucelit commented 1 month ago

Hi Mo,

you are right. Actually, I found a way to bypass using disjunctive constraints by introducing additional decision variables and then using Big-M method.

Best regards,

Bruce

mmghannam commented 1 month ago

You could also achieve the same I think with binary variables and indicator constraints (to skip figuring out what the right M is πŸ˜„). Take a look at add_cons_indicator

matbesancon commented 1 month ago

Hi @brucelit, as an alternative approach if finding a tight big-M value is hard for your problem, indicators have received more attention and smart tricks than disjunctions, even though they are more or less equivalent: https://scipopt.org/doc/html/cons__indicator_8h.php You just need an additional binary variable mentioning whether a constraint should be active

brucelit commented 2 weeks ago

Dear Mo and Mathieu,

thank you very much for the indicator idea. I am not an expert in linear programming, so your suggestion on this helped me greatly!