Solving a Classical Optimization Problem Using GAMS Optimizer Package: Economic Dispatch Problem Implementation

This paper presents an effectiveness strategy to model and solve nonlinear mathematical optimization problems in electrical engineering using General Algebraic Modeling System (GAMS) for undergraduate students. A classical problem known as economic dispatch has been selected to show the need of using mathematical tools to solve a large scale optimization problem related with engineering. The economic dispatch is a classical optimization problem in operation of thermal electric systems, being the main idea to find an economical operation for thermal generators. This operation is based on a quadratic cost curve with some operating constraints, i.e., power balance and generation capacities. A numerical simulation is implemented using GAMS optimization package in demo version. This research has been developed with the support of 36 students of the course of Regulation and Operation of Electrical Systems (ROES) in the program of Electrical Engineering at Universidad Tecnológica de Pereira (UTP). 1 Universidad Tecnológica de Pereira, o.d.montoyagiraldo@ieee.org, http://orcid.org/ 0000-0001-6051-4925, Pereira, Colombia. Universidad EAFIT 39| Solving a Classical Optimization Problem Using GAMS Optimizer Package: Economic Dispatch Problem Implementation


Introduction
The progress of the technology is always related with the mathematical advances that allows to understand in a better way how the things work [1], [2]. For this reason, in case of undergraduate courses one of the most important focus is the chance to provide to the students the largest amount of tools available to solve engineering and science problems, specifically in areas of applied mathematics. In this way, they can better understand how to analyze real phenomena through simulation scenarios [3], [4].
The simulation tools have become one of the most important components in the integral formation of the future engineers and scientists, because these tools allow to improve their abilities to understand a particular phenomena, and also explore different forms to propose effective solutions for the problem under study. In this context, in recent years many research groups have contributed to develop multiple toolboxes to simulate different areas of the knowledge. In case of electrical engineering it is possible to find specialized software for electrical power system simulation such as DIGSILENT [5], [6], PSCAD [7], NEPLAN [8] or SIMULINK [9], among others. In case of optimization packages, commercial software applications are found, i.e., GAMS [10], [11], [12], AMPL [13], LINGO [14], Python or [15] MATLAB packages [16], [17], [18], etc.
In regards with simulation toolboxes, it is not an easy task to introduce undergraduate students in this type of tools, because it is strictly necessary that the undergraduate student had developed mathematical analysis skills [19], [20], [21], [19], [22]. In addition to this, it is also necessary that they understand whether the results obtained from simulation are correct. For aforementioned reasons, teaching the way on how to use a certain simulation package, it is required that the instructor evaluates the previous students' knowledge, in order to detect failures in their previous formation. If there are failures, then it is necessary to correct them making the undergraduate students ready to understand the basic concepts to use computational tools. This paper presents basic ideas to introduce undergraduate students in optimization problems and the available tools for their solutions. A GAMS optimization package was selected as optimizer interface, since a demo version for academic purposes is available [23]. The rest of this document is organized as follows: In section 2 basics concepts about computational thinking skills are presented. In section 3 the GAMS optimization package is presented including a numerical example. In section 4 the mathematical formulation of classical economic dispatch problem is shown. In section 5 the GAMS implementation of classical economic dispatch problem is presented. In section 6 the main conclusions derived from this work are presented, following by the acknowledges and references list.

