I'm trying to solve Sudoku using linear programming. In Sudoku, it is known that each row and column of the grid must contain number from 1 to 9 without duplicates. I need a constraint function that enforces this rule.
Given a set of natural numbers: $a_1, a_2, a_3$. I need a linear function $f$ (ie. $f(a_1, a_2, a_3) = c_1 a_1 + c_2 a_2 + c_3 a_3$) to check whether the set is contains each number starting from 1 in order once. For example, the linear function will return some value $x$ for the following permutations
$f(1,2,3) = x$
$f(2,1,3) = x$
$f(3,1,2) = x$
$f(1,3,2) = x$
$f(2,3,1) = x$
$f(3,2,1) = x$
But will return different value for the other permutations like
$f(1,2,5) ≠ x$
$f(2,2,2) ≠ x$
$f(3,1,-1) ≠ x$
$f(10, 2,-6) ≠ x$
$f(3, 4, 5) ≠ x$
I'm thinking about $f(a_1, a_2, a_3)=a_1+a_2+a_3$ which will return 6 for any permutation of $1,2,3$. But this function will also return the same result $2,2,2$ which is not what I want. Does the better linear function exist?
If the linear function does not exist then what is the nonlinear function for this problem?
Clearly this is not possible with a linear function. This problem can be formulated as
$$Ma=x\mathbf{1}$$
where $a=(a_1,a_2,a_3)$, $\mathbf{1}$ is the vector of ones, $M\in\mathbb{R}^{6\times 3}$ that contains all the permutations of the numbers $(1,2,3)$ vertically, and $x$ is an arbitrary number. Note that $M$ is full column rank.
Then, this underdetermined system of equations and either it has zero solutions or only one solution. In that case, the only solution is
$$a = \dfrac{x}{6}\mathbf{1}.$$
If we set $x=6$, then we recover your solution.
As a result no linear function can do what you are looking for.