Skip to content

Re-introduce knitro context closure and export solver quantities#633

Open
finozzifa wants to merge 10 commits intomasterfrom
close_knitro_context
Open

Re-introduce knitro context closure and export solver quantities#633
finozzifa wants to merge 10 commits intomasterfrom
close_knitro_context

Conversation

@finozzifa
Copy link
Collaborator

@finozzifa finozzifa commented Mar 24, 2026

Closes # (if applicable).

Changes proposed in this Pull Request

The Knitro Python API stores in the knitro context object all quantities related to a problem optimization. The API is built in such a way that the quantities can be extracted with dedicated methods only from the knitro context.

In order to make the linopy interface more flexible and avoid to extract in linopy all the relevant quantities, I exposed in PR #600 the knitro context and removed the lines that freed it once the optimization was completed (in fact when a knitro context is freed, all the information it contains is lost).

This however proved to be problematic in terms of memory usage.

Therefore, in this PR, I am not exposing anymore the knitro context, I free the knitro context and compute the necessary quantities from within linopy and export them as part of the Result object.

FYI @danielelerede-oet

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

@finozzifa finozzifa requested a review from FabianHofmann March 24, 2026 09:24
@finozzifa finozzifa changed the title code: re-introduce knitro context closure and export solver quantities Re-introduce knitro context closure and export solver quantities Mar 24, 2026
@FabianHofmann
Copy link
Collaborator

@finozzifa could you add a release note?

@finozzifa
Copy link
Collaborator Author

@finozzifa could you add a release note?

Done!

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