我尝试将启动成本添加到工作调度问题(无需启动成本即可工作)。应该在一个动态时期内优化时间表,即一天中的所有96个季度。我有96个价格的清单,我将其转换为矩阵:
prices = np.matrix([prices.as_matrix()])
prices = prices.T
length = prices.size
Range = range(np.size(prices))
以及以下变量:
c_turb = -100
min_turb = 0
max_turb = 8
c_pump = -50
min_pump = -10
max_pump = 0
这是我的客观功能:
prob = pulp.LpProblem("The PSP",LpMaximize)
prob +=lpSum([(price[i])*pump[i] for i in RANGE]
+ [price[i]*turbine[i] for i in RANGE]
+ [z_turb[i]*c_turb for i in RANGE]
+ [z_pump[i]*c_pump for i in RANGE])
我的变量定义如下:
pump = LpVariable.dicts("pump", RANGE,upBound=0, cat="Integer")
turbine = LpVariable.dicts("turbine", RANGE, lowBound=0, cat="Integer")
pump_status=LpVariable.dicts("pump_status", RANGE, cat="Binary")
turbine_status=LpVariable.dicts("turbine_status", RANGE, cat="Binary")
z_pump = LpVariable.dicts("pump_startup", RANGE, cat="Binary")
z_turb= LpVariable.dicts("turbine_startup", RANGE, cat="Binary")
for i in pump:
pump[i].lowBound = -10 #bounds can vary for each i but irrelevant for problem
for i in turbine:
turbine[i].upBound = 8
现在我添加了以下约束:
for i in range(1,length+1):
n=range(0,i)
prob += lpSum((-0.8*pump[i]-turbine[i])*0.25 for i in n ) <=50 prob += lpSum((-0.8*pump[i]-turbine[i])*0.25 for i in n) >=0
prob += pump[i]>=min_pump*pump_status[i]
prob += pump[i]<= max_pump*pump_status[i]
prob += turbine[i] >= min_turb * turbine_status[i]
prob += turbine[i] <= max_turb * turbine_status[i]
if i == 1:
prob += z_pump[i] == pump_status[i]
else:
prob+= z_pump[i]>=pump_status[i]-pump_status[i-1]
prob+= z_pump[i]<=pump_status[i]
prob+= z_pump[i]<=(1-pump_status[i-1])
if i == 1:
prob += z_turb[i] == pump_status[i]
else:
prob+= z_turb[i]>=turbine_status[i]-turbine_status[i-1]
prob+= z_turb[i]<=turbine_status[i]
prob+= z_turb[i]<=(1-turbine_status[i-1])
其中turbine_status
和pump_status
应该是此特定季度i
中涡轮机/泵的开/关状态。
z_pump
和z_turb
应存储启动次数,即从0到1的状态切换。
但是,我收到了错误:prob += pump[i]>=min_pump*pump_status[i]
。不幸的是error info: 96
并不是真的很冗长....
有人能指出我正确的方向吗?
谢谢!!