Submitted:
16 October 2026
Posted:
19 October 2026
You are already at the latest version
Abstract
Renewable–electric vehicle (EV) microgrids must coordinate intermittent generation, stationary storage, uncertain demand, and flexible but service-constrained EV charging or battery swapping. These challenges are amplified in weak grid and off-grid settings, where data may be scarce, grid interruptions frequent, and operational decisions must respect battery, converter, reserve, and service constraints. This paper proposes PEAR-EMS, a Physics-Embedded Adaptive Reinforce ment Learning framework for energy management in resilient renewable–EV microgrids, together with a real-time experimental setup for future validation. PEAR-EMS combines a physics based microgrid model, state- and context-aware reinforcement learning, an adaptive constraint-handling mechanism, and a model-predictive safety filter. The physical model embeds energy balance, storage dynamics, conversion limits, renewable avail ability, grid outages, and EV energy-service requirements into the agent’s observations, action projection, and reward/constraint structure. The adaptive layer adjusts policy exploration and operating margins in response to forecast uncertainty, battery state, and detected distribution shift. A proposed controller in-the-loop / hardware-in-the-loop testbed comprises a real time digital simulation or real-time simulator, a programmable controller or industrial computer, PV and battery emulation, bidirectional EV/charger emulation, grid-interface and protection emulation, measurement and communication interfaces, and a supervisory logging platform. The manuscript defines the mathematical formulation, controller architecture, experimental scenarios, comparison baselines, evaluation metrics, and repro ducibility protocol. It does not claim experimental results: the proposed architecture and test plan require implementation and empirical validation before performance or safety claims can be confirmed. The intended contribution is a transparent route from physics-informed learning to real-time evaluation for renewable EV microgrids in data-constrained environments.
Keywords:
adaptive reinforcement learning
; electric vehicles
; energy management system
; hardware-in-the-loop
; microgrids
; model predictive control
; physics-informed learning
; renewable energy
; safe reinforcement learning
1. Introduction
Microgrids that combine photovoltaic (PV) generation, stationary battery energy storage, and electric-vehicle charging or battery-swapping services can improve local use of renewable energy and provide flexible electricity services. Their operation is nevertheless difficult because renewable output and demand vary over time, EV arrivals and requested energy are uncertain, storage has finite energy and power capability, and grid availability may be intermittent. An energy management system (EMS) must balance operating cost and emissions against service quality, equipment limits, and resilience.
Rule-based controllers and mathematical optimisation provide interpretable operating policies, but their performance can degrade when forecasts are inaccurate or operating conditions change. Model predictive control (MPC) can incorporate constraints and forecasts, although its effectiveness depends on model fidelity, forecast quality, and computational resources. Reinforcement learning (RL) offers a data-driven means of adapting dispatch policies to uncertain and sequential operating conditions. However, unconstrained RL can propose unsafe actions during training or deployment, and learned policies may generalise poorly when the system moves beyond its training distribution. A practical EMS therefore needs to combine the adaptability of RL with explicit physical constraints, supervisory safety mechanisms, and an experimental route to verification.
This paper proposes PEAR-EMS, a Physics-Embedded Adaptive Reinforcement Learning framework for resilient renewable–EV microgrids. The framework is designed around four principles: (i) the physical dynamics are represented explicitly rather than treated as an opaque environment; (ii) the learning policy is conditioned on operating context and uncertainty; (iii) a constraint supervisor checks or projects candidate actions before execution; and (iv) performance is evaluated using reproducible simulation and real-time controller-in-the-loop or hardware-in-the-loop (HIL) tests.
The paper is a methodology and experimental-protocol proposal. It does not report completed real-time experiments or measured performance. The proposed contributions are:
- A physics-embedded RL formulation for joint PV, stationary storage, grid, and EV-service management.
- An adaptive decision architecture that couples uncertainty-aware policy updates with a model-based safety filter.
- A real-time experimental setup proposal, including interfaces, test scenarios, baselines, metrics, and a reproducibility protocol.
- A validation plan that separates nominal performance, constraint satisfaction, resilience under disturbances, and computational feasibility.
2. Related Work, Methodological Comparison, and Research Gap
Research on energy management for renewable–EV microgrids spans deterministic rules, mathematical optimisation, model-predictive control (MPC), reinforcement learning (RL), safe RL, and real-time experimental validation. These families solve related but not identical problems; therefore, the proposed PEAR-EMS framework should be assessed as an integrated architecture rather than by claiming that any one of its ingredients is new.
2.1. Rule-Based and Optimisation-Based Energy Management
Rule-based energy management systems use predefined priority rules, thresholds, or state machines to dispatch PV, batteries, grid imports, and flexible loads. Their principal strengths are low computational cost, transparency, and straightforward implementation on inexpensive controllers. They are useful as a fallback and as a reproducible baseline. Their weakness is that manually selected thresholds can be difficult to tune across seasons, tariffs, EV arrival patterns, and outage conditions; they also tend to represent long-horizon trade-offs only indirectly. In PEAR-EMS, a documented rule-based controller is therefore retained both as a practical comparator and as the fallback policy when the learned controller or safety optimisation is unavailable.
Mathematical optimisation formulates dispatch as a constrained scheduling problem, often using linear, mixed-integer, stochastic, or robust optimisation. Such methods can represent equipment limits and service requirements explicitly and can provide interpretable solutions when the model and forecasts are adequate. MPC repeatedly solves a finite-horizon optimisation problem using updated measurements and forecasts; learning-based MPC research highlights its potential to combine data-driven models with explicit feedback and constraints [6]. However, optimisation performance depends on model quality, forecast quality, the selected horizon, and computational feasibility. Mixed-integer formulations can be especially demanding when many EVs, discrete charging decisions, and uncertainty scenarios are represented. PEAR-EMS consequently uses MPC in two distinct ways: as a full EMS baseline, and as a short-horizon safety filter that corrects the RL action. The latter has a narrower role than a full MPC energy manager and must be evaluated for correction quality and deadline compliance.
2.2. Conventional RL and EV Scheduling
RL learns sequential decision policies through interaction with an environment and is attractive where decisions have delayed effects, such as trading current battery discharge against future reserve or meeting EV departure-energy targets. Deep RL extends this approach to larger continuous state and action spaces; SAC is a plausible starting point for continuous dispatch because it uses off-policy learning and entropy regularisation [3]. Nonetheless, a learned policy may exploit weaknesses in the simulator, violate physical limits, or perform poorly under distribution shift. Training data requirements and the gap between simulated and real operation remain important barriers to deployment [1,7].
Reviews of deep RL for microgrid control identify a growing range of applications but also heterogeneous system models, objectives, baselines, and evaluation procedures, making direct comparison across studies difficult [8]. Forecasting is another important strand: Wazirali et al. review neural-network and machine-learning approaches to microgrid energy and load forecasting, highlighting the operational importance of forecast quality [9]. Forecast accuracy alone, however, does not establish that a downstream controller is physically feasible or resilient. PEAR-EMS therefore evaluates forecast/context uncertainty jointly with dispatch, constraint intervention, EV service fulfilment, and real-time execution.
EV and vehicle-to-grid (V2G) studies bring mobility deadlines and the potential for EV batteries to provide flexible storage into microgrid scheduling. Pan et al. formulate online V2G coordination with multi-energy microgrids as an MDP and use SAC to schedule charging and discharging under uncertain prices and EV arrival/departure patterns [11]. A 2025 review of RL for V2G further organises work around grid, aggregator, and vehicle-user perspectives and identifies uncertainty as a central challenge [12]. These contributions establish that RL-based EV/V2G scheduling is already an active field; PEAR-EMS must not claim to introduce RL-based V2G scheduling itself. Its intended distinction is to combine mobility-aware service constraints with an adaptive uncertainty mechanism, an explicit runtime action-correction filter, and a reproducible real-time test protocol. V2G is optional and should only be enabled in scenarios where bidirectional hardware, vehicle availability, battery limits, and owner consent are represented.
2.3. Safe RL, Physics Embedding, and Adaptation
Safe RL methods commonly shape rewards, impose cumulative constraints, or interpose a runtime shield between the learned policy and the plant. Constrained policy optimisation is a foundational example of directly treating policy constraints during learning [4], while broader reviews classify the different safety objectives and technical approaches [5,13]. Shielding methods monitor candidate actions and block or correct actions that conflict with a safety specification; the resulting assurance remains conditional on the correctness and coverage of the model or specification used by the shield [14,15].
The closest methodological precedent is Wang et al., who develop a physics-informed safe RL method for multi-energy microgrid operation, using a learned security assessment and an action-correction layer to enforce physical constraints in training and testing [10]. Accordingly, PEAR-EMS does not claim that physics-informed safe RL or safety-layer correction is new. Rather, it proposes a testable extension and integration for renewable–EV microgrids: (i) state and context variables include EV service deadlines or battery-swap stock; (ii) the adaptive mechanism responds to calibrated forecast error or distribution shift by adjusting reserve margins and policy authority; (iii) a receding-horizon filter checks candidate actions against the implemented plant constraints; and (iv) the complete stack is assessed across service, resilience, emissions, battery stress, and controller timing. These distinctions are proposed research questions, not established advantages, and must be demonstrated through ablation and matched-baseline tests.
The term physics-embedded in PEAR-EMS refers to several explicit mechanisms rather than a claim that all neural-network layers are physics-informed: a plant model defines state transitions and conservation relationships; physically meaningful states and uncertainty indicators enter the observation; equipment and service constraints are encoded in the CMDP; and a model-predictive optimisation layer projects or rejects infeasible actions. If a physics-informed neural predictor or residual model is later added, its governing equations, loss terms, and training data must be specified separately. This operational definition prevents the label from obscuring which physical information is used and where.
2.4. Real-time Validation and the Unresolved Integration Question
Simulation studies are essential for broad scenario exploration, but they may omit controller execution time, interface delays, data loss, timestamp errors, actuator saturation, and communication failures. Casolino et al. describe and demonstrate HIL validation of a microgrid EMS, emphasising that a real-time simulated plant should exchange information with the actual EMS through representative communication interfaces [16]. Reviews of real-time microgrid simulation similarly identify HIL as a means to investigate controller and interface behaviour that offline studies cannot fully establish [17]. Recent processor-in-the-loop work also illustrates a staged route from model-based simulation to embedded-controller testing, while showing why hardware-induced timing effects should be reported rather than ignored [18].
The research gap is therefore deliberately narrow and evidence-oriented. Prior work already covers microgrid forecasting, RL-based energy management, physics-informed safe RL, EV/V2G scheduling, and HIL validation. The proposed contribution is to implement and systematically compare a single, transparent PEAR-EMS stack that combines these elements for renewable–EV microgrids, including weak-grid and outage-prone cases relevant to data-constrained settings. The study will test whether adaptive uncertainty handling and a model-predictive safety filter add measurable value beyond conventional RL, fixed-margin shielding, MPC, and rule-based control. It will also test whether any operational benefits survive controller-in-the-loop or HIL timing and communication constraints. A claim of novelty or superiority will be retained only to the extent supported by a broader literature search and the resulting experiments.
Table 1.
Methodological comparison between established approaches and the proposed PEAR-EMS evaluation.
Table 1.
Methodological comparison between established approaches and the proposed PEAR-EMS evaluation.
| Method family | Established strengths | Typical limitations to test | Role in this study | Key references |
|---|---|---|---|---|
| Rule-based EMS | Transparent, low computational burden, easy fallback implementation | Threshold tuning; limited adaptation to changing forecasts, tariffs, and EV queues | Baseline and deterministic fallback | [1] (general RL context) |
| Optimisation / MPC | Explicit constraints; interpretable schedules; forecasts can be used directly | Model/forecast dependence; horizon and solver cost; mixed-integer complexity | Full EMS comparator and short-horizon safety filter | [6] |
| Conventional deep RL | Learns sequential policies under uncertain, changing operating conditions | Training burden; unsafe exploration; sim-to-real and distribution-shift sensitivity | RL-without-filter comparator; SAC initial algorithm | [3,8] |
| EV/V2G DRL | Represents EV arrival/departure uncertainty and flexible charging/discharging | May focus on economic scheduling; test coverage of runtime safety and HIL varies by study | EV-service-aware benchmark and optional V2G case | [11,12] |
| Physics-informed safe RL | Embeds physical constraints or a safety layer into learned dispatch | Assurance depends on model fidelity, constraint coverage, and correction feasibility | Closest methodological comparator; PEAR-EMS ablation baseline | [4,10,14] |
| Real-time EMS/HIL | Reveals execution, I/O, timing, and communication effects | Hardware configuration and test scope vary; HIL does not equal field certification | CIL/HIL validation stage with declared boundary | [16,17] |
| PEAR-EMS (proposed) | Physics-based plant; uncertainty-aware adaptation; action-level feasibility filter; EV service metrics; staged real-time tests | Additional model and optimisation complexity; safety depends on model and fallback; benefits not yet demonstrated | Compare against matched baselines and test components through ablations and stress scenarios | This study |
3. System Description
3.1. Microgrid Architecture
The target system consists of a PV plant, stationary battery energy storage system (BESS), bidirectional or unidirectional power-conversion interfaces, an EV charging or battery-swapping load, a local demand, and an optional utility-grid or dispatchable backup interface. A diesel generator may be included in a case study where it represents the local system, but it is not required by the core framework. The EMS operates at discrete time steps of duration .
Let the controllable power vector be
where positive denotes battery discharge, positive denotes grid import, positive denotes EV charging demand served, and is curtailed PV power. Sign conventions must be fixed consistently in implementation. If vehicle-to-grid operation is enabled, the EV power variable is signed and EV discharge is permitted only where vehicle availability, owner consent, and battery constraints are represented.
3.2. Power Balance
A simplified AC- or DC-equivalent active-power balance is
where is available PV power, is non-EV demand, captures conversion and network losses, and is a residual used for model validation rather than a free control variable. In a detailed network model, voltage, reactive power, branch-current, and converter constraints must also be enforced.
3.3. Stationary Battery Dynamics
Let denote stored energy. With separate charge and discharge powers ,
subject to
A binary or complementarity condition is needed if simultaneous charging and discharging must be prohibited. Degradation may be represented by throughput cost or a more detailed cycle-aging model when battery data are available.
3.4. EV Service Model
For charging, let be the energy delivered to vehicle or battery i. A service request includes an arrival time, requested energy, departure deadline, and maximum charging power. A simple aggregate model is
For each request i, the energy target should be met by its deadline where physically feasible:
where is the departure time and is unmet service energy. For battery swapping, the state can instead track charged, depleted, reserved, and unavailable packs, including charger capacity and minimum ready-stock requirements. The aggregate model is appropriate for initial tests; pack-level tests should be used before deployment in a swapping station.
3.5. Grid Availability
Let denote grid availability. Grid exchange is constrained by
If export is not permitted, set . Outage transitions can be generated from empirical outage records or clearly specified stochastic processes; sensitivity analysis should cover outage duration and frequency.
4. PEAR-EMS Framework
4.1. Architecture
PEAR-EMS has five functional blocks:
- 1.
- Physics and state estimator: combines measurements and model equations to estimate battery energy, renewable availability, load, EV queue/service state, grid status, and equipment limits.
- 2.
- Context and uncertainty encoder: provides forecasts or prediction intervals for PV, demand, EV arrivals, and grid availability, together with forecast-error or distribution-shift indicators.
- 3.
- Adaptive RL policy: proposes a candidate dispatch action using the estimated state and context.
- 4.
- Physics-based safety filter: checks the candidate action against one-step and short-horizon constraints, then projects it to a feasible action where possible.
- 5.
- Supervisory logger: records requested and applied actions, constraint margins, intervention reasons, timing, forecasts, and state-estimation residuals.
The safety filter is not assumed to guarantee safety under arbitrary model error, unmeasured faults, or actuator failures; this qualification is consistent with the model-dependent nature of shielding and runtime safety assurance [10,14,15]. Any safety statement must be qualified by the accuracy of the model, the validity of uncertainty bounds, and the coverage of the tested operating envelope.
4.2. Markov Decision Process
The control problem is represented as a constrained Markov decision process (CMDP). The observation is
where summarises EV queue or swap-stock state, represents equipment and network measurements, and represents forecast uncertainty or calibrated interval widths. The action contains requested battery, grid, and EV-service setpoints. The transition is determined by the physical plant, disturbances, and measurement system.
The reward may combine operating cost, emissions, renewable curtailment, battery degradation, and EV service shortfall:
The coefficients are scenario parameters and must be reported with units and sensitivity analysis. Hard safety limits should not be represented only as reward penalties.
4.3. Constrained Objective
The policy maximises expected discounted reward while respecting expected or probabilistic operating constraints:
where can represent grid-import peaks, service shortfall, battery throughput, or other aggregate constraints. Instantaneous physical limits are additionally enforced by the safety filter.
4.4. Adaptive Learning
A practical initial implementation can use Soft Actor-Critic (SAC) for continuous dispatch, with a Lagrangian constraint mechanism or a constrained actor–critic variant [3,4]. The adaptive component should be defined operationally, not merely named: (i) estimate forecast error and distribution shift; (ii) adjust uncertainty-dependent reserve margins and exploration during training; (iii) update constraint multipliers from observed violations; and (iv) reduce policy authority or switch to a verified fallback controller when confidence or communications are inadequate.
For constraint j, a projected dual update is
where k indexes policy updates, is a learning rate, and . The exact adaptation law, update frequency, and stability implications must be documented and tested. Adaptation should be bounded to avoid abrupt control changes.
4.5. Model-Predictive Safety Filter
Let be the action proposed by the RL policy. The filter solves a short-horizon feasibility problem:
subject to power balance and device dynamic, battery, converter, EV and grid limits, reserve and network limits where modelled, uncertainty margins and terminal constraints.
Only the first action is applied; the problem is solved again at the next control step. Slack variables should be reserved for explicitly designated soft constraints. Hard equipment-protection constraints must not be relaxed by generic slack penalties. If no feasible action exists, the controller should enter a documented fallback mode and raise an alarm. Chance constraints, if used, should specify the random variables, confidence level, calibration method, and validation procedure.
4.6. Fallback and Operational Hierarchy
The proposed deployment hierarchy is: protection and interlocks; safety filter; RL dispatch request; and a deterministic fallback EMS. Protection functions remain independent of the RL policy. Loss of communications, stale measurements, solver timeout, state-estimator failure, or infeasible optimisation should trigger a pre-defined fallback. The fallback may use conservative rule-based dispatch, load prioritisation, or safe disconnection according to the site design. Exact thresholds must be determined from equipment ratings and hazard analysis rather than assumed generically.
5. Proposed Real-Time Experimental Setup
5.1. Purpose and Testbed Boundary
The testbed is intended to assess real-time execution, interface behaviour, constraint handling, and resilience under reproducible disturbances. It is not a substitute for field validation or certification. This boundary follows established HIL practice, in which the simulated plant is interfaced with the actual controller and its communication pathway is included where practicable [16,17]. A staged programme is recommended: offline model validation, software-in-the-loop (SIL), controller-in-the-loop (CIL), HIL, and finally a limited field pilot subject to site approvals and protection review.
5.2. Hardware and Software Elements
Table 2 lists a modular setup. The final equipment should be selected according to laboratory availability, voltage/power levels, and whether power hardware or only signal-level emulation is used.
5.3. Real-time Signal Flow
At each sampling instant, the measurement layer provides plant state and status to the estimator. The estimator updates the physical state and forecast context; the RL agent generates a candidate action; the safety filter solves the constrained projection; and the command layer checks validity before sending setpoints to the plant. Applied setpoints, rejected actions, solver status, and timing are logged. All data streams should use a common time base. The control period and plant integration step must be declared, with sufficiently smaller than the fastest dynamics represented by the model. These values should be chosen after a timing and numerical-stability study rather than fixed without reference to the testbed.
5.4. Safety and Commissioning
Commissioning should proceed in stages:
- 1.
- Verify each component model and sign convention independently.
- 2.
- Check energy conservation and unit consistency using deterministic test vectors.
- 3.
- Run the baseline EMS without RL and confirm expected limit handling.
- 4.
- Run the RL policy in shadow mode, with its actions logged but not applied.
- 5.
- Enable the safety filter with conservative limits and test infeasible-action handling.
- 6.
- Introduce one disturbance at a time, then test combinations.
- 7.
- Perform fault-injection tests only under an approved laboratory safety procedure.
No live power interface should be connected until electrical protection, isolation, grounding, emergency-stop behaviour, and laboratory risk assessment have been approved by qualified personnel.
6. Experimental Design
6.1. Case Studies
The following scenarios are proposed to test transfer across operational contexts:
- Case A: weak-grid community microgrid. PV, stationary BESS, critical and non-critical demand, and scheduled EV charging.
- Case B: battery-swapping station. PV and grid supply, battery charging racks, stochastic motorbike battery arrivals, minimum ready-stock requirement, and service deadlines.
- Case C: outage-prone institutional microgrid. PV, BESS, anchor loads such as water pumping or health services, and EV charging as a flexible load.
At least one scenario should use a model calibrated with measured or manufacturer-provided component data. If real operating data are unavailable, synthetic profiles may be used for initial verification but must be labelled as synthetic and must not be presented as field evidence.
6.2. Disturbance and Stress Tests
Each case should include nominal operation and controlled stress tests:
- 1.
- PV ramps and forecast bias.
- 2.
- Load surges and EV arrival bursts.
- 3.
- Grid outages, uncertain restoration time, and voltage/frequency disturbances where modelled.
- 4.
- Reduced battery capacity, altered efficiency, or conservative state-of-charge estimation.
- 5.
- Communication latency, packet loss, stale measurements, and solver timeout.
- 6.
- Distribution shift: train on one season or demand pattern and test on a held-out profile.
- 7.
- Combined disturbances to test whether individual protections remain effective.
Disturbance magnitudes and probabilities must be based on available site data, component ratings, standards, or an explicitly stated sensitivity range.
6.3. Baselines and Ablations
PEAR-EMS should be compared with:
- Rule-based EMS with documented priority logic.
- Deterministic MPC using the same physical model and forecast inputs where applicable.
- RL without the safety filter.
- RL with a fixed, non-adaptive safety margin.
- PEAR-EMS without physics embedding or without uncertainty adaptation (ablation tests).
Baselines should use comparable information, identical plant models, the same scenario seeds, and the same hardware limits. Hyperparameter tuning budgets should be disclosed to reduce unfair comparisons.
6.4. Evaluation Metrics
Table 3 defines the minimum evaluation set. Results should be reported across multiple independent seeds and disturbance profiles, with confidence intervals or bootstrap intervals where suitable.
6.5. Proposed Test Matrix and Experimental Sequence
To make the validation reproducible, each controller should be evaluated on the same plant model, scenario files, initial states, and random seeds. A recommended matrix is shown in Table 4; exact disturbance levels should be selected from measured data, equipment ratings, or a documented sensitivity analysis rather than copied as universal values.
The recommended sequence is: (1) unit-test component models and verify energy balance; (2) validate state transitions against analytical calculations or independent reference simulations; (3) run offline training and select hyperparameters using training/validation profiles only; (4) freeze the policy and evaluate on held-out scenarios; (5) conduct software-in-the-loop tests; (6) run the controller in shadow mode against a real-time plant; (7) enable action correction and fallback logic in controller-in-the-loop tests; and (8) progress to HIL only after electrical, interface, and laboratory risk reviews. If a real-time simulator or power interface is unavailable, SIL/CIL results should be reported honestly and HIL should remain a proposed next stage, not a completed experiment.
For a minimum viable testbed, the plant can initially be simulated in MATLAB/Simulink or another validated real-time-capable environment, while the EMS executes on a separate industrial PC or embedded computer. A real-time digital simulator (e.g., an available RTDS- or OPAL-RT-class platform) is preferred for HIL, but is not a prerequisite for the first software-validation stage. Begin with signal-level or controller-in-the-loop testing; add power amplifiers, PV/battery emulators, or a bidirectional EVSE only if the research question requires physical power-interface dynamics and the laboratory can support the associated protection requirements. The controller-to-plant interface, sampling period, communication protocol, numerical integration step, and timeout policy must be specified for the actual selected platform before experiments begin.
6.6. Statistical and Reproducibility Protocol
For each configuration, use multiple random seeds and a held-out set of days or profiles. Report mean, standard deviation, and 95% confidence intervals for continuous metrics, along with event counts and denominators for constraint violations. Use paired comparisons on matched scenarios where possible. Pre-register the primary metric and comparison before examining the final test set. Publish the controller configuration, model parameters that can be shared, scenario-generation code, software versions, random seeds, and anonymised logs where permitted. Clearly distinguish synthetic data, public data, manufacturer specifications, and measurements collected in the laboratory.
7. Research Questions and Hypotheses
The study is organised around four testable research questions:
- RQ1:
- Does physics embedding improve physical consistency and reduce constraint violations relative to an otherwise comparable RL policy?
- RQ2:
- Does adaptive uncertainty handling improve performance under forecast error and distribution shift relative to fixed-margin control?
- RQ3:
- Does the safety filter reduce the severity or frequency of unsafe candidate actions without causing unacceptable loss of service or excessive intervention?
- RQ4:
- Can the complete controller meet the real-time deadline on the selected controller hardware under nominal and stress-test conditions?
The corresponding hypotheses are that physics embedding improves feasibility; adaptive margins improve robustness under shift; safety filtering reduces applied-action violations; and the controller meets its declared execution deadline within the tested operating envelope. These are hypotheses to be tested, not findings established by this manuscript.
8. Discussion
PEAR-EMS is intended to make the transition from learned dispatch to laboratory evaluation explicit. Physics embedding can reduce the burden on the policy to rediscover basic conservation and device constraints, while a safety filter can prevent a subset of infeasible commands from reaching the plant. The approach nevertheless has important limits. A safety filter is only as reliable as its model, state estimates, uncertainty bounds, and solver behaviour. A feasible set may be empty during severe disturbances, so a fallback and load-prioritisation policy are essential. Adaptation can itself introduce instability if it changes margins or policy parameters too rapidly; bounded updates and independent protection are therefore required.
The proposed real-time testbed also introduces practical issues that offline simulation cannot capture, including timestamp alignment, communication delays, actuator saturation, controller overload, and measurement noise. Evaluation should report these effects rather than only energy-cost outcomes. In addition, local deployment requires the EMS to reflect the actual tariff structure, outage characteristics, EV usage patterns, and operational priorities. For example, a battery-swapping station may prioritise a minimum stock of charged batteries, whereas a clinic microgrid may prioritise critical loads. These priorities should be explicit in the model and should not be inferred from a generic reward.
Finally, transferability to Sub-Saharan African microgrids should be demonstrated using transparent assumptions and, where possible, locally grounded data. A framework designed for data-scarce contexts should quantify how its performance changes when data volume, forecast quality, or component-model fidelity is reduced. Any claims about equity, emissions, or resilience should be linked to operational definitions and measured indicators.
9. Conclusion
This paper has proposed PEAR-EMS, a physics-embedded adaptive RL framework for energy management in renewable–EV microgrids, and a staged real-time experimental setup. The proposed design combines explicit physical dynamics, uncertainty-aware context, adaptive constrained learning, a model-predictive safety filter, a deterministic fallback, and detailed operational logging. A test protocol has been specified across weak-grid, battery-swapping, and institutional microgrid scenarios, with rule-based, MPC, and RL baselines. The framework’s value remains to be established empirically. The next step is to implement the model and controller, conduct SIL/CIL/HIL validation and to report quantitative comparisons and real-time execution statistics.
References
- Sutton, R. S.; Barto, A. G. Reinforcement Learning: An Introduction, 2nd ed.; MIT Press: Cambridge, MA, USA, 2018. [Google Scholar]
- Lillicrap, T. P.; et al. Continuous control with deep reinforcement learning. Proc. International Conference on Learning Representations (ICLR), 2016. [Google Scholar]
- Haarnoja, T.; Zhou, A.; Abbeel, P.; Levine, S. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. Proc. International Conference on Machine Learning (ICML), 2018; pp. 1861–1870. [Google Scholar]
- Achiam, J.; Held, D.; Tamar, A.; Abbeel, P. Constrained policy optimization. Proc. International Conference on Machine Learning (ICML), 2017; pp. 22–31. [Google Scholar]
- García, J.; Fernández, F. A comprehensive survey on safe reinforcement learning. J. Mach. Learn. Res. 2015, vol. 16(no. 1), 1437–1480. [Google Scholar]
- Hewing, L.; Wabersich, K. P.; Menner, M.; Zeilinger, M. N. Learning-based model predictive control: Toward safe learning in control. Annu. Rev. Control Robot. Auton. Syst. 2020, vol. 3, 269–296. [Google Scholar] [CrossRef]
- Levine, S.; Kumar, A.; Tucker, G.; Fu, J. Offline reinforcement learning: Tutorial, review, and perspectives on open problems. arXiv 2020, arXiv:2005.01643. [Google Scholar]
- Dinata, N. F. P.; Ramli, M. A. M.; Jambak, M. I.; Sidik, M. A. B.; Alqahtani, M. M. Designing an optimal microgrid control system using deep reinforcement learning: A systematic review. Eng. Sci. Technol. An. Int. J. 2024, vol. 51, Art.(no. 101651). [Google Scholar] [CrossRef]
- Wazirali, R.; Yaghoubi, E.; Abujazar, M. S. S.; Ahmad, R.; Vakili, A. H. State-of-the-art review on energy and load forecasting in microgrids using artificial neural networks, machine learning, and deep learning techniques. Electr. Power Syst. Res. 2023, vol. 225, Art.(no. 109792). [Google Scholar] [CrossRef]
- Wang, Y.; Qiu, D.; Sun, M.; Strbac, G.; Gao, Z. Secure energy management of multi-energy microgrid: A physical-informed safe reinforcement learning approach. Appl. Energy 2023, vol. 335, Art.(no. 120759). [Google Scholar] [CrossRef]
- Pan, W.; Yu, X.; Guo, Z.; Qian, T.; Li, Y. Online EVs vehicle-to-grid scheduling coordinated with multi-energy microgrids: A deep reinforcement learning-based approach. Energies 2024, vol. 17(no. 11), Art. no. 2491. [Google Scholar] [CrossRef]
- Xie, H.; Song, G.; Shi, Z.; Zhang, J.; Lin, Z.; Yu, Q.; Fu, H.; Song, X.; Zhang, H. Reinforcement learning for vehicle-to-grid: A review. Adv. Appl. Energy vol. 17, Art.(no. 100214), 2025. [CrossRef]
- Gu, S.; Yang, L.; Du, Y.; Chen, G.; Walter, F.; Wang, J.; Knoll, A. A review of safe reinforcement learning: Methods, theories, and applications. IEEE Trans. Pattern Anal. Mach. Intell. 2024, vol. 46(no. 12), 11216–11235. [Google Scholar] [CrossRef]
- Alshiekh, M.; Bloem, R.; Ehlers, R.; Könighofer, B.; Niekum, S.; Topcu, U. Safe reinforcement learning via shielding. Proc. AAAI Conference on Artificial Intelligence, 2018; pp. 2669–2678. [Google Scholar] [CrossRef]
- Könighofer, B.; Bloem, R.; Jansen, N.; Junges, S.; Pranger, S. Shields for safe reinforcement learning. Commun. ACM 2025, vol. 68(no. 11), 80–90. [Google Scholar] [CrossRef]
- Casolino, G. M.; Russo, M.; Varilone, P.; Pescosolido, D. Hardware-in-the-loop validation of energy management systems for microgrids: A short overview and a case study. Energies 2018, vol. 11(no. 11), Art. no. 2978. [Google Scholar] [CrossRef]
- AhmadiAhangar, A.; et al. A review on real-time simulation and analysis methods of microgrids. Int. Trans. Electr. Energy Syst. 2019. [Google Scholar] [CrossRef]
- Charadi, S.; Chakir, H. E.; Akarne, Y.; Annoukoubi, M.; Redouane, A.; El Hasnaoui, A. Experimental validation of a hybrid AC/DC microgrid energy management system using Processor-in-the-Loop testing for green energy applications. Frankl. Open vol. 13, Art.(no. 100453), 2025. [CrossRef]
Table 2.
Proposed PEAR-EMS experimental setup.
| Subsystem | Minimum proposed implementation | Purpose / data logged |
|---|---|---|
| Real-time plant | Real-time simulator or real-time digital simulation platform running PV, load, converter, battery, grid, and EV models | Plant states, model step overruns, power balance residuals |
| Controller host | Industrial PC or embedded controller running PEAR-EMS; fixed-rate control loop | Execution time, CPU/memory use, missed deadlines, policy output |
| PV subsystem | PV array model with irradiance and temperature profiles; optional PV emulator | Available and curtailed PV power, forecast error |
| Stationary storage | Battery model or battery emulator with SOC, current, voltage, and power limits | SOC tracking, power response, limit interventions |
| EV subsystem | EVSE/charger emulator or battery-swap queue model; optional bidirectional charger | Delivered energy, deadline misses, queue and stock state |
| Grid interface | Grid-tied or islanded model with programmable outages and import/export limits | Outage response, grid power, restoration transients |
| Measurement and I/O | Analogue/digital I/O, fieldbus or Ethernet interface, time synchronisation | Sensor delay, packet loss, timestamp integrity |
| Protection layer | Independent limits, interlocks, emergency stop, overcurrent/overvoltage protection as applicable | Trips, alarms, protection events |
| Logging and analysis | Time-series logger, experiment configuration, version control, post-processing scripts | Reproducibility, metric calculation, audit trail |
Table 3.
Proposed evaluation metrics.
| Metric | Definition / reporting |
|---|---|
| Operating cost | Energy purchase and declared operating costs per day or per served kWh |
| Operational emissions | kg CO2e per day and per served kWh, using declared grid/generator emission factors and a consistent accounting boundary |
| Renewable utilisation | PV energy used divided by available PV energy |
| Unserved energy | Total unmet critical and non-critical demand, separately |
| EV service | Fraction of requests meeting energy/departure targets; mean and tail waiting time |
| Battery stress | Throughput, SOC excursions, equivalent full cycles if model supports it |
| Constraint violations | Count, duration, and magnitude by constraint; distinguish hard and soft limits |
| Shield activity | Intervention rate and mean action correction norm |
| Resilience | Recovery time and unmet energy during and after defined outages |
| Electrical quality | Voltage/frequency deviation, time outside declared bands, and recovery after disturbances where the plant model resolves these variables |
| Real-time performance | Median, 95th/99th percentile execution time; deadline-miss rate |
| Robustness | Performance degradation under forecast error and distribution shift |
Table 4.
Proposed experimental matrix.
| Test group | Controlled variation | Primary outcomes |
|---|---|---|
| Nominal | Typical PV, load, EV arrivals and grid availability | Cost, emissions, renewable use, service completion |
| Forecast error | Bias, ramp error, and widening uncertainty intervals | Robustness, reserve use, unmet load |
| EV stress | Arrival bursts, short dwell time, high departure SOC target | Queue/waiting time, energy delivered, deadline misses |
| Grid disturbance | Import cap, planned/unplanned outage, restoration event | Critical-load supply, recovery time, peak import |
| Storage stress | Reduced usable capacity, efficiency drift, SOC-estimation error | SOC limits, throughput, feasibility interventions |
| Communication | Latency, packet loss, stale measurements, time skew | Missed deadlines, fallback activation, stability of dispatch |
| Distribution shift | Held-out season, altered EV mix, changed PV/load profile | Performance degradation versus in-distribution test |
| Ablation | Remove adaptation, physics features, or safety filter one at a time | Marginal value and failure modes of each component |
| Real-time execution | Repeat representative and worst-case computational scenarios on target controller | Median and tail execution time, deadline misses |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.