[PYTHON] [Student version] I didn't have much information about the installation procedure of CPLEX, so I wrote it.

Introduction

PuLP, a modeler of mathematical planning problems, uses CBC-COIN as the default solver, but CBC-COIN ran into a problem that required about 15 hours to calculate, so IBM's paid solver. I want to use CPLEX. I'm grateful that software that costs about 27,000 yen a month for students (or in an academic environment) can be used for free ... However, even if I looked at some sites where the installation procedure was written, it took a long time to install because the information on the site was old, so I would like to summarize the installation procedure this time. (Maybe this article will be seen by juniors in the seminar next year, so I will write it as carefully as possible.) The environment is Windows 10 Home (64bit version), Python version is 3.7.1 (added here), and IBM ILOG CPLEX 12.10.0 is installed.

Installation procedure

First, go to here. Then click Get Student / Teacher Edition for free (English version). Then, ILOG CPLEX Optimization Studio will appear at the bottom right of the page that says Data Science, so click Registar or login to access this resource below it. Then you will be asked to create an account, so create an account using the email address issued by the university. After logging in, the Registar ... part of the previous page will change to "Download v12.10", so click on it. Then, I go to the page called Find by part number results, but I don't understand the upper part, so I don't enter anything and scroll to the bottom of the page. IBM Software Downloads - Google Chrome 2019_12_12 21_01_38.png Did you get to the page in the image above? Here, select All is not selected, and the one that suits your PC environment is installed from the bottom. This time it is the 64-bit version of Windows 10, so it is the second from the top. If you go further down, you will be asked for your consent, so I agree with I agree. Then click Download Now and you should see the screen below. IBM Software Downloads - Google Chrome 2019_12_12 21_11_12.png Click install / re-install Download Director IBM Download Director のインストール - Google Chrome 2019_12_12 21_12_55.png A screen like this will appear. Click Install Download Director. IBM Download Director のインストール - Google Chrome 2019_12_12 21_13_09.png IBM in the world cannot damage your computer! Click Save with a strong will. (Please take responsibility for your actions...!) IBM Download Director Setup 2019_12_12 21_14_26.png The screen does not look like step 3, but ???, but if you press the close window, the installation will start (for some reason).

After that, follow the instructions on the screen. Finally, you will be asked to install the latest version of Visual Studio, so download it. It seems that the latest version of Java was also installed at some point ... If there is an old one before installing the latest version, an uninstaller is required, so "I want to use CPLEX soon !!" Let's wait without being impatient ...

Finally, type cplex at the command prompt (the command prompt is where you type commands directly into your PC, press Win + R keys at the same time, then type cmd).

cmd.exe


Welcome to IBM(R) ILOG(R) CPLEX(R) Interactive Optimizer 12.10.0.0
  with Simplex, Mixed Integer & Barrier Optimizers

Copyright IBM Corp. 1988, 2019.  All Rights Reserved.

Type 'help' for a list of available commands.
Type 'help' followed by a command name for more
information on commands.

CPLEX>

If it becomes, it is a success. Occasionally the PATH is not available (I shut down my PC, then turn it on again and type cplex, where'cplex' is an internal or external command, an operable program or batch file. It is not recognized as.), And it becomes ???.), Edit the system environment variable and put it in the PATH. In the default case, it should be in C: \ Program Files \ IBM \ ILOG \ CPLEX_Studio1210 \ cplex \ bin \ x64_win64.

Oh, on the command prompt Type python


>python
>>>import pulp
>>>pulp.pulpTestAll()

Please enter.

>>> pulp.pulpTestAll()
         Testing zero subtraction
         Testing inconsistant lp solution
         Testing continuous LP solution
         Testing maximize continuous LP solution
         Testing unbounded continuous LP solution
         Testing Long Names
         Testing repeated Names
         Testing zero constraint
         Testing zero objective
         Testing LpVariable (not LpAffineExpression) objective
         Testing Long lines in LP
         Testing LpAffineExpression divide
         Testing MIP solution
         Testing MIP solution with floats in objective
         Testing MIP relaxation
         Testing feasibility problem (no objective)
         Testing an infeasible problem
         Testing an integer infeasible problem
         Testing column based modelling
         Testing dual variables and slacks reporting
         Testing fractional constraints
         Testing elastic constraints (no change)
         Testing elastic constraints (freebound)
         Testing elastic constraints (penalty unchanged)
         Testing elastic constraints (penalty unbounded)
* Solver <class 'pulp.solvers.PULP_CBC_CMD'> passed.
Solver <class 'pulp.solvers.CPLEX_DLL'> unavailable
         Testing zero subtraction
         Testing inconsistant lp solution
         Testing continuous LP solution
         Testing maximize continuous LP solution
         Testing unbounded continuous LP solution
         Testing Long Names
         Testing repeated Names
         Testing zero constraint
         Testing zero objective
         Testing LpVariable (not LpAffineExpression) objective
         Testing LpAffineExpression divide
         Testing MIP solution
         Testing MIP solution with floats in objective
         Testing MIP relaxation
         Testing feasibility problem (no objective)
         Testing an infeasible problem
         Testing an integer infeasible problem
         Testing column based modelling
         Testing column based modelling with empty constraints
         Testing dual variables and slacks reporting
         Testing fractional constraints
         Testing elastic constraints (no change)
         Testing elastic constraints (freebound)
         Testing elastic constraints (penalty unchanged)
         Testing elastic constraints (penalty unbounded)
* Solver <class 'pulp.solvers.CPLEX_CMD'> passed.
Solver <class 'pulp.solvers.CPLEX_PY'> unavailable
Solver <class 'pulp.solvers.COIN_CMD'> unavailable
Solver <class 'pulp.solvers.COINMP_DLL'> unavailable
Solver <class 'pulp.solvers.GLPK_CMD'> unavailable
Solver <class 'pulp.solvers.XPRESS'> unavailable
Solver <class 'pulp.solvers.GUROBI'> unavailable
Solver <class 'pulp.solvers.GUROBI_CMD'> unavailable
Solver <class 'pulp.solvers.PYGLPK'> unavailable
Solver <class 'pulp.solvers.YAPOSIB'> unavailable
>>>

However, if Solver class'pulp.solvers.CPLEX_CMD' is passed., You can select CPLEX as the solver in pulp. See this document for switching this solver.

Assuming that the juniors of the seminar will see it later, I will put a reference article on what "passing the PATH" is. This person's article was very easy to understand! https://qiita.com/sta/items/63e1048025d1830d12fd

in conclusion

I'm sorry if it has already appeared, I was surprised that CPLEX solved the problem that took 15 hours to calculate with COIN in less than 1 hour. Let's have a fun CPLEX life!

Recommended Posts

[Student version] I didn't have much information about the installation procedure of CPLEX, so I wrote it.
I didn't understand the behavior of numpy's argsort, so I will summarize it.
I didn't understand the Resize of TensorFlow so I tried to summarize it visually.
I looked at the meta information of BigQuery & tried using it
[Super basics of Python] I learned the basics of the basics, so I summarized it briefly.
The case that the installation of pip became easier before I knew it
About the virtual environment of python version 3.7
I didn't know the basics of Python
I studied about Linux, so I summarized it.
[Fundamental Information Technology Engineer Examination] I wrote the algorithm of Euclidean algorithm in Python.
Somehow the code I wrote worked and I was impressed, so I will post it
The math of some entrance exam question is awkward to think about, so I left it to python after all