1. Introduction
Nowadays, the supply of process heat for industrial processes by conventional systems leads to high CO
2 emissions, as these are predominantly based on the combustion of fossil fuels. The electrification of heat generation through the use of novel technologies, such as high-temperature heat pumps (HTHP), is a potential measure to reduce these emissions. In combination with renewable energy sources, the sustainable heat supply for industrial processes is based on complex systems that require realistic modeling as well as cost- and emission-optimized system operation. In particular, electrified energy supply systems face the challenge of determining a cost-optimal operating strategy due to the fluctuating power generation from renewable energies, while ensuring the required heat demand of the industrial process is satisfied. In this context, a potential industrial power-to-heat (P2H) system with an HTHP providing heat for a steam generator (SG), see
Figure 1, was recently proposed by Walden et al. [
1]. This P2H system uses the availability of an on-site wind turbine (WT) to generate its own electricity to power the HTHP. This reduces the cost of purchasing electricity from the power grid. These costs can be further reduced by using a thermal energy storage (TES), which serves to balance out the fluctuating generation of renewable energy. The overproduction of electricity can then be stored as thermal energy and used later to supply the system with its own resources.
In [
1], the cost-optimal operation of this electrified system with the aim of minimizing the total cost of grid power was treated as a deterministic optimization problem and solved using methods of algebraic nonconvex, nonlinear programming theory. In addition, it was assumed that future wind power generation and electricity prices were already known in advance. However, in real-world scenarios, the problem of the optimal management and operation of such systems is a decision-making problem under uncertainty, as precise forecasts of future wind energy supply and electricity prices are not possible. Therefore, the problem must be formulated in a stochastic framework.
In this context, the following typical question needs to be addressed: At what time and at what rate should energy be stored in or withdrawn from the TES to reduce the costs of grid electricity? To address this question, we will treat the cost-optimal management of the underlying industrial P2H system as a stochastic optimal control problem and solve it using Markov decision process (MDP) theory.
This literature is embedded in numerous studies on optimization problems for energy systems, particularly for electrical and thermal microgrids. However, many of the articles only briefly describe the underlying model and methods. The optimization problems are mainly related to technical aspects, and the control problem is solved with commercial optimization software. The mathematical aspects of the optimal control of energy systems are generally not sufficiently addressed.
The optimal management of
combined heating and power systems has recently been studied by several authors. In Testi et al. [
2], the optimal integration of electrically powered heat pumps into a hybrid decentralized energy supply system is investigated. The authors propose a multi-criteria stochastic optimization method to determine the integrated optimal dimensioning and operation of energy supply systems under uncertainties regarding climate, land use, energy demand, and fuel costs. Kuang et al. [
3] study the optimization of the off-design operation of combined heating and power systems, including energy storage. The cost-optimal control of a heating system for residential buildings with geothermal storage under uncertainties regarding heat supply and demand as well as energy prices is investigated in Takam et al. [
4]. A review on the optimal energy management of combined cooling, heating, and power microgrids is given in Gu et al. [
5]. Further contributions on combined heating, cooling, and power system can be found in [
6,
7] and the references therein.
In recent years,
machine learning methods have also been increasingly used to solve optimization problems. For example, Bui et al. [
8] and Mohammed et al. [
9] model a microgrid energy management system with battery storage that is connected to the energy grid and distributed energy sources. To obtain an optimal operation strategy that aims to handle loads, prices, and the decision of charging or discharging the battery, Q-learning [
10] is used. Nakabi and Toivanen [
11] considered a similar application, but they used and compared different state-of-the-art reinforcement learning algorithms like Q-learning, deep deterministic policy gradients, or proximal policy optimization to achieve the optimal management of their microgrid model. Another application of MDPs is proposed by Yu et al. [
12], who apply reinforcement learning to a home energy management system. In addition to the usage of a battery storage and the connection to the power grid as well as renewable energies, the household utilizes a heating, ventilation, and air conditioning system that needs to be operated as cost efficiently as possible. Belloni et al. [
13] use a MDP formulation of a system with a WT and battery storage to obtain the optimal control with dynamic programming. Thermal storage devices combined with a heat pump are used in the papers of Ridder et al. [
14] and Chenzi et al. [
15], which use dynamic programming and Q-learning, respectively.
The cost-optimal management of energy supply systems under uncertainty can be treated mathematically as a stochastic optimal control problem. There is extensive literature on this theory. Much of this literature focuses on solution methods based on the dynamic programming principle. For continuous-time problems in which the controlled state process is a diffusion or jump-diffusion process, this results in the Hamilton–Jacobi–Bellman equation, which acts as a necessary optimality condition; we refer to Fleming and Soner [
16], Pham [
17], and Oksendal and Sulem [
18]. This is a nonlinear partial differential equation that can usually only be solved by
numerical methods, as in Shardin and Wunderlich [
19] and Chen and Forsyth [
20].
For solutions to discrete-time problems,
Markov decision process theory offers an algorithm based on backward recursion. Standard references are Bäuerle and Rieder [
21], Puterman [
22], Hernández-Lerma and Lasserre [
23], and Powell [
24]. We note that such MDPs can be also obtained from a time discretization of continuous-time control problems.
For high-dimensional state spaces, the solution of MDPs suffers from the curse of dimensionality. To overcome this problem, powerful numerical methods have been developed in recent years. Examples are the least squares Monte Carlo method introduced in [
25,
26], approximate dynamic programming, Q-learning and related reinforcement learning methods [
10,
24,
27], and optimal quantization methods [
28] as well as neural network [
29,
30] and deep learning methods [
31,
32].
In this article we present a mathematical model for the operation of an industrial P2H system with an HTHP and a TES. It explicitly takes into account the stochasticity of intermittent renewable energy sources such as wind power and the fluctuating market prices for electricity in the power grid. These variables are modeled by suitable stochastic processes that are calibrated to real-world data. Furthermore, the model takes into account that permanent changes in the operating points should be avoided. We therefore treat the cost-optimal energy management problem a stochastic optimal control problem in discrete-time, in which the controls are kept constant between two discrete points in time. To avoid unnecessary time discretization errors, the dynamics of the state and system variables that reflect the operation of the system are still treated in continuous time.
The optimization problem is formulated as an MDP and solved using dynamic programming methods. Since the state of the control problem is three-dimensional, the numerical solution already faces the curse of dimensionality. The problem becomes even more serious when we extend and refine our stylized model to include more details of the HTHP operation. Then the computational effort for the numerical solutions becomes prohibitively high. Therefore, in this paper, we investigate reinforcement learning methods such as Q-learning to find a faster numerical approximate solution. Finally, we present the results of extensive numerical experiments in which we compare the results of the different numerical methods.
Section 2 is devoted to a thorough mathematical modeling of the considered industrial P2H system. It introduces the state and control variables and additional system variables, as well as the underlying assumptions on the P2H system. In
Section 3, a MDP formulation of the stochastic optimal control problem is derived. This section provides details on the formulation of the stochastic processes for wind speed and the electricity price, state and control constraints, and the cost functions of the optimal control problem. In
Section 4, the classical approach to solve MDP problems by backward recursion based on the associated Bellman equation is presented. Approximate solutions based on reinforcement learning techniques, particularly Q-learning, are described in
Section 5. Finally,
Section 6 presents results of numerical experiments in which the optimal control problem is solved using the methods proposed in
Section 4 and
Section 5. The
Supplementary Material collects proofs and technical results that have been removed from the main text to avoid interrupting the reader with these details. The flowchart in
Figure 2 provides an overview of the workflow of the paper. It summarizes and illustrates the interplay of the content presented in
Section 2,
Section 3,
Section 4 and
Section 5.
2. Mathematical Modeling of the Industrial P2H System
In this section, a mathematical model for the operation of the industrial P2H system is developed. It is treated as a control system with an endogenous state variable that can be influenced by a control variable and exogenous stochastic states. The P2H system is subject to various operational constraints that lead to state and control constraints. For more technical details about the underlying P2H system, we refer the reader to [
1]. In the following, we first briefly introduce the industrial P2H system and then describe its mathematical modeling as a control system.
2.1. Industrial P2H System
The industrial P2H system based on renewable energy, heat pump, and energy storage shown in
Figure 1 is designed to supply constant process heat in the form of superheated steam at 13 bar and 215 °C. The system consists of the following four components:
- (i)
An on-site wind turbine that generates renewable electricity;
- (ii)
A high-temperature heat pump for heat supply, which is powered by electricity from the WT or the power grid;
- (iii)
A concrete-based sensible thermal energy storage to store excess energy in times of high wind power production or low grid electricity prices;
- (iv)
A steam generator to provide constant process steam.
The thermal system components (ii)–(iv) are connected via a thermal oil loop. Note that the TES is specifically designed for short periods of time, i.e., for storing excess heat for some hours or a few days.
A more detailed system configuration is depicted in
Figure 3. The HTHP generates high-temperature process heat up to 350 °C with a thermal output of up to around 2.2 MW, which is fed into a thermal fluid loop with thermal oil as the heat transfer fluid (HTF). Via a fluid bypass, the charging factor
determines the proportion of the HTF that is routed through the TES, while the remaining proportion
passes directly into the SG. The bypass is used to regulate the charging process of the TES. During charging, the hot HTF flows through the cooler TES and heats the storage medium (concrete).
A second bypass from the SG outlet returning to the high-temperature heat exchanger (HTHX) of the HTHP is used to discharge the TES. The discharge factor specifies the proportion of the HTF that is passed through the TES, such that the remaining part enters directly into the HTHP. During the discharging process, the HTF cooled in the SG flows through the warmer TES and lowers the temperature of the storage medium. As the fluid now enters the HTHX at a higher temperature, the HTHP’s electricity consumption is reduced.
In idle operation, characterized by , the TES is completely bypassed by the HTF. At the low-temperature heat exchanger (LTHX) of the HTHP, a waste heat air stream at 60–100 °C from the industrial consumer is used as heat source. We note that the cold air outlet stream at the LTHX is not used for cooling applications in the current configuration. Further, it is assumed that the system components, particularly the HTHP and SG, operate in steady state. This means that the dynamic behavior of the components during operating point changes is neglected.
In our setup, we use the heat flow rates that determine the charging and discharging operations of the TES to describe the control of the P2H system. These rates have a direct functional relationship with the HTHX inlet and outlet temperatures, the HTHP’s compressor shaft speed, and electricity consumption, which is described in more detail below in
Section 2.4. The HTHP electricity consumption that is not covered by wind energy determines the amount of electricity drawn from the grid, resulting in a direct functional relationship with the running electricity costs that are included in the performance criterion of the optimization problem. More details follow below in
Section 3.4.
The mathematical description of nonlinear component models for HTHP and SG is based on process simulation software that also takes into account the part-load behavior of the heat pump. Based on this, the physical characteristics are then approximated by algebraic surrogate models that appropriately mimic the input-output behavior of the components. For our purposes, it is sufficient to model the state of charge of the TES only by its spatially averaged temperature and neglect the detailed spatial temperature distribution, as, for example, in [
33,
34]. This avoids complex calculation of internal heat propagation and facilitates the solution of the optimization problem. This simplification preserves the dynamics of the TES while significantly reducing the computational complexity, making it suitable for integration into energy management optimization.
The actual WT power output is typically modeled by a function of the wind speed at rotor height. This dependence is given by the so-called power curve, which is explained in
Section S6.3 of the Supplementary Material. We emphasize that the system and component modeling does not take into account pressure and heat losses as well as friction losses and also no electricity consumption of auxiliary systems such as fluid pumps. For example, fluid oil pumps are not considered because the main power consumption is based on the HTHP, which is many times larger than the pumps, so the total power consumption only shows a small error.
The design and dimensioning of the system components was determined by engineering calculations, for which we refer to [
1]. Recall, the aim is to determine the cost-optimal operation of the P2H system that minimizes the expected total costs over a finite planning horizon
from the purchase of grid electricity and the revenues from the sale of WT overproduction, taking into account the uncertainty of the fluctuating wind energy supply and electricity prices. To derive the mathematical formulation of this optimization problem in form of an MDP in
Section 3, we describe in the following the details of the state and control variables, additional system variables, and operational constraints.
2.2. Time Discretization
While the state and system variables of the P2H system evolve continuously over time, the control variables available to the controller are typically not changed permanently but only at discrete points in time and are then kept constant until the next time point. This is caused by the fact that operating the HTHP, i.e., changing the HTHX outlet temperature by varying the compressor shaft speed, induces thermal stresses in the heat exchangers during transient operations. For this reason, rapid changes in the operating points should be avoided and limited to a few discrete points in time.
We therefore divide the planning horizon into uniformly spaced subintervals of length and define the time grid points for . Let be a given continuous-time function. In this work we use the short-hand notation for the sampled value at the time grid point . The control variables and some related system variables are assumed to be piecewise constant functions on the time grid introduced above and take the values for with . The remaining system variables and particularly the state variables of the control problem are treated as continuous-time functions governed by certain equations that capture the dynamics of the system. However, the controller only uses the values at the time grid points for the control decisions.
The electricity price for trading on the intraday spot market is not quoted continuously over time, but generally only every 15 min. For the sake of simplicity, we model this price as a continuous-time stochastic process and discretize it accordingly.
2.3. State and Control Variables
For the formulation of the stochastic optimal control problem, the following three variables describe the state of the control system at time
:
| , | the average TES temperature | [°C]; |
| , | the wind speed | [m/s]; |
| , | the electricity price | [€/MWh]. |
These state variables can be divided into endogenous and exogenous quantities. Here, R is the only endogenous variable that is subject to the control action, while W and S are exogenous variables and determined outside the model. The storage temperature R changes during charging or discharging operation and is directly related to the associated heat flow rate, which forms the control variable introduced below.
The
exogenous states, on the other hand, are stochastic variables, as the wind speed and the electricity price are subject to a certain degree of uncertainty, meaning that future values are not known exactly in advance and are afflicted with considerable forecasting errors. They must therefore be modeled as stochastic processes, where the detailed description is deferred to
Section 3.1.
In our model, we suppose that the operation of a P2H system at time
is controlled by
| , | the heat flow rate related to the TES | [kW] |
with values in some action or control space
which will be specified below. In the following, we use the sign convention that a positive heat flow rate corresponds to charging, while negative values of
A indicate discharging. The idle mode is represented by
. We show in
Section 2.4 that specifying this variable is sufficient to adjust the other system variables describing the HTHP operation accordingly. There, we will also explain how the HTHP electricity demand depends on the control
A, which in turn determines the demand for electrical energy drawn from the grid when this demand is not fully covered by wind energy, or the overproduction of wind energy that can be fed into the grid. The operational costs associated with the control
A are derived in
Section 3.4. Note that the controller’s choice of the heat flow rate
A is subject to various constraints, which we explain in detail in
Section 3.3.
The control
A directly determines the dynamics of the only controlled/endogenous state variable in our control system, namely, TES temperature
R. It results from an energy balance that describes the change in thermal energy in the TES due to the inflow and outflow of energy during charging and discharging. Since the TES is designed to store excess heat for short periods of hours or a few days, we neglect heat losses to the environment. Then the change in thermal energy in the time interval
with
in the continuous-time setting is given by
. On the other hand, it is equal to
, where
and
denote the specific heat capacity (assumed to be temperature independent) and the mass of the storage medium, respectively. The values used are specified in
Supplementary Material, Section S2. This leads to the following relation for the TES temperature for
As already mentioned in
Section 2.2, we make the following
Assumption 1 (Piecewise constant control)
. Control A is kept constant between two consecutive grid points of the time discretization, i.e., Below, in
Section 2.4, we notice that the assumption of constant heat flow rates in the TES corresponds to constant oil temperatures at the inlet and outlet of the HTHX within the periods between the time grid points. This avoids rapid changes in the HTHP operation. Only at the time grid points
the heat flow rate changes immediately from
to
, whereby the transient behavior of the HTHP and TES components is neglected.
Under the above assumption that the heat flow rate
A is piecewise constant and does not vary within a time period
, the dynamics (
1) of the TES temperature within such a period simplifies then to
where we recall the notation
and
.
2.4. Additional System Variables and Operational Constraints
The mathematical modeling of the operation of the P2H system, as shown in
Figure 1 and
Figure 3, requires the consideration of several additional variables that have not been included in the set of state and control variables. They are referred to as system variables and are subject to certain operational constraints, which are explained in this subsection. These system variables and their dynamics are needed to derive state-dependent control constraints of the control problem that we formulate in
Section 3. However, the system variables are regarded as internal variables whose specific values do not need to be observed by the controller and which are not included in the decision-making process. The latter is based solely on knowledge of the state variables.
To formulate the mathematical model discussed in this work, we make the following simplification.
Assumption 2 (Constant HTF mass flow and waste heat temperature). The mass flow of the thermal oil stream and the temperature of the waste heat air stream at the LTHX inlet are constant over the entire period .
Note that in [
1] the HTF mass flow rate
can vary within a certain range; here, we assume that
is constant. Although this simplification leads to a lower system flexibility, it avoids the introduction of an additional control variable and thus reduces the complexity of the problem as well as the computational effort required to compute the numerical solution.
2.4.1. Steam Generator
The constant heat demand of the SG must be satisfied at all times, leading to the following relations between the mass flow
and temperatures at the inlet
and outlet
of the SG:
The nonlinear functions
and
represent surrogate models for the underlying energy balances and are generated using process simulations, see
Section S1 of the Supplementary Material. According to Assumption 2, the mass flow
is constant in our model, so
and
are also constant over the entire period
. It is obvious that
because the SG can simply be understood as a heat exchanger used to supply the factory with superheated steam.
2.4.2. High-Temperature Heat Pump
We now describe the relationship between the HTHP, particularly the inlet and outlet temperatures at the HTHX and its electricity demand, and the control variable.
According to Assumption 1, the control variable A representing the heat flow rate in the TES is piecewise constant, i.e., in each interval for . This property is transferred to the HTHX inlet and outlet temperatures and , which result from the given system configuration in which the TES is integrated, the fact that and are constant on and the following energy balances.
In period
during charging, we have an inflow of thermal energy from the HTHP to the thermal oil loop with rate
and an outflow from this loop to the SG with constant rate
. Here,
denotes the specific heat capacity (assumed to be temperature independent) of the thermal oil and
the number of HTHPs operating in parallel in the underlying P2H system, which is not explicitly shown in
Figure 3). The values used are specified in
Supplementary Material, Section S2. Since we neglect losses to the environment, the difference between the two rates gives the constant inflow rate
to the TES during the charging process. Recall that
holds in charging mode, thus it follows
.
Analogously, during discharging, there is an inflow of thermal energy from the SG with constant rate and an outflow to the HTHP with rate . The difference of the two rates determines the outflow rate from the TES, which is . Since during discharging, it follows .
Based on this, we obtain the relations
from which follows for the HTHX outlet and inlet temperatures
which are constant in each of the
N time periods. Here,
denotes the positive and negative parts of
a. From this, the following unified notation can be derived for the mapping given in (
5), which reads
with
. Note that
during charging,
during discharging, and both equations hold true during idle periods.
From [
1] it is known that there is a complex relationship between the HTHX oil outlet temperature
and the HTHX oil inlet temperature
, the HTF mass flow
, the waste heat air temperature
at the LTHX inlet, and the compressor shaft speed
D, which can be expressed by a surrogate model in terms of a multivariate cubic polynomial
as
. As we know from (
6) that
and
are stepwise functions, i.e.,
and
in each interval
for
, and based on the Assumption 2, it follows directly that
D is also constant between two subsequent discrete time points, so we obtain
More specifically, the compressor shaft speed
D can be varied (only at discrete time grid points) to determine the pressure ratio within the HTHP and thus the thermal oil temperature
at the HTHX outlet. Details on the definition of the polynomial function
are provided in
Section S1 of the Supplementary Material.
Another complex relationship from [
1] holds for the electricity consumption
of the HTHP. Again, this is expressed by a surrogate model in the form of a multivariate quadratic polynomial
for
as
The factor
in (
9) as already mentioned above, denoting the number of HTHPs operating in parallel, takes into account that the surrogate model represents only a single HTHP. The detailed definition of
can be found in
Section S1 of the Supplementary Material.
Relation (
9) together with Assumption 2 and the piecewise constant quantities
as well as
implies that
is also constant between two subsequent discrete time points. This demand has to be covered by the sum of the power
drawn from or fed into the grid and the power
generated by the WT, both of which are generally time-varying, meaning that
For
, electricity is drawn (purchased) from the grid, for
, electricity is fed (sold) into the grid. Note that the dependence of the WT power
on the wind speed
W is described by the so-called power curve,
. This is a nonlinear function that grows cubically [
35] at medium wind speeds until it reaches the rated power. This value is kept constant for higher speeds and is set to zero above the cut-out speed and below a cut-in speed of the turbine. More details are given in
Section S6.3 of the Supplementary Material.
Based on (
8) and (
9), the HTHP’s electricity consumption
can be determined at each time point
for a given control
A, which determines, by (
6), the temperatures
and
of the HTF at the outlet and inlet of the HTHX, respectively. Suppose that at time
the control is set to be
, then (
6) implies
and
, and recall that
and
are constants. Then, in a first step, the corresponding shaft speed
is determined by solving (
8) for the unknown
d, i.e.,
. Since
is a cubic polynomial in
d, the solution is among the real-valued roots of this polynomial. For the given
and using the fact that the shaft speed is restricted to values within the interval
, defined by technical conditions [
1], there is a unique root
in this interval. In a second step, the corresponding electricity consumption
is obtained by substituting
into (
9) via
To emphasize the dependence of
on the control
A, we introduce the function
that maps
A to the electricity consumption for
, i.e.,
2.4.3. Thermal Energy Storage Operational Modes
The TES operation can be divided into three operational modes as follows: charging, discharging and idle, where we assume that simultaneous charging and discharging is not allowed. From the previous subsections, the following relations are known for each operational mode:
In charging mode, the excess thermal energy is stored in the sensible TES and increases its medium temperature, while during discharging the cooler HTF with temperature
absorbs heat from the TES and decreases the temperature of the storage medium. For details on the charging and discharging mode, we refer to
Section S3 of the Supplementary Material. In idle mode, the HTF bypasses the TES completely and obviously implies
and
, which also follows directly from
Equations (S3.2) and (S3.5) given in the Supplementary Material. There, we provide further details, including the dependence of the time-varying charging and discharging factors
on the TES temperature
R and the chosen control
.
3. Stochastic Optimal Control Problem
In this section, we formulate the stochastic optimization problem using the Markov decision process framework for the cost-optimal energy management of the industrial P2H system introduced above. Most of the MDP theory can be found in the books of Bäuerle and Rieder [
21], Hernandez and Lerma [
23], Powell [
24], and Puterman [
22]. We would like to refer the interested reader to those books for further information about MDPs. The goal is to find the optimal control that minimizes the expected total cost for electricity consumption from the grid over a finite planning horizon, taking into account the uncertainties of future wind energy and electricity prices as well as the revenues from selling overproduction. The derived stochastic control problem consists of the following blocks: state dynamics, state and control constraints, operational cost functions, state and control space, transition operator, and performance criterion.
3.1. State Dynamics
In
Section 2.3, we introduced the three state variables
, and
S. The dynamics of the endogenous (or controlled) variable
R representing the TES temperature is already given in (
1) and (
3). Here, we focus on the two exogenous states, the wind speed
W and the electricity price
S. Starting with the continuous-time approach, we derive recursions for the state values at the discrete time points
for
. We decompose
W and
S into a non-random function that captures the seasonal patterns and a stochastic Ornstein–Uhlenbeck process that is mean-reverting to zero to describe the unpredictable fluctuations.
Throughout this paper, all stochastic processes and random variables are supposed to be defined on a filtered probability space
. In particular, that space carries a two-dimensional Brownian motion
, with two independent standard Brownian motions
on
, which will be used below to drive stochastic differential equations (SDEs) describing the dynamics of
W and
S. The filtration
is assumed to be generated by
B, that is,
with the
-algebras
, augmented by the
-nullsets, so that
satisfies the usual assumptions. While, the market price of electricity
S can also take negative values, the wind speed
W is always non-negative. We therefore replace
W with
and assume for
Here, the functions
describe seasonal patterns, and
and
are Ornstein–Uhlenbeck processes defined by SDEs
with mean reversion speeds
, diffusion coefficients
, and a constant
. Due to the different natures of wind speed and electricity price, we assume that
to simplify our analysis. A positive constant
leads to a negative correlation of the wind speed
W and the price process
S, see Lemma 1 and Proposition 1 below. This is often observed in energy markets.
The two SDEs above have analytical solutions that allow us to derive the following closed-form expressions for the joint distribution of the pair of random variables
W and
S as follows, with the proofs provided in
Section S5 of the Supplementary Material.
Lemma 1 (Distribution of solutions
to the SDEs (
15))
. Let . Then the solutions of the SDEs (15) on to given initial values and with are Ornstein–Uhlenbeck processes withfor and . The conditional distribution of the pair given is bivariate Gaussian with mean and positive definite covariance matrix given bywhere for with , and the covarianceIt holds that for with equality for . Combining the above result for
and
with the definitions from (
14), and recalling the notation
for
, we obtain the following result for the joint distribution of
given
. This will be useful for the construction of the transition operator and the corresponding transition kernel for the MDP’s state process below in (
34).
Proposition 1 (Conditional distribution of
given
)
. The conditional distribution of the pair given with is bivariate Gaussian with meanand the constant and positive definite covariance matrix andwhere and are given in Lemma 1. Note that the wind speed W follows a log-normal distribution because is Gaussian. The above result on the conditional distribution of the pairs and the fact that the dynamics of the stochastic fluctuations are driven by Brownian motions, i.e., processes with independent increments, can be used to derive a recursion for the discrete-time dynamics of the sequence of these pairs which is driven by a sequence of independent standard normally distributed random vectors.
Corollary 1 (Discrete-time dynamics of wind speed and energy price)
. Let the Cholesky decomposition of the symmetric and positive definite covariance matrix Σ given in Proposition 1 be of the formwhere ρ denotes the associated correlation coefficient. Then there exists a sequence of independent standard normally distributed random vectors such thatwith given in (20). Further, it holds 3.2. State Constraints
The operation and technical design of the underlying P2H system restrict the state and control variables. The state-dependent control constraints derived below in
Section 3.3 result from the following constraints on the state variables.
Due to the configuration of the P2H system, the TES temperature is bounded, i.e., for all n. More precisely, ensuring constant SG inlet and outlet temperatures by fluid bypass regulation implies that the storage temperature cannot be greater than and cannot fall below .
In contrast, the exogenous state variables are generally based on our modeling approach in (
14). Wind speeds are by nature non-negative and potentially unbounded, implying that
. Unlike wind speeds, the electricity prices are also allowed to become negative and we have
. A negative price may occur in the case of overproduction of electricity, while at the same time there is a lower demand in the grid. In addition, in this case, producers are penalized for feeding in additional power, while consumers are rewarded for using electrical energy from the grid.
3.3. Control Constraints
The various state and operational constraints mentioned in the previous subsections imply constraints on the control and lead to state-dependent sets of feasible controls from which the controller can select the actions. In particular, the control
for the period
can only be selected such that technical upper limits for the HTHX outlet temperature
and the HTHX inlet temperature
are not exceeded. While the maximal HTHX outlet temperature
is directly related to the maximal compressor shaft speed, the maximal inlet temperature
is set by system constraints of the HTHP. Furthermore, the controller needs to consider that the time-varying charging and discharging factors
, which determine the bypasses, can only take values in
and must ensure that the TES temperature
R, which is also time-varying, does not leave the range
. Given that the state at the beginning of the period
is
, the control
can be selected from a set of feasible controls
where
are piecewise linear functions of the TES temperature, which we derive in
Equations (S4.3) and (S4.6).
Figure 4 illustrates the derived set of feasible controls and their dependence on
R for the system parameters listed in the
Supplementary Material, Section S2. More precisely, we assume that
kg/s is constant, which implies
°C and
°C and limits the TES operating temperature downwards and upwards, respectively.
3.4. Operational Costs
The operational costs of the system are directly related to the HTHP’s electricity consumption
, which is linked to the HTHX outlet and inlet temperature
and
chosen by the controller, see (
11). Covering the electricity demand depends on the available power output
generated by the WT, which in turn is a function of the wind speed
W. The difference
must be drawn from the grid at the price
S if
. We assume that
is free of charge and does not incur any additional costs such as operational and maintenance costs. Consequently, only the consumed grid power
must be paid and incurs costs. A negative
means an overproduction of WT power that can be sold to the grid for revenue. Here, the selling price is usually lower than the purchase price
S.
In our model, we consider the running operational costs
in each of the periods
. These are defined as the expected cumulative costs in the period
, given that at time
the state
and the control
is chosen, and read as
where
is defined by
with
introduced in (
12). The conditional expectation
emphasizes the dependence on the current time grid point
and the current state
as well as the action
selected at this state. Further, we denote by
and
the positive and negative part of
, respectively. The functional
in (
27) is divided into two parts as follows: (i) the costs for buying electricity from the grid at price
and (ii) the revenue for selling excess energy at a lower price
. Here,
is a user defined model parameter that indicates if selling is allowed or not. If it is not allowed to sell excess energy to generate revenue, we set
. In this case, the surplus or overproduction of energy is discarded. For
, energy is fed into the grid for a reduced market price
given by
where
is called spread. This spread reflects transaction fees, taxes or the willingness of the grid operator to buy energy only at a certain discount on the market price
. A special situation occurs in times of negative market prices
S, which are often caused by energy overproduction. In this case, buying from the grid leads to a reward, i.e., one gets paid for purchasing energy. Selling, on the other hand, causes additional cost to keep the grid stable due to the abundance of energy. Here, a spread
leads to a further reduction of the selling price, which results in higher costs for feeding energy into the grid and therefore makes selling less attractive. For more details on the computation of the running costs
and particularly the conditional expectation in (
26), see
Section S7.1 of the Supplementary Material.
At the end of the planning period, a terminal cost function
can be used to evaluate the terminal state of the system, particularly the amount of thermal energy stored in the TES, in monetary terms. A typical example are
penalty and liquidation payments that are applied if the TES medium temperature is below or above a certain user-defined critical value
. Suppose that the terminal state is
, then the terminal cost is defined by
where the functions
and
describe the amount of thermal energy required to adjust the TES temperature from
r to
. In the case of penalization,
units of thermal energy must be fed in, while for liquidation,
units are withdrawn. If the TES is not sufficiently filled, i.e.,
, a penalty is applied for energy consumption at a fixed price
, depending on the respective temperature difference. In the opposite case, excess energy in the TES is liquidated, which means that energy is sold at the fixed price
, which generates a revenue that appears as a negative terminal cost
. It should be noted that this definition of the terminal cost includes a worthless expiration of the TES by setting
.
3.5. State and Action Space
Summarizing all the information from above, the state process
of the P2H system at time
is described by
with
where the state space
is defined as
with the boundaries according to
and
, resulting from system-related and technical constraints as well as model assumptions. The control process
at a given state
is specified by
with decision rules
The sequence
of decision rules is called a policy. Moreover, the system at a state
can be controlled by choosing the action
. The set of feasible controls
in state
at time
is based on the derived control constraints (
25) in
Section 3.3 and reads for
as
3.6. Transition Operator
The transition from one state to another, within the feasible set
, is mathematically described by the transition operator. For state
, action
at time point
, and a random disturbance
, the state dynamics of the system is defined by the transition operator as
In this context, according to (
3), the endogenous state dynamics for the TES temperature is given by
with
The wind speed
W as an exogenous, stochastic state is modeled as an exponential discrete-time Ornstein–Uhlenbeck process, see (
24). Its dynamic reads as
for
and
. The electricity price
S, the second exogenous and stochastic state, is described using (
24) with
Putting everything together, the transition operator (
34) is given by
For the discrete-time system we will consider a filtered probability space with the filtration where the -algebras are generated by the independent random variables , and is the trivial -algebra.
3.7. Performance Criterion and Optimization Problem
The combination of the discrete-time system and the formulation of the corresponding cost functional allows us to determine the operational performance criterion. In this context, the optimal control of the system is related to a cost-optimal policy such that the expected aggregated running costs (
26) for operating the P2H system and the terminal costs (
29) for an initial state
are minimized. A policy
is a sequence of decision rules
that maps a given state
to an admissible action
. At each point of time, the associated objective function or performance criterion
is given by
with the running and terminal cost defined in
Section 3.4. We denote by
the set of all admissible policies
u such that the objective function (
39) is well-defined and
satisfies the control constraints for all
. An admissible policy
is called optimal if
The function is called the value function and describes the minimal expected aggregated running costs. Therefore, finding the value function is equivalent of finding the optimal policy .
In practice, it is not tractable to minimize over the space of all admissible policies
. We will see that the performance criterion (
39) satisfies a recursion property from which we are able to deduce an alternative way for obtaining the value function. The following theorems can be found in Bäuerle and Rieder ([
21], pp. 21–23). Theorem 1 states that the objective function (
39) fulfills a recursion property.
Theorem 1 (Recursion property)
. Let be a fixed policy. Then for every and the objective function satisfies Using Theorem 1, we obtain that the value function is the solution of the well-known Bellman equation.
Theorem 2 (Bellman equation)
. For every , the value function for satisfies the Bellman equation The Bellman equation reduces the problem of finding an optimal policy to a recursion in which only the optimal actions for each time point n must be found.
Many applications and algorithms use an alternative performance criterion for
, which is often called the state action function and is denoted by
[
36]. It is defined for all
as
Note, that the expectation is conditional to
, and given a policy
u with deterministic decision rules
, it holds that
for all
. As the name suggests, the function
assigns a value to each feasible state action pair
, instead of a single value for each state
x as is the case with the performance criterion
. By Theorem 1, we get that
, satisfies the recursion
The optimal state action function
for
is given by
It further relates to the original value function
by
with optimal policy
and solves the Q-version of the Bellman equation [
37] below.
Theorem 3 (Q-version Bellman equation)
. For every , the optimal state action function for satisfies The main difference between the Bellman equation (
42) and the Q-version (
48) is that the expectation and minimization are interchanged. This offers certain computational advantages both in the calculation of the expected value and in the minimization, which is now a deterministic problem.
6. Numerical Results
In this section, the numerical results obtained by Algorithms 1 and 2, i.e., BDP and Q-learning, are presented and compared with each other. More precisely, we compare the results in terms of accuracy and computational effort of the computed solutions (value function and trajectory). A time horizon of
h is selected for the numerical simulation to find the value function and optimal operation for the industrial P2H system during a working week (5 days). The system and algorithm parameters can be found in
Tables S1a and S1b, respectively. To keep the results of the proposed algorithms comparable, the same action space discretization is used for both. The evaluation of the minimization over the discretized action space is done by calculating all action values and selecting the action with the minimal value. Penalty costs are applied at terminal time if the TES temperature is below a certain threshold value. In the experiments, the storage must be at least half-full, i.e., the critical value is set to
. Furthermore, falling below
is penalized with a penalization price
€/MWh. We do not reward the liquidation of the TES energy and therefore set
€/MWh. Selling excess energy into the grid is also not allowed and we set
. For the calculation of the value function, both methods made use of a time-varying state space discretization, see
Section S8 of the Supplementary Material. For visualization and convenience, we display the value function for fixed grid points selected from the set
. This set is chosen such that it is a subset of
for all
. In order to visualize the results with respect to the three-dimensional state space, we will fix some state variables to specific values and plot them against the remaining variables. In the following, these fixed values are chosen as the corresponding centers of the
r-,
w- and
s-axes.
6.1. Backward Dynamic Programming
Let us first discuss the results of the value function computed by BDP, which are presented in
Figure 6a. The graphics on the left and right show the value function for the initial time step
and the terminal costs
, respectively, as a function of TES temperature and wind speed. Obviously, low wind speed and low TES temperature lead to higher expected costs. While the dependence on the storage temperature is almost linear, the wind speed has a significant nonlinear influence on the value function, whereby the latter effect are induced by the WT power curve model. In addition, the dependence of the value function on storage temperature and electricity price as well as on wind speed and electricity price for the initial time is depicted in
Figure 6b on the left and right, respectively. The electricity price affects the expected costs mostly linearly with respect to the TES temperature, with higher prices leading to higher values. Again, higher storage temperatures reduce costs and compensate for expensive grid electricity. The relation between wind speed and electricity price is also almost linear if we consider changes with respect to the prices. However, in terms of wind speed, the values again reflect the nonlinear power curve model.
Second, we analyze a trajectory, starting from the initial state
with
, for the control obtained by BDP as shown in
Figure 7a. As expected, the control aims to charge the TES during periods of high wind power production and/or low prices. Charging that solely uses wind energy can be identified when the HTHP’s electricity consumption (dashed black line) is covered by the available wind energy (green area), while additional power from the grid (blue area) is used to charge the TES when the price falls to small values.
For instance, in hours 60 to 65, a combination of both scenarios can be observed. Conversely, when electricity prices are high and wind energy is not enough to cover the nominal HTHP power consumption, the TES is discharged, see, e.g., hours 43 to 48. Approximately four hours before the time horizon is reached, the storage temperature is reduced to match the desired threshold .
For further details on the optimal control A, see Figure 10a, where the optimal decision rule is plotted as a function of time and TES temperature. At each time step , the decision rule is calculated for the corresponding TES temperature level (left y-axis) and the values of the seasonalities and at that time step. The seasonality functions (green line) and (dashed red line) with their corresponding scales are also presented (right y-axis). The colored red and blue areas correspond to the charging and discharging mode of the system with the respective heat flow rate. The white areas represent the idle mode of the system, i.e., no charging or discharging is operated.
It can be seen that the control obtained by BDP captures the functional structure of the seasonalities. This means that when prices are globally low ( takes a global minimum), for example, at the hours 25, 50, or 75, charging is the preferred action. Conversely, discharging is performed when prices are high and wind speeds are low, see hours 20 or 45. For hours 15, 35, or 60, we can observe that when prices and wind speeds are locally high, the optimal action is to wait and operate in idle mode. Another situation where waiting is optimal appears when the storage temperature is higher than the critical temperature (dotted gray line) and prices are at the global minimum of , see, e.g., hour 45 to 55. However, when a maximum price is reached, the P2H system operates in discharge mode to compensate for the high electricity prices. Furthermore, when observing the seasonal patterns, it can be seen that the controls for charging, discharging, and idle mode are usually centered around the local and global extrema of . In particular, the electricity price appears to have a greater influence on the control than the wind speed (wind energy), as it has a major impact on the operational costs of the P2H system. An exception exists shortly before the terminal time , when it is optimal to charge the TES if its temperature is below the critical temperature , regardless of the seasonal functions. This is to avoid penalties incurred at time if the TES is not properly filled.
6.2. Q-Learning
We now compare the results of Q-learning using replay buffer, summarized in Algorithm 2, and BDP based on the computed value function and the corresponding control. Thus, BDP serves as a benchmark, as we can expect accurate results due to the high computational effort. For the parameterization of
a two-layer neural network is used with 128 neurons for each layer and ReLU activation functions. Since the parameterization is defined globally on the state space, no state discretization is required for BDP. The state distribution of the initial states
is chosen as a uniform random distribution on the discretized state space
.
Figure 8a,b shows the value function of both methods depending on TES temperature and wind speed as well as on wind speed and electricity price, respectively, for the hours 0, 45, 85, and 117. More precisely, in each value function plot of Q-learning, the reference solution of BDP is visualized as a gray shaded graph. In addition, the red lines represent a cross-section of the value function, meaning that the value function is fixed in two variables and is visualized in order to provide a more detailed view at the error between both solutions. For a better comparison, the cross-sections (from
Figure 8) are also depicted in
Figure 9. Compared to BDP, Q-learning is able to capture the same shape of the value function. Especially for
n near the terminal time, both function approximations differ only slightly. The further we move back in time from the terminal time, the more differences become visible.
Figure 7b also confirms that the approximation of the value function by Q-learning is similar to that of BDP. The difference in the control is mainly reflected in the charging and discharging intensity of the TES and thus affects the HTHP’s electricity consumption. Apart from this, the controller aims to charge the TES during times of high wind energy availability or/and low prices and to discharge vice versa. Overall, the comparison shows that the Q-learning control is qualitatively similar to that of BDP. However, an exception is the control in
Figure 7b, which almost does not contain any waiting periods. Instead, the charging or discharging periods are generally longer compared to the BDP control, which can be seen in hours 15 to 25. Furthermore,
Figure 10b provides a more detailed look at the optimal decision rule obtained with Q-learning. Obviously, the charging mode is performed in regions where price seasonality has a global minimum. However, almost every time a peak occurs, the high prices are compensated by discharging the TES. Again, the role of wind speed appears to be less important than the influence of the electricity price on the control itself. Even though seasonality is taken into account, the overall structure and sequence are not captured as well as with the BDP.
In addition to the qualitative comparison of the numerical results with BDP and Q-learning, the computational effort required to compute the numerical solution is also of practical importance. Here, the computational time serves as an indicator of how well the methods are able to deal with the curse of dimensionality. All computations are performed on a compute server with 320 GB RAM running two Intel Xeon Gold 6136 processors, each with 12 cores and 24 threads. BDP calculates and saves the value function for the grid points of the discretized state spaces . To speed up the computations of the value function in each time step, we will use all available cores and calculate its values for different grid points in parallel. In total, BDP requires 36 h computational time, which corresponds to approximately 18 min per time step. In contrast, Q-learning only takes around 8 h on a single core to compute the approximate solution. This means a time saving of a factor of 4 for the problem considered with three-dimensional states and one-dimensional actions. For stochastic optimal control problems in higher dimensions, we can expect much greater savings.
7. Conclusions
This work presents a mathematical model for the cost-optimal operation of an industrial P2H system. Apart from providing a modeling approach for the stochastic processes that takes into account correlation between wind speed and electricity price, we also calibrated the associated parameters with real-world data (see
Supplementary Material, Section S6). The resulting discrete-time stochastic optimal control problem is formulated as an MDP and solved using the classical dynamic programming approach as well as modern reinforcement learning techniques, namely Q-learning.
A comparison of the numerical results shows that both methods can achieve similar approximations of the value function and yields reliable cost-optimal decision rules. Although the results of Q-learning differ in some aspects, it offers a faster and computationally more efficient solution for complex control problems. This is especially useful for problems with high-dimensional state and control spaces, where the dynamic programming approach will fail due to the curse of dimensionality.
By dropping the assumptions of constant mass flow
and waste heat temperature
, we can extend our model and make it more general. In this case, it is necessary to introduce
as an additional state and
as an additional control variable, which increases the dimension of the control problem. Even though the classical backward recursion of dynamic programming might become intractable for this extended model due to the curse of dimensionality, we are confident that Q-learning still offers an efficient solution. However, as the dimension of the action space grows, it becomes infeasible to calculate the minimal action by discretization. Appropriate gradient descent methods could be used, at the cost that this may slow down the algorithm. Reinforcement learning algorithms such as policy gradients or actor-critic methods as in [
27] might be more suitable for dealing with large (continuous) action spaces, as they already include a way to handle this minimization step.