41|
Solving a Classical Optimization Problem Using GAMS Optimizer Package: Economic Dispatch Problem Implementation 2 Basic knowledge for the future engineers Considering the high advantages of the technological developments, nowadays it is practically impossible to imagine a world without the presence of the computers [24], [25]. In general a computer can be considered as any electronic device that can be operated using basic commands with the capacity to interact with other electronic devices such as cellphones, tablets or smart-TVs, among others [26], [27]. In this sense, many people around the world have basic knowledge about how to use technological devices. Nevertheless, they do not have the possibility to improve their skills, due to the lack of effective teaching courses to learn how to use these devices efficiently and responsibly, in order to prevent possible health problems.
The case of undergraduate students is not the exception, because the students lack of skills to explode the big computation capacities of modern technological devices such as smart-cellphones, personal computers, among others.
Due to reasons mentioned above, professors in all education centers are called to teach the main advantages of using free software to solve real life problems [28], [29]. In case of undergraduate students of engineering program, the focus is to know the correct way to use computers for solving multiple engineering problems.
To improve the computation abilities in undergraduate students, it is strictly necessary that the professors can find the best way to teach computational thinking [30], [31], [32]. A basic definition of computational thinking would be formulating things with enough clarity, and in a systematic enough way, that one can tell a computer how to do them. Figure 1 presents the basic ideas to develop computational thinking skills for undergraduate students using an ordered sequence of steps.
The block diagram in Figure 1 presents the main aspects of development computational thinking skills [31]. For this reason, the next items show the most relevant aspects related with each one.
• Decomposition: In this step it is very important to split the problem up in small pieces using the available information.
• Pattern recognition: This step classifies the information by its parti-

|42
Ingeniería y Ciencia Oscar Danilo Montoya Giraldo cular characteristics, in other words, here all information is organized through the identification of similar patterns for each component of the problem.
• Algorithm design: This step proposes possible solutions of the problem using a set of ordered steps, which have been selected based on the information obtained in the above steps.
• Review and feedback : This step is essential in the learning process of the computational thinking skills. Here a full process review is done in order to identify possible mistakes in the aforementioned steps. Then, this information is used to do a feedback in each of them to correct the possible problems.
• Results analysis: In this point of the learning process, all students need to have critical abilities to analyze the final solution obtained for the particular problem. In this step the final solution needs to fulfill all problem requirements and be completely feasible.
There will be mistakes in any computational problem implementation, as long as the correct sequence to do the particular process is understood. For this reason, it is really important that professors continuously correct their students during the learning process.

GAMS optimization package
General Algebraic Modeling System (GAMS) is one of the most powerful optimizer package available for industrial applications or academic research in areas of applied sciences or mathematics [33]. In case of academical applications, full version can be obtained after paying the license, otherwise the demo version is available with some restrictions of number of variables and solvers. [23].

Main characteristics of GAMS
The students can easily install demo version from [23] by selecting a operative system. The latest demo version 24 Figure 1: Basic block diagram to understand the correct sequence to teach computational thinking skills the installation process. The main advantages of using GAMS to implement mathematical optimization models are: • High computer capacity specifications are not required • It is easy to download and to install.
• It has good manuals and tutorial, and many books with multiple examples are available.
• The demo version has more than 50 different specialized solvers.
• It is possible to solve, linear or nonlinear models, considering continuous, discrete or binary variables, among other combinations.
These characteristics easily allow to install GAMS optimizer toolbox on personal computers and let the undergraduate students can explore by themselves the main advantages of using structure languages to solve mathematical problems. In the case of the undergraduate students of the course of ROES from electrical engineering program at UTP, the following references have been selected: the GAMS official manual [23] and the book Building and Solving Mathematical Programming Models in Engineering and Science [33], to understand the basic details for implementing problems with GAMS optimizer.

Commands needed to solve an optimization problem in GAMS
The implementation of any optimization problem in GAMS requires that the undergraduate students have basic skills using programming languages like C, C++ or Python, among others [20], [21], [19], [22]. The programming windows of GAMS just receive plain text. In this window, the necessary commands are written to solve any optimization problem [23], [33].
In order to implement a mathematical model using GAMS optimization package the following steps are needed: 1. Define the decision variables using some of these definitions: variables, integer variables, positive variables or binary variables. The selection of the type of variables depends on the nature of the optimization problem i.e. binary programming model or mixed-integer nonlinear programming model, among others.
2. Define the set of necessary equations using the reserved word equations. First, the names of the equations are defined and then their mathematical expressions are written.
3. Select the name of the model using the reserved word: MODEL name.

45|
Solving a Classical Optimization Problem Using GAMS Optimizer Package: Economic

Dispatch Problem Implementation
For more details to use the reserved words and more commands to implement mathematical models in GAMS it is strictly necessary to refer [23].
In the next section a first heuristic example to solve the classical transportation problem using GAMS optimization package will be shown.

