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

Clarify error message in quad_to_soc bridge #1259

Closed
ASaragga opened this issue Mar 2, 2021 · 2 comments · Fixed by #1260
Closed

Clarify error message in quad_to_soc bridge #1259

ASaragga opened this issue Mar 2, 2021 · 2 comments · Fixed by #1260
Labels
Submodule: Bridges About the Bridges submodule

Comments

@ASaragga
Copy link

ASaragga commented Mar 2, 2021

Running the model

model = Model(COSMO.Optimizer)  # or model = Model(SCS.Optimizer)
@variable(model, w[1:6]>= 0)
@constraint(model, sum(w) == 1)
@constraint(model, w' * pcov * w == 0.038^2)
@objective(model, Max, pmean' * w)
optimize!(model)
optimal_solution = value.(w)

with:

pmean = [0.006719140992780818, 0.011577810667787833, 0.01344208119264699, 0.005535719592233162, 0.026922967360723037, 0.00934581295816873]

pcov = [0.018717403832096687 0.005706355121276367 0.006459876807928641 0.0012524618528797894 0.002563861720279623 0.0007671488407868487; 0.005706355121276367 0.006526570285541143 0.004384136499235087 0.0011480135148245983 0.0018044216713121253 0.001154428875412326; 0.006459876807928641 0.004384136499235087 0.0054284300755523115 0.0006596834879959167 0.0016581295100441041 0.0007133949662164625; 0.0012524618528797894 0.0011480135148245983 0.0006596834879959167 0.0026543564006455294 0.00048713871877351897 0.0011206346404939; 0.002563861720279623 0.0018044216713121253 0.0016581295100441041 0.00048713871877351897 0.0023567945429189227 0.00043958950944804554; 0.0007671488407868487 0.001154428875412326 0.0007133949662164625 0.0011206346404939 0.00043958950944804554 0.0020143379751173373]

one gets the following error,

ERROR: LoadError: The optimizer supports second-order cone constraints and not quadratic constraints but you entered a quadratic constraint of type: `MathOptInterface.ScalarQuadraticFunction{Float64}`-in-`MathOptInterface.GreaterThan{Float64}`. A bridge attempted to transform the quadratic constraint to a second order cone constraint but the constraint is not strongly convex, i.e., the symmetric matrix of quadratic coefficients is not positive definite. Convex constraints that are not strongly convex, i.e. the matrix is positive semidefinite but not positive definite, are not supported yet.

However the matrix pcov is positive definite (all eigen values > 0) and the constraint is therefore strongly convex.

@odow
Copy link
Member

odow commented Mar 2, 2021

A quadratic equality constraint is non-convex.

The error message is a bit confusing, because we probably tried two rewrite the equality constraint into two inequalities, and then bridge those.

You should formulate a second-order-cone constraint directly: https://jump.dev/JuMP.jl/stable/constraints/#Quadratic-constraints, https://en.wikipedia.org/wiki/Second-order_cone_programming

@odow
Copy link
Member

odow commented Mar 3, 2021

Note that this works:

model = Model(SCS.Optimizer)
@variable(model, w[1:6]>= 0)
@constraint(model, sum(w) == 1)
@constraint(model, w' * pcov * w <= 0.038^2)
@objective(model, Max, pmean' * w)
optimize!(model)
optimal_solution = value.(w)

I'll transfer this to MOI where the error message could be improved (to state that this could come from a different constraint).

@odow odow transferred this issue from jump-dev/JuMP.jl Mar 3, 2021
@odow odow added the Submodule: Bridges About the Bridges submodule label Mar 3, 2021
@odow odow changed the title JuMP appears to be unable to recognize that a matrix is positive definite Clarify error message in quad_to_soc bridge Mar 3, 2021
@odow odow closed this as completed in #1260 Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Submodule: Bridges About the Bridges submodule
Development

Successfully merging a pull request may close this issue.

2 participants