Skip to content

Implementing multistart version of theta_est using multiple sampling methods - #3575

Open
sscini wants to merge 87 commits into
Pyomo:mainfrom
sscini:multistart-in-parmest
Open

sscini wants to merge 87 commits into
Pyomo:mainfrom
sscini:multistart-in-parmest

Conversation

@sscini

@sscini sscini commented Apr 23, 2025 •

Copy link
Copy Markdown
Member

Fixes # .

Summary/Motivation:

Currently, the optimization is only done from a single initial value. This implementation adds the ability to specify multiple initial values using selected sampling techniques: from a random uniform distribution, using Latin Hypercube Sampling, or using Sobol Quasi-Monte Carlo sampling.

Changes proposed in this PR:

  • All changes made adding pseudocode in comments
  • Added inputs needed for multistart simulation
  • Added a function to generate points using the selected method
  • Added theta_est_multistart to work for the multistart process

TODO before converting from draft:

  • Receive feedback from collaborators on logical setup
  • Convert finalized pseudocode
  • Test and debug
  • Confirm function with examples

AI-Use Disclosure

  • AI tools were NOT used during the preparation of this PR

or

  • AI tools contributed to the development of this PR

    • AI tools generated documentation (including the PR description/comments, code comments, and/or Sphinx documentation)
    • AI tools generated tests (baselines, examples, and/or code)
    • AI tools generated code (apart from tests)

    Review process (select ONE):

    • Rewritten: All AI-generated content was rewritten by me before being committed.
    • Reviewed/verified: I retained AI-generated content and verified it before committing. Verification included (as applicable):
      • Ran the code and fixed issues
      • Added and ran tests
      • Checked correctness/logic of code and tests
      • Checked for alignment with the contribution guide
      • Considered security implications
    • As-is: AI-generated content was commited directly to the repository

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

sscini commented Apr 23, 2025

Copy link
Copy Markdown
Member Author

@djlaky @adowling2 Please provide early feedback.

@sscini

sscini commented Apr 30, 2025

Copy link
Copy Markdown
Member Author

Dynamic saving using flush, add.

@adowling2 adowling2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes from our in-person discussion/informal code review

Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
@sscini

sscini commented Apr 30, 2025

Copy link
Copy Markdown
Member Author

Extend existing tests for parmest to include multistart, add.

@sscini

sscini commented Apr 30, 2025

Copy link
Copy Markdown
Member Author

Models provided need to include bounds, add exception

@adowling2 adowling2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some more comments for you to consider are you continue to refine this.

Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
@sscini

sscini commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

@blnicho @mrmundt Code is ready for your review. A lot of the checks are failing, but not from my testing? If you could please rerun it would be greatly appreciated. I also added AI disclosure to the PR statement since this was made before it was added for disclosure. Thank you!

@sscini

sscini commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

@blnicho @mrmundt Code is ready for your review. A lot of the checks are failing, but not from my testing? If you could please rerun it would be greatly appreciated. I also added AI disclosure to the PR statement since this was made before it was added for disclosure. Thank you!

Similar failures when I merged main into #4039.

@sscini

sscini commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Thank you for detailed comments @slilonfe5! I believe my changes address them all.

@mrmundt

mrmundt commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@sscini - There is no re-run that will fix this... New z3-solver version released yesterday, yay.

@mrmundt

mrmundt commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@sscini - There is no re-run that will fix this... New z3-solver version released yesterday, yay.

Okay, fix is in main. I just merged it here.

Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
Comment thread pyomo/contrib/parmest/parmest.py Resolved
@blnicho blnicho moved this from Todo to Review In Progress in November 2026 Release Nov 10, 2026
@mrmundt

mrmundt commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@sscini , @stephenscini (whichever account you see first...) - We are trying to get a release out this week and would like to include this, if possible. Would you be able to address @smondal13 's comments?

@sscini

sscini commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

@sscini , @stephenscini (whichever account you see first...) - We are trying to get a release out this week and would like to include this, if possible. Would you be able to address @smondal13 's comments?

Hi Miranda @mrmundt! Yes I am working to get through comments on my PRs by EOD tomorrow. Thank you for prioritizing and I will tag once comments are addressed.

@sscini

sscini commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

@mrmundt Shuvo's comments have been addressed. Please review when you have a chance. Thank you

sscini added a commit to sscini/pyomo that referenced this pull request Dec 1, 2026
Conflict in pyomo/contrib/parmest/parmest.py, _sample_initial_theta
(2 hunks). Resolved as the union of both sides:
- keep Pyomo#3575's argument names (n_starts, lower_bounds, upper_bounds);
- keep the sensitivity branch's lhs_optimization keyword and its pass-through
  to scipy.stats.qmc.LatinHypercube(..., optimization=lhs_optimization);
- use samples = sampler.random(n=n_starts).

No caller changes were needed: sensitivity_prcc passes the renamed arguments
positionally, and lhs_optimization by keyword. No expected test values
changed.

Checked on an identical evaluation merge: the parmest component tests give
228 passed, 4 failed (the same k_aug x3 and semibatch scenario failures as
the pin), 14 skipped. Record: parmest-tutor-private
docs/decisions/2026-11-23-phase5-evaluation-candidate.md.

Merged locally by the ParmEst Tutor overnight run (plan section 13), not
pushed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@adowling2 adowling2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one minor comment.

)


_LINEAR_DATA = [(1.0, 2.0), (2.0, 3.0)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a comment about where this is used. My guess is that it is used in a later example, but it is good to be explicit with a "global" variable (in the informal sense)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is LinearThetaExperiment defined or imported? Perhaps move this line next to it.

Comment thread pyomo/contrib/parmest/parmest.py Resolved
(uniform_random).
user_supplied_vals: dict or pd.DataFrame, optional
Starting values keyed by theta name, e.g.,
``{"asymptote": [10, 20], "rate_constant": [0.1, 0.5]}``.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense as a user interface for me. It does rely on strings, which is not perfect. But I do not have a good recommendation to get around it.

@sscini

sscini commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

@blnicho @mrmundt Would it be easier to close this PR and only need to review the larger profile likelihood PR (#3875)? I think that might be less work overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Ready for design review

Development

Successfully merging this pull request may close these issues.

10 participants