Content-Length: 297798 | pFad | http://github.com/jump-dev/CPLEX.jl/commit/636daf2e4fed8748f63e51b98f8af26bf469a680

FF Fix get RelativeGap when problem is not a mixed-integer problem (#421) · jump-dev/CPLEX.jl@636daf2 · GitHub
Skip to content

Commit 636daf2

Browse files
authored
Fix get RelativeGap when problem is not a mixed-integer problem (#421)
1 parent bec33fe commit 636daf2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/MOI/MOI_wrapper.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,6 +3206,9 @@ function MOI.get(model::Optimizer, attr::MOI.RelativeGap)
32063206
_throw_if_optimize_in_progress(model, attr)
32073207
p = Ref{Cdouble}()
32083208
ret = CPXgetmiprelgap(model.env, model.lp, p)
3209+
if ret == CPXERR_NOT_MIP
3210+
throw(MOI.GetAttributeNotAllowed(attr, "Not a mixed-integer problem."))
3211+
end
32093212
_check_ret(model, ret)
32103213
return p[]
32113214
end

test/MathOptInterface/MOI_wrapper.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ function test_PassNames()
216216
return
217217
end
218218

219+
function test_relative_gap_GetAttributeNotAllowed()
220+
model = CPLEX.Optimizer()
221+
x = MOI.add_variable(model)
222+
MOI.add_constraint(model, x, MOI.GreaterThan(1.0))
223+
MOI.optimize!(model)
224+
@test_throws MOI.GetAttributeNotAllowed MOI.get(model, MOI.RelativeGap())
225+
return
226+
end
227+
219228
end # module TestMOIwrapper
220229

221230
TestMOIwrapper.runtests()

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/jump-dev/CPLEX.jl/commit/636daf2e4fed8748f63e51b98f8af26bf469a680

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy