• [matlab]cvx安装后测试代码


    测试环境

    windows10 x64

    matlab2023a

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

    1. m = 20; n = 10; p = 4;
    2. A = randn(m,n); b = randn(m,1);
    3. C = randn(p,n); d = randn(p,1); e = rand;
    4. cvx_begin
    5. variable x(n)
    6. minimize( norm( A * x - b, 2 ) )
    7. subject to
    8. C * x == d
    9. norm( x, Inf ) <= e
    10. cvx_end

    运行结果:

    1. >> untitled
    2. Calling SDPT3 4.0: 56 variables, 22 equality constraints
    3. For improved efficiency, SDPT3 is solving the dual problem.
    4. ------------------------------------------------------------
    5. num. of constraints = 22
    6. dim. of socp var = 41, num. of socp blk = 11
    7. dim. of linear var = 11
    8. dim. of free var = 4 *** convert ublk to lblk
    9. *******************************************************************
    10. SDPT3: Infeasible path-following algorithms
    11. *******************************************************************
    12. version predcorr gam expon scale_data
    13. NT 1 0.000 1 0
    14. it pstep dstep pinfeas dinfeas gap prim-obj dual-obj cputime
    15. -------------------------------------------------------------------
    16. 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
    17. 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
    18. 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
    19. 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
    20. 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
    21. 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
    22. 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
    23. 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
    24. 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
    25. 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
    26. 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
    27. 11|1.000|0.985|5.2e-10|1.0e-09|8.9e-09|-4.775387e+00 -4.775387e+00| 0:0:00|
    28. stop: max(relative gap, infeasibilities) < 1.49e-08
    29. -------------------------------------------------------------------
    30. number of iterations = 11
    31. primal objective value = -4.77538726e+00
    32. dual objective value = -4.77538726e+00
    33. gap := trace(XZ) = 8.89e-09
    34. relative gap = 8.43e-10
    35. actual relative gap = 2.84e-10
    36. rel. primal infeas (scaled problem) = 5.17e-10
    37. rel. dual " " " = 1.05e-09
    38. rel. primal infeas (unscaled problem) = 0.00e+00
    39. rel. dual " " " = 0.00e+00
    40. norm(X), norm(y), norm(Z) = 2.1e+00, 4.9e+00, 7.0e+00
    41. norm(A), norm(b), norm(C) = 2.0e+01, 2.0e+00, 6.0e+00
    42. Total CPU time (secs) = 0.45
    43. CPU time per iteration = 0.04
    44. termination code = 0
    45. DIMACS: 5.2e-10 0.0e+00 2.3e-09 0.0e+00 2.8e-10 8.4e-10
    46. -------------------------------------------------------------------
    47. ------------------------------------------------------------
    48. Status: Solved
    49. Optimal value (cvx_optval): +4.77539

  • 相关阅读:
    modernC++手撸任意层神经网络22前向传播反向传播&梯度下降等23代码补全的例子0901b
    如何避免阿里云对象储存OSS被盗刷
    4K三路虚拟情景互动教学软件应用开发
    从 select、poll、epoll 回答IO多路复用
    Shell 脚本学习笔记
    【Android面试八股文】讲一讲StackOverFlow和OOM的区别?栈和堆分别存储的是什么?
    【DataRoom】- 基于VUE的开源的大屏可视化设计器
    FPGA的音乐彩灯VHDL流水灯LED花样,源码和视频
    2022最新版JDK1.8的安装教程、包含jdk1.8的提取码(亲测可用)
    记录电脑快捷键
  • 原文地址:https://blog.csdn.net/FL1623863129/article/details/132781927