Bug with "presolve"
AnsweredI found that presolving is sometimes buggy.
For example, in the following problem, the presolved model has objective 0.0, and all its variables/constraints are removed, which is clearly not true.
A, b, c = np.ones((10, 5)), 10 * np.ones(10), np.ones(5)
ip = gp.Model()
x_var = ip.addMVar(n, lb = 0.0, ub = float('inf'), vtype = GRB.BINARY, name = 'x')
ip.addConstr(A @ x_var <= b)
ip.setObjective(c @ x_var, GRB.MAXIMIZE)
presolved = ip.presolve()
print(presolved.getObjective())
ip.optimize()
This problem is reproducible on both my PC and colab versions.

Hi,
The model you construct hold redundant constraints only, they all state
\[\sum_{i=1}^5 b_i \leq 10\\
b_i \in \{0,1\}\]When these constraints are removed, the objective function is trivial as well.
Thus, Gurobi can provide the optimal solution without actually solving it. Therefore, the presolved model is a trivial one. Please also note that as described in How does presolve work?, it is not always possible to reproduce the original model from the presolved model. In this extreme example, the only information you get from the presolved model is that your model is indeed a trivial one.
Best regards,
Jaromił0 
Thanks, following my post, I have been working on the same projects for months, and I have come to understand the mechanisms of presolving. However, in the examples where everything is removed, do you think that it is more rational to set the objective to a constant of the optimal objective, rather than 0?
0 
However, in the examples where everything is removed, do you think that it is more rational to set the objective to a constant of the optimal objective, rather than 0?
It makes sense to set the objective of a trivially presolved model to 0, because this represents that even the optimal solution and the optimal objective value have been deduced fully from presolve by, e.g., setting all variables to their lower bounds. If one would set the objective of the presolved model to the optimal solution value of the original model, it would no longer be the presolved model, because the objective function has not been handled properly in this case.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
3 comments