Skip to content

Conversation

@FabianHofmann
Copy link
Collaborator

Summary

This PR adds support for the Artelys Knitro solver to linopy.

Changes

  • Added automatic detection of the knitro Python package to the available solvers list
  • Implemented Knitro solver class with support for solving MPS/LP files
  • Registered Knitro capabilities in the solver registry (quadratic objectives, LP file names, no solution file needed)
  • Added tests for the Knitro solver (properly skip when package not installed)
  • Mapped Knitro status codes to linopy's Status system

Implementation Details

The Knitro solver implementation follows the existing patterns in linopy:

  • File-based solver using MPS/LP files (similar to CPLEX, COPT)
  • Proper status code mapping for optimization results
  • Solution and dual value extraction using Knitro's Python API
  • Support for solver options and logging

Testing

  • Added unit tests that verify Knitro functionality
  • Tests properly skip when Knitro package is not installed
  • All existing tests continue to pass

Notes

  • Direct API support (solve_problem_from_model) is not implemented in this initial version but can be added later
  • Knitro is a powerful nonlinear optimization solver that also handles linear and quadratic problems efficiently
  • Users need to install the knitro package separately and have a valid license to use this solver

Closes #[issue_number] (if applicable)

- Add Knitro detection to available_solvers list
- Implement Knitro solver class with MPS/LP file support
- Add solver capabilities for Knitro (quadratic, LP names, no solution file)
- Add tests for Knitro solver functionality
- Map Knitro status codes to linopy Status system
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