-
Notifications
You must be signed in to change notification settings - Fork 67
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
OSQP crashing on unexpected params #570
Comments
Hi Illviljan Sorry for the cryptic error message. The error comes from the fact that the matrix P_ = jnp.array([[576.0]])
q_ = jnp.array([-216.0])
G_ = jnp.array([[-1.0]])
h_ = jnp.array([2.0])
# A_ = jnp.array([[]], dtype=float).T
# b_ = jnp.array([], dtype=float)
qp = OSQP()
deltas = qp.run(
params_obj=(P_, q_),
params_eq=None, # CHANGE HERE.
params_ineq=(G_, h_),
).params.primal Similarly, if you don't need inequality constraints just pass |
Thank you, a quite simple fix. I maybe just need to continue with all constraints active in my larger project. I get surprised because it seems to me that Using import numpy as np
import jax.numpy as jnp
from jaxopt import OSQP
from qpsolvers import solve_qp
def to_numpy(*args):
return tuple(np.asarray(v) for v in args)
P_ = jnp.array([[576.0]])
q_ = jnp.array([-216.0])
G_ = jnp.array([[]], dtype=float).T
h_ = jnp.array([], dtype=float)
A_ = jnp.array([[]], dtype=float).T
b_ = jnp.array([], dtype=float)
x = solve_qp(*to_numpy(P_, q_, G_, h_, A_, b_), solver="osqp") # works
print(x)
qp = OSQP()
x = qp.run(
params_obj=(P_, q_),
params_eq=None,
params_ineq=None,
).params.primal # Unnecessarily strict crash |
That's true ; but using OSQP when you don't have constraints is overkill. In this case OSQP algorithm degenerates toward an inefficient way to solve a linear system. As argued in the documentation you should revert to conjugate gradient in this case. |
I'm trying to move over some qp code to jaxopt, but I'm struggling to understand the cryptic errors that appears to only happen in the jaxopt implementation. I've tried with other packages and these params work with those implementations.
Here's a minimal example:
The text was updated successfully, but these errors were encountered: