Skip to content

Add differentiable CVaR to UQPCEGroup and MultiUQPCEGroup - #26

Draft
bdphilli wants to merge 3 commits into
nasa:mainfrom
bdphilli:feature/cvar-integration
Draft

bdphilli wants to merge 3 commits into
nasa:mainfrom
bdphilli:feature/cvar-integration

Conversation

@bdphilli

Copy link
Copy Markdown
Contributor

Adds conditional value at risk (CVaR) as a differentiable statistic alongside the existing confidence intervals, for use as an optimization objective or constraint.

API

A new compute_cvar option (default False) on UQPCEGroup/MultiUQPCEGroup adds cvar_lower/cvar_upper outputs next to ci_lower/ci_upper, with the same tail convention: significance=0.05 gives the mean of the worst 2.5% tail, so each CVaR pairs with its CI. The existing use_tanh_ci flag selects the implementation, exactly as it does for the CI.

Exact form (use_tanh_ci=False)

CVaRComp, a JAX component computing the Rockafellar-Uryasev form

CVaR_upper = VaR + mean((x - VaR)+) / (alpha/2)
CVaR_lower = VaR - mean((VaR - x)+) / (alpha/2)

on the resampled responses, with the same aleatory/epistemic reshape and max/min aggregation as CDFComp. Well defined for repeated (discrete) sample values; reduces to the conditional tail mean for continuous samples.

Smoothed form (use_tanh_ci=True)

CVaRGroup solves the tanh-smoothed confidence interval with the same CDFResidComp/BalanceComp machinery as CDFGroup, then CVaRTailComp evaluates the Rockafellar-Uryasev form with a softplus hinge. Since softplus >= relu, the smoothing bias is always outward -- the upper CVaR is overestimated and the lower underestimated -- mirroring the conservative bias of the tanh CI. Bias scales as omega^2 * density / tail_frac. KS aggregation across epistemic curves as in CDFGroup.

Verification

  • Exact form matches numpy references to 1e-6 and the analytic standard-normal CVaR.
  • Analytic totals match finite difference to ~1e-8 in both modes, including through the Newton balance.
  • The conservative bias direction is asserted in the tests.
  • Ten new unit tests under test_suite/test_uqpce/mdao/cvar/, mirroring the cdf test layout; the full mdao suite passes.

Example

examples/GMM/objectives_comparison_example.py optimizes the same two-variable analytical problem (built on the GMM example's uncertainty model) under each statistic -- deterministic, mean, mean_plus_var, ci_upper, cvar_upper -- and each design provably minimizes its own column of the printed statistics table. The model is quadratic in the uncertain inputs so the order-2 PCE is exact, and the CI-vs-CVaR distinction is interpretable: CVaR shifts exposure away from the unbounded multimodal input and onto the bounded one. Writes a design-space/CDF/PDF comparison figure; reproducible run-to-run (relies on the seeding fix from #25).

New compute_cvar option adds cvar_lower/cvar_upper outputs alongside the
confidence intervals, using the same tail convention (alpha=0.05 gives
the mean of the worst 2.5% tail).

- CVaRComp: exact sample CVaR in the Rockafellar-Uryasev form
  VaR + mean((x - VaR)+)/(alpha/2) on the resampled responses, with the
  same aleatory/epistemic handling as CDFComp.
- CVaRGroup (use_tanh_ci=True): solves the tanh-smoothed confidence
  interval with the same CDFResidComp/BalanceComp machinery as CDFGroup,
  then CVaRTailComp evaluates the Rockafellar-Uryasev form with a
  softplus hinge. softplus >= relu makes the smoothing bias outward
  (conservative) on both tails, mirroring the tanh CI bias. KS
  aggregation across epistemic curves as in CDFGroup.

Verified: exact form matches numpy references to 1e-6 and analytic
normal CVaR; totals match FD to ~1e-8 in both modes; conservative bias
direction asserted. 10 new unit tests; full mdao suite (24) passes.
…I, CVaR

Analytical hello-world for the UQPCE optimization statistics, built on
the GMM example's uncertainty model (multimodal GMM + uniform + normal,
same input.yaml / run_matrix.dat). A two-variable quadratic amplifies
the unbounded multimodal input through x and the bounded uniform input
through y, so each objective picks a visibly different design:

    deterministic   sits at the target, worst spread and tail
    mean            best expected value, widest distribution
    mean_plus_var   narrowest distribution, largest mean penalty
    ci_upper        best 97.5th percentile
    cvar_upper      best tail mean; shifts exposure off the unbounded
                    input relative to ci_upper

The model is quadratic in the uncertain inputs so the order-2 PCE is
exact; each design provably minimizes its own column of the printed
statistics table. Writes a design-space / CDF / PDF comparison figure
from an independent Monte Carlo of the true function. Reproducible
run-to-run (single-threaded math plus the seeded resampling fix).
The 95th-percentile CI and 5% CVaR separate the two tail-risk designs
more clearly than the 2.5% tail did: the optima are visibly distinct in
the design space and each still minimizes its own statistic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant