Theory Overview¶
DiffAPQP embeds a parameterized convex optimization problem in a PyTorch computational graph. In decision-focused learning, a forecaster first produces optimization parameters
where \(x\) is contextual input and \(\theta\) contains trainable model weights. DiffAPQP then solves the optimization problem parameterized by \(\hat y\) and propagates derivatives back to \(\theta\).
Computational structure¶
The optimization layer is decomposed into three maps:
- \(\mathcal C\) canonicalizes the original CVXPY model into affine-parametric QP data.
- \(\mathcal S\) calls a solver backend and returns the canonical primal-dual solution.
- \(\mathcal R\) retrieves the original named CVXPY decisions from the canonical decision vector.
Consequently, the solution map is
For a scalar training loss \(\ell\), the complete decision-focused computation is
Two differentiation targets¶
DiffAPQP exposes two layers because a training objective can depend on the optimization problem in two materially different ways.
| Target | Mathematical quantity | DiffAPQP interface | Backward computation |
|---|---|---|---|
| Optimal decisions | \(\hat z^\star=\mathcal O(\hat y)\) | SolMapLayer |
Full- or reduced-KKT adjoint solve |
| Optimal value | \(\alpha(\hat y)=f_0(\hat z^\star,\hat y)\) | ValueFuncLayer |
Direct value-function derivative |
Use the solution-map layer when the downstream loss needs dispatch, reserve, flow, or another optimal decision. Use the value-function layer when the loss needs only the optimal objective value.
Notation¶
| Symbol | Meaning |
|---|---|
| \(x\) | Contextual input to the forecaster |
| \(\theta\) | Trainable forecaster parameters |
| \(y\) | Realized or true optimization parameters |
| \(\hat y=f(x,\theta)\) | Predicted optimization parameters |
| \(z\) | Decisions in the original domain-specific CVXPY model |
| \(\hat z^\star\) | Retrieved optimal decisions under \(\hat y\) |
| \(\tilde z\) | Canonical APQP decision vector |
| \(\tilde\nu\), \(\tilde\lambda\) | Canonical equality and inequality duals |
| \(\alpha(\hat y)\) | Optimal value function |
| \(\ell\) | Scalar training loss |
| \(N_d,N_p,N_{\mathrm{eq}},N_{\mathrm{in}}\) | Counts in the original domain model |
| \(n_d,n_{\mathrm{eq}},n_{\mathrm{in}}\) | Dimensions after canonicalization |
The hat on \(\hat y\) emphasizes that the optimization parameters are commonly forecasts. The tilde distinguishes canonical variables from the original domain variables returned to the user.
Reading guide¶
- Decision-focused learning introduces the forecasting and optimization chain and explains which layer matches each loss.
- APQP and canonicalization defines the supported mathematical problem and its affine parameter-to-data maps.
- Efficient forward pass explains solver flexibility, solver-data update, warm-starting, batching, and retrieval.
- Solution-map differentiation derives the full and
reduced KKT adjoints used by
SolMapLayer. - Value-function differentiation derives the direct
gradient used by
ValueFuncLayer. - Numerical considerations discusses regularity, degeneracy, active-set detection, and stabilization.
For argument-level behavior, shapes, defaults, and return types, use the API overview and the two implementation references.