Problem with Error using lmi/horzcat One of the constraints evaluates to a FALSE LOGICAL

95 views
Skip to first unread message

XM XM

unread,
Jan 16, 2017, 12:28:16 AM1/16/17
to YALMIP
Hi Johan,

I have a question about yalmip. My code is follows

r = sdpvar(len_r*2, 1); % The parameters to be optimized

Constr_A = zeros(num_states, 1, num_actions); % num_states = 80, num_actions = 4
Constr_B = zeros(num_states, 1, num_actions);

Constr_A_B = zeros(num_states, 1, num_actions);
Constr_B_A = zeros(num_states, 1, num_actions);

for j = 1 : num_actions
    Constr_A(:, :, j) = (B_A(:, :, j) - B)*D*r(1:len_r);  % A column vector of 80*1
    Constr_B(:, :, j) = (B_B(:, :, j) - B)*D*r((len_r+1):2*len_r); % A column vector of 80*1
    Constr_A_B(:, :, j) = (B_A(:, :, j) - B)*D*(r(1:len_r) + r((len_r+1):2*len_r)); % A column vector of 80*1
    Constr_B_A(:, :, j) = (B_B(:, :, j) - B)*D*(r(1:len_r) + r((len_r+1):2*len_r)); % A column vector of 80*1
end

Constraints = [-1 <= r <= 1];
bound = 2e-5;

for j = 1 : num_actions
     Constraints = [Constraints, Constr_A(:, :, j)<=bound*ones(num_states, 1), ...
                Constr_B(:, :, j)<=bound*ones(num_states, 1), ...
                Constr_A_B(:, :, j)<=bound*ones(num_states, 1), ...
                Constr_B_A(:, :, j)<=bound*ones(num_states, 1)];

end


.........

When running the red part, I encountered a problem: Error using lmi/horzcat (line 21) One of the constraints evaluates to a FALSE LOGICAL variable.

Obviously, Constr_A(:, :, j) is a 80*1 vector. What do you think could be the issue?

Thanks so much for your help

Johan Löfberg

unread,
Jan 16, 2017, 1:31:24 AM1/16/17
to YALMIP
Some of the expressions which you constrains evaluates to a numerical value, which turns out to be infeasible. Hence, look at the expressions you create, and see which turns up as a numerical value which is infeasible

XM XM

unread,
Jan 16, 2017, 12:45:08 PM1/16/17
to YALMIP
Hi Johan,

Thanks so much! I found where the problem is. It is due to the incorrect order of Constraints = [-1 <= r <= 1] and
for j = 1 : num_actions
     Constraints = [Constraints, Constr_A(:, :, j)<=bound*ones(num_states, 1), ...
                Constr_B(:, :, j)<=bound*ones(num_states, 1), ...
                Constr_A_B(:, :, j)<=bound*ones(num_states, 1), ...
                Constr_B_A(:, :, j)<=bound*ones(num_states, 1)];

end

Constraints = [-1 <= r <= 1] should be put AFTER (instead of IN FRONT OF) the following piece.

for j = 1 : num_actions
     Constraints = [Constraints, Constr_A(:, :, j)<=bound*ones(num_states, 1), ...
                Constr_B(:, :, j)<=bound*ones(num_states, 1), ...
                Constr_A_B(:, :, j)<=bound*ones(num_states, 1), ...
                Constr_B_A(:, :, j)<=bound*ones(num_states, 1)];

end

Thanks again!


Johan Löfberg

unread,
Jan 16, 2017, 1:00:06 PM1/16/17
to YALMIP
No, that should make absolutely no difference.

and if put it after, then all the first constraints disappear as you don't concatenate

Johan Löfberg

unread,
Jan 16, 2017, 1:04:11 PM1/16/17
to YALMIP
i.e, it sounds like you effectively doing variants of this

sdpvar r

% complains
Constraint = [-1 <= r <= 1];
Constraint = [Constraint, r*0 <= -1]


% first infeasible constraint is never kept, so no complaints
Constraint = [r*0 <= -1];
Constraint = [-1 <= r <= 1];



XM XM

unread,
Jan 16, 2017, 3:31:23 PM1/16/17
to YALMIP
Yes, you are right. Sorry for my typo. I put Constraints = [Constraints, -1<=r<=1] after the piece. Thanks again!
Reply all
Reply to author
Forward
0 new messages