Professional Documents
Culture Documents
Power Applications GAMS
Power Applications GAMS
Power Applications GAMS
1, February 1999 15
Debabrata Chattopadhyay
Abstract: This paper gives a systematic exposure to modeling transformation capabilities. These two developments have enabled
language as applied to power system optimization problems. the modelers to develop and test optimization models efficiently.
Specific reference to the GAMS (General Algebraic Modeling The tremendous effort that goes in developin,g an optimization
System) language has been made keeping in mind the popularity, model has a significant part in debugging lengthy computer codes
flexibility and available algorithmictools in it. An overview of the
GAMS language followed by simplistic examples are provided to (such as FORTRAN), data preparation, data transformation and
illustrate the ease and efficiency with which power system models report generation. A number of efficientmodeling languageshave
can be developed and experimentedwith. References are cited to been developed which makes use of both the development in
the related mathematicalprogramming literature as well as some improved database management and mathematical programming
selected application of GAMS in power system area. Finally the techniques. One of the most popular and flexible languages among
pros and cons of reliance on modeling languages have been these is the General Algebraic Modeling Sys1.em (GAMS) [I].
discussed. GAMS was originally developed through a World Bank funded
Keywords: Optimization, Modeling Language, Planning
study in 1988. The initial impetus for the development of GAMS
arose 'lout of the frustruting experiences of an economic modeling
I. INTRODUCTION group at the WorldBank ... The programmers in the group wrote
FORTRANprograms to prepare each model for solution; the
Application of optimization techniques to power system work was dull but demanding, and errors were easy to make and
problems have been several decades old now and there seems to hard toJind'.Since similar experiences are experienced by and
be a competition among the sophistication of the optimization large in most of the application areas of optimization, GAMS as
algorithms and the growing complexity of power system planning well as other modeling languages have found application in a
and operations related problems. The growth in complexity in variety of disciplines like finance, engineering, energy,
power system optimization problems has stemmed fiom three environment, management, economics and mathematics. It has
basic objectives: improving accuracy of the power system models also found some useful application in power system in recent
to capture the reality better, growing system size because of years.
integration of system over larger geographical areas for better
economy and reliability of operation, and also due to new This paper details the various features of GAMS with
emerging issues e.g., environmental issues, regulatory issues. specific reference to its applicability in various classes of
Research in power system optimization model development, thus, optimizationproblems in power system. It provides some simple
continue to be an active area. Development of optimization examples to illustrate model development in GAMS for power
models also form a part of learning and understanding several system planning related problems. Finally, it gives a partial list of
power system phenomena in most of the graduate level power some applications of GAMS available in the power system
system programs. There has been tremendous growth in literature. In the concluding session, a summary of the various
mathematical programming techniques and development of features of GAMS is presented and cases where application of
computer codes to solve large scale optimization models over the modeling languages should be limited have belen discussed. The
past four decades. There has also been significant development prime objective of h s paper has been to motivate students and
in relational database for improved data organization and researchers in the field of power system to make use of the
advancement in the modeling languages for optimization model
development in an efficient way. The specific reference to GAMS
PE-640-PWRS-0-12-1997 A paper recommended and approved by has been made keeping in mind its popularity, flexibility and
the IEEE Power Engineering Education Committee of the IEEE Power constant research and development to add new features to it over
Engineering Society for publication in the IEEE Transactions on Power
Systems. Manuscript submitted October 7, 1996; made available for
the years. However, the emphasis has been laid primarily on
printing December 12, 1997. exposing the readers to a generic description of modeling language
features, why, how and where these should be used, rather than
"teaching GAMS language". Section I1 of the paper gives an
overview of the GAMS language , In section 111, some simple
illustrative examples are given to help understanding how the
modeling language simpllfy programmingfor model development.
Section IV concludes the paper with a caution why blind reliance
on modeling languages for power system modeling may not be the
best thing to do.
The basic structure of a mathematical model coded in GAMS has Declaration and definition
the components: sets, data, variable, equation, model and output e.g.,(load flow constraints,voltage limit,
(Fig.1). An example of the elements of an optimal power flow generation limits on MW and MVAr, cost functioi
(OPF) model is given for the readers to relate these components etc.}
to power system problem. In general, any optimizationproblem
can be formulated using these components. The data
presentation in GAMS can be done in its most elemental form
using tables, columns etc. There are standard IF-ELSE, WHILE, Model and Solve Staemene
LOOP, exception handling (CONTROL statements) logic
available which give the mherent flexibility to use GAMS almost Declaration, assignment of appropriate solver
like any programming language while retaining the basic e.g., {Model OPF; Solve OPF Using NLP
advantages. There are p o w e h l output specification facilities Minimizing Cost}
like PUT whch can generate reports in any desired format Also,
the output can be directly linked to spread-sheet programs for output
graphical analysis etc. Excellent debugging features exist for
quick and effective identification of errors. No attempt is made
Display, Put
here to give the syntax of GAMS and the interested readers are
referred to GAMS Users' Guide [I] for such details. e.g., (display optimal generation level, line flows,
voltage levels etc}
2.3 The GAMS Tool kit
Fig.1: Structure of a GAMS model
GAMS provides powefil solvers for the following classes of
optimization problems: The tool kit in GAMS embodies several man-years of research that
has gone into developing and fine tuning the algorithms in each
* Linear programming (LP) variants of Simplex category of problems. GAMS also has the unique feature of
methods and Interior Point methods primal, Primal- providing a common language that can make use of a variety of
Dual and Primal-Dual Prcdiotor-CorreGtor mGthods) solvers developed by dmerent research group/companies. Table- 1
Non-linear programming (TVLP) (variants of Gradient gives the list of currently available GAMS solvers. References to
. methods)
Linear mixed integer programming (MIL& (various
the basic literaturelreferencemanuals have been made for further
explorationon specific solvers. There is probably no solver which
. Branch and Bound Algorithms)
Non-linear mixed integer programming (MINLP)
(based on Outer Approximation Algorithm)
can be labeled as "best" and their performance is closely linked to
the structure of the problem. The choice of solver is thus dependent
on the understanding of the special structure of the problem and
some experimentation.
B-matrix
Table LossCoff (ij)
1 2 3
LP BDMLP,MINOS 5 [2],ZOOM[3],
MPSX [4] , SCICOMC [5],APEX 1 0.000136 0.0000175 0.000184
2 0.0000175 0.000154 0.000283
IV [6], LAMPS, OSL, XA, CPLEX 3 0.000184 0.000283 0.00161
[71
MINOS 5 , CONOPT [8], GRG 2 Scalar Load /300/ ;
[9], NPSOL [lo] "3. Declaration of variables with explanatory text
Variables
IV, XA, OSL, LAMPS
P(i) optimal generation level of i
I I DICOPT-H [l 11 I Cost minimum cost
alias (ij) ; After solving the model EDC, the output (Fig.3) looks like:
* implies set i = set j
*2. Data presentation
____ 57 VARIABLE P.L optimal generation level of i
Table Data(i,head)
1 193.974, 2 69.765, 3 53.000
Low UPP A B C ____ 57 VARIABLE C0ST.L 3666.122 minimum cost
* MW MW %/MWz %fMW 0 =
One can immediately see the major advantages of using GAMS DemCons(@.. Sum((i,step),S(i,step,q))+Sum(i,Minm(i)*w(i,q)) =g=
Demand(q)+LOSS(q) ;
even for this simple problem:
coding is easy, fast and compact CapCons(i,step,q).. S(i,step,q) =1= Power(i,step)*w(i,q) ;
the number of generators can be 'increased by simply
adding the member to the set and data set without * Relwul fixes the initial state of all units to "on" position
Relwul(i,"l").. w(i,"l")-1 =I= u(i,"l") ;
changing the variables, equations, model, solve
statements. In fact, the 40 unit Tai Power system case Relwu2(i,q)$(ord(q) gt l)..w(i,q)-w(i,q-l) =I= u(i,q) ;
study reported in [12] has been carried out with
* Relwvl fixes the initial state of all units to "on" position
prohibitive zones in the heat rate curve modeled using
MINOS using the same model with additional
-
Relwvl(i,"l").. 1 w(i,"l") =I= v(i,"l") ;
TABLE MDATAT(M,LABELS) DATA FOR THERMAL PLANTS ECH(MH,T).. SUM(B, DUR(B)*ZH(MH,B,T)) =L=
MDATAH(MH,"E-FACT")
TABLE TUF'(M,TE) UPPER BOUND ON THERMAL UNIT EXPANSIONS *(MDATAH(MH,"INITCAP") t SUM(V%VS(T,V),
HLO(M,TE) LOWER BOUND: HYDRO UNIT EXPANSIONS (MW) RCH(MH).. SUM(T, HH(MH,T)) =L= MDATAH(MH,"MAXCAP");
HUP(M,TE) UPPER BOUND: HYDRO UNIT EXPANSIONS (MW)
TM(M,TE) LOWER BOUND: THERMAL UNIT EXPANSIONS (MW) CAT(MT).. HTT(MT) =E= SUM(V, HT(MT,V));
* $( ) statement here applies on the equation name -this is a very useful way of This list is far from exhaustive and is intended to just give an idea
* restricting the redundant equations while keeping the general equation format of the variety of optimization problems that has been addressed
using modeling languages.
CCT(MT,V,T)%VS(T,V).. SUM(B, ZT(MT,V,B,T)) =L=
MDATAT(MT,"AVAIL"y(KIT(MT,V)
t HT(MT,V),
20
ACKNOWLEDGEMENT Deb Chattopadhyay received his B.Engg degree in 1990. He was with the Indira
Gandhi Institute of Development Research (IGIDR) between 1990 and 1995. He
I take this opportunity to thank Dr.Alex Meeraus and Dr.Ramesh Raman of spent a year (1995-96) at the Howard University, USA He served the Indian set up
GAMS Development Corp, for helpful discussions and providing an evaluation of PTI between 1996-97. He is currently an academic staff with the Dept of
copy of GAMS software. The opinions expressed in this paper, however, do not Management, Univ of Canterbury, New Zealand. His research interests include
necessarily reflect their views. application of optimization techniques to power system planning and operations.
21
Cost(p). .objs=e=sum(t,G(t,’vc’)~a(t,p));
The paper makes available useful information on model- Pmi(t,p). .o(t,p)=g=G(t, ’pmin’)*v(t,p) ;
ing languages to students, researchers and practitioners Cma(n,nl,p)..Ln(n,nl,’ss’)t(ag(n,p)-ag(nl,p))=l=Ln(n,nl,’cp’);
in a convenient and compact fashion. We would like to
Cmi(n,ni,p). .Ln(n,nl,’ss’)*(ag(n,p)-ag(nl,p))=~-Ln(n,ni,’=p’) ;
make the following remarks:
*** 5 . Declaration and definition of master problem equations
Equations Mast Benders master problem cost
1. A fundamental capability of current modeling lan- Cutci)
Rvy(t.k)
Benders cut
Logic of plant operation
guages is the ability to perform loops. This makes it Fact(k) Feasibility cut;
possible the implementation of decomposition proce- Mast..abjm=e=r+sum((k.t)$p(k).C(t,’fc’)*tpv(t,k)+C(t,’sc1)*tpy(t,k));
dures and therefore the treatment of dynamic mul-
Cut (it), .r=g=tot(it)+sum((t ,k)$p(k) ,l(it ,t ,k)*(tpv(t,k)-val(it ,t,k))) ;
tiperiod problems, such as power system planning
problems. Through the use of dynamic sets it is Rvy(t,k)$p(k). .tpy(t,k)=g=tpv(t,k)-tpv(t.k-l);
possible to sequentially solve problems of increasing Fact(k) $p (k) .. sum(t, G(t ,’pmax ’) *tpv(t .k) 1=g=sum(n, Ld (n ,k) ) ;
dimension, and these problems appear in decompo- t** 6 . Initial values
sition procedures. Figure A below shows a GAMS tpv.fx (t , ini’)EO:
code to solve a multiperiod DC OPF problem in- I** 7. Model and Solve statement in a LOOP
cluding start up and shut down of units, using Ben- Model SBP Benders Subproblem / C a s t , B p w , P m a , P m i , C , C m i / ;
Model MST Benders Master Problem /Mast,Cut,Rvy,Fact/;
ders decomposition. This figure illustrates the use of
loops and dynamic sets in GAMS. Loop(i$((abs(ap-in)/(abs(in)+l)) gt le-10).
basically the same modeling capabilities as GAMS. Solve MST using MIP minimizing objm;
t
in
v.fx(t.k)
-
variables updating *
0bjm.L;
= tpv.l(t,k);
*** 1. Set Definitions y.fx(t,k) = tpy.L(t,k);
Sets k periods of time /ini,1*3/ tot(i+l) = 0.;
1 loop iterations /1*10/
n
t
nc(t.n)
buses
thermal units
bus-unit
/bl,b2/
/al,a2/
/al.bi.aZ.b2/
*
p(k)$(ord(k) ne 2) no; -
only first period is considered I
Table Ln(n,nl,cln) line susceptance and capacity limit We finally would like to congratulate again the author
88 cp for an educationally useful paper.
* (puOhm) (puMVa)
bl.b2 1.2 1.5;
References
Scalars sp upper bound cost /inf/
in lower bound cost /-inf/;
[A] A. Brooke, D. Kendrick and A. Meeraus. GAMS/Cplex 4.0
Parameters l(i,t,k) marginal cost /l.(al,a2).1*3 O./
val(i.t,k) value of status variable /l.(al,a2).1+3 O./
User Notes. GAMS Development Corporation. Washington,
tot(i) subproblem cost /l o./; 1996.
*t8 3. Declaration of variables [B] R. Fourer, D. M. Gay and B. W. Kerninghan. A M P L : A
Positive Variables o(t,k) ,v(t,k) ,y(t,k),r;
Free Variables ag(n,k) ,objs,objm;
Modeling Language for Mathematical Prqgmmming. Scien-
Binary Variables tpv(t,k) ,tpy(t,k) ; tific Press. San Francisco, 1993.
ttt 4 . Declaration and definition Of subproblem equations [C] J. Bisschop and R. Entriken. AIMMSr The Modeling System.
Equations Cast Benders subproblem cost Paragon Decision Technology. Haarlem, 1993.
Bpv(n.k) Power balance at every bus
Pma(t,k) Maximum output power
Pmi(t,k) Mini” output power
Cma(n,nl,k) n-nl m a x line transmission capacity
22
Deb Chattopadhyay (University of Canterbury, solvers may be obtained from the GAMS web page:
Christchurch, New Zealand): I greatly appreciate the http://www.gams.com;
comments by Dr. Conejo and Dr. Alguacil which add value to
the content of the original paper. The intent of the paper has 3. Other Modelling Languages: AMPLIAIIMS are of
been to provide a comprehensive overview of modelling more recent origin compared to GAMS. In my
language to enable students and researchers in power system opinion, both these languages have relatively easier
area with basic information. Nevertheless, the additional syntax compared to GAMS, and hence easier to
information provided by the discussors is useful. Further to learn. As mentioned in the paper, reference to
their comments, I would like to add the following: GAMS was made mainly because it
Solving within a LOOP: The multi-period OPF using e has been more widely used in a range of
Bender’s decomposition (Figure-A) is an excellent disciplines for several years now,
example of using the solve facility within a LOOP. It 0 provides access to a much larger number of
should be reckoned that, commercial solvers. Some of the solvers are not
(a) This special application of Bender’s available to any other modelling languages for
decomposition could be achieved at a much special classes of problems such as DICOPT
lower effort using GAMS features compared to (non-linear MIP problems), MILES/PATH
its implementation using conventional (MCP problems), and MPSGE (for CGE
programming language, and, problems), and
(b) ?‘he Bender’s decomposition computational a has found some application in power system
scheme for the multi-period OPF problem (for area;
large scale application) may be conveniently
benchmarked with standard MIP algorithms I wish to thank Dr. Conejo and Dr. Alguacil for making
like CPLEXlXNZOOM etc at minor this educational paper more informative.
incremental efforts.
Some explanatory comments on the program in Figure-A [D] Y. Smeers and W. Jing-Yuan, “Spatially ohgopolistic
may be useful. Firstly, the two sub-models (Master and model with opportunity cost pricing for transmission
Slave sub-problems in Bender’s iterative scheme) are capacity reservations: a variational inequality approach’
CORE Discussion Paper 9717, Center for Operations
defined in sections 1-6 (Fig A). In section 7, the first Research and Econometrics, Universite Catholique de
(outer) LOOP is defined over a set I and includes a solve Louvain, Belgium.
statement for the Master. A conditional statement using $
is stated to define the convergence criterion on the
difference between upper and lower bounds produced by
the Master and Slave respectively. The second (inner)
loop includes the Slave problem which uses information
from the Master. For example, the MW output from
generator t in period p denoted as o(t,p) is constrained in
the Slave by the status of the unit (ON/OFF) v(t,p)
determined in the Master problem. Note that
v.fx(t,k)=tpv.l(t,k) (in section 7 ) means variable v() is
fixed at the level of tpv() where the later is the binary
decision variable in the Master). Many other iterative
schemes can be implemented using this facility. It should
be mentioned that load flow schemes can also be
implemented using GAMS as a simultaneous system of
non-linear equations and further, may be included as part
of an iterative scheme;