• test for cvx library in matlab


    Download the zip file of cvx

    http://cvxr.com/cvx/download/ by downloading cvx-w64.zip

    Require a licence for academic use

    a file named cvx_license.dat 

    Install with licence

    unzip the zip file into the toolbox directory ($MatlabRoot oolbox)

    run the command in matlab after entering the directory of cvx (adding the path of licence file)

    >> cvx_setup E:softwareMATLABR2014a oolboxcvxcvx_license.dat

    Then

    ---------------------------------------------------------------------------
    CVX: Software for Disciplined Convex Programming (c)2014 CVX Research
    Version 2.1, Build 1112 (ef41608) Sun Oct 2 17:15:09 2016
    ---------------------------------------------------------------------------

    Test with simple script

    cvx_test.m

     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

    run the script

     1 >> cvx_test
     2  
     3 Calling SDPT3 4.0: 56 variables, 22 equality constraints
     4    For improved efficiency, SDPT3 is solving the dual problem.
     5 ------------------------------------------------------------
     6 
     7  num. of constraints = 22
     8  dim. of socp   var  = 41,   num. of socp blk  = 11
     9  dim. of linear var  = 11
    10  dim. of free   var  =  4 *** convert ublk to lblk
    11 *******************************************************************
    12    SDPT3: Infeasible path-following algorithms
    13 *******************************************************************

    ------------------------For abbreviatin --------------
    14 rel. primal infeas (scaled problem) = 2.01e-09 15 rel. dual " " " = 6.95e-10 16 rel. primal infeas (unscaled problem) = 0.00e+00 17 rel. dual " " " = 0.00e+00 18 norm(X), norm(y), norm(Z) = 1.5e+00, 4.5e+00, 6.4e+00 19 norm(A), norm(b), norm(C) = 1.8e+01, 2.0e+00, 6.3e+00 20 Total CPU time (secs) = 0.07 21 CPU time per iteration = 0.01 22 termination code = 0 23 DIMACS: 2.0e-09 0.0e+00 1.2e-09 0.0e+00 6.3e-09 6.2e-09 24 ------------------------------------------------------------------- 25 26 ------------------------------------------------------------ 27 Status: Solved 28 Optimal value (cvx_optval): +4.29018
  • 相关阅读:
    第十五讲 实例模式
    第十四讲 实例模式
    将博客搬至CSDN
    CSU 1616: Heaps(区间DP)
    hdu 1281棋盘游戏(二分匹配)
    hdu 1042 N!(大数的阶乘)
    hdu 3371 Connect the Cities (最小生成树Prim)
    hdu 4502吉哥系列故事——临时工计划 (简单DP)
    hdu1230火星A+B (大数题)
    hdu1301 Jungle Roads (Prim)
  • 原文地址:https://www.cnblogs.com/loadofleaf/p/6202667.html
Copyright © 2020-2023  润新知