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 interface to set HiGHS option #19

Closed lucidfrontier45 closed 1 year ago

lucidfrontier45 commented 1 year ago

I added an API to set HiGHS options to the HighsProblem struct. This solves #18 .

Currently the API is not safe enough, we can still add invalid key and value type. For example set_option("time_limit".to_string(), 10) will panic when solve method is called. Perhaps I should add explicit APIs like set_time_limit(value: f64). What do you think?

lovasoa commented 1 year ago

If you want to add support for time limits, we should store an explicit time_limit: Option<f64> and not a hashmap<String, Anything>

lucidfrontier45 commented 1 year ago

If you want to add support for time limits, we should store an explicit time_limit: Option<f64> and not a hashmap<String, Anything>

No, I don't want to just use time_limit. I also want to use other options like presolve, parallel etc. There are 45 options in total. Writing specific setter for each of them sounds too redundant. That's why I wrote a generic setter in the current PR.

lovasoa commented 1 year ago

I think you should have specific setters and tests for each of them. And even for each combination of them where it's relevant. It's the only way to guarantee we will not panic at runtime.

lucidfrontier45 commented 1 year ago

@lovasoa

I re-wrote the PR to implement explicit setters for a few HiGHS options.

lucidfrontier45 commented 1 year ago

@lovasoa How about this PR? Is there anything I have to do to merge it?