I would like to solve a system of linear equations with the added constraint that the solution vector must only contain integers. I assume this can be accomplished by something like intlinprog
, but it is not clear to me how a regular linear equation is supposed to be translated into a linear programming problem that this function can accept. Maybe the solution is obvious, maybe I'm just really confused about how to approach such a problem. Could somebody point me in the right direction?
As an example:
n = 7;
A = magic(n);
x = (1:n)' + (2 * rand(n, 1) - 1) / 10;
y = A * x;
clear x
How do I reconstruct x
from just A
and y
so that x
comes out as [1; 2; 3; 4; 5; 6; 7]
?