zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    模拟实现ajax加载框
    京东晒单的js实现
    微信分享js代码(转载)
    css模拟实现selec下拉框
    网页端实现输入卡号四字隔开
    返回顶部的动态显示与隐藏
    js等比例缩放图片(转载)
    css模拟实现checkbox
    quartz的使用 Mr
    Spring声明式事务配置管理方法 Mr
  • 原文地址:https://www.cnblogs.com/loadofleaf/p/6202667.html
Copyright © 2011-2022 走看看