Skip to content

Commit a25e0d1

Browse files
committed
refactor(OptimizationMOI): use BarrierIterations only when available
unfortunatelly there's no API for determining this
1 parent 65eecbb commit a25e0d1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/OptimizationMOI/src/nlp.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,19 @@ function SciMLBase.__solve(cache::MOIOptimizationNLPCache)
559559
minimum = NaN
560560
opt_ret = SciMLBase.ReturnCode.Default
561561
end
562-
stats = Optimization.OptimizationStats(time = MOI.get(opt_setup, MOI.SolveTimeSec()),
563-
iterations = MOI.get(opt_setup, MOI.BarrierIterations()))
562+
563+
# check if the solver supports BarrierIterations
564+
iterations = try
565+
MOI.get(opt_setup, MOI.BarrierIterations())
566+
catch e
567+
if !(e isa MOI.GetAttributeNotAllowed)
568+
rethrow(e)
569+
end
570+
0
571+
end
572+
573+
stats = Optimization.OptimizationStats(; time = MOI.get(opt_setup, MOI.SolveTimeSec()),
574+
iterations)
564575
return SciMLBase.build_solution(cache,
565576
cache.opt,
566577
minimizer,

0 commit comments

Comments
 (0)