Portfolio Optimization for Electricity Market Participation with NPSO-LRS

Massive changes in electricity markets have occurred during the last years, as a consequence of the massive introduction of renewable energies. These changes have led to a restructuring process that had an impact throughout the electrical industry. The case of the electricity markets is a relevant example, where new forms of trading emerged and new market entities were created. With these changes, the complexity of electricity markets increased as well, which brought out the need from the involved players for adequate support to their decision making process. Artificial intelligence plays an important role in the development of these tools. Multi-agent systems, in particular, have been largely explored by stakeholders in the sector. Artificial intelligence also provides intelligent solutions for optimization, which enable troubleshooting in a short time and with very similar results to those achieved by deterministic techniques, which usually result from very high execution times. The work presented in this paper aims at solving a portfolio optimization problem for electricity markets participation, using an approach based on NPSO-LRS (New Particle Swarm Optimization with Local Random Search). The proposed method is used to assist decisions of electricity market players.


INTRODUCTION
The power from renewable sources has increased worldwide. However, in the case of renewable energy sources, the installed capacity does not directly represent generated energy, as there are several restrictions that limit the production and use of energy from these sources [1]. The incorporation of this energy in the electrical system is a challenge that has been investigated and successfully applied today. Several changes have occurred and are occurring in electrical systems due to the incorporation of energy produced from renewable sources.
Privatization, liberalization and integration of international systems that previously had a national character are examples of relevant changes that have occurred and potentiated the great development of the electricity sector [2]. The electricity markets have been a target of research and investigation around the world because they are still restricted to the participation of large producers [3], which makes it difficult to incorporate renewable energy sources into the system, as it is essentially produced by small producers with a distributed nature.
With these developments and changes in electricity markets, such as the inclusion of new entities in the market, the operation of markets has become different, more competitive, where power buyers and power sellers play a game of offers where the final result is gain or loss. Thus it is essential for the professionals in this area to understand the principles of the market and how to evaluate investments in this competitive economic environment [4]. In order to try to overcome these problems, simulation tools are used to understand market behavior and how the integration of new market entities can affect market results.
Market simulators are especially relevant tools in this domain. Artificial Intelligence (AI) methodologies play an important role in this scope. Simulation combined with Multi-Agent based tools allows analyzing dynamic and adaptive systems with complex interactions between the involved entities and components, such as energy markets [5]. Energy market simulators provide markets players the ability to test novel solutions, validate them and try different and new alternatives for the functioning of markets. Another possibility is the inclusion of new types of players in simulations, thus allowing to see how the market reacts.
MASCEM (Multi-Agent Simulator of Competitive Electricity Markets) is a simulation software developed with the aim of studying the complex restructuring of electricity markets [5]. MASCEM is connected with a tool called AiD-EM (Adaptive Decision Support for Electricity Market Negoitations) [6], which provides decision support to the decision-making process of electricity market players, during their negotiations.
This paper focuses on one of the most important decision support features of AiD-EM, namely the capability to optimize the portfolio of participation in multiple alternative / complementary electricity markets. An approach based on NPSO-LRS (New Particle Swarm Optimization with Local Random Search) [7] is proposed to solve the optimization model previously presented in [6]. The proposed methodology aims at reaching a high quality of results in a fast execution time, by adding a local search feature to the traditional PSO (Particle Swarm Optimization) procedure.

II. PROPOSED METHODOLOGY
This paper proposes a methodology based on NPSO-LRS to solve the problem of participation portfolio optimization in electricity markets. For this, different values for frequency of oscillation of the inertia strategy are studied and compared. The portfolio optimization problem aims at finding the best way to invest a certain amount of money in a given set of securities or assets [8]. The Modern Portfolio Theory was published in 1952 by Harry Markowitz in an article in the Journal of Finance [9] and was later developed in the book Portfolio Selection: Efficient Diversification of investments in 1959. The problem approached in this paper uses an adaptation of the main portfolio optimization concept, in order to be used as decision support for electricity market players' actions when deciding in which markets to participate, as presented in [6].
Some input variables are required to feed this methodology and bring realism into the decision support. One of the most important aspects is that problem requires the expected prices in every market, continuously. The forecast of market prices is provided by an artificial neural network (NN), which is provided by AiD-EM, as presented in [10]. In some market types the price of Electricity is unique for each negotiation period. However, in others it is not, e.g. bilateral contracts. In order to deal with these price estimations, a methodology that allows calculating the price of electricity depending on the amount of negotiated power has been developed [11].

A. PSO Methodology
PSO is a search algorithm that is used to solve optimization problems. This algorithm was introduced by Kennedy and Eberhart in 1995 [12] and is inspired by the collective movement of flocks of birds and schools of fish. In the standard PSO algorithm is started with a starting solution for each particle that represent different solution to the problem. During the optimization process the particles seek a new solution in accordance with a rule that directs their movement in space, equation (1) and (2). Where: • -iteration; • -particle; • -represent the velocity of particle i in iteration k; • +1 -represent the velocity of particle i in iteration k+1; • -represent the position of particle i in iteration k; • +1 -represent the position of particle i in iteration k+1; • -best personal solution; • -best global solution; • inertia; • 1term of local attraction; • 2term of global attraction; One of the important parameters in PSO is the inertia, which defines how the algorithm will search. A good parameterization of this term influences the optimization result. In [13] the authors suggest the Oscillating Inertia Weight methodology for inertia strategy calculation, which can be obtained through (3). Where: • -is the minimum value of inertia weight; • -is the maximum value of inertia weight; • -is the number pi, approximately 3,1415; • -is the current iteration; • 1 -is the number of iterations for which the inertia weight is allowed to oscillate; • * -∈ and is a parameter that controls the frequency of oscillation.
The NPSO-LRS [7] is an improvement of the standard PSO. The main development is that it includes a local search. The criterion that defines the local search is user defined and can be e.g. a generation of a random number. In this case a component that stores the worst solutions is included, and it considers the particle in the worst position visited during the search process to calculate the speed. The bad experience of the particle is also taken into account in the search equation. The equation (1) of PSO is replaced for equation (6). Where: • 1 -acceleration coefficient, which accelerates the particle toward its best position; • 1 -acceleration coefficient, which accelerates the particle away from its worst position; • 1 , 1 -three separately generated uniformly distributed random numbers in the range [0, 1] ; • -bad position visited by particle i.
LRS (Local Random Search) [7] is a local search method, which is executed according to equations (7), (8), (9) and (10): In (7) and (8), corresponds to the minimum and maximum limits of the problem variables, respectively. The parameter is called local parameter area. in equation (10) corresponds to a random number with minimum -1 and maximum of 1. After performing the local search, each solution found to be better than the previous will be in memory and will be used at the beginning of the following search.

B. Mathematical Formulation
The formulation presented in (11) is used to represent the optimization problem, as proposed in [14] . In (11) represents the weekday, represent the number of days, represents the negotiation period, represent the number of negotiation periods, and are boolean variables, indicating if this player can enter in negotiation in each market type, represents the referred market, represents the number of markets, represents a session of the balancing market, and represents the number of sessions. Variables The formulation considers the expected production of a market player for each period of each day. The price value of electricity in some markets depends on the power amount to trade. With the application of a clustering mechanism it is possible to apply a fuzzy approach to estimate the expected prices depending on the negotiated amount. Equation (12) defines this condition.
Equation (13) represents the main constraint to be applied in this type of problems, and imposes that the total power that can be sold in the set of all markets is never higher than the total expect production (TEP) of the player, plus the total of purchased power [14] . Further constrains depend on the nature of the problem itself, e.g. type of each market, negotiation amount, type of supported player (renewable based generation, cogeneration, etc.).

III. CASE STUDY
This section presents a case study, which is used to test and validate the proposed methodology, by comparing the achieved optimization results with those obtained using the standard PSO approach [12]. Market prices forecasting is performed using an artificial network neural (ANN) [10], which is trained with data from the Iberian market -MIBEL [15]. In this case study the model considers five markets, with specific rules for proving adaptability of the proposed model. Acting as a seller, the supported market player can sell energy in all five markets, but is not allowed (due to market specifications) to purchase in the day-ahead spot market. In the case of balancing markets, only one operation (selling or buying) is allowed in each session. For Bilateral contracts negotiations, and local markets, a methodology for estimating Electricity prices based on a dynamic fuzzy methodology published in [11] has been used.
A study to evaluate the best parameter of frequency control oscillation of inertia is performed, departing from the study performed in [13]. Five different * values are experimented, resulting in different oscillations. Through the analysis of the Fig. 1 it is possible to understand the operating mechanism of the chosen inertia strategy.

Fig. 1 -Oscillating frequencies
As can be seen by Fig. 1, when the value of * increases, the wave period becomes shorter. Fig. 1,shows only the value of inertia up to 300 iterations, repeating until 1000 runs. When * = 1, the wave length is 300 iterations. The wave length decreases until * = 9, where the wave length is 60 iterations. Different * values, defining the wave length, are experimented. Afterwards, the results achieved using each of these values are compared, and the best * value is chosen. Fig. 2 shows some box plots, referring to all considered frequencies of oscillation. The presentation of this figure is used to choose the best frequency of oscillation to be applied to solving the problem.

Fig. 2 -Box Plots for oscillating frequencies
It is possible to see that all oscillation frequencies reach very identical maximum values. From Fig. 2 it is impossible to point out that the frequency of oscillation that reaches the highest value. However, from the analysis of results it is visible that with * = 1 we obtain 2000.645575 € which is higher value. For * = 5 the worst maximum value is found, and records a difference of 1,2231E-11 with respect to * = 1. It is worth noting a curious feature in the graphs, which is the fact that the median is at the bottom of the diagram (very close to the value of the 1 st Quartile), which means that the data is skew in the lower of the diagram. Between the values of the 1 st and 3 rd Quartile 50% of the data are represented, which means that the diagram that has the smaller space between them represents a good alternative. The value with the smaller difference between the quartiles is * = 5. However, the other * ′ have minimal differences, in the order of 0.1%.
Through the analysis of Fig. 2 it is not possible to conclude which of the oscillation frequencies is the best, but the oscillation * = 1, 3 and 5 showed promising aspects that overlap to the others. The graph of Fig. 3 represents the confidence of intervals for all oscillations frequencies.  Fig. 3 have a degree of 95% confidence reliability. In this case the theory presupposes that the average value can be obtained with 95% confidence with a particular error. In this case it is important to choose the frequency of oscillation that presents a higher average and a minor error. For this, an analysis to the graph of Fig. 3 is performed. At a first glance the oscillation * = 5 and 7 will be excluded since they have the lowest average. Good options will be the * = 1 or * = 3. Observing the recorded values we can conclude that with * = 3 we get an average of € 1759.637095 following up * = 1 with a relative difference of 0.1%. The oscillation * = 7 has a relative difference of 0.5%.

Confidence intervals shown in
As already referenced, every confidence interval is associated with an error or tolerance. In this case * = 7 had the lowest error for the calculated confidence interval, but it is worth noting that the other registered errors do not differ much from this, because the biggest error is in * = 1, which has a difference of 3.5% compared to the smallest. The frequency oscillation of * = 3 is thereby chosen, because it is the one with a higher average, it is also the one with the best difference between quartiles (as seen in Fig. 2), and it has also recorded one of the best minimum values of error (the confidence interval is very close the best achieved value, with a difference of 2%).   As shown by TABLE I, differences are noticeable between the two approaches. The NPSO-LRS approach presents better results in all parameters. The maximum value presents a difference of 0.1% between the two approaches. However, it should be noted that STD was reduced by 95.4% compared to the best (minimum), which leads to the conclusion that there is less dispersal in the found solutions. In the case of minimum and average values, the improvement is well visible. From TABLE II it is visible that the NPSO-LRS approach clearly has a higher run time and higher mean number of iterations, which is normal because it is a more elaborate and more accurate method. In terms of execution time, the implemented NPSO-LRS approach takes about 3 seconds (average) to achieve a solution, which can be considered a very good time for the targeted problem. The number of iterations has increased considerably comparing to PSO, which is due to the fact that the NPSO-LRS has a condition to search at least 250 iterations. TABLE III shows the portfolio optimization results (i.e. amount of purchase and sale of energy in each market, which resulted from NPSO-LRS when it registered the maximum value of objective function). As seen by TABLE III, the NPSO-LRS approach suggests market sales in the day-ahead spot, bilateral contracts and SG negotiations. Purchases are allocated to bilateral contracts and two sessions of the balancing market. When analyzing the results it is possible to conclude that the optimization model respects the imposed rules, such as not being possible to sell and buy at the same time in the same session of auction based markets; the impossibility for the supported seller to buy in the spot market, and making the sum of the amount of energy sold 34.73 MW equal to the amount purchased 24.73 MW, plus the amount available production: 10 MW.
The model also suggests both buying and selling energy in bilateral contracts, which occurs because in these markets the price of energy is not constant and varies with the traded amount. In these cases it may be profitable to buy amounts that can be achieved a lower prices, and sell in the same market amounts that can provide higher incomes.

IV. CONCLUSIONS
This paper presented the application of a methodology based on NPSO-LRS for solving the problem of portfolio optimization for electricity markets participation. Results show that the use of * = 3 for the oscillation frequency presents advantages in relation to the use of other * ′ . Another important aspect of this paper is to have demonstrated that the use of NPSO-LRS brings clear advantages when compared to the standard PSO. Although it is more complex and takes a longer execution time and iteration number to reach results, the results of the objective function fully justify its applicability.
The proposed methodology has also demonstrated to be able to solve the targeted problem, by respecting the rules that have been imposed.
For future work other methods will be applied, such as genetic algorithms, to compare the performance of already applied algorithms. Additionally, it will be experimented to include in the model a component permitting to strike a balance between risk and profit and weighing in optimization. It is also proposed to develop a heuristic with the purpose of providing a valid starting solution for the algorithms to start the search.