[matlab]cvx安装后测试代码

这篇具有很好参考价值的文章主要介绍了[matlab]cvx安装后测试代码。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

测试环境:

windows10 x64

matlab2023a

代码来自官方网站:CVX: Matlab Software for Disciplined Convex Programming | CVX Research, Inc.

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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包