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

Quadratic constraint failure #127

Closed
jonhar97 opened this issue Jun 25, 2024 · 2 comments
Closed

Quadratic constraint failure #127

jonhar97 opened this issue Jun 25, 2024 · 2 comments

Comments

@jonhar97
Copy link

Hi,

I am using the following call to OSQP via JuMP in Julia:

  @variable(m1, x[1:n] >= 0)
  @objective(m1, Min, - dot(g,x));
  @constraint(m1, sum(m[i]*x[i] for i in 1:n) == 1.0); 
  @constraint(m1, x'*A*x <= inb) # quadratic constraint
  JuMP.optimize!(m1);
  c = JuMP.value.(x)

It seems as it cannot handle the quadratic constraint, or am I mistaken? I have tested a bunch of alternative solvers and all works in this setting. But it would be awesome to use OSQP.
Help is much appreciated!

Here is the error message:

ERROR: Constraints of type MathOptInterface.ScalarQuadraticFunction{Float64}-in-MathOptInterface.LessThan{Float64} are not supported by the solver.

If you expected the solver to support your problem, you may have an error in your formulation. Otherwise, consider using a different solver.

The list of available solvers, along with the problem types they support, is available at https://jump.dev/JuMP.jl/stable/installation/#Supported-solvers.
Stacktrace:

error(s::String) at [error.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

_moi_add_constraint(model::MathOptInterface.Utilities.CachingOptimizer{…}, f::MathOptInterface.ScalarQuadraticFunction{…}, s::MathOptInterface.LessThan{…}) at [constraints.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

add_constraint(model::Model, con::ScalarConstraint{QuadExpr, MathOptInterface.LessThan{Float64}}, name::String) at [constraints.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

macro expansion at [@constraint.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

macro expansion at [macros.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

OC2(A::Matrix{Float64}, g::Vector{Float64}, m::Vector{Float64}, n::Int64, inb::Float64) at [JumpOSQPPortFact_ptae926.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

top-level scope at [JumpOSQPPortFact_ptae926.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

Some type information was truncated. Use show(err) to see complete types.

ERROR: Constraints of type MathOptInterface.ScalarQuadraticFunction{Float64}-in-MathOptInterface.LessThan{Float64} are not supported by the solver.

If you expected the solver to support your problem, you may have an error in your formulation. Otherwise, consider using a different solver.

The list of available solvers, along with the problem types they support, is available at https://jump.dev/JuMP.jl/stable/installation/#Supported-solvers.
Stacktrace:

error(s::String) at [error.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

_moi_add_constraint(model::MathOptInterface.Utilities.CachingOptimizer{…}, f::MathOptInterface.ScalarQuadraticFunction{…}, s::MathOptInterface.LessThan{…}) at [constraints.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

add_constraint(model::Model, con::ScalarConstraint{QuadExpr, MathOptInterface.LessThan{Float64}}, name::String) at [constraints.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

macro expansion at [@constraint.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

macro expansion at [macros.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

OC2(A::Matrix{Float64}, g::Vector{Float64}, m::Vector{Float64}, n::Int64, inb::Float64) at [JumpOSQPPortFact_ptae926.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

top-level scope at [JumpOSQPPortFact_ptae926.jl](vscode-file://vscode-app/c:/Users/joah/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)

Some type information was truncated. Use show(err) to see complete types.
@imciner2
Copy link
Member

Hi @jonhar97,

OSQP does not currently support quadratic constraints, it is only a solver for linearly constrained quadratic programs, not quadratically constrained quadratic programs.

@jonhar97
Copy link
Author

Hi @imciner2,

thanks a lot for your fast reply. Much appreciated!

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

No branches or pull requests

2 participants