An heuristic example
The next example has been adapted from [33]. Suppose a factory has m production plants and n stores. A single product is shipped from the production plants to the stores. Each production plant has a given level of supply, and each store has a given level of demand. The transportation costs are also given between every pair of production plant and store, and these costs are assumed to be linear. Explicitly, the assumptions are: • The total supply of the product from production plant i is a i , where i = 1, 2, ..., m.
• The total demand for the product at store j is b j , where j = 1, 2, ..., n.
• The cost of sending one unit of the product from production plant i to store j is equal to c ij , where i = 1, 2, ..., m and j = 1, 2, ...n.
The objective is to solve this linear programming problem by finding the minimum transportation cost meeting with all demands in the stores and production capacities in the production plants.
By using GAMS to implement this mathematical model the result is presented in Algorithm 1. The final solution obtained from GAMS after solving the transportation problem is given by Figure 2.
It is important to mention that, in the general solution presented in Figure 2 all variables are integers; specifically, x 12 , x 21 , x 31 and x 32 take values different from zero and the global minimum of this example corresponds to z = 510. Additionally, for this linear-integer programming model there is a unique solution called global optimal solution. 17 4* x31 + 6* x32 ;  Notice that in the implementation presented in Algorithm 1 using GAMS to solve the classical transportation problem all the equations were written one by one. Nevertheless, when the mathematical model starts to increase, using this type of implementation is not efficient, because it is possible to have typo mistakes that could be difficult to find in large codes.
For this reason, the students need to understand how to write mathematical models in GAMS using compact notation. To use the latter to represent any mathematical optimization problem it is strictly necessary to use sets, mathematical functions and sums or products. In case of classical transportation problem, it can be rewritten using compact formulation as given in (2).
where C (i, j) is the transportation cost to send quantity x of product from the production plant i to store j. The variable x (i, j) corresponds to the decision variable of the problem (positive variable), a(i) is the maximum capacity of production in the i − th plant and b(j) represents the total demand in the j − th store.
To implement the mathematical model defined by (2) it is necessary to use two new reserved words in the script. The word SETS defines the necessary indices in the corresponding decision variables. The word TABLE is used to include all numerical information of the problem.
In Algorithm 2 the compact formulation for classical transportation problem is presented .
After solving the compact model presented in Algorithm 2 in GAMS, it is obtained the same solution presented in Figure 2, which obviously implies that both mathematical implementations are equivalents.
The main advantage of a compact formulation is that if the problem size is increased, it is only necessary to increase the numerical information of the problem, due to GAMS automatically includes the number of equations to solve it. This does not happen with the explicit formulation, as it is necessary to expand all the model and is not computationally efficient.
For more information about SETS definition or mathematical functions available in GAMS, refer to [23] and [33].

General comments
GAMS is a powerful optimization package to solve optimization problems in engineering and science, nevertheless, it is strictly necessary that the undergraduate students account with programming and mathematical skills to represent any optimization problem in equations.
In this context, the following strategy was employed with the students of electrical engineering program at UTP in operation and regulation of electrical power systems course:  3. Show the basic structure of GAMS focused on the syntax. 4. Implement a first mathematical model in GAMS using explicit formulation.
5. Allow the students to explore GAMS and implement their optimization problems using explicit formulations.
6. Explain how to solve the most common errors in GAMS.
7. Show the student how to use compact formulation to reduce codes and possible mistakes.
The most important things in the learning process mentioned above are: the students should not be afraid and to teach the students how to do a good interpretation of the results. It is important to mention that in this teaching-learning process there will have many errors on the way, but it is not possible to forget that it is the way to improve any skill.

Mathematical modeling of classical economic dispatch problem
The mathematical model for classical economic dispatch problem considers to obtain all active power generation dispatch for all thermal generators for an specific period of time guaranteeing energy balance on the electrical systems and physical capacities on electric machines. The optimization problem reduces the operation costs of the systems based on a classical quadratic curve to represent generation cost in each thermal generator [34].
In specialized literature there are multiple formulations for classical economic dispatch problem such as secure economic dispatch [35], economic dispatch with exact loss formulation [36], economic dispatch considering greenhouse emission [37] and economic dispatch using optimal power flow representation [38], among others. Nevertheless, to understand the essential analysis for solving nonlinear problems using GAMS optimization ing.cienc., vol. 13, no. 26, pp. 39-63, julio-diciembre. 2017.

