test for cvx library in matlab - windows

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\toolbox)

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

>> cvx_setup E:\software\MATLAB\R2014a\toolbox\cvx\cvx_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

 

posted @ 2016-12-20 14:55  loadofleaf  Views(343)  Comments(0Edit  收藏  举报