Dear Friends,
I have a problem with this code. My objective is to minimize the cost in order to find the optimal power flow in a power system. The cost is equal to the output power from all generators multiplied by the unit cost of each generator. So, it should be =e=. However, when I put =e=, the solution is 9 which is not logical at all because the least MW costs 10 and I have 10 MWs. When I put =g=, the solution becomes 1056 and it is logical. So, what is the problem?
Set
bus / 13 /
slack(bus) / 3 /
Gen / g1g3 /;
Alias (bus,node);
Table GenData(Gen,*) ‘generating units characteristics’
b pmin pmax
g1 10 0 65
g2 11 0 100;
Set GBconect(bus,Gen) ‘connectivity index of each generating unit to each bus’ / 1.g1, 3.g2 /;
Table BusData(bus,*) ‘demands of each bus in MW’
Pd
2 100;
Set conex ‘bus connectivity matrix’ / 1.2, 2.3, 1.3 /;
conex(bus,node)$(conex(node,bus)) = 1;
Table branch(bus,node,*) ‘network technical characteristics’
x Limit
1.2 0.2 50
2.3 0.25 100
1.3 0.4 100 ;
branch(bus,node,‘x’)(branch(bus,node,'x')=0) = branch(node,bus,'x');
branch(bus,node,'Limit')(branch(bus,node,‘Limit’)=0) = branch(node,bus,‘Limit’);
branch(bus,node,‘bij’)$conex(bus,node) = 1/branch(bus,node,‘x’);
Variable OF, Pij(bus,node), Pg(Gen), delta(bus);
Equation const1, const2, const3, const9, const10, const4, const5, const6, const7, const8;
const1(bus,node)$conex(bus,node)…
Pij(bus,node) =e= branch(bus,node,‘bij’)*(delta(bus) - delta(node));
const2(bus)…
sum(Gen$GBconect(bus,Gen), Pg(Gen)) - BusData(bus,‘Pd’) =e= sum(node$conex(node,bus), Pij(bus,node));
const3…
OF =e= sum(Gen,Pg(Gen)*GenData(Gen,‘b’));
const9(bus,node)$conex(bus,node)…
Pij(bus,node)=l=branch(bus,node,‘Limit’);
const10(bus,node)$conex(bus,node)…
Pij(bus,node)=g=-branch(bus,node,‘Limit’);
const4(Gen)…
Pg(Gen)=l=GenData(Gen,‘Pmax’);
const5(Gen)…
Pg(Gen)=g=GenData(Gen,‘Pmin’);
const6(bus)…
delta(bus)=l=pi;
const7(bus)…
delta(bus)=g=-pi;
const8(bus)…
delta(‘3’)=e=0;
Model loadflow / all /;
solve loadflow minimizing OF using lp;
display Pij.l, of.l, pg.l, delta.l;