NLPModelsJuMP.jl icon indicating copy to clipboard operation
NLPModelsJuMP.jl copied to clipboard

Unsupported features should error, not warn

Open odow opened this issue 2 years ago • 2 comments
trafficstars

@ccoffrin was running a few examples and getting incorrect results because quadratic constraints are not supported (#50).

Shouldn't this be an error instead of a warning?

https://github.com/JuliaSmoothOptimizers/NLPModelsJuMP.jl/blob/12d8f2315328f1b8c8af0a6a4552b6ad71327674/src/utils.jl#L216-L219

odow avatar Jun 04 '23 00:06 odow

I'll add to this a request for support of ScalarQuadraticFunction, which is maybe what https://github.com/JuliaSmoothOptimizers/NLPModelsJuMP.jl/issues/50 is about?

ccoffrin avatar Jun 04 '23 00:06 ccoffrin

Hi @odow and @ccoffrin, I started to support quadratic constraints with #102. I can find time to finalize it next week.

amontoison avatar Jun 04 '23 12:06 amontoison

Sorry for the delay @ccoffrin and @odow. I finally added the support of quadratic constraints in #181. We will return an error if we encounter an unsupported feature now.

Do you know where I can find an example of a JuMP model with a VectorQuadraticFunction ?

amontoison avatar Jun 20 '24 20:06 amontoison

A MOI.VectorQuadraticFunction is a vector of quadratic terms:

model = Model()
@variable(model, x[1:2])
@constraint(model, [x[1], x[1]^2 + x[1] * x[2] + 3.0] >= 0)

odow avatar Jun 20 '24 21:06 odow

Thanks Oscar, it will help to verify that my parser of MOI.VectorQuadraticFunction is working: https://github.com/amontoison/NLPModelsJuMP.jl/blob/quadcon/src/utils.jl#L284-L345

amontoison avatar Jun 20 '24 21:06 amontoison

I didn't look at the details, but my only comment is that you might need a 2.0 or a 0.5 factor in there https://github.com/amontoison/NLPModelsJuMP.jl/blob/0b227b47a2ad9c99b4c7c4f9efa569f421295532/src/utils.jl#L322 I don't know if your COO assumes symmetry, etc.

odow avatar Jun 20 '24 21:06 odow

We assume symmetry in this case, and add the 0.5 when we evaluate the constraints: https://github.com/amontoison/NLPModelsJuMP.jl/blob/0b227b47a2ad9c99b4c7c4f9efa569f421295532/src/moi_nlp_model.jl#L114

amontoison avatar Jun 20 '24 22:06 amontoison

Cool cool. I think the definition of ScalarQuadraticFunction was a mistake. We should have just made it a list of terms. It's so easy to get confused with the different conventions.

odow avatar Jun 20 '24 22:06 odow

When we define a constraint with VectorQuadraticFunction, what are the accepted sets? Is it MOI.NonPosivitive / MOI.NonNegative or MOI.Zeros, the sets allowed for VectorAffineFunction? https://github.com/JuliaSmoothOptimizers/NLPModelsJuMP.jl/blob/main/test/nlp_problems/lincon.jl#L8

amontoison avatar Jun 20 '24 22:06 amontoison

what are the accepted sets

Any subtype of MOI.AbstractVectorSet. But yes, Nonnegative is f(x) >= 0, Nonpositive is f(x) <= 0, and Zeros is f(x) = 0.

odow avatar Jun 20 '24 22:06 odow