我的决策变量是最小的:
DV2 = { "P1" : {"V1" : 38.11, "V2" : 21.47, "V3" : 27.98, "V4" : 24.95, "V5" :25.22},
"P2" : {"V1" : 31.10355934, "V2" : 34.20506007, "V3" : 30.46890595, "V4" : 33.74346353, "V5" : 29.47098217},
"P3" : {"V1" : 29.13518894, "V2" : 38.89035574, "V3" : 30.97508704, "V4" : 33.50849106, "V5" : 34.94861333}
}
它与运输问题类似,但目标函数为:
0.71 *成本* DV2 + 0.29 *风险* DV2,其中成本为:
cost= { "P1" : {"V1" : 0.2, "V2" : 0.22, "V3" : 0.2, "V4" : 0.2, "V5" :0.17},
"P2" : {"V1" : 0.2, "V2" : 0.21, "V3" : 0.19, "V4" : 0.19, "V5" : 0.19},
"P3" : {"V1" : 0.19, "V2" : 0.19, "V3" : 0.2, "V4" : 0.19, "V5" : 0.2}
}
风险是:
risk= { "P1" : {"V1" : 0.5, "V2" : 0.52, "V3" : 0.25, "V4" : 0.25, "V5" :0.57},
"P2" : {"V1" : 0.5, "V2" : 0.51, "V3" : 0.9, "V4" : 0.9, "V5" : 0.9},
"P3" : {"V1" : 0.6, "V2" : 0.6, "V3" : 0.7, "V4" : 0.8, "V5" : 0.9}
}
lowBound将是:
min1= { "P1" : {"V1" : 500, "V2" : 500, "V3" : 500, "V4" : 0, "V5" :500},
"P2" : {"V1" : 500, "V2" : 0, "V3" : 500, "V4" : 500, "V5" : 0},
"P3" : {"V1" : 500, "V2" : 500, "V3" : 500, "V4" : 500, "V5" : 500}
}
upBound将是:
max1= { "P1" : {"V1" : 5000, "V2" : 5000, "V3" : 5000, "V4" : 0, "V5" :5000},
"P2" : {"V1" : 5000, "V2" : 0, "V3" : 5000, "V4" : 5000, "V5" : 0},
"P3" : {"V1" : 5000, "V2" : 5000, "V3" : 5000, "V4" : 5000, "V5" : 5000}
}
如果有人可以告诉我如何在这种情况下公式化目标函数,将不胜感激,因为lowBound和upBound应该只取实数(这是我得到的错误)。
最佳答案
对于标量边界:
L = 1.0
U = 2.0
x = LpVariable.dicts("x",J,L,U,LpContinuous)
对于索引范围,请使用约束:
L = {"a": 0.2, "b" : 0.3}
U = {"a": 1.2, "b" : 1.3}
for j in J:
prob += x[j] >= L[j]
prob += x[j] <= U[j]
LP / MIP求解器将在预求解阶段内部根据单例约束进行界限。