Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
1.9k stars 490 forks source link

PyomoNLP scaling factors on sub-blocks #3295

Open bknueven opened 2 weeks ago

bknueven commented 2 weeks ago

Fixes # N/A

Summary/Motivation:

Scaling factors in the PyomoNLP interface will not be applied if the scaling_factor Suffix is on a sub-block.

Changes proposed in this PR:

As-is this PR would change the behavior of these methods in that they would always return scaling factors. I cannot seem to exactly replicate the prior behavior which would allow all existing tests to pass without modification.

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.
bknueven commented 5 days ago

Thanks for the PR, this is a good change. I have a minor concern about backward incompatibility, see below. Also, can you add a small unit test to TestPyomoNLP in test_nlp.py that exercises this functionality?

Thanks for the review. I believe I have address all comments except for potential modifications to SuffixFinder to support a context argument. I believe the same potential issue would also affect the NL writer.