1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Pulp - Ubuntuで自分で用意したCBCソルバーを利用する

Last updated at Posted at 2021-04-27

Google Colaboratory環境などを想定

ソルバーを入手

ここの「Cbc-master-bionic-linux-x86_64-gcc7.tgz」をダウンロード。
解凍して任意のディレクトリに配置。
解凍先ディレクトリの/bin/cbcが実行するソルバーファイルとなる。

パスを通す

import sys
sys.path.append('保存場所/bin/')

 設定ファイルを更新

パスを通す代わりに、ソルバーの設定ファイルを編集しても良い。
pulp.__path__ を実行し、設定ファイルのパスを確認。
設定ファイルのディレクトにあるpulp.cfg.linux を開き
CbcPath =に、上記で配置した/bin/cbcのパスを設定。
Google Claboratory上で実行する場合はエラーの元になるので、
パスを通すやり方を推奨。

実行

pulp.COIN_CMD にて実行されるソルバーが変更される。
マルチスレッド対応しているので、threadsに適切なスレッド数を設定することで高速化が期待される。
※設定スレッド数を増やすことで逆に計算時間が増えることも有る。

ソルバー指定の例
solver = pulp.COIN_CMD(threads=2, timeLimit=1800)
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?