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

📄 norm_approx.m

📁 斯坦福大学Grant和Boyd教授等开发的凸优化matlab工具箱
💻 M
字号:
% Examples 5.6,5.8: An l_p norm approximation problem% Boyd & Vandenberghe "Convex Optimization"% Jo雔le Skaf - 08/23/05%% The goal is to show the following problem formulations give all the same% optimal residual norm ||Ax - b||:% 1)        minimize    ||Ax - b||% 2)        minimize    ||y||%               s.t.    Ax - b = y% 3)        maximize    b'v%               s.t.    ||v||* <= 1  , A'v = 0% 4)        minimize    1/2 ||y||^2%               s.t.    Ax - b = y% 5)        maximize    -1/2||v||*^2 + b'v%               s.t.    A'v = 0% where ||.||* denotes the dual norm of ||.||cvx_quiet(true);% Input datarandn('state',0);n = 4;m = 2*n;A = randn(m,n);b = randn(m,1);p = 2;q = p/(p-1);% Original problemfprintf(1,'Computing the optimal solution of problem 1... ');cvx_begin    variable x(n)    minimize ( norm ( A*x - b , p) )cvx_endfprintf(1,'Done! \n');opt1 = cvx_optval;% Reformulation 1fprintf(1,'Computing the optimal solution of problem 2... ');cvx_begin    variables x(n) y(m)    minimize ( norm ( y , p ) )    A*x - b == y;cvx_endfprintf(1,'Done! \n');opt2 = cvx_optval;% Dual of reformulation 1fprintf(1,'Computing the optimal solution of problem 3... ');cvx_begin    variable nu(m)    maximize ( b'*nu )    norm( nu , q ) <= 1;    A'*nu == 0;cvx_endfprintf(1,'Done! \n');opt3 = cvx_optval;% Reformulation 2fprintf(1,'Computing the optimal solution of problem 4... ');cvx_begin    variables x(n) y(m)    minimize ( 0.5 * square_pos ( norm ( y , p ) ) )    A*x - b == y;cvx_endfprintf(1,'Done! \n');opt4 = (2*cvx_optval).^(.5);% Dual of reformulation 2fprintf(1,'Computing the optimal solution of problem 5... ');cvx_begin    variable nu(m)    maximize ( -0.5 * square_pos ( norm ( nu , q ) ) + b'*nu )    A'*nu == 0;cvx_endfprintf(1,'Done! \n');opt5 = (2*cvx_optval).^(0.5);% Displaying resultsdisp('------------------------------------------------------------------------');disp('The optimal residual values for problems 1,2,3,4 and 5 are respectively:');[ opt1 opt2 opt3 opt4 opt5 ]'disp('They are equal as expected!');

⌨️ 快捷键说明

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