Optimal Scheduling and Management of a Smart City Within the Safe Framework

This paper proposes an enhanced cyber secure energy and data transaction framework for the optimal operation and management of the smart city. Recently, the concept of smart city within the power systems has taken the center stage. Although the power system full monitoring and accessibility is guaranteed through the smart city concept, the risk of cyber-attacks to the system has been promoted, severely. With this in mind, in this paper an effective smart city model including the smart grid, smart transportation systems (STSs) that consist of the metro and electric vehicles (EVs), microgrid and smart energy hub (EH) is presented. In the proposed model, an improved directed acyclic graph (DAG) approach is represented in order to enhance the security of data transaction within the smart city. In this approach, a security layer is added to the blockchain which will prevent the cyber hackers access to the system information. An effective energy management schedule is also developed in this paper. To do so, an intelligent priority selection (IPS) based on advanced math operators is provided to allocate the metro-owned charging stations (MCSs), optimally. Furthermore, the unscented transform (UT) is utilized to handle the uncertainty of the system parameters. The results showed that the proposed IPS could improve the method CPU time over 75% compared to other well-known meta-heuristic methods in the area. Moreover, the results showed that the proposed framework has remarkably reduced the run time and increased the accuracy of the solution compared to the other meta-heuristic algorithms.

The associate editor coordinating the review of this manuscript and approving it for publication was Filbert Juwono .  Weighing coefficients in stochastic model.

I. INTRODUCTION
Smart City as a fresh concept for improving the life quality is introducing a new way of conceiving buildings, transportation system, publics services, power system, healthcare, etc. Today, the metropolitan population is more than half worldwide, and by 2030 it is projected to be around five billion [1]. To this end, cities certainly are assessed as one of the primary positions in addressing major public and financial problems, involving low carbon expansion, decrease in emissions, energy efficiency, shared energy resources, financial growth, and more [2].

A. MOTIVATION AND AIMS
The smart city idea is focused on the connection and the relationship between structures wherever communication and information technology (IT) take a major part [3]. Many smart cities taxonomies are discussed and explained in [4], [5]. These explanations point out that the smart cities still face with many challenges and issues in terms of energy trading, security and privacy of the agents. In the analyses over the systems with bigger scales (e.g. smart cities), more producers, agents and components will be appeared and the interactions among them are unassailable and their related challenges need to be investigated. The proposed interactions need to be based on a secure platform on the smart environment where all the systems are equipped with smart devices. These issues demand undergoing researches to overcome such challenges and motivated us to work in the field.

B. LITERATURE REVIEW 1) ENERGY TRADING
Cities' energy requirements are abundant and complex. That is why contemporary smart cities should enhance current energy systems and deploy new alternatives by taking into account the associated synergies between all energy systems. Recent renewable energy sources, energy requirements, transport technologies and other problems are evidence of significant energy challenges appearing in smart cities [6]. In this regard, transportation technologies and smart housing are key components inside smart cities alongside the big power customer. Different sections can be considered in the smart cities including the smart transportation system (metro and EVs), microgrid and Energy Hub (EH).

a: TRANSPORTATION SYSTEMS
In the transportation systems, electric vehicles (EVs) and underground metro systems are the most widely-used but challenging technologies in towns, given the large electricity requirements and the growing environmental emissions. In addition, the presence of plug in EVs (PEVs) with stochastic parameters and the high penetration of distributed energy sources (DERs) like wind turbines (WTs) can pose a further barrier to the implementation and development of smart city concept.
In order to mitigate the high effects of EVs in the smart city and change their only consuming role into an active player, the idea of EV-to-Grid (E2G) was developed by researchers in recent years.
The E2G innovation has had advantages, characteristics, flaws, economical features and technical requirements which a complete review can be found in [7], [8]. Authors in [9] assessed the effect of EVs on the electricity grid and its use as a tool for developing renewable energy resources. In [10], the organized combination of aggregated EVs as portable distributed demand and storage and renewable energy sources such as WT in electricity installations was investigated using stochastic models. That model takes into account the probabilistic performance of electricity vehicles and their influence on the optimum operation of the smart city. A stochastic method was proposed in [11] to model the uncertainties of EVs and WTs when it comes to the high penetration of EVs into the power grid in an E2G infrastructure. Also to improve the performance of the EVs, the wireless charging lines model is proposed in [12]. In [13], the effectiveness of the transport scheme was enhanced through five primary task types: energy effectiveness, effective riding, convenience, regenerative braking systems, intelligent governance and evaluation. In addition, the railway scheme was also regarded as a quick transit scheme which of course is a big electric consumer. Technically, rail systems can carry heavy crowds which make them popular and common in metropolitan regions. Due to the large number of train stations in a mid-size city, regenerative braking may save some energy for urban rail systems [14]. In [15], regenerative braking was proposed as an effective restoration method in the train using traction motors during slowdown. In order to improve the effectiveness of Braking Energy (BE) recovery in the rail systems; optimal scheduling, power storage and reversible stations were assessed too. An optimal scheduling of decelerating trains at stations was investigated in [16] considering the departure moment of a different train in the nearby electrical area. The speeding train has also the ability to utilize regenerative BE without any storage device involved and in effect a programming problem is described to discover an optimal scheduling solution in the railway system. Authors in [17] re-examined the storage system for the use of electrical braking power. The major benefit of this technique is that there is no need to the complicated synchronization of the railway, but the additional storage devices lead to greater expenses. The last approach VOLUME 8, 2020 for returning BE to the grid was presented in [18] which uses reversible substations. They also addressed the usage of the regenerative BE for charging the EVs.

b: EH AND MICROGRID
As it can be inferred from the above survey, the smart city idea is growing fast and new advanced technologies are emerging to help last-long support of the system. Meanwhile, the considerable expansion of cities, along with critical global energy growth and the increasing need to reliable and secure energy in smart cities, are motivating concepts for implementing the EH in the smart cities. The EH is a multi-carrier energy system infrastructure with several inputs and outputs with various conversion systems based on gas, heat and electrical infrastructures, including thermal, natural gas and electrical consumptions of commercial, residential and industrial demands in an efficient method [19], [20]. The use of EH would be a great innovation from the perspective of energy and environmental issues in smart cities. This is a response to the advent of advanced sensors and communication apparatuses as well as large quantity of different types of energies demands (electrical, thermal, gas and water) in the cities [21]. In [22], authors tried to investigate the operation problem of the smart EH in the smart grid. They have provided a smart platform for the system to minimize the operation cost of smart energy hub. In [23], the residential EH operation is investigated in the smart grid wherein the systems are equipped with communication systems. The performance of the microgrid is not solely depend on electricity energy but also depends on other types of energy. With this in mind, authors in [24] investigated the concept of EH in microgrids in multi-carriers.

2) DATA SECURITY
As it was mentioned before, providing a secure energy transaction is also concerned in smart cities. The decentralized based cryptographically data transaction method so called ''blockchain'' has attracted many attentions in the field of power systems [25]. In this regard, a blockchain based technique in [26] is used to control cyber threats, prohibit fraud and decrease network operating costs. Authors in [27] addressed a secure data transmission framework based on blockchain technology in the smart cities. Same approach pursued in [28], in which authors provided a hybrid structurebenefits from both central and decentralized features based on blockchain technology for secure data transmission. Since in blockchain technology, the data blocks are sequentially dependent, the chance of getting attacked by malicious third parties is still possible. To overcome this challenge, it is shown in the literature [29] that the cybersecurity of electricity trading in the microgrids can be much improved by changing the blockchain technologies relying on a direct acyclic graph (DAG). In [30], a review is provided on the technological attributes and platforms in the current literature for the standing-alone fog computing and internet of everything paradigms. Moreover, a new concept, fog of everything, is proposed that incorporates the benefits of both fog computing and internet of everything in one unit form.
The main challenge in a high scale energy trading environment such as smart city, is the dependency between different sections of the smart cities which demands an appropriate model to address this issue which has not been addressed by previous works. Such high scale environments increase the possibility of data attacks due to the high number of agents, devices and transactions which needs to be investigated properly. Table 1 summarizes the above explanations.

C. FEATURES AND CAPABILITIES
The main drawback of [17] is that the optimal place of the metro owned charging stations (MCSs) have not been addressed which might have a significant impact on the overall performance of the metro's energy transactions. For allocation problems, a wide range of meta-heuristic algorithms are regularly used [31]. This drawback attempted to be solved in this work by optimally planning the locations of MCSs using a novel mathematical based algorithm which significantly reduced the time and increased the accuracy of optimal solution. This paper also proposes a secured data and energy transaction framework for smart city considering the transportation systems (EVs and metro), EH, microgrid and smart grid. As previously mentioned, due to the interdependency of proposed sections of the smart city, it is tried to address an energy trading model to cover all these sections aiming to assess their impacts as well. The concept of DAG is also used here but with a novel cryptography based security layer which is used to enhance the DAG performance. Therefore, the primary attributes and characteristics of this document with regard to the prior publications can be stated as follows: • Developing an appropriate energy trading framework among the EH, microgrid, transportation system and smart grid considering wireless recharging lines and the traffic jam within the urban paths.
• In this paper, in order to enhance the security level of the DAG method, an improved security framework is proposed by adding a new security layer to the data blocks structures.
• For optimal planning the locations of MCSs, an intelligent priority selection (IPS) algorithm based on mathematical modelling with high accuracy and very low computational burden is developed in this paper. • The unscented transform (UT) method as a key element is used to model the uncertainty of the WTs, PV units as well as EVs within the transportation system.

II. MATHEMATICAL FORMULATION FOR SMART CITY
This section is dedicated to the mathematical formulation of different sections considered in the studied smart city which is illustrated in Fig. 1.
The EVs are capable of transacting the energy with the smart grid aiming to maximize their profits. Equation (1) represents EVs' profit which is made up of three main terms including the V2G (2), V2M energy transactions (3) and fading cost model of the EVs' battery is shown in (4). The performance procedure of the energy transaction of EVs with the smart grid and the metro are expressed in (5)- (13). The charging level of EVs through the recharging lines [12] and the energy consumption of EVs due to the traffic of the urban paths are represented by El i,k and Et i,k in (6) [11].
The metro as an important system of the STS has a financial framework with the smart grid. In this regard, it would be well worth it if we prepare a situation wherein the metro is capable of selling its BE to the smart grid. Moreover, the metro is allowed to supply its demand by buying energy from the smart grid. The profit of selling the metro's BE to the grid and the costs of buying the energy from the smart grid are represented in (14)- (18). The constraint (17) determines the power balance of the metro which needs to be satisfied hourly.
In addition, the constraint (18) defines the metro's BE limits.
The M2V defines the energy exchange between the metro and EVs. Eq. (19) represents the profit of the metro which comes from the fact that EVs charging and discharging would be considered as the profit and cost of the metro, respectively. The profits of the M2V energy transaction are defined by (19)-(21).

3) ENERGY HUB CONSTRAINTS
The constraint (22) limits the input active power of the EH in time duration t. The available energy stored in the electrical storage of EH is presented in (23) which will not allow the charging/discharging process being deviated from the nominal capacity of the energy storage. The constraint (24) indicates the battery stored energy during each time t. The charging and discharging power limits of the battery within its maximum charge rate is represented in (25) and (26), respectively. The constraint (27) will allow the EH's energy storage to be charged or discharged during time t. The electrical and thermal power balance of EH is represented in equations (28) and (29), respectively. Equation (30) models the naturalgas power balance of EH input. The EH's energy conversion constraints is represented in (31)- (33).

D. SMART GRID OBJECTIVE FUNCTION
All the previous energy transactions affect the total cost of the smart city which is represented in (34). It consists of the cost of demand response (DR), the cost of metro's demand supplement and the aimed profits of EVs, M2G and M2V. The constraint (35) defines the power balance of the smart grid with each one of the smart city's segments.

1) OBJECTIVE FUNCTIONS
As it was mentioned before, addressing the interdependency between the proposed sections is one of aims of this paper. Hence, the dependency of smart transportation systemsmart grid (5) and (17), microgrid-smart grid (35), EH-smart grid (35) are expressed in the above. Fig. 2 shows the inputs and outputs of the methodology of the work. The security of data and energy transactions is highly matters in the smart city and needs an ongoing investigation. In order to provide an accurate model of the smart city, the data and energy transactions among different sections of the smart city need to be effectively addressed in the studied model. However, there are some points, which need to be properly pointed out in order to clarify the necessity of data security in the smart city.

III. IMPROVED DAG MODEL
Blockchain is a secure, decentralized and conceptually cyclic structure in which the nodes of the system are connected by ledgers. Recently, such technology has been perceived by the researchers for energy and data transaction within a power network [25]. Such a secure framework was against this backdrop that the data was gathered in a central point and then broadcasted through a communication link to the destination point. High risk of data attack by the external unallowable authorities, is the main drawback of such systems, so-called ''supervisory control and data acquisition (SCADA)''. Accordingly, the researchers proposed that this would be receiving a boost if each one of the nodes of the system, particularly within the power system, try to broadcast the data non centralized through a secured data blocks. In this regard, each one of the nodes/agents (power producers and demands particularly in the power grid) will generate a data block which is signed and encrypted by a hash address (HA) and then broadcasted to the other nodes/agents of the system which is proceeded by a private key as an identification and confirmation tool. The agents are able to access to the data blocks by a public key. However, there are still some issues with such a data encryption method. The accuracy decrement of the HA's calculation within a complex system with many nodes/agents is definitely one issue. The possibility of unauthorized access when the data blocks are chained cyclic is another. To overcome this drawback, the possibility of broadcasting the data based on the concept of directed acyclic graph (DAG) approach is represented by researchers. A directed acyclic graph (or DAG) is a digraph that has no cycles. A rooted tree is a special kind of DAG and a DAG is a special kind of directed graph. In the data transmission case, DAG provides a special way for keeping the security of data transferring among the different agents. In this regard, the DAG structure brings the chance of broadcasting the public data (through the public blockchain) and the transaction data (through the transaction blockchain) among different active nodes/agents of the system, independently [25]. Moreover, the cyclic configuration of the blockchain does no longer remain with the aim of diminishing the cyber-attacks.
By considering such cryptographically source-based cybersecurity configuration, any kind of external unauthorized access is expected to be frustrated during the data broadcast. However, there is still a challenge within the DAG structure which can limit its security. It should be noted that HA was used as a conformation tool for the next data block. With this security mechanism and the availability of transmitting data among different nodes/agents particularly through the transaction blockchain, the possibility of receiving/monitoring and frustrating the data blocks by attackers is still valid. In other words, any unauthorized access might be able to receive and decrypt the data blocks through a long period of data sampling, due to the interdependency of HAs of the consecutive data blocks. To solve this issue, this paper proposes a new approach for the source-based data encryption mechanism in which the data blocks will be sent to the receiver with different HAs. In this method, there are a specific number of HA generation mechanisms considered which are randomly selected for hashing at each data transmission. Therefore, the HAs for the consecutive data blocks are no longer independent and are different for each time slot. In each data block, a randomly selected number as hash index (HI) is assigned to the data block's header and broadcasted to the receiver. Fig. 3 shows the proposed dynamic hashing mechanism process. Indeed, the HI is a sign which represents the functionality of the related hash generator in the source from the perspective of both sender and receiver. In such a case, after decrypting the data block using the security key, the receiver will be able to confirm the data block by determining the HI and imposing its related HA function (similar to the one in the source) to the current HA and the merkle root. After the exertion of the related HA function on both current HA and mekle root, the equality of the resulted data can be used to confirm the data block validation. The proposed data transmission mechanism is implemented by the following steps in Table 2 . Using these steps, the receiver is able to decrypt and accredit the data security status. It should be noted that the HA generator is randomly generated and selected for each data transmission process. Therefore, any false data injection or manipulation will be immediately recognized as soon as the receiver process the data block. The applicability of the proposed method is demonstrated for a test smart city. In this case, the HAs are 32-bit compounded words using the hash function SHA-256, consisting of numbers and letters {0-9, A-F}.

IV. INTELLIGENT PRIORITY SELECTION ALGORITHM
Owing to its nonlinear nature, this paper proposes a new powerful optimization algorithm to allocate the MCSs within the smart city. Owing to its nonlinear nature, this paper proposes a new powerful optimization algorithm to allocate the metro-owned charging stations within the smart city. In this regard, optimization algorithms based on mathematicalmodeling or artificial intelligence are developed and widely used for optimal allocation problems. However, mathematicalmodeling algorithms and artificial intelligence algorithms suffer from long runtime and inappropriate accuracy, respectively. Therefore, this paper proposes a novel and powerful optimization algorithm based on stochastic models to not only increase the accuracy but also reduce the total runtime, effectively. To begin with, in statisticalmodeling, thenumber of combination of N things taken n is defined as follows: The above equation reveals that the resulted sample space consists of a high number of possible outcomes for selecting n samples out of N . In such a model, finding out the solution would be accurate through the brute force search, but due to the high number of sample space, the process is highly time consuming. To overcome such a problem, the proposed algorithm will diminish and restrict the number of sample spaces, intelligently. Be on that, the proposed optimization method is represented by the following steps: Step 1: First, consider the base set P representing the available candidates comprises of the optimal points of the problem. The control variables' matrix is represented through the vector K which is randomly established in the first step. The rest of the candidate points (P − K ) are represented through the set W . Afterwards, all the possible sets resulted from replacing each one of the set W members with the set K members which results in formation of the matrix KT . Each member of the set H w i is calculated by the replacement of the i-th member of the W into the set K which is followed by calculating the optimal value of the objective function among the members of the i-th H W i ,shown by F best It is worth to say that K n shows the n-th element of the K which is replaced by the elements of the W in (37)-(40), shown at the bottom of the page.
According to the objective function value, the members of i-th H W i , are ranked from the best to the worst values as expressed in equation (41), (42). The elements of the matrix W are ranked based on the objective function value. The matrix W j is represented as the set of the aforementioned rearranged W matrix elements (43). Same definition is valid for set K j " (44). Finally in this step, the value of the objective function for W 1 is selected as the best solution (45).
Step 2: In this step, the new matrix KT (KT new r ) is attained. Firstly, the matrix W j is updated according to (46) by using the elements of matrix W j . Since W 1 was chosen as the best solution in the previous iteration, this step is initialized with W 2 as mentioned in (46). The matrix K 1 new j is defined by eliminating the elements of matrices k j and w j from matrix K j (47). All possible sets resulted from replacing each member of W j with member of K 1 new j creates a new member of KT new r (same as equation (40)). The union of sets KT new r and w j is defined as ψ r where r is from 1 to m − j in which parameter j shows the iteration number and m is a constant value which refers to the length of matrix W in the first step according to (48). The objective function value is calculated for each member of ψ r and the best answer of the objective function (F1 Best ) and its related element in matrix ψ r (ψ Best ) are stored as (49) and (50), respectively. In each iteration, the matrix K is updated by ψ Best according to (51).
Step 3: The last member is selected as the best answer among the others in each iteration. Fig. 4 shows the flowchart of the proposed IPS algorithm.

V. UNSCENTED TRANSFORM
In order to model the uncertainties of the parameters, this paper deploys a stochastic framework based on UT to capture this uncertainty effects. UT belongs to the estimation methods with a high capability for providing accurate and reliable expected values in the correlated environments. Initially, UT was proposed for the nonlinear mappings and correlations. But owing to its special features such as low computations, high uncertainty modeling and ability of modeling the correlated uncertainty, it was used as a successful method for stochastic problems. For explaining the UT methods, let us consider the stochastic problem as y = f (X ); in which y shows the output vector, f is the nonlinear function and X is the input uncertain vector. Then a covariance matrix P xx is constructed that the diagonal elements are the variance of the uncertain parameter and the non-diagonal elements are covariance among the corresponding two uncertain parameters. For a problem with n number of uncertain parameters,  UT constructed 2n + 1 deterministic frameworks using estimated sample as follows: Phase 1: Estimate 2n + 1 samples from the input uncertain vector as below: In the above, the term (B) k represents the k th row or column of any matrix B. Also, W 0 shows the weight of the mean value µ.
Phase 2: Compute the weighting factor assigning to each sample point as below: The weighting factors are calculated such that the summation would be unit: Phase 3: Feed 2n + 1 samples to the nonlinear function and calculated the output values: Phase 4: Using the output samples, the mean µ y and covariance P yy of the output variable Y (cost function in our case) would be calculated:

