• Gurobi Staff

By default, variables added via Model.addVar() or Model.addVars() have a lower bound of $$0$$. If the $$Z$$ variables are free, you should define them as follows:

Z = m.addVars(Ind, lb=-GRB.INFINITY, vtype='C', name='Z')

With this change, the optimal value of $$x$$ is around $$60$$.

The only other difference I see between the mathematical formulation and your code is that the formulation includes $$p_k$$ in the objective function summations, where your code instead uses a single $$\texttt{pro}$$ value. Of course, this isn't an issue if all of the $$p_k$$ are equal to $$\texttt{pro}$$.

Thank you so much. That fixes the problem!

Yes, pro is constant as they have a  similar probability.