Skip to content

Conversation

@Robbybp
Copy link
Contributor

@Robbybp Robbybp commented Dec 31, 2021

Summary/Motivation:

When debugging a model that has an unexpected overconstrained or underconstrained subsystem, a common task we want to do is remove a particular variable and constraint from the incidence graph/matrix, the equivalent of fixing a variable and deactivating a constraint. This can help narrow down the "cause" of the unexpected overconstrained/underconstrained system. This is currently possible by fixing/deactivating, then re-constructing the incidence graph, but would be nice to do this without altering the Pyomo model. This motivates the addition of a method on IncidenceGraphInterface for removing nodes from an incidence graph. Note this is "projecting" variables and constraints out of the model, rather than doing some sort of vertex elimination (where new edges/nonzeros would be added to the graph).

Changes proposed in this PR:

  • Add a remove method to IncidenceGraphInterface that removes columns and rows corresponding to provided variables and constraints from the cached incidence matrix
  • Basic tests for the new method

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 4, 2022

Codecov Report

Merging #2240 (1ffbc13) into main (e9dd0b9) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2240   +/-   ##
=======================================
  Coverage   83.05%   83.05%           
=======================================
  Files         607      607           
  Lines       76968    77000   +32     
=======================================
+ Hits        63923    63955   +32     
  Misses      13045    13045           
Flag Coverage Δ
linux 80.33% <100.00%> (+<0.01%) ⬆️
osx 70.62% <100.00%> (+<0.01%) ⬆️
other 80.30% <100.00%> (+<0.01%) ⬆️
win 77.44% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
pyomo/contrib/incidence_analysis/interface.py 98.17% <100.00%> (+0.21%) ⬆️
pyomo/contrib/incidence_analysis/util.py 100.00% <0.00%> (ø)

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 e9dd0b9...1ffbc13. Read the comment docs.

Copy link
Member

@jsiirola jsiirola left a comment

Choose a reason for hiding this comment

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

I think this is OK, but there is a small change that you can make to make the API a little more flexible,

@jsiirola jsiirola changed the title Add remove method to IncidenceGraphInterface Add remove_nodes method to IncidenceGraphInterface Jan 11, 2022
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