OptimizationAdjoint for constrained optimization solution sensitivities #1444
OptimizationAdjoint for constrained optimization solution sensitivities #1444jClugstor wants to merge 19 commits into
Conversation
SummaryAdds a new OptimizationAdjoint sensitivity algorithm that computes opt_sol = solve(prob, NLopt.LD_SLSQP()) # solve once
dgdu!(out, u, _, _, _) = (out .= dG_dx) # cotangent of loss w.r.t. x*
dp = adjoint_sensitivities(opt_sol, nothing;
sensealg = OptimizationAdjoint(),
dgdu = dgdu!) |
The MathA simple way to say this is that this is basically the same thing as SteadyStateAdjoint, but just doing the implicit differentiation on the Nonlinear system that is made up of the gradient of the lagrangian and the constraint equations all set to zero. First of all though, we do need all of the KKT variables/ dual variables / lagrange multipliers, the variables that are multiplied by the constraint functions in the lagrangian that satisfy the KKT conditions. We get the optimal This is typically overdetermined (more x's than active constraints), so we solve via LinearSolve.QRFactorization — least-squares, which under LICQ recovers the exact multipliers. LICQ says that at the optimal point, the gradients of the active constraints are all linearly independent. QR decomposition finds the least squares solution, so it's finding but if we found a viable local minimum, the KKT theorem states that If any returned z_I is negative (KKT violation), the corresponding constraint was wrongly classified as active; drop it and redo the multiplier solve. The sign-check + redo handles boundary degeneracy that proximity-based active-set detection alone gets wrong. Now for the sensitivity, the idea is that a solution of the constrained optimization problem satisfies the Karush-Kuhn Tucker (KKT) conditions: Taking only the set of inequality constraints that are actually active, The solution of the optimization problem satisfies this nonlinear system of equations. Our end goal is to find Using the above, Now consider that we have some scalar cost function that will be a function of the solution of the optimization problem, But this term so that |
908f0f0 to
9c6375c
Compare
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.