51|
Solving a Classical Optimization Problem Using GAMS Optimizer Package: Economic Dispatch Problem Implementation package, the most classical representation of economic dispatch formulation using unique node representation was selected [34].
For a graphical interpretation on the problem the schematic representation shown in Figure 3 was considered. In this representation all thermal generator plants were connected on a equivalent node and all demands have been aggregated in the same node, in other words, the behavior of the electrical network has been removed.  The mathematical model of the system presented in Figure 3 is defined for one period of time (typically one hour of operation) as shown in equations (3) to (5). The equation (3) represents the minimum cost possible to operate the generation electrical system thermal-based and its formulation is made using quadratic function to represent the cost of generate active power in thermal plants. This formulation for operating cost is the most common formulation in economic dispatch problem [34], because this objective function is a convex function and guarantees a global optimal solution for this problem, if the solution space defines an affine space. Equation (4) represents an energy power balance in the thermal system, i.e the first Kirchhoff law applied as an active power function. Finally, in (5) the minimum and maximum generation limits for each thermal generator are defined.

|52
Ingeniería y Ciencia where C (P G (i)) corresponds to the objective function, in this context, it is the total operation cost of all generators to attend the power demand, P G (i) is the active power generated by i − th thermal generator, a(i), b(i) and c(i) are the coefficients of the quadratic costs representation for the i−th thermal generator, P D is the total active power demand in the system and finally P min G (i) and P max G (i) represent the minimum and maximum limits of capacity to generate active power in the i − th thermal generator, respectively.
In order to complement the classical model of economic dispatch problem, in this paper a common way to consider the electrical network effect in this problem is also included. The effect of the electrical network in this problem includes electrical losses in the economic dispatch model. For this reason, to add the loss effect in the model presented, it is just necessary to include it on balance equation (see eq. (4)) as given in (6).
where B L (i, j) corresponds to power loss relation between two different generators. Notice that when i = j this parameter represents a quadratic component of the losses caused by the generation of active power with the i − th thermal generator.
To guarantee that all undergraduate students understand the mathematical development of the economic dispatch model, it is strictly necessary that they have some previous skills in mathematical optimization problem formulation and know what an optimization problem is. To ensure that all students overcome this requirement in the first part of the course, an optimization basis were explored using the basic concepts in reference [33] where there are optimization problems widely explained with their corresponding implementation using GAMS.

GAMS implementation
The classical EDP was implemented using GAMS free demo version 24.8.3 available in [23]. To solve the mathematical nonlinear programming model, a large scale nonlinear solver known as KNITRO was used.
Both classical mathematical models were implemented in ROES course at UTP. In case of first mathematical model defined from (3) to (5), the implementation was done during an explanation of how to use GAMS optimizer package. In case of second nonlinear model (mathematical model defined by (3) to (5), (4) was replaced by (6)), the implementation was performed as a group homework.
The parameters of the test system were taken from [34]. This is the reference book for the course. The generators costs data and power limits are shown in Table 1, and the parameters of the power loss relation matrices are defined in Table 2.

First model implementation
In Algorithm 3, GAMS implementation of the classical EDP using compact formulation via set definitions is presented. Notice that this strategy of implementation allows to easily modify GAMS code in regards with the parameters. This also allows to include more generation plants without increasing the number of equations. When the total power generation given by Fig. ?? is analyzed, it is possible to observe that the third generator attends the 72.03% of the total demand of the system, followed by the second generator with the 19.64%, while the rst generator just attends the 8.33%. This results implies that the global optimal solution of this problem is not restricted by the maximum or minimum capacities of each generator. This means that when the solutions space is analyzed, none capacity constraint has been activated, and the global solution is located inside of the solution space.

