417
417
function MOI. optimize! (model:: Optimizer )
418
418
model. diff = nothing
419
419
MOI. optimize! (model. optimizer)
420
-
421
- # do not fail. interferes with MOI.Tests.linear12test
422
- if ! in (MOI. get (model. optimizer, MOI. TerminationStatus ()), (MOI. LOCALLY_SOLVED, MOI. OPTIMAL))
423
- @warn " problem status: $(MOI. get (model. optimizer, MOI. TerminationStatus ())) "
424
- return
425
- end
426
-
427
420
return
428
421
end
429
422
@@ -486,6 +479,10 @@ The output problem data differentials can be queried with the
486
479
attributes [`BackwardOutObjective`](@ref) and [`BackwardOutConstraint`](@ref).
487
480
"""
488
481
function backward (model:: Optimizer )
482
+ st = MOI. get (model. optimizer, MOI. TerminationStatus ())
483
+ if ! in (st, (MOI. LOCALLY_SOLVED, MOI. OPTIMAL))
484
+ error (" Trying to compute the forward differentiation on a model with termination status $(st) " )
485
+ end
489
486
diff = _diff (model)
490
487
for (vi, value) in model. input_cache. dx
491
488
MOI. set (diff, BackwardInVariablePrimal (), model. index_map[vi], value)
@@ -510,6 +507,10 @@ The output solution differentials can be queried with the attribute
510
507
[`ForwardOutVariablePrimal`](@ref).
511
508
"""
512
509
function forward (model:: Optimizer )
510
+ st = MOI. get (model. optimizer, MOI. TerminationStatus ())
511
+ if ! in (st, (MOI. LOCALLY_SOLVED, MOI. OPTIMAL))
512
+ error (" Trying to compute the forward differentiation on a model with termination status $(st) " )
513
+ end
513
514
diff = _diff (model)
514
515
if model. input_cache. objective != = nothing
515
516
MOI. set (diff, ForwardInObjective (), MOI. Utilities. map_indices (model. index_map, model. input_cache. objective))
0 commit comments