Matlab 2017bでYALMIP, SeDuMiを使えるようにしたメモ.
環境
- macOS: 10.11.6-x86_64
- Xcode: 8.2.1
YALMIP
サイト(
https://yalmip.github.io/download/)からダウンロードして解凍する.適当な場所に置く(~/MATLAB/YALMIP-master など).
Matlabでパスを通す.
addpath(genpath('/Users/hoge/Documents/MATLAB/YALMIP-master'))
savepath
SeDuMi
サイト(
https://github.com/sqlp/sedumi)からダウンロード.macOS 64bit用のバイナリ(**.mexmaci64)を適当な場所に配置してパスを通す.
テストしてみるとSDPが解けていない.
yalmiptest
| SDP| N/A| Unknown problem in solver (Turn on 'debug' in sdpsettings) (関数または変数 'y_s' が未定義です。)|
SeDuMiバイナリの作成
どうやらsedumiがインストールできていないよう.
sedumi([1; 1], 1, [1 1])
無効な MEX ファイル '/Users/hoge/Documents/MATLAB/sedumi-master/whichcpx.mexmaci64':
dlopen(/Users/hoge/Documents/MATLAB/sedumi-master/whichcpx.mexmaci64, 6): Library not loaded:
@loader_path/libmwlapack.dylib
Referenced from: /Users/hoge/Documents/MATLAB/sedumi-master/whichcpx.mexmaci64
Reason: image not found。
エラー: pretransfo (line 211)
cpx = whichcpx(K);
エラー: sedumi (line 261)
[A,b,c,K,prep,origcoeff] = pretransfo(A,b,c,K,pars);
mexファイルがおかしいと言われるのでコンパイルしてみる.github上のソースファイルから修正が必要.
ここを参考に:
Found the link for the fix.
-#define FORT(x) FORTRAN_WRAPPER(x)
+#define FORT(x) x
at line at line 45 in blksdp.h
修正したらSeDuMiのファイル直下でinstall_sedumiをオプション付きで実行する.
install_sedumi -rebuild
できた.
yalmiptest
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| Test| Solution| Solver message|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| Core functionalities| N/A| Successfully solved (YALMIP)|
| LP| Correct| Successfully solved (LINPROG)|
| LP| Correct| Successfully solved (LINPROG)|
| QP| Correct| Successfully solved (QUADPROG)|
| QP| Correct| Successfully solved (QUADPROG)|
| SOCP| Correct| Successfully solved (SeDuMi-1.3)|
| SOCP| Correct| Successfully solved (SeDuMi-1.3)|
| SOCP| Correct| Successfully solved (SeDuMi-1.3)|
| SDP| Correct| Successfully solved (SeDuMi-1.3)|
| SDP| Correct| Successfully solved (SeDuMi-1.3)|
| SDP| Correct| Successfully solved (SeDuMi-1.3)|
| SDP| Correct| Successfully solved (SeDuMi-1.3)|
| MAXDET| Correct| Successfully solved (SeDuMi-1.3)|
| MAXDET| Correct| Successfully solved (SeDuMi-1.3)|
| Infeasible LP| N/A| Infeasible problem (LINPROG)|
| Infeasible QP| N/A| Infeasible problem (QUADPROG)|
| Infeasible SDP| N/A| Infeasible problem (SeDuMi-1.3)|
| Moment relaxation| Correct| Successfully solved (SeDuMi-1.3)|
| Sum-of-squares| Correct| Successfully solved (SeDuMi-1.3)|
| Bilinear SDP| N/A| No suitable solver|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
設定
Note that YALMIP uses historical default settings for SeDuMi. According to the user guide for SeDuMi 1.1, the YALMIP defaults should be updated as below:
S = sdpsettings('solver', 'sedumi', 'sedumi.eps', 1e-8, ...
'sedumi.cg.qprec', 1, 'sedumi.cg.maxiter', 49, ...
'sedumi.stepdif', 2);