使用Cplex编码网络模型

时间:2016-10-25 13:58:11

标签: cplex

请帮帮我!我是CPLEX的新用户。我尝试使用CPLEX编写网络模型。我的网络有24个节点和38个线(弧),我的一个约束有矩阵乘法。以下是我能想到的。

我想知道模型是否正确。

其次,我将我的模型和数据链接到excel,但是当我运行配置时,它给出了一个内部错误。请问是什么导致了这一点。

请帮帮我。感谢。

//parameters

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 Mmatrix[1..38][1..24] = ...;

//Variables

dvar float+ G[nodes];
dvar float+ D[nodes];
dvar float+ F[lines];

minimize sum (i in nodes, k in lines)
(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)
 F[k]==Mmatrix[k][i]*(G[i]-D[i]);
  }

我的数据

B=24;
L=38;

SheetConnection my_sheet("Area 1.xlsx");

cost_generation from SheetRead(my_sheet,"'Branches'!Q3:Q26");
cost_shedding from SheetRead(my_sheet,"'Branches'!R3:R26");
cost_transmission from SheetRead(my_sheet,"'Branches'!E3:E40");
max_generation from SheetRead(my_sheet,"'Branches'!L3:L26");
load_demand from SheetRead(my_sheet,"'Branches'!M3:M26");
max_power_flow from SheetRead(my_sheet,"'Check'!C1:C38");
Mmatrix from SheetRead(my_sheet,"'M Matrix'!B2:Y39");

0 个答案:

没有答案