How to test a Solver functionality availability

In JuMP, depending on the solver, there are some functionalities that are available, and some which are not, see for instance here.

How should I test that before creating a Model(optimizer) ?

As an example:

if optimizer == Lazy Constraints Callbacks are available # How to test a Solver functionnality availability
### do some stuff like Model(Optimizer) and call Lazy Constraints Callbakcs
else
    @info "The optimiser you selected does not support Lazy Constraints Callbacks"
    return
end

Wishing you a happy weekend :smiley:

You can use the supports function.

In the context of lazy callbacks, it would look something like

if MOI.supports(model, MOI.LazyConstraintCallback())
    # do something
else
    error(…)
end
2 Likes

Thank you very much for your reply!

I believe try-catch will also work in some use cases:

    try
        set_attribute(m, MOI.LazyConstraintCallback(), call_back_ilp_lazy)
    catch
        error("Your solver doesn't support Lazy Constraints Callback")
    end

:smiley:

1 Like