Skip to content

Commit

Permalink
馃摑 Fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jan 11, 2019
1 parent 78f6960 commit e5aa164
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ DocTestSetup = quote
@objective(model, Max, -2x);
JuMP.optimize!(model);
mock = JuMP.backend(model).optimizer.model;
MOI.set(mock, MOI.TerminationStatus(), MOI.OPTIMAL)
MOI.set(mock, MOI.DualStatus(), MOI.FEASIBLE_POINT)
MOI.set(mock, MOI.ConstraintDual(), JuMP.optimizer_index(con), -2.0)
end
Expand Down
5 changes: 4 additions & 1 deletion src/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,10 @@ end
Return the value of the attribute `attr` from model's MOI backend.
"""
function MOI.get(model::Model, attr::MOI.AbstractModelAttribute)
if MOI.is_set_by_optimize(attr)
if MOI.is_set_by_optimize(attr) &&
!(attr isa MOI.TerminationStatus) && # Before `optimize!` is called, the
!(attr isa MOI.PrimalStatus) && # statuses are `OPTIMIZE_NOT_CALLED`
!(attr isa MOI.DualStatus) # and `NO_SOLUTION`
moi_get_result(backend(model), attr)
else
MOI.get(backend(model), attr)
Expand Down

0 comments on commit e5aa164

Please sign in to comment.