Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Apr 2, 2024
1 parent d77d6a0 commit ea1871c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/MOI/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ function MOI.set(
::MOI.ObjectiveFunction{F},
f::F,
) where {F<:MOI.ScalarQuadraticFunction{Float64}}
# setting linear part also clears the existing quadratic and nonlinear terms
# setting linear part also clears the existing quadratic terms
MOI.set(
model,
MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(),
Expand Down Expand Up @@ -3428,7 +3428,13 @@ end
function MOI.get(model::Optimizer, attr::MOI.ObjectiveValue)
_throw_if_optimize_in_progress(model, attr)
MOI.check_result_index_bounds(model, attr)
attr = is_mip(model) ? Lib.XPRS_MIPOBJVAL : Lib.XPRS_LPOBJVAL
attr = if model.has_nlp_constraints
Lib.XPRS_NLPOBJVAL
elseif is_mip(model)
Lib.XPRS_MIPOBJVAL
else
Lib.XPRS_LPOBJVAL
end
return @_invoke Lib.XPRSgetdblattrib(model.inner, attr, _)::Float64
end

Expand Down
1 change: 1 addition & 0 deletions test/test_MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,7 @@ function test_nlp_constraint_log()
t_val = MOI.get(model, MOI.VariablePrimal(), t)
@test (x_val, 2.0; atol = 1e-6)
@test (t_val, log(x_val); atol = 1e-6)
@test (MOI.get(model, MOI.ObjectiveValue()), t_val; atol = 1e-6)
return
end

Expand Down

0 comments on commit ea1871c

Please sign in to comment.