-
Notifications
You must be signed in to change notification settings - Fork 20
Add FICO Xpress Optimizer backend support #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- added status enums - added support for string attribute/controls ids - kept int attribute/controls id for internal use - fixed broken defaults in binded arguments - added missing _add_linear_constraint overloads - added missing get_value overloads - added missing pprint overloads - added missing set_objective overloads - fixed a whole lot of defect during initial testing - implemented xpress.py model - added a simple partial implementation of the tsp example - callback system - license error message - default message cb - OUTPUTLOG 1 by default - CB from main thread to avoid issues with Python GIL - Made XpressModel CALLBACK mode more explicit and checked - cb_get_* queries - Lazy and usercut mapped to XPRSaddcuts - Auto submit solution after CB end - xpress.Model wrap of RawModel in python CB - XpressModel move ctor to enable wrapping-unwrapping - Removed deprecated attribute - Flatten out XpressModel fields - Fixed repeated set_callback calls - Removed mutex (not used) - Original XpressModel used also in cbs - Added forgotte cb bindings - Complete tsp_xpress.py callback test - xpress_model.hpp comments - Cleaned up xpress_model*.cpp - NLP objective + SOC + Exp Cones - Postsolve and minor fixing - Version check - Ptr ownership bugfix + stream flushing
|
Thanks for your hard work on this heroic PR! I will look into your PR next week. |
|
I have gone through the code changes and your implementation is quite neat. I am not familiar with the C API of xpress and our existing tests can ensure the basic correctness of solver interfaces. My only concern is that we should contain the header files (with C API) in POI, so that the project can be built standalone. This is important because I need to build and distribute wheels via GitHub actions and do not want to bother to download the whole package of solvers. Is it OK with you? If so, I will include the headers and modify the cmakelists accordingly. |
|
Hi, I completely understand the need to include the headers for standalone builds. |
|
Hi! Since I can't predict how long it might take to get a definitive answer about including This header contains only the minimal type declarations, function signatures, and constants needed by POI to compile against the Xpress API. I hope this works for you. Let me know if there are any other improvements you'd like to see! |
|
Great! |
|
Windows: The I also find the
Update: these issues have been easily fixed with the help of AI. |
Hi!
This PR adds support for the FICO Xpress Optimizer to PyOptInterface. The implementation follows the established patterns from the Gurobi and COPT backends, adapting Xpress-specific features to fit the PyOptInterface design.
Supported Features
Implementation Notes
Xpress-Specific Adaptations:
Global Environment Management: Xpress requires global initialization/cleanup via
XPRSinit/XPRSfree. This is handled through a reference-countedXpressEnvclass to ensure proper lifecycle management across multiple model instances.Quadratic Term Scaling: Xpress uses different conventions for quadratic terms:
The implementation handles this transparently in
set_objectiveandadd_quadratic_constraint.Callback Threading: Xpress callbacks receive thread-local problem clones. The implementation uses a swap mechanism to ensure the user interacts with the correct problem instance, with proper GIL management. Callbacks are serialized via
XPRS_MUTEXCALLBACKS=1to avoid race conditions. Note: this implementation does not support Python's new free-threading feature (PEP 703). If you plan to add free-threading support to PyOptInterface, we can adapt the Xpress backend to enable parallel callbacks, which Xpress supports natively.Callback Interface: PyOptInterface's single callback with context enumeration is mapped to Xpress's native multi-callback interface internally, maintaining consistency with other backends. Xpress provides additional callback contexts and APIs that allow customization of other optimization aspects (e.g., branching rules). Let me know if you're interested in extending PyOptInterface to support these advanced features.
Parameter Access: The implementation preserves Xpress naming conventions: "controls" for read/write optimizer parameters, "attributes" for read-only model and optimization status information.
Testing
All existing PyOptInterface tests pass with the Xpress backend. Additionally, a TSP callback example demonstrates the integration of optimization callbacks with lazy constraint generation.
Documentation
User documentation has been added in
docs/source/xpress.md, covering installation, basic usage, and Xpress-specific considerations.Please let me know if any design choices need adjustment to better align with PyOptInterface conventions, or if you have questions about the implementation. Happy to discuss further details or make modifications as needed.
Thanks for the great library!
Best,
Francesco