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

Support TIME_LIMIT in is_solved_and_feasible #3915

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

odow
Copy link
Member

@odow odow commented Jan 16, 2025

Originally added in #3668, doesn't look like we discussed TIME_LIMIT.

But this came up last year in a discussion I had with Simon Bowly, where I thought we did support TIME_LIMIT.

And then @ccoffrin just asked me about it as well.

I tend to think that most people who set a time limit and get given a feasible solution would say that is_solved_and_feasible is true.

If we decide to add, there's an open question whether we should fold this into allow_local, or whether we add a new allow_time_limit kwarg.

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.58%. Comparing base (99cdc4c) to head (64997bb).

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

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

@joaquimg
Copy link
Member

I do not like this.

Why TIME_LIMIT is more important than ITERATION_LIMIT, NODE_LIMIT or even OBJECTIVE_LIMIT?

I think users needing more details should use the statuses directly.

I we end up adding it, I would certainly I prefer allow_time_limit with a default false.

@ccoffrin
Copy link
Contributor

Don't change the semantics on my account. As long as the documentation is clear, I think this semantics is clean.

Reflecting on my confusion. I think the root of the issue here is solved is a bit of ambiguous term, so I jumped to a conclusion about what it meant without reading the docs. Given that this needs to support both optimal and converged status types I agree solved is a reasonable umbrella term.

In the use-case I encountered, what I needed is an is_feasible or has_solution function, which just checks for primal feasibility. Do we already have a shorthand for that type of test?

@odow
Copy link
Member Author

odow commented Jan 16, 2025

TIME_LIMIT seems like the one most commonly set by users who expect a solution. ITERATION_LIMIT can happen in interior point-type solvers and tends to indicate failure, not success. NODE_LIMIT and OBJECTIVE_LIMIT are up for debate.

In the use-case I encountered, what I needed is an is_feasible or has_solution function, which just checks for primal feasibility. Do we already have a shorthand for that type of test?

Just define:

has_values(model) = primal_status(model) == FEASIBLE_POINT

We have

JuMP.jl/src/variables.jl

Lines 1916 to 1951 in 99cdc4c

"""
has_values(model::GenericModel; result::Int = 1)
Return `true` if the solver has a primal solution in result index `result`
available to query, otherwise return `false`.
See also [`value`](@ref) and [`result_count`](@ref).
## Example
```jldoctest
julia> import HiGHS
julia> model = Model(HiGHS.Optimizer);
julia> set_silent(model)
julia> @variable(model, x);
julia> @constraint(model, c, x <= 1)
c : x ≤ 1
julia> @objective(model, Max, 2 * x + 1);
julia> has_values(model)
false
julia> optimize!(model)
julia> has_values(model)
true
```
"""
function has_values(model::GenericModel; result::Int = 1)
return primal_status(model; result = result) != MOI.NO_SOLUTION
end

but it's not quite the same thing.

@odow odow added the Status: Needs developer call This should be discussed on a monthly developer call label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs developer call This should be discussed on a monthly developer call
Development

Successfully merging this pull request may close these issues.

3 participants