Skip to content

[Depends on #3575] ParmEst: Add profile likelihood analysis for model identifiability - #3875

Draft
sscini wants to merge 121 commits into
Pyomo:mainfrom
sscini:profile-likelihood
Draft

sscini wants to merge 121 commits into
Pyomo:mainfrom
sscini:profile-likelihood

Conversation

@sscini

@sscini sscini commented Mar 17, 2026 •

Copy link
Copy Markdown
Member

Fixes # .

Summary/Motivation:

This PR implements profile likelihood as a method for practical identifiability analysis of parmest models. This includes a new function within the experiment class in parmest.py, and a new visualization function in graphics.py

Changes proposed in this PR:

  • Add profile likelihood analysis for structural identifiability based on multistart
  • Add visualization tool for analyzing results
  • Adjust private functions to accommodate extension
  • New tests to confirm extension works as intended

TODO before converting from draft:

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

sscini added 30 commits April 23, 2025 11:50
sscini and others added 15 commits October 15, 2026 23:35
theta_est_multistart moved only theta to each start value. Every start
began from the states the Experiment class built for its own theta (e.g.,
a discretized ODE trajectory simulated at the nominal theta), so starts
differed only in theta and Ipopt's initial point was inconsistent. The
per-start model refresh that handled this was removed in 51ca54a.

theta_est_multistart now initializes the states at every start by
default (initialize_states=True): each experiment block is solved with
theta fixed at the start values. If the direct solve fails, theta is
moved from the Experiment's values to the start values in 4, then 16,
steps, each solve starting from the previous one. If initialization still
fails (e.g., the discretized model has no solution at that theta), the
block keeps the Experiment's initialization, the status is recorded in
the new initialization_termination column, and one warning summarizes
the count.

_Q_opt gains initialize_states, and _create_scenario_blocks records the
theta each Experiment built its model with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	pyomo/contrib/parmest/parmest.py
profile_likelihood rebuilt the model from the Experiments at every grid
value, so each solve started from the states the Experiment built for its
own theta. The "neighbor" warm start carried over only the theta values
of the previous solution, not its states.

- "neighbor" now copies all free variable values (states and thetas) of
  the previous solved grid value into the new model (_Q_opt
  warm_start_model, _copy_scenario_values).
- profile_likelihood(initialize_states=True), the default, then solves
  each experiment with the thetas fixed at the starting values (the
  profiled theta at the grid value), as theta_est_multistart does. With
  "neighbor" this is a small step from the previous solution; with
  "none" it starts from the Experiment's initialization.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sscini added a commit to sscini/pyomo that referenced this pull request Dec 1, 2026
sscini added a commit to sscini/pyomo that referenced this pull request Dec 1, 2026
…profile-likelihood)

Child of profile-likelihood (Pyomo#3875, cd88987). ParmEst Tutor bug
register B-38: a 2-theta Arrhenius profile (the Tutor's case s13) logged
270 Pyomo W1002 "outside the bounds" warnings, 54 without
initialize_states (attributed to 7ec5980 on 2026-11-23).

Cause (located by recording where each warning is raised): when a
non-profiled theta sits on a bound, IPOPT returns it up to its bound
relaxation past the bound (bound_relax_factor, 1e-8 * max(1, |bound|) by
default; e.g. activation_energy = 9999.99996 with lower bound 10000).
That solution is the next grid value's warm start, and it was set on the
bounded theta of every scenario block in _create_scenario_blocks, then
again at every continuation step and at the end of
_initialize_scenario_states (which multiplies the count, hence the
initialize_states attribution). The grid values themselves were inside
the bounds (restricting the grid to the bounds left all 270).

_profile_sweep now projects theta_hat and each solution it uses as a
warm start onto the theta bounds (read from the first experiment's
parmest model), and _initialize_scenario_states projects the values it
fixes and restores (its origin may also come from a copied solution).
The projection moves a value by no more than the solver's bound
relaxation, so the profile is unchanged: the test model's profile and
the s13 profile give the same rows as the base commit; the s13 warning
count goes from 270 to 0.

Test: profile theta_a of y = theta_a x + theta_b where theta_b reaches
its upper bound for theta_a <= 1: no "outside the bounds" warning (fails
on cd88987, whose warm start is theta_b = 3.0000000224), every row
succeeds, and each objective equals the closed-form profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sscini added a commit to sscini/pyomo that referenced this pull request Dec 1, 2026
…ag an invalid profile (child of profile-likelihood)

Child of profile-likelihood (Pyomo#3875, cd88987). ParmEst Tutor bug
register B-33 (not fixed by 7ec5980).

Every profile solve starts from a converged point: theta_hat, or the
solution at the neighboring grid value. IPOPT first moves each variable
at least min(bound_push * max(1, |lb|), bound_frac * (ub - lb)) away from
its bounds (Waechter & Biegler 2006, sec. 3.6), 0.01 with the defaults.
A theta closer than that to a bound (k_ref = 1.5e-4 with a lower bound of
1e-6 in the Tutor's case s13) was moved up to 100x away, outside its
basin, onto a region where the model outputs no longer depend on it. The
solves still terminated "optimal", so every row of the E profile,
including the row at theta_hat itself (lr_stat 7322 instead of 0), lay on
a plateau and the interval was NaN/NaN.

profile_likelihood now gives the profile solves bound_push = bound_frac =
1e-10 unless solver_options sets them (restored afterwards), so the warm
start is kept up to 1e-10 * max(1, |bound|). It also checks the row at
theta_hat: it re-solves the estimation problem from its own solution, so
it must reproduce obj_hat (lr_stat = 0) up to the solver tolerance
(1e-6 relative); otherwise it logs that the profile of that theta is not
valid. On s13 the E interval becomes (45251, 125799), which contains the
truth and equals the result of the 2026-11-23 manual workaround.

Tests (y = A exp(-k t), k ~ 1.5e-6, t up to 1e5): with default options the
profile of A stays in the basin (lr_stat at theta_hat = 0) and every row
equals the profile objective minimized independently over k by scipy;
on cd88987 every row is on the plateau (lr_stat 339962). With
bound_push forced back to 0.01 by the user, the invalid profile is now
reported (no message on cd88987).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants