pympcc.sensitivity

pympcc.sensitivity(result, problem, *, dgrad_L_dp, dc_dp, fd_h=None, regularize_eps=1e-12, active_tol=1e-06)[source]

Compute dx*/dp via implicit differentiation through the KKT system.

Solves the saddle-point system

[[H, J_c^T], [J_c, 0]] · [dx; dλ] = − [dgrad_L_dp; dc_dp]

where H = ∇²_xx L(x*, λ*) and J_c is the active constraint Jacobian. Skips with skipped_reason set when MPCC-LICQ prerequisites fail (non-converged result, or biactive pairs present).

Parameters:
  • result (MPCCResult) – Converged solve result. When tnlp_refine=True was used, the TNLP-refined multipliers are picked up automatically; otherwise a zero-multiplier fallback is used and a UserWarning is emitted (only when no analytic Hessian is available).

  • problem (MPCCProblem) – Source problem (original space, not presolve-reduced).

  • dgrad_L_dp (array-like, shape (n,) or (n, n_p)) – ∂(∇_x L)/∂p at x* with (x, λ) held fixed. When parameters enter only f, this is ∂(∇_x f)/∂p; otherwise callers must include the cross-term Σ_i λ_i · ∂(∇_x c_i)/∂p. A 1-D input is treated as a single parameter column.

  • dc_dp (array-like, shape (n_active,) or (n_active, n_p)) – ∂c/∂p at x*, with rows ordered to match active_row_labels(). See SensitivityResult for the per-row label format.

  • fd_h (float, optional) – Step size for the central-difference Hessian fallback when problem.lagrangian_hessian is not provided. Defaults to problem.fd_h.

  • regularize_eps (float) – Tikhonov ridge added to the KKT diagonal when the dense solve fails. Default 1e-12.

  • active_tol (float) – Active-set detection tolerance (default 1e-6).

Return type:

SensitivityResult