This section describes in detail the methodology applied for the energy management of the considered power-to-heat system as well as the results of it, integrating the novel method “BO–IPOPT”.
5.1. Methodology
The primary objective of this study was to operate the industrial energy system described in
Section 2 in a cost- and emission-efficient manner by minimizing electricity costs from the grid and CO
2 emissions, while considering the uncertainties associated with fluctuating solar energy. The role of the energy management within the broader framework of real-time optimization is illustrated on the left of
Figure 4. This framework is typically structured into three hierarchical levels: system-level energy management, component-level control, and physical process operation.
At the top level (system level), which was the focus of this work, predictive optimization is carried out on a timescale ranging from minutes to hours. This level involves solving a multi-period optimization problem to determine cost- and emission-minimizing setpoint trajectories for system variables such as temperature, mass flow rate, and power. These trajectories are subsequently passed to the second level (component level), where dynamic controllers ensure stable system behavior by managing process dynamics at finer time steps (seconds to minutes). The third level focuses on the real-time execution of control signals by physical actuators, such as valves and pumps. In this study, only the system-level optimization was considered; component-level dynamics were excluded. Additionally, the system-level optimization was directly coupled with market operations—e.g., participating in electricity trading.
As outlined in
Section 1, this study employed the RHA, shown on the right of
Figure 4, which provides a structured and adaptive method for handling uncertainties in energy management. The RHA repeatedly solves an optimization problem over a moving time window. After each iteration, only the first control action is implemented, while the rest of the computed trajectory is discarded. The horizon then moves forward to incorporate new real data, enabling ongoing refinement of operational decisions.
For this purpose, the open-source
CoDeOpT tool can be used, which was first introduced in [
20] and further enhanced in the current work to support the energy management of systems like the one presented in this study. As seen in
Figure 5,
CoDeOpT connects forecasting, system modeling, optimization, and data exchange with the real plant in a modular architecture designed for industrial applications. It utilizes weather data from the
Gws platform via an API and processes day-ahead electricity price data from the
Smard platform [
42]. At each RHA iteration,
CoDeOpT computes optimal setpoints and provides them to the real plant through the interface “
Sinnogenes Middleware”, while simultaneously receiving actual plant values, enabling the system to adapt its operation based on actual process conditions and deviations from expected behavior. However, this study did not consider real-time measurements. In addition, the first step of the workflow, performed offline, is to determine an optimal system design and structure, which serves as the foundation for the subsequent energy management and real-time operation phases.
In this work, solar irradiance was considered as the fluctuating input variable, with data selected for one representative week in January and another in August at a single location in Germany—capturing periods of low and high solar activity, respectively (see
Figure 6). The solar data were obtained from the
Gws platform. The electricity price and the CO
2 emission factor associated with grid electricity were assumed to be fixed and known in advance (see
Section 2). Since the solar data were originally available at a 10 min resolution, they were resampled using monotonic cubic interpolation to align with the 15 min resolution required by the energy management framework.
5.2. Results
The effectiveness of energy management in our system is influenced by several key factors, including the choice of optimization algorithm, the allowed computation time per iteration of the RHA, the forecasting model used for solar data, and the length of the optimization horizon. These parameters are summarized in
Table 3. For this section, we systematically evaluated the impact of varying each of these parameters on the system performance. First, we evaluated the performance of the new hybrid method BO–IPOPT, in comparison with the widely used stochastic optimizers “GA” and “PSO”. GA is inspired by the process of natural selection, where a population of candidate solutions evolves over generations through operations such as selection, crossover, and mutation. PSO, on the other hand, mimics the social behavior of swarms, where candidate solutions, called particles, adjust their positions in the search space based on both individual and collective experience. Both methods are widely used in nonlinear and black-box optimization problems and are commonly applied in nonlinear RHA-based energy management tasks.
All the methods were implemented in
Python 3.8. The IPOPT was accessed via the
Pyomo optimization modeling framework, using its default configuration. GA and PSO adopted default parameter settings from [
43,
44]. The BO–IPOPT was configured according to recommendations from [
19], with the number of best-performing candidates per outer iteration set to four—corresponding to the number of available CPU cores. The parallelization of the IPOPT runs in the BO–IPOPT was achieved via the
Python’s library “
Multiprocessing” to enhance computational efficiency. However, to ensure fair comparison with GA and PSO, the BO component in the hybrid method was not parallelized.
All the experiments were conducted on a machine equipped with an Intel(R) Core(TM) i7-8665U CPU. For GA, PSO, and the BO–IPOPT, the optimizer was allowed to run for a fixed time duration (running time) at each RHA step to search for the best possible solution (i.e., the optimal control trajectories for the system). It is worth noting that all the optimization methods considered in this study are based on a certain degree of randomness. For this reason, we repeated each numerical experiment 10 times to average out the stochastic nature of the optimizers.
Moreover, we used a baseline optimization horizon of 8 time steps, equivalent to 2 h at a 15 min resolution, resulting in an optimization problem of 1064 dimensions at each RHA iteration. This choice balanced the problem complexity with the reliability of the solar forecasting models. However, the impact of varying the optimization horizon is analyzed later in this work.
When comparing optimization results across different settings, the global minimum ideally serves as the reference solution. However, since the global minimum was unknown, we used the best solution found by the BO–IPOPT, which ran with a 5 min time limit per RHA iteration, as a benchmark for performance comparison.
First, we evaluated the impact of different optimizers integrated into the RHA framework. To ensure a fair comparison, all the numerical experiments were performed under ideal conditions, i.e., without uncertainties in the input data. Furthermore, the optimizer’s running time was fixed to 50 s per RHA iteration, a value chosen to balance the need for real-time control signal exchange and system response with the computational complexity and high dimensionality of the underlying optimization problem. The optimization outcomes are summarized in
Figure 7, which presents the operating costs and CO
2 emissions for a representative winter and summer week. The results are visualized as box plots, showing the distribution of the accumulated objective values over the repeated experiments for each optimizer.
In all cases, the novel hybrid method the BO–IPOPT clearly outperformed the stochastic solvers “GA” and “PSO”, in terms of both costs and emissions. In the winter week, the BO–IPOPT achieved an average operating cost, measured in terms of the median, of EUR 303.07, with a relative error of 2.75% compared to the best known solution (EUR 294.95). In contrast, GA and PSO yielded significantly worse results—EUR 0.27 and EUR 0.06, corresponding to relative errors of 99.9% and 100%, respectively. It is important to note that the lower values observed in GA and PSO are misleading, as they resulted from violated constraints—penalties embedded in the objective function—with constraint violation values in the order of 1010. These solvers struggled to satisfy the constraints within the short time limit. In contrast, the BO–IPOPT combines the global search capability of BO with the fast local convergence of IPOPT, enabling both constraint satisfaction and superior optimization performance.
This discrepancy can be attributed to the structural limitations of GA and PSO in constrained, high-dimensional, nonlinear optimization problems like the one considered here. These algorithms rely on population-based search strategies and stochastic operators, which often require significantly more iterations to converge to feasible and optimal regions. However, due to the tight CPU time limits imposed in the real-time framework, they are unable to sufficiently explore and refine their solutions. In contrast, the BO–IPOPT leverages the global exploration ability of BO to identify promising regions, followed by the rapid, gradient-based convergence of the IPOPT for local refinement. This hybridization ensures both constraint satisfaction and improved optimization performance, even within strict time constraints.
In the summer week, where higher solar irradiance enabled greater use of PV and STC systems, the BO–IPOPT achieved a lower operating cost of EUR 187.96, with a relative error of 2.9% compared to the best solution (EUR 182.68). GA and PSO again performed poorly, with objective values of EUR 0.08 and EUR 0.25, corresponding to relative errors of 100% and 99.9%, respectively.
The same pattern held for the CO
2 emissions. In winter, the BO–IPOPT reached 101.08 kg, with a relative error of 2.5% compared to the benchmark value of 98.61 kg. GA and PSO showed much lower emissions—2.21 kg and 1.54 kg—translating to relative errors of 97.8% and 98.4%, respectively. In summer, the BO–IPOPT led to 65.78 kg CO
2 with a relative error of 2.9% compared to the best solution (63.95 kg), while GA and PSO resulted in 2.22 kg and 1.58 kg CO
2, i.e., relative errors of 96.5% and 97.5%, respectively. The performance of each optimizer is summarized in
Table 4. Overall, the BO–IPOPT outperformed the other two stochastic optimizers across all four scenarios, and it was, thus, used exclusively in the following investigations of this study.
In many real-time applications, it is crucial to keep the optimizer’s CPU running time as short as possible to ensure that the optimized operational strategy is generated in time to react effectively to rapidly changing system conditions.
Figure 8 presents the optimization results of the BO–IPOPT across different CPU running times—20 s, 30 s, 40 s, and 50 s per RHA iteration—for both operating costs and CO
2 emissions under winter (left) and summer (right) conditions. As expected, extending the CPU time generally improved the optimization quality. For the winter dataset, the average operating costs decreased by approximately 0.7% from 20 s to 50 s, while the CO
2 emissions reduced by around 1.0%. Similarly, under summer conditions, the operating costs dropped by about 1.8%, and the emissions fell by 2.2% over the same interval. Although the average improvements in objective values were relatively modest, a more pronounced benefit of the increased running time was the narrowing of the box plots—representing the spread of outcomes—which became particularly clear at 50 s. This indicates a significant gain in the consistency and reliability of the optimization results. Notably, even at shorter running times (20 s and 30 s), the optimizer was able to identify near-optimal solutions, although with higher variability. These findings confirm that longer running times enhance both solution quality and robustness. While running times beyond 50 s can offer advantages, in terms of improved optimization quality—such as greater robustness and reductions in operating costs and emissions—they were less suitable for the current study, due to the practical limitations. In this study, we fixed the CPU time per RHA iteration to 50 s, as it provided a good trade-off between solution accuracy and computational speed. This choice enabled efficient execution of the further investigations, where longer running times would significantly increase the overall CPU time. Even with this 50 s limit, the optimizer demonstrated reliable performance, allowing us to draw meaningful conclusions about the impact of other factors—uncertainties in the solar data and the length of the optimization horizon—on the optimization outcomes. In future work, the optimization framework will run on a
Linux server interfaced directly with the real plant. This setup is expected to support either extended running times or, more effectively, a higher number of evaluations within the same running time window, enabling faster and more reliable real-time optimization.
As previously discussed, accounting for uncertainties in the input data is essential to reflect more realistic operating conditions. In this context, we integrated the solar irradiance forecasting models into the RHA and evaluated their impact on the system performance. The models tested included MLR, HGBR, and KNN using a recursive forecasting strategy—chosen for their good balance between predictive accuracy and computational efficiency, with training times under 5 s (see
Section 4.7). Additionally, we evaluated a CNN–LSTM model, which, due to its higher computational cost, was trained only once at the beginning of the energy management process and not retrained at each RHA iteration like the other models. This model was selected for this section since it demonstrated good forecasting performance in
Section 4.7.
Figure 9 presents the results for a fixed optimizer running time of 50 s and an eight-step optimization horizon per RHA iteration. For both the winter (left) and the summer (right) weeks, incorporating forecasted solar data using the MLR, HGBR, and KNN models led to noticeable increases in operating costs and CO
2 emissions compared to the idealized scenario with perfect (known) solar data. The maximum deviations reached, on average, approximately 5.8% in costs and 4.4% in emissions. These increases were primarily due to the systematic underestimation of solar irradiance by the forecasting models, which reduced the utilization of the available solar energy and increased the dependency on grid electricity.
Among the tested models, MLR consistently delivered strong performance with minimal deviation from the known data baseline—remaining within 1% across all cases—while requiring very low training effort. In contrast, the CNN–LSTM model showed higher variance and average values (up to 13.3% in costs and 8.8% in emissions), likely due to its lack of retraining during the RHA iterations, reducing its ability to respond to changing data trends. Overall, these findings underline the suitability of simple models such as MLR for real-time energy management tasks, particularly in scenarios where computational efficiency and high accuracy are required. For this reason, MLR was used in the following analysis.
The final parameter investigated in this work was the length of the optimization horizon, which plays a critical role in defining the operational strategy within the RHA-based energy management framework. The horizon length affects the performance in two key ways. First, longer horizons enable the optimizer to better account for future system conditions—such as fluctuations in renewable energy availability and electricity prices—leading to more informed and strategic operation, especially in the management of energy storage systems. Second, extending the horizon increases the dimensionality and complexity of the optimization problem, making it more computationally demanding and potentially more sensitive to forecast uncertainties. In practical applications, this trade-off between planning depth and computational feasibility must be carefully managed. For the numerical experiments presented in this study, we evaluated optimization horizons of 8, 12, 16, 20, and 24 steps, corresponding to 2, 3, 4, 5, and 6 h (based on a 15 min resolution), with a fixed CPU running time of 50 s per RHA iteration.
Figure 10 shows that increasing the optimization horizon at each RHA iteration led to reductions in both operating costs and CO
2 emissions, under both winter and summer conditions. This was because the longer horizons allowed the optimizer to better predict future system behaviors—especially the availability of renewable energy sources such as PV and STC—and make more informed, forward-looking operational decisions. Additionally, the best solution achieved improved (i.e., the objective value decreased) as the horizon increased. However, as observed for the 24-step horizon, the spread in the results increased. This suggests that the optimization problem becomes more complex with increasing horizon length, and the fixed 50 s running time may no longer be sufficient to consistently find high-quality solutions. Horizons longer than 24 steps were not tested, as the associated increase in decision variables and constraints would have exceeded the computational capacity within the 50 s limit.
Figure 11 compares the influence of forecast uncertainty by contrasting the optimization results using forecasted solar data (MLR) with those using perfect, known data. Even for the longest tested horizon of 24 steps, the increase in operating costs and emissions due to forecast errors was limited to approximately 1.24% and 0.7%, respectively. These differences are comparable to those observed for shorter horizons (see
Figure 9), indicating that the BO–IPOPT maintains robust performance in the presence of solar prediction uncertainties. This also suggests that the employed MLR forecast model delivers sufficiently reliable input for effective real-time control.