Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported features should error, not warn #150

Closed
odow opened this issue Jun 4, 2023 · 10 comments · Fixed by #181
Closed

Unsupported features should error, not warn #150

odow opened this issue Jun 4, 2023 · 10 comments · Fixed by #181

Comments

@odow
Copy link
Contributor

odow commented Jun 4, 2023

@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?

for (F, S) in contypes
F == VI && continue
F <: AF || @warn("Function $F is not supported.")
S <: LS || @warn("Set $S is not supported.")

@ccoffrin
Copy link

ccoffrin commented Jun 4, 2023

I'll add to this a request for support of ScalarQuadraticFunction, which is maybe what #50 is about?

@amontoison
Copy link
Member

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

@amontoison
Copy link
Member

amontoison commented Jun 20, 2024

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
Copy link
Contributor Author

odow commented Jun 20, 2024

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
Copy link
Member

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
Copy link
Contributor Author

odow commented Jun 20, 2024

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
Copy link
Member

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
Copy link
Contributor Author

odow commented Jun 20, 2024

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
Copy link
Member

amontoison commented Jun 20, 2024

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
Copy link
Contributor Author

odow commented Jun 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants