Sets

G in dex of generators /g1*g2/
N index of buses /n1*n3/
MAP(G,N) indicates in what bus are the generators connected /g1.n1, g2.n2/

Parameters
load(n)   load at bus N   /N3 0.85/

Table Gdata(G,*) Generator input data
                   Pmin         Pmax         cost
*                  (KW)         (KW)         ($/MWh)
g1                 0.15         0.6          6
g2                 0.10         0.4          7       ;

Table Ldata(N,N,*)    line input data
                   Sus          Limit
*                  (S)          (KW)
n1.n2              2.5          0.3
n1.n3              3.5          0.5
n2.n1              2.5          0.3
n2.n3              3.0          0.4
n3.n1              3.5          0.5
n3.n2              3.0          0.4   ;

Variables

z                 objective function
p(g)              output power of generator g
d(n)              angle at bus n ;
p.lo(g)= gdata(g,'pmin');
p.up(g)= gdata(g,'pmax');
d.fx('n3')=0;

Equations

cost             objective function
Maxpow(n,n)      maximum line power limit
Minpow(n,n)      minimum line power limit
Loadbal(n)       load balance equation ;
Alias(n,np);


cost..              z=e=sum(g,gdata(g,'cost')*p(g));

Maxpow(n,np)..      ldata(n,np,'sus')*(d(n)-d(np))=l=ldata(n,np,'limit');

Minpow(n,np)..      ldata(n,np,'sus')*(d(n)-d(np))=g=-ldata(n,np,'limit');

Loadbal(n).. sum(g $ map(g,n), p(g))+sum(np,ldata(n,np,'sus'))