VI. SIMULATION RESULTS
This section is dedicated to the performance analysis of the proposed smart city model. All the simulations are performed in GAMS and MATLAB software and solved on 3.4-GHz windows-based PC with 32 GB of RAM. The proposed smart city consists of a microgrid, STS, smart grid and an EH [17]. Different types of DERs including a PV power plant, a wind park, energy storage and a fuel cell unit are considered. Similar to the study in [26], WTs are considered to be operated based on wind speed. In this paper, EVs are able to charge/discharge in grid charging stations (GCSs) and MCSs. In order to find the optimal location of MCSs, it's assumed that EVs are grouped in different fleets with different technologies, arrival times to the MCSs and available powers. Table 3 represents the EV fleets characteristics [11]. The BE is also executed similar to the one studied in [17]. In this paper, EVs are capable to drive in two different paths with different traffic jams to access to the MCSs [32]. Moreover, the charging/discharging energy transaction prices are extracted from [33,34]. Between two successive metro's arrival times, the EVs are allowed to get charged/discharged, since the storages at the MCSs are not capable of being charged/discharged, simultaneously. The optimal locations of MCSs are allocated among 6 different geographically dispersed candidate points in the city. The technical specifications of the grid and demands are borrowed from [18]. In this section, 5 different case studies are provided aiming to analyze the performance of different parts of the smart city in details: 1) Case I: energy transaction analysis among smart city sectors 2) Case II: energy transaction between EH and electricity grid 3) Case III: analysis of the uncertainties associated with the smart city sectors 4) Case IV: performance analysis of the proposed allocation method of MCSs within the transportation network 5) Case V: analysis of the proposed method for data security in the smart city

A. CASE I: ENERGY TRANSACTION ANALYSIS AMONG SMART CITY SECTORS
As it was mentioned before, the transportation systems consist of EVs and metro as the public transportation system. An effective framework is provided within the transportation network and also between the transportation systems and the smart electricity grid such that both the metro and EVs attempt to maximize their profits through a proper energy transaction schedule. By utilizing BE, the metro is capable of both serving part of its demand and also selling the energy to the grid with the aim of gaining its profit. As it was mentioned before, MCSs need to be optimally allocated within the transportation network. Based on the optimization procedure, the stations 2, 3 and 5 are obtained. Figs. 5-7 illustrate the energy transactions of the EVs-metro (V2M) within the optimal location of the MSCs, the EVs-smart grid (V2G) and the metro-smart grid (M2G). Fig. 8 shows the total energy transaction of the smart grid. The negative values indicate the energy consumption and the positive values indicate the energy injection. At first glance, it can be seen that EVs have tried to purchase energy from the smart grid and sell it to the metro at some specific hours. The metro's BE has been flowed down one-sidedly aiming to maximize the metro's profit. It would well worth it if the performance of the EVs being discussed during hours 7 to 11. After a rapid change in the V2M energy exchange at t = 7, on the average, the V2M energy profile starts increasing until t = 9.

B. CASE II: ENERGY TRANSACTION BETWEEN EH AND ELECTRICITY GRID
In this subsection, the energy transaction between EH and the smart grid is discussed. It is crucial to say that the V2M energy transaction condition heavily lies on the PV output power after t = 16. During these hours, the PV power plant will no longer be able to supply the smart grid demand. This reveals that the electricity grid needs to consume energy    aiming to serve the electric demands of the system. Accordingly, EVs try to inject the power to the smart grid as well as the EH as depicted in Fig. 9. This shows that the CHP power generation is significantly increased which leads to the EH exchange power growth with the aim of serving the EH demand load and injecting the power to the smart grid in order to increase the EH's profit during the proposed timespan.

