Skip to content

KKT Transform Code Refactor#3881

Merged
blnicho merged 50 commits intoPyomo:mainfrom
ChrisLaliwala:kkt-transform-refactor
Apr 29, 2026
Merged

KKT Transform Code Refactor#3881
blnicho merged 50 commits intoPyomo:mainfrom
ChrisLaliwala:kkt-transform-refactor

Conversation

@ChrisLaliwala
Copy link
Copy Markdown
Contributor

@ChrisLaliwala ChrisLaliwala commented Mar 24, 2026

Fixes # .

Summary/Motivation:

This PR refactors the KKT transformation code (see PR #3860) to make it more efficient. In the original PR, it was suggested by @jsiirola that the order of operations be reversed to avoid repeated work and the use of unintuitive data structures.

Changes proposed in this PR:

  • Refactors code to increase efficiency
  • Simplifies API for getting multipliers/components from model

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.

ChrisLaliwala and others added 29 commits February 24, 2026 12:20
Co-authored-by: Bethany Nicholson <blnicho@users.noreply.github.com>
Co-authored-by: John Siirola <jsiirola@users.noreply.github.com>
Co-authored-by: John Siirola <jsiirola@users.noreply.github.com>
Co-authored-by: John Siirola <jsiirola@users.noreply.github.com>
Co-authored-by: John Siirola <jsiirola@users.noreply.github.com>
Co-authored-by: John Siirola <jsiirola@users.noreply.github.com>
Co-authored-by: John Siirola <jsiirola@users.noreply.github.com>
…mo into kkt-transform

need to fix merge conflicts.
@ChrisLaliwala ChrisLaliwala changed the title Kkt transform refactor KKT Transform Code Refactor Mar 24, 2026
@ChrisLaliwala ChrisLaliwala requested a review from jsiirola March 31, 2026 13:48
Copy link
Copy Markdown
Contributor

@emma58 emma58 left a comment

Choose a reason for hiding this comment

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

Apologies for the much-delayed review. This looks really good! I have a few minor nits, and then one (perhaps more controversial) naming question.

Comment thread pyomo/core/plugins/transform/kkt.py Outdated
Comment thread pyomo/core/plugins/transform/kkt.py Outdated
Comment thread pyomo/core/plugins/transform/kkt.py Outdated
Comment thread pyomo/core/plugins/transform/kkt.py Outdated
Comment thread pyomo/core/plugins/transform/kkt.py Outdated

active_objs[0].deactivate()

def get_object_from_multiplier(self, model, multiplier_var):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer this be named get_constraint_from_multiplier even though it could return a Var if it is a multiplier on bounds. But I'm open to being argued with.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have to admit that I would prefer object (for consistency with component_data_objects) or component (for the same reason).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was afraid you would say that! :P OK, let's leave it then.

f"The KKT multiplier: {multiplier_var.name}, does not exist on {model.name}."
)

def get_multiplier_from_object(self, model, component):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same naming thought as above

Comment thread pyomo/core/plugins/transform/kkt.py Outdated
@blnicho blnicho merged commit 37084d9 into Pyomo:main Apr 29, 2026
29 of 30 checks passed
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.

5 participants