1 Introduction

1.1 Motivation and aims

Due to the policies established by the governments all around the world toward the sustainable energy, some new concepts have been more and more used and developed in the area of energy, such as microgrid (MG), RESs, PEVs, distributed generation (DG), and electrical storage systems. In this regard, DG units are interpreted as small-size generating units, generally close to customers, among which renewable energy based ones are capturing more attention. Providing of energy is one of the most important issues for each country. Also, environmental issues due to fossil fuel depletion are other serious concern of them. In this regard, moving toward energy sustainability is a constructive solution for each country [1]. It should be noted that a high penetration of such technologies into power systems would lead to serious problems in the secure and reliable energy supply [1]. Several technologies are taken into consideration distributed energy resources (DERs), among them fuel cells (FCs), WTs, PV systems, diesel generators, microturbines (MTs), combined heat and power (CHP) units, and electrical storage systems such as batteries are the most famous technologies [2]. It is noteworthy that MGs would enable the network to take advantage of DGs, storage systems, and electric vehicles through providing the required infrastructure [3]. An MG is a LV distribution network, including both DERs and active consumers which can operate both in grid-connected or islanded mode [4].

Another element that is gaining more attention is EVs, both EVs and PHEVs, as they emit less environmental pollution [5]. By using such vehicles, the oil reserves would be less consumed, and higher efficiencies can be achieved together with enhanced energy security. PEVs and PHEVs have the G2V and the V2G capabilities, enabling them to act as mobile energy storage systems and provide the system with different services, such as peak shaving. They would also provide other ancillary services such as frequency regulation, spinning reserve, and voltage stability, besides the reactive power provision. These capabilities have turned these vehicles into an appropriate alternative to integrate intermittent RESs into power systems [6].

Different national and international organizations are giving subsidies to motivate people to buy EVs. On the contrary, it should be noted that a large penetration of such vehicles and connecting them to the grid can adversely impact the power system. The uncertainty would increase in the presence of RESs and the connection of EVs to the grid in large numbers would worsen the situation by probably increasing the peak load demand [7].

1.2 Literature review

There are numerous research works thus far published regarding the MGs energy management equipped with EVs. In this respect, parking lots with charging facilities in the context of MGs as active distribution networks would facilitate this process and bring a good solution to this problem [8]. A novel load management system has been presented in ref. [9], taking into account EV aggregators and numerous consumers in which the appliances load management and the energy trade of EVs have been applied. Once the system faces a shortfall in the energy supply, the system would automatically deploy the available energy in the battery energy storage systems to transact power with adjunct MGs or the main grid. Reference [10] studied FC-EVs in MGs. The joint energy and reserve hourly based day-ahead planning of virtual power plants (VPPs) has been investigated in ref. [11], where the role and effect of the produced CO2 emission have been discussed by assigning a penalty factor to the objective function.

By adding EVs, the total load demand of the system would vary, while it can provide the MGs with a unique opportunity to track the RESs’ intermittent power generation. It should be considered that in the absence of expensive fast charge facilities, the EV’s battery charging would take too long which can cause long lines in parking lots. In this regard, a linear framework has been presented in ref. [12] for charging stations where a distributed control technique has been used to plan the load demand of the EVs. In addition, the optimal scheduling of EVs charging/discharging can solve the problem of congestion in charging stations and some major problems encountered by the system operator. Such mentioned problems have been addressed in ref. [13] by developing an efficient MILP framework for energy management in charging stations while applying the demand response programs (DRPs). Reference [14] discussed a European project known as V-Charge program which included advanced driver support in urban zones like maneuvering, parking lots and charging EVs. Particularly, the scheduling techniques to assign vehicles to parking lots have been implemented both using static and dynamic frameworks. The problem of car sharing has been solved in ref. [15] using a discrete event simulation method and unified modeling language (UML).

Several event-driven techniques have been so far presented for the integrated scheduling of MGs and parking lots. In this respect, an event-driven optimization method was used in [16] to discuss the feasibility of discharging of EVs’ batteries to alleviate the peak demand over peak times. Reference [17] considered parking lots for the EVs using the model predictive control (MPC) similar to ref. [18], where it is targeted at seeking a trade-off between the energy withdrawal cost minimization and error in tracking a reference charging pattern. By investigating a similar problem, the authors in [19] tried to plan energy resources with respect to self-consumption maximization requirements and energy usage cost minimization in complicated realizations. Reference [20] used a dual coordination strategy to control a series of devices operating both in the market and real-time. The coordinated charging scheduling problem of EVs has been solved in ref. [21] by developing a hierarchical event-driven multiagent model. By having taken into account several parking lots, ref. [22] presented a distributed dynamic framework for assigning a considerable number of EVs. The problem of EV scheduling has been proposed in [23] where several parking lots are allocated to the network, supplied by either RESs or the distribution system.

1.3 Contributions

This paper investigates the short-term planning of an MG using the θ-modified krill herd (θ-MKH) method, where the efficiency of the presented algorithm compared to other methods has been verified through a comparison [24, 25]. In this paper, renewable-based networks provide a new intelligent stochastic framework for optimizing the charging as well as the discharging scheduling. In this framework, the V2G technology is used to supply a two-way power transaction between the local distribution system and PEVs. Also, this suggested network investigates various types of power sources like MT, WT, PV, and FC. On the other hand, one of the other important issues is the determination of the favorable dispatch for energy units since designing the charging and discharging of EVs for optimizing the overall cost of operation are performed by the MG central control (MGCC). Also, based on an unscented transform, a novel stochastic framework is designed to model the problem uncertainty. In fact, the unscented transform accounted as a nonlinear superposition attitude has demonstrated great efficiency in evaluations. This method is able to predict the error model at the load with one-hour resolution and the cost due to the local broadcasting system, hourly PV production, and WT power output. Also, the PEV’s behavior includes the destination time in each trip, the number of EVs in each fleet and the departure time.

In this research work, a novel framework based on an algorithm called “krill herd” is designed for effectively solving the problem. In fact, this algorithm provides a novel optimization algorithm that is capable of mimicking the behavior of krill animals to seek food [26, 27]. In this paper, a novel version of this algorithm named θ-MKH algorithm is presented to enhance the searching capability as well as the convergence rate of the KH algorithm. This smart algorithm solves the problem by replacing the polar coordinates with the Cartesian coordinates. On the other hand, this algorithm uses a two-step correction manner to promote the multifariousness of the population of the krill. In addition, the θ-MKH algorithm presented in this paper is smarter than the original KH algorithm. Besides, this paper investigates the efficiency of the presented technique by implementing the framework on the ordinary renewable energy based MG.

The other sections of the paper have been categorized as follows: cost functions and the related constraints are introduced in Sect. 2. Section 3 presents the point estimation method (PEM). Section 4 represents optimization algorithms. The simulation results are given in Sect. 5, and finally, Sect. 6 represents conclusions.

2 Modeling of system structure

During the past two decades, the penetration level of PEVs and PHEVs has been considerably increased and it will reach 50% by the year 2050, mainly due to the development in the digital industry. Such a penetration level, together with the substantial installation of RESs and other types of DGs, has led to severe complexity in the communication systems of electrical networks and also in the control and operation strategies. One critical factor in enabling the best performance of MGs is the communication systems and their development [28]. As Fig. 1 depicts, the network configurations, comprising the communication system, different DERs and also the transactions between different elements, have been taken into consideration in this paper. It is noteworthy that EVs have captured attention due to their effectiveness in mitigating the environmental concerns caused by the existing transportation systems with mostly fossil fuel vehicles. Introducing MGs to power systems have resulted in making the most of EV’s capabilities when connected to the grid to absorb/inject power from/to the system [29]. Such capabilities are known as G2V and V2G capabilities, proving the electrical grid with numerous advantages, such as peak shaving, frequency regulation, reduced operating cost, and enhanced power quality. Using these capabilities causes bidirectional power flow in the system between the grid and PEVs, which have bigger batteries compared to hybrid EVs [30]. Therefore, this study concentrates on the hourly planning of PEVs and investigates an intelligent charging and discharging design for PEVs. PEVs should have enough energy before driving on the road. Thus, the EV systems should be fully charged before the trip starts in the morning. Moreover, since EV batteries as energy storage play the most significant role in the V2G technology, in the near future, the traffic-based smart scheme will be a proper solution to EVs’ charging and discharging planning.

Fig. 1
figure 1

The idea of V2G in the operation of PEVs

2.1 Objective function

The problem formulation is to minimize the cost of the network as follows [4, 5, 9,10,11,12,13,14]:

$$\begin{aligned} {\text{Min}}\,\,\,\text{Cos} t = & \sum\limits_{{t = 1}}^{T} {(\sum\limits_{{k = 1}}^{{N_{{DG}} }} {C_{{DG,k}}^{t} P_{{DG,k}}^{t} } + C_{{Grid}}^{t} P_{{Grid}}^{t} + C_{{ENS}}^{t} } \\ \quad \times & \sum\limits_{{i = 1}}^{{N_{{Cus}} }} {L\alpha _{i}^{t} U_{i}^{t} } + (\sum\limits_{{n = 1}}^{{N_{\nu } }} {U_{{_{\nu } }}^{t} C_{{_{\nu } }}^{t} P_{{_{\nu } }}^{t} } + \text{Cos} t_{{\deg }}^{t} )) \\ \end{aligned}$$
(1)

where Eq. (1) demonstrates the cost of power produced by DGs, the cost due to power bought from the upstream system, the ENS cost, and the cost of PEVs, containing the charging and discharging costs and the battery degradation cost due to the V2G and G2V capabilities (Costdeg). In the expression (1), the negative and positive signs of the variable \({P}_{v}^{t}\) specify the direction of the power flow, so that the negative sign shows the power flow from the vehicle to the grid. Besides, the positive sign shows the power flow from the grid to the vehicle. It is noted that V2G technology has been employed in this paper to utilize the EV’s capabilities to improve the service quality in the system. In this respect, EVs would be able to charge or discharge when they are parked and connected to the grid. Such vehicles are taken into consideration mobile storage systems, having the capability to play the generator or load role in electric power networks. Thus, they can contribute to enhancing and facilitating the resource scheduling problem. Generally, the Wohler curve is used to estimate this cost which is represented as (2) [30]:

$$N_{c} (DOD) = \alpha \times DOD^{b}$$
(2)

where Nc is the number of battery’s discharge cycles. In this regard, a and b, which are parameters are determined based on the battery type.

2.2 Constraints

The optimization problem is subjected to the following constraints [4, 5]:

$$P_{DGi,\min }^{t} \le P_{DGi}^{t} \le P_{DGi,\max }^{t}$$
(3)

where Eq. (3) shows the limitation of power generation by DG unit.

$$\left\{ \begin{gathered} P_{i}^{t} = \sum\limits_{j} {\left| {\,V_{i}^{t} } \right|\left| {\,V_{j}^{t} } \right|\left| {\,Y_{ij} } \right|\cos (\theta_{ij} + \delta_{i}^{t} - \delta_{j}^{t} )} \hfill \\ Q_{i}^{t} = \sum\limits_{j} {\left| {\,V_{i}^{t} } \right|\left| {\,V_{j}^{t} } \right|\left| {\,Y_{ij} } \right|\sin (\theta_{ij} + \delta_{i}^{t} - \delta_{j}^{t} )} \hfill \\ \end{gathered} \right\}$$
(4)

where Eq. (4) indicates the relationships of the power flow, including both active and reactive power. \({\text{V}}_{{\text{i}}}^{{\text{t}}}\) is the voltage angle of bus i at time slot t. \(\delta_{i}^{t}\) represents the voltage angle of bus i at time slot t. Yij and θij are the magnitude and phase of admittance across node i and node j, respectively.

$$V_{i}^{\min } \le V_{i}^{t} \le V_{i}^{\max }$$
(5)

where Eq. (5) states the voltage magnitude constraint at the system buses. \(V_{i}^{{{\text{min}}}}\) and \(V_{i}^{{{\text{max}}}}\) represent the voltage magnitude of minimum and maximum, respectively.

$$\left| {P_{sub}^{t} } \right| \le P_{sub}^{\max }$$
(6)

Equation (6) states the upper limit constraint of power flow transacted with the main grid.

$$S_{ij}^{t} \le S_{ij}^{\max }$$
(7)

Equation (7) relates to the maximum power flow constraint because of the thermal limit of the line.

$$U_{c,\nu }^{t} + U_{d,\nu }^{t} + U_{i,\nu }^{t} = U_{\nu }^{t}$$
(8)

Also, Eq. (8) specifies the charging/discharging/idle modes of fleet v with a one-hour time resolution. Moreover, the limitation on the charging power is assigned to the model as (9).

$$U_{c,\nu }^{t} P_{c,\nu }^{\min } \le P_{c,\nu }^{t} \le U_{c,\nu }^{t} P_{c,\nu }^{\max }$$
(9)

where the upper and lower bounds of the charging rate of the battery are specified by \(P_{c,v}^{{{\text{max}}}}\) and \(P_{c,v}^{{{\text{min}}}}\), respectively.

3 Unscented transform (UT)

One of the most important members of the group of approximation approaches is the unscented transform method. This method uses some of focus points to substitute the probability distribution of the uncertainties. Furthermore, the mentioned method has many features, such as the capability to handle the uncertainty of correlation, low computational load, precise modeling, and simple scheme. This method is used to characterize the uncertainty of nonlinear correlated alterations. The unscented transform method is the most complicated; so, in this regard, it needs that the load flow equations be better understood. Also, these equations as a formula of nonlinear mathematical are assumed as y = f(X); where y shows the vector of outputs and the nonlinear function is expressed by f. Moreover, X shows the vector of inputs, including m unknown parameters with an average value m as well as covariance Pxx(m × m matrix). In Pxx the symmetric elements show the average values of the uncertain inputs, while non-symmetric ones between the two uncertain parameters are correlations. In fact, with the total number of unknown parameters equal to m, the presented technique can solve the difficulty with 2 m + 1 times for modeling the uncertainty [4, 31].

$$\chi^{0} = \mu$$
(10)
$$\chi ^{k} = \mu + \left( {\sqrt {\frac{n}{{1 - W^{0} }}} } \right)_{k} \,\,\,\,\quad ;k = 1,2,......m$$
(11)
$$\chi ^{k} = \mu - \left( {\sqrt {\frac{n}{{1 - W^{0} }}} } \right)_{k}; k = 1,2,......m$$
(12)

where the term (\(\sqrt {\frac{n}{{1 - W^{0} }}}\)) k shows the row Kth or column matrix. On the other hand, W0 is the primary weighting of the average value m.

4 Optimization algorithms

4.1 Genetic algorithm (GA)

GA is a recognized algorithm in which the roulette wheel mechanism is used, starting with a primary population including some chromosomes, that each shows a solution of the studied problem, assessed by a fitness function [32]. This optimization algorithm has been applied to some modern problems.

4.2 Particle swarm optimization (PSO)

PSO was introduced in 1995 [32], and it is categorized into evolutionary optimization algorithms which utilizes the pattern used in the movement of the swarm to find the food in an area. This algorithm uses a given number of iterations to search for the best value of the fitness function in a predetermined search space. In this problem, every solution parameter is taken into account a particle in the swarm conscious of its own behavior as well as the behavior of the common group. Besides, it is worth mentioning that every particle follows two position values indicated by pbest and the gbest known as the best solutions, obtained thus far respectively by itself and the group. The weighted random integer presented in the following is used to accelerate the algorithm to the two abovementioned points, while after each iteration, the velocity, as well as the position of particles, is amended.

4.3 Ant colony search (ACS) algorithm

Using the research carried out in 1992, it was revealed that ants use a particular pheromone to put a sign in the path for others, while as more ants pass by the path, the pheromone increases. In this respect, the paths not used or used less would not have a strong smell of pheromone. Thus, the paths with more deposited pheromone would lead to more food. It was observed that the ants are interested in finding and choosing the shortest path to the food. The ACS algorithm would implement the strategies mentioned above to determine the best solution for a specific objective function. The iterative application of transition rules presented in [32] is used by the ants to start their exploration from an initial state to a final state.

4.4 Firefly algorithm (FA)

This algorithm is developed by simulating the flashing patterns and behavior of fireflies introduced in 1995 [32]. The three principles of the FA are that fireflies are as follows: first, they engage with others disregarding the sex. Afterward, the fireflies which are less bright would be absorbed by brighter fireflies, and in the case of unavailability of any other brighter one, they randomly move. Finally, the brightness of a firefly should be jointed to the objective function of the problem.

4.5 θ-MKH algorithm

This method was first presented in 2012 and categorized into evolutionary algorithms [27]. Indeed, this algorithm is capable of mimicking the treatment of krill animals to seek food. This evolutionary algorithm has various special potential mechanisms, taken from the GA and PSO and it has many merits such as straightforward implementation, low affiliation on the regulating parameters, quick convergence, and it is effective to solve continuous and discrete optimization problems. Also, this algorithm has an automatic subdivision for solving several models of optimization problems. By utilizing these abilities, this algorithm is capable of handling any type of optimization problems with non-convexities. Since the initialization of the algorithm is by a random krill population; thus, the best krill is saved after evaluating the fitness function worthiness for all krill, and afterward, this algorithm will try to ameliorate the krill population. The detailed procedure is presented below [27, 33]:

$$X_{i}^{k + 1} = X_{{r,i^{\rho } }}^{k} V_{r,i}^{k} \rho \sum\limits_{j = 1}^{{N_{\nu } }} {(u_{j} - l_{j} )}$$
(13)

In this formula, \(V_{r,i}^{k }\) is the velocity of the ith krill which is under the effect of three motions as below:

The first motion is the induction motion \(V_{{{\text{ind}},i}}^{k }\), the second motion is foraging \(V_{{{\text{frg}},i}}^{k }\), and the third motion is the random diffusion \(V_{{{\text{diff}},i}}^{k }\). The following formula shows these stages:

$$V_{r,i}^{k} = V_{{{\text{ind}},i}}^{k} + V_{{{\text{frg}},i}}^{k} + V_{{{\text{diff}},i}}^{k}$$
(14)

\(V_{i}^{t }\) is a motion discussed comprehensively later. However, to prevent any repetition, at first the theta prescription of KH algorithm (θ-MKH) is explained. As explained in the Introduction, a novel version of the KH algorithm can be designed instead of the Cartesian space for the optimal search in the polar space. Actually, this idea is capable of transforming the conceivable search area for every variable to a finite span of = [−(\(\pi\)/2), + (\(\pi\)/2)]. Hence, with faster convergence, the search procedure could be carried out easily. Also, to formulate the θ-MKH, each krill Xi is substituted by its phase vector θi. Also, the speed Vi is substituted by θi which is its phase vector. Hence, moves of induction \(V_{{{\text{ind}},i}}^{k }\), foraging \(V_{{{\text{frg}},i}}^{k }\) and accidental diffusion \(V_{{{\text{diff}},i}}^{k }\) can be changed as Eq. (16). Thus, like Eqs. (13) and (14), it can be rewritten as follows [33]:

$$\theta_{i}^{k + 1} = \theta_{i}^{k} + \Delta \theta_{{r,i^{\rho } }}^{k} \sum\limits_{j = 1}^{{N_{\nu } }} {(u_{j} - l_{j} )}$$
(15)
$$\Delta \theta_{r,i}^{k} = \Delta \theta_{{{\text{ind}},i}}^{k} + \Delta \theta_{{{\text{frg}},i}}^{k} + \Delta \theta_{{{\text{diff}},i}}^{k}$$
(16)

Now, the three motions of induction, foraging as well as accidental diffusion will be described:

Induction motion The way the krill is influenced by its neighboring krill and it is specified using the induction motion as follows:

$$\Delta \theta_{{{\text{ind}}.i}}^{k} = \alpha_{{{\text{ind}},i}} \Delta \theta_{{{\text{ind}},i}}^{\max } + \omega \Delta \theta_{{{\text{ind}},i}}^{k - 1}$$
(17)
$$\alpha _{{{\text{ind}},i}} = \sum\limits_{{j = 1}}^{{N_{s} }} {\left[ {\frac{{f_{i} - f_{j} }}{{f_{w} - f_{b} }} \times \frac{{\theta _{i} - \theta _{j} }}{{\left| {\theta _{i} - \theta _{j} } \right| + \xi }}} \right]} + 2\left[ {r{\text{and}}(0) + - } \right]f_{i}^{b} \theta _{i}^{b}$$
(18)

where the value of the fitness function, which is normalized and multiplied by the induction direction of the neighboring krill is determined using the first term of (18). Accordingly, the negative and positive signs determine the attractiveness or defensive state of the neighboring krill. The following expression specifies if the krill θj is in the neighboring of krill θi.

$$R_{{{\text{Vicinity}}}} = \frac{1}{{5N_{p} }}\sum\limits_{j = 1}^{{N_{\rho } }} {\left| {\theta_{i} - \theta_{j} } \right|}$$
(19)

where Np is the number of population members. Figure 2 depicts an example of the induced distance over every krill [33].

Fig. 2
figure 2

Distance over every krill

Foraging motion The pattern of the movement of the krill to search for food is modeled using the foraging motion by taking into account the present and previous positions of the food as (20).

$$\Delta \theta_{{{\text{frg}},i}}^{k} = 0.02\left[ {2(1 - \frac{i}{{{\text{Iter}}}})f_{i} \frac{{\sum\nolimits_{i = 1}^{{N_{s} }} {\frac{{\theta_{i} }}{{f_{i} }}} }}{{\sum\nolimits_{i = 1}^{{N_{s} }} {\frac{1}{{f_{i} }}} }} + f_{i}^{b} \theta_{i}^{b} } \right] + \omega_{{{\text{frg}}}} \Delta \theta_{{{\text{frg}},i}}^{k - 1}$$
(20)

Based on this equation, first, the center of the food and second the food attraction are determined.

Random diffusion A random procedure would be gone through using the maximum diffusion speed and a directional random vector.

$$\Delta \theta_{{{\text{diff}},i}}^{k} = \nu \times \omega_{{{\text{diff}}}}$$
(21)

Therefore, the phase vector should be converted to its Cartesian mold Xi in each time that the objective function needs to be calculated according to the following equation [27, 33]:

$$X_{i}^{k} = \frac{{X_{\max } - X_{\min } }}{2}\sin \theta_{i}^{k} + \frac{{X_{\max } + X_{\min } }}{2}$$
(22)

This formula is used to calculate the equivalent Cartesian vector for θi as a necessary tool.

4.5.1 Modification method

A two-stage modification process is introduced in this section, aimed at enhancing the search capability of the original KH method, by raising the diversity of the population of krill at every iteration. In this respect, the Levy flight method is used in the first-stage modification to do a local search around every krill [33, 34].

$$\theta_{i}^{k + } = \theta_{i}^{k} + \varphi \oplus {\text{L}}\mathop {\text{e}}\limits^{^{\prime}} {\text{vy}}(r)$$
(23)
$${\text{L}}\mathop {\text{e}}\limits^{^{\prime}} {\text{vy}}(\Gamma ) \sim \tau = k^{ - r} ;\,\,(1 < \Gamma < 3)$$
(24)

The second stage of the modification process relates to shifting the mean of the population so as to approach the best krill in every iteration. Consequently, the mean value is specified as Mnk and in the subsequently, the location of each krill is updated as (25):

$$\theta_{i}^{k + 1} = \theta_{i}^{k} + {\text{round}}\;(1 + r{\text{and}})\;(\theta^{b} - Mn_{k} )$$
(25)

where the above motion increases the convergence rate of the suggested algorithm. Figure 3 shows the comprehensive of the suggested θ-MKH algorithm [27, 33].

Fig. 3
figure 3

The θ-MKH method

4.5.2 Implementation of θ-MKH algorithm

The presented θ-MKH algorithm is implemented in this paper using the steps below to tackle the day-ahead resource scheduling problem of an MG connected to the utility grid.

  • Step1 Initializing the procedure by the data of the MG, DGs, algorithm and PEVs.

  • Step2 Unconstraining the original constrained problem by applying penalty factors, so that every constraint is satisfied.

  • Step3 Producing the initial krill population. In this respect, every krill is taken into account a vector specifying the state and power output of the unit. The initial phase and the corresponding incremental angle, shown by θi and Δθi are calculated as follows:

    $$\begin{gathered} \theta_{i,j} = \psi_{5} (\theta_{j,\max } - \theta_{j,\min } ) + \theta_{{j,\min ;\,\,\,\,\,\,\,\,\,j = 1,2,...,N_{\nu } }} \hfill \\ \Delta \theta_{i,j} = 0.1 \times \theta_{i,j} ;\,\,\,\,\,\,\,\,i = 1,2,...,N_{\rho } \hfill \\ \end{gathered}$$
    (26)

    As it has been mentioned previously, the phasor component of the control vector X is denoted by θ.

  • Step4 Transforming from the phase angle space to the Cartesian space.

  • Step5 Assessing the expected value of the cost while taking consideration that m random variables would cause solving the problem for 2 m times using the 2 m + 1 PEM method. Accordingly, the mean and standard deviation of the cost function would be determined.

  • Step6 Keeping the best krill, specified as the one associated with the minimum cost.

  • Step7 Continuing the procedure by using the modification step for each krill individually. Consequently, the population of krill would be updated.

  • Step8 Reupdating the population of krill utilizing the presented modification technique.

  • Step9 Updating the location of every krill and saving them.

  • Step10 Checking the stop criterion to see if it is met. If not, the algorithm proceeds to step 7.

5 Simulation results

This section discusses the efficiency of the suggested stochastic programming technique in a small-scale distribution system with 32 nodes. The investigated test system is linked to the upstream network via a transformer. In addition, for the possibility of the power exchange, the local distribution system uses a transformer linked to the main grid. The studied system voltage magnitude is 12.66 kV. Figure 4 illustrates the configuration of the studied system. Indeed, Fig. 4 shows the test system, including two MTs, two WTs, one FC, one PV solar unit as well as two fleets of PEVs. It is also worth noting that WTs are located at bus 10 and bus 14, the PV unit is located at bus 19, the FC is located at bus 25, and MTs are located at bus 29 and bus 32. Furthermore, two PEV fleets can use bus 3 and bus 15 to access the area outside the studied system. In this study, the assumption is that the three-phase balanced network is a local distribution system; thus, the analysis is performed only for the single-phase system. As has been mentioned above, the studied distribution network is coupled to the main grid through a transformer to have a bidirectional power flow. The load demand of the network is shown in Fig. 5.

Fig. 4
figure 4

The test MG

Fig. 5
figure 5

General load demand

In addition, Table 1 presents the detailed data of DG units [5, 6]. The market price forecast is shown in Fig. 6. The hourly forecasted power output of the WT and the PV is shown in Fig. 7 [5, 6].

Table 1 The data of DGs [5, 6]
Fig. 6
figure 6

Hourly market price

Fig. 7
figure 7

Forecasted power output of the PV and the WT

In this research, WT 2 is 1.2 times bigger than WT 1. In this regard, two fleets of PEVs with various trip paths have been investigated for modeling the remarkable influence of PEVs in the studied test system. It is noteworthy that the required energy is similar to that of coming back to the beginning point for driving in one direction. The first travel from home to work begins in the morning to outside the distribution network. Therefore, the second trip of the fleet starts from the office at night and from the outside of the network to the network. But for the second fleet, a contrary travel sample is studied. Actually, the first trip of the second fleet starts from outside the system to the system and in the morning. It means that this fleet in its second travel in the evening will exit the system. Also, owing to the relatively small size of the grid, the travel is considered outside the network. Therefore, all trips can be checked using a similar procedure. Table 2 shows the departure time and the arrival time data of the two fleets [4].

Table 2 Travel of PEVs

Furthermore, the data related to the number of PEVs, the lower and upper bounds of the capacity and also the amount of charge and discharge of the fleet are shown in Appendix A [4]. Indeed, various energy requirements are defined for PEV fleets. In this system, it is assumed that the yearly driving interval by the PEV fleet is about 12 thousand miles with an average distance of 32.88 miles over each 24 h period. Moreover, the energy demand of each PEV is about 9 kWh each day with a mean of 3.65 miles/kWh. Therefore, the required energy of each fleet at each interval of the scheduling period is, respectively, 7.65 and 9.00 kWh. The lithium-ion (Li-ion) battery is utilized in this paper due to its popularity and efficiency. Additionally, in this study, the parameters a and b of the Wohler curve for Li-ion battery are considered 1331 and −1.825, respectively. This problem is solved for a 24-h period, and accordingly, the MGCC would be able to decide to transact energy at each time with the main grid. Since RESs need adequate support, the distribution network must purchase the whole generated power by the WT and PV units. Three different scenarios are defined in order to compare the generating units and their performance to decrease the network cost.

In the first scenario, the scheduling is carried out, disregarding PEVs, and all generating units are compelled to be ON over all time intervals. In the second case, although the dispatchable power units like the FC and MTs are able to choose to turn OFF, still PEVs are neglected. Also, in the third scenario, units can change their status, taking into consideration the economic priorities, while PEVs are present in the network. Table 3 includes a comprehensive comparison made between the performance of the optimization methods in terms of their best solution (BS), worst solution (WS), average results (Mean), and standard deviation (Std). The obtained simulation results related to the first scenario are shown in Fig. 8a, b. Figure 8a, b depict the results, derived from simulating the problem. In this respect, the number of trails is 20 to fairly make the comparison. Table 3 represents the results, derived by utilizing the proposed θ-MKH algorithm where this algorithm shows a superior performance at a lower cost, compared to other methods. Moreover, Fig. 8a, b include the hourly dispatch of distributed energy resources for scenario 1. With respect to the considerably higher operating cost of the MT, the FC has been employed more, as demonstrated in Fig. 8c, which can be easily seen over off-peak hours and initial time intervals. Figure 8d indicates the power produced by each asset to meet the load demand. The share of each DG in serving the load demand has been depicted in Fig. 8d. As can be observed, MT1 and MT2, FC, have been used the most due to their lower operating costs. Their contributions are 16.1%, 22%, and 8%, respectively. On the other hand, renewable generation units, i.e., WT1, WT2, and the PV system would be used less, which is because of their higher operating costs. In this respect, their shares in serving the load demand are 9.1%, 11.2%, and 11.3%, respectively.

Table 3 Decisive comparison of costs in scenario 1
Fig. 8
figure 8figure 8

a the best solution of DGs in scenario 1 b the best solution of DGs in scenario 1 c FC’s power nd electricity price in scenario 1 d DGs participation

Table 4 shows the results obtained in scenario 2. In this respect, the power units are permitted to change their status during the day. Moreover, Table 4 shows that for all 20 existing trails, the proposed θ-MKH is able to reach the desired solution with higher stability. With respect to the greater flexibility provided by the dispatchable generating units, the total network cost in this scenario is lower than the first scenario. Figure 9a, b show the hourly power generation of DG units where it is preferred to turn off the MT at off-peak hours. FC’s power output and electricity market price in scenario 2 are shown in Fig. 9c. The contribution of each DG unit in supplying the load demand has been shown in Fig. 9d, where MT 1, MT 2, and FC have the largest contributions.

Table 4 Comparison of different algorithms in scenario 2
Fig. 9
figure 9figure 9

a Best solution of DGs in scenario 2 b Best solution of DGs in scenario 2 c FC’s power and electricity price in scenario 2 d Percentage of participation of DGs

The impacts of PEVs have been assessed in this case, where two fleets of PEVs are taken into account. In this respect, it is assumed that PEVs start their first trip, while the state of the charge (SOC) is 100%. The system operator is supposed to consider the charging/discharging power of the vehicles once they are about to arrive/depart the network. Table 5, as well as Fig. 10a, b represent the results obtained from simulating the third case. Although a considerable number of PEVs can impose a huge load on the system, the effective management of their charging/discharging power can provide the system with a reduced operating cost. It is worth mentioning that all these advantages are provided thanks to the G2V and V2G capabilities, making PEVs mobile storage systems that can be effectively utilized by the MGCC when these vehicles are parked. Figure 10b shows the obtained schedule of the EVs besides the wind turbines and PVs. This figure shows that these vehicles are charged over off-peak hours so that they can provide the system with enough storage capacity over peak hours. The hourly data of market price and FC's power output have been illustrated in Fig. 10c. This paper studies three scenarios and it has been revealed that the last scenario, i.e., scenario 3 with the operating cost, equal to 49,711.75 (€ct) is associated with the least operating cost and the first scenario, i.e., scenario 1, is associated the highest operating cost by 50,170.09 (€ct). It is noted that costly DG units, like MT are used in the first scenario, while the third scenario utilizes PEVs as mobile storage to bring profit to the system when parked. Indeed, the DGs are able to turn off or on. Furthermore, the critical role of PEVs in the day-ahead scheduling can be observed from Tables 3, 4 and 5 PEVs would help transmit energy throughout the system disregarding the system's constraints. This capability would also enable renewable energies integration.

Table 5 Comparison of different algorithms in scenario 3
Fig. 10
figure 10

a Hourly DGs’ power generation in scenario 3 b DGs’ power generation in scenario 3 c fuel cell generation and electricity market price in scenario 3

6 Conclusion

The paper studied the day-ahead scheduling problem in the MGs equipped with renewable energy units and a considerable presence of electric vehicles. The proposed optimization framework was aimed at minimizing the total cost of the system, including the energy not served costs. The random load flow is based on the unscented transform to model the uncertainty. As the obtained simulation results showed, the suggested smart scheduling framework was able to effectively use generating units and plug-in electric vehicles. Moreover, it can reduce the total cost. By utilizing the capabilities of the PEVs, it is possible to alleviate the total cost by energy transition from one section of the system to another part disregarding the thermal constraints of the feeder for the load flow. This capability, besides the power transaction with the main grid, would help find the desired solution. Hence, although the effects of uncertainty can increment the total system costs, exploiting such capabilities can lead to the desired solution.