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 ImageLink.

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.

Windows

Please download the git tools for Windows from here. During the installation process, please ensure that you select Use Git Bash and optional Unix tools from the Windows Command prompt. In addition, please make sure that you select Checkout as-is, commit Unix-style line endings.

git windows   git windows.

Download and installation

  1. 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
    

    warning Please note the --depth=1 in the clone command. Run this command in Terminal (on macOS and linux) or in Git Bash (on windows) - not in matlab. Although not recommended, you can download the repository as a compressed archive.

  2. Change to the folder cobratoolbox/ and run from matlab

    >> initCobraToolbox
    

Solver compatibility

Linux Ubuntu

SolverName R2021b R2021a R2020b R2020a
IBM CPLEX 20.10 warning warning warning warning
IBM CPLEX 12.10 white_check_mark white_check_mark white_check_mark white_check_mark
IBM CPLEX 12.8 white_check_mark white_check_mark white_check_mark white_check_mark
GUROBI 9.1.1 white_check_mark white_check_mark white_check_mark white_check_mark
TOMLAB CPLEX 8.6 white_check_mark white_check_mark white_check_mark white_check_mark
MOSEK 9.2 white_check_mark white_check_mark white_check_mark white_check_mark
GLPK white_check_mark white_check_mark white_check_mark white_check_mark
DQQ MINOS white_check_mark white_check_mark white_check_mark white_check_mark
PDCO white_check_mark white_check_mark white_check_mark white_check_mark

macOS 10.13+

SolverName R2021b R2021a R2020b R2020a
IBM CPLEX 20.10 warning warning warning warning
IBM CPLEX 12.10 white_check_mark white_check_mark white_check_mark white_check_mark
IBM CPLEX 12.8 white_check_mark white_check_mark white_check_mark white_check_mark
GUROBI 9.1.1 white_check_mark white_check_mark white_check_mark white_check_mark
TOMLAB CPLEX 8.6 white_check_mark white_check_mark white_check_mark white_check_mark
MOSEK 9.2 white_check_mark white_check_mark white_check_mark white_check_mark
GLPK white_check_mark white_check_mark white_check_mark white_check_mark
DQQ MINOS white_check_mark white_check_mark white_check_mark white_check_mark
PDCO white_check_mark white_check_mark white_check_mark white_check_mark

Windows 10

SolverName R2021b R2021a R2020b R2020a
IBM CPLEX 20.10 warning warning warning warning
IBM CPLEX 12.10 white_check_mark white_check_mark white_check_mark white_check_mark
IBM CPLEX 12.8 white_check_mark white_check_mark white_check_mark white_check_mark
GUROBI 9.1.1 white_check_mark white_check_mark white_check_mark white_check_mark
TOMLAB CPLEX 8.6 white_check_mark white_check_mark white_check_mark white_check_mark
MOSEK 9.2 white_check_mark white_check_mark white_check_mark white_check_mark
GLPK white_check_mark white_check_mark white_check_mark white_check_mark
DQQ MINOS white_check_mark white_check_mark white_check_mark white_check_mark
PDCO white_check_mark white_check_mark white_check_mark white_check_mark

Legend

  • white_check_mark : compatible with the COBRA Toolbox (tested)
  • warning : not compatible with the COBRA Toolbox (tested)
  • warning : 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 MATLAB R2017a+.
  • Only actively supported interfaces are evaluated for compatibility.
  • The matlab solver interface is compatible with all actively supported MATLAB versions.
  • The interfaces cplex_direct and tomlab_snopt bear the same compatibility pattern as tomlab_cplex.
  • The interface quadMinos bears the same compatibility pattern as dqqMinos.
  • The interface lindo_old bears the same compatibility pattern as lindo_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.

gcc compiler

You can download gcc from here. You may find information on how to install gcc here.

gfortran compiler

You can install gfortran by following the instructions here.

Solver installation

warning Please make sure that you install a compatible solver. Check the compatibility here.

Platform-specific instructions are marked with

  • Windows - windows
  • macOS - macOS
  • linux - linux

warning Most steps require superuser or administrator rights (sudo).

pencil Make sure that you replace <ver> with the respective version of the installed solver when setting the environment variables.

TOMLAB

  1. Download TOMLAB/CPLEX from here, where you can also download TOMLAB/SNOPT. You must purchase the tomlab.lic license separately.

  2. linux In a terminal window, navigate to the download directory of Tomlab and do the following:

    $ chmod +x <filename>.bin
    $ sudo ./<filename>.bin
    

    windows Run the tomlab-win64-setup_<ver>.exe as an administrator.

    macOS Double-click on tomlab-osx64-setup.app.

  3. Follow the installation instructions and install tomlab in:

    • linux: /opt such that you will have a folder /opt/tomlab.
    • windows: C:\ such that you will have a folder C:\tomlab.
    • macOS: /Applications such that you will have a folder /Applications/tomlab.
  4. linux Copy the tomlab.lic license to the folder /opt/tomlab and change its permissions (you must have superuser or sudo rights):

    $ sudo chmod 644 tomlab.lic
    

    windows Copy the tomlab.lic license to the folder C:\tomlab. macOS Copy the tomlab.lic license to the folder /Applications/tomlab.

  5. macOS linux Set the environment variable by editing your ~/.bashrc file:

    $ nano ~/.bashrc
    

    Append the following lines, hit the ESC key, then save and exit by typing CTRL-X and hitting ENTER:

    export TOMLAB_PATH="/opt/tomlab"
    

    Reload your ~/.bashrc:

    $ source ~/.bashrc
    

    windows In order to set the environment variables on Windows, please follow the instructions here.

