Bug report of cvx installation and function vec

When I try to re-install CVX to including solver SCS, The following strange error is reported.

CVX: Software for Disciplined Convex Programming ©2014 CVX Research
Version 3.0beta, Build 1175 (1326ef2) Mon Nov 23 14:29:34 2015

Installation info:
MATLAB version: 9.1 (R2016b)
OS: Windows 8 amd64 version 6.2
Java version: 1.7.0_60
Verfying CVX directory contents:
No missing files.

Saving updated preferences…done.
Testing with a simple model…
UNEXPECTED ERROR: --------------------------------------------
Undefined function ‘vec’ for input arguments of type ‘double’.
Error in cvx_binary_op (line 107)
z = p.funcs{vu(1)}( vec(x), vec(y), varargin{:} );
Error in - (line 27)
z = cvx_binary_op( P, x, y );
Error in cvx_setup (line 261)
minimize( norm(A*x-b,1) );
Please report this error to support, and include entire output of
CVX_SETUP in your support request.

Typing ‘help vec’ in comand window, I get the following information.

Warning: ‘FxvcATsnitliubxvcerp_46wxvcnoitalumislairetaMhcraeseR鐩樻鍚屼簯搴︾櫨E’ exceeds MATLAB’s maximum name length of 63
characters and has been truncated to ‘FxvcATsnitliubxvcerp_46wxvcnoitalumislairetaMhcraeseR鐩樻鍚屼’.

In matlab.internal.language.introspective.hashedDirInfo (line 34)
In matlab.internal.language.introspective.classWrapper.base/getFileMethod (line 51)
In matlab.internal.language.introspective.classWrapper.base/getElement (line 29)
In matlab.internal.language.introspective.classWrapper.rawMCOS/getElement (line 41)
In matlab.internal.language.introspective.classWrapper.base/getClassInformation (line 24)
In matlab.internal.language.introspective.NameResolver/resolveImplicitPath>binaryResolveThroughPackages (line 198)
In matlab.internal.language.introspective.NameResolver/resolveImplicitPath>binaryResolve (line 115)
In matlab.internal.language.introspective.NameResolver/resolveImplicitPath>innerResolveImplicitPath (line 45)
In matlab.internal.language.introspective.NameResolver/resolveImplicitPath (line 23)
In matlab.internal.language.introspective.NameResolver/innerDoResolve (line 13)
In matlab.internal.language.introspective.NameResolver/doResolve (line 31)
In matlab.internal.language.introspective.NameResolver/underqualifiedResolve (line 11)
In matlab.internal.language.introspective.NameResolver/executeResolve (line 15)
In matlab.internal.language.introspective.resolveName (line 20)
In helpUtils.helpProcess/getTopicHelpText (line 12)
In helpUtils.helpProcess/getHelpText (line 3)
In help (line 55)
— help for cvx/vec —

vec CVX implementation of vec

I found there are two functions vec. One is %cvxrootfile%\cvx\functions\vec_\vec.m. Another is %cvxrootfile%\cvx\functions@cvx\vec.m. The former is for cvx objects, while the latter is for numbers.

Your installation completed fine, so you should be OK. The vec function for numeric vectors is only used by SDTP3.

You can add %cvxrootfile%\cvx\functions\vec_ to your path, and that will fix the problem for SDPT3. I’m a little puzzled why cvx_setup didn’t add it. It’s supposed to detect that vec is not available to you and add it to your path if it finds it’s not there.

Do not add the second path, the one for CVX objects. That’s already available to CVX as is.

If I manually add %cvxrootfile%\cvx\functions\vec_ to my path, it indeed works. I have also tried CVX 2.1. The same bug occurs.

The problem is due to cvx_startup, called by cvx_setup. In CVX 3.0, the following block of codes in cvx_startup is used to detect function vec and square. It detected a function vec at \YALMIP\yalmipR20160930@sdpvar\vec.m, and a function square at \MATLAB\R2016b\toolbox\signal\signal\square.m. Then cvx_startup failed to add %cvxrootfile%\cvx\functions\vec_\vec.m and %cvxrootfile%\cvx\functions\square_\square.m to the path.

addpaths = { ‘builtins’, ‘commands’, ‘functions’, ‘lib’, ‘structures’ };
if ~cvx___.isoctave
qq = which(‘vec’);
if isempty(qq)
addpaths{end+1} = [ ‘functions’, fs, ‘vec_’ ];
elseif ~quiet
warnings{end+1} = sprintf([…
‘WARNING: An existing copy of “vec.m” was found in your MATLAB path:\n %s\n’, …
‘CVX models will not be affected, but SDPT3 depends on this function. So if\n’, …
‘you delete it, you will need to re-run CVX_SETUP.’], qq );
qq = which(‘square’);
if isempty(qq)
addpaths{end+1} = [ ‘functions’, fs, ‘square_’ ];
elseif ~quiet
warnings{end+1} = sprintf([…
‘WARNING: An existing copy of “square.m” was found in your MATLAB path:\n %s\n’, …
‘Models using SQUARE() in CVX expressions will not be affected; but outside\n’, …
‘of CVX, this version will be used, and it likely has a different meaning.\n’, …
‘To avoid any confusion, just use X.^2 instead of SQUARE(X) in CVX.’], qq );

Both functions should be added to the path whether MATLAB detects such functions with the same name or not. One way to solve this problem is to add the following codes after the above block.
addpaths{end+1} = [ ‘functions’, fs, ‘square_’ ];
addpaths{end+1} = [ ‘functions’, fs, ‘vec_’ ];

Moreover, a function sym exists at \MATLAB\R2016b\toolbox\symbolic\symbolic@sym\sym.m. Then the function sym at %cvxrootfile%\cvx\functions\sym.m encountered the same trouble.

Gabriel, I am very grateful for your detailed analysis! I now realize why vec_ was not added to the path. (It is correct behavior for square_ not to be added to the path.)