diff --git a/docs/quadratic_programming.rst b/docs/quadratic_programming.rst index 30009e84..ce938d7d 100644 --- a/docs/quadratic_programming.rst +++ b/docs/quadratic_programming.rst @@ -195,6 +195,9 @@ Example:: It is also possible to specify only equality constraints or only inequality constraints by setting ``params_eq`` or ``params_ineq`` to ``None``. +Use ``None`` for a missing constraint family rather than empty arrays, such as +zero-row equality matrices. If both equality and inequality constraints are +absent, use the unconstrained QP approach below instead of :class:`jaxopt.OSQP`. OSQP ~~~~ @@ -231,6 +234,12 @@ Example:: See :class:`jaxopt.BoxOSQP` for a full description of the parameters. +When using :class:`jaxopt.OSQP`, pass ``params_eq=None`` if there are no +equality constraints, or ``params_ineq=None`` if there are no inequality +constraints. At least one of these two arguments must be provided. Problems +without constraints should be solved as unconstrained QPs, for example with +conjugate gradient. + .. topic:: Example * :ref:`sphx_glr_auto_examples_constrained_multiclass_linear_svm.py` diff --git a/jaxopt/_src/osqp.py b/jaxopt/_src/osqp.py index 83cb920f..bd8fe5d8 100644 --- a/jaxopt/_src/osqp.py +++ b/jaxopt/_src/osqp.py @@ -1058,8 +1058,12 @@ def run(self, a tuple (Q, c) with Q a pytree of matrices, or a tuple (params_Q, c) if ``matvec_Q`` is provided, or an arbitrary pytree if ``fun`` is provided. - params_eq: (A, b) or None if no equality constraints. - params_ineq: (G, h) or None if no inequality constraints. + params_eq: (A, b) or None if no equality constraints. Use None rather + than an empty equality matrix. + params_ineq: (G, h) or None if no inequality constraints. Use None + rather than an empty inequality matrix. At least one of params_eq or + params_ineq must be not None; use an unconstrained QP solver when both + constraint families are absent. Returns: (params, state), ``params = (primal_var, dual_var_eq, dual_var_ineq)`` """