Smart Control of an Electric Vehicle for Ancillary Service in DC Microgrid

This article presents a two-stage framework for optimal Electric Vehicle (EV) charging/discharging strategy for DC Microgrid (MG) with Distributed Generators (DGs). A multi-objective optimisation task aimed at minimising system losses and EV battery degradation with Vehicle-to-Grid (V2G) peak shaving service has been realised. This coordinated EV integration into the DCMG was formulated as a directed weighted single source shortest path problem that was solved using a modified Dijkstra’s algorithm. The weights of the edges were obtained using primal-dual interior point method. The proposed framework has been experimentally verified using simulations with a test DCMG system with practical IEEE European low voltage test feeder load profiles. Results show realisation of peak demand shaving leveraging on EV discharge with minimal on-board battery degradation as well as reduced system losses. It is also shown that the proposed two-stage framework reduces the battery state of charge (SOC) sample space requirements in the analysis, thus, reducing the computational burden.

Recently, there is increased awareness of the adverse impacts of fossil fuel consumption on environmental sustainability as well as the threats this poses to national economies and their energy security. For instance, it was estimated that in the last decade, light-duty vehicles, sports utility vehicle and motorcycles accounted for approximately 61.8% of oil demand within the aggregate transportation sector [1]. Such fossil fuel consumption leads to emission of greenhouse gases. Therefore, several governments have made commitments to fundamentally transform the transportation sector, moving from gasoline dependent vehicles to an integrated system that powers mobility with electricity [2]. As a result, more than 1. 3

million EVs have been registered in
Europe by June 2018 [3]. Meanwhile, a market penetration of 20% for EVs by 2030 with a focus on achieving emission targets has been predicted in Europe based on more efficient and hybridised Internal Combustion Engine (ICE) vehicles [4], [5]. Despite the rapid progress currently being made in the global EV market, substantial barriers to widespread EV adoption still exist. Overcoming these barriers will require thoughtful investment in charging infrastructure, innovative battery and vehicle development, reliable electric power sector interface and strategic marketing policy [2]. Indeed, the currently under-developed charging infrastructure has slowed down the pace of transport sector electrification. Furthermore, large-scale EV charging would challenge utility networks due to the need for network capacity expansion, asset operation optimisation and software updating to support a range of smart grid applications including Grid-Enabled-Vehicles (GEVs) [6]. Regulatory reforms are also required.
Interestingly, MG has demonstrated to be a feasible option to meet GEV charging demand and mitigate the intermittency and volatility of GEV integration into modern power networks. When connected to distributed networks, GEVs could be considered as controllable loads during charging, called grid-to-vehicle (G2V) and as DGs during discharging, called vehicle-to-grid (V2G) [7]. Similarly, these GEVs can be manipulated as remote Energy Storage Systems (ESSs) to participate in the operation and control of the MG, thereby improving performance and reliability of MG by providing optimal charging and ancillary peak demand shaving service. However, to establish a comprehensive and effective gateway between the network and GEVs, both network power flows and EV integration need innovative strategies to serve conventional customers and GEVs. This is usually tackled as an optimisation problem.
Generally, the main objective in an MG scheduling task is supplying power at minimum cost while ensuring maximum profit to the MG owners [8]. To this end, some studies in the literature have adopted the multi-objective optimisation approach by focusing on operational cost and emission minimisation [9]; energy cost minimisation and reliability consideration as energy loss index [10]; combined heat and power operation cost and energy trading from/to the grid as total MG operation cost [11]; DG units related costs, income and subsidy of Distribution System Operator (DSO) for electricity sales to aggregators as total cost of DSO [12]; and distributed energy resources (DERs) penetration and generation cost for microgrid energy supply [13]. Besides, benefit maximisation and cost minimisation have also been investigated to achieve optimal economic value [14]. According to these previous studies, it can be concluded that operational cost, emission, and reliability are popular concerns in multi-objective optimisation in the context of MGs.
The above described optimisation tasks have been formulated using numerous techniques. Pareto-based approach has been widely used because of the existence of conflicting objectives in such studies. Where Pareto optimal set is obtained, a best compromise solution would be selected with the help of the preferences [9]. Moreover, weighting method is considered the most suitable method for optimisation with aggregate objectives because of its capability of identifying non-inferior solutions that are not obtainable on a non-convex boundary [15]. To solve such problems, several algorithms have been adopted in the literature. Non-dominated sorting genetic algorithm II is one of the most popular algorithm due to its high performance for finding a set of Pareto solutions [16], [17]. Memetic algorithm has also been proposed in Ref. [18] for its separated local and global iterative process which guarantees convergence accuracy. Mixed Integer Linear Programming is another popular technique -it involves the use of some linearisation approach to convert the nonlinear models into linear models [11], [12], [19]. Particle swarm optimisation, a heuristic approach, has also been proposed in the literature [19], [20].
Furthermore, these MGs analysed for EV uptake could be either DC or AC type. Indeed, DCMGs offer significant advantages like fewer conversions, skin-effect free and no requirement for reactive power control, which are more suitable for EV integration and DERs compared with AC network [21]. In such systems, controlled DGs, DERs as well as EV discharging share high proportion of total system generation compared to the feeder from main grid. Therefore, the use of prespecified slack bus is replaced with the concept of distributed slacks [22].
With an Optimal Power Flow (OPF) established based on distributed slack buses, EV integration mechanism is built by aggregating OPF model as a time series optimisation problem. Remembering that the most fundamental task of EV integration is charging, thus, any improvement of system VOLUME 8, 2020 performance leveraging on EV discharge should guarantee EV is charged to satisfied level as expected. However, enabling EV discharging and injecting energy back to the network would require to meet three conditions. Firstly, a bidirectional converter is needed. Secondly, communication with DCMG operator is also necessary. Lastly, on-board precision meter should be available [23]. After satisfying these conditions, EV could be discharged to provide ancillary service to the MG within its operational capacity [24].
Obviously, various types of ancillary services based on optimal V2G strategies have been proposed by other researchers. For instance, enhancement of PV generation provided by optimal V2G by minimising the penalty cost for PV power imbalances between predicted power and actual output with driving patterns was proposed in [25]. Meanwhile, frequency regulation service was presented with the help of a game-theoretic model describing interaction among EVs and aggregators in [26]. A probabilistic multi-objective microgrid planning method was proposed in [17]. Additionally, an optimal charging/discharging coordination between aggregator and its EVs was shown as a convex optimisation problem [27]. Similarly, peak shaving service provision strategy was reported in [28] in order to compensate PV production with an optimal power management performed by Dynamic Programming (DP). The objective was defined as cash flow minimisation where EV battery degradation and operation of PV and EV charging were also taken as constraints [28].
In this study, optimal EV charging/discharging strategy for ancillary service is proposed for a test DCMG. The DCMG scheduling problem consists of OPF formulation aimed at minimising system losses and EV battery degradation, thus, a multi-objective formulation is realised. We considered the battery capacity losses as the cost of peak shaving from the standpoint of EV owners, rather than simply including it as constraint as adopted in [28]. Also, compared with [27], a realistic power flows incorporating droop control has been considered. The multi-objective OPF in this article was formulated as a shortest path problem and solved by modified Dijkstra's method to accomplish EV optimal charging and peak shaving. The weights of the paths were determined by deploying the interior point method. Thus, a two-stage optimisation framework is realised.
Other sections of this article are organised as follows: the mathematical model of OPF for DCMGs with EV integration is presented in Section II. The modified Dijkstra's algorithm and optimisation flowchart are introduced in Section III. The case studies using a test DCMG system is presented in Section IV. Finally, Section V concludes this technical work.

A. PROBLEM FORMULATION 1) DROOP CONTROL IN DC NETWORK
In DC network modelling, buses are generally catalogued into two types according to droop implementation. Non-dispatchable DGs and uncontrollable loads are considered as P buses, dispatchable DGs and controllable loads are considered as DG buses which deploy the droop control.
Considering Figure 1, the droop control constraint for bus i is [22]: where V g,i is the output voltage in bus i, V 0i is the nominal voltage in bus i, and R vi is the virtual resistance of the dispatchable DG unit i. I gi is the output current and can be written as where P G,i is the output power of DG connected in bus i. In steady state mode, the DC network can be considered as purely resistive. Using KCL, the network equations for the two categories of buses (i.e., P and droop buses) can be written as [22]: where In the above expression, I i is the i th bus injection current. G ij and R ij are respectively the conductance and resistance between bus i and j, V i and V j are voltages in bus i and j respectively. With the assumption of a unipolar DCMG, the i th bus injection power P i is stated thus:

2) BATTERIES IN EVs
This study has been performed with passenger EVs where lithium batteries are mostly popular in global market. Thus, the EV was modelled as lithium batteries in this study. Generally, battery pack can be modelled as battery equivalent circuits [29]. However, battery packs in EVs are controlled by battery management system (BMS) and connected to the grid via on-board chargers (OBC). Therefore, EVs are regarded as controllable DGs when discharging and controllable loads when charging. The concepts of State-of-Charge (SOC) and State-of-Health (SOH) are thus included in the model. The SOC describes the level of charge of an electric battery relative to its capacity and it is still the subject of many studies [30]. The specific SOC calculation from [28] is chosen for this study. The expression for SOC is shown below: where SOC t,i is battery SOC at time t in bus i, Cap ref ,t,i is battery capacity of reference at time t in bus i, and Cap t,i is the capacity of battery at time t in bus i. It is logical to develop a recursive expression of battery SOC in terms of EV battery charging/discharging power [28]: where P EV ,t,i is EV charging/discharging power at time t in bus i and it is assumed to be constant in time step t. P EV ,t,i would be positive when charging and negative when discharging. SOC t,i and SOC t− t,i are battery SOC at time t and t − t respectively. The SOH describes the merit of the condition of a battery and can be generally defined below [28] where SOH t,i is the i th bus EV battery State-of-Health at time t and Cap ref ,nom,i is the reference nominal battery capacity which is available from manufacturer's data sheet [31]. Degradation of the performance of batteries during the aging process has been modelled by [32] and it is represented as losses of capacity of reference that are considered linear according to the Depth-of-Discharge (DOD) of batteries [31]. A linear aging coefficient L a is set to capture aging level for different battery technologies and has a value of 3 × 10 −4 for lithium-ion battery [32] and can be expressed recursively as where L a is lithium battery linear aging coefficient. Based on equations (7) -(10), we obtain: where SOH t,i indicates bus i battery State-of-Health at time t.

B. OPF MODEL 1) OBJECTIVE FUNCTIONS
Considering DCMG with EV charging/discharging task from the perspective of MG operators, one of the most significant network performance indicator is system loss. Thus, the OPF formulated for the DCMG seeks to minimise system losses with the help of EV discharging. With EV discharging enabled, EVs together with Electric Vehicle Owners (EVOs) are regarded as a service provider to the network. Thus, the cost of EV discharging needs to be integrated into the OPF framework. For the EV discharging, the on-board battery life degradation is the most obvious cost in this process. Therefore, the battery capacity loss is used in quantifying the battery aging during EV discharging. The system (total line/feeder) loss for the DCMG is stated as: Also, battery capacity loss defined in (9) can be rewritten in terms of EV charging/discharge power as: However, to establish an OPF with two comparable objectives, battery capacity loss Cap loss,t,i and system loss should be modified to the same unit. Thus, both losses would be modified as ''energy loss'' which have been defined below.
In this way, with a weighting factor W , the objective function comprising two objectives can be expressed as: Notice that when the EV is in charging mode or disconnected, the objective function will simply be reduced to system loss.

2) CONSTRAINTS
The equality constraints include the following: Power flows: The power flow mismatch function for the i th bus can be represented as where P g,t,i , P d,t,i and P t,i respectively indicate DG generated power, load power and power injection in bus i at time t. Droop control mismatch can be derived from (1) and expressed as SOC mismatch is realised from (7) and can be rewritten as The terms are as defined in the nomenclature. The total number of equality constraint equations M can be expressed as follows where N is the number of buses in the network, D is the number of dispatchable DG bus, and K is the number of DG VOLUME 8, 2020 bus deployed with GEVs. Newton-Raphson algorithm was deployed to linearise the equality constraints [33]- [35]. State variables have been selected as: The Jacobian can be represented in condensed form as The derivation of sub-matrices in J can be found in Appendix A.
The inequality constraints are as stated next. Bus voltage limits: Bus voltage at all times in DCMG must be maintained within the prescribed limits: DG output power limits: The DGs output powers are constrained by their maximum value: EV charging/discharging power limits: Similar to DGs, EV charging and discharging enforces the constraint: Virtual resistance limits: Virtual resistance in droop control is constrained by converter control method: SOC operation: EV battery SOC is constrained within Degree-of-Discharge (DOD) and below 1: where DOD is generally taken as 0.8. Optimal EV charging: Generally, the EVO expects that full charge will be realised at the end of the integration process. This is thus reflected by the constraint: where t a indicates the time EV is integrated, t m indicates time duration of EV integration into the network, SOC t a indicates battery SOC before integration. P EV ,t,i will be positive when charging and negative when discharging. Note that battery self-discharge is not considered in this study. Peak Shaving: While various ancillary services can be realised from EV discharging (V2G), the main issue with EV charging is that the additional demand from this charging process challenges the available DCMG network capacity. Thus, peak shaving implementation leveraging on EV discharging mechanism is selected and expressed as follows: where S c is load power capping and EV is able to discharge when the total load reaches power capping and adequate battery capacity is available [36].

3) INTERIOR-POINT ALGORITHM
A popular approach in the power systems literature for optimising the objective function (16), subject to constraints (17)-(29) is the interior point method (IPM) [37], [38]. In particular, the problem is cast in a condensed form as shown below.
min f (x) (30) subject to: and h(x) respectively denote the objective function, sets of equality and inequality constraints. x is a vector comprising the control and state variables, The IPM requires series of steps for realising the optimality conditions [37], [38]. This include converting the inequality constraints into equality constraints by using a vector of non-negative slack variables s and introducing the barrier function; thus, subject to: where µ is a positive scalar called barrier parameter. The vectors x and s = [s 1 , . . . , s r ] T are called primal variables. Subsequently, the equality constrained optimisation problem is transformed into an unconstrained formulation by writing the Lagrangian function [37]: (36) where the vectors of Lagrangian multipliers λ and π are dual variables and y = [s, π, λ, x] T . At the optimal solution, these dual variables represent the sensitivity of the cost function to slight adjustments in the constraint equations [37].
Furthermore, the Karush-Kuhn-Tucker optimality conditions is realised by setting the partial derivatives of the Lagrangian function to zero.
where S is a diagonal matrix of slack variables, e = [1, . . . , 1] T , ∇f (x) indicates the gradient of f , J g (x) is the Jacobian of g(x) and J h (x) is the Jacobian of h(x).
The primal dual IPM algorithm is used to solve for variables that satisfy the KKT condition as illustrated in [37].

III. OPTIMAL EV INTEGRATION IMPLEMENTATION FRAMEWORK
A. TWO-STAGE OPTIMISATION FRAMEWORK EV ancillary service, in this case, is a trade-off between the network loss reduction benefit (leveraging on EV discharge) and EV charging task (which is focused on ensuring full EV battery charge before end of the integration time). Indeed, addressing this challenge of optimal EV integration using IPM alone is inadequate.
Firstly, since this study focuses on providing ancillary service to MG operators, battery degradation is not considered during EV charging, which means the number of objectives is different between charging and discharging goals. Implementing IPM while switching objectives will lead to convergence issues. This was experienced during the initial stages of this technical work. Besides, optimal EV integration is also a matter of Time-of-Use which is also not suitable for the classical IPM [6].
It is more appropriate to modify the IPM-OPF by leveraging on a high-level algorithm. Consequently, the shortest path formulation [6], [28] has been deployed. It is pertinent to highlight that while DP can also be used for such optimisation task [28], [39], the significant reduction in number of possible paths (and thus the narrowing of the flexibility of path selection) limits the advantages that would have accrued from the use of DP [40]. Moreover, implementing DP will also necessitate a very large sample space for the battery SOC. Dijkstra's technique, a method based on greedy algorithm, is thus a more attractive approach for this shortest-path problem with limited vertices [41].
Based on the above explanations, a two-stage optimisation framework is proposed in this article. That is, the problem is formulated as a shortest path problem based on modified Dijkstra's algorithm while IPM is employed to determine the weight of the edges/paths of the graph. Detailed logical steps are explained in subsequent sections and a flowchart also provided. Figure 2(a) shows the detailed SOC sample space. In this figure, the considered state is the battery's SOC and it has been discretized for each time period, t (with each value been equals δ SOC ). The battery can assume any of the discretized value δ SOC as long as this is within the constraint boundaries. This problem can be considered as comprising of subproblems [28]. Figure 2(b) shows SOC space with three time-steps. All the possible trajectories from the origin to all allowed states at the end are presented. It is easily understood that if an optimal solution to the problem contains within it optimal solutions to subproblem, this problem exhibits optimal subproblem which in this case becomes optimal power flow at each time step t in either charging or discharging mode [42]. Moreover, all possible trajectories in Figure 2(a) can be simplified as optimal trajectories in charging, discharging and disconnected mode as shown in Figure 2(b). Thus, the total states have been reduced to three indicating charging, discharging and not charging.

C. SHORTEST PATH FORMULATION
The aforementioned optimisation goals could be translated into subproblems as previously highlighted. For each subproblem, OPF solutions including bus voltage, DG/EV power, battery SOC and losses vary with load conditions of the system. The greedy algorithm approach is leveraged to solve these optimisation tasks. Such strategy is achieved by assembling local greedy choices as global optimal solution. In other words, greedy strategy make whatever choice seems best at the moment and then solve the subproblems that remains.
Inspired by greedy method, the problem can be further considered as a weighted single source shortest-path problem. In this shortest-path problem, a weighted, directed graph G = (V , E) is given, with weight function ω : E → R mapping edges to real-value weights. However, since not only the network losses and battery degradation require minimisation but also SOC constraint need to be satisfied, therefore two weight functions are deployed. The SOC weight ω SOC (p) and net loss weight ω loss (p) of path p = v ta , v ta+1 , . . . , v tm are the sum of their constituent edges: where t a is start time, t z is end time, t m is total time step. We define a shortest-path weight δ(t a , t z ) from t a to t z by A shortest path from vertex t a to vertex t z is then defined as any path p with weights Since this EV integration problem has been modelled as a single source shortest problem with Greedy strategy, Dijkstra's algorithm is applied due to its well-known advantages as discussed in [42].
With already represented weights in shortest path problem, vertices require further explanation and representation. Given a directed graph G = (V , E), we maintain for each vertex v ∈ V a predecessor v.π that is either another vertex or nil. When attributes of π are set, the chain of predecessors originating at a vertex v runs backwards along a shortest path from s to v. However, the value of π may not indicate the shortest paths. The predecessor subgraph G π = (V π , E π ) induced by the π value should draw more attention. V π here is designed to be a set of vertices of G with non-nil predecessors and the sources s. The edges set E π is the set of edges induced by V π which is shown below [42]: However, δ SOC (u, v) can be negative when EV is discharging, which implies negative weight edges. Since δ loss (t a , t z ) is the weight to be optimised, relaxation will focus on ω loss (v) measurement. It is known that ω loss (v) will find minimum value during optimal discharging with negative ω SOC (v). In this way, vertices would be relaxed into discharging mode at each step until SOC reach the lower bound. Thus, δ SOC (u, v) requires further modification before relaxation in Dijkstra's algorithm. Since OPF solution to each state is predictable, given that: and it is possible to design a novel procedure fitting implementation of Dijkstra's algorithm based on OPF characteristics. Hence, an ultimate procedure is introduced to enable negative edges in Dijkstra's algorithm and satisfy ω SOC constraint, which is implemented after initialisation. In the ultimate procedure, vertices will be enforced in charging state so that ω SOC (p) + SOC a would reach 1 and net loss weight ω loss (p) achieve its maximum. Then, relaxation procedure can be executed based on that.
With the implementation of ultimate procedure, Dijkstra's algorithm is able to solve single-source shortest-path problem for the case in which negative edges exist. Dijkstra's algorithm maintains a set S of vertices whose final shortest-path from last step is determined. The algorithm repeatedly selects the vertex u ∈ V − S with the minimum shortest-path estimate, adding u to S and relaxing the other edges but u. In this case, since vertices are already attributes of charging state whose ω loss (u) are the highest compared to weights in other states, the relaxation will based on the maximum net loss decrease from charging state to others in the same step. Then a min-priority queue Q of vertices keyed by their d value is maintained by the variant that Q = V − S.
Dijkstra's algorithm firstly initialises π and d value, and attributes ultimate value for π and d. After that, S is set as empty, then the min-priority queue Q contains all the other vertices in V . Since δ SOC (s, u) is maximum value at that time, the variant is true. Each time through the while loop a vertex is extracted from Q and added to S, thereby maintaining the invariant. If vertex u has the largest loss weight decrease in Q, then estimate d and predecessor π will be updated, until SOC ta + δ SOC (s, u) is less than 1. In this way, net weight is minimised with SOC constraint satisfied. The flowchart for the proposed 2-stage optimisation framework is shown in Figure 3.

IV. CASE STUDY A. TEST SYSTEM AND PARAMETERS 1) TEST SYSTEM
The test system shown in Figure 4 was used to verify the effectiveness of the proposed technique. In this network, bus 1, 2 and 3 were considered as dispatchable buses controlled by droop controller through virtual resistance. Buses 4, 5 and 6 were considered as time-series power (load) buses with IEEE European Low Voltage Test Feeder v2 load profiles having total duration of 24 hours and time interval of 10 minutes. These load profiles are identified as Loads 1, 2, 3 in this article and are shown in later sections.

2) PARAMETERS
Initial battery SOC was set to 30% i.e. at the start of EV integration and desired SOC after the entire EV charging was limited to 100%. Battery discharging was enabled after SOC reached 50% bearing in mind the battery health, protection and minimal travel demand. Maximum EV charging/discharging power was set to 4kW (battery capacity was set to 3.5kWh). The virtual resistance on droop buses varied between 0.2-ohms and 5.0-ohms. Power capping for peak shaving service is 0.3p.u. The DGs are considered as combined PV and BESS, like the arrangement in the microgrid supplying power to the company complex where the first author had worked in China prior to his commencement of PhD study in the UK. For the test network, two DGs were deployed with rating of 6.5kW and 7.0kW.

B. CASES
In order to investigate the performance of the proposed method, four EV integrating cases and two load scenarios were analysed for the test system.

1) CASE 0 -BASE CASE
In this case, three load profiles were deployed at buses 4, 5 and 6 but no generator or load was connected to bus 3. Two DGs with droop control using virtual resistance were integrated into the test network at nodes 1 and 2 for this case. Since EV integration was not involved in case 0, the resulting OPF is a single objective optimisation aimed at minimising system losses.

2) CASE 1 -CONSTANT POWER EV CHARGING
Using the same network configuration explained for case 0, EV charging unit with constant power was added to bus 3 for this case.

3) CASE 2 -OPTIMAL EV CHARGING
In addition to the state variables of bus voltages and DG output powers, EV charging power was modified to a controllable load at bus 3. Furthermore, virtual resistances for the 2 DGs and the EV implementing droop control were integrated. Modified Dijkstra's Algorithm was employed to implement the time-series optimal charging.

4) CASE 3 -OPTIMAL EV CHARGING/DISCHARGING
System configuration in case 3 is identical to that of case 2: two DGs, the EV and three Loads. EV discharging was however enabled by the two-stage optimisation algorithm after battery was charged to more than 50% SOC.

C. SCENARIOS
In order to investigate the effectiveness of the proposed method for different scenarios, load profiles were catalogued into commercial and residential load scenarios. The load profile data set was selected for 24 hours; however, scenarios considering weekday and seasonal features were not included in this study.

1) COMMERCIAL SCENARIO
Loads in commercial scenario simulate electricity consumption in commercial buildings like office buildings, hospitals, and university campus. The demand peak time in commercial scenario occurred during the day.

2) RESIDENTIAL SCENARIO
Residential scenario presents electricity consumption in a residential district like apartments and flats in urban district. The peak time of residential property occurred in the evening and the morning (exact time differ for each of the three load profiles). The load profiles for both scenarios are plotted in later sessions in this article.

1) CASE 0
Bus output power in case 0 with commercial loads is shown in Figure 5(a) where generated powers are plotted in the positive vertical axis and loads are shown in the negative VOLUME 8, 2020 vertical axis. Clearly, from the plot, the DG output powers increase with increasing load requirement.
Results in residential scenario have also been shown in Figure 5(b). The trend is similar. However, unlike loads in commercial scenario, residential loads peaked in the evening as well as in the morning.

2) CASE 1
As previously highlighted, EV charging was introduced to the system for this case, specifically at bus 3. Results are shown in Figure 6(a). When charged with constant power like in this case, EVs are considered as an uncontrollable load. The charging process started from 09:00 and ended at 16:10; thereby mirroring the daily behaviour of EV owners (EVOs) in commercial properties. The charging power was ramped up to 3.5kW at 09:10 and kept constant until 15:20 when EV SOC reached 93.4%. Charging power was then reduced for battery protection until full charge was realised at 16:10. For residential scenario, the EV was considered available overnight i.e. from 20:00 to 08:00. Constant power charging was executed from 20:10 until 02:20. The power requirements from the DGs due to the additional EV charging demand exceeded those of case 0 as shown in the plots.

3) CASE 2
Result in commercial scenario can be seen in Figure 7(a). The time slot for EV charging is the same as case 1. For load peaks at 11:40, 12:50 and 17:40, the charging power was reduced to avoid additional system stress. Therefore, this resulted to longer charging time (10.5 hours) which is 3 hours 20 minutes longer than that of case 1. Figure 7(b) shows case 2 result in residential scenario. Charging process started at 20:00 and terminated at 05:30.

4) CASE 3
Result of case 3 in commercial scenario is shown in Figure 8(a). EV discharging was enabled in this case when battery SOC reached 50% and the EV behaviour was then modified as a DG to shave load peaks as seen in the plot. During EV discharging, both system losses and battery capacity losses were optimised. Figure 8(a) shows that EV discharged at 11:40, 12:50 and 17:40; interestingly, these times correspond with peak demand. Figure 8(b) indicates results of case 3 in residential scenario. During load peak at 20:50 and 22:20, EV charging was paused to reduce system losses and ease network burden. Like commercial scenario, beyond 50% SOC, EV discharging was enabled. Figure 8(b) shows the EV discharged at 23:30, 23:50, 07:20 and 07:50.
Discussions on the Test Cases: The net demand comparison for both scenarios has been shown in Figure 9. Demand profiles for each case consists of local power demand and the additional EV charging demand except case 0 where EV was not considered. From the figure, it is obvious that case 1 (uncoordinated EV charging) resulted in the highest peak net demand. This is true for both commercial and residential scenarios. With smart charging (case 2), the peak net demand was reduced. A further reduction in peak net demand was observed in case 3 (smart control (charge/discharge) strategy). System loss comparison in the commercial and residential scenarios are also shown in Figure 10. The plots show that case 1 had the highest system losses for the residential scenario which is expected given that it presented the highest peak net demand in the test network. On the other hand, it is interesting to observe that case 2 presented a slightly higher aggregated power losses (over the 24-hour horizon) than case 1 due to the EV taking longer to charge for case 2 than case 1. Generally, the high demand and increased system losses negatively challenge DCMG operations and thus, deteriorate the system performance.
In all scenarios, case 3 resulted in the lowest system losses (excluding the base case where there was no EV in the DCMG). In other words, with the smart EV control/discharge as demonstrated in case 3, the network was relieved of current flows requirement since loads were met locally. This aligns with findings from the field trials involving the coordinated control of PVs and energy storage units reported by the same authors in another publication [34].
Furthermore, Figure 11 shows the comparison of DG capacity requirement in different cases. As evident from the VOLUME 8, 2020 plot in Figure 11, from case 0 to case 1, the DG power supply requirements for both scenarios increased. This is interlinked with the increased demand; thus, this would necessitate network reinforcement/expansion and further investment costs. From case 1 to 2 and to 3, the DG capacities were reduced; hence, indicating that optimal operation of EV integration can effectively reduce the power supply requirements from the DGs. However, the capacity of DG2 in residential scenario remained mostly the same (except for case 1) because the load peaks happened outside of smart EV discharge time slot.
From these findings, it is therefore obvious that for MG operators as well as DNOs, the advantages of enabling EV discharge is significant. Firstly, EV discharging is able to reduce output power requirement from network generators during heavy load conditions since such demands are met locally. This enhances system security and defers the need for expansion investments. Moreover, system losses are further reduced when more DGs operate as distributed slack buses and participate in power sharing unlike the traditional single slack approach.  It is also important to highlight that some drawbacks exist. As realised, it will take longer time to attain full charge i.e. if the EV is discharged during the integration period; this implies battery capacity losses (battery degradation). Nevertheless, with our proposed framework, a wise trade-off between EV charging task and peak shaving service is achievable as shown in this technical work. Hence, the proposed two-stage optimisation framework finds useful applications in modern DCMGs as well as encouraging the fast-tracking of EV uptakes.

V. CONCLUSION AND FUTURE WORK
In this article, an EV charging/discharging strategy based on two-stage optimisation framework (that combines modified Dijkstra's algorithm and IPM) which minimises DCMG network losses and EV battery degradation has been presented. The objective was to make a trade-off between performing peak shaving and EV charging in the same time interval. The particularity of this technical work lies in the consideration of battery degradation as optimisation objective simultaneously with network losses and the solution implementation using a novel two-stage framework for the time-series multiobjective task. Simulations in commercial and residential load scenarios have been performed and compared. For a 24-hour simulation, 4.4% of system losses were reduced and 17.8% of DG capacity was saved by leveraging on the proposed framework i.e. for the commercial scenario. Similarly, 13.9% of system losses were reduced and 27.0% of DG capacity saved for residential scenario. Further investigation that takes into account large-scale network and significant EV uptake is on course.