测试环境:
windows10 x64
matlab2023a
代码来自官方网站:CVX: Matlab Software for Disciplined Convex Programming | CVX Research, Inc.文章来源:https://www.toymoban.com/news/detail-703712.html
m = 20; n = 10; p = 4;
A = randn(m,n); b = randn(m,1);
C = randn(p,n); d = randn(p,1); e = rand;
cvx_begin
variable x(n)
minimize( norm( A * x - b, 2 ) )
subject to
C * x == d
norm( x, Inf ) <= e
cvx_end
运行结果:文章来源地址https://www.toymoban.com/news/detail-703712.html
>> untitled
Calling SDPT3 4.0: 56 variables, 22 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.
------------------------------------------------------------
num. of constraints = 22
dim. of socp var = 41, num. of socp blk = 11
dim. of linear var = 11
dim. of free var = 4 *** convert ublk to lblk
*******************************************************************
SDPT3: Infeasible path-following algorithms
*******************************************************************
version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime
-------------------------------------------------------------------
0|0.000|0.000|1.4e+01|1.1e+01|3.5e+03| 9.612805e+00 0.000000e+00| 0:0:00| chol 1 1
1|0.872|0.476|1.8e+00|5.8e+00|8.4e+02| 1.407022e+01 -4.875554e+00| 0:0:00| chol 1 1
2|1.000|0.959|1.9e-05|2.5e-01|4.9e+01| 1.799136e+01 -5.885102e+00| 0:0:00| chol 1 1
3|0.953|0.929|2.8e-06|1.8e-02|7.7e+00| 1.773656e+00 -5.018059e+00| 0:0:00| chol 1 1
4|0.837|0.787|7.8e-07|4.0e-03|1.4e+00|-3.472607e+00 -4.830411e+00| 0:0:00| chol 1 1
5|0.984|0.112|3.8e-08|4.4e-03|4.5e-01|-4.454519e+00 -4.812811e+00| 0:0:00| chol 1 1
6|0.990|0.879|1.6e-08|5.3e-04|7.3e-02|-4.710280e+00 -4.778388e+00| 0:0:00| chol 1 1
7|0.977|0.975|2.3e-09|1.4e-05|1.8e-03|-4.773757e+00 -4.775449e+00| 0:0:00| chol 1 1
8|0.981|0.987|1.6e-09|7.0e-06|7.6e-05|-4.775357e+00 -4.775389e+00| 0:0:00| chol 1 1
9|0.936|0.979|1.7e-09|3.0e-07|3.8e-06|-4.775385e+00 -4.775387e+00| 0:0:00| chol 2 2
10|1.000|0.975|7.5e-09|1.5e-08|2.4e-07|-4.775387e+00 -4.775387e+00| 0:0:00| chol 2 2
11|1.000|0.985|5.2e-10|1.0e-09|8.9e-09|-4.775387e+00 -4.775387e+00| 0:0:00|
stop: max(relative gap, infeasibilities) < 1.49e-08
-------------------------------------------------------------------
number of iterations = 11
primal objective value = -4.77538726e+00
dual objective value = -4.77538726e+00
gap := trace(XZ) = 8.89e-09
relative gap = 8.43e-10
actual relative gap = 2.84e-10
rel. primal infeas (scaled problem) = 5.17e-10
rel. dual " " " = 1.05e-09
rel. primal infeas (unscaled problem) = 0.00e+00
rel. dual " " " = 0.00e+00
norm(X), norm(y), norm(Z) = 2.1e+00, 4.9e+00, 7.0e+00
norm(A), norm(b), norm(C) = 2.0e+01, 2.0e+00, 6.0e+00
Total CPU time (secs) = 0.45
CPU time per iteration = 0.04
termination code = 0
DIMACS: 5.2e-10 0.0e+00 2.3e-09 0.0e+00 2.8e-10 8.4e-10
-------------------------------------------------------------------
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +4.77539
到了这里,关于[matlab]cvx安装后测试代码的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!