Skip to main content

Module sens

Module sens 

Source
Expand description

Parametric-sensitivity and reduced-Hessian post-processing for the pounce driver.

This is the suffix-driven sIPOPT path: when an AMPL .nl declares the sIPOPT-style suffixes (sens_state_1, sens_state_value_1, sens_init_constr), pounce runs a normal solve and then performs the post-optimal sensitivity step via pounce-sensitivity, writing the perturbed primal back into the .sol as a sens_sol_state_1 suffix. The --compute-red-hessian flag additionally computes the reduced Hessian over the variables tagged by the red_hessian integer var-suffix.

Mirror of upstream sIPOPT’s ipopt_sens AMPL binary (ref/Ipopt/contrib/sIPOPT/src/AmplTNLP.cpp etc.), limited to the metadata-measurement path that the parametric_ampl example exercises.

The required suffixes (otherwise the solve is a plain nominal solve):

  • sens_state_1 — integer var-suffix tagging each parameter (value = 1..n_params, 0 for non-parameters).
  • sens_state_value_1 — real var-suffix carrying the perturbed parameter values.
  • sens_init_constr — integer con-suffix tagging which constraint pins each parameter to its nominal value (value = 1..n_params, 0 otherwise).

See ref/Ipopt/contrib/sIPOPT/examples/parametric_cpp/parametricTNLP.cpp get_var_con_metadata for the canonical suffix shape upstream emits, and pounce#16’s parametric_cpp.rs for an end-to-end cross-check against upstream’s golden output.

Structs§

RedHessianResult
Outputs of try_compute_red_hessian: the column-major n × n reduced Hessian (hr), the variable indices var_indices that label its rows/cols (so a downstream JSON consumer can map back to AMPL var names), and the optional eigendecomposition.

Functions§

compute_sens_perturbed_x
Run the post-optimal sensitivity step and return the perturbed primal lifted onto the full-x grid (length n_full). Returns None (quietly) when the required suffixes are missing — the caller then writes just the nominal solution.
is_sensitivity_input
True when the .nl declares the three sIPOPT-style suffixes that drive the parametric sensitivity step. When this returns false, pounce runs a plain nominal solve.
print_red_hessian_to_stderr
Format a reduced Hessian (and optional eigendecomp) onto stderr. Matches the style of upstream sIPOPT’s SensReducedHessianCalculator.cpp S->Print(...) / eigenvalues->Print(...) calls — informational, not parsed.
sol_suffix_to_report
Convert a .sol-shaped suffix block into the JSON report’s flat representation.
try_compute_red_hessian
Read the AMPL red_hessian integer var-suffix from .nl, select the tagged free variables, and compute the reduced Hessian via SensApplication::compute_reduced_hessian (optionally also the eigendecomposition). Returns None (quietly) when the suffix is missing or empty.