$title Optimal power flow for a simple two-bus system $onText For more details please refer to Chapter 6 (Gcode6.1), of the following book: Soroudi, Alireza. Power System Optimization Modeling in GAMS. Springer, 2017. -------------------------------------------------------------------------------- Model type: QCP -------------------------------------------------------------------------------- Contributed by Dr. Alireza Soroudi IEEE Senior Member email: alireza.soroudi@gmail.com We do request that publications derived from the use of the developed GAMS code explicitly acknowledge that fact by citing Soroudi, Alireza. Power System Optimization Modeling in GAMS. Springer, 2017. DOI: doi.org/10.1007/978-3-319-62350-4 $offText Set Gen / g1*g2 / bus / 1*2 /; Scalar L2 / 400 / X12 / 0.2 / Sbase / 100 / P12_max / 1.5 /; Table data(Gen,*) a b c Pmin Pmax G1 3 20 100 28 206 G2 4.05 18.07 98.87 90 284; Variable P(gen), OF, delta(bus), P12; Equation eq1, eq2, eq3, eq4; eq1.. OF =e= sum(gen, data(gen,'a')*P(gen)*P(gen) + data(gen,'b')*P(gen) + data(gen,'c')); eq2.. P('G1') =e= P12; eq3.. P('G2') + P12 =e= L2/Sbase; eq4.. P12 =e= (delta('1') - delta('2'))/X12; P.lo(gen) = data(gen,'Pmin')/Sbase; P.up(gen) = data(gen,'Pmax')/Sbase; P12.lo =-P12_max; P12.up = P12_max; delta.fx('1')=0; Model OPF / all /; solve OPF using qcp minimizing of;