Installation¶
System Requirements¶
Can I check if everything is properly set up before I start?¶
MATLAB¶
Please ensure that you have a compatible and working MATLAB
installation.
The list of compatible solvers is available here.
No support is provided for versions older than R2014b.
MATLAB is released on a twice-yearly schedule. After the latest release (version b),
it may be a couple of months before certain methods with dependencies
on other software become compatible. For example, the latest releases of MATLAB
may not be compatible with the existing solver interfaces,
necessitating an update of the MATLAB interface provided by the solver developers,
or an update of the COBRA Toolbox, or both.
git¶
You can check if you have a working installation of git by typing in
the Terminal (on linux and macOS) or cmd (in
Windows, not Git Bash):
$ git --version
If installed properly, this will return git version 2.13.1 [...] or
similar with another version number.
curl¶
You can check if you have a working installation of curl by typing
in the terminal (cmd on Windows, not Git Bash):
$ curl --version
which will return curl 7.51.0 [...] or similar with another version
number if installed properly. If you encounter any issues with curl, please
post in our .
What if my system is not properly configured?¶
Linux (Ubuntu or Debian)¶
$ sudo apt-get install git-all curl
There is a known issue on Matlab 2016b (or earlier) with a default library that is used to access web resources. Please have a look at the FAQ.
macOS¶
In order to install git, install the Xcode Command Line
Tools.
For curl, follow the instructions
here.
Download and installation¶
Download this repository (the folder
./cobratoolbox/will be created). You can clone the repository using:$ git clone --depth=1 https://github.com/opencobra/cobratoolbox.git cobratoolbox
Please note the --depth=1in the clone command. Run this command inTerminal(on
and
) or in Git Bash(on
) -
not in
. Although not recommended, you can download the
repository as a compressed archive.Change to the folder
cobratoolbox/and run from
>> initCobraToolbox
Solver compatibility¶
Linux Ubuntu¶
| SolverName | R2021b | R2021a | R2020b | R2020a |
|---|---|---|---|---|
| IBM CPLEX 20.10 | ![]() |
![]() |
![]() |
![]() |
| IBM CPLEX 12.10 | ![]() |
![]() |
![]() |
![]() |
| IBM CPLEX 12.8 | ![]() |
![]() |
![]() |
![]() |
| GUROBI 9.1.1 | ![]() |
![]() |
![]() |
![]() |
| TOMLAB CPLEX 8.6 | ![]() |
![]() |
![]() |
![]() |
| MOSEK 9.2 | ![]() |
![]() |
![]() |
![]() |
| GLPK | ![]() |
![]() |
![]() |
![]() |
| DQQ MINOS | ![]() |
![]() |
![]() |
![]() |
| PDCO | ![]() |
![]() |
![]() |
![]() |
macOS 10.13+¶
| SolverName | R2021b | R2021a | R2020b | R2020a |
|---|---|---|---|---|
| IBM CPLEX 20.10 | ![]() |
![]() |
![]() |
![]() |
| IBM CPLEX 12.10 | ![]() |
![]() |
![]() |
![]() |
| IBM CPLEX 12.8 | ![]() |
![]() |
![]() |
![]() |
| GUROBI 9.1.1 | ![]() |
![]() |
![]() |
![]() |
| TOMLAB CPLEX 8.6 | ![]() |
![]() |
![]() |
![]() |
| MOSEK 9.2 | ![]() |
![]() |
![]() |
![]() |
| GLPK | ![]() |
![]() |
![]() |
![]() |
| DQQ MINOS | ![]() |
![]() |
![]() |
![]() |
| PDCO | ![]() |
![]() |
![]() |
![]() |
Windows 10¶
| SolverName | R2021b | R2021a | R2020b | R2020a |
|---|---|---|---|---|
| IBM CPLEX 20.10 | ![]() |
![]() |
![]() |
![]() |
| IBM CPLEX 12.10 | ![]() |
![]() |
![]() |
![]() |
| IBM CPLEX 12.8 | ![]() |
![]() |
![]() |
![]() |
| GUROBI 9.1.1 | ![]() |
![]() |
![]() |
![]() |
| TOMLAB CPLEX 8.6 | ![]() |
![]() |
![]() |
![]() |
| MOSEK 9.2 | ![]() |
![]() |
![]() |
![]() |
| GLPK | ![]() |
![]() |
![]() |
![]() |
| DQQ MINOS | ![]() |
![]() |
![]() |
![]() |
| PDCO | ![]() |
![]() |
![]() |
![]() |
Legend
: compatible with the COBRA Toolbox (tested)
: not compatible with the COBRA Toolbox (tested)
: possibly incompatibile with the COBRA Toolbox (problems reported)
Notes
- Make sure to install the correct Tomlab version for your version of
macOS. Please note that there is a different Tomlab installer for MATLABR2017a+. - Only actively supported interfaces are evaluated for compatibility.
- The
matlabsolver interface is compatible with all actively supported MATLAB versions. - The interfaces
cplex_directandtomlab_snoptbear the same compatibility pattern astomlab_cplex. - The interface
quadMinosbears the same compatibility pattern asdqqMinos. - The interface
lindo_oldbears the same compatibility pattern aslindo_legacy.
Binaries and Compilers¶
For convenience, we provide
glpk_mex and
libSBML-5.17+ in
/external.
Binaries for these libraries are provided in a submodule for Mac OS X 10.6 or later (64-bit), GNU/Linux Ubuntu 14.0+ (64-bit), and Microsoft Windows 7+ (64-bit). For unsupported OS, please refer to their respective building instructions (glpk_mex, libSBML).
Read more on the compatibility with SBML-FBCv2 here.
Solver installation¶
Please make sure that you install a compatible solver. Check the
compatibility
here.
Platform-specific instructions are marked with
- Windows -

