Originally posted by: DannyYoung
Thanks, please find below and attached as requested.
I also observed another problem, when I tried to change the max power flow values to zero in the excel, the model still run using the previous data.
Please help.
//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 P[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.5*max_generation[i]<=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 (i in nodes)
P[i]==G[i]-D[i];
forall (k in lines)
F[k]==sum (i in nodes)Mmatrix[k][i]*P[i];
}
B=24;
L=38;
SheetConnection my_sheet("Area.xlsx");
cost_generation from SheetRead(my_sheet,"cost_generation");
cost_shedding from SheetRead(my_sheet,"cost_shedding");
cost_transmission from SheetRead(my_sheet,"cost_transmission");
max_generation from SheetRead(my_sheet,"Max_generation");
load_demand from SheetRead(my_sheet,"Load_demand");
max_power_flow from SheetRead(my_sheet,"max_powerflow");
Mmatrix from SheetRead(my_sheet,"Mmatrixx");
G to SheetWrite(my_sheet,"resultg");
D to SheetWrite(my_sheet,"resultd");
P to SheetWrite(my_sheet,"resultp");
F to SheetWrite(my_sheet,"resultf");
#DecisionOptimization#OPLusingCPLEXOptimizer