good_lp icon indicating copy to clipboard operation
good_lp copied to clipboard

add interface to set HiGHS option

Open lucidfrontier45 opened this issue 3 years ago • 4 comments

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?

lucidfrontier45 avatar Sep 14 '22 00:09 lucidfrontier45

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

lovasoa avatar Sep 14 '22 06:09 lovasoa

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.

lucidfrontier45 avatar Sep 14 '22 07:09 lucidfrontier45

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.

lovasoa avatar Sep 14 '22 07:09 lovasoa

@lovasoa

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

  • presolve
  • solver
  • parallel
  • time_limit
  • threads

lucidfrontier45 avatar Sep 14 '22 13:09 lucidfrontier45

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

lucidfrontier45 avatar Jan 17 '23 04:01 lucidfrontier45