问题
So I have 3 datasets as follows, Cost data:
Vcost
Out[325]:
P1 P2 P3
Vendors\Product List
V1 0.204403 0.208178 0.198216
V2 0.220126 0.213755 0.198991
V3 0.204403 0.191450 0.203258
Risk data:
Vrisk
Out[326]:
P1 P2 P3
Vendors\Product List
V1 0.198598 0.210145 0.198157
V2 0.172897 0.178744 0.193548
V3 0.219626 0.200483 0.205069
Decision variables data:
Vdecision
Out[327]:
P1 P2 P3
Vendors\Product List
V1 a b c
V2 f g h
V3 k l m
My objective is to minimize 0.71*Cost*x + 0.29*Risk*x subjected to constraints of row summation and column summation of the decision variable matrix. So basically the objective fuction will be something like:
0.71*(0.204*a+0.208*b+0.198*c....+0.203*m) + 0.29*(0.198*a+0.210*b+0.198*c....+0.205*m)
I'm trying to use the PuLP module and defined the function as:
prob = LpProblem("Inventory Optimization", LpMinimize)
prob += lpSum([0.71*i*x for i,x in zip(Vcost.values,Vdecision.values) + 0.29*j*x for j,x in zip(Vrisk.values,Vdecision.values)])
But I'm getting the following error:
TypeError: can't multiply sequence by non-int of type 'float'
Can somebody help me formulate the objective function please?
来源:https://stackoverflow.com/questions/49194399/linear-optimization-in-python-using-pulp