Skip to content

Commit

Permalink
Add doc string for has_values (#1624)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 15, 2018
1 parent 98e6494 commit ef17037
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,16 @@ Use `has_values` to check if a result exists before asking for values.
Replaces `getvalue` for most use cases.
"""
value(v::VariableRef) = MOI.get(owner_model(v), MOI.VariablePrimal(), v)
function has_values(model::Model)
return MOI.get(model, MOI.PrimalStatus()) != MOI.NoSolution
end

"""
has_values(model::Model)
Return true if the solver has a primal solution available to query, otherwise
return false.
See also [`value`](@ref).
"""
has_values(model::Model) = primal_status(model) != MOI.NoSolution

@Base.deprecate setvalue(v::VariableRef, val::Number) set_start_value(v, val)

Expand Down

0 comments on commit ef17037

Please sign in to comment.