Checking membership in a MathOptInterface Set

Hello folks,

I hope this is an easy question, but unfortunately some of the internals of MathOptInterface and JuMP are opaque. constraint_object(constraint::ConstraintRef) operation in JuMP returns a ScalarConstraint, which has .func and .set attributes. I know how to evaluate the .func, but I am still confused about how to confirm membership in the set (i.e. feasibility to the constraint). Here is a MWE.

using MathOptInterface
val = 18.
set = MathOptInterface.GreaterThan{Float64}(-2.)
# How do I confirm membership in the set, returning Bool, or distance from constraint boundary?

Thanks in advance!

I guess another way to put it is, how does one convert a ScalarConstraint to a JuMP expression that can be evaluated?

Not sure if this answers your questions, but there is a package MathOptSetDistances.jl that is able to check set membership for several sets in MOI, a functionality that is not provided by MOI itself, I believe.

1 Like

See here for the full saga: https://github.com/jump-dev/MathOptInterface.jl/pull/1023

1 Like

Wow, thanks @odow for the blow-by-blow. I see how difficult it is to define a notion of set distance and not step on anyones’ toes :stuck_out_tongue:

1 Like

Thanks @leethargo for the reference. Will check it out and get back here!