Skip to content

Commit cf20541

Browse files
authored
Fix getting default objective function (#510)
1 parent 480933b commit cf20541

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ext/IpoptMathOptInterfaceExt/MOI_wrapper.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ function MOI.get(
988988
MOI.ScalarQuadraticFunction{Float64},
989989
},
990990
}
991-
return MOI.get(model.qp_data, attr)
991+
return convert(F, MOI.get(model.qp_data, attr))
992992
end
993993

994994
function MOI.set(

test/MOI_wrapper.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,15 @@ function test__VectorNonlinearOracle()
12401240
return
12411241
end
12421242

1243+
function test_default_objective_function()
1244+
model = Ipopt.Optimizer()
1245+
F = MOI.get(model, MOI.ObjectiveFunctionType())
1246+
@test F == MOI.ScalarAffineFunction{Float64}
1247+
f = MOI.get(model, MOI.ObjectiveFunction{F}())
1248+
@test f zero(F)
1249+
return
1250+
end
1251+
12431252
end # module TestMOIWrapper
12441253

12451254
TestMOIWrapper.runtests()

0 commit comments

Comments
 (0)