How to ask for second best solution to a MIP using JuMP

房东的猫 提交于 2020-06-14 04:06:54

问题


I have a Mixed Integer Programming problem. I can use JuMP to find the optimal solution. But how can I find the second best solution? Or the third-best etc.

This potentially might be another equally optimal solution, or it might be a worse solution, or it might be :Infeasible -- there might be no most solutions.

I know for a TSP-like problem, I can find additional solutions by progressively removing links that are on the optimal path (I.e setting the distances between some of the cities to be infinite). For a schedualling type problem, I can similarly progressive set the availabilities of the timeslots used in the optimal path to be forbidden.

But is there a general way of doing this, without coding up myself problem specific methods for disallowing this solution?


回答1:


You can add a cut to forbid the optimal solution just found and solve again. Say your model has binary variables x(i). Let a(i):=x*(i) be the optimal solution found earlier. Then add the linear constraint:

sum(i, x(i) * a(i)) - sum(i, x(i) * (1-a(i))) <= sum(i, a(i)) - 1

and solve again. (This thing is derived here). If x is a general integer variable, things become more complicated.

Some solvers like Cplex and Gurobi also have something called a solution pool which also can do this.



来源:https://stackoverflow.com/questions/42591384/how-to-ask-for-second-best-solution-to-a-mip-using-jump

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!