Home:ALL Converter>Solve system of linear equations for integer solutions

Solve system of linear equations for integer solutions

Ask Time:2020-12-02T23:13:44         Author:Marcel Tesch

Json Formatter

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]?

Author:Marcel Tesch,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/65110849/solve-system-of-linear-equations-for-integer-solutions
yy