I tried implementing the solution in optimal binary matrix using Matlab function intlinprog
to a test input as in the following code
a=[450;400;250;200]; % test input
b=[750;500]; % test input
n = 4; % length of a
m = 2; % length of b
oness=ones(m,1);
f = (kron(a,oness))'; % objective function
cont1=kron(eye(n),oness');
cont2=-cont1;
cont3=-kron(a',eye(m));
A=[cont1;cont2;cont3];
bb=[ones(n,1);-zeros(n,1);-b];
lb = zeros(m*n,1);
ub = [ones(m*n,1)]; % enforces binary
intcon= [1,2,3,4,5,6,7,8]; % all variable should be integers
Aeq = [];
beq = [];
x = intlinprog(f,intcon,A,bb,Aeq,beq,lb,ub)
However, I am getting the message
Intlinprog
stopped because no integer points satisfy the constraints.
An obvious optimal solution for this test input would be x = [0;1;1;0;1;0;0;0]
.
However, if I remove the integrality constraints via intcon=[]
, I get an optimal solution. Why can't the function find the minimum solution with integral constraints?