Introduction

General overview

Aligning with the goals of SDG7, power system grids are migrating mostly towards renewable generation1. The degradation of the conventional fossil fuels has further fastened up this paradigm shift. However, the greatest demerit of the renewables is their intermittent nature and its dependence on climate. These renewable sources are a major source of generation in microgrids. A microgrid is essentially a scaled-down version of a traditional power grid that can autonomously manage its load demands through localized generation or with support from the main grid. These systems typically rely on distributed energy sources like wind, solar, and battery storage, while diesel generators are sometimes employed as auxiliary power units. Reducing microgrid operational costs is a crucial challenge in the design and implementation of decentralized energy systems. Key aspects of cost reduction include identifying the optimal energy resource mix, employing advanced energy management systems (EMS) to enhance operational efficiency, integrating energy storage solutions to mitigate the variability of renewable sources, ensuring smooth interaction with the main grid, evaluating the microgrid’s total lifecycle costs, and understanding applicable regulatory frameworks for grid integration. These factors are essential in developing a microgrid that operate optimally as well as possess high resiliency. Demand side management (DSM) is an important concept when dealing with microgrid cost minimization as both leads to an economic and efficient energy management solutions.

DSM is a method of energy management which considers the patterns of energy consumption of consumers2. The primary objective of demand side management (DSM) is to maintain a balance between energy demand and supply, ensuring mutually beneficial outcomes for both consumers and the grid operators. These are accomplished by encouraging the consumers to move their load usage to non-peak hours, endorsing energy efficient technologies, integrating smart grid technologies, implementing demand response programs (DRP), etc. Hence, DSM is a dynamic and evolving area that integrates engagement of consumers, grid laws and advanced methods to achieve a greater flexibility and energy efficient operation leading to sustainability.

One of the most important aspects of DSM is DRP. DRP consists of changing the usage of electricity in accordance with indications from grid operators3. When the grid experiences peak loads, the grid operators generally raise the electricity tariff rate. At these times, the consumers may desire to reduce their less priority loads voluntarily for obtaining financial benefits. Computerized algorithms and innovative communication methods are used to streamline DRP. The optimal scheduling of generators and DRP are interrelated apparatuses in the broader context for managing the electricity grids efficiently.

Optimal generator scheduling is a power system management strategy focused on meeting electricity demand efficiently while minimizing costs and ensuring the reliability of the power system. Achieving this involves determining and evaluating the best operating parameters for a group of generators, considering factors such as fuel costs, environmental regulations, and grid stability. Key elements of demand response programs (DRP) in this context include load forecasting, generator performance characteristics, unit commitment, transmission limitations, and reserve requirements. The dynamic and complex task of DRP essentially revolves around achieving a balance in-between these parameters to ensure a reliable, environment friendly and cost-effective operation of power system4,56. A deeper comprehension of grid dynamics along with advancement in technology constantly refine the methods employed for generator scheduling in modern and efficient power systems.

Exhaustive literature survey

The body of literature on economic and optimal microgrid management is extensive7,8,9,10. In11, the authors propose an optimization framework for modeling hybrid renewable energy systems, performing four key tasks: an energy management system (EMS) for resource optimization, a multi-objective moth flame optimization technique for determining energy resource sizing, the Taguchi method for setting upper limits on decision variables, and generating the best Pareto front using fuzzy models. The authors of12 reduced CO2 emissions and operational costs in microgrids by combining model predictive control, a decision-making tool, and a multi-objective optimization method. This combination facilitated rapid responses to fluctuations within the microgrid. The model predictive control utilizes the receding horizon technique, while the multi-objective optimization produces optimal Pareto solutions. For optimal EMS scheduling13, presents a novel strategy that considers the aging of battery energy storage systems (BESS) and the efficiency of reversible solid oxide cells. The hybridization of genetic algorithm-II and tabu search was employed, and results verified using data from Ningxia, China, showed a reduced payback period of 14.57 years and a self-sufficiency rate of 93.28%.

In14, eight metaheuristic approaches are evaluated to optimize the microgrid size with a focus on hydrogen storage. The objective is to minimize costs while ensuring efficient regulation of energy flow within the system. Key decision variables in this optimization include battery capacity, photovoltaic capacity, and fuel cell capacity. Among the methods, particle swarm optimization proved to be the most effective, reducing the annual system cost by 25.3% compared to the least efficient approach. Additionally, the method demonstrated an ability to avoid local optimum solutions. A dynamic economic dispatch problem for a hybrid microgrid network—incorporating battery storage, traditional power sources, and renewables—is addressed in15. This study utilizes a distributed optimization technique to minimize total generation costs. By applying a weight-sum technique, the multi-objective optimization problem is converted into a single objective, with convex functions representing the objective functions. The Lyapunov function method combined with convex analysis is utilized to assess the algorithm’s performance, ensuring that the process yields solutions that meet capacity constraints and maintain supply-demand balance within each time slot. In16, the authors applied second-order cone programming alongside a stochastic response surface approach to optimize microgrid dispatch strategies under the uncertainties of renewable energy supplies and demand fluctuations. The stochastic optimization model incorporates the Nataf transformation and Hermite chaotic matrix, employing multi-objective functions. The model’s convexity is achieved through second-order cone relaxation, and the Yalmip-Gurobi solver is used to improve both stability and computational efficiency. This approach is validated through case studies involving Monte Carlo simulations. A bi-layer optimization method is presented in17 for minimizing microgrid operating costs. In the upper layer, binary chance-constrained outage planning is addressed, while the lower layer manages power deviations. This method was tested across various outage scenarios and uncertainty levels, demonstrating significant reductions in operational costs. Additionally18, introduces a distributed hierarchical framework aimed at optimizing the economic costs of grid-connected microgrids. This system utilizes a multi-agent leader-following consensus algorithm, which provides enhanced steady-state accuracy and improved transient responses. In19, the authors focus on a hybrid microgrid in a remote region of Nigeria, emphasizing the potential for optimally hybridizing energy resources to meet increasing load demand. The energy costs of the existing system are analyzed over a 25-year period using the annualized system cost approach. Particle swarm optimization and hypothetical mathematical models are used to configure the system for minimal cost while maintaining reliability. This method effectively enhances the reliability of the microgrid at reduced operational costs.

The paper in20 explores relaying-assisted communications for demand response in smart grids, focusing on cost modeling, game strategies, and algorithms to optimize demand-side management. In21, a three-stage multi-energy trading strategy based on peer-to-peer (P2P) trading models is proposed to improve the efficiency of energy trading in hybrid microgrids. The study in22 presents a two-stage economic-safety optimization for sizing seasonal hydrogen energy storage systems in integrated energy systems, particularly for northwest China. The research in23 introduces a homomorphic encryption-based distributed energy management system that ensures resilience against cyber-attacks in microgrids using an event-triggered mechanism. In24, a framework for event-trigger-based resilient energy management in smart grids is developed to protect against false data injection (FDI) and denial-of-service (DoS) attacks, focusing on maintaining reliability in distributed energy management systems. The paper in25 investigates multi-objective optimization using deep reinforcement learning to manage microgrid dispatch, considering frequency dynamics to enhance operational stability and cost-efficiency. In26, a short-term interval prediction strategy for photovoltaic power is proposed, incorporating meteorological reconstruction with spatiotemporal correlations and multi-factor interval constraints to improve energy forecasting accuracy. The study in27 presents a novel operation method for renewable buildings by combining a distributed DC energy system with deep reinforcement learning, aiming to optimize energy management in renewable-powered buildings. The research in28 focuses on the reliability modeling and maintenance cost optimization of wind-photovoltaic hybrid power systems, providing a framework to assess and improve the reliability and economic performance of such systems. Lastly, in29, a distributed algorithm is proposed for solving dynamic economic dispatch problems in microgrids, which optimizes energy allocation and dispatch strategies without requiring initialization steps.

The integration of MATPOWER’s optimized execution with the solution-finding capabilities of various metaheuristic algorithms is examined in30 for an IEEE 30 bus system. The study explores the performance of several optimization techniques, including the Lichtenberg algorithm, particle swarm optimization (PSO), political optimizer, genetic algorithm, and mixed integer distributed ant colony optimization. Hyperparameter tuning is performed for each method, with PSO delivering the best outcome, achieving a convergence time of 19.17 s, high reliability, and a final solution of $801.57 per hour. Ultimately, an ant-colony-based algorithm is applied for economic dispatch in the microgrid, targeting the minimization of the levelized cost of energy. In31, the authors adopt a master-slave game optimization model to manage the coordination between the microgrid (acting as the master) and its loads and energy sources (acting as slaves). This approach facilitates optimized interaction among the microgrid’s load, generation, and storage components, ensuring efficient and balanced operations. Minimization of the overall cost of operation is considered to be the aim of the master and minimization of the cost of operation of renewable energy is considered to be the aim of the slave. It is shown that after 45 games, each can achieve Stackelberg equilibrium. In32, An innovative multi-agent coordinated dispatch methodology is introduced to optimize economic dispatch in a microgrid within a time-sensitive pricing environment. The microgrid’s economic operation model is meticulously developed and scrutinized using an advanced multi-agent chaotic particle swarm optimization approach is implemented. A Java agent development framework is used to establish a simulation environment for multi-agent systems, which demonstrates a high level of efficiency. An islanded microgrid is examined in33, where a two-stage distributionally robust model is developed for its optimal operation and design. The two-stage problem is solved using a column and constraint generation-based technique, and the algorithm’s effectiveness is demonstrated through multiple islanded microgrid scenarios. In34, optimal battery operation for grid-connected and standalone DC microgrids is explored, with the objective functions targeting the reduction of CO2 emissions, operational costs, and electrical energy losses. Several optimization algorithms, including the parallel ant lion optimizer, parallel particle swarm optimization, and parallel vortex search algorithm, are employed to optimize power flow on an hourly basis using successive approximations. In35, the Grey Wolf Optimizer is utilized to minimize the energy cost of a hybrid microgrid system in Malaysia. Four key performance parameters—excess energy index, renewable energy index, loss of power supply probability, and storage performance index—are analyzed to evaluate the method’s reliability. The study concludes that climatic conditions play a significant role in determining appropriate generation sources. A Coloured Petri Net-based dynamic scheduling method is proposed in36 for energy management in a microgrid powered by battery storage, solar, and wind energy. The Quantum Particle Swarm Optimization (QPSO) algorithm is applied to solve the objective function, and the results show enhanced cost-effectiveness, aligning with the enterprise benefits experienced by power utilities. A bi-level framework for day-ahead energy management is introduced in37 for a modified 33-bus distribution power grid microgrid. At the first level, load demands, solar irradiance, and wind speed are predicted for each microgrid using historical data. The second level focuses on scheduling the microgrids for the next day, with power exchange rates determined through a game-theoretic approach. The framework incorporates prediction of uncertain parameters using conventional artificial neural networks, hybrid deep learning neural networks, and long short-term memory (LSTM) networks. The findings reveal a 2.67% reduction in operational costs.

A community level management strategy at power and energy levels incorporating source-load interface is presented in38. a two-level collaborative approach is presented for its management. The first level integrates all schedulable resources for achieving balance between multi-energy sources optimally. The next level integrates hybrid virtual electrical storage. Chance-constrained programming is employed to bridge the two optimization levels, effectively reducing grid interaction variability by 59.48% and costs by 5.75%. In39, an energy management system (EMS) is introduced for a microgrid powered by solar, wind, and hydrogen storage. The primary goal is to minimize operational costs related to hydrogen storage systems and batteries. Demand response programs (DRP), combined with the Grey Wolf Optimization algorithm, are used for optimal system operation. This approach successfully lowers the final cost of the microgrid and proves highly effective in addressing complex operational challenges. A utility-driven load-shaping strategy for a digital twin of wind and solar power sources is presented in40, proposing a triple-stage stochastic EMS to optimize day-ahead planning and minimize microgrid operating costs. The suggested stochastic model, which integrates 20% demand-side management (DSM), achieves a 43.8% reduction in pricing. Similarly, in41, a stochastic programming model is developed for energy management involving multiple renewable sources, employing a multi-objective enhanced slime mould algorithm. Hong’s (2m + 1) point estimate technique is applied to account for solar irradiance and wind speed uncertainties. The combined DSM and DR methods lead to a 12.62% reduction in generation costs for wind energy, with a 7.43% decrease in environmental emissions. For solar energy systems, generation costs drop by 31.53%, while emissions are reduced by 2.51%. In42, a hybrid intelligence method is proposed for reducing total costs across three microgrid systems, incorporating DSM to optimize performance and achieve cost savings. Practical difficulties such as unit commitment was incorporated. The approach achieved cost savings between 8% and 18% across various test systems analyzed. The impact of DSM in efficient cost reduction is studied in43. Based on the priority of the loads, a shifting technique is employed. Particle swarm optimization is used for load flexibility and mini-grid sizing automatically. The analysis reveals that the levelized energy cost decreases by 20.7% and 45.8% for productive and household sectors, respectively. In44, an integrated Demand Side Management (DSM) approach is introduced, combining multi-energy pricing with a non-cooperative game strategy for a regional integrated energy system. The demand-side competition is modeled as a non-cooperative energy consumption game, while the energy hub utilizes a scheduling strategy on the supply side, applying linear programming to optimize equipment operation. This strategy successfully reduces the peak-to-average ratio, thus balancing supply and demand. In45, an opposition theory and sine cosine-based slime mould algorithm is proposed as a DSM control strategy, demonstrating enhanced optimization capabilities for the slime mould algorithm. Additionally46, presents a novel hybrid crow search algorithm integrated with JAYA for DSM analysis. By restructuring demand with 20% DSM participation, electricity generation costs were reduced by 3–5%. This approach outperformed in nonparametric statistical analysis, central tendency measures, and execution time. In47, an innovative method is proposed to optimize performance in a demand-shifting DSM strategy, focusing on top-performing students in the context of DSM applications. The strategy provides significant incentives for participants in the day-ahead electricity market, encouraging effective demand-shifting behavior.

In reference48, an Energy Management System (EMS) is proposed to enhance both the environmental and economic performance of a system incorporating multiple microgrids, electric vehicles, and renewable energy sources. The EMS integrates various components to optimize energy distribution and usage, thereby reducing emissions and operational costs. This system is designed to efficiently manage the interaction between electric vehicles, renewable power generation, and microgrid infrastructure, promoting sustainability while ensuring cost-effectiveness in energy operations. The article integrates the price elasticity Program was integrated to examine the impact of incentives and real-time pricing provided to consumers. The strategy employed is a two-level hybrid optimization approach that combines the characteristics of grey wolf and whale optimization. In order to showcase its benefits, the approach is effectively tested on a system that includes industrial, residential, and commercial microgrids. In49, a demand response program (DRP) model is presented, aiming to optimize the benefits of microgrids. The model utilizes an exhaustive optimization technique to estimate the appropriate incentive value, assuming 40% customer participation in the DRP. A sophisticated approach is then applied to reduce the total cost of the microgrid system and assess the results with and without DRP implementation. After incorporating DR, the cost is reduced from 880¥ to 872¥, and the maximum power requirement drops by 5.13%, from 180 kW to 170.754 kW. In50, the impact of price-based DRPs on optimizing microgrid scheduling is examined, taking into account both nonlinear and linear load models. The DRP generates five distinct load models: hyperbolic, linear, power, logarithmic, and exponential. The Sparrow search algorithm is applied to solve the EMS problem. Various techno-economic performance metrics are assessed across different scenarios, and a prioritization ranking is established using a multi-criteria evaluation method. In51, a detailed explanation is provided for the optimal dispatch of an integrated energy system that includes both electricity and gas, factoring in carbon trading and DRPs. The proposed model is solved using particle swarm optimization combined with CPLEX. The results show enhanced benefits for both supply and demand sides, demonstrating the effectiveness of the model in optimizing system performance.

Research gap and motivation leading to the contribution of the work

Despite the vast body of literature on economic and optimal microgrid management, several gaps remain unaddressed in the current research. While numerous studies have explored the impact of distributed energy resources (DERs) and energy management systems (EMS) in microgrids, many fail to comprehensively analyze the integration of demand response programs (DRP) with varying price elasticities. Most works primarily focus on single, static DRP models or limited pricing strategies, such as real-time pricing or time-of-use rates, neglecting the more complex, dynamic interactions of non-linear load-responsive models. Moreover, the deployment of metaheuristic optimization techniques in microgrid operations, though gaining popularity, lacks consistency in evaluating their performance across diverse DRP scenarios52,53. There is also insufficient analysis on the effects of limited grid participation and the operational dynamics between DERs and the main grid in both islanded and grid-connected microgrids54,55.

Additionally, existing optimization algorithms often struggle with balancing the trade-offs between system reliability, environmental impact, and cost-efficiency under dynamic pricing conditions. The integration of advanced methods such as the Greedy Rat Swarm Optimizer (GRSO) has not been sufficiently explored, particularly in combination with flexible DRPs and nonlinear load models. Furthermore, there is a noticeable gap in studies that simultaneously address both the economic and environmental objectives within a unified framework, especially with respect to the impact of grid participation constraints.

The major contributions of the work that tends to attend to the research gap developed by the aforementioned exhaustive literature survey can be listed as follows:

  1. a.

    A price-based demand response (PBDR) was implemented to restructure the load demand of a grid connected microgrid system. Thereafter, the efficiency of the distribution network with respect to reduction of peak load, savings in energy and improvement in load factor were analysed for different PBDR models.

  2. b.

    The minimum generation cost of the MG system was evaluated for all the PBDR load models and four different cases.

  3. c.

    Results were compared with those in various literatures that involved diverse range of optimization algorithms and other demand side management strategies.

  4. d.

    A greedy RSO that involved the amalgamation of RSO and JAYA algorithm was used as the optimization tool for the study. Non-parametric statistical analysis was performed to comment on the efficacy and robustness of the proposed algorithm.

The remainder of this paper is organized as follows: Sect. 2 presents the formulation of the fitness function, detailing the objective function, equality and inequality constraints, and the responsive load economic model used for microgrid optimization. Section 3 discusses the uncertainty modelling of distributed energy resources (DERs), including the modelling of solar photovoltaic (PV) systems and wind turbines, as well as their intermittent nature. Section 4 describes the proposed optimization algorithms, focusing on the Greedy Rat Swarm Optimizer (GRSO) and its hybridization with other methods, such as the JAYA algorithm, to achieve optimal performance. Section 5 provides a comprehensive analysis of the case studies and numerical findings, including the development of load demand models based on price-driven demand response programs and the strategic scheduling of DERs to minimize generation costs. It also includes a comparative analysis across different operational cases and discusses the impact of grid participation and load profiles on microgrid performance. Section 6 concludes the paper by summarizing the key findings and highlighting the contributions to microgrid energy management, with suggestions for future research directions in optimizing microgrid operations through advanced demand response strategies and optimization techniques.

Formulation of fitness function

Objective function

Reduction of the cost of generation of the microgrid as well as the carbon emission is the primary objective of the problem which can be represented as per (1)56, where, \(\:M\left({W}_{r}\right)\) is the total cost of the microgrid, d is the number of DG units that is incorporated within the microgrid, \(\:{M}_{gen}\left({W}_{r}\right)\) is the cost of generation and \(\:{M}_{em}\left({W}_{r}\right)\) is the cost of emission,\(\:\:{W}_{r}\) is the output power corresponding to rth DG and t is the time in hour which varies from 1 to 24. The total cost of generation of the rth DG is a combination of expenses on fuel, cost associated with operation and maintenance and depreciation cost56. It can be expressed as (2) where, \(\:{M}_{fc,r}\left({W}_{r}^{t}\right),\:\:{M}_{o\&m,r}\left({W}_{r}^{t}\right)\) and \(\:{M}_{dpc,r}\left({W}_{r}^{t}\right)\) are the expenses on fuel, cost associated with operation and maintenance and depreciation cost respectively, \(\:{C}_{G}^{t}\) is the electricity tariff and \(\:{W}_{G}^{t}\) is the power by the grid.

$$\:Minimize\:M\left({W}_{r}^{t}\right)=\sum\:_{r=1}^{d}{M}_{gen}\left({W}_{r}^{t}\right)+\sum\:_{r=1}^{d}{M}_{em}\left({W}_{r}^{t}\right)$$
(1)
$$\:{M}_{gen}\left({W}_{r}^{t}\right)={M}_{fc,r}\left({W}_{r}^{t}\right)+{M}_{o\&m,r}\left({W}_{r}^{t}\right)+{M}_{dpc,r}\left({W}_{r}^{t}\right)+{C}_{G}^{t}\times\:{W}_{G}^{t}$$
(2)

The operational fuel expense of DG can be expressed mathematically as (3), where \(\:{Z}_{FC,r}\) is the fuel expense coefficient for the rth DG source. Similarly, the operation and maintenance expense of DG can be expressed mathematically as (4), where \(\:{Z}_{o\&m,r}\) is the operation and maintenance expense coefficient for the rth DG source. For calculating the depreciation expenses of the corresponding DG units, a factor called depreciation expenses per kWh, DC, the maximal power output of the corresponding DG units, \(\:{W}_{max}\), and the dynamic output power of the units along with its capacity factor, cf56. are considered which can be mathematically represented as per (5). DC is further dependent on cost of installation, IC56, which can be shown as per (6), where, rate is the interest percentage rate, life is the life span in years. The cost associated with the treatment of the pollutant released by DG units \(\:{M}_{gen}\left({W}_{r}^{t}\right)\) can be formulated as per (7), where, \(\:{S}_{j}\) is the cost of treatment for the jth pollutant by DG unit r, \(\:{Z}_{rj}\) is the emission coefficient of jth pollutant from DG unit r and \(\:{Z}_{Gj}\) is the emission coefficient of jth pollutant from grid.

$$\:{M}_{fc}\left({W}_{r}^{t}\right)={Z}_{FC,r}\times\:{W}_{r}^{t}$$
(3)
$$\:{M}_{o\&m}\left({W}_{r}^{t}\right)={Y}_{o\&m,r}\times\:{W}_{r}^{t}$$
(4)
$$\:{M}_{DC}\left({W}_{r}^{t}\right)=\frac{DC}{{W}_{max}\times\:8760\times\:capf}\times\:{W}_{r}^{t}$$
(5)
$$\:DC=IC\times\:\frac{{rate(1+rate)}^{life}}{{(1+rate)}^{life}-1}$$
(6)
$$\:{M}_{gen}\left({W}_{r}^{t}\right)=\sum\:_{r=1}^{d}{\sum\:}_{j}{(S}_{j}{Z}_{rj})\times\:{W}_{r}^{t}+{\sum\:}_{j}{(S}_{j}{Z}_{Gj})\times\:{W}_{G}^{t}$$
(7)

Equality and inequality constraints

For a reliable and stable power system operation, the required load demand by the consumers must be catered jointly by the grid, the DGs and the batteries57,58,59,60. Therefore, this required constraint can be expressed mathematically as per (8), where \(\:{W}_{RES}^{t}\) is the power supplied by the grid and \(\:{W}_{load}^{t}\) is the total load demand of the consumers that is required to be met. The constraints that are applied to the DGs and the grid can be represented as per (9) and (10) respectively, where \(\:{W}_{r,min}^{t}\) is the least power that should be generated by the rth DG,\(\:\:{W}_{r,max}^{t}\) is the maximum power that can be generated by the rth DG, \(\:{W}_{G,min}^{t}\) is the least power that should be supplied by the grid and \(\:{W}_{G,max}^{t}\) is the maximum power that should be supplied by the grid.

$$\:\sum\:_{r=1}^{d}{W}_{r}^{t}+{W}_{G}^{t}+{W}_{RES}^{t}={W}_{load}^{t}$$
(8)
$$\:{W}_{r,min}^{t}\le\:{W}_{r}^{t}\le\:{W}_{r,max}^{t}$$
(9)
$$\:{-W}_{G,min}^{t}\le\:{W}_{G}^{t}\le\:{W}_{G,max}^{t}$$
(10)

Responsive load economic model

Developing a responsive load economic model helps to analyse the impact due to customer participation and investigate their reaction on the electricity price changes61,62. End consumers can be broadly categorized into two groups as stated in63,64,65. One of the groups consists of sensitive loads consumers that have critical loads in a single period \(\:pd\) and can be represented as in Eq. (11), where \(\:EM\:\left(pd,pd\right)\) is called self-elasticity matrix. Likewise, the other group consists of non-sensitive loads consumers that have noncritical loads in multi-period and can be represented as in Eq. (12), where \(\:EM\:\left(pd,qd\right)\) is called cross-elasticity matrix and qd is another period. The demands and price for periods \(\:pd\) = (1, 2, 3, …., 24) and \(\:qd\) = (1, 2, 3, …., 24) are represented by \(\:dem\) and \(\:pri\), respectively. The matrix corresponding to defining the relation between these is represented by Eq. (13).

$$\:EM\:\left(pd,qd\right)=\:\frac{pri\left(pd\right)}{dem\left(pd\right)}\times\:\frac{\delta\:dem\left(pd\right)}{\delta\:pri\left(pd\right)}$$
(11)
$$\:EM\:\left(pd,qd\right)=\:\frac{pri\left(qd\right)}{dem\left(pd\right)}\times\:\frac{\delta\:dem\left(pd\right)}{\delta\:pri\left(qd\right)}$$
(12)
$$\:\left[\begin{array}{c}\begin{array}{c}\delta\:dem\left(1\right)\\\:\delta\:dem\left(2\right)\end{array}\\\:\begin{array}{c}\dots\:\\\:\delta\:dem\left(pd\right)\end{array}\\\:\delta\:dem\left(24\right)\end{array}\right]=\left[\begin{array}{c}\begin{array}{c}EM\left(\text{1,1}\right),\:EM\:\left(\text{1,2}\right),\dots\:.,\:EM\left(\text{1,24}\right)\:\\\:EM\left(\text{2,1}\right),\:EM\:\left(\text{2,2}\right),\dots\:.,\:EM\left(\text{2,24}\right)\end{array}\\\:\begin{array}{c}\dots\:\\\:\dots\:,\:\dots\:.,\dots\:.,\:EM\left(pd,qd\right),\:\dots\:\dots\:,\:\dots\:.\end{array}\\\:EM\left(\text{24,1}\right),\:EM\:\left(\text{24,2}\right),\dots\:.,\:EM\left(\text{24,24}\right)\end{array}\right]\left[\begin{array}{c}\begin{array}{c}\delta\:pri\left(1\right)\\\:\delta\:pri\left(2\right)\end{array}\\\:\begin{array}{c}\dots\:\\\:\delta\:pri\left(qd\right)\end{array}\\\:\delta\:pri\left(24\right)\end{array}\right]$$
(13)

Electricity model with fixed price and static cost coefficient is not a true depiction of the response of the consumer. Therefore, modified cross and self-elasticity coefficient matrices in a flexible price elasticity model is considered in the present work. The responsive load models for non-linear loads as well as linear loads are represented by Eq. (14) to Eq. (18), where the various load model constants are represented by \(\:{x}_{lin}\), \(\:{y}_{lin}\), \(\:{x}_{pwr}\), \(\:{y}_{pwr}\), \(\:{x}_{exp}\), \(\:{y}_{exp}\), \(\:{x}_{log}\), \(\:{y}_{log}\), \(\:{x}^{hyp}\) and \(\:{y}^{hyp}\). For the non-linear and linear load responsive models, the cross and self-elasticity matrices are represented as per Eq. (19) to Eq. (28). Based on “price elasticity” and “customer benefit function”61, the flexible load models with modified price elasticity matrices can be obtained as per Eq. (29) to Eq. (33). A comprehensive load model can be represented by Eq. (34), which integrates all demand functions into one model. This model considers each response of individual customer for individual DRP. The values of \(\:{wt}_{lin},\:{wt}_{pwr},\:{wt}_{exp},\:{wt}_{log}\) and \(\:{wt}_{hyp}\) are considered by an approach of fitting historical data. All the details of the aspects of the modelling can be obtained from66.

$$\:{dem}^{lin}\left(pd\right)=\:{x}_{lin}+{y}_{lin}pri\left(pd\right)$$
(14)
$$\:{dem}^{pwr}\left(pd\right)={x}_{pwr}{pri\left(pd\right)}^{{y}_{pwr}}$$
(15)
$$\:{dem}^{exp}\left(pd\right)={x}_{exp}\text{e}\text{x}\text{p}\left({y}_{exp}pri\right(pd\left)\right)$$
(16)
$$\:{dem}^{log}\left(pd\right)={x}_{log}+{y}_{log}\text{l}\text{n}\left(pri\right(pd\left)\right)$$
(17)
$$\:{d}^{hyp}\left(pd\right)={x}^{hyp}+\frac{{y}^{hyp}}{pri\left(pd\right)}$$
(18)
$$\:{EM}_{lin}\left(pd,\:pd\right)=\frac{{y}_{lin}pri\left(pd\right)}{{x}_{lin}+{y}_{lin}pri\left(pd\right)}$$
(19)
$$\:{EM}_{lin}\left(pd,\:qd\right)=-{y}_{lin}\frac{pri\left(qd\right)({x}_{lin}+2{y}_{lin}pri(qd\left)\right)}{({x}_{lin}+{y}_{lin}pri\left(pd\right))({x}_{lin}+2{y}_{lin}pri(qd)}$$
(20)
$$\:{EM}_{pwr}\left(pd,pd\right)={y}_{pwr}$$
(21)
$$\:{EM}_{pwr}\left(pd,qd\right)={-y}_{pwr}{\left(pri\left(qd\right)/pri\left(pd\right)\right)}^{1+{y}_{pwr}}$$
(22)
$$\:{EM}_{exp}\left(pd,pd\right)={y}_{pwr}pri\left(pd\right)$$
(23)
$$\:{EM}_{exp}\left(pd,qd\right)=-{y}_{exp}pri\left(qd\right)\frac{\left[1+{y}_{exp}pri\left(qd\right)\right]\text{e}\text{x}\text{p}\left({y}_{exp}pri\right(qd\left)\right)}{\left[1+{y}_{exp}pri\left(pd\right)\right]\text{e}\text{x}\text{p}\left({y}_{exp}pri\right(pd\left)\right)}$$
(24)
$$\:{EM}_{log}\left(pd,pd\right)=\frac{{y}_{log}}{{x}_{log}+{y}_{log}\text{l}\text{n}\left(pri\right(pd\left)\right)}$$
(25)
$$\:{EM}_{log}\left(pd,qd\right)=-\frac{{y}_{log}}{{x}_{log}+{y}_{log}\text{l}\text{n}\left(pri\right(pd\left)\right)}\times\:\frac{pri\left(qd\right)({x}_{log}+{y}_{log}(1+\text{ln}\left(\text{p}\text{r}\text{i}\left(\text{q}\text{d}\right)\right)))}{pri\left(pd\right)({x}_{log}+{y}_{log}(1+\text{ln}\left(\text{p}\text{r}\text{i}\left(\text{p}\text{d}\right)\right)\left)\right)}$$
(26)
$$\:{EM}_{hyp}\left(pd,\:pd\right)=\frac{{y}^{hyp}}{{x}^{hyp}pri\left(pd\right)+{y}^{hyp}}$$
(27)
$$\:{EM}_{hyp}\left(pd,\:qd\right)=\frac{{y}^{hyp}pri\left(qd\right)}{pri\left(pd\right){(x}^{hyp}pri\left(pd\right)+{y}^{hyp})}$$
(28)
$$dem^{{lin}} \left( {pd} \right) = dem_{0} \left( {pd} \right)\left\{ {1 + EM_{{lin}} \left( {pd,pd} \right)\left[ {\frac{{pri\left( {pd} \right) - pri_{0} \left( {pd} \right)}}{{pri_{0} \left( {pd} \right)}}} \right] - \sum {\:_{{q = 1;q \ne \:p}}^{T} } EM_{{lin}} \left( {pd,qd} \right)\left[ {\frac{{pri\left( {qd} \right) - pri_{0} \left( {qd} \right)}}{{pri_{0} \left( {qd} \right)}}} \right]} \right\}$$
(29)
$$\:{dem}^{pwr}\left(pd\right)={dem}_{0}\left(pd\right)\left\{1+{EM}_{pwr}\left(pd,pd\right)\left[\frac{pri\left(pd\right)-{pri}_{0}\left(pd\right)}{{pri}_{0}\left(pd\right)}\right]-\sum\:_{q=1;q\ne\:p}^{T}{EM}_{pwr}\left(pd,qd\right)\left[\frac{pri\left(qd\right)-{pri}_{0}\left(qd\right)}{{pri}_{0}\left(qd\right)}\right]\right\}$$
(30)
$$\:{dem}^{exp}\left(pd\right)={d}_{0}\left(pd\right)\left\{1+{EM}_{exp}\left(pd,pd\right)\left[\frac{pri\left(pd\right)-{pri}_{0}\left(pd\right)}{{pri}_{0}\left(pd\right)}\right]-\sum\:_{q=1;q\ne\:p}^{T}{EM}_{exp}\left(pd,qd\right)\left[\frac{pri\left(qd\right)-{pri}_{0}\left(qd\right)}{{pri}_{0}\left(qd\right)}\right]\right\}$$
(31)
$$\:{dem}^{log}\left(pd\right)={dem}_{0}\left(pd\right)\left\{1+{EM}_{log}\left(pd,pd\right)\left[\frac{pri\left(pd\right)-{pri}_{0}\left(pd\right)}{{pri}_{0}\left(pd\right)}\right]-\sum\:_{q=1;q\ne\:p}^{T}{EM}_{log}\left(pd,qd\right)\left[\frac{pri\left(qd\right)-{pri}_{0}\left(qd\right)}{{pri}_{0}\left(qd\right)}\right]\right\}$$
(32)
$$\:{dem}^{hyp}\left(pd\right)={dem}_{0}\left(pd\right)\left\{1-{EM}_{hyp}\left(pd,pd\right)\left[\frac{pri\left(pd\right)-{pri}_{0}\left(pd\right)}{{pri}_{0}\left(pd\right)}\right]-\sum\:_{q=1;q\ne\:p}^{T}{EM}_{hyp}\left(pd,qd\right)\left[\frac{pri\left(qd\right)-{pri}_{0}\left(qd\right)}{{pri}_{0}\left(qd\right)}\right]\right\}$$
(33)
$$\:dem\left(pd\right)={wt}_{lin}{dem}^{lin}\left(pd\right)+{wt}_{pwr}{dem}^{pwr}\left(pd\right)+{wt}_{exp}{dem}^{exp}\left(pd\right)+{wt}_{log}{dem}^{log}\left(pd\right)+{wt}_{hyp}{dem}^{hyp}\left(pd\right)$$
(34)

Uncertainty modelling of the renewable energy sources involved as distributed energy resources (DER) for the microgrid.

Modelling of solar PV

The power developed by solar panels is governed by several system parameters that includes cell ambient temperature and solar irradiance57,58,59,60,67,68,69,70. The active power output (\(\:{W}_{opv}\)) of a solar PV can be obtained as per Eq. (35)63, where the maximal watt of the PV module is denoted by \(\:{W}_{max}\), solar irradiance in W/m2 is represented by \(\:solr\), the temperature coefficient of the cell in oC−1 is represented by \(\:\alpha\:\) and the temperature of the cell module in oC is represented by \(\:{T}_{cmo}\). The expression for \(\:{T}_{cmo}\) can be written as in Eq. (36), where the ambient temperature in oC is represented by \(\:{T}_{amb}\) and the nominal cell temperature value in oC is represented by \(\:{T}_{nct}\). Since the solar irradiance has an intermittent nature, for estimating the hourly solar irradiance beta PDF (\(\:{f}_{pv}\left(\rho\:\right)\)) is widely used as defined in Eq. (37), where \(\:\gamma\:\) and \(\:\:\varnothing\:\) are the values associated with the shaping of the solar irradiance. These values, represented by Eq. (38) and Eq. (39), are dependent on standard deviation \(\:\sigma\:\) and mean value \(\:\mu\:\),. The discrete probability state of solar irradiance during any time can be equated as per Eq. (40), where \(\:{\rho\:}_{1}\) and \(\:{\rho\:}_{2}\) are the limits.

$$\:{W}_{opv}={W}_{max}\frac{solr}{1000}(1+\alpha\:({T}_{cmo}-25\left)\right)$$
(35)
$$\:{T}_{cmo}={T}_{amb}+\frac{solr}{800}({T}_{nct}-20)$$
(36)
$$f_{{pv}} \left( \rho \right) = \left\{ {\begin{array}{*{20}l} {\left\{ {\frac{{\mathbb{\Gamma} \left( {\gamma + \varphi } \right)}}{{\mathbb{\Gamma} \left( \gamma \right)\mathbb{\Gamma} \left( \varphi \right)}}} \right.\rho ^{{\gamma - 1}} \left( {1 - \rho } \right)^{{\varphi - 1}} ;} \hfill & {0 \le \rho \le 1,~\gamma \ge 0,~\emptyset \ge 0} \hfill \\ {0;} \hfill & {otherwise} \hfill \\ \end{array} } \right.$$
(37)
$$\:\varnothing\:=\left(1-\mu\:\right)\times\:\left(\frac{\mu\:\left(1+\mu\:\right)}{{\sigma\:}^{2}}-1\right)$$
(38)
$$\:\gamma\:=\frac{\mu\:\times\:\varnothing\:}{1-\mu\:}$$
(39)
$$\:P\left(\rho\:\right)={\int\:}_{{\rho\:}_{1}}^{{\rho\:}_{2}}{f}_{pv}\left(\rho\:\right)d\left(\rho\:\right)$$
(40)

Modelling of wind turbine

The power developed by wind turbine is governed by several parameters that includes wind characteristic curve and velocity of wind71,72,73,74. The power obtained can be represented by Eq. (41), where the cut in speed is represented by \(\:{s}_{ci}\), cut out speed is represented by \(\:{s}_{co}\) and the rated speed of the wind turbine is represented by \(\:{s}_{r}\) and the rated output power of the WT is represented by \(\:{W}_{nop}\). Since the wind speed has an intermittent nature, for evaluating the wind speed uncertainty, Weibull PDF (\(\:{f}_{wt}\left(s\right)\)) is widely used as defined in Eq. (42), where \(\:m\) and\(\:\:n\) represents the scaling and shaping values. At any instant, the probability of a discrete state can be given as per Eq. (43), where \(\:{s}_{1}\) and \(\:{s}_{2}\) are the wind speed limits.

$$\:{W}_{owt}=\left\{\begin{array}{c}\:\:\:\:0\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:0\le\:s\le\:{s}_{ci}\:or\:s\ge\:{s}_{co}\\\:\frac{{s}^{2}-{s}_{ci}^{2}}{{s}_{r}^{2}-{s}_{ci}^{2}}\times\:{W}_{nop}\:\:\:\:\:\:\:\:\:\:\:\:\:\:{s}_{ci}\le\:s\le\:{s}_{r}\\\:{W}_{nop}\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:{s}_{r}\le\:s\le\:{s}_{co}\end{array}\right.$$
(41)
$$\:{f}_{wt}\left(s\right)=\frac{m}{n}{\left(\frac{s}{n}\right)}^{m-1}exp\left\{-{\left(\frac{s}{n}\right)}^{m}\right\}$$
(42)
$$\:P\left(s\right)={\int\:}_{{s}_{1}}^{{s}_{2}}{f}_{wt}\left(s\right)ds$$
(43)

Proposed optimization algorithms

Rat swarm optimizer (RSO)

Rat algorithm is chosen as the optimization algorithm which deals with the chasing and fighting behaviour of the rats. Rats generally chase their pray together in a group by a special type of behaviour known as social agonistic behaviour75. To mimic this characteristic in terms of mathematics, it is presumed that the best search agent possesses the information about the location of the prey. Following the best search agent found so far, the other search agents will adjust their positions accordingly. The mathematical equation governing this mechanism can be represented in (44), where \(\:\:\overrightarrow{{J}_{l}}\left(u\right)\)is the position vector of the rats and \(\:\overrightarrow{{J}_{lb}}\left(u\right)\) is the best optimum solution. The values of the parameters B and C are calculated as per (45) and (46) respectively, where u = 0,1, 2, …, \(\:{Iter}_{max}\) and R is a random value within the range of 1 and 5. C is also a random number ranging from 0 to 2. The parameters B and C are responsible for improved exploration and exploitation in the successive iterations75.

$$\:\overrightarrow{J}=B.\overrightarrow{{J}_{l}}\left(u\right)+C.(\overrightarrow{{J}_{lb}}\left(u\right)-\overrightarrow{{J}_{l}}\left(u\right))\:$$
(44)
$$\:B=R-u\times\:\left(\frac{R}{{Iter}_{max}}\right)$$
(45)
$$\:C=2\times\:rand\left(\right)$$
(46)

The fighting behaviour of the rats with the prey can be represented in terms of mathematics as per (47), where \(\:\overrightarrow{{J}_{l}}\left(u+1\right)\) is the next updated location of the rat. The best solution is saved, and the positions of other search agents is updated accordingly as per the best search agent. Hence, the adjusted value of parameters B and C guarantees the exploration and exploitation. This technique saves the optimum result with least number of operators.

$$\:\overrightarrow{{J}_{l}}\left(u+1\right)=\left|\overrightarrow{{J}_{lb}}\left(u\right)-\overrightarrow{J}\right|$$
(47)

JAYA algorithm

The Sanskrit word JAYA means “success” or “victory.” The major advantage of this algorithm is that there is just one governing equation for the algorithm and no tuning parameters. This makes the algorithm less tedious to deal with and can handle larger test systems with more complex constraints. As the termination requirements are met, the algorithm moves away from the worst solution (or failure) in each iteration, bringing it closer to the best answer (or success/victory). The JAYA algorithm’s basic governing equation is as per (48)76, where \(\:{R}_{f,g,h}\) denotes the value corresponding to the fth variable for the gth candidate in the iteration cycle h, \(\:{R}_{f,best,h}\) and \(\:{R}_{f,worst,h}\) denotes the value of fth variable for the best candidate and worst candidate respectively, \(\:{R}_{f,g,h}^{{\prime\:}}\) being the updated value of \(\:{R}_{f,g,h}\) and \(\:{\omega\:}_{1,f,h}\) and \(\:{\omega\:}_{2,f,h}\) are two random numbers which varies from 0 to 1. \(\:\left({R}_{f,best,h}-\left|{R}_{f,g,h}\right|\right)\)part of (48) represents the inclination of the solution to approach the best solution whereas the part \(\:{(R}_{f,worst,h}-\left|{R}_{f,g,h}\right|)\) represents the inclination of the solution to avert the worst solution. \(\:{R}_{f,g,h}^{{\prime\:}}\) is retained if it provides a better function value and is used for next cycle.

$$\:{R}_{f,g,h}^{{\prime\:}}={R}_{f,g,h}+{\omega\:}_{1,f,h}\left({R}_{f,best,h}-\left|{R}_{f,g,h}\right|\right)-{\omega\:}_{2,f,h}\left({R}_{f,worst,h}-\left|{R}_{f,g,h}\right|\right)$$
(48)

Greedy RSO (GRSO)

GRSO is a modified version of the above described RSO which implements the greedy strategy of JAYA in the later iterations of RSO. This modification not only assisted RSO from avoiding local minima, but also amplified the balance between diversification and intensification to obtain better quality solutions repeatedly. The flowchart of GRSO is shown in Fig. 1. GRSO have been implemented in this work to minimize the generation cost of microgrid systems for diverse case studies and load profiles.

Numerical findings and elaborative discussions on case studies

The study’s test system was a low voltage microgrid system. Its energy-generating components include three separate fossil-fuelled units (FF) (1, 2, and 3; referred to as “G” in the corresponding tables and figures), a solar-PV unit, a WT unit, one direct-methanol FC, and a gas turbine (GT) fed by natural gas. The subject microgrid system’s single line diagram is displayed in Fig. 2. The suggested GRSO procedures and a variety of flexible load DR techniques are used to evaluate the cost minimization function. Table 1 presents the cost and emission metrics for a variety of distributed generation (DG) resources. These metrics align with the capacity considerations outlined in previous research77. The total power requirement for the microgrid, amounting to 2.2660 MW, is distributed across a 24-hour cycle, as illustrated in Fig. 3. Additionally, Fig. 4 portrays the dynamic price of electricity, which fluctuates according to the realistic load demands in the market. Remedial costs for NOx, SO2, and CO2 are 62.9640/kg, 14.8420/kg, and 0.21/kg, respectively. MATLAB R2017a installed in a laptop with 8 GB RAM and configured with Intel(R) Core(TM) i5-8250U CPU @ 1.60 GHz 1.80 GHz was used for the work done in the paper.

Table 1 Scalar parameters of the DER77.

The microgrid operates in four distinct modes, or “cases,” to evaluate the effects of pricing, renewable energy sources (RES), and grid participation on system performance. These cases provide a comprehensive analysis of how different factors influence the microgrid’s operation. In each scenario, all distributed generation (DG) resources are expected to be active during daylight hours, ensuring consistent energy production and allowing for a thorough assessment of each case’s impact on overall system efficiency and cost optimization.

Fig. 1
figure 1

Flowchart of GRSO.

Fig. 2
figure 2

Single line diagram of the considered microgrid.

Fig. 3
figure 3

System load demand and corresponding electricity market price77.

Restructuring of load demand model based on price-based DRPs

To optimize the scheduling and operational costs of the microgrid, the base case—excluding demand response programs (DRP)—is evaluated first. The hourly bidding price for real-time pricing (RTP) is derived from the electricity market prices illustrated in Fig. 3. The base rate or time of usage (TOU) is determined for valley, off-peak, and peak periods, while the fixed critical peak pricing (CPP) rates are applied during non-peak and critical peak periods50. Given the constraints related to static cross-elasticity and self-elasticity coefficients, the flexible elasticity model (FEM) for each price-driven DRP is calculated, as shown in Figs. 4, 5 and 6. A three-dimensional representation of the flexible price elasticity coefficients is evaluated for periods pd=(1,2,3,…,24) and qd=(1,2,3,…,24). Figure 7 presents the final nonlinear and linear load-responsive models generated for the FEM. Notably, the revised load demand profiles significantly improve peak load reduction. Table 2 outlines the decrease in peak load demand and the enhancement in load factor across the different load profiles analyzed.

Table 2 Calculations based on price-based demand response load modelling (kW).
Fig. 4
figure 4

FEM for TOU based demand response model.

Fig. 5
figure 5

FEM for RTP based demand response model.

Fig. 6
figure 6

FEM for CPP based demand response model.

Fig. 7
figure 7

Restructured load demand model pertaining to various PBDR strategies.

Strategic planning of DERs to achieve minimal generation costs in the microgrid system

For both the base load profile (LP) and all the linear and nonlinear LPs developed, the Greedy Rat Swarm Optimizer (GRSO) is employed to minimize generation costs within the microgrid system under four distinct scenarios. The GRSO algorithm is used to identify the optimal scheduling and cost-efficient operation for each case. The resulting outcomes are analyzed in detail in the following sections, providing insight into the effectiveness of each load profile in achieving the lowest possible generation costs across various operational conditions.

Case 1

This scenario represents the optimal operational mode for the microgrid, where all distributed energy resources (DERs) operate within their designated limits. The most significant factor contributing to the lowest generation cost in this scenario, compared to others, is the grid’s active involvement in both buying and selling electricity. Using the Greedy Rat Swarm Optimizer (GRSO), the minimum generation cost was calculated at 882¥. However, when considering the load profile based on critical peak pricing (CPP), the generation cost was further reduced to 746¥, as detailed in Table 3. Figure 8 visualizes the distribution of hourly loads across the DERs at the point of achieving the lowest cost. This scenario establishes the benchmark, and the next sections explore refinements and variations to improve microgrid performance further across different operational conditions.

Fig. 8
figure 8

Minimum generation cost for CPP based load profile during Case 1.

Case 2

This scenario examines the microgrid’s operation with the grid in a passive role, where it only supplies power when distributed energy resources (DERs) are unable to meet the load demand during specific periods. Outside these periods, the grid remains inactive. In this case, the generation cost decreased to 989¥ using the Greedy Rat Swarm Optimizer (GRSO), as shown in Table 3. Among the different load profiles, the logarithmic-based load profile further reduced the generation cost to 817¥. The distribution of hourly loads across DERs for this scenario is illustrated in Fig. 9. Notably, the grid does not exhibit any negative power flows, only supplying electricity during the 19th and 24th hours, when load demand peaks. The overall increase in generation costs compared to the optimal scenario is attributed to the limited, passive role of the grid, which constrains its ability to actively manage and reduce costs.

Fig. 9
figure 9

Minimum generation cost for logarithmic based load profile during Case 2.

Case 3

This minimises the generation cost without taking the RES into account. In this instance, the minimised generation cost was 17,014¥, roughly double that of Case 1. This increase is due to both the stream in penalized emission costs and the enhanced fuel expenses for generators, which were consumed more frequently owing to the absence RES. Among the other LP studied, logarithmic based LP reduced the generation cost further to 1551¥ and the same is shown in Fig. 10.

Fig. 10
figure 10

Minimum generation cost for logarithmic based load profile during Case 3.

Case 4

Examining the grid’s fixed price behaviour is the last and fourth stage in developing Case 1. As seen in Fig. 3, this is accomplished by taking the mean of the price of electricity for a full day. In this instance, GRSO yielded a minimum generating cost of 939¥ for the base load profile, and it exceeds the price evaluation for Case 1. By contrasting Cases 1& 4, it is also possible to verify that, in addition to the grid’s energetic contribution, the behaviour of electricity pricing is a significant factor in reducing a distribution system’s generation cost. Among the other load profiles studied, CPP based LP reduced the generation cost further to 802¥ as shown in Table 3 and the hourly load sharing amongst the DERs are shown in Fig. 11.

Fig. 11
figure 11

Minimum generation cost for CPP based load profile during Case 4.

Table 3 Comparative cost analysis for different cases with existing literature.

The logarithmic based LP was responsible for the minimum generation cost during Cases 2 and 3 and the CPP based LP was responsible for the minimum generation cost during Cases 1 and 2 respectively. For the other LPs, although the minimum generation cost was less than the base LP, but they weren’t the least expected ones. A ranking table shown in Table 4 displays the ranks of the LPs where the lowest rank means that the LP delivered the minimum generation cost for maximum cases compared to the rest of them.

Table 4 Rank-wise distribution of various LP in providing the minimized generation cost compared to the base LP.

Exhaustive analysis of the system

Table 1 mentions that the upstream limit of the grid is 80 kW, i.e. the grid can sell up to 80 kW an hour. This is more than twice the downstream limit of the grid which is 30 kW only. In other words, the grid is acting as an infinite source of power for the subject microgrid system. This analysis studies the scenario when the upstream and downstream limit of the grid is same (30 kW). All the previous four cases are evaluated gradually, and the minimum generation cost obtained using GRSO is recorded. Table 3 shows that the minimum generation costs of the system when the upstream capacity of the grid is limited to 30 kW are 948¥, 1055¥, 1800¥ and 977¥ for cases 1 to 4 respectively. Approximately 7% increment in the generation cost is observed for all the cases when the grid is restricted to transact power within 30 kW.

Grid participation for various cases

The hourly active power output of the grid was analyzed across all load profiles (LPs) in Case 1, as well as for the scenario where the grid’s upstream power flow was limited. Figure 12 illustrates the grid’s active participation in buying and selling power throughout the 24-hour period. During peak load hours (19 to 24), the grid primarily supplies power to the microgrid system, while for the remaining hours, it either buys back power or engages in minimal power sales. In the scenario where grid participation is restricted, the grid’s buying and selling transactions do not exceed 30 kW. Figure 13 displays the total power bought and sold by the grid for all LPs during Case 1. The highest levels of transactions between the grid and the microgrid system were observed for the base, real-time pricing (RTP), exponential, and hyperbolic-based LPs, whereas the lowest transaction volume occurred with the logarithmic-based LP. Positive values in Fig. 13 indicate that the grid sold power at the end of the day, while a negative value, representing 133 kW, reflects the amount of power the grid bought by the end of the day in the limited upstreaming power scenario. Total load demand transactions between grid and system during Case 1 is shown in Fig. 14.

Fig. 12
figure 12

Hourly load sharing by grid for various load profiles and cases.

Fig. 13
figure 13

Load demand transactions between grid and microgrid system during Case 1.

Fig. 14
figure 14

Total load demand transactions between grid and system during Case 1.

Table 5 Central Tendency measures for optimum generation cost in Case 1 and case 3.

Due to the stochastic nature of the random numbers employed in the mathematical modeling, the Greedy Rat Swarm Optimizer (GRSO) was executed 30 times for each case to ensure comprehensive data collection on generation costs and algorithm execution times, allowing for the maximum number of iterations. The characteristics of the convergence curves, as shown in Figs. 15 and 16, illustrate the GRSO’s performance in determining the minimum generation costs for both the base load profile (LP) and the critical peak pricing (CPP)-based LP. Table 5 presents the statistical evaluation of the GRSO’s resilience and effectiveness, based on the simulated results from these trials. The findings reflect the consistency and robustness of the algorithm under various scenarios. Finally, after 30 trials, Fig. 17 displays box plot representations for the base load requirements in each scenario, providing a visual summary of the distribution of outcomes and reinforcing the algorithm’s performance in optimizing generation costs.

Fig. 15
figure 15

Cost convergence curve with GRSO for base LP (Case 1).

Fig. 16
figure 16

Cost convergence curve with GRSO for CPP based LP (Case 1).

Fig. 17
figure 17

Box plot representation for base LP using GRSO.

Conclusion and future research directions

The proposed framework for microgrid energy management, incorporating flexible price-elastic demand response models and the Greedy Rat Swarm Optimizer (GRSO), provides a robust and efficient solution to the challenges of microgrid optimization. The integration of diverse demand response programs, such as time-of-use (TOU), real-time pricing (RTP), and critical peak pricing (CPP), allowed for a more dynamic and accurate response to market price fluctuations. Our results show that the GRSO-based optimization framework successfully minimized generation costs and reduced peak loads across various scenarios. Key outcomes demonstrate significant improvements in both cost and environmental performance. For the base case scenario, without demand response programs, the generation cost was reduced to 882¥, with a further reduction to 746¥ using the CPP-based load profile. Additionally, a 15.4% decrease in generation cost and an improvement of up to 87.7% in the load factor were achieved, highlighting the effectiveness of flexible demand response integration. Notably, when grid participation was limited, the logarithmic load profile resulted in a generation cost of 817¥, further underscoring the importance of grid interaction. The study also demonstrates the robustness of the GRSO algorithm in managing the complexity of microgrid systems, achieving consistent results across multiple trials while improving computational efficiency and convergence time. By evaluating four distinct operational cases, this work offers a comprehensive analysis of how different load profiles and grid participation levels affect both economic and environmental outcomes. In conclusion, this research highlights the potential of combining price-elastic demand response strategies with advanced metaheuristic optimization techniques to enhance the cost-efficiency and sustainability of microgrids. The insights gained can inform future microgrid management practices and contribute to the development of more resilient and environmentally friendly energy systems.

Building upon the findings of this study, several potential avenues for future research are worth exploring. First, further development and refinement of demand response programs (DRPs) can be pursued, particularly by incorporating more sophisticated load models that account for behavioural factors, such as consumer preferences and elasticity in response to time-varying pricing schemes. These advanced models could enhance the accuracy of demand forecasts and provide more granular insights into consumer engagement with price-based DRPs. Second, the integration of additional renewable energy sources, such as biomass, geothermal, and advanced storage systems (e.g., hydrogen storage or second-life electric vehicle batteries), could provide a more comprehensive understanding of how different energy sources interact within a microgrid. By modelling the impact of diverse renewable sources, researchers could better address the intermittent nature of renewables and optimize the use of various DERs in achieving cost-efficiency and system reliability. Third, expanding the current optimization framework to include multi-objective functions that simultaneously optimize factors such as power quality, voltage stability, and system resiliency alongside cost and environmental impact would enhance the robustness of microgrid operation strategies. The development of hybrid algorithms that combine GRSO with other advanced techniques, such as machine learning models for load prediction or reinforcement learning for adaptive energy management, could further improve microgrid efficiency. Additionally, future studies could explore real-time optimization approaches for microgrids that operate under highly dynamic conditions, such as those frequently impacted by weather changes or fluctuating energy market prices. Incorporating real-time data streams and enhancing the decision-making process through advanced forecasting techniques would enable microgrids to better respond to short-term variations in load and resource availability.