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

Add assert_is_solved_and_feasible #3925

Merged
merged 8 commits into from
Jan 28, 2025
Merged

Add assert_is_solved_and_feasible #3925

merged 8 commits into from
Jan 28, 2025

Conversation

odow
Copy link
Member

@odow odow commented Jan 25, 2025

Closes #3923

Bikeshedding: the alternative is is_solved_and_feasible(model; assert = true)

Copy link

codecov bot commented Jan 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.58%. Comparing base (6e4427a) to head (90757eb).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3925   +/-   ##
=======================================
  Coverage   99.58%   99.58%           
=======================================
  Files          43       43           
  Lines        6059     6063    +4     
=======================================
+ Hits         6034     6038    +4     
  Misses         25       25           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/optimizer_interface.jl Outdated Show resolved Hide resolved
src/optimizer_interface.jl Outdated Show resolved Hide resolved
@mlubin
Copy link
Member

mlubin commented Jan 25, 2025

I like it.

@odow odow force-pushed the od/assert-is-solved branch from d3671ae to 98f0a40 Compare January 26, 2025 21:04
@odow
Copy link
Member Author

odow commented Jan 27, 2025

It's too late now, but for JuMP 2.0, a better solution might be for this to be the default behavior of optimize!(model), and you have to explicitly pass something optimize!(model; skip_status_check = true) which is a sign that you will then explicitly check the problem statuses before querying the solution.

Right now we have the behavior that almost everyone should use

optimize!(model)
assert_is_solved_and_feasible(model)

and some people should do

optimize!(model)
if termination_status(model) == OPTIMAL
    # ...
else if termination_status(model) == TIME_LIMIT
    # ...
else
    # ...
end

@odow
Copy link
Member Author

odow commented Jan 28, 2025

Thoughts on new function instead of a keyword?

@blegat
Copy link
Member

blegat commented Jan 28, 2025

This is something to be used in quick scripts so keystrokes matter. assert_is_solved_and_feasible will be easier to type, auto-complete etc... It also makes sense as another function since the behavior is quite different, I don't see it just as finetuning of is_solved_and_feasible

@odow
Copy link
Member Author

odow commented Jan 28, 2025

Okay. This is good to go by me then.

@odow odow merged commit 3b98ac1 into master Jan 28, 2025
11 checks passed
@odow odow deleted the od/assert-is-solved branch January 28, 2025 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

assert_is_solved_and_feasible
4 participants