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

Fix handling of POW in Baron writer #2693

Merged
merged 4 commits into from
Jan 18, 2023
Merged

Conversation

jsiirola
Copy link
Member

@jsiirola jsiirola commented Jan 13, 2023

Fixes # .

Summary/Motivation:

@shermanjasonaf noted a bug in the Baron writer where expressions of the form "m.x ** (c + m.p * m.y)" where m.p is a mutable Param with value 0 would be written to the BAR file as "x ^ (3 + 0*y)", which is not legal (Baron sees the right argument as variable).

This PR resolves the issue by re-evaluating fixed arguments to resolve them to numeric constants, and adds tests exercising this edge case,

Changes proposed in this PR:

  • Resolve fixed arguments to POW to numbers when generating Baron 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 Jan 18, 2023

Codecov Report

Base: 87.06% // Head: 87.06% // Decreases project coverage by -0.01% ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2693      +/-   ##
==========================================
- Coverage   87.06%   87.06%   -0.01%     
==========================================
  Files         757      757              
  Lines       84585    84591       +6     
==========================================
+ Hits        73645    73647       +2     
- Misses      10940    10944       +4     
Flag Coverage Δ
linux 84.45% <100.00%> (-0.01%) ⬇️
osx ?
other 84.63% <100.00%> (+<0.01%) ⬆️
win 81.79% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
pyomo/repn/plugins/baron_writer.py 81.84% <100.00%> (+0.27%) ⬆️
pyomo/contrib/mindtpy/iterate.py 79.54% <0.00%> (-1.82%) ⬇️
pyomo/common/download.py 92.17% <0.00%> (-0.44%) ⬇️
pyomo/core/expr/visitor.py 93.40% <0.00%> (+0.15%) ⬆️

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.

@jsiirola jsiirola merged commit 15d5e9f into Pyomo:main Jan 18, 2023
@jsiirola jsiirola deleted the baron-pow-with-fixed branch January 18, 2023 20:46
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.

2 participants