One of the constraints evaluates to a FALSE LOGICAL variable

28 views
Skip to first unread message

Guanghui Zhu

unread,
May 24, 2025, 10:26:00 AMMay 24
to YALMIP
Hi Prof. Johan Löfberg,

When constructing an integer linear programming model using YAMIP, I encountered the following error: “One of the constraints evaluates to a FALSE LOGICAL variable”.

As far as I understand, this occurs when some constraints are clearly infeasible.

However, I would like to perform further actions depending on whether the model has a feasible solution or not. For example:

for i=1:n
F = [];
% When building the model based on the i-th argument,
% the above error occurs. I cannot continue to call 'optimize'.
F = [..A(i)..];

output = optimize(F,[ ],options);
if output.problem == 0
% Action 1;
else
% Action 2;
end
end

Due to the above error, I'm unable to complete the model construction, which prevents me from executing any actions based on the optimization result.

Do you have any suggestions for how to handle this situation?

Thx a lot!

Guanghui Zhu

unread,
May 24, 2025, 11:01:15 AMMay 24
to YALMIP
%This is the code script.

M_curr = [1,0,3,1,2]';
Cu = [0,0,-1,0,1]';
t_u_number = 1;
pm = [1,0,0]';
A=[1, 0, 0, 0, 0;0, 1, 0, 0, 0;0, 0, 0, 1, 0];

F = [];
sigma_u = intvar(t_u_number,1,'full');
F = [F, sigma_u >= 0];
F = [F,M_curr+Cu*sigma_u >= 0];
for j=1:t_u_number
F = [F, A*(sigma_u(j)*Cu(:,j)) == 0];
end
sigma_u_alpha = intvar(t_u_number,1,'full');
F = [F, sigma_u_alpha >= 0];
F = [F,sigma_u_alpha <= 1];
F=[F,M_curr+Cu*sigma_u+Cu* sigma_u_alpha >= 0];
F=[F,ones(1,t_u_number)*Cu * sigma_u_alpha == 1];
F = [F, A*(M_curr+Cu*sigma_u+Cu* sigma_u_alpha) == pm]; % error occurs.
output = optimize(F,[],options);

Johan Löfberg

unread,
May 24, 2025, 1:04:48 PMMay 24
to YALMIP
>> A*(M_curr+Cu*sigma_u+Cu* sigma_u_alpha)

ans =

     1
     0
     1


>> pm

pm =

     1
     0
     0

Guanghui Zhu

unread,
May 25, 2025, 3:55:45 AMMay 25
to YALMIP
Thanks very much.
You answer helps me a lot! I have revised the code.

Reply all
Reply to author
Forward
0 new messages