Consider $x$ an n-dimensional vector with $x_i$ is integer in the range $[0 \dots k], k\in N$.

Given $A_{n\times n}$ is the covariance matrix of $x$.

$u$ is a given n-dimensional vector of real values with $0.0 \leq u_i \leq k.0$

Given a set of $x$, I need to find the minimum value of $f(x)$ defined as follow:

$f(x) = \sum_{i=1}^n\sum_{j\neq i}(x_i-u_i)(x_j-u_j)A_{ij}$

I've tried to simply calculate all the values of $f(x)$ and find the minimum of them. In matlab, it could take me more than 30 minutes if $n=1000$ and $k \leq 5$.

Does any one here know of any efficient algorithm for this problem? If possible, could you give me some suggestion or direct me to the literature where I can search for the solution?

Thanks,