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

How can I set model/solver options, especially for HiGHS ? #18

Closed lucidfrontier45 closed 1 year ago

lucidfrontier45 commented 1 year ago

I tried to set time limit option but I found there is no way to call highs::Model::set_option .

With good_lp API the only chance I can get an instance of highs::Model is to call good_lp::solvers::highs::HighsProblem::into_inner as solve does internally.

https://github.com/rust-or/good_lp/blob/65b4018726ca966fb97ec781eac7178e8f9b8f44/src/solvers/highs.rs#L65

Then I can have several set_option calls and at the end solve method call. Even though I still cannot have HighsSolution instance as solution: highs::Solution field is private and HighsSolution does not have any explicit constructor like new method.

https://github.com/rust-or/good_lp/blob/65b4018726ca966fb97ec781eac7178e8f9b8f44/src/solvers/highs.rs#L126

Can you give me any suggestion to simultaneously use good_lp API as well as set Highs options?

Thank you.

lovasoa commented 1 year ago

Good_lp offers the into_inner escape hatch if you need to work with a raw Highs instance. But if you use it, you are then on your own, and have to use highs directly to get your solution. I don't think it would be a good thing for good_lp to let you do anything you want with the model, and then take it back as if nothing happened. The model you give back could have nothing to do with the one good_lp initially handed out to you ! However, if there are options that are safe to use within good_lp, please open a pull request to add support for them directly in good_lp !