Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NLv2: fix 0 operands in pow expressions #2726

Merged
merged 3 commits into from
Feb 10, 2023

Conversation

jsiirola
Copy link
Member

@jsiirola jsiirola commented Feb 9, 2023

Fixes IDAES/idaes-pse#1084.

Summary/Motivation:

IDAES noted an error in the NLv2 writer for the case of pow expressions where the second operand was a constant 0. This resolves that error (adding a test). In addition, this PR adds logic to simplify expressions that are **0 and **1 (also adding tests).

Changes proposed in this PR:

  • resolve error for binary operators with constant 0 operands
  • add special-case simplification of **0 and **1 expressions

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.

@codecov
Copy link

codecov bot commented Feb 10, 2023

Codecov Report

Base: 86.83% // Head: 86.97% // Increases project coverage by +0.14% 🎉

Coverage data is based on head (8bd1a90) compared to base (8fe21bb).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2726      +/-   ##
==========================================
+ Coverage   86.83%   86.97%   +0.14%     
==========================================
  Files         771      771              
  Lines       86162    86167       +5     
==========================================
+ Hits        74818    74948     +130     
+ Misses      11344    11219     -125     
Flag Coverage Δ
linux 84.14% <100.00%> (+<0.01%) ⬆️
osx 73.59% <100.00%> (+<0.01%) ⬆️
other 84.32% <100.00%> (+0.20%) ⬆️
win 81.51% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyomo/repn/plugins/nl_writer.py 93.60% <100.00%> (-0.14%) ⬇️
pyomo/util/subsystems.py 89.13% <0.00%> (-8.70%) ⬇️
...ontrib/appsi/utils/collect_vars_and_named_exprs.py 93.75% <0.00%> (-6.25%) ⬇️
pyomo/core/base/external.py 95.43% <0.00%> (-3.16%) ⬇️
pyomo/contrib/appsi/writers/nl_writer.py 84.39% <0.00%> (-2.32%) ⬇️
pyomo/repn/plugins/ampl/ampl_.py 81.40% <0.00%> (-1.86%) ⬇️
pyomo/core/expr/compare.py 96.52% <0.00%> (-1.74%) ⬇️
pyomo/contrib/appsi/solvers/ipopt.py 88.51% <0.00%> (-0.34%) ⬇️
pyomo/contrib/appsi/base.py 84.94% <0.00%> (-0.26%) ⬇️
... and 15 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mrmundt mrmundt changed the title NLv2: fix 0 operands in pow expressiosn NLv2: fix 0 operands in pow expressions Feb 10, 2023
@jsiirola jsiirola merged commit f1b9831 into Pyomo:main Feb 10, 2023
@jsiirola jsiirola deleted the nlv2-fix-0-operands branch February 10, 2023 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Power Plant Costing NGCC+SOEC Bug with New NL-Writer
2 participants