pyoptsparse
pyoptsparse copied to clipboard
Added linear constraint check and updated documentation
Purpose
pyOptSparse computes the linear constraints exclusively based on jac
, lower
, and upper
entries of addConGroup
, and it ignores the linear constraint value returned by the user-defined obj/con function. This is confusing and can result in unexpected behavior (see related #296).
This PR adds a linear constraint checkerto make sure that a user-defined obj/con function does not return linear constraint values. If it does, pyOptSparse will raise an error. I also updated the documentation accordingly.
I fixed a few existing tests that have been computing linear constraint values in the obj/con function (which we should not). I also added a test to check if pyOptSparse raises an error as expected.
This change will break some existing runscripts that return linear constraint values in the user-defined function. OpenMDAO's pyOptSparseDriver will be fine. Not sure about MACH runscripts (haven't checked).
Expected time until merged
Type of change
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (non-backwards-compatible fix or feature)
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [x] Documentation update
- [ ] Maintenance update
- [ ] Other (please describe)
Testing
Checklist
- [ ] I have run
flake8
andblack
to make sure the Python code adheres to PEP-8 and is consistently formatted - [ ] I have formatted the Fortran code with
fprettify
or C/C++ code withclang-format
as applicable - [x] I have run unit and regression tests which pass locally with my changes
- [x] I have added new tests that prove my fix is effective or that my feature works
- [x] I have added necessary documentation