1 Introduction

Energy is a key determinant of socioeconomic development [1], in part, because energy consumption and economic growth are interrelated [2]. Energy is a vital commodity in modern living and a necessary intermediate input in all productive sectors. Moreover, energy access helps to improve conditions that in turn can alleviate poverty and contribute to sustainable development [3], [4]. While energy security is essential for economic growth and development, the power sector is responsible for 41% of global CO2 emissions. Without addressing emissions levels, countries cannot meet CO2 mitigation targets, as laid out in the Paris Climate Agreement and nationally determined contributions (NDCs) [5].

Currently, more than 70% of global demand for electricity is supplied by burning fossil fuels [6]. Electricity demand is growing as the global economy grows, and as a result, fossil fuels are increasingly consumed. The use of renewable energy is very important and cost-effective because of its nature and ease of use and is one of the most promising alternative energy systems [7]. The country’s new energy strategy aims to ensure energy security by increasing energy efficiency as well as through diversification [8]. In this paper, a particle swarm optimization-based simulation approach has been developed to tackle the multi-objective optimization problems. The proposed algorithm has been tested on a case study of Egypt electrical network that includes a total generation mix consisting of gas, oil, nuclear, wind, solar and hydro-generation types. Finally, an analysis study is carried out to get the optimal sharing from each source in the total generation mix [9].

Several researchers have developed energy models for power generation technologies. In [10], proposed a mixed integer linear programming (MILP) model. The model was developed and implemented in general algebraic modeling system (GAMS) for the fleet of electricity generation in Peninsular Malaysia to reduce the CO2 emissions by 50% from current CO2 emission level. In [11], developed a static linear programming investment model to determine the optimal technology mix based on increasing the contribution of wind power in the electric generation system. That alternative methodology results in a reasonable reduction in the capacity of inflexible generation. In [12], developed scheme to solve the generation expansion planning (GEP) problem in competitive electricity markets. The developed approach recognizes the presence of several generation agents aiming at maximizing their profits and the planning environment is influenced by uncertainties affecting the demand, fuel prices, investment and maintenance costs and the electricity price. The proposed approach used system dynamics to characterize the evolution of electricity prices and of the demand.

In [13], proposed a mixed integer linear programming (MILP) model for the optimal long-term energy planning of a (national) power generation system. The proposed model determines the optimal planning of the power generation system, the selection of the power generation technologies, the type of fuels and the plant locations so as to meet the expected electricity demand, while satisfying environmental constraints in terms of CO2 emissions. The proposed approach can provide policy makers with a systematic computer-aided tool to analyze various scenarios and technology options. In [14], proposed a methodology to determine the optimal mix of renewable energy sources (RES) and fossil fuels in an electricity system by taking into account the hourly values of RES production and electricity demand. The methodology was applied to the Mexican electricity system. Several combinations of biomass, wind and solar power that achieve a minimum of 35% RES electricity production were identified. In [15], proposed a generic methodology to determine an optimal energy mix for a period of around 15 years. The proposed optimal energy mix is a right combination of energy sources that minimize the risk caused due to future uncertainties related to the energy sources. The proposed methodology used stochastic optimization to address future uncertainties over a planning horizon and minimize the variations in the desired performance criteria such as energy security and costs. In [16], presented optimization method for the power generated from a hybrid renewable energy systems (HRES) to achieve the load of typical house as an example of load demand using PSO technique.

In [17], presented a mixed integer linear programming optimization algorithm to determine the optimal size of the distributed generation unit and battery storage system based on operational savings and investment costs, as well as estimation of environmental benefits. In [18], investigated and analyzed three scenarios to study the impact of nuclear plant on the Egyptian grid from carbon dioxide emission, price, fossil fuel consumption and water consumption. In [19], reviewed and analysis new ways of energy practice of hybrid sources. It presented the physical modeling of the renewable energy resources with numerous methodologies and principles of the optimization for the hybrid networks. Also this paper introduced a global survey on the present condition of optimization techniques especially that related to the isolated microgrid. In [20], presented optimal sizing of a PV/wind/diesel and battery storage based on multi-objective self-adaptive differential evolution algorithm. By using the multi-objective optimization approach, the objectives are treated simultaneously and independently, thereby leading to a reduction in computational time. The multi-objective optimization approach is then used to analyze the loss of power supply probability, the cost of electricity and the renewable factor in relation to hybrid energy system cost and reliability.

In [21], the cost of renewables and community welfare are optimized. Community welfare is ensured by minimizing the purchased power and maximizing the sold power to the utility grid with different time-of-use electricity tariffs. Markov models of photovoltaic power generation, wind generation, load and temperature are utilized to reduce the numbers of variables and constraints. The Markov-based optimization problem is then solved using the interior-point algorithm. In [22], presented a comprehensive review on recent developments in size optimization methodologies, as well as a critical comparison of single algorithms, hybrid algorithms and software tools used for sizing standalone solar and wind hybrid renewable energy systems. In addition, make an evaluation of all the possible combinations of standalone solar and wind energy systems, including their assessment parameters of economical, reliability, environmental and social aspects. In [23], the distributed energy resources customer adoption model is used to determine the optimal size and type of distributed energy resources and their operating schedules for a sample utility distribution system. In [24], presented two different meta-heuristic optimization algorithms, namely whale and sine cosine, which are employed to find the optimal design of the system for minimizing the total annual cost and system emissions in hybrid power generation systems.

However, the development and application of a comprehensive bottom-up energy optimization models for the assessment of long-term energy policies and low-carbon development strategies for Egypt are currently lacking. In [25], developed a prototype model (an approach of integrating multi-criteria decision analysis, geographic information system data analysis and agent-based modeling) for Egypt to assess an energy security roadmap for Egypt. In the study, future energy mix for Egypt according to actors’ priorities is assessed and presented, but as suggested by the authors, the study lacks precision. Other energy studies for Egypt include solar and wind power for economic development [26], sustainable development indicators for the assessment of electricity production [27], an assessment of Egypt’s concentrated solar power components [28], a sustainability assessment of electricity generation technologies [29] and a further road map for renewable energy research and development [30].

This study is using the PSO optimization framework in order to provide an optimal yearly mix from generation sources that gives minimum cost with an acceptable range from the emitted pollution and satisfying the forecasted load that meet Egypt’s rising electricity demand. This study used PSO optimization scheme, because that it is simple and can be extended to deal with more multi-objective functions besides dealing with more renewable energy system. Also, this research reveals that the grid will operate successfully for supporting the utility as well as reduces cost of generation. This paper is organized as follows: Description of the proposed framework is introduced in Sect. 2; Sect. 3 describes a case study and implementation; Sect. 4 examines simulation results and analysis; and finally, the conclusions are given in Sect. 5.

2 Proposed framework

2.1 Particle swarm optimization scheme

To begin a PSO scheme, the initial velocity and position of each particle in a group of particles are randomly determined. Then, the evolving process is as follows: Also, Fig. 1 shows the flow chart of the proposed PSO scheme.

  1. 1.

    The initial position and velocity of each particle in the N-th dimension are determined randomly.

  2. 2.

    The fitness value of each particle is assessed according to the defined objective function.

  3. 3.

    If the fitness value of each particle’s current location is better than its P best, the P best is set to the current position.

  4. 4.

    The fitness value of the particle is compared with that of the Gbest. If it is better, the Gbest is updated.

  5. 5.

    Equation (1) is applied to update the velocity and position of each particle.

  6. 6.

    The process is repeated from Step 2 until the termination criterion is met or the optimal solution in the universe is obtained.

At time step t, the position and velocity of a particle are given by x(t) and v(t), respectively, the update formula for the velocity being [31, 32]:

$$ v\left( {t + 1} \right) = v\left( t \right) + c_{1} *{\text{rand}}*\left( {p{\text{Best}}{-}p} \right) + c_{2} *{\text{rand}}*\left( {g{\text{Best}}{-}p} \right) $$
(1)

where p: particle’s position, v: path direction, c1: weight of local information, c2: weight of global information, pBest: best position of the particle, gBest: best position of the swarm, rand: random variable and c1, c2: the balance factors between the effect of self-knowledge and social knowledge in moving the particle toward the target. Usually, the value 2 is suggested for both factors in the literature.

Fig. 1
figure 1

Particle swarm optimization flowchart

And then, simply adding this to the old position gives the new position:

$$ x\left( {t + 1} \right) = x\left( t \right) + v\left( {t + 1} \right) $$
(2)

This version of PSO is the most commonly used and is referred to as the conventional PSO in our study.

Equations 1 and 2 are written by the following formula:

$$ V_{i,j}^{k + 1} = w* V_{i,j}^{k} + c_{1} * r_{1} *\left( {P_{{{\text{best}}_{i,j}^{k} }} - X_{i,j}^{k} } \right) + c_{2} * r_{2} *\left( {G_{{{\text{best}}_{j}^{k} }} - X_{i,j}^{k} } \right) $$
(3)
$$ X_{i,j}^{k + 1} = X_{i,j}^{k} + V_{i,j}^{k + 1} $$
(4)

The most commonly used parameters of PSO algorithm are considered as follows:

  • Inertial weight: 0.9–0.4

  • Acceleration factors (C1 and C2): 2

  • Population size: 10–100

  • Maximum iteration (Max.ite.): 500–10,000

  • Initial velocity: 10% of position.

PSO parameters values are set to be:

M = 3;:

% number of variables

N = 100;:

% population size

Wmax = 0.9;:

% inertia weight

Wmin = 0.4;:

% inertia weight

C1 = 2;:

% acceleration factor

C2 = 2;:

% acceleration factor

Maxite = 1000;:

% set maximum number of iteration

Max-run = 10;:

% set maximum number of runs need to be

2.2 Carbon intensity of electricity supply “CIES”

There are several ways for calculating CO2 intensity (g-CO2/kWh) for power generation, depending on the way at which combined heat and power generation is taken into account. In our study, the following formula is used for calculating CO2 intensity [33]:

$$ {\text{CO}}_{2} \;{\text{intensity}} = {{\sum \left( {\frac{1}{{E_{i} }}*C_{i} P_{i} } \right)} \mathord{\left/ {\vphantom {{\sum \left( {\frac{1}{{E_{i} }}*C_{i} P_{i} } \right)} {\sum Pi}}} \right. \kern-0pt} {\sum Pi}} $$
(5)

This equation is called the objective function,

where i fuel source 1… n, Ei energy generation efficiency per fuel source, Ci CO2 emission factor per fuel source, (tone CO2/TJ) and Pi power production from public power plants per fuel source (MWh).

2.3 Levelized cost of energy

Actually the levelized cost of electricity depends on many parameters such as the type of plant and type of fuel. The levelized cost of electricity is a constant unit price ($/MWh) for comparing the costs of power plants that have different technologies, use different fuels, different capital expenditure paths, different annual costs such as operating, maintenance, taxes and carbon prices, different net outputs and different economic lives. With the escalation of dollar value relative to the local currency, it does not have a clarified image to calculate the real cost. Generally, the levelized cost of electricity is defined through equations [34,35,36].

$$ \sum\nolimits_{t} {\frac{{\left( {{\text{electricity}}\;{\text{sold}}} \right)_{t} * \left( {{\text{P}}_{\text{electricity}} } \right)}}{{\left( {1 + r} \right)^{t} }}} = \sum\nolimits_{\,t} {\frac{{{\text{capital}}\;{\text{expenditure}}}}{{\left( {1 + r} \right)^{t} }}} + \frac{{{\text{O}}\& {\text{M}}_{t} }}{{\left( {1 + r} \right)^{t} }} + \frac{{{\text{fuel}}_{t} }}{{\left( {1 + r} \right)^{t} }} $$
(6)

where electricity sold is the net electricity produced in (MWh) and sold in 1 year, Pelectricity is a constant price of electricity that is given in Eq. 7, r is the annual rate that is used to discount the values taken to be fraction a predefined rate of return required to cover equity and debt cost; Capital expenditure is the expenditure in year (t), associated with construction of the plant in $, O&Mt is the total non-fuel operating and maintenance in $; and fuelt is the total fuel costs in year.

The left side of Eq. 6 represents the present value of all received income from electricity sales over the plant life. This amount must balance with the present value of the following costs for building, operation and maintenance of the plant over its life. Since fuel cost is the dominant component of operating costs, this item is commonly called out separately from other non-fuel operating costs. The annual O&M costs also may include such items as taxes, carbon dioxide values or any other costs incurred through time. In case of fossil fuel technologies, any decommissioning costs at the end of the plant life are usually ignored. The rule of thumb is that the plant salvage value will cover these costs.

Taking Pelectricity in Eq. 6 to be defined as the constant levelized cost of electricity (LCOE), it is defined mathematically by Eq. 7 as follows:

$$ {\text{LCOE}} = \sum\nolimits_{T} {{{\frac{{\left( {{\text{capital}}\;{\text{expenditure}}} \right)_{t} }}{{\left( {1 + r} \right)^{t} }}} \mathord{\left/ {\vphantom {{\frac{{\left( {{\text{capital}}\;{\text{expenditure}}} \right)_{t} }}{{\left( {1 + r} \right)^{t} }}} {\sum\limits_{t} {\frac{{\left( {{\text{electricity}}\,{\text{sold}}} \right)_{t} }}{{\left( {1 + r} \right)^{t} }}} }}} \right. \kern-0pt} {\sum\limits_{t} {\frac{{\left( {{\text{electricity}}\,{\text{sold}}} \right)_{t} }}{{\left( {1 + r} \right)^{t} }}} }}} $$
(7)

The levelized term arises from the recognition that the calculations in Eq. 7 establish a single present value of overall cost that can be transformed into a series of uniform level, annual values through the use of so-called levelization factors. By common practice in LCOE calculations, the levelization factors are termed differently when applied to different cost elements, as elaborated below.

If the operating condition, maintenance, fuel costs, the net electricity produced and the net output of the plant are constant over the plant life, then Eq. 7 is reduced to Eq. 8 as follows:

$$ {\text{LCOE}} = \frac{{\left( {\text{TCR}} \right)\left( {\text{FCF}} \right) + {\text{FOM}}}}{{\left( {\text{MW}} \right)\left( {{\text{CF}} * 8766} \right)}} + {\text{VOM}} + \left( {\text{HR}} \right)\left( {\text{FC}} \right) $$
(8)

where TCR is the total capital requirement in the base $ year of the analysis, FCF is the fixed change factor (fraction), FOM is the fixed O&M costs ($/year), MW is the net power output of the plant (Mw), CF is the capacity factor (fraction), VOM is the variable O&M costs ($/MWh), HR is the net power plant heat rate (MJ/MWh), and FC is the fuel cost per unit of energy ($/MJ).

The levelization factor for the total capital requirement is commonly called the fixed charge factor, FCF. This factor converts the total capital value to a uniform annual amount (also called an annuity); the FCF is given by the following equation:

$$ {\text{FCF}} = \frac{{r\left( {1 + r} \right)^{t} }}{{\left( {1 + r} \right)^{t} - 1}} $$
(9)

where r is the interest rate or discount rate, and T is the economic life of the plant relative to the base year of analysis used in the study. Note that the assumption of constant values for all terms in Eq. 8 is, explicitly or implicitly, an analysis of electricity cost in real (or constant) dollars. On the other hand, a modified version of Eq. 8 is needed if annual plant costs change through time as occurs, for example, when using nominal (current dollar) costs that include an assumed inflation rate, or when assuming “real escalation rates” for fuel or other O&M costs, or when the level of plant output varies over time (reflected by different capacity factors). In such cases, the LCOE is expressed as:

$$ {\text{LCOE}} = \frac{{\left( {\text{TCR}} \right)\left( {{\text{FCF}}_{L} } \right) + L_{1} \left( {\text{FOM}} \right)}}{{\left( {\text{MW}} \right)\left( {{\text{CF}}_{L} *8766} \right)}} + L_{2} \left( {\text{VOM}} \right) + L_{3} \left( {\text{HR}} \right)\left( {\text{FC}} \right) $$
(10)

Here, l1, l2 and l3 are levelization factors applied to the initial (first year) value of fixed and variable operating costs and total fuel cost, respectively. (Additional factors can be applied to any sequence of other annual costs, or to the individual components of FOM and VOM.) These factors serve as “multipliers” that effectively convert all first year O&M and fuel costs to annuity values over the plant life, expressed in the base year of the analysis. In discrete terms, these various levelization factors, li (i = 1, 2, 3), are given by Weiner et al. [37]:

$$ L_{i} = \frac{{K_{i} \left( {1 - \mathop K\nolimits_{i}^{T} } \right)}}{{A_{T} \left( {1 - K_{i} } \right)}} $$
(11)
$$ K_{i} = \frac{{1 + e_{a,\,i} }}{{1 + \gamma^{n} }} $$
(12)
$$ e_{a,\,i} = \left( {1 + e_{a,\,i} } \right)\left( {1 + e_{\inf } } \right) - 1 $$
(13)

Here, r and T are as defined earlier. The additional term AT represents the present value of an annuity payment, and ea,i is the apparent escalation rate of the relevant cost component, i, resulting from real annual escalation rate, er,i, and a general inflation rate, einf (in the case of a current dollar analysis). In the case of constant dollar analysis with no real cost escalations, the value of ea is zero and the levelization factors, Li, are equal to 1.0.

3 Case study

The developed computer program is applied to the current Egyptian electrical network until 2030. The optimization analysis is performed among nuclear, wind and solar generating sources to obtain the optimal sharing from gas and oil generating sources to keep both the power generation cost (PSC) < 0.10 $/kWh and to keep also the carbon intensity of electricity supply < 500 g/kWh [14]. A constant GW of hydro-power generation source is assumed during the duration study. The reference scenario for the study is the data from the government model.

Table 1 summarizes the input generation mix for Egypt national network according to the forecasted updated plan of Egyptian government, until 2030 [38].

Table 1 Input generation mix for the proposed model (GW)

4 Results and discussion

4.1 Power generation cost and CO2 emitted effect

The developed computer program is applied to the current Egyptian electrical network until 2030. The optimization analysis is performed among nuclear, wind and solar generating sources to obtain the optimal sharing from gas and oil generating sources to keep both the power generation cost < 0.10 $/kWh and to keep also the carbon intensity of electricity supply < 500 g/kWh. A constant GW of hydro-power generation source is assumed during the study duration. The reference scenario for the study is the data from the government model introduced in Table 1.

At 7% interest rate, the simulation results between particle swarm optimization algorithm versus reference model for both CO2 emitted are shown in Fig. 2.

Fig. 2
figure 2

CO2 emitted when using PSO model versus reference model

From this figure, it is observed that using the PSO algorithm allows the emitted CO2 to increase, but within the desired range (< 500 g/kWh). This means that the sharing from gas and oil will increase causing the cost to decrease. Also, increasing the sharing from non-conventional (nuclear and renewable) energies in the total generation mix will decrease the sharing from gas and oil, consequently leading to an increase in generation cost per unit. To control the cost per unit, there will be an increase again in the sharing from gas and oil leading to an increase in CO2 emitted as shown in Fig. 2. This will result in a decrease in the cost per unit again.

Figure 3 illustrates a comparison graph for the value of power generation cost (PGC) when using the PSO algorithm versus the reference model, from which it is observed that using the PSO algorithm causes the value of power generation cost to decrease at the same interest rate as the sharing from gas and oil is increased.

Fig. 3
figure 3

Power generation cost when using PSO algorithm

4.2 Wind and solar effect

Studying the performance of the PSO algorithm when increasing the sharing from only wind and solar sources, we can get the following results:

4.2.1 Effect of increasing wind and solar generation on the CO2 emission

Here, the algorithm output generation mix (GW) will be affected directly. So, the sharing of each source will change accordingly. Also, the CO2 emitted and PGC will directly affect. The following are the simulation results regarding to this excess in wind and solar for PSO model and the reference one:

From Fig. 4, it is observed that increasing the sharing from wind and solar will result in a decrease in the sharing from gas and oil (sources of CO2). This will decrease the amount of CO2 emitted. Accordingly, both the power generation cost and annual cost will increase.

Fig. 4
figure 4

CO2 emitted when using PSO algorithm at 10, 20% excess from wind and solar versus the reference model

4.2.2 Effect of Increasing wind and solar generation on the PGC

From Fig. 5, we can observe that more increase from the sharing of wind and solar will result in a decrease in the sharing from gas and oil. This will decrease the amount of CO2 emitted. Accordingly, both the power generation cost and annual cost will increase. To control the cost per unit, there will be an increase again in the sharing from gas and oil leading to an increase in CO2 emitted as shown in Fig. 5. This will result in a decrease in the cost per unit again.

Fig. 5
figure 5

PGC using PSO algorithm at 10, 20% excess from wind and solar versus the reference model

4.3 Impact of increasing nuclear energy

The impact of increasing the sharing from only nuclear energy source on both power generation cost and CO2 emission when applying the PSO algorithm scenario will be analyzed.

The nuclear energy is assumed to be increased by 50%, and then by 100%, and the impacts on the generation mix on the total power generation costs are compared with the government model. The comparison is shown in Fig. 6 with respect to the proposed model. From the figure, it can be observed that increasing the sharing from nuclear source yields to an increase in the power generation cost, where the proposed model still has the best performance.

Fig. 6
figure 6

Increasing the sharing of nuclear against the PGC

4.4 Impact on CO2 emission

The nuclear energy is assumed to be increased by 50%, and then by 100% versus the government model. A comparison between the new scenarios and the reference model is shown in Fig. 7 with respect to the proposed model. The figure clarifies that increasing the sharing from nuclear source yields to a decrease in the emitted CO2, where the proposed model has the highest level of emitted CO2 but still inside the desired values.

Fig. 7
figure 7

Increasing the sharing of nuclear against the CO2

5 Conclusion

This paper presents a general framework model that is capable of realizing the optimal mix of energy supply sources that meet current and future electricity demand. The objective of minimizing the CO2 emission and lower the overall cost of electricity with a novel PSO technique is presented. A MATLAB program was built to represent the proposed model. The developed program was applied to the plan of energy mix for the Egyptian electric network until 2030. In comparison with both the current Egyptian plan and the conventional optimization technique, the results show that applying the proposed PSO framework leads to a potential saving of approximately 2 billion $/year. Although this research focuses on certain types of power generation mix, the proposed framework can be extended to a wide range of power systems that use multi-source energy. The presented technique proves that the PSO optimization technique is now emerging as a viable planning tool in grid optimization and renewable energy applications.

The energy development future chosen by Egypt will not only affect the country, but will also have repercussion on both exporters of energy to Egypt and importers of Egyptian energy sources. With growing trade and inter-connections of electric grids, a stronger and more diversified Egyptian energy sector can support a wider regional economy, in addition to contributing to a better future climate. This work assists the decision makers to choose the PSO optimization technique for the energy generation because it is able to minimize the emission of CO2 and price of electricity (KWs).