google / google/jaxopt

OSQP crashing on unexpected params

Open
#570 3 comments 0 reactions 1 assignee Claimed by @Algue-Rythme View on GitHub
documentation
Dominant language
Python
Stars
1.1k
Forks
76
Avg merge
2d 21h
Merged PRs (30d)
1

Description

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:
```python
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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.