Installation

RBApy requires an optimization solver (Cplex, Gurobi or GlpK) and can be installed with Python 3.8 or any later version compatible with the optimization solver. We recommend to use Cplex or Gurobi to simulate large models.

1. Install Python

If Python is not installed on your own computer, you need to install it. Go to the website https://www.python.org/downloads/. Download the appropriate python release for your system and install it.

2. Install CPLEX or GUROBI

2.1 CPLEX

IBM® CPLEX is an optimization software package. RBApy uses this package for the generation and checking of feasibility of the Linear Programming (LP) problem. CPLEX requires a licence to run, and one can be obtained for free if you have an academic email address. This you can do as follows:

After you have successfuly downloaded the package you need to install it and setup the Python API.

2.1.1 On Unix systems

Open a terminal, navigate to executable and run following commands (make sure to adapt the executable name if necessary):

chmod u+x cplex_studio2212.linux_x86_64.bin
./cplex_studio2212.linux_x86_64.bin 

Make sure to remember CPLEX's installation path. For the newest cplex version (22.1.2 or later), the CPLEX Python interface is no longer delivered inside CPLEX Optimization Studio, but can be installed directly from PyPI or from Anaconda, using the commands

 pip install cplex (conda install cplex for Anaconda)
 pip install docplex (conda install docplex for Anaconda)  
The first command installs the Community Edition CPLEX and CP Optimizer runtimes as well as a low-level Python interface to CPLEX. The second installs the higher-level "docplex" Python package which includes CPLEX and CP Optimizer modelling and solving support. The Community Edition runtimes which come as standard are limited in the size of optimization problems that they can solve. To upgrade the Community Edition runtimes and remove size limitations, use the command "docplex" which was installed when you installed the "docplex" module with pip or conda. Running:
 docplex config --upgrade Full_Path_To_This_CPLEX_Studio_Installation  
will upgrade the CPLEX and CP Optimizer Python runtimes from the Community Edition version to a size-unlimited version.

You can check that CPLEX was correctly installed by running:

python
import cplex

2.1.2 On Windows systems

Open the navigator, navigate to the location of the CPLEX installer and run it. Make sure to remember CPLEX's installation path, as we will need to navigate to it to set up the Python API.
Then open a batch console with administrative permissions. Go to the directory where CPLEX is installed, then go the sub-directory named python.

cd Path\To\Cplex\cplex\python\x64_win64

A file named setup.py should be present. Set up the Python API by typing in the console (Adapt the following line to the version of Python and to the Python path on your computer).

Path\To\Python\python.exe setup.py install

You can check that CPLEX was correctly installed by running:

Path\To\Python\python.exe
import cplex

2.1.3 On MAC systems

Open a terminal, navigate to executable and run following commands (make sure to adapt the executable name if necessary):

chmod u+x cplex_studio12.7.1.osx.bin 
./cplex_studio12.7.1.osx.bin 

Do remember the installation path of CPLEX, as we will need to navigate to it to set up the Python API. Go to the directory where CPLEX is installed, then go the sub-directory named python. A file named setup.py should be present. Be sure that you have administrator permissions, then set up the Python API by typing

python setup.py install

Here is an example with a default Mac installation, cplex 12.7 and python3.5:

cd /Users/my_username/Applications/IBM/ILOG/CPLEX_Studio1271/cplex/python/3.5/x86-64_osx
python setup.py install
# alternative: install to custom location
python setup.py install --home yourPythonPackageshome/cplex

You can check that CPLEX was correctly installed by running:

python
import cplex

2.2 GUROBI

To use RBApy with Gurobi, ask for an academic licence on the Gurobi's website. Save your license to your home directory (~/gurobi.lic) or to the appropriate location for your OS (e.g., /opt/gurobi/gurobi.lic for Linux). Then install the gurobipy package by typing:
pip install gurobipy

Then check the installation by typing

python
import gurobipy

3. Install RBApy package

We recommend that you use the stable relase of the RBApy package which you can download either via Pypi, either from our github page, and find under the tab Releases. To install RBApy via Pypi, open a console and type:

pip install rbapy
Alternatively, if you wish to clone the repository, make sure you checkout the commit containing the tag referencing the latest release, as shown:
git clone https://github.com/RBAgroup/RBApy
cd RBApy
git checkout tags/v2.0

Navigate to the directory containing RBApy, be sure that you have administrator permissions and install it by typing:
On UNIX and MAC systems,

cd path/to/rbapy/package
python setup.py install

On Windows systems,

cd path\to\rbapy\package
Path\To\Python\python.exe setup.py install

The Path\To\Python should be replaced by a Python installation path valid on your computer.

This step may take some time, as it will install missing dependencies.

After this step is finished, you can check that RBApy was correctly installed by running:

python
import rba

or for Windows systems

Path\To\Python\python.exe
import rba