-
Notifications
You must be signed in to change notification settings - Fork 98
Description
We have fallbacks for a few attributes such as ConstraintPrimal but currently, they are only used by MockOptimizer.
When you have a CachingOptimizer{Solver.Optimizer}, a common use case is to do
try
MOI.get(model, MOI.ConstraintPrimal(), ...)
catch
MOI.get_fallback(model, MOI.ConstraintPrimal(), ...)
endHowever, as mentioned in #1249, relying on try-catch for such normal behavior is not ideal. Moreover, we might catch other errors that shouldn't be ignored.
We decided against having a supports for getters and Solver.Optimizer cannot call get_fallback because it does not implement MOI.ConstraintFunction. Maybe we could have a function use_fallback and in the caching optimizer, we call use_fallback first and if it returns true then we call get_fallback instead of get.
Then if a solver does not natively support giving the ConstraintPrimal nor the ConstraintFunction, it can implement use_fallback(::Solver.Optimizer, ::MOI.ConstraintPrimal) = true. It would then be able to pass the MOI tests needed ConstraintPrimal.