Minimizing an expression with linear constraints

101 Views Asked by At

Given a system of under-constrained (i.e. infinite solutions) linear equations (all values will be integers, all coefficients will be 0, 1, or -1), I want to pick values for the variables to minimize an expression. The variables must all be non-negative integers.

The expression to minimize represents the "error" in my answer, so I'm a bit flexible on it: the sum of squares of each variable is preferable, but if this problem is easiest to do with a linear expression, the straight-forward sum of the variables is also acceptable. Heuristics are fine; the variables must be non-negative integers fulfilling the constraints, but it's fine if the expression isn't perfectly minimized.

I'll be coding this up in C, so simpler algorithms are preferred. (I've searched the site, but perhaps I just don't know the right terminology) Thanks so much!