Hello,
I'm trying to maximize the inner product between two vectors (one is fixed), subject to the fact that the sum of the elements of the vector with respect to which I want to optimize is equal to a fixed number. The vector with respect to which I have to maximize must contain integer values.
In math it would be:
max_{y} x^{T} * y
s.t. sum(y) == Q & int(y) == y
Although it seems a convex problem I'm not able to solve it with KKT.
This is the code:
x = zeros(256, 1);
p = 0.003;
for b = 1:256
pb = p * (1 - p)^(b-1);
x(b) = pb;
end
Q = 512;
% Setup the problem using YALMIP
y = intvar(256, 1);
obj = sum(x.*y);
cons = [sum(y) == Q];
sol = optimize(cons,-obj);
y = value(y);
The solution that I obtained is that the vector y is all zeros, and this is clearly not the maximum result for the inner product that I can have. Moreover, I obtain the message:
Root LP problem is unbounded.
Intlinprog stopped because the root LP problem is unbounded.
Could you please help me?
Thank you.