-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add various options to the scip solver #84
base: main
Are you sure you want to change the base?
Conversation
KnorpelSenf
commented
Jan 22, 2025
- setting the verbosity level
- setting the heuristics
- setting the time limit
- setting the memory limit
- setting int, longint, bool, str, and float options
- setting the verbosity level - setting the heuristics - setting the time limit - setting the memory limit - setting int, longint, bool, str, and float options
Co-authored-by: Mohammed Ghannam <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Could we:
- avoid panicking and return the error to the user instead?
- make a single generic set_option method? (with a trait implemented on the required types)
- add tests?
By the way, can I add you to the rust-or GitHub org? You have been doing a lot of great work in the space recently. |
Yep, I'll fix all that!
Absolutely, that would make things easier. Thanks! |
@lovasoa is that how you expected the trait to look? Also, I have no idea how to test this properly. There is no way to get the option, so we can't really test if the option was set without solving a model and asserting that it was solved a certain way. That seems excessively expensive. How to proceed? |
Also, setting the time limit partially moves the model … that is not a very ergonomic API. I am not really sure how to improve this. |
Yes, you should either take the SCIPProblem by value and return a SCIPProblem, or take it by mutable reference and return nothing (using std::mem::take or replace). Try to be consistent with option setting in other solvers. |
for the trait, it looks good this way 👍 for testing, yes, you should make a problem, set an option, solve, and check that the option was respected by checking the solution |
So we would do something like pub fn set_memory_limit(&mut self, memory_limit: usize) {
std::mem::take(self.as_inner_mut()).set_memory_limit(memory_limit);
} or maybe pub fn set_memory_limit(mut self, memory_limit: usize) -> Self {
std::mem::take(self.as_inner_mut()).set_memory_limit(memory_limit);
self
} etc? The only other place I found that has this is the let solution = vars.maximise(10 * (a - b / 5) - b)
.using(default_solver) // multiple solvers available
.with(constraint!(a + 2 <= b))
.with(constraint!(1 + a >= 4 - b))
.set_parameter("name", "value")
.solve()?; Unfortunately, this isn't possible and now I have to do let mut model = vars.maximise(10 * (a - b / 5) - b)
.using(default_solver) // multiple solvers available
.with(constraint!(a + 2 <= b))
.with(constraint!(1 + a >= 4 - b));
model.set_parameter("name", "value");
let solution = model.solve()?; which looks odd to me. Should I still go ahead with the the former suggestion for the sake of consistency? |
Nice! It inspired scipopt/russcip#196 btw
That will take a very long time, add a lot of complexity, and slow down the tests, too. I would have to
This honestly sounds overkill when factoring in the low complexity of my changes. We would effectively be performing the exact same tests as russcip already runs, so we just test the underlying crate. Instead, shouldn't we just read back the parameters in the tests and make sure that they were set correctly? Reading model parameters is available in latest [email protected] which we could update to. |
Okay! let's go with option 2: read the parameters back. |
Thanks, I'll perform these changes soon! Do you have an opinion on which API to use in #84 (comment)? |
no opinion :) |