How to use a variable as a divisor in PuLP

心已入冬 提交于 2019-12-06 02:27:17

Linear Programming doesn't understand divisions, hence the error :) You have to reformulate it so that the division is formulated linearly. In this case:

prob += x / (x + y) > 0.5  
prob += y / (x + y) < 0.4

is equivalent to:

prob += x > 0.5 * (x + y)
prob += y < 0.4 * (x + y)

Which are linear constraints. Good luck!

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