pyomo
pyomo copied to clipboard
Pyomo.DoE bug fixes
Fixes No issue
Summary/Motivation:
- Minor enhancements in Pyomo.DoE in preparation for a tutorial/workshop
Changes proposed in this PR:
- Fixed error about ambiguous
a.any()versusa.all()for logical check of a list-like object - Added a TypeError to prevent a downstream cryptic error message
- Update type checking per suggested best practices from @jsiirola and @mrmundt
- Improved initialization of the Jacobian and Cholesky factorization
- Added optionally passing
thetaparameter values intocreate_modelwhen generating scenarios. This is especially helpful ifcreate_modelincludes initialization such was using the simulator inpyomo.dae - Added more comments
- Fixed degree of freedom issue by fixing the parameters on the nominal case model. This is important if
create_modelcreates a full model instage1model. Our original design anticipatedstage1mode would be really lite, but that is inconvenient when trying to use the samecreate_modelforparmestandpyomo.doe
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.
@jsiirola @mrmundt Suggestions for type(lower_bounds) in [int, float]?
Any reasons for not replacing if type(self.L_initial) != type(None) with if self.L_initial is not None?
For checking for numeric types, we generally use
from pyomo.common.numeric_types import native_numeric_types
if type(lower_bound) in native_numeric_types:
pass
# or
if lower_bound.__class__ in native_numeric_types:
pass
and yes: if self.L_initial is not None is the recommended idiom.
@adowling2 - Please run black -S -C on your changes to enforce PEP8 standards.
More development plans:
- [x] Ensure
discretize_model = Noneworks on TCLab example (separate repo, really helpful for testing) - [x] Use the
jac_initialargument. Currently, it is stored in self and not used. - [x] Automatically initialize Cholesky factorization
- [x] Confirm that the "square problem" has zero degrees of freedom. Correct if necessary.
- [x] Run black
@adowling2 - Please run
black -S -Con your changes to enforce PEP8 standards.
I got Error: no such option: -C
However, black -S worked fine. I have version 19.10b0 if that matters.
Update: I reinstalled black and it works using the command provided by @mrmundt. Now using black, 24.4.2. I'm going to keep the comment above for my future reference.
@dlakes94 @slilonfe5 @jialuw96 Check out these enhancements to Pyomo.DoE. We'll want to use this branch (which will hopefully be merged into main soon) when refreshing the Pyomo.DoE examples.
Update: I reinstalled black and it works using the command provided by @mrmundt. Now using
black, 24.4.2. I'm going to keep the comment above for my future reference.
Future reference - yup, it matters! We use the newest black, unless there are bugs in it (e.g., 24.4.1 had a bug that was problematic).
Anything else needed to get this reviewed and merged?