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

Sympy fix for complex numbers #1140

Merged
merged 4 commits into from
Oct 26, 2019
Merged

Sympy fix for complex numbers #1140

merged 4 commits into from
Oct 26, 2019

Conversation

jsiirola
Copy link
Member

Fixes #1139

Summary/Motivation:

In certain situations, sympy's diff() will return expressions with re() and im() nodes in the tree. We will tell sympy that all variables are expected to be real variables, so that some situations can avoid the introduction of complex nodes.

Changes proposed in this PR:

  • inform sympy that all pyomo variables are expected to be real values
  • add processing of the sympy.Abs expression node

Legal Acknowledgement

By contributing to this software project, I 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.

This tells sympy to treat all Pyomo variables as real values,
simplifying some results returned by differentiate().  Fixes Pyomo#1139.
@codecov
Copy link

codecov bot commented Oct 25, 2019

Codecov Report

Merging #1140 into master will increase coverage by 0.13%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1140      +/-   ##
==========================================
+ Coverage    70.4%   70.53%   +0.13%     
==========================================
  Files         532      532              
  Lines       80841    80841              
==========================================
+ Hits        56915    57021     +106     
+ Misses      23926    23820     -106
Impacted Files Coverage Δ
pyomo/core/expr/sympy_tools.py 100% <100%> (ø) ⬆️
pyomo/pysp/util/config.py 65.35% <0%> (+0.14%) ⬆️
pyomo/pysp/scenariotree/tree_structure.py 83.5% <0%> (+0.22%) ⬆️
pyomo/pysp/scenariotree/manager.py 88.01% <0%> (+0.31%) ⬆️
pyomo/solvers/plugins/smanager/pyro.py 83.33% <0%> (+0.79%) ⬆️
pyomo/pysp/scenariotree/action_manager_pyro.py 83.04% <0%> (+1.16%) ⬆️
pyomo/pysp/util/configured_object.py 76.23% <0%> (+1.48%) ⬆️
pyomo/pysp/util/misc.py 63.76% <0%> (+1.73%) ⬆️
pyomo/pysp/scenariotree/server_pyro.py 80% <0%> (+5.5%) ⬆️
pyomo/pysp/scenariotree/manager_worker_pyro.py 80.52% <0%> (+16.84%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be7d286...2fb9e93. Read the comment docs.

@jsiirola jsiirola merged commit 26b85a0 into Pyomo:master Oct 26, 2019
@jsiirola jsiirola deleted the sympy-fix branch October 26, 2019 23:39
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.

Error whil using mindtpy
4 participants