Resource allocation model for cloud-fog-based smart grid

. This paper investigates the allocation model, the ﬂ exibility, and the scalability of fully distributed communication architectures for metering systems in smart grids. Smart metering infrastructure aggregates data from Smart Meters (SMs) and sends the collected data to the fog or the cloud data centres to be stored and analysed. The system needs to be scalable and reliable and to respond to increased demand with minimal cost. The problem is to ﬁ nd the optimal distribution of application data among devices, data centres or clouds. The need for support computing at marginal resources, which can be hosted within the building itself or shared within the construction of the complex, has become important over recent years. The resource allocation model is presented to optimize the cost of the resources in the communications and relevance parts of computing (the data processing cost). The fog helps cloud computing connectivity on the edge network. This paper explains how calculation/analysis can be performed closer to the data collection site to complement the analysis that would be undertaken at the data centre. Results for a range of typical scenarios are presented to show the effectiveness of the proposed method.


Introduction and literature review
Smart Grid (SG) as a data communication network is one of the most important applications of the Internet of Things.Smart Grid enables real-time data collection and analysis from the power grid acquired from transmission lines, distribution substations, and consumers [1].It is expected that the application of two-way communication in the smart grid will not only enable dynamic monitoring of electricity use but also open the possibility of automated scheduling of electricity use [2].The smart grid initiative will therefore be characterized by the integration of several technologies which will help improve the reliability and efficiency of electricity supply.These technologies will also reduce generation costs and electricity supply to the consumers [3].Efficient and accurate billing and metering services require the integration of Advanced Metering Infrastructure (AMI), Customer Information Systems (CIS), billing systems and Meter Data Management Systems (MDMS).Further integrating AMI with Outage Management Systems (OMS), Distribution Management Systems (DMS), and other Distribution Automation (DA) systems can increase the benefits of each smart grid technologymaking system integration a top priority and a major technical challenge for many utilities [4].The utility company and customers interact through the fog and the cloud to realize a response to a certain demand.These requirements are executed in the cloud, not in the utility's energy management system.The grid is designed to reduce demand during peak periods by the use of metering technologies and communication protocols.
This paper aims to combine a traditional network with a cloud system to create a Smart grid system that helps the efficient use of electricity by consumers.Smart appliances and smart meters can meet their demand for electricity from nearby grid stations.Integration of a cloud-fog-based platform helps the usage of electricity resources efficiently with lower response time [5].
The authors in [6] proposed a model for the integration of the SG platform based on a cloud fog for optimal allocation of resources using the First Come First Serve (FCFS) and Ant Colony Optimization (ACO) techniques, improved throughout the response time.Infrastructure based on cloud-fog for the allocation and distribution of resources at the request of end users, with improved Processing Time (PT) and minimizing costs is presented in [7].A new service mediation policy has been proposed for fog selection in [8], where the authors presented a model for resource allocation on cloud-based fog-based infrastructure for efficient energy management.
This paper proposes to find the optimal distribution of application data among devices, data centres or clouds to minimize the cost.The main contribution can be summarised as follows: -Reduce the overall cost in relation to bandwidth, distance, and processing time, -New algorithm for scheduling Fog Computing Systems (FCSs) in a distributed architecture, -Fog will provide smart device location awareness, the policy on closest data service provider that helps to allocate Virtual Machines (VMs).
The rest of the paper is organized as follows: Section II presents a formulation of the problem.Simulation methods are described in section III.The results analysis and conclusion are presented in sections IV and V, respectively.

Problem formulation
The optimization problem is formulated in order to find the optimal allocation of the FCS [9]. Figure 1 shows the proposed model of a fog computing architecture comprising three tiers.The first tier consists of smart meters, the second tier consists of fog servers, and the third one is the conventional cloud.Communication between the tiers is possible in four different ways: (a) Smart device to smart device, (b) smart device to fog server, (c) fog server to fog server, and (d) fog server to cloud server.Under fog computing, most of the functions of data processing are performed in the cloud, so a reliable and efficient communication system is required, to get a robust, affordable, and secure power supply through SGs [10].
To optimize the proposed AMI architecture, the following optimization components must be determined and defined: decision parameters and variables, cost and reward, performance metrics and objective functions.Performance metrics in terms of parameters of communication architectures and processing parameters are first formulated.Performance metric scales are then formulated with the necessary communication and processing resources.These are determined by the number of applications how much data is used by smart meters and their sampling frequency.Since FCS is an entity that manages and processes data in a smart grid system, our primary task is to design a scalable architecture focused on FCS considering its interaction with smart meters and the access networks to operate and manage [11].
Communication and processing cost in a distributed communication architecture consists of two parts.The first part of the cost is the Bandwidth Distance (BD) product, which calculates the cost from the gateways to the corresponding FCS (or distributed VMs).The other part of the communication and processing cost is the sum of BD products from each FCS to the Central operation Center (CoC).FCS, as noted above, represents the heart of AMI and works with data coming from gateways by processing and storing them appropriately.
Since the distance between smart meters and the appropriating gateways is small, communication and processing costs between the meters and gateways are minor, as are the communication and processing costs between FCSs and CoCs.The cost of setting up communication equipment such as fibre optics and routers, is proportional to the BDs and they are calculated as a product of BD and unit cost r.The FCS setup cost is the cost of the required BD to obtain the targeted optimization problem function [12].
Parameters and variables, which are used to determine the optimization problem, are listed below.For gateway i connected to FCSj, the BD of the information collected could be expressed as k i d ij , and the corresponding BD of the information used as sk i E j .
In this case, k i is the speed of generated traffic on the individual gateways expressed in (Mbps), d ij is the distance of the gateways from FCS (km), E j is the distance of FCSj from CoC (km), and s is the ratio of the data amount required to operate CoC and FCSs relative to the amount of raw data collected by the distributed FCSs.
Taking into account the total BD generated by all N gateways, the first part is where M is the total number of potential locations for FCSs.The x ij indicator is used because the expressions k i , d ij and sk i E j will be considered only when the gateways i are connected to FCS j, otherwise, it is zero.Furthermore, the r unit price of the bandwidth distance product (Mbps Â km/$) should be added are S j the cost of using FCS at the location j ($).
Let A be the size of the area covered by the service (a Â a).The y j tag indicates whether a potential location j has been selected to use the FCS.As a result, an optimization problem that minimizes total system costs could be expressed as C 1 : With conditions: If the communication and processing cost between FCSs and CoCs is observed to be the same, then the bandwidth q required to exchange information between distributed FCS and central CoC (Mbps) can be taken as a measure of cost computation since such a consideration is very similar to the earlier consideration, the problem of equation ( 1) will be discussed below.The same method can be applied to another scenario with the same cost between FCSs and C.
In addition to the above communication and processing cost, the data processing cost C 2 in FCS and CoC will be discussed below.It is well known that usually one type of application is running on the VM providing the appropriate service, and specifically in SG it can be a measurement of characteristic parameters.If the fog finds any VM, with minimum time response and with a smaller load, it assigns end-user requirements to the VM on a layer of fog.If the fog cannot find any VM on a layer of fog, which can meet the requirement, it requires a cloud layer, which is the service provider.On the other hand, in the cloud layer, each user has their own profile maintained by the cloud.If the cloud finds any VM in the core network that can meet the demand, the VM assigns a profile to the user.Whereas, if the cloud cannot find the VM in the basic network, it sends the request to adjacent clouds, to provide services to the end users.Service providers in the cloud generally have few Data Centers scattered along geographical areas.The fog platform provides the best response time, acting as an intermediary platform between the cloud cover and the layer of the end user.Whenever the fog receives an application from the layer of the end user, it begins to locate a VM that can serve the incoming request.Processing costs can be directly linked to the response time and thus weigh the total cost of such a network.Let us have a set of task T and VM inside FCSs.VMs denote a set of virtual machine, and T denotes a set of tasks, so it is mathematically represented as in ( 5) and ( 6): A set of VMs varies from 1 to L, and all VMs have the same capacity.Showing the execution time ET any task is mathematically defined in (7): where FT presents the completion time of task k in VM l and ST is the start time of task k in VM l.The sum of the time of implementation of the task T is presented in: A task that has a maximum execution time has been chosen for the allocation of resources to the VM.Equation ( 8) represents the assignment status of VM tasks.
In this case, a better response is achieved by reducing the implementation time of the VM, i.e., VM cost k .The total cost of C 2 required for virtual machines is the sum of the total task time with the cost of using VM resources.The total cost of communication and processing is then which can be minimized as: Assignment of VM tasks is done to minimise the execution time.When the completion time of all tasks is calculated, the task with the smallest execution time will be selected.
The task is then assigned to the selected VM, whose completion time is minimum among all available VMs [13].
For experimental purposes, the chosen selected number of FCSs is considered in a limited area.The results are evaluated based on the cost and response time.The calculated cost includes only the VM cost.

Selection of the simulation method and setting
With this setup, it is assumed that there are no capacity constraints on individual FCSs.This is a reasonable assumption, since at this stage of planning, we aim to reduce the total cost of implementing the selected communication infrastructure and some of the estimated processing costs.Data collected by one or more meters in the same area are stored together and are available through the same FCS.The cost of setting up the FCS is considered if the FCS is obtained as a result of the optimization.The solution to the problem is selecting the potential FCS locations for the optimal overall system cost, including an assessment of the processing cost [14].
Considering the objective function and the conditions given by the expressions (2), ( 3) and ( 4), the greedy algorithm will be used to determine optimal solutions to the FCS location problem.The chosen method is used in cases where the variables that represent the solution to the optimization problem are limited to integers, which in our case represent the number of selected FCSs.With this algorithm, the location of the FCS-s is selected from the pool of potential locations while simultaneously determining the total cost of communication and the partial processing cost.
The first FCS is selected based on the minimum setup costs.When selecting a different location and each subsequent one, two FCSs are taken, including one that has already been selected and the next FCS is selected based on the target minimum cost.In the end, the optimal number of locations as well as the minimal cost of connecting with FCS is the solution to the optimization problem [15].The greedy algorithm method was used as part of the optimization tool within Matlab.The proposed approach first generates random locations for CoCs, FCS-s and gateways.After that, by changing the scaling parameter N, the size of the grid in which the production and distribution facilities are located as well as the number of these facilities are scaled.That said, the density of facilities of each type per grid area is independent of N. Various configuration parameters can be considered like the number of users, number of virtual machines, number of requests generated per user per hour, number of processors, amount of storage, etc.Based on the given parameters, the tool calculates the simulation result and shows it graphically.By performing various simulations, the cloud service provider can determine the best way of resource allocation, in order to optimize the cost for providing services [16].

Results and discussion
The configuration defined above was used and after the performed simulation, the result of the calculation for the common metric cost such as response time and cost in meeting the requirements is shown in Figures 2-9.Parameters such as average response time and total costs of different data centres were considered in the analysis.
The area for which the service coverage is provided is in the form of a Â a, with both dimensions being expressed in kilometres (km).A random number generator was used to schedule gateways and FCSs.The greedy algorithm enables the optimal connection of gateways and FCSs at minimal cost.A random distribution of FCSs was used to solve the optimization problem and the gateways are shown on a 100 Â 100 surface.In the simulation, 50 and 100 FCSs were used along with 1000 gateways.The data rates between gateways and FCSs, FCSs and CoCs are the same for the entire observed surface.The FCS-s setup price is constant throughout the simulation.Figure 2  In these simulations, N ranges from 100 to 1000, M from 0 to 100, S from 10,000 to 100,000 $, k from 1 to 10 Mbps, a from 0.1 to 1, and b from 100 Mbps Â km/$.
When a centralized communication architecture is used, only one FCS is in use, collecting and processes data received from all devices in the network.Centralized architecture is not scalable, and any increase in users is a potential problem.For a centralized communication architecture with many gateways, BD and total cost can be determined using the following expressions: and BD and total cost change linearly with increasing number of gateways, average data rate, and average distance between gateways and FCS.
In the case of distributed communication architecture, expressions are derived for the optimal number of FCS locations (M 0 ) that minimizes total cost, BD, and optimal total cost, as follows: where S is the average cost of setting up FCS, s is the ratio of data used by the operating and control centre.
In the case of distributed architecture, BD and total cost for information gathering are scaled by x 2 3 taking into account the number of gateways N, the average number of arrival messages k, and the average distance between gateways and FCS D. It can be observed that for smaller parameter values s, a distributed architecture is more scalable compared to centralized communication infrastructure.Based on this, we can conclude that the total cost and BD of distributed architecture are s times higher than centralized architecture.After performing the simulation, the selected locations for the FCS are presented in Figure 3.
Figure 4 shows the connection of gateways to the selected FCS.The connection was made based on the obtained simulation results.
In this simulation, the number of selected FCSs is 18 out of the total number of M = 50.The overall cost is much lower after optimization is completed.We can see the benefits of using a distributed communication architecture if we compare it with a centralized communication architecture in terms of the total costs.
Figures 5 and 6 show the optimization results for M = 100 as well as how to connect gateways and selected FCSs.In this case, the optimal number of FCSs is 23, resulting in savings of about 57%.
As part of the analysis of the optimization results, a change in the BD and the total cost of device setup will be observed, with a change in the number of selected FCSs from 100 potential locations, as shown in Figure 7.This phenomenon of BD reduction can be explained by the fact that during the optimization process, we strive to reduce the total cost and load on the selected FCSs.Reducing the load implies a decrease in the total BD.On the other hand, the total cost decreases exponentially and reaches a minimum value for the selected 17 FCSs, after which the total cost increases linearly.
The total cost and BD were calculated by running multiple simulations and using the equations (11) to (14) for different amounts of gateways while keeping the other parameters constant.By increasing the number of gateways, BD increases linearly for both types of infrastructure, centralized and distributed.Comparing the distributed and centralized architectures (Fig. 8), BD is smaller for distributed architecture, which is to be expected, since we want to minimize implementation costs.Simulations were performed for values of parameter s = 1.Looking at the change in the total cost, the total cost in the case of distributed communication infrastructure is significantly less than the centralized communication infrastructure.Thus, by solving the optimization problem, fewer FCSs were required, thus minimizing the overall cost of implementation.
The k was varied in the range from 1 to 10 Mbps and a change in the mentioned sizes was observed for centralized and distributed architectures.In the case of centralized communication architecture, total cost and the BD changes linearly with the change in the average data rate.In the case of distributed architecture, the total cost and the BD increase slowly, while the difference between the total cost and the BD increases with the increase in data rate.It is important to note that the total cost is much lower when s values are smaller.In the case of s = 1, the total cost in the distributed system is closer to that in the centralized system.The analysis was performed for M = 50, N = 500, r = 100 $/Mbps$, S = 100,000 $ (Fig. 8).
Additionally, we observed the behaviour of the system for s = 0.1, s = 0.5, and s = 1.The effect of changing the cost of setting up an individual FCS on the total cost was also observed and a comparison of centralized and distributed architecture was made.The simulation was performed for M = 100.The results obtained are shown in Figure 9.
Changing the cost of setting up an individual FCS, as can be seen, does not make a huge change in the simulation results.The total cost is still less for distributed compared to centralized architecture.With the increase in FCS setup cost, the total cost increases.This phenomenon can be explained as follows: when the FCS setup cost increases, the optimization process will choose a smaller number of FCSs to slow down the overall cost increase.It can be concluded that some savings have been made by using distributed architecture and the savings are greater with the increase in the number of elements in the network.
The cloud-fog model combines clouds and fog to enhance data processing and ensure quick response times.Unlike previous models discussed in references ( 6), (7), and (8), this model considers the location of network ele-    ments in communication networks within a smart grid.Furthermore, by fine-tuning the parameters associated with specific applications in the smart grid, such as the parameter k in our proposed model, it becomes feasible to establish a connection between the virtual machine's location and the user's profile.This approach can lead to improved results in terms of latency and efficient utilization of resources, which were not considered in the aforementioned models.Certain parts of the data processing can be done in the fog, close to the data source, to reduce latency and reduce the load on the communication network.This architecture enables more efficient use of resources, optimization of data flow and better support for critical applications in the smart grid.In this model, cloud and fog cooperate with each other to support different tasks in the smart grid.Deciding which tasks should be performed in the cloud and which in the fog depends on various factors, such as latency, resources, security, and application requirements.The results obtained by this method can help to further determine the bandwidth allocation models that analyse the bandwidth requirements of different applications within the smart grid, such as power distribution management, data transmission and network control, and determine the optimal bandwidth allocation to ensure efficient and reliable communication.

Conclusion
The large number of smart meters and the growing need for very frequent data readings represent a major challenge for scaling the AMI smart grid system.This study examines two distributed communication architectures that are scalable and aimed at providing efficient AMI smart grid services in the scenario of rapidly growing smart meter traffic.
The placement of FCS in a distributed architecture can be investigated as an optimization problem to decrease the price that is proportional to the accumulated bandwidth and the data processing services.That is being done by evaluating the communication and processing resources for data migration in the support system of the smart grid.The presented results indicate that the recommended greedy optimization algorithm is very efficient in distributed communication architectures in contrast to centralized architecture.These two architectures have also been compared from the scalability standpoint which is another important contribution of the study: an asymptotic analysis shows cost assessment of the scalability of distributed architectures.The influences of various factors on required communication resources are investigated through the BD value, closedform expressions for the minimum total cost, optimal number of FCS and the data processing cost.
In future work, it is possible to investigate costs related to the specific FCS hardware components, as well as the cost cases of the necessary smart grid services.
displays the positioning of FCSs and gateways for two scenarios: one with 50 potential gateway locations and another with 100 potential gateway locations.The figure illustrates where the gateways (M) can be located in relation to the FCSs, indicating the possible placement options.