Restrict scipy.optimize.minimize to integer values : <p>I'm using <code>scipy.optimize.minimize</code> to optimize a real-world problem for which the answers can only be integers. My current code looks like this: </p>

<pre><code>from scipy.optimize import minimize

def f(x):
    return (481.79/(5+x[0]))+(412.04/(4+x[1]))+(365.54/(3+x[2]))+(375.88/(3+x[3]))+(379.75/(3+x[4]))+(632.92/(5+x[5]))+(127.89/(1+x[6]))+(835.71/(6+x[7]))+(200.21/(1+x[8]))

def con(x):
    return sum(x)-7

cons = {'type':'eq', 'fun': con}

print scipy.optimize.minimize(f, [1,1,1,1,1,1,1,0,0], constraints=cons, bounds=([0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7]))
</code></pre>

<p>This yields: </p>

<pre><code>x: array([  2.91950510e-16,   2.44504019e-01,   9.97850733e-01,
     1.05398840e+00,   1.07481251e+00,   2.60570253e-01,
     1.36470363e+00,   4.48527831e-02,   1.95871767e+00]
</code></pre>

<p>But I want it optimized with integer values (rounding all <code>x</code> to the nearest whole number doesn't always give the minimum). </p>

<p>Is there a way to use <code>scipy.optimize.minimize</code> with only integer values?</p>

<p>(I guess I could create an array with all possible permutations of <code>x</code> and evaluate f(x) for each combination, but that doesn't seem like a very elegant or quick solution.)</p>