- macOS -

- linux -

Most steps require superuser or administrator rights (sudo).
Make sure that you replace <ver> with the respective
version of the installed solver when setting the environment
variables.
TOMLAB¶
Download
TOMLAB/CPLEXfrom here, where you can also downloadTOMLAB/SNOPT. You must purchase thetomlab.liclicense separately.
In a terminal window, navigate to the download directory of
Tomlaband do the following:$ chmod +x <filename>.bin $ sudo ./<filename>.bin
Run the tomlab-win64-setup_<ver>.exeas an administrator.
Double-click on tomlab-osx64-setup.app.Follow the installation instructions and install
tomlabin:
: /optsuch that you will have a folder/opt/tomlab.
: C:\such that you will have a folderC:\tomlab.
: /Applicationssuch that you will have a folder/Applications/tomlab.
Copy the tomlab.liclicense to the folder/opt/tomlaband change its permissions (you must have superuser orsudorights):$ sudo chmod 644 tomlab.lic
Copy the tomlab.liclicense to the folderC:\tomlab.
Copy the tomlab.liclicense to the folder/Applications/tomlab.
Set the environment variable by editing your ~/.bashrcfile:$ nano ~/.bashrcAppend the following lines, hit the
ESCkey, then save and exit by typingCTRL-Xand hittingENTER:export TOMLAB_PATH="/opt/tomlab"Reload your
~/.bashrc:$ source ~/.bashrc
In order to set the
environment variables on Windows, please follow the instructions
here.
IBM ILOG CPLEX¶
Download the
CPLEXinstallation binary. The limited community edition is here. CPLEX is free for students (and academics) and further information how to register and download is here.
Add executepermission to binary$ chmod +x <cplexbinary>.bin
Run the installer binary as superuser, follow the installation
procedure, and accept the default installation path.$ sudo ./<cplexbinary>.bin
Run
cplex_studio<ver>.win-x86-64.exeas an administrator. Follow the installation instructions and installCPLEXinC:\Program Files\IBM\ILOG\CPLEX_Studio<ver>.
Set the environment variable by editing your ~/.bashrcfile:$ nano ~/.bashrcAppend the following lines, hit the
ESCkey, then save and exit by typingCTRL-Xand hittingENTER.On
:export ILOG_CPLEX_PATH="/opt/ibm/ILOG/CPLEX_Studio<ver>"On
:export ILOG_CPLEX_PATH="/Applications/IBM/ILOG/CPLEX_Studio<ver>"Reload your
~/.bashrc:$ source ~/.bashrc
Make sure that you select
Yes, update the PATH variable.. You can also follow the instructions here.
If you installed cplex in a non default folder (or if you are using the community version) please make sure, that you create an environment variable ILOG_CPLEX_PATHpointing to the directory containing the CPLEX matlab bindings. This can also be done by creating a startup.m file as detailed here here. In this startup file add the following command:setenv('ILOG_CPLEX_PATH','C:\<yourCPLEXPath>\CPLEX_Studio<ver>\cplex\matlab\<arch>')where<yourCPLEXPath>is the path to cplex,<ver>is the installed version and<arch>is the architecture identifier.
GUROBI¶
Register and log in here
Request license from the download center and retrieve
YOUR-LICENSE-KEY-FROM-SITEDownload the
Gurobioptimizer from here
Navigate to the directory where Gurobiwas downloaded and enter$ tar -xvzf <archive>.tar.gz $ sudo mv gurobi<ver> /opt/. $ cd /opt/gurobi<ver>/linux64/bin/
Run Gurobi-<ver>-win64.msiand follow the installation instructions. Accept the default pathC:\gurobi<ver>\.
Run gurobi<ver>_mac64.pkgand follow the installation instructions. Accept the default path/Applications/gurobi<ver>/.
Edit the bashsettings to include paths$ nano ~/.bashrcAppend the following lines, hit the
ESCkey, then save and exit by typingCTRL-Xand hittingENTER:export GUROBI_HOME="/opt/gurobi<ver>/linux64" export PATH="${PATH}:${GUROBI_HOME}/bin" export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib" export GUROBI_PATH="${GUROBI_HOME}"
Reload your
~/.bashrc:$ source ~/.bashrc
In order to set the environment variables on Windows, please follow the
instructions here.
Activate your license by running:$ grbgetkey YOUR-LICENSE-KEY-FROM-SITEYou will be prompted
In which directory would you like to store the Gurobi license key file? [hit Enter to store it in /home/<userid>]:
Hit
ENTER.
Browse to
Start > All Programs > Gurobi < VER> > Gurobi Interactive Shell (<ver>). This should prompt to enter the license keyYOUR-LICENSE-KEY-FROM-SITE. Enter this key and hiterENTER.
Verify that Gurobiis successfully installed by launching theGurobiprompt:$ gurobi.sh
Browse to
Start > All Programs > Gurobi < VER> > Gurobi Interactive Shell (<ver>).
Browse to /Applicationsand double-click onGurobi<ver>to start the Gurobi shell.This command should give you the prompt for
Gurobi. Exit by enteringexit()or hittingCTRL-Don your keyboard.
MOSEK¶
Download
MOSEKas an archive hereApply for a license here. A free academic license is here. You will receive an email with your
mosek.licfile.
Save (or move) the downloaded archive tar.bz2to/opt/.(you must have superuser orsudorights).
Save (or move) the
downloaded archive tar.bz2to/Applications/.(you must have superuser orsudorights).
Navigate to /optand extract the archivecd /opt $ tar xvjf <filename>.tar.bz2
Run moseksetupwin64x86.msiand selectTypicalinstallation. This will installmosekinC:\Program Files\Mosek.
Browse to /Applicationsand double-click the archive to uncompress.
It is important to run the script python /Applications/mosek/<ver>/tools/platform/osx64x86/bin/install.py, which makes important updates to the installation.
Configure the PATHandMOSEKLM_LICENSE_FILEenvironment variables in~/.bashrcby editing yourbashrcfile$ nano ~/.bashrcAppend the following lines, hit the
ESCkey, then save and exit by typingCTRL-Xand hittingENTER.On

