From 8ce6f5658d649c72a9d5b3c391f7a50ab8041b08 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 31 Jan 2024 14:59:41 +1300 Subject: [PATCH] Fix MOI wrapper if solve_mcp fails (#101) --- src/MOI_wrapper.jl | 6 ++++++ test/MOI_wrapper.jl | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 899d011..cc53c3a 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -387,6 +387,12 @@ function MOI.optimize!(model::Optimizer) jacobian_data_contiguous = true, [k => v for (k, v) in model.ext[:kwargs]]..., ) + if x === nothing + x = fill(NaN, length(initial)) + end + if info === nothing + info = Information() + end model.ext[:solution] = Solution(status, x, info) return end diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index 4c2e008..888d776 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -457,6 +457,13 @@ function test_user_defined_function() return end +function test_empty_model() + model = PATHSolver.Optimizer() + MOI.optimize!(model) + @test MOI.get(model, MOI.TerminationStatus()) == MOI.LOCALLY_SOLVED + return +end + end TestMOIWrapper.runtests()