Permutation error (turned out to be incompatibility of CVX 2.1 with Mac OS X and MATLAB R2016a-2017b, but MATLAB R2015b works with Mac OS X and CVX 2.1)

When I tried same code in 2017 it worked, but this time it doens’t work.

cvx_begin quiet
 variables x y z 

 p = [x y z]
 pp = perms(p)

Then error occurs like below:
Struct contents reference from a non-struct array object.

Error in cvxobj/isequal (line 2)
z = x.id_ == y.id_;

Error in perms (line 32)
    if isequal(V, 1:n)

Please help me…
I’ve tried to find similar error in this forum, but I couldn’t get any useful answer…

Please show the output from cvx_version . it sounds like an incompatibility/bug.

And tell us the exact configuration which successfully ran this example.

1 Like

Thank you first.

  1. output from cvx_version:

  2. Here is the exact code I try:

     sx = [-1 -1];
     sy = [1 1];
     tx = [0 0 0];
     ty = [1 1 0];
    
    
      n=1;
      tolen = zeros(3*3*3*3);
    
     for i = 1:1:2  
      
     for j = 1:1:2
     
     for k = 1:1:2 
     
     cvx_begin quiet
         variables x1 x2 x3 x4 x5 x6
        
     p1x = [x1 x3]; 
     p1y = [x2 x4];
     pp1x = perms(p1x);
     pp1y = perms(p1y);
     
     p2x = [x1 x5];
     p2y = [x2 x6];
     pp2x = perms(p2x);
     pp2y = perms(p2y);
     
     p3x = [x3 x5];
     p3y = [x4 x6];
     pp3x = perms(p3x);
     pp3y = perms(p3y);
     
    
     %    
     s1p1 = [(sx(1)-pp1x(i,1)) (sy(1)-pp1y(i,1))];
     len1 = norm(s1p1);
     % 
     s1p1 = [(pp1x(i,1)-pp1x(i,2)) (pp1y(i,1)-pp1y(i,2))];
     len2 = norm(s1p1);
     %
     t1p1 = [(tx(1)-pp1x(i,2)) (ty(1)-pp1y(i,2))];
     len4 = norm(t1p1);
         
     %
     s2p2 = [(sx(2)-pp2x(j,1)) (sy(2)-pp2y(j,1))];
     len5 = norm(s2p2);
     %
     s2p2 = [(pp2x(j,1)-pp2x(j,2)) (pp2y(j,1)-pp2y(j,2))];
     len6 = norm(s2p2);
     %
     t2p2 = [(tx(2)-pp2x(j,2)) (ty(2)-pp2y(j,2))];
     len8 = norm(t2p2);
         
     % 
     s3p3 = [(sx(3)-pp3x(k,1)) (sy(3)-pp3y(k,1))];
     len9 = norm(s3p3);
     %
     s3p3 = [(pp3x(k,1)-pp3x(k,2)) (pp3y(k,1)-pp3y(k,2))];
     len10 = norm(s3p3);
     % 
     t3p3 = [(tx(3)-pp3x(k,2)) (ty(3)-pp3y(k,2))];
     len12 = norm(t3p3);    
         
    
     minimize(len1+len2+len4+len5+len6+len8+len9+len10+len12);
         
     cvx_end
    
     tolen(n) = cvx_optval;
     n = n+1;
     end
     k = 1;
     end
     j = 1;
     end
    

(the code for the exact configuration… is it correct answer…?)

The code you posted isn’t even executable.
s3p3 = [(sx(3)-pp3x(k,1)) (sy(3)-pp3y(k,1))];
produces
Index exceeds matrix dimensions
because it includes sx(3) , but sx = [-1 -1]; which is 1 by 2.

Also, it’s not a good idea to use the quiet option until you are confident your program is working properly. By using quiet, you don’t see solver output and CVX status.

`

1 Like

Sorry for mistake.

Even if I change sx= [ -1 -1 -1] sy = [0,0,1] and delete quiet, the same error occur.

Did you find any hint from the output ofcvx_version…?

I just ran the code successfully, with all problems solved to optimality on Windows 7 professional service pack 1, using CVX 2.1 Build 1123 using both SDPT3 and SeDuMi and MATLAB R2014a and R2017b…

Either

  1. There is an incompatibility with CVX 2.1 Build 1123 under MATLAB 2017b under Mac(OS X)… Note, Mac is tested and used much less with CVX than Windows and perhaps Linux. It may be that an older version of MATLAB is more compatible with CVX 2.1.
    or
  2. Your CVX installation has been corrupted. I suggest you delete all CVX directories from your MATLAB path, start a new MATLAB session, re-install CVX 2.1 Build 1123, then run the program.
1 Like

Thank you very much!!!
I’ll do that right away.!

Just for curiosity, how did you find out the problem?
Did you see the documents of cvx?

BTW, the quiet option will have no effect on whether errors occur or the solver results. It just determines whether or not you can see what is going on with the solver and CVX status. You can always examine cvx_status after CVX exits, even if you used the quiet option - that is what do if I am using CVX inside a larger program and CVX is run many times - but I do that after I have the program working properly.

My suggestions are educated guesses based on personal experience, together with seeing many posts on this forum over the years.

You can look at the CVX MATLAB source code if you want.

1 Like

oh…
I tried R2017a, R2016b, R2016a… and nothing works…(same problem)

Also I removed all cvx files, etc and reinstall…

This is just a guess, but 2016a might be the dividing line. Maybe 2015b works - but no guarantee.

1 Like

Finally!
(On the Mac, it is still installing… R2015b)
But Good news is, on the Linux, R2015b works!!!

Thank you very much…!

It’s good to know.that 2015b worked but 2016a didn’t (under MAC OS X).

In the first post you wrote

When I tried same code in 2017 it worked

What was the configuration you were referring to in that post which worked? I.e., version of OS, MATLAB, CVX.

I mean 2017 years, not meaning about the version of Matlab.

    Summary:  **perms(array of variables)** doesn't work in the below version

    On the Mac and Linux: R2018b~R2016a.
    Mac(Mojave 10.14.1), Linux(ubuntu 17.10)

But it works with R2015b!!

Thank you again.