Skip to content

Xpress 9.9+ backward compatibility and other updates#701

Merged
FabianHofmann merged 3 commits into
PyPSA:masterfrom
brunoficoxpress:feature/xpress-api-updates-9.9
May 20, 2026
Merged

Xpress 9.9+ backward compatibility and other updates#701
FabianHofmann merged 3 commits into
PyPSA:masterfrom
brunoficoxpress:feature/xpress-api-updates-9.9

Conversation

@brunoficoxpress
Copy link
Copy Markdown
Contributor

Restore Xpress 9.9+ API backward compatibility and fix deprecation warnings

Closes # (if applicable).

Changes proposed in this Pull Request

Xpress 9.8 renamed several API methods (e.g. loadproblemloadLP/loadMIP/loadQP/loadMIQP, addnamesaddNames, getDualgetDuals, etc.). PR #542 added try/except AttributeError wrappers to support both old and new API. These wrappers were inadvertently dropped in the Xpress direct-IO rewrite (787c4ce), reintroducing deprecation warnings when running against Xpress 9.9.

This PR restores the wrappers across all affected call sites in:

  • Problem loading: selects loadLP, loadMIP, loadQP, or loadMIQP based on problem type (integer variables / quadratic objective); falls back to loadproblem on Xpress < 9.8
  • Names: addNames() with addnames() fallback
  • File I/O: readProb, readBasis, writeBasis, writeBinSol with lowercase fallbacks
  • Solve helpers: postSolve, setLogFile with lowercase fallbacks
  • Solution retrieval: getDuals() (was incorrectly getDual())

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.

Copy link
Copy Markdown
Collaborator

@FabianHofmann FabianHofmann left a comment

Choose a reason for hiding this comment

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

wonderful! thanks for being so quick! In the refactoring I could not test newer xpress versions and according to the docs the loadproblem should still be valid, but this is better!

some of our projects still rely on xpress 9.4 which is the lower bound of the compat range. would you mind checking this version as well?

Comment thread linopy/solvers.py
Comment thread linopy/solvers.py Outdated

m = xpress.problem()
m.read(path_to_string(problem_fn))
m.readProb(path_to_string(problem_fn))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is old xpress compatible?

Comment thread linopy/solvers.py Outdated
@brunoficoxpress
Copy link
Copy Markdown
Contributor Author

wonderful! thanks for being so quick! In the refactoring I could not test newer xpress versions and according to the docs the loadproblem should still be valid, but this is better!

some of our projects still rely on xpress 9.4 which is the lower bound of the compat range. would you mind checking this version as well?

Good points, thanks for the quick turnaround! Updated the PR with your suggestions.

Tested on both 9.4 and 9.6 - all LP/MIP tests pass on both versions, all pre-9.8 fallbacks exercised correctly (loadproblem, read, addnames, getDual, etc.).

If you get any issues, or some other queries related to Xpress, feel free to reach out or tag me. Thank you for the nice work with the library :).

@FabianHofmann
Copy link
Copy Markdown
Collaborator

What a responsiveness ;) thanks bruno, merging now

@FabianHofmann FabianHofmann merged commit 7e2d3c1 into PyPSA:master May 20, 2026
19 of 21 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.

2 participants