Skip to content

Installation

COBRA-k is a Python package hosted on PyPI, compatible with Python version 3.10 or later. If you have already installed an appropriate Python version on your system, you can install COBRA-k with pip:

pip install cobrak
Note: If you encounter any trouble due to a missing SCIP installation (which may happen on some systems), you have to install the free and open-source mixed-integer linear solver SCIP on your system. To do so, follow the SCIP download instructions here:

https://scipopt.org/index.php#download

or, if no matching download is provided for your system, the compilation instructions here:

https://scipopt.org/doc/html/INSTALL.php

Optional alternative installation for conda or mamba users

If you're using conda or mamba and want to have a clean COBRA-k environment, create an empty environment with Python and pip, activate it and install COBRA-k afterwards. E.g., on a plain bash console, the steps are as follows (again, any Python≥3.10 should work):

(base) conda create --name cobrak python=3.10 pip -c conda-forge
(base) conda activate cobrak
(cobrak) pip install cobrak
If you use mamba, just switch "conda" to "mamba".

Alternative installation for COBRA-k developers

If you want to directly play with COBRA-k's code base, follow the developer instructions in COBRA-k's README

Installation of third-party solvers

COBRA-k always comes pre-packaged with the quite capable open source linear (mixed-integer) solver HiGHS and the linear and non-linear program solver IPOPT (and on some systems, also automatically the solver SCIP). With this solver, all optimizations without integer variables provided by COBRA-k can be run.

Note

IPOPT comes pre-packages with the free linear subsolver MA27. However, for larger models, the much faster linear subsolver MA57 or one of its alternatives are highly recommended. See here on how to obtain them (e.g. a free academic license is provided):

https://licences.stfc.ac.uk/product/coin-hsl

In the cobrak.standard_solverssubpackage (which is further explained in later chapters), you can find IPOPT_MA57, an example on how to configure a Solverinstance for MA57. The standard solver IPOPTuses the slow MA27.

Additionally, all solvers supported by pyomo can be used. These include the very fast commercial mixed-integer linear solvers CPLEX and Gurobi. However, as both of these solvers are not automatically bundled with COBRA-k, these solvers and their Python bindings have to be installed seperately. Thereby, the Python bindings have to be installed in your COBRA-k Python environment.

For CPLEX, you can find installation instructions here:

For Gurobi, you can find installation instructions here: