我有2个区域,每个区域都有多个供应源,每个区域每个月的需求量不同(总共6个月)。我的目标是使满足需求的总成本最小化。
目标是在一个月内汇总每个地区的供电量,并决定满足该地区的需求或将电力转移到另一个地区。
g_max_c = c_data[:,1] #maximum output for a supply source in region 1 (1:40)
g_min_c = c_data[:,2] #minimum output for a supply source in region 1 (1:40)
c_c = c_data[:,4] #cost per unit in region 1 (1:40)
g_max_nw = nw_data[:,1] #maximum output for a supply source in region 2 (1:36)
g_min_nw = nw_data[:,2] #minimum output for a supply source in region 2 (1:36)
c_nw = nw_data[:,4] #cost per unit in region 2 (1:36)
d_c = d_data[:,1] #demand in region 1 (1:6)
d_nw = d_data1[:,1] #demand in region 2 (1:6)
const loss = 0.04 #loss in line in case of transfer from region 1 to region 2 or vice versa
const cap = 2000 #capacity of the supply line between regions
@variable(uc, g_min_c[i] <= g_c[i=1:40,j=1:6]<=g_max_c[i]) #limits on production
@variable(uc, g_min_nw[k] <= g_nw[k=1:36,j=1:6]<=g_max_nw[k])
@variable(uc, 0<= tr_c[j=1:6]<= cap) #transfer supply from region 1
@variable(uc, 0<= tr_nw[j=1:6]<= cap) #transfer supply from region 2
@variable(uc, t12[j=1:6], Bin)
目标函数如下:
@objective(uc, Min, sum(g_c[i,j]*c_c[i] for i in 1:40, j in 1:6)+sum(g_nw[k,j]*c_nw[k] for k in 1:36, j in 1:6))
问题是如何在地区之间的供应线上施加约束并在一个月内计算产量?现在我有这个:
for j in 1:6
@constraint(uc, sum(g_c[i,j] for i in 1:40) == d_c[j]+t12[j]*tr_c[j]*(1-loss)-(1-t12[j])*tr_nw[j]*(1-loss))
for j in 1:6
@constraint(uc, sum(g_nw[k,j] for k in 1:36) == d_nw[j] + (1-t12[j]) * tr_nw[j]*(1-loss)-t12[j]*tr_c[j]*(1-loss))
for j in 1:6
@constraint(uc, sum(tr_c[j]+tr_nw[j] for j in 1:6)<= cap) #line constraints
所以基本上我想做的是总结一个月的产量,并决定是否在不超出传输限制的情况下将电力发送到另一个地区。
我在这里做错了什么?谢谢!