IBM ILOG CPLEX

  1. Download the CPLEX installation binary. The limited community edition is here. CPLEX is free for students (and academics) and further information how to register and download is here.

  2. macOS linux Add execute permission to binary

    $ chmod +x <cplexbinary>.bin
    
  3. macOS linux Run the installer binary as superuser, follow the installation procedure, and accept the default installation path.

    $ sudo ./<cplexbinary>.bin
    

    windows Run cplex_studio<ver>.win-x86-64.exe as an administrator. Follow the installation instructions and install CPLEX in C:\Program Files\IBM\ILOG\CPLEX_Studio<ver>.

  4. macOS linux Set the environment variable by editing your ~/.bashrc file:

    $ nano ~/.bashrc
    

    Append the following lines, hit the ESC key, then save and exit by typing CTRL-X and hitting ENTER.

    On linux:

    export ILOG_CPLEX_PATH="/opt/ibm/ILOG/CPLEX_Studio<ver>"
    

    On macOS:

    export ILOG_CPLEX_PATH="/Applications/IBM/ILOG/CPLEX_Studio<ver>"
    

    Reload your ~/.bashrc:

    $ source ~/.bashrc
    

    windows #ff0000 Make sure that you select Yes, update the PATH variable.. You can also follow the instructions here.

    windows warning 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_PATH pointing 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

  1. Register and log in here

  2. Request license from the download center and retrieve YOUR-LICENSE-KEY-FROM-SITE

  3. Download the Gurobi optimizer from here

  4. linux Navigate to the directory where Gurobi was downloaded and enter

    $ tar -xvzf <archive>.tar.gz
    $ sudo mv gurobi<ver> /opt/.
    $ cd /opt/gurobi<ver>/linux64/bin/
    

    windows Run Gurobi-<ver>-win64.msi and follow the installation instructions. Accept the default path C:\gurobi<ver>\.

    macOS Run gurobi<ver>_mac64.pkg and follow the installation instructions. Accept the default path /Applications/gurobi<ver>/.

  5. linux Edit the bash settings to include paths

    $ nano ~/.bashrc
    

    Append the following lines, hit the ESC key, then save and exit by typing CTRL-X and hitting ENTER:

    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
    

    windows In order to set the environment variables on Windows, please follow the instructions here.

  6. macOS linux Activate your license by running:

    $ grbgetkey YOUR-LICENSE-KEY-FROM-SITE
    

    You 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.

    windows Browse to Start > All Programs > Gurobi < VER> > Gurobi Interactive Shell (<ver>). This should prompt to enter the license key YOUR-LICENSE-KEY-FROM-SITE. Enter this key and hiter ENTER.

  7. linux Verify that Gurobi is successfully installed by launching the Gurobi prompt:

    $ gurobi.sh
    

    windows Browse to Start > All Programs > Gurobi < VER> > Gurobi Interactive Shell (<ver>).

    macOS Browse to /Applicationsand double-click on Gurobi<ver> to start the Gurobi shell.

    This command should give you the prompt for Gurobi. Exit by entering exit() or hitting CTRL-D on your keyboard.

MOSEK

  1. Download MOSEK as an archive here

  2. Apply for a license here. A free academic license is here. You will receive an email with your mosek.lic file.

  3. linux Save (or move) the downloaded archive tar.bz2 to /opt/. (you must have superuser or sudo rights). macOS Save (or move) the downloaded archive tar.bz2 to /Applications/. (you must have superuser or sudo rights).

  4. linux Navigate to /opt and extract the archive

    cd /opt
    $ tar xvjf <filename>.tar.bz2
    

    windows Run moseksetupwin64x86.msi and select Typical installation. This will install mosek in C:\Program Files\Mosek.

    macOS Browse to /Applications and double-click the archive to uncompress. warning It is important to run the script python /Applications/mosek/<ver>/tools/platform/osx64x86/bin/install.py, which makes important updates to the installation.

  5. macOS linux Configure the PATH and MOSEKLM_LICENSE_FILE environment variables in ~/.bashrc by editing your bashrc file

    $ nano ~/.bashrc
    

    Append the following lines, hit the ESC key, then save and exit by typing CTRL-X and hitting ENTER.

    On linux

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

    On macOS

    export MOSEK_PATH=/Applications/mosek/<ver>
    export PATH=$MOSEK_PATH:$PATH
    export MOSEKLM_LICENSE_FILE=/Applications/mosek/
    

    Reload your ~/.bashrc:

    $ source ~/.bashrc
    

    windows In order to set the environment variables on Windows, please follow the instructions here.

  6. linux Copy the license file mosek.lic to /opt/mosek/. windows Copy the license file mosek.lic to C:\Users\<yourUsername>\mosek\. macOS Copy the license file mosek.lic to /Applications/mosek/.

  7. linux Verify that MOSEK is correctly installed by using the following command in your terminal

    $ /opt/mosek/<ver>/tools/platform/linux64x86/bin/./msktestlic
    

    This 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.
    ************************************
    

    windows 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.

    macOS In a terminal, run:

    $ /Applications/mosek//tools/platform/osx64x86/bin/./msktestlic
    

    This should produce an output as shown above.

Test the installation

You may test your installation by running from matlab

>> testAll

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