サブロウ丸

Sabrou-mal サブロウ丸

主にプログラミングと数学

SCIP version 8.0.3 コンパイル + おまけでpulpから実行

SCIP: https://www.scipopt.org/は言わずと知れたLP、MIPソルバ。

このプロジェクトにはfscip: https://ug.zib.de/も同封されています。これはSCIPのスレッド並列版ソルバです。

https://www.scipopt.org/images/scip_structure_landscape-compressed.png

Environment

Build

unzip scipoptsuite-8.0.3.zip
cd scipoptsuite-8.0.3/
mkdir build
cd build/
cmake ..

そしてエラー。

-- Found Boost: /usr/include (found suitable version "1.65.1", minimum required is "1.65.0")  
CMake Error at soplex/CMakeLists.txt:191 (message):
  ERROR:  If no GMP is linked, then the minimal Boost verion is 1.70.
   Found Boost version is 1.65.1.  Either provide newer Boost, link GMP,
  or disable Boost by setting BOOST=off.


-- Build shared libraries: ON
-- Build type: Release
CMake Warning at scip/CMakeLists.txt:117 (message):
  You are not using the automatic build option.

  If you have troubles configuring, you can consider setting AUTOBUILD=ON to
  try and find optional packages as available.


-- Finding symmetry computation program "bliss"
-- Support SYM: bliss
-- Finding ZLIB
-- Finding ZLIB - found
-- Finding Readline
-- Found Readline: /usr/include  
-- Finding Readline - found
-- Finding GMP
-- Could NOT find GMP (missing: GMP_INCLUDE_DIRS GMP_LIBRARIES) 
CMake Error at scip/CMakeLists.txt:345 (message):
  GMP not found, try specifying GMP_DIR.

  If you have troubles configuring, you can consider setting AUTOBUILD=ON to
  try and find optional packages as available.


-- Configuring incomplete, errors occurred!
See also "/home/hogehoge/usr/source/scipoptsuite-8.0.3/build/CMakeFiles/CMakeOutput.log".
See also "/home/hogehoge/usr/source/scipoptsuite-8.0.3/build/CMakeFiles/CMakeError.log".

install third-parties

エラー解消のために色々インストール。

# install tbb
cd _deps/tbb-src  # pwd = scipoptsuite-8.0.3/build/_deps/tbb-src
mkdir build
cd build
cmake ..
make -j 33
sudo make install

# install GMP
sudo apt-get install libgmp-dev

# install LAPACK
sudo apt-get install liblapack-dev pkg-config

# install IPOPT
git clone https://github.com/coin-or/Ipopt.git
cd Ipopt/
./configure 
make -j
sudo make install

# install boost-program-options
sudo apt-get install libboost-program-options-dev

# install boost (必要であれば)
# wget https://boostorg.jfrog.io/artifactory/main/beta/1.82.0.beta1/source/boost_1_82_0_b1.tar.gz
# tar -xf boost_1_82_0_b1.tar.gz 
# cd boost_1_82_0/
# ./bootstrap.sh 
# ./bootstrap.sh --prefix=/usr/local
# ./b2 install -j 32

install SCIP

cmake ..
make -j
sudo make install

pulpからの使用

version 2.7.0

git clone https://github.com/coin-or/pulp.git
cd pulp/
pip install .

example

solverを指定しているところに注目。

solver = SCIP()
# solver = FSCIP()  # use shared parallel version

version 2.7.0だとこれだけでscipを使える。ついでにfscipも使える。

from pulp import *

prob = LpProblem("test1", LpMinimize)

x = LpVariable("x", 0, 4)
y = LpVariable("y", -1, 1)
z = LpVariable("z", 0)

prob += x + 4 * y + 9 * z, "obj"
prob += x + y <= 5, "c1"
prob += x + z >= 10, "c2"
prob += -y + z == 7, "c3"

# SCIPソルバを使用
solver = SCIP()
# solver = FSCIP()  # use shared parallel version
prob.solve(solver=solver)

# Print the status of the solved LP
print("Status:", LpStatus[prob.status])

# Print the value of the variables at the optimum
for v in prob.variables():
    print(v.name, "=", v.varValue)

# Print the value of the objective
print("objective=", value(prob.objective))