Reputation: 11
I have tried to solve several similar optimization problems using Gurobi and Pyomo. The problems differ just by a few parameters. Each problem is run three times, each time with the same constraints but a different objective function.
There was one problem for which Gurobi could solve for only two of the objective functions I had specified. For the third objective function, it couldn't solve the problem, specifying the problem as 'infeasible'. But this didn't make sense to me as the feasible domain was exactly the same as when the other two objective functions were used to solve the problem.
I turned my computer off and on, and tried to solve the problem again on both PyCharm and Spyder. Gurobi was still telling me the problem was infeasible. However, I was sure the problem was perfectly feasible based on my observations of the other similar problems. So I tried to solve the exact same problem on another computer. This time it worked!...
I thus have partially solved my problem. I have the results I need but since I don't understand what's going on with Gurobi on my computer, I may be facing the same kind of problem in the future.
Does anyone have any idea about this "bug"?
Upvotes: 0
Views: 716
Reputation: 21572
You should verify that you Gurobi is reporting a status "infeasible" and not "infeasible or unbounded". You can check the return status or the log or turn off the presolve Dual Reductions. If you have large coefficients, you can see the previous question about integer programming and leaky abstractions. You can check one measure of the numerical difficulty of your problem with the attribute KappaExact. As @LarrySnyter610 suggested in the comments, Gurobi might also be running out of time.
If the objective is really the only thing that changes, you can likely resolve all these difficulties and get a performance boost by solving the problems consecutively. That way, Gurobi can use the solution from the previous objective as a warm start.
Suppose you have 2 objectives, obj1
, obj2
for the same set of objectives. You can solve them consecutively by
m.setObjective(obj1)
m.optimize()
if m.SolCount > 0:
solution1 = m.getAttr('X', m.getVars())
m.setObjective(obj2)
if m.SolCount > 0:
solution2 = m.getAttr('X', m.getVars())
Upvotes: 1