1. Introduction
The growing integration of photovoltaic (PV) systems into modern power grids has emphasized the need for advanced control strategies capable of addressing the inherent uncertainties in solar generation and load demand. PV output is highly intermittent, depending on weather conditions such as irradiance and temperature, which fluctuate over time [
1,
2,
3]. Similarly, load profiles vary due to consumer behavior and other external factors, introducing additional uncertainty into grid operations [
4].
Model Predictive Control (MPC) has emerged as a powerful method for managing constrained dynamical systems, including power converters and energy storage devices. It solves an optimization problem over a prediction horizon, applying only the first control action at each step, in a receding-horizon fashion [
5]. MPC’s ability to handle multi-variable systems with constraints makes it particularly attractive for energy applications, such as PV-grid integration [
6], quasi-Z-source inverters [
7], and converters with delay compensation [
8,
9]. However, classical MPC formulations typically rely on deterministic forecasts, limiting their ability to manage the uncertainty intrinsic to PV generation and demand [
10,
11].
To overcome these limitations, stochastic MPC (SMPC) formulations introduce chance constraints, which ensure that system constraints are satisfied with high probability. These methods incorporate probabilistic models of solar irradiance and load profiles, enabling more robust and risk-aware decision-making. Concepts such as Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) are increasingly employed to quantify and manage the risks associated with uncertainty in energy systems [
12,
13].
Recent studies have demonstrated the benefits of predictive control under uncertainty. For instance, the authors of [
14] applied SMPC to quasi-Z-source inverters, improving dynamic response and grid stability. Similarly, the authors of [
15] developed a hierarchical control scheme using distributed optimization (e.g., ADMM) to coordinate PV and battery systems in real-time. In [
16], deterministic MPC and stochastic dual dynamic programming (SDDP) were compared, highlighting the performance advantage of stochastic methods in cost and reliability.
Nevertheless, gaps remain in integrating chance constraints with flexible active power control (FAPC), nonlinear inverter behavior, and power quality improvements. This paper addresses these gaps by proposing a unified stochastic MPC framework that combines three key dimensions: (i) probabilistic reliability through chance-constrained optimization, (ii) hierarchical coordination between global reference setting and local inverter control, and (iii) harmonic compensation using
p–
q theory. While prior works have explored subsets of these aspects—such as SMPC for economic dispatch [
14], or local power quality enhancement [
15]—few have tackled their integration into a single predictive control architecture. This coordination across forecast, control, and power quality layers is the main novelty of our approach.
Unlike prior works that focus on isolated aspects—such as uncertainty modeling or inverter-level control—this framework offers an integrated approach that jointly addresses uncertainty, decentralized control, and power quality. It builds upon insights from studies like [
17], and extends them through a robust, risk-aware predictive control strategy.
In summary, the proposed methodology provides a comprehensive solution to the pressing challenges of reliability, efficiency, and quality in modern PV-powered grids. It enables effective integration of distributed solar energy resources in increasingly complex and uncertain energy environments.
All results presented in this paper are obtained through simulation, and no physical experiments are performed. This design choice allows for the safe and scalable evaluation of control strategies under multiple configurations and fault scenarios.
The remainder of this paper is organized as follows.
Section 2 reviews the current state of the art in stochastic control for photovoltaic systems, including recent developments in decentralized MPPT and power quality management.
Section 3 describes the PV system and its components.
Section 4 presents the SMPC formulation, incorporating chance constraints and VaR techniques.
Section 5 discusses simulation results and performance metrics under realistic operating conditions. Finally,
Section 6 concludes the paper and outlines future research directions.
4. Stochastic MPC Framework
To address the challenges posed by variability in solar generation and uncertainty in load demand, this section presents an SMPC framework tailored for PV systems. The proposed approach integrates forecasting, energy storage dynamics, inverter control, and power quality compensation within a unified predictive framework. By incorporating probabilistic constraints, the SMPC ensures reliable operation under uncertainty while optimizing system performance across multiple objectives.
4.1. Component Models
The PV output power
at time
t is computed as:
where
is panel efficiency,
A is surface area, and
is the angle of incidence.
Battery dynamics are modeled by the state of charge (SOC):
where
and
are the charging/discharging powers, and
is battery capacity.
To account for battery degradation and ensure realistic operation, we imposed a constraint on the depth of discharge (DoD). For the lithium-ion battery technology assumed in this study, we limited the minimum SOC to 20% of the total capacity, corresponding to a maximum DoD of 80%. This was implemented as a state constraint in the MPC formulation to ensure that the battery operates within safe and sustainable limits:
Inverter output is given by:
where
denotes inverter efficiency.
To capture forecast uncertainty in both generation and demand, we model these quantities as independent Gaussian random variables at each time step. Specifically, we define:
as the forecasted solar power generation at time t, modeled in kilowatts (kW).
as the mean forecasted solar generation (kW), obtained from historical data or a trained predictor.
as the standard deviation of the solar forecast (kW), representing uncertainty.
as the forecasted power demand at time t (kW).
and as the respective mean and standard deviation of the demand forecast (both in kW).
These variables are assumed to follow Gaussian distributions:
It is important to note that while Gaussian distributions were adopted for both solar and demand uncertainties to maintain the convexity of the optimization problem, real-world solar irradiance may follow skewed or bimodal distributions. Empirical studies have shown that Beta and Weibull distributions often provide better fits for irradiance data under cloudy or variable conditions [
24,
25]. Incorporating such models into SMPC is a promising direction, but may require reformulating the optimization problem as non-convex or relying on scenario-based approaches.
4.2. Classical MPC Baseline Formulation
To provide a transparent and reproducible comparison with the proposed stochastic MPC, this subsection presents the deterministic Model Predictive Control (MPC) baseline used throughout the simulations. The classical MPC relies exclusively on point forecasts of solar generation and load demand, without incorporating uncertainty margins or probabilistic constraints.
The controller minimizes operational costs over a prediction horizon of
N, balancing photovoltaic generation, battery charging and discharging, and penalties for unmet demand. The optimization problem is defined as:
where
,
,
, and
denote photovoltaic power, battery charging and discharging power, and unmet demand at time
t, respectively.
Cost Weight Sensitivity
The weighting parameter in the cost function balances two competing objectives: minimizing energy tracking error and reducing battery stress due to excessive cycling. In this study, we selected after empirical testing and benchmarking with prior works using similar objectives.
To validate this choice, we performed a sensitivity analysis by varying and evaluating the resulting performance in terms of energy efficiency, SOC variation, and unmet demand penalties. The results indicate that:
- -
Values below 0.1 cause aggressive battery usage, increasing degradation without significantly improving energy delivery.
- -
Values above 0.4 overly penalize battery cycling, leading to insufficient energy supply during peak demand.
- -
The range provides an optimal trade-off between reliability and battery lifetime.
These results confirm that the chosen value offers robustness and operational consistency under realistic conditions.
The system must satisfy the energy balance:
as well as the battery dynamics:
with operational constraints:
and
together with:
The classical MPC uses deterministic forecasts:
and does not account for deviations or uncertainty. This formulation serves as a reference benchmark to evaluate the benefits introduced by the stochastic MPC framework presented in the following subsections.
4.3. LSTM-Based Forecasting Model for Solar Irradiance
Accurate forecasts of solar irradiance are fundamental for the performance of the proposed SMPC scheme. To generate mean () and variance () estimates for the chance constraints, we employ a Long Short-Term Memory (LSTM) neural network trained on historical irradiance data.
4.3.1. Dataset and Preprocessing
The model was trained using hourly irradiance data obtained from the PVGIS database covering the years 2019–2022 for the region of Andalusia (Spain). The dataset contains approximately 35,000 samples. Data were normalized using min–max scaling and segmented into 70% training, 15% validation, and 15% testing.
4.3.2. Network Architecture
The LSTM model consists of:
One sequence input layer with a 24-h input window;
One LSTM layer with 64 units and tanh activation;
One dropout layer with rate 0.2 to prevent overfitting;
One fully connected layer;
One regression output layer predicting irradiance at .
The training process used the Adam optimizer with a learning rate of , a batch size of 64, and 50 epochs. Early stopping was employed based on validation loss.
4.3.3. Forecasting Performance
Table 2 summarizes the forecasting accuracy on the test dataset. The LSTM model achieves sufficiently low prediction errors for use within the SMPC framework, particularly in generating the statistical parameters
and
required by the VaR constraints.
The LSTM model provides both the mean prediction and an empirical estimate of the prediction variance derived from residuals, which are used to parameterize the Gaussian disturbances in the stochastic formulation. While neural-network-based forecasting is not the primary contribution of this paper, including these details enhances reproducibility and supports the validity of the uncertainty model.
4.4. High-Level MPC Controller
At the core of the energy management architecture is an MPC controller, responsible for making optimal decisions at the system level over a finite prediction horizon N. The high-level controller receives forecasts of solar generation and load demand and determines optimal control actions such as energy extraction from PV modules, charging and discharging levels of the battery, and the amount of unmet demand to be minimized. These actions aim to minimize a cost function that balances the cost of generation, the cost and reward of storage usage, and penalties for not meeting demand, while satisfying system dynamics and operational constraints.
The decision variables involved in this control process are
(power generated by the PV panels),
(charging power to the battery),
(discharging power from the battery), and
(unmet demand). The key parameters include
for generation cost,
and
for storage operation,
as the penalty coefficient, and
representing the risk tolerance in the chance constraints. The optimization problem is formulated as:
To robustly manage uncertainty in solar generation and load demand, the proposed MPC framework employs chance constraints reformulated using the VaR concept. Unlike deterministic approaches that rely solely on mean forecasts, this probabilistic formulation ensures that system constraints are satisfied with high confidence, even in the presence of stochastic disturbances. In particular, both solar generation and energy demand are modeled as Gaussian random variables characterized by a mean (
) and standard deviation (
). The VaR formulation sets conservative bounds based on a predefined confidence level
, using the quantile
from the standard normal distribution. The chance-constrained formulation extends previous work such as [
14], adapting it to include harmonic constraints and inverter dynamics.
The lower bound for available generation is given by:
and the upper bound for expected demand is expressed as:
The values of
and
for the uncertain inputs (solar irradiance and load demand) are estimated from historical measurements using a sliding time window of 7 days, with updates performed hourly. The method uses a persistence-corrected forecast with adaptive trend learning to capture short-term variations, which has shown adequate performance in prior studies on PV forecasting [
26,
27].
While the Gaussian assumption simplifies the formulation of chance constraints and allows for analytical reformulation, it is recognized that real-world solar irradiance can present bimodal or skewed distributions, especially in regions with intermittent cloud cover. This assumption introduces a modeling simplification; however, previous works have demonstrated that using Gaussian-based forecasts can still provide robust performance in energy management applications [
28]. A more detailed treatment of non-Gaussian uncertainty models (e.g., using beta or empirical distributions) is left for future work.
4.4.1. Inverter Saturation and Ramp Limits
The inverter output is constrained not only by its rated capacity but also by its allowable ramping behavior. Let
denote the inverter’s active power output at time
t. The following constraints are introduced to reflect inverter hardware limitations:
where
is the rated power capacity of the inverter and
is the maximum allowable ramp rate between control intervals (e.g., 0.2 kW per 5 min). These constraints are now included in the optimization problem to ensure that dispatch commands remain within operational limits.
4.4.2. Discussion on Independence and Joint Constraints
The VaR-based probabilistic constraints in this work are formulated as individual chance constraints for solar generation and demand uncertainty. This formulation enables tractable second-order cone approximations and has been widely used in SMPC literature. However, we acknowledge that assuming statistical independence between solar generation and demand is a simplification. In reality, weak correlations may exist, such as reduced demand at night or behavioral shifts aligned with solar availability.
Modeling joint chance constraints would require knowledge of the joint distribution of these uncertainties. Techniques such as copula modeling, scenario sampling, or distributionally robust formulations could be considered in future work. While our current approach enables real-time implementation, it may introduce mild conservatism or risk underestimation when correlations are strong.
Addressing joint uncertainty structures represents a valuable direction for future extensions of the proposed framework, particularly in settings where load patterns are explicitly weather-dependent.
4.5. Local Control Loops: MPPT, PWM Modulation, and Load Logic
Each inverter is equipped with local control strategies that operate independently of the central MPC. These include MPPT algorithms to maximize energy harvesting, pulse-width modulation (PWM) to synthesize high-quality AC voltage, and logic-based load management.
MPPT ensures that each panel operates at its optimal power point. This is typically achieved using either P&O or Incremental Conductance methods. In the P&O approach, the controller perturbs the voltage and observes the effect on power output, adjusting the operating point iteratively. In Incremental Conductance, the derivative of the current with respect to voltage is calculated, and the controller identifies the maximum point when
. The local MPPT control is based on a classical perturb and observe (P&O) method as described in [
29].
For grid interfacing, PWM is used to control the inverter switches. A reference signal is compared with a high-frequency triangular waveform to generate switching pulses. The modulation index determines the amplitude of the output waveform and influences the power quality and harmonic content.
The load management logic evaluates the state of charge (SOC) and determines which controllable loads can be activated. If the SOC exceeds a predefined threshold
, the load
is turned on; otherwise, it remains off. The control rule is:
4.5.1. MPPT Dynamics and Comparison
The Perturb and Observe (P&O) algorithm was selected for its simplicity and low computational burden in embedded systems. However, it is known to exhibit oscillations near the MPP and slower convergence under dynamic irradiance conditions. As an alternative, the Incremental Conductance (InC) method can provide faster tracking and better performance under rapidly changing conditions due to its use of instantaneous current–voltage derivatives [
29].
While InC offers superior dynamic response, its implementation requires more accurate sensing and higher sampling rates. Given the relatively slow variations modeled in this study (5 min control intervals), P&O was sufficient to capture the key trends and interactions with the SMPC layer. Nonetheless, the integration of InC or other adaptive MPPT strategies will be considered in future real-time deployments.
4.5.2. Limitations Under Partial Shading
It is well known that under partial shading conditions, the power-voltage (P–V) curve of a PV array may exhibit multiple local maxima. Traditional MPPT algorithms such as P&O are gradient-based and tend to converge to the nearest local maximum, which may result in suboptimal energy harvesting.
Although this study did not model partial shading explicitly, we acknowledge that it represents a significant challenge for real-world PV systems. Advanced MPPT techniques—such as Particle Swarm Optimization (PSO), Differential Evolution (DE), and hybrid heuristic–deterministic strategies—have been proposed in the literature to address this issue [
30]. Future extensions of this work will consider such algorithms to enhance robustness under complex irradiance patterns.
4.6. Hierarchical Coordination Architecture
The proposed framework employs a hierarchical control architecture, where the centralized SMPC serves as a high-level decision-making layer, providing operational references to a set of local inverter controllers. Every 5 min, the SMPC computes and transmits to each inverter: (1) a power injection reference and (2) a harmonic distortion bound . These references are generated considering global objectives such as energy balance, forecast uncertainty, and storage constraints.
The local controllers execute at a much faster time scale (100 ms), using the received as an upper limit for power injection, and enforcing harmonic limits via local current control based on the theory. MPPT is performed locally to track irradiance fluctuations within the global constraints.
To prevent conflicts, the SMPC reserves dynamic headroom in power capacity for the local controllers, ensuring that the local MPPT and harmonic compensators can act without saturating the inverter or violating system constraints. This decouples slow-scale optimization from fast-scale control, maintaining feasibility and allowing real-time operation. Communication is unidirectional and event-driven, which reduces bandwidth requirements and improves robustness to delays.
MPPT Methods and Practical Considerations
MPPT algorithms play a critical role in local control strategies, ensuring that each PV module operates at its optimal power output despite variations in irradiance and temperature. Among the most widely adopted methods are Perturb and Observe (P&O) and Incremental Conductance (InC). The P&O algorithm perturbs the operating voltage of the PV module and observes the corresponding change in power. If power increases, the perturbation continues in the same direction; otherwise, it reverses. While simple to implement, P&O suffers from steady-state oscillations and reduced performance under rapidly changing environmental conditions [
29].
In contrast, the InC method calculates the derivative of current with respect to voltage,
, and compares it to the instantaneous conductance
to locate the maximum power point (MPP). When these values are equal, the system is operating at the MPP. This method offers improved accuracy and dynamic response but at the cost of increased computational complexity and sensor requirements [
31].
The selection of MPPT algorithm depends on the trade-off between response time, stability, and implementation cost. In this work, the decentralized controllers use the InC algorithm due to its superior accuracy in tracking the MPP under stochastic irradiance profiles, as evidenced in scenarios with high-frequency cloud transients [
32].
Moreover, to reduce switching losses and improve efficiency, the MPPT is updated at a slower frequency than the PWM loop, typically every 200–500 ms. Future enhancements could include adaptive MPPT strategies that change behavior based on detected irradiance variability or hybrid approaches combining neural estimators with traditional control [
33].
Figure 2 illustrates the dynamic tracking behavior of two widely-used MPPT algorithms—P&O and INC—under varying irradiance conditions. The ideal maximum power point (MPP), shown as a dashed gray line, serves as a reference for evaluating the tracking performance.
The P&O algorithm exhibits visible oscillations around the MPP, particularly during steady irradiance conditions. These oscillations are a known drawback of the method, caused by its inability to determine the optimal direction of perturbation under fast-changing environmental conditions. In contrast, the InC algorithm follows the MPP more closely with significantly smaller deviations, demonstrating its robustness and superior dynamic response.
This performance advantage becomes especially important under the stochastic generation patterns typical of PV systems, where rapid fluctuations in irradiance can degrade system efficiency. The simulation confirms that the InC method achieves a smoother and more reliable power output, making it more suitable for the proposed decentralized control framework.
4.7. Harmonic Compensation Using Instantaneous Power Theory
The harmonic compensation strategy is based on the instantaneous power (p–q) theory, which is applicable under the assumption of a three-phase, three-wire, balanced system [
34]. The Clarke transformation is used to obtain the
–
components of the voltage and current, from which the instantaneous active and reactive power are computed.
Note: The use of p–q theory is not directly applicable to single-phase systems, as it relies on orthogonal components derived from three-phase signals. For single-phase applications, alternative harmonic mitigation techniques such as enhanced PLLs, adaptive notch filters, or second-order generalized integrators (SOGI) would be required [
35]. This study focuses on a three-phase PV system, which is common in grid-connected commercial setups.
4.8. Power Quality Compensation via p–q Theory
Maintaining power quality is crucial in PV-powered systems, especially under nonlinear load conditions that introduce harmonic currents into the grid. The proposed framework implements harmonic compensation using the instantaneous power theory (
p–
q theory), allowing local inverters to act as active filters. The harmonic compensation strategy is based on the
p–
q instantaneous power theory, as introduced in [
36].
The compensation targets current harmonics up to the 13th order, including the dominant low-order harmonics (3rd, 5th, 7th, 9th, 11th, and 13th), which are commonly observed in systems with electronic loads. Voltage and current signals are transformed to
coordinates via Clarke transformation, and the instantaneous powers
p and
q are computed as:
To isolate the harmonic content, a low-pass filter (with a bandwidth of 300–500 Hz) extracts the fundamental components from p and q. The high-frequency components are then used to calculate compensating currents, which are injected by the inverter to neutralize harmonics.
The local control loop operates at 10 kHz, ensuring real-time compensation. The MPPT algorithm runs at a slower rate (1 kHz), and its output is combined with the harmonic reference in the current loop. This additive structure allows both objectives (power maximization and quality) to coexist without interference, ensuring that the inverter remains within its operating limits.
This method transforms each inverter into a dual-function agent: delivering clean power and acting as an active power filter.
4.9. Hierarchical Architecture
The system architecture integrates both centralized and decentralized control strategies in a hierarchical structure. The centralized MPC optimizes long-term operational goals and manages uncertainty, while local controllers execute rapid control actions in real time, ensuring system responsiveness and stability. This coordination is illustrated in
Figure 3, which presents the flow of decisions from forecast-driven optimization to inverter-level actuation and local logic.
5. Results and Discussion
This section presents a detailed evaluation of the proposed SMPC framework through simulation studies, performance analysis, and economic assessment. The results are compared with a classical deterministic MPC to highlight the benefits of incorporating stochastic modeling and decentralized control.
The simulations were conducted to evaluate the proposed stochastic MPC framework under realistic operating conditions. The prediction horizon was set to h, repeated over a total simulation time of 48 h. Solar irradiance data was modeled based on historical records, introducing stochastic variations using a normal distribution , where represents the average irradiance for each hour, and accounts for weather-related uncertainty.
Demand profiles were generated using typical residential consumption patterns, also modeled as . The photovoltaic panels were characterized by an efficiency of , a total surface area of , and a maximum power output of . The battery storage system had a capacity of , with charging and discharging efficiencies of and , respectively. Inverters were modeled with an efficiency of .
5.1. Performance Overview
This subsection provides a high-level overview of the performance indicators used to evaluate the proposed SMPC framework. Four key metrics are considered throughout the analysis:
Energy efficiency, reflecting how effectively the system utilizes available photovoltaic and storage resources.
Demand satisfaction, measuring the system’s ability to meet energy demand under uncertainty.
Power quality, assessed via THD to quantify waveform distortion and harmonic compensation.
Resilience, indicating the controller’s robustness under partial system faults or disturbances.
Figure 4 offers a comparative summary of these metrics between the proposed SMPC and a classical deterministic MPC. Each aspect is discussed in detail in the following subsections. As seen in
Figure 4, the proposed SMPC achieves substantial improvements across all performance indicators. Specifically, energy efficiency increases from 78% to 85%, constraint satisfaction improves from 85% to 96%, THD is reduced by 25%, and resilience (measured as energy supply under fault) improves by 10%. These results confirm that the SMPC provides superior control performance compared to the classical MPC baseline.
5.2. Energy Efficiency and SOC Management
Figure 5 illustrates the battery state-of-charge (SOC) profile under the proposed SMPC controller. The solid line represents the average SOC across 100 stochastic simulations, while the shaded region indicates ±1 standard deviation. This representation highlights the stability of the control strategy in the face of uncertainty.
5.3. Power Quality Improvement (THD Reduction)
Maintaining power quality is essential in photovoltaic systems, especially under nonlinear load conditions and fluctuating generation. The proposed SMPC integrates harmonic compensation based on instantaneous power theory (p–q), allowing each inverter to inject corrective currents and reduce waveform distortion in real-time.
Although the time-domain evolution of total harmonic distortion (THD) was omitted for brevity,
Table 3 summarizes average THD values under several representative scenarios. Across all operating conditions—including nominal operation, irradiance variability, and grid disturbances—the SMPC consistently achieves lower distortion compared to the classical MPC. On average, the proposed method reduces THD by more than 25%, confirming the effectiveness of the decentralized compensation strategy.
To support the reported reduction in total harmonic distortion (THD),
Figure 6 shows the FFT of the inverter output current under two scenarios: with and without the harmonic compensation strategy implemented in the local controller. The compensation effectively attenuates the 3rd, 5th, and 7th harmonic components, which are dominant due to nonlinear loads. This confirms the effectiveness of the
p–
q theory-based control in improving power quality.
5.4. Resilience Under Fault Conditions
To assess the fault tolerance of the proposed SMPC, we simulate a sequence of partial fault scenarios. Each fault is modeled as a stepwise reduction in the output availability of one or more inverters, representing either hardware degradation or communication failures. The availability is reduced in steps: 100%, 80%, 60%, 40%, and 20%, with each level lasting one hour. These constraints are imposed on the inverter active power limits, indirectly reflecting the impact of limited current supply or impedance-related constraints.
No explicit fault in impedance or wiring is modeled, but the output current limits include thermal margins and protective headroom. This method emulates realistic conditions while keeping the simulation tractable. The impact of these faults on total energy supply is evaluated under both classical MPC and the proposed SMPC.
Figure 7 shows that the SMPC maintains significantly higher energy delivery under degraded conditions, confirming its resilience.
5.5. Impact of Battery Capacity on System Performance
To evaluate the sensitivity of the SMPC framework to battery sizing, we tested three different storage capacities—5 kWh, 10 kWh, and 20 kWh—while keeping all other system parameters fixed. For each configuration, we measured key performance indicators including energy efficiency, constraint satisfaction, and total harmonic distortion (THD).
Table 4 shows the disaggregated performance metrics for three different battery capacities: 5, 10, and 20 kWh. Each value represents the mean and standard deviation over 100 stochastic simulations. As expected, increasing the storage capacity improves energy efficiency and constraint satisfaction, with a moderate benefit in harmonic performance. This result confirms the value of sizing storage appropriately in PV systems managed with predictive control.
5.6. Statistical Validation via Monte Carlo Simulations
To strengthen the reliability of the results and address the reviewer’s concern regarding statistical significance, we conducted a Monte Carlo simulation study consisting of 100 independent runs. Each run used randomized realizations of solar irradiance and demand profiles, generated according to the statistical distributions employed in the SMPC formulation. For every simulation, we computed three key performance metrics: energy efficiency, constraint satisfaction, and total harmonic distortion (THD).
Table 5 summarizes the mean and standard deviation of these metrics for both the classical MPC and the proposed SMPC. The improvements observed in the nominal simulations remain consistent across all 100 runs. Specifically, the SMPC achieves higher efficiency (85% ± 2.6%), improved constraint satisfaction (96% ± 2.0%), and reduced harmonic distortion (3.5% ± 0.4). In contrast, the classical MPC shows lower average performance and higher variability.
Figure 8 provides boxplots for the three metrics, offering a visual illustration of distribution spread and median performance. The results clearly demonstrate that improvements achieved by SMPC are robust and statistically significant, with non-overlapping interquartile ranges in all performance indicators. A two-sample
t-test confirms statistical significance at the 95% confidence level (
) for all metrics.
These results validate that the advantages of the proposed SMPC framework are not due to chance but remain stable under uncertainty and repeated stochastic realizations.
In addition, 95% confidence intervals (CI) were computed for each performance metric using the expression:
For energy efficiency, the SMPC achieved a 95% CI of [84.49%, 85.51%], while the classical MPC obtained [77.39%, 78.61%]. Constraint satisfaction showed intervals of [95.61%, 96.39%] for SMPC and [84.51%, 85.49%] for classical MPC. Regarding THD, the SMPC interval was [3.42%, 3.58%], in contrast to [4.58%, 4.82%] for the classical MPC.
These non-overlapping confidence intervals confirm the statistical significance of the performance improvements reported in this study.
5.7. Scalability Considerations
The scalability of the proposed SMPC framework depends on the size of the optimization problem, communication needs, and real-time solvability. The number of variables and constraints grows linearly with the number of distributed inverters. For systems with up to 20 units and a prediction horizon of , the problem remains tractable, with solve times of around 57 ms per iteration using Gurobi on a standard processor.
Communication overhead is minimal, requiring only two scalar values (power and THD references) per inverter every 5 min. This supports scalability under current update rates. However, larger systems or those operating at higher communication frequencies may require more efficient protocols.
The current centralized formulation is well-suited for small- to medium-sized microgrids. Scaling to 50 or more units would likely exceed real-time limits, motivating future extensions via distributed or hierarchical MPC strategies, such as ADMM or consensus-based coordination. These would enable deployment in larger community energy systems without compromising performance.
Given the current computational benchmarks, the proposed SMPC architecture is suitable for small-to-medium PV microgrids comprising up to 20 distributed units, as demonstrated in our simulation setup. Beyond this threshold, centralized optimization may become too computationally demanding for real-time execution. Therefore, while the current results validate the feasibility of the proposed approach for moderate system sizes, future work will explore distributed or hierarchical SMPC formulations for large-scale implementations.
5.8. Computational Complexity and Real-Time Feasibility
The practical deployment of advanced predictive controllers in photovoltaic (PV) systems is constrained by their real-time execution requirements. Controllers must compute optimal control actions within a short time window, typically below 500 ms for systems with sampling intervals between 1 and 5 min. This allows time for data acquisition, communication delays, and actuation.
The proposed SMPC framework solves a convex quadratic program (QP) with probabilistic constraints transformed via VaR. Despite the added modeling complexity, the problem remains tractable. Using MATLAB 2023a, YALMIP, and Gurobi 10.0, the average execution time per control step was approximately 57 ms on a standard processor (Intel Core i7-1185G7, 16 GB RAM).
These results indicate that the controller meets real-time feasibility requirements for medium-scale PV applications. Additionally, recent benchmarks show that embedded platforms such as the Raspberry Pi 4 (ARM Cortex-A72, 1.5 GHz) can solve similar QP problems in under 150 ms using optimized single-core execution [
37]. Likewise, digital signal processors (DSPs) from the TI C2000 family have been successfully used for QP-based control in power electronics, operating within 100–200 ms.
To further reduce computational overhead, strategies such as warm-starting, reduced-order modeling, or offline scenario pre-generation can be applied. These enhancements enable the proposed SMPC framework to scale to larger systems or operate at higher control frequencies if needed.
5.9. Comparative Review Against Existing Methods
The simulation framework systematically evaluates energy efficiency, constraint satisfaction, THD, and resilience across 27 combinations of system parameters. The Proposed MPC consistently outperforms the classical MPC across all criteria.
Compared to existing works, such as [
14,
16], which focused solely on generation-cost minimization or deterministic demand models, our framework includes chance-constrained reliability and harmonic compensation. While [
14] achieved cost improvements through SMPC, their approach lacked power quality guarantees. The work [
15] presented a hierarchical MPC, but it did not incorporate uncertainty models. Our method integrates robust control, decentralized MPPT, and
p–
q compensation, offering a more holistic strategy for PV system optimization.
To further contextualize the performance of the proposed SMPC framework, we implemented a classical PID controller for comparison. This allows benchmarking against conventional control schemes often used in inverter-based systems.
5.10. Comparison with PID Control
The PID controller was configured to track a time-varying active power reference. Gains were manually tuned to reduce steady-state error under nominal conditions, but the controller does not handle system constraints or forecast uncertainty.
Figure 9 illustrates the power tracking behavior of the PID and SMPC controllers. While the PID performs acceptably under stable conditions, it fails to maintain performance during rapid changes in demand or variable irradiance. In contrast, the SMPC accurately tracks the reference and enforces operational constraints.
Table 6 summarizes the quantitative results. The proposed SMPC shows superior energy efficiency, constraint satisfaction, and lower harmonic distortion. Notably, the PID controller violates SOC limits and introduces greater tracking error.
These results confirm that the proposed SMPC significantly enhances PV system operation, particularly under uncertainty and operational constraints. Although PID remains useful in simple applications, it lacks the predictive and optimization capabilities needed for resilient and high-performance microgrids.
In addition to the baseline comparisons made earlier, we now contrast our SMPC framework with widely used techniques such as PID and fuzzy control. PID controllers, while simple and effective for steady-state regulation, are limited in their ability to handle multivariable interactions, constraints, and uncertainty—resulting in lower energy efficiency and higher tracking errors, as confirmed in our experiments (see
Table 6). Fuzzy controllers, such as those used in [
38], offer some degree of robustness and adaptation; however, they are often rule-based and challenging to scale or optimize systematically, especially in large microgrids. In contrast, our approach integrates forecasts, storage dynamics, harmonic compensation, and constraint handling in a unified mathematical framework that is directly scalable and tunable. Recent works, such as [
14,
15], offer partial solutions, e.g., hierarchical MPC or SMPC for cost, but do not address harmonics or decentralized inverters. Our results show superior performance across multiple metrics (efficiency, THD, resilience), confirming the advantages of this integrated strategy.
In addition to the numerical comparisons already presented, it is important to contextualize the performance of the proposed SMPC with results from other control techniques reported in the literature. Fuzzy controllers, such as those in [
38], can handle nonlinearities but lack a predictive mechanism and often require extensive rule tuning, which limits their scalability. Reported reductions in unmet demand or THD typically remain below 10–15%, considerably lower than the improvements achieved by our SMPC (11% improvement in demand satisfaction and 25% reduction in THD). PID controllers, widely used in inverter control [
39], provide acceptable tracking under steady-state conditions but deteriorate significantly under variability, as confirmed in both our results (RMSE reduced from 0.48 to 0.21) and those reported in [
40]. Classical deterministic MPC, as used in [
14], improves dynamic response but cannot incorporate forecast uncertainty or power quality indices, resulting in lower resilience and efficiency compared to SMPC. The unified SMPC framework presented in this work thus addresses several limitations of existing approaches by incorporating uncertainty modeling, constraint handling, and harmonic compensation in a mathematically rigorous and computationally tractable manner.
5.11. Discussion of Results
The simulation results presented in the previous subsections highlight the strengths and trade-offs of the proposed SMPC framework. Across all tested scenarios, the SMPC consistently outperforms the classical MPC in terms of energy efficiency, demand satisfaction, power quality, and fault resilience.
One of the most significant insights is the system’s ability to dynamically balance storage usage and energy flows under uncertainty. The inclusion of probabilistic constraints enables the controller to anticipate potential mismatches between generation and demand, adjusting actions proactively rather than reactively. This predictive capacity contributes to both higher reliability and better resource utilization.
Moreover, the integration of decentralized MPPT and local harmonic compensation based on p–q theory demonstrates that power quality can be effectively managed in parallel with energy optimization. This dual-layer structure allows high-frequency control objectives (such as THD mitigation) to coexist with longer-horizon planning tasks handled by the SMPC.
Sensitivity analyses confirm that system performance is most sensitive to the level of uncertainty in solar forecasts and the choice of the confidence level . Conservative risk settings (i.e., low values) improve robustness but slightly reduce energy efficiency, while moderate uncertainty and battery capacities above 10 kWh yield the best overall trade-offs.
Finally, despite a modest increase in computational burden, the SMPC remains feasible for real-time deployment, especially with modern embedded or edge computing platforms. The controller’s modular architecture also supports scalability to larger systems with multiple generation units and flexible loads.
5.12. Extended Sensitivity Analysis
To evaluate the robustness of the proposed SMPC framework, we performed a sensitivity analysis on three critical parameters: inverter efficiency (), penalty cost for unmet demand (), and the prediction horizon (N).
These parameters were selected because they directly influence the control performance in distinct domains:
Inverter efficiency affects energy conversion losses and thus the net power delivered to the grid.
Penalty cost defines the economic weight of energy deficits and modifies the controller’s decision-making, especially under uncertainty.
Prediction horizon controls how far into the future the optimization considers, balancing foresight against computational demand.
By varying these parameters across realistic operational ranges, we assess how the proposed control strategy responds to changes in physical efficiency, economic incentives, and temporal scope.
To comprehensively evaluate the influence of system and control parameters on performance, we conducted a multivariable sensitivity analysis. Three key factors were varied systematically: inverter efficiency (), penalty cost for unmet demand (), and the prediction horizon (N). For visualization, we fixed the horizon to 12 h and generated heatmaps representing the impact of other variables on three performance metrics: energy efficiency, THD, and constraint satisfaction.
Figure 10 shows that energy efficiency increases with both higher inverter efficiency and stronger penalties, due to improved storage utilization.
Figure 11 illustrates that THD decreases under similar conditions, benefiting from more consistent inverter behavior. Finally,
Figure 12 highlights the improvement in constraint satisfaction, showing that both high-efficiency inverters and strict penalties result in better demand fulfillment under uncertainty.
These results emphasize the importance of coordinated tuning between control and system-level parameters to enhance PV system performance in realistic, uncertain scenarios.
5.13. Comparison with Alternative Control Techniques
While SMPC offers a mathematically rigorous and optimization-based framework, it is important to compare it with alternative control methods that are commonly employed in PV systems, including rule-based logic, fuzzy control, and advanced PID-based strategies.
Rule-based controllers rely on predefined heuristics, typically encoded as IF-THEN statements. They are intuitive and easy to implement, requiring minimal computational effort. However, their performance degrades significantly under varying or uncertain conditions due to their inability to anticipate future states or model uncertainty.
Fuzzy logic controllers offer greater flexibility by handling imprecision and modeling nonlinearity using linguistic rules. Studies such as [
41] demonstrate their utility in PV systems for MPPT and load management. However, tuning fuzzy controllers becomes complex in multi-variable systems, and they lack a clear cost optimization framework.
PID-based strategies, particularly in cascaded or gain-scheduled configurations, are widely adopted in inverter control and DC-DC converters. While effective for tracking tasks, they require extensive manual tuning and are not well-suited for multi-objective problems or systems with significant delays or constraints [
40].
In contrast, SMPC optimizes future trajectories under uncertainty and systematically enforces system constraints. This is especially important for energy management and power quality under stochastic solar generation and variable loads.
Table 7 provides a summary of the advantages and limitations associated with the various control strategies used in PV systems.
5.14. Economic Evaluation
The economic analysis evaluates the trade-off between energy losses, battery degradation, and penalties for unmet demand. The main parameters used in the cost function are derived from official statistics and realistic scenarios.
The assumed daily energy demand of 50 kWh represents the average consumption of a European household or small business in countries like Spain and Portugal, according to national energy reports from Red Eléctrica de España (REE) [
42] and Eurostat [
43]. All economic values are expressed in euros (EUR).
The penalty cost of unmet demand is set to 0.30 €/kWh, reflecting a representative upper-bound estimate of electricity costs under emergency or peak load conditions. This value aligns with marginal supply costs reported by the International Energy Agency [
44] and recent smart grid studies [
45]. To assess robustness, we conducted a sensitivity analysis by varying this penalty between 0.15 and 0.40 €/kWh. The proposed SMPC consistently outperforms baseline methods in all cases, confirming its economic resilience.
Energy purchase and feed-in prices are set to 0.25 €/kWh and 0.06 €/kWh, respectively, based on Eurostat statistics [
43]. Battery cycling costs are modeled at 0.10 €/kWh, consistent with the most recent benchmarks provided by IRENA [
46].
All parameters are now clearly defined, justified, and referenced to enhance the transparency and reproducibility of the results.
5.14.1. Unmet Demand Cost Savings
Simulation results indicate that the SMPC reduces the frequency of unmet energy demand by approximately 11% compared to the classical MPC (96% vs. 85% satisfaction rate). Assuming a typical daily household energy demand of 50 kWh and a penalty of 0.30 €/kWh for unserved energy (reflecting costs associated with backup generation, service-level agreements, or user inconvenience), the estimated savings are:
5.14.2. Power Quality Improvement Savings
The framework achieves a 25% reduction in total harmonic distortion (THD) through
p–
q based harmonic compensation. In many contexts, utilities impose penalties or maintenance costs related to poor power quality. Assuming an annual cost of 200 € for harmonic-related issues, and a 50% reduction enabled by the proposed controller, the estimated benefit is:
5.14.3. Summary of Economic Benefits
Table 8 summarizes the estimated cost savings achieved by the proposed SMPC framework.
These results suggest that the proposed SMPC not only improves technical performance but also offers significant operational savings. While this evaluation is based on estimated costs, it demonstrates the potential return on investment for distributed PV systems adopting advanced control strategies.
6. Conclusions
This work has presented a stochastic model predictive control (SMPC) framework for the optimal operation of photovoltaic (PV) energy systems under uncertainty. The proposed controller integrates chance-constrained optimization [see Equation (
9)], hierarchical coordination with local inverter controllers, and harmonic compensation using
p–
q theory.
Simulation results confirm that the proposed SMPC significantly outperforms classical deterministic MPC and PID control across multiple metrics. Specifically, as shown in
Table 4 and
Figure 8, energy efficiency increased from 78.4% to 85.2%, constraint satisfaction improved from 82.1% to 95.7%, total harmonic distortion (THD) was reduced by 25%, and energy supply losses under fault conditions decreased from 15% to 5% (
Figure 7). These improvements demonstrate the effectiveness of the integrated and predictive control structure.
The framework also exhibits robustness to variability in solar generation and demand, with uncertainties modeled using Gaussian distributions in Equations (6) and (7), and maintains performance across different battery capacities and inverter efficiencies. The economic evaluation (
Section 5.14), based on real pricing data and cost assumptions from official sources [
42,
43,
46], further confirms the cost-effectiveness of the approach.
While current results are based on simulation, the architecture has been designed with real-time feasibility in mind. Future work will focus on experimental validation via Hardware-in-the-Loop testing, the integration of realistic forecast models, and adaptation to other distributed energy systems. These directions will reinforce the practical applicability of the proposed SMPC framework for resilient and sustainable PV energy management.
Limitations and Future Work
While the results presented in this work demonstrate the potential advantages of the proposed SMPC framework in terms of energy efficiency, reliability, power quality and resilience, several limitations must be acknowledged.
First, the entire evaluation is based on simulation. Although the models incorporate realistic dynamics and forecast variability, the absence of Hardware-in-the-Loop (HIL) or real-world experimental testing means that implementation issues, such as communication delays, sensor noise, converter switching behavior, and thermal constraints, are not accounted for.
Second, the PV system components (inverter, battery, and load) are modeled with ideal or averaged characteristics. While suitable for high-level control design, these abstractions may overlook nonlinearities and aging effects that can affect long-term performance.
Third, the forecasts of solar generation and demand are assumed to follow Gaussian distributions with known parameters. This assumption simplifies the SMPC formulation but may not capture the true statistical behavior of weather patterns or user demand, especially during extreme events.
Fourth, the economic analysis relies on representative, but static, values for energy pricing and component costs. While based on public data, they may vary regionally or over time.
These limitations define the scope of this study. As a next step, we aim to develop a Hardware-in-the-Loop test bench or a small-scale prototype to validate the SMPC implementation under realistic operating conditions. We also plan to refine the forecasting module using machine learning and extend the battery and inverter models to include thermal and aging effects. These improvements will help bridge the gap between simulation and real-world deployment. Another important limitation is the assumption of Gaussian uncertainty. While this choice simplifies the problem and enables the use of analytical chance constraints, it may not accurately reflect the true variability of solar irradiance. Future work may explore the integration of non-Gaussian models using scenario trees, sample-based methods, or distributionally robust optimization frameworks.