Based docplex notebook without cplex installed. Base to install cplex.
372
We will be using a notebook docker image to run cplex on your computer. We are using the free edition that cannot solve problems with more than 1000 variables or 1000 constraints.
Reference: https://github.com/legraina/docplex-notebook
First, you need to install docker. This software is managing all the images for you. You can download the adequate version depending on your system on https://store.docker.com/search?type=edition&offering=community. You will need to create account first. The different steps for mac are detailed below:









Once docker has started, we will test the system with a basic notebook.
Open a terminal, and run:
docker run --rm -it -p 8888:8888 jupyter/base-notebook
Once it's running, you will see:
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://(58a38e1b28f5 or 127.0.0.1):8888/?token=8f2df45e526c81bdbfe17e3a9d1da64e4a6edf6573e7cdca
Note that the token will be different.
Finally, open your favorite browser and go to http://127.0.0.1:8888/?token=8f2df45e526c81bdbfe17e3a9d1da64e4a6edf6573e7cdca (replace the token with yours).
You are now on jupyter notebook: you can create new notebook and be ready to code. You can kill the process when you have finished .

We will now install cplex inside a docker. First, you need an installer for cplex on linux 64 bits. It can be either the free edition or one that you already have. However, your version needs to support python 3.6 (12.8.0 supports it). To get the free edition, create an account on ibm and download it on: https://www.ibm.com/account/reg/us-en/signup?formid=urx-20028.






You may also refresh the page until it's activated. 
Now, download CPLEX.
8. Click another time on "Download".
9. On the download page, you must choose the version for Linux x86-64. Click on "I Agree" for this version to start the download. 
If you have any issues with IBM website (it can happen ...), just retry later or contact IBM support.
Now that you have the installer for Linux-64 downloaded, you need to install it within a container:
docker run --rm -v "/path/to/cplex/installer/directory:/home/jovyan/cplex" --name empty-docplex-notebook legraina/empty-docplex-notebook
You must give the absolute path to the directory where the cplex installer has been downloaded on your computer (instead of "/path/to/cplex/installer/directory") in order to be able to access the installer from within the container. For Windows, your firewall will block the volume, see this documentation: https://success.docker.com/article/error-a-firewall-is-blocking-file-sharing-between-windows-and-the-containers.
docker exec -it empty-docplex-notebook bash
./cplex/COSCE128LIN64.bin
You will then answer to the questions asked by the script:








cd CPLEX_Studio/cplex/python/3.6/x86-64_linux/ && python3 setup.py install
Now that cplex is installed in your container and ready to be used, we will save the image. First quit the container, with "ctrl+D" or by typing "exit". Then, commit the container:
docker commit empty-docplex-notebook docplex-notebook
You have now an image "docplex-notebook" ready to be used. You may now kill the container empty-docplex-notebook that you have started on 1. You can finally launch the your jupyter server and play with docplex.
docker run --rm -v "/path/to/some/exercices:/home/jovyan/work/exercises" -p "8888:8888" --name docplex-notebook docplex-notebook
You may add a volume with the command "-v": the idea is to load some existing notebooks within jupytherhub, for example some exercises. The volume command links the directory "/path/to/some/exercises" to the directory "/home/jovyan/work/exercises" inside the container. You need to use absolute paths for this command. Note that the volume is mounted inside the container, it means that if you add any file in the directory on your system or in the container, you will be able to access it on the other system immediately.
You can now connect to the jupytherhub (with the token given in the terminal output) and try to run the files that are either preloaded in the "examples" directory or the ones in the mounted directory "exercises".

Here, the SteelMill example in the cp directory of the examples.

MP documentation: https://ibmdecisionoptimization.github.io/docplex-doc/mp/index.html
CP documentation: https://rawgit.com/IBMDecisionOptimization/docplex-doc/master/docs/cp/index.html
Examples: https://github.com/IBMDecisionOptimization/docplex-examples
Content type
Image
Digest
Size
1.5 GB
Last updated
almost 8 years ago
docker pull legraina/empty-docplex-notebook