Feature/add funnel globalization mechanism to trf#3832
Feature/add funnel globalization mechanism to trf#3832gulhameed361 wants to merge 12 commits intoPyomo:mainfrom
Conversation
|
Thank you for reviewing this PR! Please let me know if there are any changes or clarifications needed. I have tested the feature locally, and all tests passed successfully. |
mrmundt
left a comment
There was a problem hiding this comment.
Some initial requests for changes that will be stoppers on this PR.
|
Also, please install the most recent version of |
gulhameed361
left a comment
There was a problem hiding this comment.
Many thanks for the quick feedback. I have addressed the requested changes:
- Added copyright headers to
funnel.pyandtest_funnel.py. - Consolidated Funnel and Filter tests into
test_TRF.pyand removed duplicate test files (test_TRF_w_Funnel.pyandtest_TRF_w_Filter.py). - Formatted the updated files using
black. - Verified functionality with
pytest, and all tests passed successfully.
Please let me know if further changes are required. Thank you!
gulhameed361
left a comment
There was a problem hiding this comment.
All the requested changes have been addressed. Made a few additional changes as well to the code to make it concise/efficient.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3832 +/- ##
=======================================
Coverage 89.68% 89.68%
=======================================
Files 908 909 +1
Lines 106753 106822 +69
=======================================
+ Hits 95740 95807 +67
- Misses 11013 11015 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I have added a test for lines which were not tested as per the codecov report, and updated both the main and feature branches. |
|
I haven't updated the branch, because it may require the PR to go through all checks again! I can do it whenever required. |
e70f720 to
56ae690
Compare
|
Rebased onto the latest main, this should fix the CI failures. |
mrmundt
left a comment
There was a problem hiding this comment.
Thanks for doing the updates! Sorry, we messed with you a bit here on the copyright. We updated them everywhere while this PR was open.
Additionally, there is existing online documentation for TRF: https://pyomo.readthedocs.io/en/stable/explanation/solvers/trustregion.html
It would be good for you to go edit those files with updates about your changes: https://github.com/Pyomo/pyomo/blob/main/doc/OnlineDocs/explanation/solvers/trustregion.rst
5b5bdae to
109f802
Compare
…added tests for both funnel and filter methods
…py, made small theoretical changes to TRF.py as per the funnel mechanism published in AIChE, added a comment in example2.py showing how funnel mechanism can imprive solver's performance.
…y as per reviewers' suggestion, updated test_TRF.py as per the changes made in TRF.py
…tion strategy and fix copyright years
109f802 to
a314a55
Compare
mrmundt
left a comment
There was a problem hiding this comment.
Sorry sorry, little bit of a nitpick here.
Co-authored-by: Miranda Mundt <55767766+mrmundt@users.noreply.github.com>
Co-authored-by: Miranda Mundt <55767766+mrmundt@users.noreply.github.com>
I think it was a great catch as it wasn't step 4, it was just an alternative. |
|
I just noticed it was at pre-test inspected status. Apologies for re-requesting review! |
| # | ||
| # Development of this module was conducted as part of the Institute for | ||
| # the Design of Advanced Energy Systems (IDAES) with support through the | ||
| # Simulation-Based Engineering, Crosscutting Research Program within the | ||
| # U.S. Department of Energy’s Office of Fossil Energy and Carbon Management. | ||
| # | ||
| # This software is distributed under the 3-clause BSD License. |
There was a problem hiding this comment.
@gulhameed361 I'm assuming the development of the funnel approach was not funded under the IDAES program in which case the IDAES copyright assertion can be removed from any new files in this PR.
| # | ||
| # Development of this module was conducted as part of the Institute for | ||
| # the Design of Advanced Energy Systems (IDAES) with support through the | ||
| # Simulation-Based Engineering, Crosscutting Research Program within the | ||
| # U.S. Department of Energy’s Office of Fossil Energy and Carbon Management. | ||
| # | ||
| # This software is distributed under the 3-clause BSD License. |
There was a problem hiding this comment.
Same comment about the IDAES copyright. I suspect this can be removed but confirm with your paper coauthors.
| "``0`` = Filter (default), ``1`` = Funnel. " | ||
| "Default = 0.", | ||
| ), | ||
| ) |
There was a problem hiding this comment.
Why did you set this up to be an integer instead of something more verbose/explicit like a string enum where the options are "filter" and "funnel"? Using an enum would prevent users having to remember which integer is mapped to which variant.
If you decide to change this implementation you can find a couple examples here:
https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/pyros/config.py#L628
https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/incidence_analysis/config.py#L67
| ) -> bool: | ||
| # Δf ≥ μ_s · Δθ | ||
| return (f_old - f_new) >= self.mu_s * ((theta_old) ** 2) | ||
| # return (f_old - f_new) >= self.mu_s * (theta_old - theta_new) |
There was a problem hiding this comment.
Can this commented line be removed? Also, do you still need to pass theta_new to this function if it's not being used?
Fixes # .
Summary/Motivation:
This PR introduces the Funnel globalization strategy to the Trust Region Framework (TRF) solver in Pyomo. The Funnel method is an alternative to the existing Filter globalization mechanism.
The solver functionality remains unchanged by default and will continue to work as it has in previous versions unless the user explicitly selects the Funnel strategy in solver's options (globalization_strategy=1). This ensures backward compatibility.
The Funnel strategy is based on the methodology introduced in the paper "A Trust-region Funnel Algorithm for Grey-Box Optimisation" (https://arxiv.org/abs/2511.18998), which is accepted in AIChE Journal and will be live in the upcoming days.
Changes proposed in this PR:
funnel.pyto implement the Funnel globalization strategy.TRF.pyto integrate the Funnel strategy into the Trust Region Framework solver.test_funnel.py: Tests for the Funnel class.test_TRF_w_Funnel.py: Tests for the integration of Funnel with TRF.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: