JuliaSmoothOptimizers / NLPModelsJuMP.jl

Create NLPModels with JuMP
Other
34 stars 8 forks source link

Unsupported features should error, not warn #150

Closed odow closed 2 months ago

odow commented 1 year ago

@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

ccoffrin commented 1 year ago

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?

amontoison commented 1 year ago

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

amontoison commented 2 months ago

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 ?

odow commented 2 months ago

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)
amontoison commented 2 months ago

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

odow commented 2 months ago

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.

amontoison commented 2 months ago

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

odow commented 2 months ago

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.

amontoison commented 2 months ago

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

odow commented 2 months ago

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.