Skip to content
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: time limits and solution statuses #89

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

KnorpelSenf
Copy link
Contributor

@KnorpelSenf KnorpelSenf commented Feb 27, 2025

It is currently possible to set time limits for individual solvers.

This pull request introduced a generic API to set this for all solvers that provide implementation for this. Currently, CBC, HiGHS, and SCIP are supported. HiGHS bindings depend on rust-or/highs#24, so this PR temporary switches to HiGHS from GitHub. As soon as rust-or/highs#24 is merged, this commit can be reverted.

These changes also include a way to read the solutions even when the solving process was halted early due to a time limit. A new status on the solution lets developers differentiate between optimal solution and solutions reached via time limit.

Also, it aligns how MIP gaps are handled with the newly introduced solution status.

@KnorpelSenf
Copy link
Contributor Author

@mmghannam you might be interested in this

@lovasoa
Copy link
Collaborator

lovasoa commented Feb 27, 2025

cool !

@KnorpelSenf
Copy link
Contributor Author

It might make sense to merge #90 before this so I can update and align these changes consistently. But it's not a big deal, if this is merged first I'll just do it in #90 instead.

@lovasoa
Copy link
Collaborator

lovasoa commented Feb 28, 2025

It might make sense to merge #90 before this

done !

@lovasoa
Copy link
Collaborator

lovasoa commented Feb 28, 2025

@KnorpelSenf , you have been pushing a lot of great PRs lately. Would you like to be granted commit access to this repo, in order to participate to its maintenance on the long run ?

@KnorpelSenf
Copy link
Contributor Author

@KnorpelSenf , you have been pushing a lot of great PRs lately. Would you like to be granted commit access to this repo, in order to participate to its maintenance on the long run ?

Sure thing, thank you!

@KnorpelSenf KnorpelSenf changed the title feat: time limits feat: time limits and solution statuses Feb 28, 2025
let sol = pb.solve().unwrap();
assert_float_eq!(sol.value(v), limit, abs <= 1e-8);
}

const VARIABLE_COUNT: usize = 75;
const CLAUSES: &[(i32, i32, i32)] = &[
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let me know if you have a better idea than this

@KnorpelSenf
Copy link
Contributor Author

@lovasoa please check out rust-or/highs#24. After it is released, I can revert 66662fb and then this is ready.

TimeLimit,
/// The solution is not optimal and it was obtained because the gap limit
/// was reached
GapLimit,
Copy link
Contributor Author

@KnorpelSenf KnorpelSenf Mar 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would ideally like to do

Suggested change
GapLimit,
GapLimit(f64),

to communicate the actual gap of the solution but I think the underlying bindings for CBC and SCIP don't expose this data yet.

I mostly think this would be better library design but I honestly don't ever need this myself … so I might just not do it?

@lovasoa lovasoa marked this pull request as draft March 1, 2025 21:07
@lovasoa
Copy link
Collaborator

lovasoa commented Mar 1, 2025

Marking this as draft to make sure this isn't merged until we release highs

@lovasoa
Copy link
Collaborator

lovasoa commented Mar 1, 2025

Feel free to undo when the dependencies point to stable highs

@KnorpelSenf
Copy link
Contributor Author

Marking this as draft to make sure this isn't merged until we release highs

Probably wise, I'll do that myself from now on

@lovasoa lovasoa mentioned this pull request Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants