Smart Microgrids: Optimizing Local Resources toward Increased Efficiency and a More Sustainable Growth

Smart microgrids are a possibility to reduce complexity by performing local optimization of power production, consumption and storage. We do not envision smart microgrids to be island solutions but rather to be integrated into a larger network of microgrids that form the future energy grid. Operating and controlling a smart microgrid involves optimization for using locally generated energy and to provide feedback to the user when and how to use devices. This chapter shows how these issues can be addressed starting with measuring and modeling energy consumption patterns by collecting an energy consumption dataset at device level. The open dataset allows to extract typical usage patterns and subsequently to model test scenarios for energy management algorithms. Section 3 discusses means for analyzing measured data and for providing detailed feed- back about energy consumption to increase customers’ energy awareness. Section 4 shows how renewable energy sources can be integrated in a smart microgrid and how energy production can be accurately predicted. Section 5 introduces a self-organizing local energy system that autonomously coordinates production and consumption via an agent-based energy auction system. The final section discusses how the proposed meth - ods contribute to sustainable growth and gives an outlook to future research.


Motivation
While our energy system has been considerably stable in its components and operation over several decades, the need for integrating sustainable energy resources and for making the system more efficient requires a major change of the energy system on all levels.
Sustainability is a concept that touches many aspects, which often makes it difficult to define its application in a limited domain. For example, in energy generation, photovoltaics (PV) provide an attractive means of a zero-carbon energy source, but when looking at it through a sustainability lens, the energy and resource usage during production of the panels has to be considered as well. While a growing importance of sustainability is to be welcomed, this has also led to an inflationary use of the term sustainability which has been reportedly pointed out [1]. For instance, Google books Ngram Viewer 1 reports an increasing use of the term "sustainability" by a factor of one thousand between 1970 and 2008 (the most recent accessible year).
Keeping in mind that sustainability means include the combination of many aspects, we want to show a number of different means in the context of electric energy systems in this chapter, evolving around the concept of a smart microgrid. This transition to a low carbon, affordable energy system, also coined Energiewende based on continuous efforts since the 1980s in Germany aiming at a cleaner energy system, requires new technologies and new control strategies. This involves also putting the user into the loop, either by having people directly acting based on some feedback system or by learning the users' needs and optimizing an energy management system in a way that it can act on a user's behalf. Such a system is inherently complex, since it involves many aspects starting from meteorologic parameters influencing PV and wind generation up to economic models related to energy markets and finally the psychology of users regarding their experienced comfort or discomfort. Thus, there is a strong motivation for approaches that can handle the complexity of optimizing resources of an energy system toward increased efficiency and a more sustainable growth. In the following, we address these problems from several viewpoints and depict solutions based on smart microgrids. local control intelligence to operate and coordinate its components. With this in mind, we can assess components of a microgrid based on the possibility to control their power. Renewable energy sources such as PV systems or wind turbines provide only a limited possibility of control, since they are normally operated to provide their maximum output (e.g., operating at the maximum power point of a PV array). While it is possible to reduce their output (e.g., operating a PV array off the maximum power point or using feathering in a wind turbine), this is no good strategy in economic terms since the energy not retrieved cannot be recovered later. Energy consumers allow limited controllability given that they can be controlled (see the concept of a smart appliance [2] for particular approaches and issues) and that the comfort loss for the user is acceptable [3]. Energy storage can operate as a consumer (given that the storage is not full) and as a provider of energy (given that the storage is not empty). While, in general, a storage allows a larger time frame for the balancing between energy generation and consumption, it also comes with additional complexity for finding the right control strategy and for defining the optimal size for a storage.
While smart microgrids come with the advantage of being a small system in comparison with the overall energy grid, the small size also comes with new challenges. For example, a microgrid requires a tighter coordination of its components since the law of large numbers does not apply for them. This also means much less inertia and therefore smaller timescales in its control systems. While a large synchronous grid comes with timescales of minutes that can be handled by a human operator, a small microgrid could have a timescale of milliseconds, thus requiring a fully automatic system for its control. Current trends in smart microgrid research therefore include automatic and self-organizing control systems, prediction of renewable energy sources, stabilizing microgrids by adding storage or designing DC microgrids to better address the nature of PV produced energy and batteries. An energy management system for a smart microgrid aims at controlling a microgrid in order to fulfill a given objective. Objectives could be maximizing renewable energy usage, maximizing revenue, maximizing user satisfaction, giving user feedback or protecting privacy by obfuscating the power consumption at the grid connection point [4].

Investigating energy usage
Energy usage entails complex dynamics which need to be understood in order to offer effective energy conservation and management strategies. Specifically, to enable research on energy management and sustainability, it is important to build upon publicly available datasets. This allows for assessing solutions before their actual deployment, while still guaranteeing that they work for the real world. In this section, we explore existing energy datasets with the aim of offering an exhaustive comparison of previous measurement campaign and findings. We report of a completed research project addressing energy conservation in Austria and Italy. In particular, we discuss an initial survey carried out to identify common scenarios (e.g., in terms of used devices, diffusion of renewable energy generation) [5]. We then focus on the GREEND dataset, which we collected during a year-long measurement campaign in the regions of study [6]. The dataset was used in our research to model the operation of household appliances, particularly in terms of usage mining and load disaggregation [7], and the problem of determining running devices from an overall power measurement [8].

The MONERGY project
The MONERGY project aimed at proposing solutions to reduce residential energy consumption in the Austrian region of Carinthia and the Italian region of Friuli-Venezia Giulia. This required firstly the identification of commonalities and differences in terms of scenarios and lifestyle. Therefore, we carried out an analysis of the devices responsible for most consumption so as to derive typical consumption scenarios in the regions. Specifically, we conducted a web survey targeted to residents of the area under study being older than 18. The survey was offered in Italian and German, required approximately 15 min to be completed, and consisted of 43 questions concerning five main sections: (i) household information, (ii) use of electrical devices, (iii) sensitivity toward energy consumption and renewable energy generation, (iv) sensitivity and expectation toward energy management systems, and (v) demographic information. The collected 397 responses were cleaned and resulted in 325 usable ones, namely 186 from Carinthia (96 F and 90 M) and 139 from Friuli-Venezia Giulia (63 F and 76 M). The analysis of collected survey data reported in Ref. [5] provided further insights on the consumption scenarios across the regions. In particular, we identified a greater share of electrical devices, namely hobs, heaters and boilers in Carinthia and contrarily a greater adoption of gas-powered devices and air conditioners in FVG. The study also showed a still limited diffusion of renewables (7.91% in FVG and 2.69% in Carinthia), as well as in billing mechanisms. Because of the already completed rollout of digital meters, residents of FVG are billed under a time-of-use tariff plan (mainly distinguishing nights from day, as well as weekends), while in Carinthia yearly metering and billing is still the norm. As a consequence, we observed that residents in FVG are already benefitting of timeof-use tariffs to exploit more favorable pricing conditions when operating their devices, namely their washing machine (62.59%), lights (24.46%), iron (22.3%), electric oven (21.58%), dryer (10.79%), conditioner (10.07%) and dishwasher (9.35%). The main countermeasure to increase efficiency in Carinthia is device replacement, done by 67.20% of respondents in the previous 4 years, although Carinthians expressed their willing to exploit more favorable pricing schemes, mainly to operate their washing machine (48%), electrical boiler (23%), and dryer (20%). The analysis was continued in Ref. [9] with an estimation of energy usage and an assessment of residents' attitude toward energy management systems, as well as in Ref. [10], where building information was used to extract models of the dwellings (e.g., in terms of number of floors, area) to be used to optimally size the communication infrastructure of an energy monitoring system.

Collecting energy data
Energy management is only possible after the collection of energy consumption and production data. In particular, we deal with the following physical quantities: (i) the voltage expressed in volts, (ii) the current (i.e., the quantity of charge per second) expressed in amperes, and (iii) the phase shift between these two measures. To collect digital measurements, the amplitude of a signal can be lowered with a voltage divider and fed into an analog-to-digital converter (ADC) to extract its voltage value. The current can be measured using a Hall-effect sensor or a current transformer, that are transducers converting the magnetic field generated from the flowing current into a proportional output voltage, which can be similarly fed into an ADC and stored as digital value. Contrarily, the phase shift (phi) is the time shift between the measured voltage and the flowing current, and is generally estimated using numerical methods. It is important to remark that datasets for energy management commonly deal with power measurements, which can be distinguished in three different quantities: (i) an active or real power measured in watts (W), a reactive power specified in reactive-volt-amperes (VAR) and (ii) an apparent power expressed in volt-amperes (VA), related as follows: The root-mean-square value (RMS) of a signal can be computed by dividing the peak value by the crest factor, a signal-specific property. For a sinusoidal signal, this is for instance √ __ 2 while it is √ __ 3 for a triangular one. Another important matter when measuring electrical signals is the sampling frequency, which according to the Nyquist-Shannon theorem should be greater than twice the highest frequency in the measured signal, in order to avoid the aliasing effect, in presence of which it is impossible to reconstruct the original signal.

Energy datasets
Energy datasets are necessary to allow for the assessment of solutions on real scenarios and consequently allow for comparable and reproducible research. We report a survey of existing datasets in Table 1.
Collected features are: active power (P), reactive power (Q), apparent power (S), energy (E), frequency (f), phase angle (phi), voltage (V), current (I), and power factor (pf). Remarkably, datasets can be classified as those that monitor only a limited number of buildings at a high sampling frequency (e.g., REDD and BLUED), those collecting data from individual devices without providing any building information (e.g., Tracebase and ACS-F1), and those providing a high number of locations for statistical validity (e.g., HES and OCTES).

The GREEND dataset
The GREEND dataset was carried out within the activities of the MONERGY project to overcome the limits of existing datasets and offer a framework for a better understanding of the regions of study. As previously shown in Table 1, the dataset consists of more than 1 year active power data (P) collected in eight households at 1 Hz resolution. In particular, the dataset includes the following: • House #0 a detached house with two floors in Spittal an der Drau (AT), whose residents are a retired couple, spending most of time at home. Monitored devices include a coffee machine, a washing machine, a radio, a water kettle, a fridge with freezer, a dishwasher, a kitchen lamp, a TV and a vacuum cleaner.
• House #1 an apartment with one floor in Klagenfurt (AT), whose residents are a young couple, spending most of daylight time at work during weekdays, mostly being at home in evenings and weekend. Monitored devices include a fridge, a dishwasher, a microwave, a water kettle, a washing machine, a radio with amplifier, a dryer, kitchenware (mixer and fruit juicer), and a bedside light.
• House #2 a detached house with two floors in Spittal an der Drau (AT), whose residents are a mature couple (one housewife and one employed) and an employed adult son (28 years). Monitored devices include TV, networked-attached storage (NAS), washing machine, drier, dishwasher, notebook, kitchenware, coffee machine, and bread machine.
• House #3 a detached house with two floors in Klagenfurt (AT), whose residents are a mature couple (one working part-time and one full time), living with two young kids. Monitored devices include entrance outlet, dishwasher, water kettle, fridge without freezer, washing machine, hair drier, computer, coffee machine, and TV.
• House #4 an apartment with two floors in Udine (IT), whose residents are a young couple, spending most of daylight time at work during weekdays, although being at home in evenings and weekend. Monitored devices include total outlets, total lights, kitchen TV, living room TV, fridge with freezer, electric oven, computer with scanner and printer, washing machine, and hood. • House #5 a detached house with two floors in Colloredo di Prato (IT), whose residents are a mature couple (one housewife and one employed) and an employed adult son (30 years). Monitored devices include: plasma TV, lamp, toaster, stove, iron, computer with scanner and printer, LCD TV, washing machine and fridge with freezer.
• House #6 a terraced house with three floors in Udine, (IT), whose residents are a mature couple (one working part-time and one full time), living with two young children. Monitored devices include total ground and first floor (including lights and outlets, with white goods, air conditioner and TV), total garden and shelter, total third floor.
• House #7 a detached house with two floors in Basiliano (IT), whose residents are a retired couple, spending most of time at home. Monitored devices include TV with decoder, electric oven, dishwasher, hood, fridge with freezer, kitchen TV, ADSL modem, freezer, and laptop with scanner and printer.
The GREEND dataset is provided for free via the SourceForge page. 2 Possible applications of GREEND include the derivation of appliance usage patterns, occupancy detection and developing and testing load disaggregating algorithms.

Analyzing energy use and improving awareness
Energy efficiency can generally be improved by replacing loads with more efficient ones, improving building efficiency (e.g., using a better insulation for windows), as well as optimizing energy usage. For the latter, a possibility is to analyze energy data, collected by the growing number of digital meters, as in Beckel et al. [11].
This allows utilities to offer targeted services, based on derived information such as size, income and consumption patterns. Efficiency is very dependent on energy awareness. The main problem of common billing mechanisms is the delay occurring between energy consumption and feedback. Prepaid billing offers a way to mitigate this problem, being the balance commonly reported on the energy meter and disconnections occurring upon expenditure. This was shown by DEFG, leading to 11% savings in UK [12].
Interactive systems can be employed to monitor and display energy production and consumption information and assist decision making. The effectiveness of these solutions depends greatly on the sensitivity and motivation of served users [13]. Also, as identified by Erhard-Martinez et al. [14] and Armel et al. [15], most effective feedback mechanisms are those provided at time of consumption (i.e., direct) rather than as historical (i.e., indirect), especially when breaking down consumption and costs to the appliance level, as this leads to an average of 12% savings in the considered studies. In particular, [15] estimated a potential of up to 20% savings when feedback is enforced by tailored advice, that is, tips on how to improve consumption behavior as based on actual device availability and usage (see Figure 1).  In the study reported in Monacchi et al. [16], we analyzed the GREEND dataset to identify energy hogs and possible policies for improving overall efficiency, which can be summarized as: • Promoting replacement of particularly consuming devices (e.g., incandescent light bulbs) with more efficient ones. This also has a diagnostics component, as device performance tends to change with aging.
• Promoting shedding of stand by devices, especially as resulting from consumer electronic devices (e.g., TV and modem). Occupancy models can be exploited to minimize user discomfort.
• Promoting device operation in off-peak time periods. This includes both deferral and preference of efficient devices over energy-demanding ones, such as using the LCD TV during the day and the plasma over the night period.
• Promoting device curtailment as consequence to anomalous behavior (e.g., with respect to the average number of usages).
While these policies can result from common sense and have a general validity, our intention was to provide an interactive system, able to autonomously analyze collected data to return most effective advices. In particular, this resulted in the design of an energy advisor, formulating advices over two steps: (i) candidate generation, in which advices are formulated depending on the availability of specific device types and ranked based on their saving potential, and (ii) information filtering, in which advices are ranked and filtered, as based on user's previous experience and responses. In particular, user's feedback to the advisor is explicit, with namely: "Ok thanks," "I am already doing it," "No thanks" (see Figure 2). A recommendation is considered converted in a behavior when the user explicitly accepts it as being already followed. Converted advices are directly deactivated. A usefulness score is instead computed for all others, as using the votes from positive (i.e., "Ok thanks") and negative (i.e., "No thanks") feedback. Consequently, positive feedback reinforces the advice by increasing its score, while negative feedback can result for a mistrust in the advice type or the specific device category to be operated. As such, the system needs further specification and prompts the user with the selection of a cause. Based on this cause, the score of all advices of same type for the user or vice versa for the device category is decreased. The usefulness score is used to rank the advices, and randomness is introduced for those with same value.
The advisor was later implemented as a widget in the Mjölnir: an open-source energy management system, which we publicly released to the research community. Mjölnir provides a modular web-based dashboard where data analysis is implemented in the form of widgets, which can be arranged on the interface and reused on different data sources.
An estimation of potential savings yielded by the feedback mechanism followed the analysis, calculated in a potential of 34% using the sites measured in the GREEND dataset. The analysis was then concluded with a small usability and acceptance study, where seven participants engaged in a guided interaction with the widget, while we were interested on validating the effectiveness of the advisor widget in informing and persuading them.
The experimental setup consisted of a synthetic scenario, which included: a coffee machine, a washing machine, a dishwasher, a PlayStation 4 and a television. The attractiveness of the design was ultimately rated using a satisfaction questionnaire, where we used a five-point Likert scale, with "strongly agree" (+2) as a left anchor and "strongly disagree" as a right anchor (-2). Although limited, the analysis suggested that while the advisor can deliver "useful" and "tailored" information, it lacks on engaging users on a long term (i.e., after an initial learning curve). The results are reported in Figure 3. The nine questions included: "it takes short time to learn the meaning of the buttons," "the position of the buttons is logical," "I understand what happens when I click the buttons," "the advices are unusual, inventive, original," "the advices are useful to improve energy efficiency," "The advices are doable," "I can learn something from the advices," "I would use this widget every day" and "I would use this widget again."

Integrating renewable energy sources
Using renewable energy sources in a microgrid is a challenge, since typical renewable sources like PV or wind are dependent on meteorological conditions, which are themselves hard to predict. Therefore, one needs to address the problem of accurate prediction of renewable generation and based on these data find an optimum configuration for a smart microgrid. In the following, we give an example for a prediction approach for power generated by a PV systems, followed an optimization example for sizing the components of a smart microgrid.

Predicting solar radiation
When modeling renewable energy systems with unpredictable sources as solar or wind power, a more accurate prediction can be the key to their effective utilization. For example, being able to predict the expected minimum output over a duration of several days helps to find a minimum size of the battery storage of such a system, which means saving resources and money in their production. In other words, an accurate prediction of renewable energy sources can be the key to a sustainable development of energy systems.
However, predicting parameters related to weather phenomena can be very hard, given the complex nature of meteorological systems. For a PV system, for example, it is straightforward to depict the position of the sun at a given point in time, but other effects related to clouds, fog and reflections of sunlight are difficult to model and might require to adjust the model based on the climatic condition at the deployment site. In Ref. [17], an artificial neural networks (ANNs) is trained and used to make accurate predictions for a specific site. Therefore, parameters like current time and date, humidity, sunshine ratio, temperature and geographical parameters like latitude and longitude are used to make a prediction on direct and diffuse radiation. While this approach requires a history of previous radiation and weather measurements to learn the corresponding correlations, it allows a more accurate prediction of the solar radiation in comparison with predefined models. A schematic diagram of an ANN used for solar radiation prediction is illustrated in Figure 4. The network has three layers: the input, hidden and output layers. Each layer is interconnected by connection strengths, called weights.

Sizing microgrids
The introduction of photovoltaic-based distributed generation (DG) units in the distribution system may lead to several benefits such as voltage support, improved power quality, loss reduction, deferment of new or upgraded transmission and distribution infrastructure and improved utility system reliability. The installation of DG units at nonoptimal locations and with nonoptimal sizes may cause higher power loss, voltage fluctuation problem, system instability and amplification of operational cost.
Before installing DG units in a distribution system, a feasibility analysis has to be performed. DG owners are requested to present the type, size and location of their DG. The power system is usually affected by the installation of DG. Therefore, the allowable DG penetration level must comply with the harmonic limits. Thus, optimal placement and sizing of DG is important because installation of DG units at optimal places and with optimal sizes can provide  economic, environmental and technical advantages such as power losses reduction, power quality enhancement, system stability, and lower operational cost.
The meta-heuristic method is also used in optimal placement and sizing of DG in distribution systems. This method applies an iterative generation process which can act as a lead for its subordinate heuristics to find the optimal or near-optimal solutions of the optimization problem. It combines different concepts derived from artificial intelligence to improve performance. Some of the techniques that adopt meta-heuristics concepts include genetic algorithm (GA), Tabu search, particle swarm optimization (PSO), ant colony optimization (ACO), and gravitational search algorithm (GSA).
The implementation of a general optimization technique for solving the optimal placement and sizing of DG problem is depicted in Figure 5. A multi-objective function is formulated to minimize the total losses, average total voltage harmonic distortion (THDv) and voltage deviation in a distribution system. The procedures for implementing the general optimization algorithm for determining optimal placement and sizing of DG are described as follows: • Obtain the input network information such as bus, line and generator data.
• Randomly generate initial positions within feasible solution combination, such as the DG location; DG size in the range of 40-50% of the total connected loads; and DG controllable bus voltage in the range of 0.98-1.02 p.u.
• Improvise the optimization algorithm using the optimal parameters such as population size, number of dimension and maximum iteration.
• Run load flow and harmonic load flow to obtain the total power loss, average THDv and voltage deviation.
• Calculate the fitness function.
• Check the bus voltage magnitude and THDv constraints. If both exceed their limits, repeat step iv.
• Update the optimization parameters.
• Repeat the process until the stopping criterion is achieved and the best solution is obtained.

Simulating microgrids
Simulation is an efficient way to investigate various questions in research as well as in engineering. This holds also true for microgrids. The specifics in simulation of microgrids relate to size of the grid, the type of power generation and the particular questions to answer. Independently, the microgrid simulation is constituted of the models for the physical microgrid, the production facilities and the consumption patterns. All these models need to fit the required time resolution or, more general, the level of accuracy.
The model of the microgrid represents the physical properties of the grid. In the simplest form, it ensures that the power balance equation holds. More detailed models capture the power flow on the different branches of the microgrid for each phase. Power flow simulation is a well-studied question and widely applied in (transmission) grid load schedule processes.
Further parts of a microgrid model are a central controller and the circuit breaker which manage the connection to the superior grid.  Models for load profiles of consumers as well as generators vary a lot in their accuracy. In a widely used approach, measured values of similar real life utilities are used to as time series for simulation. This method is especially efficient when the power profile contains periodic patterns of different length, like daily, weekly or annual events which are hard to model. The recorded data must cover the full annual cycle (or duration of simulation) and cannot be arbitrary generalized. Such models are common for sizing of renewable energy production facilities, like PV and wind turbines, and for residential consumer loads. More sophisticated are physical models where the related processes are described with detailed mathematical equations. Successful examples are the production of a PV system under blue sky conditions as a function of time and date or the heating power of a house depending on the outside temperature. Other modeling techniques based on artificial neural networks or Markov processes require a big dataset to train the model. Those models are expected to handle stochastic events better than physical model, like cloud coverage of PV systems.
Consequently, a simulation platform for microgrids needs to provide physical grid simulation and a variety of models for power generation and consumption. The two historical fields power system simulation and renewables production forecasts, which developed separately, should be combined in microgrid simulation. In Ref. [18], several open-source simulators have been compared, where the different features and aims of the simulation systems become apparent. Some recent simulators such as GridLAB-D [19] or RAPSim [20] aim at integrating different features, especially by addressing renewable energy sources.

Automating energy management
As previously identified, demand response has been advocated as a potential solution to involve consumers into the stabilization of the power grid. In particular, demand-side management can be classified as (i) direct load control, namely with the utilities exploiting a direct communication channel to control their customers' appliances, and (ii) indirect load control where a price signal is shared to reflect the availability of energy resources (see [21] for a complete overview of demand response approaches). Indirect demand response assumes that users will timely react to system changes (i.e., price changes) and control their load. A higher degree of autonomy has to be achieved throughout the system to effectively introduce demand response. Hence, we discuss in this section on the possibility of designing controllers for energy prosumers.

Controlling energy prosumers
Energy management using computational agents has been addressed in previous work, such as [21][22][23]. In particular, coordination has been implemented using various mechanisms: cooperative games [24,25], noncooperative games [23,[26][27][28][29], especially double-sided auctions [30][31][32]. Ideally, energy management is performed by finding a suitable operational schedule, with respect to a previously truthful revelation of agents' preferences. This demands an infrastructure sized to handle the centralized optimization of schedules, and it most importantly assumes the cooperative nature of agents, that is, they will reveal their schedule without having any interest in gaining power in the system. However, energy management is typically a process performed by decentralized entities, as such energy resources are, which pursue their own goal competitively. Electronic markets provide a framework to regulate the allocation of limited resources to competing agents [33]. Auctions use the shared price signal to assign resources to those agents that value them most, that is, that bid best. Coordination is in this case a process distributed across the community, meaning that no central optimizer takes care of computing the schedules and allows the agents for keeping their utility function private. Auctions can be classified in multiple ways, among which (i) single-sided and two-sided depending on the presence of both multiple buyers and sellers, and (ii) single-unit rather than multi-unit or combinatorial depending on the divisibility of the traded commodity. We forward the reader to [34] for a complete overview on auctions. Energy markets are commonly distinguished in (i) a wholesale market in which producers compete to supply energy to retailers and (ii) a retail market in which end customers select their provider. In our work, we advocate for achieving coordination using double-sided auctions. In this kind of markets, bid matching is a very lightweight process consisting in sorting all received ASK and BID offers for their price, so that the very best can result in a transaction. The so-called orderbook can be kept on a peer-elected agent, or distributed on each agent. This avoids any single point of failure in the architecture. In Monacchi et al. [35], we introduced the HEMS simulator (see Figure 6), which allows for simulating energy production and usage in microgrids, in order to learn controllers for energy prosumers. While other simulators exist in literature to model users' consumption behavior [36,37], they lack in offering a complete solution for modeling consumption and production, as well as learning appropriate control strategies. To this end, we introduced a prosumer controller based on artificial neural networks (see Figure 7). The controller uses both a buyer and a seller model, along with contextual information to model time and trading tendency. Accordingly, a tendency value is computed to reflect the availability of local energy (i.e., as resulting from a battery element or local generation) which could be sold, or vice versa the necessity to buy energy if operation needs or was previously started. The latter value is taken directly as a probabilistic usage model embedded in the agent, which was previously extracted from an energy consumption dataset.
The controller can be trained using multiple methods. In the paper, we defined a cost function based on operational costs and user discomfort (i.e., delayed or interrupted operation) and showed the controller being successfully trained to trade power in a uniform-price double auction (UCDA), using the NNGA evolutionary algorithm. In particular, we selected in the study a 1-s allocation interval. Sizing such an interval depends directly on the state length of operated loads, as we desire on one hand to operate without service interruption, which a 15-min interval as in Ref. [30] can ensure, but on the other hand it is necessary to guarantee system responsiveness (i.e., a minimal delay between trading time and allocation time such that environment changes can be addressed). For this reason, any statically defined allocation size in a strictly competitive environment will always lead to suboptimal results, that is, service interruption. To address this problem, we investigated in Monacchi and Elmenreich [38] the design of an energy broker providing microgrids customers with the possibility to buy service-level agreements, namely power provisioning contracts having different duration, and consequently different price and uncertainty.

Conclusions
The proposed approaches contribute to sustainable growth at various stages of the design cycle. First, the collected data on energy consumption allow for an assessment of required electrical energy on a fine-grained time basis. This is necessary to avoid bulk assignments in energy planning that are usually based on a larger value when there is doubt about the expected energy consumption. Moreover, it allows pretesting systems via simulation before an actual deployment. A system for measuring energy consumption data furthermore enables feedback systems that inform consumers and involve them in decisions regarding device usage. This is a prerequisite for efficiently using renewable energy sources, since without some flexibility in device usage and, therefore, energy demand, excess energy from renewables eventually goes back into the grid or needs to be stored. Storage is comparably expensive, and feed-in tariffs are expected to further drop, which on the one hand is an economical problem for the owner of the production system and on the other hand poses a problem for the overall grid, when energy production exceeds demand due to renewable energy production peaks. Current solutions such as a reduction or cap of production mean letting green energy production units underused. The proposed automatic control of energy consumers based on machine-learned intelligence further develops the idea of a self-organizing and self-balancing energy management system, which relieves the users from micro-managing their appliances according to the current microgrid situation.