CVX下載
CVX安裝
下載壓縮文件后解壓縮至任意地址,打開matlab,進入解壓縮后的地址,在matlab中輸入 cvx_setup,如果出現以下信息,則說明安裝成功。
Testing the cvx distribution. If this script aborts with
an error, please report the error to the authors.
-------------------------------------------------------------
No errors! cvx has been successfully installed.
最后需要保存一下路徑,在Preferences→General的Toolbox Path Caching里點擊update Toolbox Path Cache更新一下,點擊Apply即可。
基本用法
- 查看當前求解器
cvx_solver
- 選擇求解器
cvx_solver sedumi
- 設置精度
cvx_precision low
cvx_precision medium
cvx_precision default
cvx_precision high
cvx_precision best
- 線性規划問題
n=3;
A=[1 2 3;0 2 4];
b=[10;9];
c=[2 3 4];
lb=[0;0;0];
ub=[10;10;10];
cvx_begin
variable x(n);
dual variable y;
minimize(c*x);
subject to
y:A*x==b;
lb<=x<= ub;
cvx_end