Decision-Focused Learning¶
Decision-focused learning trains a predictive model according to the quality of the downstream decisions it induces, rather than prediction error alone. DiffAPQP provides the differentiable optimization layer in this forecasting and decision-making chain.
Forecast followed by optimization¶
Let a forecaster produce
where \(x\) contains contextual information, \(\theta\) contains trainable weights, and \(\hat y\) may represent predicted demand, renewable generation, reserve requirements, or market prices.
The prediction is passed to a domain-specific optimization problem:
The compact solution-map notation is
and the associated value function is
Users write this optimization in its natural engineering form with CVXPY. Canonicalization converts a compatible model to the APQP representation required by DiffAPQP.
Decision-focused objective¶
For a dataset \(\mathcal D\) of contextual inputs and realized outcomes, a generic decision-focused objective is
The optimization outputs remain in the PyTorch computational graph. The chain rule therefore propagates the loss gradient through the optimization layer and then through the forecaster:
The middle factor is the differentiable-optimization contribution. It is the focus of solution-map differentiation.
Closed-loop decision losses¶
A closed-loop loss evaluates decisions produced by one or more optimization stages. In a forecast--economic-dispatch--redispatch chain, for example,
The loss may combine dispatch and redispatch costs:
Because the loss depends on optimal decisions, this setting requires
SolMapLayer. Its backward pass
solves either the full or reduced KKT adjoint.
Counterfactual value losses¶
A counterfactual loss can compare the objective induced by predicted parameters with an oracle objective computed from the realized parameters:
If \(\alpha(y)\) is precomputed, only \(\alpha(\hat y)\) participates in the
training graph. Because the loss depends directly on the optimal value,
ValueFuncLayer can use the
direct value-function derivative and avoid a KKT adjoint
solve.
Choosing the layer¶
| Loss requires | Recommended layer | Reason |
|---|---|---|
| Original optimal decisions \(\hat z^\star\) | SolMapLayer |
Returns autograd-connected named primal variables |
| Only the optimal value \(\alpha(\hat y)\) | ValueFuncLayer |
Avoids solution-map Jacobian and adjoint KKT solve |
The distinction affects only the differentiation target. Both layers share the same APQP canonicalization and forward-solve structure.