6. Appendix: Installing the code in this primer and the required packages

Each tutorial outlines how to install all of the necessary software. The following is a consolidated guide to installing all of the software needed for the tutorials.

6.1. Requirements

Below is a list of all of the packages needed for the tutorials. Note, each tutorial only requires a subset of these packages. Please see the tutorials for information about the packages required for each tutorial.

  • CPLEX
  • Docker
  • Gimp
  • Git
  • Illustrator
  • Inkscape
  • libgit2
  • Meld
  • Open Babel
  • Pandoc
  • Pip
  • Python

6.2. How to install these tutorials

Run the following command to install the latest version from GitHub:

git clone git@github.com:KarrLab/intro_to_wc_modeling.git
pip install -e intro_to_wc_modeling

6.3. Detailed instructions to install the tutorials and all of the requirements

  1. Follow the instructions in Section 2.3.2 to build a Linux virtual machine

  2. Install several packages

    1. Enable the Docker Aptitude repository:

      curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
      sudo add-apt-repository \
         "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
         xenial \
         stable"
      sudo apt-get update
      
    2. Install several packages from the Mint repository:

      sudo apt-get install \
          apt-transport-https \
          ca-certificates \
          curl \
          docker-ce \
          gimp \
          git \
          ipython \
          ipython3 \
          inkscape \
          libgnome-keyring-dev \
          libpython-dev \
          libpython3-dev \
          meld \
          mysql-server \
          python \
          python3 \
          python-pip \
          python3-pip \
          software-properties-common \
          texlive \
          zip
      
    3. Install support for large file in Git repositories:

      curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
      sudo apt-get install git-lfs
      git lfs install
      
    4. Install libgit2:

      wget https://github.com/libgit2/libgit2/archive/v0.26.0.tar.gz -O /tmp/libgit2-0.26.0.tar.gz
      tar -xvvf /tmp/libgit2-0.26.0.tar.gz
      cd /tmp/libgit2-0.26.0
      cmake .
      make
      make install
      ldconfig
      
      echo "" >> ~/.bashrc
      echo "# libgit2" >> ~/.bashrc
      echo "export LIBGIT2=/usr/local" >> ~/.bashrc
      
    5. Install Open Babel:

      wget https://github.com/openbabel/openbabel/archive/openbabel-2-4-1.tar.gz -O /tmp/openbabel-2.4.1.tar.gz
      tar -xvvf /tmp/openbabel-2.4.1.tar.gz
      cd openbabel-openbabel-2-4-1
      mkdir build
      cd build
      cmake ..
      make
      make install
      ldconfig
      
    6. Install the CPLEX optimization package and the CPLEX Python binding

      1. Register for an academic account and download CPLEX from https://ibm.onthehub.com

      2. Install CPLEX:

        chmod ugo+x cplex_studio128.linux-x86-64.bin
        ./cplex_studio128.linux-x86-64.bin
        
      3. Install the Python binding:

        # Python 2.7
        cd /opt/ibm/ILOG/CPLEX_Studio128/cplex/python/2.7/x86-64_linux/
        pip2.7 install .
        
        # Python 3.6
        cd /opt/ibm/ILOG/CPLEX_Studio128/cplex/python/3.6/x86-64_linux/
        pip3.6 install .
        
    7. Optionally, install the COIN-OR Cbc optimization package and the CyLP Python binding:

      # set environment variables
      echo "" >> ~/.bashrc
      echo "# COIN-OR: CoinUtils, Cbc" >> ~/.bashrc
      echo "export COIN_INSTALL_DIR=/opt/coin-or/cbc" >> ~/.bashrc
      echo "export PATH=\"\${PATH}:/opt/coin-or/cbc/bin:/opt/coin-or/coinutils/bin\"" >> ~/.bashrc
      echo "export LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH}:/opt/coin-or/cbc/lib:/opt/coin-or/coinutils/lib\"" >> ~/.bashrc
      ~/.bashrc
      ldconfig
      
      # CoinUtils
      cd /tmp
      wget --no-check-certificate https://www.coin-or.org/download/source/CoinUtils/CoinUtils-2.10.14.tgz
      tar -xvvf CoinUtils-2.10.14.tgz
      cd CoinUtils-2.10.14
      mkdir build
      cd build
      mkdir -p /opt/coin-or/coinutils
      ../configure -C --prefix=/opt/coin-or/coinutils --enable-gnu-packages
      make
      make install
      
      # COIN-OR Cbc
      /tmp
      wget --no-check-certificate https://www.coin-or.org/download/source/Cbc/Cbc-2.8.5.tgz
      tar -xvvf Cbc-2.8.5.tgz
      cd Cbc-2.8.5
      mkdir build
      cd build
      ../configure -C --prefix=/opt/coin-or/cbc --enable-gnu-packages
      make
      make install
      
      # CyLP
      pip install numpy scipy
      pip install git+https://github.com/jjhelmus/CyLP.git@py3#egg=cylp
      
    8. Optionally, install the Gurobi optimization package and the Gurobi Python binding

      1. Get a Gurobi license from http://www.gurobi.com. Gurobi provides free licenses for academic users.

      2. Install Gurobi:

        apt-get install
        wget http://packages.gurobi.com/7.5/gurobi7.5.2_linux64.tar.gz
        tar xvfz gurobi7.5.2_linux64.tar.gz
        mv gurobi752 /opt/
        
        echo "" >> ~/.bashrc
        echo "# Gurobi" >> ~/.bashrc
        echo "export GUROBI_HOME=/opt/gurobi752/linux64" >> ~/.bashrc
        echo "export PATH=\"\${PATH}:\${GUROBI_HOME}/bin\"" >> ~/.bashrc
        echo "export LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH}:\${GUROBI_HOME}/lib\"" >> ~/.bashrc
        
      3. Use your license to activate Gurobi:

        /opt/gurobi752/linux64/bin/grbgetkey "<license>"
        
      4. Install the Python binding:

        cd /opt/gurobi752/linux64
        python setup.py install
        
    9. Optionally, install the MINOS optimization package and the MINOS Python binding:

      1. Request an academic license from Michael Saunders

      2. Use the following commands to compile MINOS:

        apt-get install csh gfortran
        cd /path/to/parent of quadLP.zip
        unzip quadLP.zip
        
        cd quadLP/minos56
        sed -i 's/FC        = gfortran/FC        = gfortran -fPIC/g' Makefile.defs
        make clean
        make
        cd /tmp/quadLP/minos56/test
        make minos
        ./run minos t1diet
        
        ../../../quadLP/qminos56
        sed -i 's/FC        = gfortran/FC        = gfortran -fPIC/g' Makefile.defs
        make clean
        make
        cd /tmp/quadLP/qminos56/test
        make minos
        ./run minos t1diet
        
      3. Use the following commands to install the MINOS Python binding:

        git clone https://github.com/SBRG/solvemepy.git
        cd solvemepy
        cp /path/to/quadLP/minos56/lib/libminos.a ./
        cp /path/to/quadLP/qminos56/lib/libquadminos.a ./
        pip install .
        
    10. Optionally, install the MOSEK optimization package and the Mosek Python binding:

      1. Request an academic license at https://license.mosek.com/academic

      2. Recieve a license by email

      3. Save the license to ${HOME}/mosek/mosek.lic

      4. Install Mosek:

        cd /tmp
        wget --no-check-certificate https://d2i6rjz61faulo.cloudfront.net/stable/8.1.0.37/mosektoolslinux64x86.tar.bz2
        tar -xvvf mosektoolslinux64x86.tar.bz2
        mv /tmp/mosek /opt/
        
        echo "" >> ~/.bashrc
        echo "# Mosek" >> ~/.bashrc
        echo "export PATH=\"\${PATH}:/opt/mosek/8/tools/platform/linux64x86/bin\"" >> ~/.bashrc
        echo "export LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH}:/opt/mosek/8/tools/platform/linux64x86/bin\"" >> ~/.bashrc
        
      5. Install the Python binding:

        # Python 2.7
        cd /opt/mosek/8/tools/platform/linux64x86/python/2/
        python2.7 setup.py install
        
        # Python 3.6
        cd /opt/mosek/8/tools/platform/linux64x86/python/3/
        python3.6 setup.py install
        
    1. Optionally, install the SoPlex optimization package and the SoPlex Python binding:

      1. Download SoPlex 3.1.1 from http://soplex.zib.de/#download

      2. Use the following commands to install SoPlex:

        cd /path/to/parent of soplex-3.1.1.tgz
        tar -xvvf soplex-3.1.1.tgz
        cd soplex-3.1.1
        mkdir build
        cd build
        cmake ..
        make
        make test
        make install
        
      3. Use the following commands to install the SoPlex Python binding:

        apt-get install libgmp-dev
        pip install cython
        git clone https://github.com/SBRG/soplex_cython.git
        cd soplex_cython
        cp /path/to/soplex-3.1.1.tgz .
        pip install .
        
    2. Optionally, install the XPRESS optimization package and the XPRESS Python binding

      1. Download and unpack XPRESS:

        cd /tmp
        wget --no-check-certificate https://clientarea.xpress.fico.com/downloads/8.4.4/xp8.4.4_linux_x86_64_setup.tar
        mkdir xp8.4.4_linux_x86_64_setup
        tar -xvvf xp8.4.4_linux_x86_64_setup.tar -C xp8.4.4_linux_x86_64_setup
        
      2. Get your host id:

        cd /tmp/xp8.4.4_linux_x86_64_setup
        utils/xphostid | grep -m 1 "<id>" | cut -d ">" -f 2 | cut -d "<" -f 1
        
      3. Use your host id to create a license at https://app.xpress.fico.com

      4. Save the license to /tmp/xpauth.xpr

      5. Install XPRESS. Note, the standard library directory needs to be added to the library path to prevent the OS from using the versions of libcrypto and libssl provided by XPRESS.:

        cd /tmp/xp8.4.4_linux_x86_64_setup
        ./install.sh
        
        echo "" >> ~/.bashrc
        echo "# XPRESS" >> ~/.bashrc
        echo "export XPRESSDIR=/opt/xpressmp" >> ~/.bashrc
        echo "export PATH=\"\${PATH}:\${XPRESSDIR}/bin\"" >> ~/.bashrc
        echo "export LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH}:/lib/x86_64-linux-gnu:\${XPRESSDIR}/lib\"" >> ~/.bashrc
        echo "export CLASSPATH=\"\${CLASSPATH}:\${XPRESSDIR}/lib/xprs.jar:\${XPRESSDIR}/lib/xprb.jar:\${XPRESSDIR}/lib/xprm.jar\"" >> ~/.bashrc
        echo "export XPRESS=\"\${XPRESSDIR}/bin\"" >> ~/.bashrc
        
      6. Setup the XPRESS Python binding:

        • Add XPRESS to your Python path:

          # Python 2.7
          echo "/opt/xpressmp/lib" | tee /usr/local/lib/python2.7/site-packages/xpress.pth
          
          # Python 3.6
          echo "/opt/xpressmp/lib" | tee /usr/local/lib/python3.6/site-packages/xpress.pth
          
        • Save the following package meta data to /usr/local/lib/python2.7/site-packages/xpress-8.4.4.egg-info for Python 2.7 and/or /usr/local/lib/python3.6/site-packages/xpress-8.4.4.egg-info for Python 3.6:

          Metadata-Version: 1.0
          Name: xpress
          Version: UNKNOWN
          Summary: FICO Xpress-Optimizer Python interface
          Home-page: http://www.fico.com/en/products/fico-xpress-optimization
          Author: Fair Isaac Corporation
          Author-email: UNKNOWN
          License: UNKNOWN
          Description:
              Xpress-Python interface
              Copyright (C) Fair Isaac 2016
              Create, modify, and solve optimization problems in Python using the Xpress Optimization suit
          Platform: UNKNOWN
          

      Note: If you want to install XPRESS onto a cluster, virtual machine, or docker image, you should first install a XPRESS license server on a static host and then install XPRESS using a floating license. See the XPRESS documentation for more information.

    3. Install the Sublime text editor:

      sudo add-apt-repository ppa:webupd8team/sublime-text-3
      sudo apt-get update
      sudo apt-get install sublime-text-installer
      
    4. Install the PyCharm IDE:

      sudo mv ~/Downloads/pycharm-community-2018.2.2.tar.gz /opt/
      sudo tar -xzf pycharm-community-2018.2.2.tar.gz
      cd pycharm-community-2018.2.2/bin
      ./pycharm.sh &
      
    5. Install the CircleCI command line tool:

      sudo curl -o /usr/local/bin/circleci https://circle-downloads.s3.amazonaws.com/releases/build_agent_wrapper/circleci
      sudo chmod +x /usr/local/bin/circleci
      
    6. Purchase and install Illustrator

  3. Configure the packages

    1. Configure your Git user name and email:

      git config --global user.name "John Doe"
      git config --global user.email "johndoe@example.com"
      
    2. Configure Git to store your GitHub password:

      cd /usr/share/doc/git/contrib/credential/gnome-keyring
      sudo make
      git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring
      
    3. Add the following to ~/.gitconfig to configure Git to use meld to visualize differences:

      [diff]
          tool = meld
      [difftool]
          prompt = false
      [difftool "meld"]
          cmd = meld "$LOCAL" "$REMOTE"
      
    4. Open Sublime and edit the following settings

      • Tools >> Install Package Control

      • Preferences >> Package control >> Install package >> AutoPEP8

      • Preferences >> Key Bindings:

        [
            {"keys": ["ctrl+shift+r"], "command": "auto_pep8", "args": {"preview": false}}
        ]
        
    5. Open PyCharm and set the following settings to configure PyCharm

      • File >> Settings >> Tools >> Python Integrated Tools >> Default test runner: set to py.test
      • Run >> Edit configurations >> Defaults >> Python tests >> py.test: add additional arguments “–capture=no”
      • Run >> Edit configurations >> Defaults >> Python tests >> Nosetests: add additional arguments “–nocapture”
    6. Configure Docker:

      sudo usermod -aG docker $USER
      
    7. Install Docker Compose:

      sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
      sudo chmod +x /usr/local/bin/docker-compose
      
    8. Optional, setup IDEs such as PyCharm to run code using a Docker image, such as, an image created with wc_env_manager.