Getting all solutions in Google or-tools

眉间皱痕 提交于 2019-12-12 03:37:34

问题


I have a linear problem of finding all solutions that meet all constraints. For example my variables are = [0.323, 0.123, 1.32, 6.3...] Is it possible to get for example top 100 solutions sorted by fitness(maximization/minimization) function?


回答1:


In a continuous LP enumerating different solutions is a difficult concept. E.g. consider max x, s.t. x <= 1. Obviously x=1, x=0.99999 are solutions and so are the infinite number of solutions in between. We could enumerate "corner solutions" (or basic solutions). See here for an example. Such a scheme could be adapted to find the first 100 different corner points sorted by the objective. For models with discrete variables, many constraint programming solvers will give you the possibility to find many solutions.




回答2:


If you can define a fitness function as you suggested, then you might first want to solve the LP that maximizes this function. Afterwards you can include an objective cutoff that forces your second solution to be slightly worse than the first. You can implement this by introducing a cut that is your objective function with the right hand side of optimal value - epsilon.

Of course, this will not give you all (basic) solutions, but you might discover which variables are always at the same value or how much variance there is between the different solutions.



来源:https://stackoverflow.com/questions/37682209/getting-all-solutions-in-google-or-tools

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