纸浆溶液
经过一些研究,我不认为你的目标函数是线性的.我在Python pulp库中重新创建了这个问题但是纸浆不喜欢我们用浮点数和’LpAffineExpression’来划分. This answer表明线性规划“不理解分歧”,但该评论是在增加约束的背景下,而不是目标函数.该评论将我指向“Mixed Integer Linear Fractional Programming (MILFP)”和Wikipedia.
如果它确实有效,你可以在纸浆中做到这一点(也许有人可以找出原因):
import pulp
data = [(481.79, 5), (412.04, 4), (365.54, 3)] #, (375.88, 3), (379.75, 3), (632.92, 5), (127.89, 1), (835.71, 6), (200.21, 1)]
x = pulp.LpVariable.dicts('x', range(len(data)), lowBound=0, upBound=7, cat=pulp.LpInteger)
numerator = dict((i,tup[0]) for i,tup in enumerate(data))
denom_int = dict((i,tup[1]) for i,tup in enumerate(data))
problem = pulp.LpProblem('Mixed Integer Linear Programming', sense=pulp.LpMinimize)
# objective function (doesn't work)
# TypeError: unsupported operand type(s) for /: 'float' and 'LpAffineExpression'