diff --git a/linopy/solvers.py b/linopy/solvers.py index a121a2b5..023dcb5d 100644 --- a/linopy/solvers.py +++ b/linopy/solvers.py @@ -48,6 +48,7 @@ "mosek", "copt", "mindopt", + "knitro", ] # Solvers that don't need a solution file when keep_files=False @@ -145,6 +146,9 @@ class xpress_Namespaces: # type: ignore[no-redef] except coptpy.CoptError: pass +with contextlib.suppress(ModuleNotFoundError, ImportError): + pass + quadratic_solvers = [s for s in QUADRATIC_SOLVERS if s in available_solvers] logger = logging.getLogger(__name__) @@ -176,6 +180,7 @@ class SolverName(enum.Enum): COPT = "copt" MindOpt = "mindopt" PIPS = "pips" + Knitro = "knitro" def path_to_string(path: Path) -> str: diff --git a/pyproject.toml b/pyproject.toml index b5105230..2370d0f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ docs = [ "gurobipy==11.0.2", "ipykernel==6.29.5", "matplotlib==3.9.1", + "knitro>=15.0.1", ] dev = [ "pytest", @@ -70,6 +71,7 @@ dev = [ "types-requests", "gurobipy", "highspy", + "knitro", ] solvers = [ "gurobipy", @@ -81,6 +83,7 @@ solvers = [ "coptpy!=7.2.1", "xpress; platform_system != 'Darwin' and python_version < '3.11'", "pyscipopt; platform_system != 'Darwin'", + "knitro>=15.0.1", ] [tool.setuptools.packages.find]