Skip to content

Conversation

@jsiirola
Copy link
Member

Fixes # .

Summary/Motivation:

This implements the first 2 proposals from #2180:

  • Var values are checked against both the domain and the bounds
  • Values failing the domain or bounds checks generate a warning and not an exception

Changes proposed in this PR:

  • Emit warnings when setting a Var value outside the domain or bounds
  • Make set_value() and fix() implementations consistent across Var, BooleanVar, AutoLinkedBinaryVar and AutoLinkedBooleanVar
  • Resolve bug in contrib.constraints_to_var_bounds that could move a var value outside its bounds
  • Update examples to avoid initializing outside domain
  • Update documentation to not set Var values outside bounds

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 Nov 17, 2021

Codecov Report

Merging #2196 (a887d6d) into main (f8c4b04) will decrease coverage by 0.02%.
The diff coverage is 92.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2196      +/-   ##
==========================================
- Coverage   82.99%   82.96%   -0.03%     
==========================================
  Files         607      607              
  Lines       76774    76756      -18     
==========================================
- Hits        63718    63684      -34     
- Misses      13056    13072      +16     
Impacted Files Coverage Δ
...mo/contrib/preprocessing/plugins/bounds_to_vars.py 82.35% <80.00%> (-0.19%) ⬇️
pyomo/core/base/boolean_var.py 77.60% <88.00%> (-0.09%) ⬇️
pyomo/core/base/var.py 92.77% <92.85%> (+0.42%) ⬆️
pyomo/gdp/disjunct.py 85.85% <100.00%> (-0.43%) ⬇️
pyomo/util/calc_var_value.py 100.00% <100.00%> (ø)
pyomo/contrib/gdpopt/util.py 90.29% <0.00%> (-3.74%) ⬇️
pyomo/contrib/mindtpy/single_tree.py 51.16% <0.00%> (-2.64%) ⬇️

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 f8c4b04...a887d6d. Read the comment docs.

Copy link
Contributor

@michaelbynum michaelbynum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great.

@mrmundt mrmundt merged commit ac85e32 into Pyomo:main Nov 23, 2021
@jsiirola jsiirola deleted the var-pep-2180 branch November 26, 2021 20:23
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.

4 participants