Second model implementation
In case of classical EDP considering transmission losses eect the same compact formulation presented in the rst case is used; including the expression (6) related with the transmission losses eect in the active power balance. When it is observed the optimal solution of the classical EDP considering transmission power losses eect (see Fig. 4), it is clear that the total power generation produced by each generator changes drastically in comparison with the ideal case. In this context, the rst 71| Figure 4: GAMS solution of EDP without transmission losses using GAMS, the results given in Figure 4 are obtained.
When the total power generation given by Figure 4 is analyzed, the third generator supplies the 72.03% of the total demand of the system, followed by the second generator with the 19.64%, while the first generator just attends the 8.33%. This results implies that the global optimal solution of this problem is not restricted by the maximum or minimum capacities of each generator. This means that when the solutions space is analyzed, none capacity constraint has been activated, and the global solution is located inside of the solution space.

Second model implementation
In case of classical EDP considering transmission losses effect, the same compact formulation presented in the first case is used; including the expression (6) related with the transmission losses effect in the active power balance.
When it is observed the optimal solution of the classical EDP considering transmission power losses effect ( Figure 5), it is clear that the total power generation produced by each generator changes drastically in comparison to the ideal case. In this context, the first generator supplies around the 35.86%, while the second plant generates 41.07% and the third generator produces 23.07% of the total generation. It is also possible to observe that the total active power losses caused by the transmission lines are around 4.74%. Additionally, by examining the total power generated by the third generator, the power generation is located at its minimum value, which implies that this generator has the most effect in total operative cost of the system, since this generator has the worst relation between its power generation and technical losses as shown in TABLE BL(G,G) in Algorithm 4.    Finally, when the total operative cost of the thermal system are compared, it is possible to observe that the eect of transmission losses increases up to 7.83%.

5.3
Undergraduate students experience During the ROES course (see Fig. 5), there have been multiple experiences while the students have basic ideas to implement optimization models in GAMS. Some of them are listed below: • Many students have expressed that GAMS can be employed in dierent contexts to analyze real optimization problems that involve high investments and optimization of natural resources as renewable energies or production process in the industry; nevertheless, all of them also expressed that the most important thing to learn when using GAMS is understand how to developed mathematical models, which represents adequately the problem under study.
• The students think that the implementation and solution of classical optimization problems such as optimal power ow or economical dispatch in GAMS, allows to understand in better way the general concepts of electrical engineering, specically, coning.cienc., vol. 9, no. 18, pp. 5378, julio-diciembre. 2013.
73| Figure 5: GAMS solution of EDP considering transmission losses effect Finally, when the total operative costs of the thermal system are compared, the effect of transmission losses increases up to 7.83%.

Undergraduate students experience
During the ROES course, there were multiple experiences while the students had basic ideas to implement optimization models in GAMS. Some of them are listed below: Many students have expressed that GAMS can be employed in different contexts to analyze real optimization problems that involve high investments and optimization of natural resources as renewable energies or production process in the industry; nevertheless, all of them also expressed that the most important thing to learn when using GAMS is understand how to develop mathematical models, which represents adequately the problem under study.
The students think that the implementation and solution of classical optimization problems such as optimal power flow or economical dispatch in GAMS, allows to understand in better way the general concepts of electrical engineering, specifically, concepts related with planning and operation of electrical power systems.
Finally, some of them mentioned that thanks to Internet documentation, tutorial and videos it was possible to understand the structure and syntax employed by GAMS, to implement large scale optimization problems.
In this paper a GAMS optimization package to solve single-objective optimization problems was presented. GAMS is presented as a toolbox to engage multiple classical engineering problems to introduce undergraduate students in the learning process of computational skills. Additionally, to understand how GAMS receives the information of the problem, the basic commands to implement a mathematical optimization problem was presented, showing the main advantages to use compact mathematical formulations to implement multiple optimization problems.
The approach proposed allows to know basic ideas to use optimization toolboxes like GAMS to solve classical engineering optimization problems using free demo versions for academical purposes. The improvement of the computational skills of the undergraduate engineering students, can carry out the development of practical solutions in their professional lives, specially in the age of information and communication technologies.