C. CASE III: ANALYSIS OF THE UNCERTAINTIES ASSOCIATED WITH THE SMART CITY SECTORS
This part is dedicated to the stochastic analysis within the smart city. As mentioned before, some sections of the smart city including the transportation system and microgrid contain much uncertainty due to the wind speed, sun light, traffic jam, accessible time of EVs and so forth which needs to be modelled by UT method [11]. Table 4 compares the stochastic and deterministic analysis of the metro's optimal station, metro's profit and the total cost of the smart city operating which are much more remarkable compared to the other variables of the problem. Table 4 obviously shows that the stochastic analysis has changed the metro' optimal stations. It has also decreased the metro's cost due to the microgrid power generation increment. As can be seen, under the uncertainty circumstance, the optimal locations of the metro are changed from 2, 3, 5 to 5, 4 and 3.   the performance of the optimization algorithm is compared with genetic algorithm (GA), particle swarm optimization (PSO) and firefly algorithm (FA) in terms of the solution accuracy, convergence rate and deviation. Fig. 10 reveal that the proposed algorithm could first find the optimal solution after 6 iterations which is remarkably comparable with GA, PSO and FA with 300, 300 and 500 iterations, respectively. This obviously shows that the proposed algorithm requires significantly much less time to find the solution. Table 5 shows the comparison among the studied optimization algorithms.

E. CASE V: ANALYSIS OF THE PROPOSED METHOD FOR DATA SECURITY IN THE SMART CITY
As it was mentioned before, the data transaction framework within the smart city includes the data transaction within each segment of the smart city using the private blockchain and among all of segments using the transaction blockchain. It was also mentioned that each segment will broadcast its public information to the other segments through the public blockchain. Table 6 represents the private blockchain within the EH at t = 1. It can be seen that the EH and CHP has generated −21.542 kW (negative sign= from grid to EH) and 22.224 kW power at t = 1, respectively. These information would be broadcasted to the private blockchain through a data block surely secured with a specific HI = i in which the i = {1, 2 , . . . ,24}. It is noteworthy to mention that in this case, there are 24 different HA generator mechanisms considered for each hourly data blocks. Tables 7 shows the data block structure broadcasted to the public blockchain at t = 7. This data block contains each one of the smart city's segments  public information. In Table 7 BN = 1 and BN = 2 are the data blocks related to the public information of the EH and microgrid, respectively. Tables 8 represents the transaction data blocks between the smart grid and transportation system at time t = 3. These data blocks will be broadcasted to the transaction blockchain with different HIs.

VII. CONCLUSION
This paper proposed an improved secure data transaction framework based on directed acyclic graph (DAG) approach within the smart city. Also, a comprehensive model of the smart city was developed which incorporates the smart electricity grid, smart transportation systems (STSs), microgrid and energy hub (EH). At the core of attention in this work, the energy transactions among smart city's segments were investigated in details. The proposed model can effectively manage the braking energy (BE) of metro, the energy transaction of EH and microgrid with smart grid, the energy transaction of the EVs with the MCSs and smart grid to increase the total profit at each segment of the smart city and accordingly improve the energy management within the smart city. Based on the five different simulation cases, it was seen that EVs are capable to get charged/discharged by using the metro's BE through the metro-owned charging stations (MCSs) as well as grid charging stations. Also, it was seen that the proposed novel mathematical based optimization algorithm could find the optimal location of MCSs at the shortest time with a very high accuracy. It was shown that the proposed DAG improvement has significantly increased the security of the data transaction among different segments of the smart city by adding a new security layer to the data blocks. Moreover, the results show that the proposed novel algorithm has remarkably reduced the run time and increased the accuracy of the solution compared to the other meta-heuristic algorithms. In addition, the UT method could accurately model the uncertainty parameters associated with the smart city's sectors. In the future, authors will investigate the possibility of distributed control and management of the proposed model in a multi-agent framework. Moreover, the cyber layer will be assessed in a more complex format to provide a security indepth approach.