Multiagent Simulation of Demand Flexibility Integration in Local Energy Markets

. Overcoming the issues associated with the variability of renewable generation has become a constant challenge in power and energy systems. The use of load flexibility is one of the most promising ways to face it. Suitable ways to incorporate flexibility in the electricity market, in addition to the already challenging integration of distributed generation primary sources, are therefore crucial. The integration of prosumers and consumers flexibility in the market is, however, not straightforward, as current wholesale and retail market structures are not prepared to deal with the current and future needs of the system. Several models for local energy markets have been studied and experimented; but there it is still not clear what is the most efficient way to integrate the dynamic participation of demand flexibility in this type of local markets.


Introduction
Local Electricity Markets (LEM) are emerging as one of the most promising ways to deal with the effective integration of distributed renewable energy sources, while endowing the consumer with an active role in the system [1]. Designing efficient market structures for local energy trading that can deal with the multiple challenges related to the incorporation consumption flexibility, need for real-time trading, and interaction with current wholesale and retail market structures is, however, a demanding task [2]. This paper proposes four models of energy transaction in local energy markets considering the integration of consumption flexibility. These models are based on combinations of asymmetric and symmetric pool models; directed to the synergy between the negotiation of conventional energy and flexibility. Offers based on bidding curves are considered to incorporate the flexibility from the consumers' side. Additionally, the proposed models consider alternative approaches concerning the potential participation of external players, such as retailers and external suppliers, which may guarantee the full 2 Local Energy Markets

Local Market Structures
The first step towards an effective local electricity market project is the definition of market attributes. The attributes should be directly related to the characteristics of market participants. The degree of competition, trading horizon and dispatch intervals should be considered in the market definition project [1].
The bi-directional energy and information flow connect end-users to the local network (e.g., aggregator). Prosumers are the main contribution to the customization of the market itself [2]. Prosumers of the community are the main contribution to market customization [2].
After defining the participants, the next step is to define the market rules and optimization. Restrictions and pricing algorithms are part of the acceptance and pricing [1].
Generally, local energy markets are divided into two key categories. These two categories classify the type of trading and control and can be centralized and decentralized [3].
• Centralized: When a power-trading scenario is configured to have only one central controller that can dictate its decisions to a group of users. It will be considered a centralized negotiation and control structure. The market operator determines the optimal dispatch, receiving complete information on marginal costs and demand for distributed units.
• Decentralized: Defined when multiple users interact and try to optimize their resources and do not consider other users and network conditions. It assumes different names and structures; the most prominent is Peer-to-Peer (P2P). To dispatch the market operator receives a simple supply of only a few values and quantities of distributed unit prices [4].
For local market concession in a centralized approach, it is recommended to use the auction format. Auctions require bid and offer orders to be submitted to a blocking order. These orders are combined on a continuous basis or at different market closing times. The use of the auction mechanism at the local level has been used to determine the price of local electricity transactions [5].
The use of the aggregator at a local market aims the decision and the supervision and can be carried out in a centralized way. The aggregator has a complete view of the local market status and can make decisions to benefit the local energy community as a group and not as each player individually.
The main advantage of using P2P (decentralized) approaches is the independence of a central entity, considering that agents have their interests, and this can reduce the market's efficiency [6].
According to [7], despite not being conceptualized as a market, demand response approaches are considered centralized. The aggregator (DR operator) acts as an intermediary between generation and demand, managing the demand to reach a necessary energy consumption pattern.
The Virtual Power Plants (VPPs), as well as local markets, can also be classified as decentralized and centralized architectures. The VPPs are typically traded as the energy market and with other distributed energy sources. In the definition of the two categories, the local energy market is like the VPPs, because in the centralized architecture there is a central controller that will make decisions that dictate the actions that the participants will have to take. The decentralized architecture allows the aggregates to act independently and autonomously in their decision-maker [8].

Local Energy Markets Simulation
Most of the simulations in local markets are carried out through adaptations to existing tools in electricity markets, specific simulators for local markets are not so used yet. Some simulations performed with your models and tools will be presented in this section.
In [9] it is presented that for the creation of models in local energy markets there are three categories of modeling: game theory, agent-based and Case Studies. The first one uses the game theory to model, analyze and evaluate the behavior of local markets according to internal and external factors to find the market balance. The agent-based model builds a model based on the behavior of single agents and aggregates; the simulation analyzes the behavior of agents and the market. Case studies are not strictly modeling, but implementation of local markets and the market is not only simulated but implemented under realistic conditions.
In [9] a simulation based on DR agents is performed in local markets composed of 100 households, including combined generation and photovoltaic units. After the definition of the scenarios, methodologies and strategies of the local market, AnyLogic simulation software was used to obtain the market results.
An auction model in local markets is tested in [10] where scenarios with 24 bidders and trading strategies are assembled. The agent-based simulation program was implemented in Matlab using its optimization tools to obtain the results.
In [7] is performed modeling based on agents of a smart grid. Where active customers are autonomous agents with specific load profiles and generation and storage capabilities. The scenarios were applied in the modeling and simulation agent-based platform Repast Symphony.
A local market mechanism is proposed in [11]. Power flow analysis using the Distribution Network Simulation Platform (DisNetSimPl) and consumption data obtained through the Multi-agent Simulator of Human Behavior (SMACH) is performed.
A P2P energy-trading platform called Elecbay was designed in [12] and energy trading was simulated using game theory. The bidding simulation through Elecbay can be used to: demonstrate how energy consumers and prosumers within a micro-grid conduct P2P energy trading among themselves; obtain new load profiles from consumers and prosumers to quantify how their energy consumption is affected by P2P energy trading; and enable the microgrid analysis and control connected to the distribution grid under the P2P energy trading.
The Landau Microgrid Project (LAMP) is a local market research project of the Karlsruhe Institute of Technology (KIT) in Germany and has promoted the first implementation of a local energy market in the country. In [13] the LAMP market is simulated using multi-agent technology and the market prices and levels of generation and consumption are analyzed. The main objectives of the project are to design and implement prototypes of local energy markets following the German regulations; to analyze the behavior of the market and the agents; to evaluate the autonomy and to compare the simulated and real local electricity prices with the existing tariffs.
In [14] a Multi-Agent System (MAS) is used to simulate a real-time micro-grid operation. After formulating the problem and assembling scenarios, the Real-Time Digital Power System Simulator (RTDS) was used.
The work in [15] presents a structure optimized for energy management in a cooperative network of heterogeneous microgrids. There is an energy transaction between the microgrids connected to satisfy the variations in energy production and demand. For this purpose, the Monte Carlo simulation method is used, generating 2000 scenarios with equal probability to represent the uncertainties of wind speed, solar irradiance and total system load. General Algebraic Modeling System/Scenario Reduction (GAMS/SCENRED) software is used to reduce the number of scenarios and solve the optimization problem.
An agent-based energy management system is proposed in [16] to facilitate energy trade between microgrids with demand response and distributed storage. Demand Response and Distributed Storage (DRaDS) were developed using JADE and its multi-agent system power management is effective in reducing peak and cost-effectiveness of the system for customers.

MASCEM Simulator
MASCEM is an electricity market simulator developed by Research Group on Intelligent Engineering and Computing for Advanced Innovation and Development (GECAD). The purpose is to facilitate the study of restructured and complex electricity markets. The agents presented at MASCEM represent several participants in the electricity market: buyers, sellers (generators), VPP (aggregators), the market operator and the system operator. The user defines the market model, the number of agents and its strategies, with their own decision support resources, guaranteeing a competitive advantage in the market [17].
The MASCEM was developed as a simulator based on multiple agents and market participants are complex and independent entities with different objectives, purposes and behaviors, making their own decisions by interacting with each other.
The introduction of MASCEM to the scientific community took place in 2003 [18] and since then many changes have occurred in the electricity markets. The increase in competitiveness together with the accommodation of large-scale distributed generation from renewable sources, projects for the unification of regional markets, the necessity of an active consumers participation and the introduction of new concepts, such as smart grids and VPP, bring an exponential need for simulation and decision support resources that cannot be easily met with outdated models and architectures.
For this reason, a complete restructuring of the system occurred in recent years as presented in [19] including the definition of the multi-agent model. It was brought the use of ontologies that facilitate the communication of participants, providing the means for a more accessible cooperation with external agents that complement the simulation capabilities of MASCEM. These include the AiD-EM (Adaptive Decision Support for Electricity Markets Negotiations) [20] that provides decision support capabilities for trading participants in the market and incorporates other specific decision support systems, such as ALBidS (Adaptive Learning strategic Bidding System) [21]; and MASGriP (Multi-Agent Smart Grid Platform) [22], a multi-agent platform that supports the simulation of microgrids and smart grids.
This collaboration between the different MAS provides ways to achieve more complex and advanced simulation studies, as shown in Fig. 1, where the central simulation environment provided by MASCEM can be extended by integrating complementary multiagent simulators, such as the MASGriP.

Flexibility Integration In LEM
To reach conclusions on the potential for consumption flexibility integration in local energy markets, this work carries out several studies of alternative market models, based on auctions, and ways of dealing with load flexibility. Different models and proposals for energy and flexibility transactions are studied. Subsequently, simulations have been performed in a virtual local market to obtain results and conclusions.
In order to support the studies on the integration of load flexibility in local markets, simulations have been carried out using MASCEM simulator with data from a virtual local market based on real data from the city of Vila Real, Portugal; this power network has been introduced in [23].
Currently local markets are not practiced in the Iberian market and it is not expected to be a reality in the coming years, so it was studied the feasibility and the impact of these markets in a future scenario with projection data for 2050, when the penetration of renewable energy, the use of electric vehicles and the energy storage will be higher. This network has 233 buses and was developed based on the system evolution targets, by the European Commission, for the year 2050, as described in [24].
The simulation data of the generating units and the consumers are provided for each hour of a day with the specified values for all the respective 136 producers and 162 consumers.
Supply and demand prices were based on the daily market values of Portugal and Spain, Iberian Electricity Market (MIBEL) provided by Iberian Energy Market Operator -Spanish center (OMIE) [25] referring to February 28, 2019.
Generator prices were determined in such a way that the external supplier presents an approximate price to the market price, renewable sources a price of 0.00€ and cogeneration half the market price of MIBEL.
Consumer prices were taken from MIBEL market price and applied to a random function with increases of 5% to 25% to ensure that consumers submit bids with maximum purchase prices above the market price.
The Symmetric and Asymmetric Pool models were used to match orders between suppliers and consumers. For case studies using the symmetric model, producers shall transmit their offers for each period of the following day, indicating the quantity to be sold and the minimum selling price. Consumers communicate demand orders, specifying the desired power for each time interval and the maximum price they are willing to pay. In cases integrated with the flexibility the consumer besides informing his demand also informs the amount of flexibility (consumption reduction), he is willing to provide and the minimum price to be paid for it. After the presentation of the offers, the market operator, which creates a purely economic dispatch, organizes them, price-based.
The asymmetric model works only with sales proposals. In the simulations performed in Case Study 2, this sale corresponds to consumers' flexibility. Flexibility of 30% is considered (i.e. it is assumed that consumption can be reduced to a maximum of 30%) and this quantity is placed in the Asymmetric Pool for sale. Since the demand in the asymmetric model is considered completely inelastic, a proportional elasticity between price and quantity is used, for a consumption reduction of 30%, the price is also increased by 30%.
The following sections explain the four Case Studies, including their respective specificities and results.

Symmetric Pool
For the first scenario only a Symmetric Pool model was applied, simple purchase and sale, without flexibility, to obtain a basis for the functioning of the local market without the active participation of consumers.
Two simulations were carried out, with and without the external supplier, with an amount of 9.5 MWh throughout all periods of the day, in order to analyze the differences in market results when there is the possibility of purchasing energy other than that produced locally and when only a local energy transaction is possible. The Fig. 2 shows the main results obtained.

Fig. 2. Demand and Market Price with and without External Supplier
The Fig. 2 shows that the participation of an external supplier ensures the satisfaction of all local demand, but at a higher cost than the transaction price obtained when considering purely local transactions.

Asymmetric Pool for Flexibility Trading
Asymmetric Pool is proposed in this case for the transaction of consumption flexibility. An elasticity of 30% is considered; thus, the used price was the randomized market price with the addition of 30% of the value, according to the considered elasticity. The price of flexibility is considered as higher than the market price to be profitable for the consumer who provides it, otherwise, there would be no economic advantage to it by reducing its load. Fig. 3 compare the main results obtained.

Fig. 3. Energy Cost with External Supplier or Flexibility
The local generation is not enough to supply all the demand, so it can be supplied by external sources or by using the consumers' flexibility. The Fig. 3 shows the market costs considering external suppliers or by applying demand flexibility, demonstrating that it is possible to run a local market efficiently using only local energy, with equivalent costs to those obtained with the external generation.

Integrated Market for Energy and Flexibility
In the third Case Study, it is considered a market approach with simultaneous energy and flexibility trading, as shown in Fig. 4. The two previous cases are used to create a single scenario, in addition to the energy supply through common generators and consumers (case study 1), flexibility is also offered on the demand side (as considered in case study 2). In this way, buyers are duplicated and divided into buyers (of energy) and sellers (of flexibility). It is considered a single market, through symmetrical auction, as considered in case study 1, with the difference of including additionally the flexibility sale offers.

Fig. 4. Supply and Flexibility
The symmetric pool model was used to trade the energy and suppliers inform the minimum prices to be paid for the quantity offered and consumers the maximum price they are willing to pay for the amount demanded. It can be concluded that the price of flexibility was higher than what the consumer was willing to pay, so flexibility was not transacted Fig.  4. Therefore, even without considering external supplier and "forcing" the energy transaction locally, flexibility is not traded due to its high price.

Integrated Market for Energy and Flexibility with Bid Curves
Since the previous case studies allowed the conclusion that the integration of consumption flexibility in the energy market is not a trivial task mainly due to the high price of flexibility, Case Study 4 considers a market model in which flexibility is offered in an integrated way through the consumer purchase bidding process. The purchase of energy will be made according to the prices and generation existing in the market at each moment. If energy is available at low prices, the consumer will increase his consumption by taking advantage of energy at a lower price; on the other hand, if the market price is high, the consumer will only buy the amount strictly necessary.
Based on the original price, as shown in Table 1, the price was first reduced by 30% and demand increased by 30% and in the second part, the price increased by 30% and demand decreased by 30%. With these values, the demand-supply curves were created.  Fig. 5 shows the power curves of each buyer's bid decreasingly.

Fig. 5. Bidding Curves
It is possible to verify that all consumers present three purchase bids, with different prices and quantities according to their flexibility and consumption needs.
Demand is higher in this case due to additional demand in case of lower prices. However, the generation remains the same as in previous cases.
The first simulation of study case 4 is performed with the participation of the external supplier and the use of supply curves increases the requested demand compared to the other study cases because it includes the additional demand that the consumer requests if the price is low, Fig. 6a. The generation quantity is the same as in previous case studies.
To analyze a scenario where more available power at lower prices, the price of the external supplier was reduced, Fig. 6b. A reduction of 45% in the market price used in the other study cases and 5% higher than the cogeneration price was made.
In the third simulation, Fig. 6c, the external supplier is excluded, and the market is executed only with local generation and consumption.

Fig. 6a. Demand with External Supplier
Since the consumer offers three types of power request with different prices, not all the demand was satisfied, as shown in Fig. 6a. This happens because the price of one of the consumer bids is lower than the price of the external supplier, i.e., it was not accepted. Fig. 6b shown that most of the demand was satisfied when compared to the previous simulation. With the lowest price from the external supplier, approximately 91% of the requested demand was supplied throughout the day, and in the previous version, Fig. 6a, this supply reached only 76%.

Fig. 6c. Demand Without External Supplier
Without the external supplier, Fig. 6c, about 44% of demand is supplied only. In this case, only the highest price purchase offers are accepted, which represents the amount of consumption strictly necessary for consumers. Once the available energy is lower, consumers make use of their flexibility implicitly represented in purchase offers and only buy the necessary amount of consumption. Fig. 7 compares the prices of the three versions of this case study and although a lower share of demand was supplied by the most expensive external supplier, the market price remained higher for this version.

Fig. 7. Market Prices
The prices obtained with and without the external supplier were the same as those obtained in the first case, Fig. 2. However, with a lower price from the external supplier, the average daily price was €29, which confirms the advantage of using the supply curve, since it is possible to automatically buy larger quantities at lower prices. The consumer buys around 15% more energy at a 45% lower price than the market without supply curves.

Results Discussion
The first important result is that the local market of Vila Real cannot supply its demand only with the generation produced locally, i.e., without application of flexibility or use of the external supplier. Therefore, better ways of supplying it should be analyzed.
The first simulation of case study 1, Fig. 2, where only electric power was traded, without flexibility or any change in the patterns of the symmetric model, with the use of an external supplier, obtained an average daily market price of 53€, which is the same obtained in version 1 of case 4, Fig. 6a; the amount of demand satisfied is also the same, with the observation that in case 4 the demand is not completely satisfied, due to the supply curve request a higher demand from the system.
Other three simulations, that do not have the participation of the external supplier, have the same average daily price, 26.5€. These are present in Fig. 2 (Without External Supplier), Fig. 4 and Fig. 6c. In the first one, only 58% of the requested demand is supplied. The second one, flexibility is offered, but it was not accepted by the consumer due to the high price; in the last one demand was higher, only 44% of it was supplied, because of the increase in the bidding curve.
The simulation presented in Fig. 6b has a different price from the others, which results in a 45% reduction in the price of the external supplier, resulting in approximately 91% of the demand supplied, and this case presents 30% of additional demand due to the supply curve. The average daily price was €29, and this confirms the advantage of using the bidding curve, since it is possible to automatically buy larger quantities at lower prices. The consumer buys about 15% more energy at a price 45% lower than in the market without bid curves.
In the study carried out on an asymmetric market model, Section 4.2, was transacted only the consumers' flexibility and obtained an average daily price of 89€. It is noted that the price of flexibility sales is much higher than the price of energy purchase in the symmetrical market, meaning for the consumer, at times where it is possible to sell their flexibility is of extreme advantage by the profit obtained.
The result obtained when comparing the total cost of energy with the external supplier and with flexibility, Fig. 3, showed that the use of flexibility, integrated with energy in a separate auction is extremely advantageous, because in this way the use of the external supplier is avoided, i.e., the market is sustained only with local energy with costs equivalent to those obtained with external generation. In this way, the market would be supplied with what is generated locally and completed with the consumers' flexibility.

Conclusions
In most places, the local generation does not supply all the demand; hence external suppliers are needed; or the activation of consumers' flexibility. In this work, it has been analysed what would be the total cost of energy if flexibility and electricity were put into integrated but distinct auctions; the result obtained was equivalent to that achieved with the use of the external supplier. In other words, it is possible to supply the market locally by making use of flexibility being offered separately from energy, avoiding the purchase of external generation.
The last case study obtained satisfactory results. The buyer presents a curve of offers which allows him to integrate flexibility to his demand in an effective way because when the price of the offer is lower it is possible to buy more quantity for a lower cost; and when the price increases the demand is reduced by consuming and buying only what is necessary.
It has also been shown that flexibility is not attractive enough to take part in a single auction as an independent commodity; it needs to be separately integrated with energy. However, the high value of flexibility, when transacted, presents a great advantage to the selling consumer.