Skip to content

Conversation

@brunoficoxpress
Copy link

Summary

This PR updates the linopy Xpress solver integration to support the new Python API introduced in Xpress 9.8+, while maintaining full backward compatibility with Xpress 9.6+ through fallback mechanisms.

Changes

1. API Method Migration (linopy/solvers.py)

All method calls updated with try/except blocks for backward compatibility:

  • m.read()m.readProb()
  • m.setlogfile()m.setLogFile()
  • m.readbasis()m.readBasis()
  • m.writebasis()m.writeBasis()
  • m.writebinsol()m.writeBinSol()
  • m.postsolve()m.postSolve()
  • m.getnamelist()m.getNameList()
  • m.getDual()m.getDuals()

2. Status Handling Improvements (linopy/solvers.py)

  • Replaced numeric status codes with xpress.SolStatus enum constants
  • Updated solver status checks to use xpress.enums.SolveStatus.STOPPED
  • Improved code readability and maintainability

3. Exception Handling (linopy/solvers.py)

  • Replaced broad Exception catching with specific xpress.SolverError and xpress.ModelError
  • Prevents masking of unrelated errors while catching only solver-specific issues

4. IIS (Irreducible Infeasible Subset) Detection (linopy/model.py)

  • solver_model.iisall()solver_model.IISAll() with fallback
  • solver_model.getiisdata()solver_model.getIISData() with fallback
  • Fixed mypy type checking errors by declaring variables before try/except blocks

5. Unicode Handling (linopy/constraints.py)

  • Added Windows console encoding fix for Unicode characters (≤, ≥) in constraint display

6. Documentation Updates

  • Updated Xpress documentation URLs in doc/index.rst and doc/prerequisites.rst

Testing

Test Environment

  • Xpress 9.8.0: Primary development version
  • Xpress 9.6.0: Backward compatibility validation

Test Results

  • ✅ All 414 Xpress-specific tests PASSED
  • ✅ All infeasibility detection tests PASSED (IIS functionality verified)
  • ✅ Pre-commit hooks (Black, Ruff): All passed
  • ✅ Backward compatibility confirmed through fallback mechanisms

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.

1 participant