⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex_5_39.m

📁 斯坦福大学Grant和Boyd教授等开发的凸优化matlab工具箱
💻 M
字号:
% Exercise 5.39: SDP relaxations of the two-way partitioning problem% Boyd & Vandenberghe. "Convex Optimization"% Jo雔le Skaf - 09/07/05% (a figure is generated)%% Compares the optimal values of:% 1) the Lagrange dual of the two-way partitioning problem%               maximize    -sum(nu)%                   s.t.    W + diag(nu) >= 0% 2) the SDP relaxation of the two-way partitioning problem%               minimize    trace(WX)%                   s.t.    X >= 0%                           X_ii = 1% Input datarandn('state',0);n = 10;W = randn(n); W = 0.5*(W + W');% Lagrange dualfprintf(1,'Solving the dual of the two-way partitioning problem...');cvx_begin sdp    variable nu(n)    maximize ( -sum(nu) )    W + diag(nu) >= 0;cvx_endfprintf(1,'Done! \n');opt1 = cvx_optval;% SDP relaxationfprintf(1,'Solving the SDP relaxation of the two-way partitioning problem...');cvx_begin sdp    variable X(n,n) symmetric    minimize ( trace(W*X) )    diag(X) == 1;    X >= 0;cvx_endfprintf(1,'Done! \n');opt2 = cvx_optval;% Displaying resultsdisp('------------------------------------------------------------------------');disp('The optimal value of the Lagrange dual and the SDP relaxation fo the    ');disp('two-way partitioning problem are, respectively, ');disp([opt1 opt2])disp('They are equal as expected!');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -