gpt4 book ai didi

Matlab cvx 错误与 cvx_begin

转载 作者:行者123 更新时间:2023-12-02 05:36:25 25 4
gpt4 key购买 nike

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

最佳答案

安装比较简单:

  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. 现在您可以运行示例之一:

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

如果您想连接到外部求解器(Gurobi 和 MOSEK),请阅读 docs 中的相应部分。 。这需要 CVX Professional 许可证。

关于Matlab cvx 错误与 cvx_begin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26191167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com