我正在尝试为大约100个节点和120个弧的网络流问题编写代码。我的一个约束还涉及矩阵乘法(潮流方程)。但是,作为初学者尝试使用CPLEX
非常具有挑战性。以下是我到目前为止所尝试的但是没有产生结果。请在CPLEX
中帮助更好地编码网络流量问题。非常感谢。
int B=...; //number of nodes
int L=...; //number of lines
range nodes =1..B;
range lines =1..L;
float cost_generation [nodes]= ...;
float cost_shedding [nodes]= ...;
float max_generation[nodes]= ...;
float load_demand[nodes] = ...;
float cost_transmission [lines]= ...;
float max_power_flow[lines] = ...;
float admittance[1..4][1..4] = ...;
dvar float+ G[nodes];
dvar float+ D[nodes];
dvar float+ F[lines];
最小化和(节点中的i,行中的k)
(cost_generation[i]*G[i] + cost_transmission[k]*F[k] - cost_shedding[i]*D[i]);
subject to {
forall (i in nodes)
0<=G[i]<=max_generation[i];
forall (i in nodes)
-load_demand[i]<=-D[i]<=0;
forall (k in lines)
-max_power_flow[k]<=F[k]<=max_power_flow[k];
forall (k in lines, i in nodes, j in nodes)
sum(i in nodes, j in nodes)
admittance[i][j]*G[j]-D[j]==F[i];
}