rust-or / good_lp

Linear Programming for Rust, with a user-friendly API. This crate allows modeling LP problems, and lets you solve them with various solvers.
https://crates.io/crates/good_lp
MIT License
216 stars 35 forks source link

add support for SCIP cardinality constraints #39

Closed yonch closed 9 months ago

yonch commented 10 months ago

This adds the ability of users to add cardinality constraints when using a SCIP optimizer.

This will also require a Cargo.toml change to a dependency version of russcip with the cardinality support, which is tracked by https://github.com/scipopt/russcip/pull/106 -- so this is not yet ready to merge.

(cardinality constraints allow a user to limit the number of non-zero variables from a given set in the solution to be <= N.)

lovasoa commented 10 months ago

Hello and thanks for the PR! We do already give miracle access to the scip model object, so we shouldn't have anything to do here to support new scip features. But what would be interesting in good_lp would be to implement this as a trait, with implementations on multiple optimizers.

yonch commented 9 months ago

Hi @lovasoa , thanks for the comment. The trait idea seems a good trade-off, and I pushed an update to the PR. If accepted I think this helps users create constraints using good_lp Variables without understanding the underlying interface of solvers with good_lp.

Also rebased to current main.

On the other hand, if this is not aligned with good_lp architecture feel free to close this PR.

lovasoa commented 9 months ago

You can fix the tests (looks like you forgot to run cargo fmt) and I'll merge.

yonch commented 9 months ago

oops, sorry for that (cargo fmt). thanks for catching & fixing!