diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 4ee2f02c..9620a2ef 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -163,6 +163,7 @@ function allow_modification(o::Optimizer) if SCIPgetStage(o) != SCIP_STAGE_PROBLEM @SCIP_CALL SCIPfreeTransform(o) end + o.scip_solve_status = _kSCIP_SOLVE_STATUS_NOT_CALLED return nothing end diff --git a/src/MOI_wrapper/results.jl b/src/MOI_wrapper/results.jl index a6434d7c..ecc5dcbf 100644 --- a/src/MOI_wrapper/results.jl +++ b/src/MOI_wrapper/results.jl @@ -5,8 +5,8 @@ # results -term_status_map = Dict( - SCIP_STATUS_UNKNOWN => MOI.OPTIMIZE_NOT_CALLED, +const _TERMINATION_STATUS_MAP = Dict( + SCIP_STATUS_UNKNOWN => MOI.OTHER_ERROR, SCIP_STATUS_USERINTERRUPT => MOI.INTERRUPTED, SCIP_STATUS_NODELIMIT => MOI.NODE_LIMIT, SCIP_STATUS_TOTALNODELIMIT => MOI.NODE_LIMIT, @@ -25,7 +25,10 @@ term_status_map = Dict( ) function MOI.get(o::Optimizer, ::MOI.TerminationStatus) - return term_status_map[SCIPgetStatus(o)] + if o.scip_solve_status == _kSCIP_SOLVE_STATUS_NOT_CALLED + return MOI.OPTIMIZE_NOT_CALLED + end + return _TERMINATION_STATUS_MAP[SCIPgetStatus(o)] end function MOI.get(o::Optimizer, attr::MOI.PrimalStatus) diff --git a/test/cutcallback.jl b/test/cutcallback.jl index 2982d4cd..7f6576af 100644 --- a/test/cutcallback.jl +++ b/test/cutcallback.jl @@ -60,7 +60,7 @@ import MathOptInterface as MOI MOI.set(optimizer, MOI.UserCutCallback(), cutcallback) # solve the problem - SCIP.@SCIP_CALL SCIP.SCIPsolve(inner.scip[]) + MOI.optimize!(optimizer) # The cut callback was called and obtaining the LP-solution worked. @test calls >= 1 diff --git a/test/sepa.jl b/test/sepa.jl index 830dc6e1..322d6f6a 100644 --- a/test/sepa.jl +++ b/test/sepa.jl @@ -43,13 +43,10 @@ import MathOptInterface as MOI SCIP.include_sepa(inner.scip[], inner.sepas, sepa) # solve the problem - SCIP.@SCIP_CALL SCIP.SCIPsolve(inner.scip[]) + MOI.optimize!(optimizer) # the separator is called @test sepa.called >= 1 - - # free the problem - finalize(inner) end # Test, whether adding cuts in `exec_lp` via `add_cut_sepa` works [1/2]. @@ -94,7 +91,7 @@ end SCIP.include_sepa(inner.scip[], inner.sepas, sepa) # solve the problem - SCIP.@SCIP_CALL SCIP.SCIPsolve(inner.scip[]) + MOI.optimize!(optimizer) # SCIP found the single remaining optimal solution @test MOI.get(optimizer, MOI.TerminationStatus()) == MOI.OPTIMAL @@ -105,9 +102,6 @@ end rtol @test MOI.get(optimizer, MOI.VariablePrimal(), y) ≈ 1.0 atol = atol rtol = rtol - - # free the problem - finalize(inner) end # Test, whether adding cuts in `exec_lp` via `add_cut_sepa` works [2/2]. @@ -152,7 +146,7 @@ end SCIP.include_sepa(inner.scip[], inner.sepas, sepa) # solve the problem - SCIP.@SCIP_CALL SCIP.SCIPsolve(inner.scip[]) + MOI.optimize!(optimizer) # SCIP found the single remaining optimal solution @test MOI.get(optimizer, MOI.TerminationStatus()) == MOI.OPTIMAL @@ -163,9 +157,6 @@ end rtol @test MOI.get(optimizer, MOI.VariablePrimal(), y) ≈ 0.0 atol = atol rtol = rtol - - # free the problem - finalize(inner) end # Test, whether we can cut the optimal solution. @@ -210,7 +201,7 @@ end SCIP.include_sepa(inner.scip[], inner.sepas, sepa) # solve the problem - SCIP.@SCIP_CALL SCIP.SCIPsolve(inner.scip[]) + MOI.optimize!(optimizer) # SCIP found the non-optimal solution, that remains after the cut. @test MOI.get(optimizer, MOI.TerminationStatus()) == MOI.OPTIMAL @@ -221,7 +212,4 @@ end rtol @test MOI.get(optimizer, MOI.VariablePrimal(), y) ≈ 0.0 atol = atol rtol = rtol - - # free the problem - finalize(inner) end