export PATH=/opt/mosek/<ver>/:$PATH export MOSEKLM_LICENSE_FILE=/opt/mosek/
On

export MOSEK_PATH=/Applications/mosek/<ver>
export MOSEK_PATH=*YOUR*PATH*/mosektoolslinux64x86/mosek/10.1/toolbox/r2017a; export PATH=$MOSEK_PATH:$PATH export MOSEKLM_LICENSE_FILE=/Applications/mosek/
Reload your
~/.bashrc:$ source ~/.bashrc
In order to
set the environment variables on Windows, please follow the
instructions
here.
Copy the license file mosek.licto/opt/mosek/.
Copy the
license file mosek.lictoC:\Users\<yourUsername>\mosek\.
Copy the license file mosek.licto/Applications/mosek/.
Verify that MOSEKis correctly installed by using the following command in your terminal$ /opt/mosek/<ver>/tools/platform/linux64x86/bin/./msktestlicThis command should give an output similar to this:
Problem Name : Objective sense : min Type : LO (linear optimization problem) Constraints : 1 Cones : 0 Scalar variables : 5000 Matrix variables : 0 Integer variables : 0 Optimizer started. Mosek license manager: License path: /opt/mosek/mosek.lic Mosek license manager: Checkout license feature 'PTS' from flexlm. Mosek license manager: Checkout time 0.01. r: 0 status: 0 Interior-point optimizer started. Presolve started. Eliminator started. Freed constraints in eliminator : 0 Eliminator terminated. Eliminator - tries : 1 time : 0.00 Lin. dep. - tries : 0 time : 0.00 Lin. dep. - number : 0 Presolve terminated. Time: 0.00 Interior-point optimizer terminated. Time: 0.00. Optimizer terminated. Time: 0.02 ************************************ A license was checked out correctly. ************************************
By browsing to Start > All Programs > Mosek Optimization Tools, you can run Test license system. This should open a window and display the output as shown above.
In a terminal, run:$ /Applications/mosek//tools/platform/osx64x86/bin/./msktestlicThis should produce an output as shown above.
Test the installation¶
You may test your installation by running from

>> testAll
If you need support, please feel free to post your question in our
.