凸优化工具包CVX的安装注册

CVX is a Matlab-based modeling system for convex optimization. CVX turns Matlab into a modeling language, allowing constraints and objectives to be specified using standard Matlab expression syntax.

我们从最新版本cvx 3.0的安装、注册和实例讲起,对自己最新文章中的一个算法进行验证。


1、CVX 3.0 安装

CVX 3.0 beta是最新版本,支持多个平台,附下载地址。 
注意3.0版本和2.X版本不兼容,只能下载安装其一,如果已安装任意版本均需要卸载才能安装新版本。

(1)下载zip文件后,解压缩至任意地址,如D:\Download\cvx-w64 
(2)打开matlab将当前文件位置改到D:\Download\cvx-w64\cvx 
(3)matlab 命令行中输入命令

cvx_setup
  • 1
  • 1

安装正常后信息显示如下

>> cvx_setup

---------------------------------------------------------------------------
CVX: Software for Disciplined Convex Programming       (c)2014 CVX Research
Version 2.1, Build 1110 (66e9a9c)                  Wed Jun 10 21:43:38 2015
---------------------------------------------------------------------------
Installation info:
    Path: D:\Download\cvx-w64\cvx
    MATLAB version: 8.3 (R2014a)
    OS: Windows 7 amd64 version 6.1
    Java version: 1.7.0_11
Verfying CVX directory contents:
    No missing files.
Preferences: none found; defaults loaded.
License host:
    Username: user
    Host ID: 64006a58e9ad (eth3)
Installed license:
    No license installed.
No valid licenses found.
    Click here to fill out an academic license request
    for the username and first hostid listed above.
---------------------------------------------------------------------------
Setting CVX paths...done.
Saving updated path...done.
Searching for solvers...5 shims found.
2 solvers initialized (* = default):
 *  SDPT3    4.0        {cvx}\sdpt3
    SeDuMi   1.34       {cvx}\sedumi
3 solvers skipped:
    GLPK                
        Could not find a GLPK installation.
    Gurobi              {cvx}\gurobi\w64
        No valid Gurobi license was found. (Please note that this
        license is *not the same* as the CVX license; it must be
        obtained directly from Gurobi Optimization.) If you do have
        a Gurobi license, the the Gurobi MEX file could not find it.
        Please consult the Gurobi documentation for assistance.
    Mosek    unknown    {cvx}\mosek\w64
        A CVX Professional license is required.
Saving updated preferences...done.
Testing with a simple model...done!
---------------------------------------------------------------------------
To change the default solver, type "cvx_solver name>".
To save this change for future sessions, type "cvx_save_prefs".
Please consult the users' guide for more information.
---------------------------------------------------------------------------
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47

(4)敲入

cvx_version
  • 1
  • 1

可看到还没完成注册

>> cvx_version

---------------------------------------------------------------------------
CVX: Software for Disciplined Convex Programming       (c)2014 CVX Research
Version 2.1, Build 1110 (66e9a9c)                  Wed Jun 10 21:43:38 2015
---------------------------------------------------------------------------
Installation info:
    Path: D:\Download\cvx-w64\cvx
    MATLAB version: 8.3 (R2014a)
    OS: Windows 7 amd64 version 6.1
    Java version: 1.7.0_11
Verfying CVX directory contents:
    No missing files.
Preferences: 
    Path: C:\Users\user\AppData\Roaming\MathWorks\MATLAB\cvx_prefs.mat
License host:
    Username: user
    Host ID: 64006a58e9ad (eth3)
Installed license:
    No license installed.
No valid licenses found.
    Click here to fill out an academic license request
    for the username and first hostid listed above.
---------------------------------------------------------------------------
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

2、CVX 3.0 注册

(1)在此地址进行注册申请注册,如果有高效邮箱是可以申请免费试用的。 
以“Academic license request”为例,填写一些很基本的信息,其中需要在此部分 
这里写图片描述
中填写刚才上一个代码段的信息

License host:
    Username: user
    Host ID: 64006a58e9ad (eth3)
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

(2)然后在自己邮箱中接收邮件,将附件cvx_license随意另存个位置,如D:\Download\cvx_license.dat 
(3)matlab命令行中输入

cvx_setup D:/Download/cvx_license.dat
  • 1
  • 1

顺利注册后的信息如下

>> cvx_setup D:/Download/cvx_license.dat

---------------------------------------------------------------------------
CVX: Software for Disciplined Convex Programming       (c)2014 CVX Research
Version 2.1, Build 1110 (66e9a9c)                  Wed Jun 10 21:43:38 2015
---------------------------------------------------------------------------
Installation info:
    Path: D:\Download\cvx-w64\cvx
    MATLAB version: 8.3 (R2014a)
    OS: Windows 7 amd64 version 6.1
    Java version: 1.7.0_11
Verfying CVX directory contents:
    No missing files.
Preferences: 
    Path: C:\Users\user\AppData\Roaming\MathWorks\MATLAB\cvx_prefs.mat
License host:
    Username: user
    Host ID: 64006a58e9ad (eth3)
Installed license:
    No license installed.
Installing license:
    File: D:/Download/cvx_license.dat
    Organization: ******** university, P.R.China
    Contact: ** **** (********@***.edu.cn)
    License type: academic
    Named user: user
    Host ID: 64006a58e9ad
    Expiration: 2017-05-17 (364 days remaining)
    Status: verified
---------------------------------------------------------------------------
Setting CVX paths...already set!
Searching for solvers...5 shims found.
3 solvers initialized (* = default):
    Mosek    7.1.0.12    {cvx}\mosek\w64
 *  SDPT3    4.0         {cvx}\sdpt3
    SeDuMi   1.34        {cvx}\sedumi
2 solvers skipped:
    GLPK                 
        Could not find a GLPK installation.
    Gurobi               {cvx}\gurobi\w64
        No valid Gurobi license was found. (Please note that this
        license is *not the same* as the CVX license; it must be
        obtained directly from Gurobi Optimization.) If you do have
        a Gurobi license, the the Gurobi MEX file could not find it.
        Please consult the Gurobi documentation for assistance.
Saving updated preferences...done.
Testing with a simple model...done!
---------------------------------------------------------------------------
To change the default solver, type "cvx_solver name>".
To save this change for future sessions, type "cvx_save_prefs".
Please consult the users' guide for more information.
---------------------------------------------------------------------------
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52

3、例程

官网上有个很简单的小案例 
这里写图片描述

4、备注

最后特别提醒下,cvx工具箱只能解决特定形式的问题,如对于包含除号的目标函数,就无能为力了,即使你证明了这个OP是凸的,这时可以考虑使用fmincon函数。

文章出处:http://blog.csdn.net/lipengcn/article/details/51442005#comments

你可能感兴趣的:(凸优化工具包CVX的安装注册)