osmose.calibration.stability

Bounded-equilibrium instability penalty for the SP-A Baltic stability calibration.

stability_penalty() returns 0.0 for a trajectory that stays bounded and inside its ICES envelope, and grows with extinction (persistence), envelope violation, drift (trend), and boom-bust variability. It is a pure function so the picklable calibration objective can call it across a ProcessPool boundary.

Design notes (see docs/superpowers/specs/2026-07-01-baltic-stability-recalibration-spA-design.md):

  • persistence is a SMOOTH log10-below-floor term (commensurate with the ICES log10^2 error), not a flat step, so it trades off continuously against the ICES match instead of swamping it.

  • the trend term takes the MAX of the full-window and late-window slopes, so a config that holds flat then tips in the final years is not averaged into a near-zero slope.

  • the “late window” is relative (final decade of whatever horizon is run), valid for both the in-loop proxy and the 50-yr certification.

  • documented boom-bust species (stickleback) are not charged for variability.

Functions

stability_penalty(biomass, targets, *[, ...])

Scalar instability penalty over the post-warmup window (0.0 = bounded & in-envelope).