1 Introduction

According to statistical reports, thermal power plants have long played a critical role in supplying electricity using fossil fuels. However, due to the high investment and operation costs of these power plants and their destructive effects on the environment, the use of renewable energy sources (RESs) such as wind turbines (WTs) and photovoltaics (PVs) in power networks has been considered as an effective alternative to traditional power plants [1]. The presence of RESs as clean and high-efficiency power plants has broadened new horizons in cheap electricity generation. These RESs can form microgrids (MG) combined with flexible loads and storage devices [2, 3]. MGs can be used in grid-connected and island modes; therefore, control and management systems must be designed for each mode [4]. Each distributed generation can play an influential role in the optimal operation and high efficiency of both MGs and the main grid. MG management's principal aim is to calculate the optimal production of each RES to minimise operating costs and maximise the participation of resources in the electricity market [5]. However, one of the significant problems in MGs' optimal operation is the intermittent output of RESs due to weather condition changes [6]. Therefore, considering the uncertainties in the output of RESs and the uncertainties in the load is one of the most important issues that should be considered in MGs' optimal scheduling.

So far, various articles on the optimal scheduling of MGs are published. In [7], MGs' optimal operation is evaluated by considering their resources' erratic behaviour. In this article, MGs' optimal scheduling has been done by considering the resources' uncertainties and reducing costs and losses. Liu et al. [8] suggest an optimal MG operation consists of RESs, storages and controllable distributed generations (DGs) and load in a resurrected power system. The main purpose of this article is to control the Generation and consumption of DGs to organise the import and export of energy in the MG to minimise costs.

Niknam et al. [9] propose optimal management for an MG comprise several DGs. The objective function of this study is to minimise losses, costs and voltage distortions. In [10], MGs' day-ahead scheduling to maximise distribution companies' profit and minimise MGs' operating costs has been evaluated. Optimal scheduling is also presented for a grid-connected MG in [11]. The proposed model is implemented based on cost and benefit to improve the efficiency of the MG. In [12], optimising MGs' performance to maximise MGs' profit in the uncertain electricity energy market has been investigated. In this paper, MGs' role in reducing electricity prices, increasing reliability and reducing operating costs is investigated. Optimal scheduling for the MG, including RESs and hybrid vehicles, is given in [13, 14]. The uncertainties in this paper are modelled using the Monte Carlo simulations. In [15, 16], to maximise the profit and enhancement in ancillary services in the energy market, an arrangement among various sources including pumped storage hydro-power plant, PV and WT is made. The uncertainties in the output of sources and the price are also modelled.

According to the reviewed papers, although much research has been done on MGs' optimal scheduling, one of the main disadvantages of the aforementioned work is the lack of PHEVs. Given the recent developments in PHEVs, it is expected that they will play a significant role in the future of MGs [17, 18]. In [18], the performance of EVs and RESs in the power system is investigated. The impact of PEVs on the power system on reducing environmental pollution has been assessed in [19, 20]. Due to the increasing influence of PEVs in power networks, the negative effects of uncertain behaviour of them are evaluated in [21]. According to the statistics, it is expected that PEVs can reach 20% of the US car market by 2030 [22]. Besides, the charging and discharging capability of PEVs make them effective to exchange power with the main grid as ancillary services. PEVs can also play the role of batteries to deal with the intermittent nature of the RESs and provide more power quality and reliability for the power system. MGs can also use PEVs as the storage to provide a stable and secure power when the output of RESs are fluctuated [23]. PEVs are also capable of participating in the market and provide ancillary service with arbitrage [24].

To deal with MGs' optimal operation with RESs and PHEVs, a robust optimisation is used for minimising the operational cost while considering the risk management [25]. Day-ahead scheduling for an MG consisting of PHEVs, storage devices and RESs using symbiotic organism search (SOS) algorithm is suggested in [13]. This optimisation aims to minimise local units' operational cost and reduce the cost of interaction between the main grid. To minimise energy costs not supplied, reliability and power supply for loads and PHEVs, an optimal operation for a MG using the bat algorithm is given in [26]. The optimal operation of a MG containing vehicle to grid (V2G) technology is solved to minimise the operational cost in [27]. In [28, 29], the V2G is used to enhance an islanded MG's performance under unbalanced conditions. This paper aims to meet market participation with risks, while it improves the economic and environmental advantages. In [30], the sitting and sizing of V2G in a MG are investigated.

One of the main challenges of PHEVs is the optimal time management for charging. If the optimal charging time is not achieved, the MG cannot supply the charging demand, and the cost of operation is increased. Therefore, this study is focused on the charging influence of PHEVs on the MG operation. To achieve this goal, three various charging patterns consisting of uncontrolled, controlled and smart charging patterns are taken into account. The paper suggests an effective methodology to shift the charging demand of PHEVs from peak times to light loads. The increasing integration of PHEVs in the MG can decrease the MG cost. Due to PHEVs' stochastic behaviour, it is needed to investigate the effect of high penetration of them into the MGs. The probability density functions (PDF) is used for modelling uncertain parameters. Monte Carlo simulation (MCS) is also used to model the uncertainties of PHEVs in the MGs. To address the nonlinear optimisation problem, the MHS algorithm is used.

The paper's organisation is as follows: Three different plans for charging PHEVs are given in Sect. 2. Section 3 contains the mathematical representation of the problem. The optimisation algorithm is suggested in Sect. 4, and the modification approach and the way it applies are thoroughly described as well. A comprehensive comparison is made in Sect. 5 between the MHS algorithm and other algorithms. Furthermore, the impacts of PHEVs integration are investigated in this section. Lastly, Sect. 6 includes the conclusions of the paper.

2 Charging behaviour of PHEVS

The load demand in PHEVs relies on various aspects, including the distance, departure and arrival times, battery capacity, the state of charge (SOC), the present charge level and the charging algorithm. In this part, uncoordinated charging (UC), coordinated charging (CC) and smart charging (SC) patterns are evaluated.

2.1 Uncoordinated Charging

In this section, it is assumed that PHEVs leave morning and return home in the afternoon. So, most PHEVs start charging when they get home, around 6:00 P.M. The PDF with a uniformly distributed feature can be presented as [22]:

$$f(t_{{{\text{start}}}} ) = \frac{1}{{b - \alpha }}\,\,\,\,\,\,\,\alpha \le t_{{{\text{start}}}} \le b\,\,\,\,\alpha = 18,\,\,b = 19\,\,\,\,\,\,\,\,$$
(1)

2.2 Coordinated Charging

Light load conditions are considered for charging of PHEVs in this pattern. In other words, the charging process is done when the energy price is low, after 9.00 P.M. The PDF for this part can be given as:

$$f(t_{{{\text{start}}}} ) = \frac{1}{{b - \alpha }}\,\,\,\,\,\,\,\alpha \le t_{{{\text{start}}}} \le b\,\,\,\,\alpha = 21,\,\,b = 24\,\,\,\,\,\,\,$$
(2)

2.3 Smart Charging

In this part, the charging process is done when these exist a surplus in the power generation where the energy tariff is low. It is accomplished based on interest between PHEV owners and the power grid. The PDF of this pattern is:

$$f(t_{{{\text{start}}}} ) = \frac{1}{{\sigma \sqrt {2\pi } }}e^{{\left( { - \frac{{ - 1}}{2}\left( {\frac{{t_{{{\text{start}}}} - \mu }}{\sigma }} \right)^{2} } \right)}} \,\,\,\,\,\,\mu = 1\,\,,\,\,\,\,\sigma = 3$$
(3)

The PDF of the daily driven miles can be given as:

$$f(m) = \frac{1}{{m\sigma _{m} \sqrt {2\pi } }}e^{{\frac{{ - \left( {\ln \left( m \right) - \mu _{m} } \right)^{2} }}{{2\sigma m^{2} }}}} \,\,\,\,\,\,\,\,m \succ 0$$
(4)

The ratio of energy in a battery to the capacity is called the SoC of a PHEV. It is calculated based on the distance and the vehicle AER (the maximum distance travelled in the electric mode). The SOC can be given as:

$${\text{SoC}} = \left\{ \begin{gathered} 0\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\;\;\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,m \succ {\text{AER}} \hfill \\ \frac{{{\text{AER}} - m}}{{{\text{AER}}}} \times 100\% \,\,\,\,\,\,m \le {\text{AER}} \hfill \\ \end{gathered} \right.$$
(5)

The initial SOC, final SOC and vehicle's battery capacity play a key role in the needed energy for charging PHEVs. The required energy for charging PHEVs is received from the main grid based on the desired charging algorithm as:

$$t_{D} = \frac{{C_{{{\text{bat}}}} \times (1 - {\text{SOC}}) \times {\text{Max}}_{{{\text{DOD}}}} }}{{\eta \times P}}$$
(6)

According to the internal power management scheme of PHEVs, the MaxDOD is calculated. P denotes the charging rate determined by the type of charger. P and η form a limit for the PHEV charging period, while η is the charger efficiency. The rates of various types of chargers are represented in Table 1 [25, 27].

Table 1 Different states of PHEV charging

3 Formulating of problem

Here, the objective function and the considered constraints are given to achieve optimal operation for the MG.

3.1 Cost of energy

The MG is responsible for meeting the loads in all conditions using the DGs and storages or the main grid. Firstly, the MG should try to supply loads using their own DGs and storages at the minimum cost. However, if the inside sources cannot meet the loads, it is necessary to buy power from the utility grid. However, when the electricity tariff is low, it is more profitable for the MG to buy power from the utility grid and keep its sources at minimum capacity. It is also more economical for storage devices to store energy when the tariff is low and utilise it at peak load conditions. To achieve an ecumenical operation with the minimum cost, MG central control (MGCC) is in charge of optimising the following cost function [16, 31, 32]:

$${\text{Min}}\,f(x) = \sum\limits_{{t = 1}}^{T} {\text{Cos} t^{t} } = \sum\limits_{{t = 1}}^{T} {\left\{ {\sum\limits_{{i = 1}}^{{N_{g} }} {\left[ {u_{i} (t)p_{{Gi}} (t)B_{{Gi}} (t) + S_{{Gi}} \left| {u_{i} (t) - u_{i} (t - 1)} \right|} \right] + \sum\limits_{{j = 1}}^{{N_{s} }} {\left[ \begin{gathered} u_{j} (t)p_{{sj}} (t)B_{{sj}} (t) + \hfill \\ S_{{sj}} \left| {u_{j} (t) - u_{j} (t - 1)} \right| + P_{{{\text{Grid}}}} (t)B_{{{\text{Grid}}}} (t) \hfill \\ \end{gathered} \right]} } } \right\}}$$
(7)

The ON/OFF condition of DGs are:

$$\begin{aligned} & X = \left[ {P_{g} ,U_{g} } \right]_{{1 \times 2nT}} \,\,\,\,\, \hfill \\ & P_{g} = \left[ {P_{G} ,P_{s} } \right] \hfill \\ & \,n = N_{g} + N_{s} + 1 \hfill \\ \end{aligned}$$
(8)

where

$$\begin{aligned} & P_{G} = \left[ {P_{{G,1}} ,P_{{G,2}} ,...,P_{{G,N_{g} }} } \right] \hfill \\ & P_{{G,i}} = \left[ {P_{{G,i}} (1),P_{{G,i}} (2),...,P_{{G,i}} (T)} \right]\,\,\,\,\,\,\,\,\,\,\,\,\,i = 1,2,...,N_{g} + 1 \hfill \\ & P_{s} = \left[ {P_{{s,1}} ,P_{{s,2}} ,...,Ps,N_{s} } \right] \hfill \\ & P_{{S,i}} = \left[ {P_{{S,j}} (1),P_{{S,j}} (2),...,P_{{S,j}} (T)} \right]\,\,\,\,\,\,\,\,\,\,\,\,j = 1,2,...,N_{s} \hfill \\ \end{aligned}$$
(9)

3.2 Limitations

3.2.1 Generation and consumption balance

The MGCC is responsible for balancing the Generation and consumption in the MG. It should be noted that PHEV charging demand is considered as variable loads [6, 7].

$$\begin{aligned}\sum\limits_{{i = 1}}^{{N_{g} }} {P_{{G,i}} (t) + } \sum\limits_{{j = 1}}^{{N_{s} }} {P_{{s,j}} (t) + } \sum\limits_{{i = 1}}^{{N_{g} }} {P_{{{\text{Grid}}}} (t) = \sum\limits_{{k = 1}}^{{N_{L} }} {P_{{L,k}} (t) } }\\+ \sum\limits_{{l = 1}}^{{N_{{{\text{PHEV}}}} }} {P_{{{\text{PHEV}},l}} (t)} \end{aligned}$$
(10)

3.2.2 Generation capacity

The generation capacity for each DG is limited by [16]:

$$\begin{aligned} & P_{{Gi,\min }} (t) \le P_{{Gi}} (t) \le P_{{Gi,\max }} (t) \hfill \\ & P_{{{\text{grid}},\min }} (t) \le P_{{{\text{Grid}}}} (t) \le P_{{{\text{grid}},\max }} (t) \hfill \\ \end{aligned}$$
(11)

3.2.3 Battery charging/discharging limits

Batteries can inject power at time t into the MG based on the amount of power stored in the last hours. The charging or discharging process of batteries are based on the specific rates as [6]:

$$\begin{aligned} & W_{{{\text{ess}}}} (t) = W_{{{\text{ess}}}} \left( {t - 1} \right) + \eta _{{{\text{charge}}}} P_{{s,{\text{charge}}}} \Delta t \\&\qquad~~~~- \frac{1}{{\eta _{{{\text{discharge}}}} }}P_{{s,{\text{discharge}}}} \Delta t \hfill \\ & \left\{ \begin{aligned} &W_{{{\text{ess}},\min }} \le W_{{{\text{ess}}}} (t) \le W_{{{\text{ess}},\max }} \hfill \\ & P_{{s,{\text{charge}}}} (t) \le P_{{{\text{charge}},\max }} \hfill \\ &P_{{s,{\text{discharge}}}} (t) \le P_{{{\text{discharge}},\max }} \hfill \\ \end{aligned} \right. \hfill \\ \end{aligned}$$
(12)

3.3 Stochastic framework

To model the uncertain considerations in the MG's optimal scheduling, it is required to select a proper method. The uncertain parameters include the output power of WT and PV system, fluctuations in the loads, electricity price and PHEV charging demand. So far, many stochastic approaches have been suggested for modelling the uncertainties in the problem. Among various methods, MCS received considerable attention in recent years. It is implemented based on generating in which each scenario denotes a probable position with inaccuracies. The parameters of the MCS are PDF for forecast errors.

4 MHS algorithm

The harmony search (HS) is a nature-inspired algorithm that mimics music players' improvisation and is recommended by Geem and Kim [31, 32]. The harmony in music is similar to the optimisation solutions, and the musician's improvisations are like the local and global search patterns. In this algorithm, a stochastic random search is used in preference to a gradient search. It applies harmony memory (HM) by considering the rate and pitch adjustment rate to find solutions in the search space. In this scheme, to determine the optimal value of the objective function, the aesthetic estimation concept to find the perfect state of harmony is applied. The advantages of this algorithm include a simple concept, a low number of parameters and easy implementation. This algorithm can deal with several optimisation problems properly.

The HS algorithm optimisation process can be described as:

  1. 1.

    Initialising the optimisation problem and algorithm parameters.

  2. 2.

    Initialising the HM.

  3. 3.

    Improvising the novel HM.

  4. 4.

    Updating the HM.

  5. 5.

    Examination for stopping criteria. If not, repeat step 3 to 4.

Further details on the HS algorithm are provided in [29,30,31]. The flow chart of the recommended method is shown in Fig. 1.

Fig. 1
figure 1

Flow chart of the proposed method

The number of population in this algorithm is similar to other evolutionary algorithms. This algorithm's matrix is filled with a large number of created random values between the minimum and maximum amount.

In this part, HMCR and HM are applied to generate a novel solution \(X_{i}^{{{\text{new}}}}\) as:

$$\begin{aligned} & X_{i}^{{{\text{new}}}} = \left[ {x_{{i,1}}^{{{\text{new}}}} ,...,x_{{i,j}}^{{{\text{new}}}} ,...,x_{{i,d}}^{{{\text{new}}}} } \right] \hfill \\ & x_{{i,j}}^{{{\text{new}}}} = \left\{ \begin{aligned} & x_{{i,j}}^{{HM}} \quad\quad{\text{for}}\quad{\text{rand}} <{\text{HMCR}} \hfill \\ & x_{{i,j}}^{{{\text{rand}}}} \quad{\text{for}}\quad{\text{else}} \hfill \\ \end{aligned} \right\} \hfill \\ & X_{i}^{{HM}} = \left[ {x_{{i,1}}^{{HM}} ,...,x_{{i,j}}^{{HM}} ,...,x_{{i,d}}^{{HM}} } \right] \hfill \\ &X_{i}^{{{\text{rand}}}} = \left[ {x_{{i,1}}^{{{\text{rand}}}} ,...,x_{{i,j}}^{{{\text{rand}}}} ,...,x_{{i,d}}^{{{\text{rand}}}} } \right] \hfill \\ \end{aligned}$$
(13)

A random single is created within the allowable values as \(x_{{i,j}}^{{{\text{rand}}}}\). The algorithm with a higher HMCR chooses novel components of the HM. Then, in order to pitch adjustment, the solutions obtained from the previous step must be evaluated. This operation utilises the pitch adjusting rate (PAR) parameter. The operation is done by PAR using the parameter as:

$$x_{{i,j}}^{{{\text{new}}}} = \left\{ \begin{aligned} & x_{{i,j}}^{{{\text{rand}}}} \pm {\text{rand}} \times bw\quad{\text{for}}\quad{\text{rand}} < {\text{PAR}} \hfill \\ & x_{{i,j}}^{{{\text{rand}}}} \quad{\text{for}}\quad{\text{else}} \hfill \\ \end{aligned} \right.$$
(14)

where bw is the arbitrary distance bandwidth [31].

$$\begin{aligned} & bw(Iter) = bw_{{\max }} \exp (c \times Iter) \hfill \\ & c = \frac{{Ln\left( {\frac{{bw_{{\min }} }}{{bw_{{\max }} }}} \right)}}{{Iter^{{\max }} }} \hfill \\ \end{aligned}$$
(15)

4.1 Modified algorithm

In this part, three novel modified methods have been proposed for the HS algorithm. The first modified technique employs a mathematical formulation to create a local search around each solution. With this method, population diversity can be efficiently improved. The suggested MHS can cope with any nonlinear constraint without simplifying or requiring derivatives in problem formulation compared to conventional approaches.

To achieve this aim, the mean value of the HM is determined MHM, at first. Afterwards, the whole HM is moved towards the best player as:

$$\begin{aligned} & X_{i}^{{{\text{new}}}} = X_{i}^{{{\text{old}}}} + T_{F} \left( {X_{{{\text{best}}}} - M_{{HM}} } \right) \hfill \\ & X_{{{\text{best}}}} = \left[ {x_{{{\text{best}},1}} ,x_{{{\text{best}},2}} ,...,x_{{{\text{best}},d}} } \right] \hfill \\ \end{aligned}$$
(16)

If the novel result is superior to the previous one, it must be replaced. To improve the diversity of the results, the second modification technique is employed. This amendment decreases the probability of achieving local optima. In this regard, three solutions, hm1, hm2 and hm3, are selected from the HM matrix as i ≠ hm3 ≠ hm2 ≠ hm1. i stands for the ith solution in the HM (Xi). The enhanced solution can be presented as:

$$X_{\text{mut}} = X_{{hm1}}^{{HM}} + \rho _{1} \times \left( {X_{{hm2}}^{{HM}} - X_{{hm3}}^{{HM}} } \right)$$
(17)

Assuming the best solution is Xbest. Three novel solutions \(X_{1}^{{{\text{new}}}} ,X_{2}^{{{\text{new}}}} ,X_{3}^{{{\text{new}}}}\) are created as follows. The best solution among \(X_{1}^{\text{new}} ,\,X_{2}^{\text{new}} ,\,X_{3}^{\text{new}}\, \& \,X_{i}\) replaces Xi.

$$\begin{aligned} & x_{{1,j}}^{{{\text{new}}}} = \left\{ \begin{aligned} & x_{{{\text{mut}},j}} \quad{\text{if}}\,\,\,\rho _{2} \le \rho _{3} \hfill \\ & x_{{{\text{best}},j}} \quad {\text{else}} \hfill \\ \end{aligned} \right. \hfill \\ & x_{{2,j}}^{{{\text{new}}}} = \left\{ \begin{aligned} &x_{{{\text{mut}},j}} \quad{\text{if}}\,\,\,\rho _{3} \le \rho _{4} \hfill \\ & x_{j} \quad{\text{else}} \hfill \\ \end{aligned} \right. \hfill \\ & x_{3}^{{{\text{new}}}} = \rho _{5} \times X_{{{\text{best}}}} + \rho _{6} \times \left( {X_{{{\text{best}}}} - HM\left( {n_{{{\text{rand}}}} } \right)} \right) \hfill \\ \end{aligned}$$
(18)

5 Results of simulation

In this part, energy management performance in MG with several RESs and storage devices is investigated. In Fig. 2, the structure of the grid-connected MG is depicted. To determine the optimal power generation for each source, a 24 h analysis is performed. Table 2 shows the constraints of DGs and the bidding strategy in cents of Euro (€ct) per kilo-Watt hour (kWh). The MG can import or export power with the main grid based on various conditions. To investigate the performance of the MHS with the presence of PHEVs in this MG, two case studies are considered.

Fig. 2
figure 2

MG structure

Table 2 Costs and limitations of DGs [6, 7]

5.1 First Scenario

In this part, the simulation is done deterministically without considering PHEVs, and the outcomes of the suggested algorithm are compared with other popular approaches. In this stage, the battery is considered charged infinitely at the starting point. Besides, all sources of MG are in service for 24 h. The forecasted outputs powers of WT's and PV's are given in Fig. 3. The real-time electricity tariff and the load demand of the MG are depicted in Fig. 4, respectively. All DGs operated in the MG operate at unity power factor. According to Fig. 5, when the energy tariff is low on the utility side, the battery starting to charge while other sources generate in minimum possible power. Conversely, during peak load condition, the battery starts to discharge, the DGs produce at maximum rate and the MG export power to the utility to reduce MG operational cost. Since the power generation with the MT is costly, it generates power at the minimum rate in the first hours of the day due to the low energy price. However, when the energy tariff on the utility side is raised, it is more preferable to enhance the output power of the MT during hours 9 to 17. This strategy leads to minimising the cost of the MG. Moreover, the MGCC allows the FC to generate at maximum rate as the power generation cost is low with this source.

Fig. 3
figure 3

Power output of the PV and WT

Fig. 4
figure 4

Hourly market price and estimated load demand

Fig. 5
figure 5

a and b Power generation of units, disregarding the PHEVS—Scenario 1. c Simulation time of Scenario 1

Table 3 signifies the simulation outcomes, disregarding PHEVs. Table 3 gives a comprehensive comparison among various conventional methods and the suggested scheme in the case of the best solution (BS), worst solution (WS), average results (mean) and standard deviation (Std). The comparison outcomes indicate that the MHS algorithm enhances the total operating cost of MG. Evaluating the MHS algorithm compared with eight algorithms verifies that this algorithm is the best one. The obtained results verify that the used algorithm has a superior act in coping with MG management.

Table 3 Comparison of costs

The time desired by each algorithm to handle the given studies is shown in Fig. 5c. According to the figure, the time needed by the used scheme to handle the first case study's challenge is 5.87 s, showing improvement than GA, PSO and HS, which require 12.56 s, 10.33 s and 7.95, respectively.

5.2 Second Scenario

At the second stage, all local sources in the MG can start up or shut down while the battery is also not charged at the study's begging. The PV and WT are generated in two scenarios. As shown in Fig. 6, the MT is responsible for charging the battery as the expensive DG. Consequently, by exporting the stored energy to the utility during peak load, MG's cost can be decreased. At the first hours, the battery is charged by the utility and FC as they are cost-effective and can be used for the high-cost hours. Even though the MT is generating power in the first hours, it is not economical for power generation. In this regard, to achieve economical operation, the MGCC tried to shut it down in especial hours. Figure 6a depicts the cost function trend against the number of iterations. Table 4 shows a comparison between the proposed MHS algorithm and other approaches. Other swarm intelligence algorithms GA, PSO, FSAPSO are employed for comparing the outcomes. The comparison results revealed that the MHS algorithm enhanced the total cost of the MG. The MHS algorithm has the best performance compared to other algorithms. The time required to cope with case studies is shown in Fig. 6c. As seen, the time needed by the proposed technique to handle the problem is 5.19 s, where shows improvement than GA, PSO and HS.

Fig. 6
figure 6

a and b Power generation of units, disregarding the PHEVS—Scenario 2. c. Simulation time of Scenario 2

Table 4 Cost function comparison

5.3 PHEVs Considered for first scenario and second scenario

In this section, the performance of PHEVs is evaluated. It is assumed that the integration of PHEVs in the MGs is 30% out of 70 vehicles. Besides, MCS is used to model the MG uncertainties, including charging demand of PHEVs and load, electricity tariff and the power output of PV and WT. the various case studied containing UC, CC and SC are investigated. Figures 7, 8, 9, 10, 11, 12 and 13 depict the simulation results of this part. To enhance the maximum power generation, such a change in utility limit is required. Note that the MG cannot charge the PHEV if this modification is not performed. Note that for the test system with PHEVs, some novel amendment are needed. Owing to changing the main grid's maximum capacity, the outcomes for both cases are updated with the novel capacity.

As shown in Fig. 7, PHEVs is mostly charged through imported from the utility grid in the uncontrolled charging mode. Moreover, the battery is stored energy at light load hours. Owing to the high cost of MT, it is not contributing to the MG operation. According to Fig. 8, in a controlled charging mode, the MT is not started, and the extra required power is in response to the utility grid. Achieving minimum cost in the MG operation indicates the positive impact of controlled and smart charging modes in MG's optimal operation with PHEVs. According to the results of the three scenarios, it is clear that in the uncontrolled mode, most of the energy is provided by the utility grid during the peak period of 15–17, and in this mode, the cost of MG is high.

Fig. 7
figure 7

a and b Power dispatch of UC pattern—Scenario 1

Tables 5 and 6 show the total operating costs achieved from the MHS algorithm and other methods. Other swarm intelligence algorithms like GA and PSO have been used for comparing the results. The comparison outcomes confirm that the MHS algorithm enhances the MG cost, and it has the best performance among others. The best solutions obtained from different methods confirm that the MHS algorithm has improved performance compared to other algorithms.

Table 5 Best cost—Scenario 1
Table 6 Best cost—Scenario 2

Simulation time of the SC plans Scenario 1 and Scenario 2, as shown in Fig. 13a and b, respectively. As these figures indicate, the time needed by the suggested algorithm to handle the first scenario and second scenario is 7.33 and 7.87, respectively, which shows improvement than GA, PSO and HS algorithms.

Fig.8
figure 8

a and b Power dispatch of the CC pattern—Scenario 1

5.4 Discussion

As discussed earlier, in the first scenario PHEVs and uncertainties of MG are not considered. In the second case study, all local sources in the MG can start up or shut down while the battery is also not charged at the begging of the study; according to Table 6, in the second scenario, the MT is charging the battery as an expensive DG; to provide a comparison, the outcomes of the suggested MHS are compared with other conventional approaches. Thirty trails are used for simulations. From the table, it can be found that the suggested MHS algorithm shows high performance. The results show that the MHS algorithm has the best results by achieving the optimal solution. The MHS algorithm also shows superior performance rather than the original HS algorithm. From the two scenarios’ results, the second scenario's total cost is more than the first one.

Besides, the charging demands of PHEVs are evaluated in Sect. 5.3 for both scenarios. Moreover, MCS is used to model uncertainties in load, generation, price and charging demand of PHEVs. Section 5.3 is done by considering three modes uncontrolled charging, controlled charging and smart charging.

Tables 5 and 6 show the total operating costs attained from the MHS algorithm and other methods. Other swarm intelligence algorithms like GA and PSO have been used for comparing the results. The comparison outcomes depict that the MHS algorithm enhances the MG cost, and it has the best performance among others.

Figure 14 shows the operating costs with/without considering the PHEVs in both scenarios. According to this figure, PHEVs are supplied mainly by improving the power imported from the utility grid in the uncontrolled charging mode. Moreover, the battery is stored energy at light load hours. Owing to the high cost of MT, it is not contributing to the MG operation.

Fig. 9
figure 9

a and b Power dispatch of SC pattern—Scenario 1

Fig. 10
figure 10

a and b Power dispatch of UC pattern—Scenario 2

Fig. 11
figure 11

a and b Power dispatch of CC pattern—Scenario 2

Fig. 12
figure 12

a and b Power dispatch of SC pattern—Scenario 2

Fig. 13
figure 13

a Simulation time of the SC method—Scenario 1. b Simulation time of the SC method—Scenario 2

Fig. 14
figure 14

Comparison of cost the total operating costs

The result of this sensitivity analysis demonstrates that raising the number of memeplexes can lead to an improved fitness value but not necessarily. Nevertheless, it enhances the time of the optimisation procedure, which is not acceptable.

6 Conclusion

MG consists of active loads, storages and various DG technology. However, the day-ahead scheduling of the MG is critical issues that need considerable attention. In this work, the optimal operation of an MG with various RESs like WT, FC, PV and MT and PHEV charging demand is assessed. For evaluating the effect of PHEV charging demand UC, CC and SC modes are taken into account. The simulation results prove the improved performance of the MHS algorithm rather than conventional methods. Form outcomes: It is clear that SC mode can adequately reduce the total effect, but the PHEV charging demand can raise the MG's total cost.

Moreover, smart charging mode can minimise the cost of the MG in comparison with other patterns. Generally, the proposed algorism can ensure reliable and satisfying performance when operating the MG, and the results also show that increasing penetration of PHEVs provides more reliability and security for the MG with minimum cost. This paper showed that the use of PHEVs in MG provides many economic, technical and environmental benefits.