LoginSignup
11
5

More than 1 year has passed since last update.

【学生版】CPLEXのインストール手順に関する情報があまりなかったので書いてみた

Last updated at Posted at 2019-12-12

追記(2021/5/27)

CPLEXのバージョンが変わりました.近々新しいバージョンに対応した記事を書く予定です.

はじめに

 数理計画問題のモデラーであるPuLPは,デフォルトのソルバーとしてCOINが使用されていますが,COINでは計算に15時間程度要してしまう問題に遭遇してしまったため,IBM社の有償ソルバーであるCPLEXを使いたいと思いました.
 しかし,インストールの手順が書いてある記事をいくつか見てみてみると,サイトの情報が古く,インストールに手間取ってしまいました.そこで今回はインストール手順をまとめてみたいと思います.
 環境はWindows 10 Home(64bit版), Pythonのバージョンは3.7.1であり,IBM ILOG CPLEX 12.10.0をインストールします.

インストール手順

 まずはここをクリックして,IBM社のホームページへアクセスします.次に学生版・教員版を無料で入手する(英語版)をクリックします.するとData Scienceと書かれたページの右下にILOG CPLEX Optimization Studioというのが出ますので,その下にあるRegistar or login to access this resourceをクリックします.するとアカウント作成を求められるので,「大学発行のメールアドレス」を使ってアカウントを作ります.
 ログイン後は,先ほどのページのRegistar or login to access this resourceの部分が,「Download v12.10」に変化するので,それをクリックします.すると,Find by part number resultsというページにいくのですが,ページの下部へスクロールします.
IBM Software Downloads - Google Chrome 2019_12_12 21_01_38.png
 上の画像のページにたどり着けたでしょうか.この画面では,Select Allは選択せずに,ページの下部から自分のPC環境にあったものをインストールします.今回はWindows10 の64bit版なので,上から2番目です.さらに下へ行くと,同意を求められるので,I agreeと同意します.そしてDownload Nowをクリックすると,下のような画面が出ます.
IBM Software Downloads - Google Chrome 2019_12_12 21_11_12.png
 install/re-install Download Directorをクリックすると,
IBM Download Director のインストール - Google Chrome 2019_12_12 21_12_55.png
このような画面が出るので,Download Directorのインストールをクリックします.
IBM Download Director のインストール - Google Chrome 2019_12_12 21_13_09.png

IBM Download Director Setup 2019_12_12 21_14_26.png
ステップ3のような画面にはならず,?となりますが,close windowを押せば,インストールが開始されます.

その後は画面に従ってに操作します.最後にVisual Studio の最新版のインストールが求められるので,ダウンロードします.またJavaの最新版も途中のタイミングでインストールする必要がでてくるため,古いバージョンのJavaがインストールされていると,アンインストールをする必要にがあります.

最後にコマンドプロンプトにcplexと打って

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>

となれば成功です.たまにPATHが通っていない場合があるのでシステム環境変数の編集をしてPATHを通します.デフォルトの場合には,C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\bin\x64_win64にあります.

また,コマンドプロンプト上で,
pythonと入力して,


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

と入力してみてください.

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

このように表示されますが,Solver class 'pulp.solvers.CPLEX_CMD'が,passed.になっていれば,pulpでCPLEXをソルバーとして選択できます.PuLPでのソルバーの切り替えは,たとえばこの文献を見てください.

おわりに

 既出でしたらすみません.COINでは計算に15時間要した問題も,CPLEXは1時間足らずで解いてしまったので驚きでした.それでは楽しいCPLEXライフを!

11
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
5