Description
Hi all,
I am trying to get gradients on a QP solution, but I am having the following error: ValueError: Can't apply Jacobian with a quadratic objective.
This is the trace:
File python3.8/site-packages/cvxpylayers/torch/cvxpylayer.py:286, in _CvxpyLayerFn.<locals>._CvxpyLayerFnFn.backward(ctx, *dvars)
284 grad = [[] for _ in range(len(param_order))]
285 for i in range(ctx.batch_size):
--> 286 del_param_dict = compiler.apply_param_jac(
287 dcs[i], -dAs[i], dbs[i])
288 for j, p in enumerate(param_order):
289 grad[j] += [to_torch(del_param_dict[p.id],
290 ctx.dtype, ctx.device).unsqueeze(0)]
File python3.8/site-packages/cvxpy/reductions/dcp2cone/cone_matrix_stuffing.py:222, in ParamConeProg.apply_param_jac(self, delc, delA, delb, active_params)
214 """Multiplies by Jacobian of parameter mapping.
215
216 Assumes delA is sparse.
(...)
219 A dictionary param.id -> dparam
220 """
221 if self.P is not None:
--> 222 raise ValueError("Can't apply Jacobian with a quadratic objective.")
224 if active_params is None:
225 active_params = {p.id for p in self.parameters}
using cvxpy 1.4.1
and cvxpylayers 0.0.1
I need help understanding why it does not work with quadratic objectives. Any insights will be much appreciated.
Thank you.
Just for reference, this is the form of my program:
where cp.Variable
, cp.Parameter
.
For context, the goal is to optimize via the backpropagated gradients a set of parameters that produce