Issue on constraint after update

43 views
Skip to first unread message

Sleris Saezien

unread,
Apr 22, 2015, 1:11:13 PM4/22/15
to yal...@googlegroups.com
Hello,

I recently updated my YALMIP installation from something quite old (probably a release of 2013 or 2012, since I didin't use YALMIP in 2014), and I have a piece of code which is no longer working.

Here comes a sample of the code:

nPose = 12;
nPts = 15;

D = rand(nPose,nPts) < 0.75;
Mask = kron(D,[1;1;1]);

t = sdpvar(nPose,nPts,'full');

tP = t(:)>=0.00001
size(tP)
for i = 1:nPose
    for j = 1:nPts
        if(Mask(3*i,j) == 0)
            tP((i-1)*nPose+j) = t(i,j)==1;
        end
    end
end

I got the following output and error:

++++++++++++++++++++++++++++++++++++++++
|   ID|                      Constraint|
++++++++++++++++++++++++++++++++++++++++
|   #1|   Element-wise inequality 180x1|
++++++++++++++++++++++++++++++++++++++++

ans =

     1     1

Error using constraint (line 9)
Not enough input arguments.


I guess an hint on the problem might be that size(tP) is returning [1 1] and so when I access tP((i-1)*nPose+j) then something gets wrong.
If I try to display tP or its size after the error, I get this:
>> size(tP)

ans =

     1     3

>> tP
Field reference for multiple structure elements that is followed by more reference blocks is an error.

Error in constraint/getlist (line 10)
if isequal(X.List{2},'==')

Error in lmi (line 141)
        [Fi,strict,LMIIdentifiers,tags] = getlist(X);

Error in constraint/display (line 3)
display(lmi(X));

Thanks for any help !

Johan Löfberg

unread,
Apr 22, 2015, 2:31:14 PM4/22/15
to yal...@googlegroups.com
I'm surprised it ever worked.

Now is the time to update and imrove the code. What is it you really want to do? To me, it looks like you simply want to do

[ t >= 0.00001, t(find(Mask(3:3:end,:)==0)) == 1]


Sleris Saezien

unread,
Apr 23, 2015, 9:51:35 AM4/23/15
to yal...@googlegroups.com
Well to be truthfull, it's not my code, and it was time for me to go home, so I didn't even take the time to try to rewrite it but I thought the bug was interesting to report.
An appropriate rewrite would probably be

tP = [ t(Mask(3:3:end,:)==1) >= 0.00001, t(Mask(3:3:end,:)==0) == 1];

Anyway, even if the previous code isn't nice, it shouldn't crash.

Johan Löfberg

unread,
Apr 23, 2015, 10:16:06 AM4/23/15
to yal...@googlegroups.com
Are you sure this has ever worked. I tried with a bunch of old versions dating back to 2009 and they all fail in the same (correct) way.

tP is a list of 1 constraint objects. That object is an LP constraint of dimension 180

tP(2) etc do not exist. Hence, when you try to replace some constraint tP(...)=new constraint, YALMIP complains.

If your code would have worked, it would not have given you what you what you would have wanted. You would get something like

[180 constraints,[],[],...[], something ==1, [],[], something ==1]


Sleris Saezien

unread,
Apr 23, 2015, 10:34:12 AM4/23/15
to yal...@googlegroups.com
Well, I have once run the full code from which this piece has been extracted without errors.
But I'm not sure it did produce good result by the way, maybe you are right and it was producing garbage (would be strange, this code come from the author of an ECCV'10 paper, so the code worked for him enough to make the results presented in the paper).
I updated yalmip just after I found out the code was using it and then ran into this issue.

Johan Löfberg

unread,
Apr 23, 2015, 1:13:32 PM4/23/15
to yal...@googlegroups.com
Peer reviewed publication is not a stamp of quality or correctness, but an indication that it is hopefully not blatantly wrong or obviously totally crap. 

My guess is the code never ran for some reason, such as the mask condition being false for the data used. I cannot see how it ever could have run without crashing.

Sleris Saezien

unread,
Apr 23, 2015, 1:21:03 PM4/23/15
to yal...@googlegroups.com
You might be right, when I first tested the code after I found out it was using yalmip, I probably used simulated data without missing data.
That's probably why it worked at this time.
Then I updated yalmip and tried with more realistic simulation, and then I ran into that issue.

But still, it would mean the author never really tested its code with missing data, that make me wondering is the entire paper isn't crap.
Reply all
Reply to author
Forward
0 new messages