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:
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([[-1.0]])
h_ = jnp.array([2.0])
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
qp = OSQP()
deltas = qp.run(
params_obj=(P_, q_),
params_eq=(A_, b_),
params_ineq=(G_, h_),
).params.primal # Crashes with cryptic error.
# TypeError: dot_general requires contracting dimensions to have the same shape, got (1,) and (2,).
# jax-0.4.23 jaxlib-0.4.23 jaxopt-0.8.3 ml-dtypes-0.3.2 opt-einsum-3.3.0
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: