{'fraction_non_alphanumeric': 0.016776335289584447, 'fraction_numerical': 0.0030232971723279387, 'mean_word_length': 4.726408689748812, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Energy management System using Multi Agent Systems with IoT and Machine learning

This paper deals with a Dynamic, Distributed Energy Management in a Smart Micro-grid. At present, the energy management is done using a system called SCADA (Supervisory Control and Data Acquisition). This paper advocates the application of Multi Agent System for dynamic energy management. Economic and environment optimization is implemented by choosing the least cost renewable resource available at that time. The outcome of this paper is to show that MAS based control architecture can be used to optimize the energy management in a microgrid. Machine learning has been used for load forecasting and to improve the efficiency of the power grid and create a smooth operating environment.


Introduction
The power produced initially is much more compared to the power that reaches the consumers. This is because most of the power produced is wasted since losses occur in the form of discharges like heat. This forms a mismatch in the ratio of consumption and demand. We cannot continuously monitor the power usage since there will be regular blackouts and power outages in the current systems. These challenges are the reason for a need of an efficient system for managing power. In our paper we would have dealt with management of demand of power with the using smart grid and micro grid to ensure efficiency in storage and transmission portion of the system. Using IoT concepts the data is constantly recorded and stored in the cloud for further analysis. Figure 1 shows the MAS Architecture for microgrid.  [1]. The main goal of sustainable development is to increase the share of renewable energy from the total power consumed in the world's power sector. Microgrids are the most important part of a power supply network in order to integrate the renewable energy production along with conventional energy sources. Microgrids have to connected upon in larger networks in order maintain power reliability, quality and cost effectiveness [2]. Multi agent system (MAS) is a collection of different types of agents in a single package can be effectively programmed to manage the power supply within the network of microgrids [3]. MAS is looked upon as the most efficient and reliable entity to build a dynamic architecture. It plays a major role in many research and prototypes [4]. In MAS every agent has its own local responsibility and decision-making authority. Also, these agents can be integrated together to take care of the whole network of grids. This feature of MAS gives it an ability to operate continuously even under breakdown and malfunctions in network [5]. MAS can be combined along with cloud system and IoT features can be handled through it [6]. The strategy and scheduling of agents can be programmed, and performance of every agent can be improved [7]. Smart energy sharing and smart micro-grid are discussed in [8]. Agent based simulation of micro-grid is discussed in [9]. The multi agent system based dynamic operation and control strategies of microgrid network are discussed in [10].
We also have used Machines learning to optimize the current system of power grid and improving the efficiency on the demand side as well as consumer side management by predicting the short-term load using Machine learning algorithms. This prediction provides improved efficiency and lowers the cost of power production as well as evens out consumption during times of the day instead of having a single peak time and spreading It throughout the day.
The rest of the paper is organized in the following manner. Section II presents MAS and IOT in energy management. Section III explains the Machine learning in microgrid. The work plan is given in Section IV. MAS implementation is given in section V. Implementation of machine learning is given in section VI.

Multi agent system and IoT based energy management in microgrid
Various components are required for the building of IoT based energy management system. These are explained in this section.

Microgrid
Microgrids are the basic building block of smart grid. These grids can be added in many numbers to form a smart grid. The microgrids are interconnected with each other and they form a network giving seamless power supply. When it is connected along with conventional power supply and renewable energy sources, it can seamlessly switch between the different supplies and provide constant energy. Even if one grid is under maintenance, the power can be re-routed through other microgrids. The power supply interruption can be avoided.

Smart grid
Smart grid is a network of power stations, substations, transmission lines, transformers etc. which is responsible for distribution of electricity to industries and households. It acts a mediating channel between power production and consumption, so that it takes care of any power outages and breakdown of network. This smart grid controls all the microgrids of a region and consist of both conventional and non-conventional power sources. So, it takes care of overloading, peak demand and equally distributes the available energy to the consumers by reducing the cost of production.

Internet of things (IoT)
R e t r a c t e d IoT is the collection of data through internet, interfacing and manipulating them in order to obtain a desired output. In this paper we incorporate multi agent system and features of IoT.JADE(Java Agent Development Environment) is used to implement the concepts explained in this paper. A cloud data base (like UBIDOTS) is used for online storage and data communication purposes.

Multi agent systems
MAS is a distributive system where agents collaborate for achieving a common goal. MAS is implements in JADE platform. JADE is an API (application programming interface) which allows the user to program the required agents and obtain the raw data in order to calculate variables like peak load time, cost effective distribution etc. JADE which is FIPA (Foundation for Intelligent Physical Agents) compliant framework for developing multi agent systems is implemented using Java language. It makes the process of creating multi-agent system through user friendly means by providing a set of graphical tools. JADE can provide a convenient way for users to on develop agents to view and control the power flow in a microgrid system. Figure 2 shows the General Agent Architecture.

Ubidots
It is an online cloud services which can send or receive data from any device with internet connectivity. All the data obtained from the smart grid and users are stored here which is operated upon by the JADE environment to find out various efficient method of power distribution. It is an IoT platform which gives users the access to host and maintain their own servers for data handling. You can configure actions and alerts based on your real-time data and unlock the value of your data through visual tools. Figure 3 shows the JADE Architecture.

Arduino
Arduino is the smallest individual part of a grid network which takes care of sensors management and load measurement. The Wi-Fi module present in it helps in connecting to the data server and it R e t r a c t e d delivers the collected data to the cloud. It allows seamless plug and play features like any new production source (like solar) can be plugged in or away from the grid without directly affecting the power supply network. It is processing component of the whole network of smart grid.

Machine learning in smart grid
The ML algorithms have become useful by using data science in the use for prediction in Smart grid. ML models are used to predict various factors that help in the efficient operation of the grid. Renewable energy being dynamic in nature can be greatly benefitted from this prediction. ML algorithms are used to obtain predictions which increased accuracy. Huge amount of data is analyzed and machine learning algorithms are used for predicting use of electricity in the consumer and also utility. Perfect planning can be done to reduce capital costs. Cost of energy purchasing and can be diminished with use of ML. Various planning and management factor all depends on how accurately the load can be predicted at any given time. These data are collected to form a unique model to improve the accuracy. Data mining predicts user activities and it will try to approximate the value of load based on these characteristics.
Embedding these multiple characteristics increases the accuracy but also causes an increase in the accuracy hence features have to be selected properly.

Radial basis function
Radial Basis Function (RBF) approach is more intuitive approach. Here, network regression is performed by similarities measurement between data available to predict output and samples from every training set, stored in each he neuron. Then the Euclidean distance between the two adjacent neurons and input is obtained in the regression process. It is moved into a category which more appropriate. This network positions neurons in the space given by the features. It is so called as the radial distance is the parameter of the function. Euclidian distance determines importance, and this oppositely affects the output. Overfitting is the only disadvantage.

Random forest method
Random forest is an algorithm used for regression by using numerous decision trees at to train and using the mean forecast of as continuous output. Random decision forests overcome the over-fitting problem using "stochastic discrimination" method of regression. It consists of numerous trees which has numerous nodes and leaves. The nodes represent values, which further branches into 2 more leaves depending on the satisfaction of the condition. The leaf again splits to more nodes to create layers. In this way by giving an input value to number trees an output for a given input is predicted. Since highly efficient, it is very accurate for the collection of data for fewer number of attributes.

Work plan
• MAS is implemented in JADE in the micro-grid and the agents (like load agent, solar agent, wind agent etc.,) operations are practically verified using Arduino mega microcontroller through RxTx serial communications.

•
Potentiometers and LEDs are connected to the Arduino board to form a testbed. Potentiometers represent environmental variables of the micro-grid such as solar and wind resources, loads, batteries, grid, and diesel generators; and the LEDs indicate the actuator signals. JADE agents receive the environmental values from Arduino board and, through coordination, take strategic decisions shown in Figure 4.

•
The resulting command signals sent by the agents to the Arduino board are indicated by the LEDs, which can be used to trigger/drive the actuators of the micro-grid in the field. A smart micro-grid testbed is built by interconnection of three micro-grids and the smart grid features are verified in a dynamic environment Figure 5. A transactive energy market is created where anyone can buy or sell power across the network at an optimal price. This can be scaled up to form future smart grid.

Implementation of multiagent system
The various steps involved in the implementation of multiagent system using JADE has been explained below

Creating agents in jade framework
JADE is available as a library (jade.jar) which can be added to java IDE. The MAS is created on microgrid based model where one microgrid consist of agents with load and source agents such as solar, wind, battery and grid agent which serves as common for all the microgrids. Figure 5 Shows the agents that has being implemented for the project. The following code is used to create the agents as shown in Figure 6.

Implementing Agent communication
The most fundamental characteristic of MAS is the communication ability of agents. The communication is accomplished by agents through sharing messages which contain information. A relevant agent communication language must be used to implement the communication between agents depending on the agent development framework selected. There are various axillary data on a message other than the content information like message type, sender data, receiver data, etc. It is simple and often the method is to keep the content as "String "with application dependent meaning.

Outputs
The basic logic behind this management system created using MAS is to make sure load agent gets the power from source agents with lowest price with maximum power capacity. The algorithm ranks each of the agents from best to worst and moves from one to another in need of power.

Case 2.
In this case the load demand is high and the load agent taps power from the lowest prices source to higher depending upon the need. Figure 9 and Figure 10 shows the output of this case.

Case 3.
In this case all the source agents will provide power in the same price so during this kind of situation the load agent tries to find the agent with highest power capacity. That agent with the highest capacity with the same price becomes the best source agent so it taps from that agent and moves to the next best if need is required.Figures11 and Figure 12 shows the output of this case.

Implementation of machine learning
Scikit learn and Pandas have been installed using Anaconda Navigator. The code is written in TensorFlow using the Jupyter platform. The load usage for a day is observed and the Electrical Department has been considered for load observations. The training data is taken as the load vs time observation for a period of one year in the electrical department. Out of this data, 80% is taken for training and the remaining 20% is taken for testing. The performance is observed using linear regression model which is applied in scikit learn library environment in Python using Jupyter code editor initially. Since single feature will not give accurate prediction, the dynamic pricing is considered. The performance is analyzed with MLR model in TensorFlow by importing necessary packages. The linear regression models will not give a good performance results for nonlinear data and hence Neural Network multilayer perceptron with hidden layer is used to improve the accuracy of prediction for nonlinear data. Then, RBF is applied using TensorFlow in Python. TensorFlow is an open source AI library for python programming language which allows developers to create largescale neural networks with many layers. It uses data flow graphs to build models. Tensor Flow is mainly used for: Classification, Regression, Deep Learning, Neural Networks etc. Pandas are used for fetching the data as data frame and data pre-processing and NumPy in Python is used for numerical calculations. Here, the load vs time and the unit price are considered. One dependent variable and two independent variables are considered. The data is loaded and Pandas is used for data cleaning and preprocessing.

Simulation results
The packages used are depicted in Figure13. Mathematical techniques are implemented and to test goodness of fit of the model. When the datasets are analyzed only a very small difference is noticed to the primary set hence the MSE is negligible. The good level of fitness has been proved by R 2 value of RBF which is found to be 98.2% as given in the following Figure 14. The code is written in jupyter after the packages have been added which are required. In this diagram the rbf kernel has been implemented and a highly accurate graphical representation of the results vs predicted values can be seen so this means that the accuracy of the algorithm. The R2 score value is 0.99 which is accurate.
The random forest regressor has been implemented using the sci kit learn package of python and the results vs predictions are highly accurate achieving an R2 score of 0.989 which denotes very high accuracy as shown in Figure 15.

Conclusion
In this paper, a development of a MAS architecture-based EMS for a microgrid has been discussed. A full micro grid was considered for the simulation in the JADE platform and almost all the scenarios were considered with realistic power data patterns. We were able to develop the MAS in JADE platform for a micro grid with multiple DES and loads to meet the following objectives.
• Multi agent concept was successfully introduced for the energy management operation of a micro grid with JADE simulation platform. • Agent communication and integrated operation qualities of agents were used for the simulation process in JADE platform. • Agents were programmed according to an energy management control algorithm and given the responsibilities for each agent. • MAS developed in the simulation platform was tested with realistic data and checked for a number of cases and results were presented and discussed. • Load forecasting is implemented with machine learning algorithms for efficient energy management. `