2

なんらかの理由で、 cvxはそのままでは機能しません。

Windows x64、cvx x64、Matlab x64 R2012a を使用しています

しかし、単純な例 (\cvx\examples\quickstart.m) だけでも実行すると、エラーが発生します。

>> quickstart

has_quadprog = exist( 'quadprog' );
has_quadprog = has_quadprog == 2 | has_quadprog == 3;
has_linprog  = exist( 'linprog' );
has_linprog  = has_linprog == 2 | has_linprog == 3;
rnstate = randn( 'state' ); randn( 'state', 1 );
s_quiet = cvx_quiet(true);
s_pause = cvx_pause(false);
cvx_clear; echo on

prob = evalin( 'caller', 'cvx_problem', '[]' );
if isa( prob, 'cvxprob' ),

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SECTION 2.1: LEAST SQUARES %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input data
m = 16; n = 8;
A = randn(m,n);
b = randn(m,1);

% Matlab version
x_ls = A \ b;

% cvx version
cvx_begin
Attempt to reference field of non-structure array.

Error in cvxprob (line 48)
    selected = cvx___.solvers.selected;

Error in cvx_begin (line 41)
assignin( 'caller', 'cvx_problem', cvxprob( varargin{:} ) );

Error in quickstart (line 25)
cvx_begin
4

1 に答える 1

8

インストールは比較的簡単です:

  1. CVX をダウンロードします (cvx-rd.zip無料のソルバーのみを含むディストリビューションを入手し、サポートされているすべてのプラットフォーム用にコンパイル済みの MEX バイナリが含まれています)。

  2. ZIPファイルをどこかに解凍します。C:\cvx

  3. MATLAB でそのディレクトリに移動し、次を実行しますcvx_setup

    >> cd('C:\cvx')
    >> cvx_setup
    
    ---------------------------------------------------------------------------
    CVX: Software for Disciplined Convex Programming       (c)2014 CVX Research
    Version 2.1, Build 1088 (e790d80)                  Sat Sep 20 22:03:02 2014
    ---------------------------------------------------------------------------
    Installation info:
        Path: C:\cvx
        MATLAB version: 8.3 (R2014a)
        OS: Windows 8 amd64 version 6.2
        Java version: 1.7.0_11
    Verfying CVX directory contents:
        No missing files.
    Preferences: none found; defaults loaded.
    ---------------------------------------------------------------------------
    Setting CVX paths...done.
    Saving updated path...done.
    Searching for solvers...3 shims found.
    2 solvers initialized (* = default):
     *  SDPT3    4.0     {cvx}\sdpt3
        SeDuMi   1.34    {cvx}\sedumi
    1 solver skipped:
        GLPK             
            Could not find a GLPK installation.
    Saving updated preferences...done.
    Testing with a simple model...done!
    ---------------------------------------------------------------------------
    To change the default solver, type "cvx_solver <solver_name>".
    To save this change for future sessions, type "cvx_save_prefs".
    Please consult the users' guide for more information.
    ---------------------------------------------------------------------------
    
  4. これで、例の 1 つを実行できます。

    >> cd('C:\cvx\examples')
    >> quickstart
    

外部ソルバー (Gurobi および MOSEK) に接続する場合は、docsの対応するセクションをお読みください。これには、CVX Professional ライセンスが必要です。

于 2014-10-04T11:39:37.620 に答える