Solve square problem to initialize regression problem using objective_at_theta() in parmest
Fixes # .
Implements changes proposed in issue #2377
Summary/Motivation:
Add code and tests to solve a square problem instance in order to initialize the regression problem in parmest
Changes proposed in this PR:
- Solve square problem instances of the model for each scenario using parameter values provided by user or values used to initialize fitted parameters; create extensive form of the model before calling
theta_est()for parameter estimation.- Call
objective_at_theta(initialize_parmest_model=True)which calls_Q_at_theta() - In
_Q_at_theta(), iterate over scenarios, create and solve instance of Pyomo model, and store solved model instance in scenario dictionary - Call function
_create_EF_from_scen_dict()to create the extensive form model with the scenario dictionary from above and set flagmodel_initialized=True - Call
theta_est()to solve parameter estimation problem using extensive form of model from above (skip building the extensive form usingtheta_est()).
- Call
- Create instance of Rooney-Biegler problem with
Constraintsto test square solve initialization - Add tests for square solve functionality
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:
- I agree my contributions are submitted under the BSD license.
- 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.
Codecov Report
Base: 86.54% // Head: 86.55% // Increases project coverage by +0.01% :tada:
Coverage data is based on head (
5170ece) compared to base (7ba914f). Patch coverage: 90.96% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## main #2438 +/- ##
==========================================
+ Coverage 86.54% 86.55% +0.01%
==========================================
Files 717 718 +1
Lines 80234 80348 +114
==========================================
+ Hits 69436 69544 +108
- Misses 10798 10804 +6
| Flag | Coverage Δ | |
|---|---|---|
| linux | 83.46% <90.32%> (+0.02%) |
:arrow_up: |
| osx | 73.67% <8.38%> (-0.11%) |
:arrow_down: |
| other | 83.65% <90.32%> (+0.02%) |
:arrow_up: |
| win | 80.64% <90.32%> (+0.02%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| pyomo/contrib/parmest/parmest.py | 83.80% <89.60%> (+2.17%) |
:arrow_up: |
| ...s/rooney_biegler/rooney_biegler_with_constraint.py | 95.83% <95.83%> (ø) |
|
| pyomo/contrib/parmest/utils/create_ef.py | 84.16% <100.00%> (ø) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
@kanishka-ghosh Note that the failing test is due to code coverage of your patch is slightly below the average coverage of the Pyomo codebase.
@kanishka-ghosh I merged PR #2352 from Kate which caused some conflicts with this PR. Could you try to resolve the conflicts and let me know if you have any issues?
@blnicho I resolved the merge conflicts
@kaklise could you review this PR?
@kaklise could you review this PR again when you have a chance?
@adowling2 volunteered to review
@kanishka-ghosh I think we should wait on this one for the release. I was taking a closer look at the test failures before your commits today and I'm not convinced that your fix is what we want. In fact, I think the tests you added for the functionality introduced in this PR are missing some important edge cases. For example, when I try adding the initialize_parmest_model=True flag to the test_parmest_basics test (https://github.com/kanishka-ghosh/pyomo/blob/square_solve_obj_at_theta/pyomo/contrib/parmest/tests/test_parmest.py#L411) it fails with a ZeroDivisionError. test_parmest_basics tests different configurations/structures for the same model so it's concerning to me that it doesn't work. If this is an invalid test case for your initialize_parmest_model flag let me know.
@kaklise could you take another look at this PR?