1 Introduction

In the last decades, we have assisted in the increase of renewable energy penetration in the electricity market, in particular from wind and solar sources. This is caused by the increasing concern about environmental pollution and global warming, and the awareness of having to exploit sources of clean energy to decrease the use of fossil fuels (Biancardi et al., 2023; Janzen et al., 2020; Razmjoo et al., 2021).

One of the main problems that hinder the use of wind power is its intermittent nature caused by rapid and unpredictable fluctuations in wind speed. This conflicts with the stability required by the energy market to guarantee a systemic balance and security (Frate et al., 2020).

Among the control strategies used to decrease the high variability of wind power, the ramp-rate limitation has seen increasing use in recent years (Bossavy et al., 2015; D’Amico et al., 2021, 2022b; Hittinger et al., 2014). Limiting the ramp rate means limiting the rate at which the power production varies between two consecutive time steps. The ramp-rate limits might be violated in two ways: up-ramping events, meaning that the variation is positive, and down-ramping events, when the change is negative (Gallego-Castillo et al., 2015). Predicting these two types of events has been in the spotlight of wind-farm managing literature for a while (Cui et al., 2021; Zheng et al., 2022).

The ramp-rate event is considered a critical event because its delayed and inadequate control can cause serious damage to the power grid and consequent economic losses. Several of the largest system operators, such as the Electric Reliability Council of Texas (ERCOT) and the state-owned electric power transmission operator in Ireland, EirGrid, require ramp-rate control to wind generators. According to the grid characteristics, it can be requested to control the ramp rate within 1- and 10-min limits (Cui et al., 2023; D’Amico et al., 2022b; Hittinger et al., 2014).

Wind farms subjected to ramp-rate limitations usually use a storage system for two main purposes: providing power when a ramp-down occurs, and storing power in the presence of a ramp-up event (Abdullah et al., 2014; Hittinger et al., 2010; Khalid & Savkin, 2010; Lone & Mufti, 2008; Teleke et al., 2009). Batteries are the most used energy storage systems due to their quick response time and easy installation, and, in this context, its main variables of interest are the size and the state of charge, but in principle also pumped-storage generating system can be used (Li et al., 2019).

In the literature, particular attention is given to the ramp rate detection and prediction (Cui et al., 2021; Zheng et al., 2022), and, more in general, to the application of stochastic processes that make the operator able to know in advance the future behaviour of the system in terms of wind power variability (An et al., 2012; Chen et al., 2009; D’Amico et al., 2013a; Grassi & Vecchio, 2010; Lee & Baldick, 2012). These aspects are relevant from an economic perspective due to the possibility of forecasting the economic losses of a wind farm under a ramp-rate policy (Cui et al., 2021, 2017). The amount of penalty can be significant if we consider that, for example, that in ERCOT the penalty is computed by multiplying the energy (in MW-h) not meeting the ramp-rate up or down limitations by the regulation up or down prices, which were \(16\$\)/MW-h and \(13\$\)/MW-h in 2008–2009, respectively (Hittinger et al., 2014). According to Wan (2011), in Texas, between 2004 and 2009, the number of large ramp events with magnitude \(>25\%\) of the highest annual wind generation is 235 per year, on average. If we want to have a rough estimate of the penalization, we can assume that the average installed capacity in Texas is 2500 MW in such a period, and the average amount of ramp events with magnitude \(>25\%\) of the highest annual wind generation is 625 MW. By considering an average penalty of \(14.5\$\)/MW-h, we obtain a total average penalty of about \(9000,00\$\) per year. These economic losses refer to the ramp events with magnitude \(>25\%\), which is very high. If we lower the percentage the losses increase.

Ramp-rate limitations are usually coupled with a penalty policy if the wind farm does not meet the imposed limits (Hittinger et al., 2014). Among the existing penalty systems applied by the system operators, one largely used method consists of multiplying a fixed monetary amount and the number of MW above or below the ramp-rate limits. The work of D’Amico et al. (2021) considers a system comprising a wind farm with a ramp-rate limitation policy and a battery, with the aim of forecasting the penalties received by the operator over a given time period. This kind of system shows a nonlinear behaviour, which is due to the interaction between the charge and discharge processes and the storage capacity of the battery. Indeed, as ramp events occur throughout time, the battery’s state of charge shifts accordingly. This affects the ability to dispatch or store energy as needed to avoid penalties. In summary, the variations of energy are subject to a time-varying nonlinear random constraint, which is the result of the wind speed fluctuations, state of charge, and ramp-rate policy. A discrete-time homogeneous Markov chain is used to model the battery operations, which are divided into three states: the charging event, the discharging event, and the neutral event or absence of operations. During each charging/discharging period, the random power stored/supplied by the battery is assumed to be a discrete collection of independent, not identically distributed, random variables. The penalty is then calculated by multiplying the random charges/discharges by the regulation fees. However, the Markovian assumption was proved to be not completely satisfactory in this context by D’Amico et al. (2022a), where a semi-Markov process was instead considered to model the battery operations and, consequently, the penalty dynamics were set to evolve as a semi-Markov modulated reward process. This kind of stochastic process has been largely used in the literature (D’Amico et al., 2013b; Feinberg, 1994; Papadopoulou et al., 2012).

This paper builds on the semi-Markov approach used in D’Amico et al. (2022a) by using a modification of a Brownian Bridge (BB) to model the charging/discharging processes during the battery’s operation periods. Hence, we take off the independence assumption, considered by D’Amico et al. (2021) and (2022a), between the random charges/discharges at different times, which does not seem to be supported by real data and can be considered only as an approximation of the behaviour of the system. Besides, a BB model accounts for the convenient Markovian and Gaussian properties along the waiting time of the underlying semi-Markov process, and it is one of the most exhaustively studied diffusion bridges, making it an appealing model from theoretical and applicable perspectives. We use 10 years of wind speed real data to compute the power production of a hypothetical wind turbine located in Sardinia, which we use to obtain the penalty associated to three different ramp-rate limitations: \(1\%\), \(5\%\) and \(7\%\) of the wind turbine rated capacity. An estimation of the penalty process is then produced via a Monte Carlo simulation algorithm. The results suggest that our semi-Markov-modulated model succeeds in simulating the accumulated penalty process over a given time period.

The rest of the paper is structured as follows. Section 2 introduces the ramp-rate policy and sets the semi-Markov model that governs the battery operation process. When the battery is either charging or discharging, a discrete-time model based on a BB is proposed in Sect. 3 to model the dynamics of the random charges. We then introduce, in Sect. 4, two key processes: the one associated with the state of the charge of the battery, and the penalty process. The last one is then generated via Monte Carlo simulations in Sect. 5, where we show the competitiveness of our method by comparing its results against the penalty obtained from real data. Final thoughts are relegated to Sect. 6.

2 The semi-Markov model of sequential ramp-rate events

Ramp-rate limitations can be used to smooth the power produced from the wind turbine and obtain a more stable output. We limit both up-ramping and down-ramping events, as done in Hittinger et al. (2014). This limitation decreases the slope by which the power profile changes between two consecutive time steps, it is indicated as a percentage of the rated capacity of the wind farm, and its unit of measure can be MW/h. Lower percentages represent stricter limitations. For example, if we consider a rated capacity of 2 MW, a ramp-rate limitation of \(1\%\) penalizes changes faster than 0.02 MW/h.

For \(\delta > 0\) and \(k\in \mathbb {N}\) let e(k) be the power generated at time \(\delta k\), and define the modified power at the same time, denoted by \(\bar{e}(k)\), as

$$\begin{aligned} \bar{e}(k) := \left\{ \begin{array}{rl} \bar{e}(k-1) + \ell \delta , & \text {if } e(k) > \bar{e}(k-1) + \ell \delta \quad \quad \quad \text {(up-ramping event)} \\ \bar{e}(k-1) - \ell \delta , & \text {if } e(k) < \bar{e}(k-1) - \ell \delta \quad \quad \quad \text {(down-ramping event)} \\ e(k), & \text {otherwise } \end{array} \right. \end{aligned}$$
(1)

where \(\ell > 0\) is the ramp-rate limit. For the sake of simplicity and because it does not sacrifice generality, we set \(\delta = 1\) for the rest of the paper. Working with an arbitrary time-step length follows identical steps. The following is an interpretation of the earlier quantities: the power generated by the wind turbine at time k is denoted by e(k), while the power that is effectively injected into the electrical grid at time k is denoted by \(\overline{e}(k)\). The ramp-rate policy is employed to stabilize the grid because \(\overline{e}(k)\) exhibits milder variations and less steep slopes than e(k).

We connect a battery to the wind turbine to either store or supply energy in case of an up-ramping or down-ramping event, respectively. A penalization is applied every time the battery cannot store the total energy surplus or provide the required energy.

We consider the battery operations over time as a Markov chain \(\left\{ J_n\right\} _{n\in \mathbb {N}}\) with state space \(E=\{-1,0,+1\}\). States \(-1\) and \(+1\) indicate discharging and charging operations, associated, respectively, with a down-ramping and up-ramping event. The state 0 represents the unchanged condition, that is, the battery is neither charging nor discharging, which occurs when the power production meets the ramp-rate limits. The process \(\left\{ K_n\right\} _{n\in \mathbb {N}}\) stands for the n-th time in which the battery changes state. We assume that \(K_0 = 0\) and \(K_n < K_{n+1}\) for all \(n \in \mathbb {N}\). The (sojourn) time the battery remains in the state \(J_{n}\), before the \((n+1)\)th jump, is denoted by \(X_{n+1}\). Formal definitions of \(J_n\), \(K_n\), and \(X_n\), are given below:

$$\begin{aligned} K_n&= \inf \left\{ k > K_{n-1} : \textrm{sgn}(e(k) - \bar{e}(k)) \ne \textrm{sgn}(e(K_{n-1}) - \bar{e}(K_{n-1}))\right\} , \\ J_n&= \textrm{sgn}(e(K_n) - \bar{e}(K_n)), \\ X_{n+1}&= K_{n+1} - K_{n},\quad X_{0}=0. \end{aligned}$$

We assume that \(\left\{ (J_n, K_n)\right\} _{n\in \mathbb {N}}\) is a Markov Renewal process, and define its kernel as

$$\begin{aligned} q_{i,j}(k)&:= \mathbb {P}\left( {J}_{n+1} = j, {X}_{n+1} = k \mid {J}_{n} = i\right) \\&= \mathbb {P}\left( {J}_{n+1}=j,{X}_{n+1} = k \mid {J}_{n} = i, J_{n-1}, \ldots , {J}_{0}, {K}_{n}, \ldots , {K}_{0}\right) . \end{aligned}$$

According to the previous relation, regardless of what the values of the past variables were, knowing the last battery operation, \(J_n\), is sufficient to provide the conditional joint distribution of the pair, \(J_{n+1}\), and \(X_{n+1}\).

For later reference, we introduce the conditional sojourn-time distribution

$$\begin{aligned} h_i(k) := \mathbb {P}\left( X_{n+1} = k\ |\ J_n = i\right) = \sum _{j \in E} q_{ij}(k) \end{aligned}$$
(2)

as well as the transition probabilities of the embedded Markov chain

$$\begin{aligned} p_{ij} := \mathbb {P}\left( J_{n+1} = j\ |\ J_n = i\right) = \sum _{k = 0}^{\infty } q_{ij}(k), \end{aligned}$$
(3)

and the conditional (to the sojourn time) transition probabilities

$$\begin{aligned} p_{ij}(k)&:= \mathbb {P}\left( J_{n+1} = j | J_n = i, X_{n+1} = k\right) = q_{ij}(k)/h_i(k). \end{aligned}$$
(4)

Finally, consider the process \(N(k) = \max \{{n > 0:K_n \le k\}}\), which counts the number of transitions up to time k, as well as the Semi-Markov Chain (SMC) associated with the Markov Renewal chain \((J_{n}, K_{n})\), indicated by \(J_{N(k)}\), for \(k\in \mathbb {N}\).

3 A Gauss–Markov model for battery operations between ramp-rate events

The purpose of this section is to model the battery storing operations using a BB, which is a well-studied process and accounts for two desirable properties, namely Gaussianity and Markovianity.

3.1 Setting the model

Consider the semi-Markov model of battery operations introduced in the previous section and call a random segment to any triplet \((J_n, J_{n+1}, X_{n+1})\), for \(n\in \mathbb {N}\). Hence, a random segment comprises an initial state \(J_n\) denoting the current operation, its time length \(X_{n+1}\), and the next operation \(J_{n+1}\). Thereby, the triplet \((J_n = +1, J_{n+1} = -1, X_{n+1} = 5)\), for instance, denotes a segment where the battery after charging for 5 units of time starts discharging afterwards.

Let C(k) represents the theoretical random energy charged/discharged into/from the battery at time \(k\in \mathbb {N}\). Define \(C_{J_n, J_{n+1}, X_{n+1}}:= \left\{ C_{J_n, J_{n+1}, X_{n+1}}(k)\right\} _{k = 1}^{X_{n+1}}\) be the process representing the charge (\(J_n = +1\)) or discharge (\(J_n = -1\)) during the nth stage of the SMC. Note that this notation presumes that the charging/discharging process depends on \(J_n\), \(J_{n+1}\), and \(X_{n+1}\), and is independent of \(K_n\). We assume that it is also independent of \(\left\{ C(m)\right\} _{m = 0}^{K_n - 1}\). That is, for \(k = 1, \ldots , x\),

$$\begin{aligned}&\mathbb {P}\left( C(K_n + k - 1) \le c\ \big |\ J_n = i, J_{n+1} = j, X_{n+1} = x, K_n = K, \left\{ C(m)\right\} _{m = 0}^{K_n - 1}\right) \\&\qquad = \mathbb {P}\left( C_{i, j, x}(k) \le c\right) . \end{aligned}$$

Consider the discrete-time processes \(\mathcal {C}_{i,j,x}:= \left\{ \mathcal {C}_{i, j, x}(k)\right\} _{k = 0}^{x+1}\), for \(i\in \{-1, +1\}\), \(j \in \{-1, 0, +1\}\backslash \{i\}\), \(x \in \mathbb {N}\). Moreover, set

  1. (P.1)

    \(\left\{ \mathcal {C}_{i,j,x}(k)\right\} _{k = 1}^x = \left\{ |C_{i,j,x}(k)|\right\} _{k = 1}^x\),

  2. (P.2)

    \(\mathcal {C}_{i,j,x}(0) = \mathcal {C}_{i,j,x}(x+1) = 0\).

In this way, we are embedding the charging process \(C_{i,j,x}\) into the bridge process \(\mathcal {C}_{i,j,x}\). Indeed, (P.1) sets the embedding while (P.2) ensures that \(\mathcal {C}_{i,j,x}\) can be regarded as a bridge that vanishes at its initial and terminal times. Note that the absolute-value transformation in condition (P.1) does not introduce identifiability issues as \(C_{i,j,x}\) has constant sign. Figure 1 shows some linearly-interpolated sample paths of \(\mathcal {C}_{i,j,x}\).

Fig. 1
figure 1

Battery charges/discharges \(\mathcal {C}_{i, j, x}\). The coloured dots represent the actual values of the charges/discharges, which are linearly interpolated. (a) accounts for \((i = -1, j = 0, x = 4)\), while in (b) \((i = +1, j = 0, x = 4)\). (Color figure online)

Essentially, properties (P.1) and (P.2) define the size of the charging/discharging values for each segment of the SMC that is enlarged by introducing two boundary conditions at the times 0 and \(X_{n+1}+ 1\), where the size of the charging/discharging is set to zero.

For a neater notation, we will define the shorthands \(C_n:= C_{J_n, J_{n+1}, X_{n+1}}\) and \(\mathcal {C}_n:= \mathcal {C}_{J_n, J_{n+1}, X_{n+1}}\).

We now introduce a parsimonious model for \(\mathcal {C}_{i,j,x}\). Define the parameters

$$\begin{aligned} \tau _{i,j,x}&:= \arg \max \left\{ \mathcal {C}_{i,j,x}(k) : k = 1,\ldots , x\right\} ,\quad h_{i,j,x} := \mathcal {C}_{i,j,x}(\tau _n), \end{aligned}$$
(5)

and the error process

$$\begin{aligned} E_{i,j,x}(k) := \mathcal {C}_{i,j,x}(k) - g_{i,j,x}(k), \end{aligned}$$
(6)

where, for \(0< \tau < x+1\) and \(h > 0\), \(g_{i, j, x}\) is given by

$$\begin{aligned} g_{i, j, x}(t)&:= \frac{h_{i,j,x}}{\tau _{i,j,x}}t\mathbb {1}(t\le \tau _{i,j,x}) + \frac{h}{T - \tau _{i,j,x}}(x + 1 - t)\mathbb {1}x + 1 - \tau _{i,j,x} \end{aligned}$$
(7)

Thus, \(C_n\) can be split into the sum of the (triangle-shaped) function \(g_{i,j,x}\) plus the stochastic process \(E_{i,j,x}\). Figure 2 shows a few paths of these three processes.

Fig. 2
figure 2

(a) Shows three paths of the bridge process Ci,j,x. (b) Displays these same charges (transparent lines), alongside the triangle functions \(g_{i, j, x}\) derived from them. The associated error process \(E_{i, j, x}\) is shown in (c). All images account for \(i = -1\), \(j = 0\), \(x = 5\), and the ramp-rate coefficient \(\ell = 0.02\). The values of \(\{\mathcal {C}_{i, j, x}(k)\}_{k = 1}^x\) are remarked using bullet points in the curves that result after linearly interpolating them

Let \(\bar{e}_{i, j, x}\) be the corrected power at the time when the battery changes to the state \(i\in E\) and remains there for a sojourn time x, after which it changes to the state \(j \in E\backslash \{i\}\). Hence, \(\bar{e}_{i, j, x}\) has the same distribution as \(\bar{e}(K_n)\) for all n such that \((J_n = i, J_{n+1} = j, X_{n+1} = x)\). We are implicitly assuming that \(\bar{e}(K_n)\) depends entirely on \(J_n\), \(J_{n+1}\), and \(X_{n+1}\).

Consider now the variable

$$\begin{aligned} \rho _{i, j, x} := {\left\{ \begin{array}{ll} \min \{\max \{\bar{e}_{i,j,x} - \ell , \ell (x+1)\}, P_r\}, & \text { if } i = -1 \\ \max \{P_r - (\bar{e}_{i,j,x} - \ell ), P_r - \ell (x+1), 0\}, & \text { if } i = +1 \end{array}\right. }, \end{aligned}$$
(8)

where \(P_r\) is the rated capacity of the wind turbine. The variable \(\rho _{i, j, x}\) can be regarded as the initial corrected power along the random segment \((J_n = i, J_{n+1} = j, X_{n+1} = x)\).

In (8), the adjustments \(\bar{e}_{i,j,x} - \ell \) and \(Pr -(\bar{e}_{i,j,x}) - \ell \) are justified by the assumption that the battery has been charging/discharging for exactly one unit of time before the first observed battery operation of the random segment. The lower bounds \(\ell (x+1)\) and \(Pr - \ell (x+1)\) are needed because the battery remains in the state i exactly one unit of time after the last observed operation, making a total charging/discharging time length of \(x+1\). Finally, the formula takes into account the fact that the initial power cannot exceed the rated capacity \(P_r\) neither be negative.

Note that

$$\begin{aligned} 0 \le \mathcal {C}_{n}(k) = |(e - \bar{e})(K_n + k - 1)| \le \rho _{J_n, J_{n+1}, X_n} - (k-1)\ell , \quad k = 1, \ldots , x. \end{aligned}$$
(9)

Inequality (9) alongside the non-negativity of \(\mathcal {C}_n\) yield the following restrictions to the error process \(E_{i, j, x}\):

$$\begin{aligned} E_{i, j, x}(k) = \max \left\{ -g_{i, j, x}(k), \min \left\{ Y_{i, j, x}(k), \rho _{i, j, x} - (k - 1)\ell - g_{i, j, x}(k)\right\} \right\} , \quad k = 1, \ldots , x, \end{aligned}$$
(10)

for some process \(Y_{i, j, x}:= \left\{ Y_{i, j, x}(k)\right\} _{k = 1}^x\). We choose to model \(Y_{i, j, x}\) as a BB going from \((0, 0)\in \mathbb {R}^2\) to \((T, 0)\in \mathbb {R}^2\) and forced to stop by \((\tau _{i, j, x}, 0)\). Hence, \(Y_{i, j, x}\) admits the representation

$$\begin{aligned} Y_{i, j, x}(k) = Y_{i, j, x}^{(1)}(k \wedge \tau _{i, j, x}) + Y_{i, j, x}^{(2)}((k - \tau _{i, j, x})\vee 0), \quad k = 1, \ldots , x, \end{aligned}$$
(11)

where \(Y_{i, j, x}^{(1)}\) and \(Y_{i, j, x}^{(2)}\) are two independent BBs satisfying the representation

$$\begin{aligned} Y_{i, j, x}^{(1)}(k)&:= \sigma _{i, j , x}\left( W^{(1)}(k) - \frac{k}{\tau _{i, j, x}}W^{(1)}(\tau _{i, j, x})\right) , \quad k = 1, \ldots , x, \end{aligned}$$
(12)

and

$$\begin{aligned} Y_{i, j, x}^{(2)}(k)&:= \sigma _{i, j, x}\left( W^{(2)}(k) - \frac{k}{x+1 - \tau _{i, j, x}}W^{(2)}(x+1 - \tau _{i, j, x})\right) , \quad k = 1, \ldots , x, \end{aligned}$$
(13)

where \(W^{(1)}\) and \(W^{(2)}\) are independent standard Brownian motions, and \(\sigma _{i, j, x} > 0\) is the common volatility term.

3.2 Estimation of the parameters

We provide here a mechanism to generate the parameters \(\rho _{i, j, x}\), \(\tau _{i, j, x}\), \(h_{i, j, x}\), and \(\sigma _{i, j, x}\). Define the shorthand notations \(\rho _n:= \rho _{J_n, J_{n+1}, X_{n+1}}\), \(\tau _n:= \tau _{J_n, J_{n+1}, X_{n+1}}\), and \(h_n:= h_{J_n, J_{n+1}, X_{n+1}}\). For \(\rho _n\), \(\tau _n\), and \(h_n\), in alignment to D’Amico et al. (2022a), we assume that all their values belong to the same population as soon as they share the same sojourn time as well as initial and next charging stages. That is, if we consider a generic segment identified by the triplet \((J_n = i, J_{n+1} = j, X_{n+1} = x)\), then the set of values

$$\begin{aligned} \left\{ (\rho _{m}, \tau _m, h_m) : J_m = i, J_{m+1} = j, X_m = x\right\} _{m\in \mathbb {N}} \end{aligned}$$

are simulations of the joint distribution of \((\rho _{i, j, x}, \tau _{i, j, x}, h_{i, j, x})\), which we denote by \(f_{i, j, x}:{\mathcal {D}}_{n} \rightarrow \mathbb {R}_{+}\), and has the support

$$\begin{aligned} \mathcal {D}_{i, j , x} := \left\{ (\rho , \tau , h) : \rho \in [\underline{\rho }, \overline{\rho }],\; \tau \in \left\{ 1, \ldots , x\right\} ,\; h \in (0, \overline{h})\right\} , \end{aligned}$$

with, in alignment to (8),

$$\begin{aligned} \underline{\rho } = {\left\{ \begin{array}{ll} 0, & \text {if } i = +1 \\ P_r - (x+1)\ell , & \text {if } i = -1 \end{array}\right. }, \quad \overline{\rho } = {\left\{ \begin{array}{ll} (x+1)\ell , & \text {if } i = +1 \\ P_r, & \text {if } i = -1 \end{array}\right. }, \end{aligned}$$

and

$$\begin{aligned} \overline{h} = {\left\{ \begin{array}{ll} \rho - \tau \ell , & \text {if } i = +1 \\ P_r - (\rho + \tau \ell ), & \text {if } i = -1 \end{array}\right. }. \end{aligned}$$

The upper bound \(\overline{h}\) comes after (8) and the definition of \(h_n\) in (5).

We estimate \(f_{i, j, x}\) in a non-parametric fashion by relying on kernel estimations of their vine copulas. This method is well-documented in Nagler (2014). Besides the flexibility of its non-parametric nature, the main drive for choosing this technique was its robustness in high-dimensional frameworks.

This method simulates \(\tau _{i, j, x}\) as a continuous variable within the interval [0, x], and then we replace that original simulation with the nearest value within the support \(\left\{ 1, \ldots , x\right\} \).

We leaned on the approach suggested by Geenens et al. (2017) for the copulas density estimation. They build on a larger body of works that transform observations in the unit square \([0, 1]^2\) into \(\mathbb {R}^2\), where standard kernel density estimation techniques can be used, and a back-transformation recovers the copula density estimation. Specifically, Geenens et al. (2017) propose a local likelihood estimator by means of quadratic polynomials approximations.

We performed the kernel density estimation with these specifications via the R package kdevine (Nagler, 2022).

To avoid running into small data issues for the bandwidth matrix estimation, we bootstrapped the sample of any random segment with less than 10 observations and introduced small perturbations to guarantee differences among the new data values.

We illustrate in Fig. 3 how this method of estimating \(\rho _{i, j, x}\), \(\tau _{i, j, x}\), and \(h_{i, j, x}\) captures the distribution of the real data.

Fig. 3
figure 3

Simulation of the parameter \(\tau _{i, j, x}\) (x-axis), \(h_{i, j, x}\) (y-axis), and \(\rho _{i, j, x}\) (z-axis). Black dots represent real data, while blue dots are randomly generated points from the kernel density estimation of \(f_{i, j, x}\). Red points in (b) indicate the augmented bootstrapped data. For all images, \(i = -1\), \(j = 0\), and \(\ell = 0.02\). (Color figure online)

The remaining parameter to be estimated is the volatility term \(\sigma _{i, j, x}\). Recall that the BBs in (12) and (13) share the same volatility. The Gaussian and Markovian properties of the BB make it easy to come up with the following formula for the maximum likelihood estimator of \(\sigma _{i, j, x}\):

$$\begin{aligned} \widehat{\sigma }_{i, j, x}&:= \sqrt{\frac{1}{M_{i, j, x}}\sum _{m = 1}^{M_{i, j, x}}(u_m - u_{m-1})^{-1}\left( Y_{i, j, x}(u_m)\frac{\tau _{i, j, x}(m) - u_{m-1}}{\tau _{i, j, x}(m) - u_m} - B_{i, j, x}(u_{m-1})\right) }, \\ \end{aligned}$$

with \(M_{i, j, x}:= \sum _{k=1}^{x} \mathbb {1}(Y_{i, j, x}(k) = E_{i, j, x}(t_k))\), and

$$\begin{aligned} u_0&= 0,\quad u_m = \min \left\{ k : k > u_{m-1}, Y_{i, j, x}(k) = E_{i, j, x}(k)\right\} ,\quad m = 1, \ldots , M_{i, j, x}, \end{aligned}$$
(14)
$$\begin{aligned} \tau _{i, j, x}(m)&= \mathbb {1}(u_m \le \tau _{i, j, x})\tau _{i, j, x} + \mathbb {1}(u_m > \tau _{i, j, x})(x + 1). \end{aligned}$$
(15)

The definition of \(u_m\) in (14) is necessary to pick up only the times that truly represent the jumps in the BBs’ paths, and do not account for spurious values due to the representation of the error process \(E_{i, j, x}\) in (10). In (15), we set \(\tau _{i, j, x}(m)\) as a single term to denote the different terminal points of \(B_{i, j, x}^{(1)}\) and \(B_{i, j, x}^{(2)}\).

One might be tempted to assume that \(\sigma _{i, j, x}\) is homogeneous with respect to other parameters like \(\rho _{i, j, x}\), \(\tau _{i, j, x}\), \(h_{i, j, x}\), and x, or the battery stages \(J_n = i\) and \(J_{n+1} = j\). However, empirical evidence suggests otherwise. For instance, higher heights \(h_{i, j, x}\) tend to produce higher volatilities, as Fig. 4 shows. It also illustrates that a convenient transformation of the volatility might result in a linear relationship between these two parameters.

Fig. 4
figure 4

Images of the relation between the volatility and the height. The y axis marks the values of \(\widehat{\sigma }_{i, j, x}\) for any value \(x\in \mathbb {N}\), and with \(i = -1\) and \(j = 0\) for (a), and \(i = -1\) and \(j = 0\) for (b), while values of \(h_{i, j, x}\) are in the x-axis. For both figures, \(\ell = 0.02\)

In light of this numerical evidence, we take \(\rho _{i, j, x}\), \(\tau _{i, j, x}\), \(h_{i, j, x}\), x, and all their first-order interactions, as regressors in a linear model where a transformation of \(\widehat{\sigma }_{i, j, x}\) is the response. The transformation is chosen from a catalog of several parameterized functions, such that it better helps the linear model to meet its assumptions, namely normality, homoscedasticity, and linearity. We used the R package trafo (Medina et al., 2018) to perform this transformation selection. All cases pointed out to Box-Cox-type transformations, having the following form

$$\begin{aligned} q_\lambda (x) = {\left\{ \begin{array}{ll} (x^\lambda - 1)/\lambda , & \lambda \ne 0 \\ \log (x), & \lambda = 0 \end{array}\right. }. \end{aligned}$$

The final estimation of the volatility \(\sigma _{i, j, x}\) is taken to be the anti-transformed mean of the linear model response, whose parameters are chosen to better fit the data

$$\begin{aligned} \left\{ (\widehat{\sigma }_{J_m, J_{m+1}, X_{m+1}}, \rho _m, \tau _m, h_m, X_{m+1}) : J_m = i, J_{m+1} = j\right\} _{m\in \mathbb {N}}. \end{aligned}$$

Actually, we fit the linear model twice. A first fitting was used to ditch out observations with outlier Cook’s distances, according to Tukey’s method of tagging an outlier as anything farther than 3 times the interquartile range from the median. The second and final fitting was done with the remaining observations. Figure 5 illustrates the final fit for \(i = -1\) and \(j = 0\). Table 1 shows the values of the adjusted \(R^2\) as a metric of the goodness of the different linear models.

Fig. 5
figure 5

Check for the linear-model assumptions before and after taking the transformation \(q_\lambda \), with \(i = -1\), \(j = 0\), and \(\ell = 0.02\)

Table 1 Adjusted R2 of the different linear models

The GitHub repository https://github.com/aguazz/WindPower-BatteryCharge provides all the R code and data necessary to implement the estimations and numerical algorithms introduced in this section.

Section 5 provides an algorithm to simulate paths of \(\mathcal {C}_{i, j, x}\). The algorithm’s performance is validated by comparing the mean and covariance matrices of real and simulated data of \(\mathcal {C}_{i, j, x}\), for different values of i, j, and x.

4 Techno-economical analysis

The study of the ramp-rate policy requires an analysis of the battery’s State Of Charge (SOC) along with the mechanism of the penalty cost.

Consider the backward-recurrence-time process \(B(k) = k - K_{N(k)}\), and let S(k) represents the SOC of the battery at time \(k \ge 1\), defined by

$$\begin{aligned} S(k)&:= {\left\{ \begin{array}{ll} (\mathcal {C}_{N(k)}(B(k) + 1) + S(k-1)) \wedge \overline{c} & \text {if } J_{N(k)} = +1 \\ (S(k-1) - {\mathcal {C}}_{N(k)}(B(k) + 1)) \vee \underline{c} & \text {if } J_{N(k)} = -1 \\ S(k-1) & \text {if } J_{N(k)} = 0 \end{array}\right. }, \end{aligned}$$

where \(\overline{c}\) and \(\underline{c}\) are the maximum and minimum SOC levels, respectively. Note that \(S(k)\in [\underline{c},\overline{c}]\) for all \(k \ge 1\). We remind that, although it is not explicitly stated in the equation above, \(\mathcal {C}_n\) depends on \(J_n\), \(J_{n+1}\), and \(X_{n+1}\). The previous relation is illustrative of the nonlinear nature of the considered stochastic system. The state of charge process is the result of a nonlinear transformation applied to the charging/discharging process which involves the random charge/discharge and the limit of the battery’s capacity. It is obvious that, in contrast to linear reward structures, the penalty process inhales the nonlinearity of the SOC process and makes it challenging to evaluate the accumulated discounted penalty process.

Likewise, consider the penalty process

$$\begin{aligned} M(k)&:= {\left\{ \begin{array}{ll} x_{+1}(\mathcal {C}_{N(k)}(B(k) + 1) - (\overline{c} - S(k-1))^+ & \text {if } J_{N(k)} = +1 \\ x_{-1}(\mathcal {C}_{N(k)}(B(k) + 1) - (S(k-1) - \underline{c}))^+ & \text {if } JN(k) = -1 \\ 0 & \text {if } J_{N(k)} = 0 \end{array}\right. }, \end{aligned}$$

where the constants \(x_{+1}\) and \(x_{-1}\) are the penalties per unit of time associated with up-ramping and down-ramping events, respectively.

Finally, consider the cumulative discounted penalty up until time \(k \in \mathbb {N}\), defined as

$$\begin{aligned} W(k) := \sum _{m=0}^k M(m) e^{-r m}, \end{aligned}$$

where \(r \ge 0\) is the discount rate.

5 System simulation

The two simulation Algorithms 1 and 2 can be used to generate random paths of the charging/discharging process \(C_{i, j, x}\) discussed in Sect. 3, as well as the SOC and the penalty processes, S and M, introduced in Sect. 4.

Algorithm 1
figure a

Battery charge/discharge simulator

Figure 6 shows simulated paths of \(\mathcal {C}_{i, j, x}\), for different values of i, j, and x, produced by implementing Algorithm 1. Note that they visually resemble the real-data paths.

Besides the visual validation in Fig. 6, we provide the relative mean \(L^2\)-error between the real and the estimated sample means and sample covariance matrices, displayed in Figs. 7 and 8, respectively. We only considered those random segments with at least 30 observations. For each random segment, we simulated as many paths as the maximum between 3 times the real-data sample size and 100 trajectories.

Fig. 6
figure 6

Real versus simulated charges. The first column of images accounts for real-data charges, that is, paths of \(\mathcal {C}_{i, j, x}\) pinned to (0, 0) and \((x + 1, 0)\). The second column displays simulated paths of \(\mathcal {C}_{i, j, x}\). The images on the first raw account for \(x = 5\), while the second row uses \(x = 45\). For all images, \(i = -1\), \(j = 0\), and \(\ell = 0.02\)

Fig. 7
figure 7

Relative \(L^2\)-error, expressed in percentage terms, between the real-data and simulated sample mean. The numbers in the x-axis represent the values of \(X_{n+1}\), while the numbers on top of the bars are the real-data sample size. For all the images, \(\ell = 0.02\)

Fig. 8
figure 8

Relative \(L^2\)-error, expressed in percentage terms, between the real-data and simulated sample covariance matrices. The numbers in the x-axis represent the values of \(X_{n+1}\), while the numbers on top of the bars are the real-data sample size. For all the images, \(\ell = 0.02\)

Algorithm 2 simulates trayectories of the Markov Renewal chain \(\{(J_{n}, K_{n})\}_{n\in \mathbb {N}}\), as well as the SOC process \(\{S(k)\}_{k\in \mathbb {N}}\) and the penalty process \(\{M(k)\}_{k\in \mathbb {N}}\).

Algorithm 2
figure b

Semi-Markov reward, SOC, and penalty processes simulator

Next we estimate the first and second moments of \(W = \{W(k)\}_{k = 1}^K\), for \(K = 24\). That is, the hourly average and standard deviation of the cumulative penalty process within a day. To do so, we used Algorithms 1 and 2 to simulate N different trayectories of W, \(W^n = \{W(k)^{(n)}\}_{k = 1}^K\), \(n = 1, \ldots , N\). Once the N trajectories have been simulated, it is possible to estimate the moments of the accumulated penalty process for any time \(t \in \mathbb {N}\) by computing the corresponding sampling moments

$$\begin{aligned} \frac{1}{N}\sum _{n=1}^N \left( \sum _{k=1}^t M^{(n)}(k)e^{-rk}\right) ^a,\quad a = 1,2,... \end{aligned}$$

For the wind-farm layout, we consider the battery described in (Hittinger et al. 2014, Table 4), that is, a NaS battery with a module energy capacity equal to 0.36 MWh. These batteries are remarkably cost-efficient compared to super-capacitors and flywheels (Hittinger et al., 2010), and their fast response is fundamental to smooth wind-power changes. We consider 10 years of real-data hourly wind speed to obtain the power production of a hypothetical wind turbine located in Sardinia. As done in D’Amico et al. (2022a), we transform the wind speed data into wind power production by means of the function

$$\begin{aligned} P(v) := {\left\{ \begin{array}{ll} 0 & \text {if } v< \underline{v} \\ P_r\frac{v^3 -\underline{v}^3}{v_r^3 - \underline{v}^3} & \text {if } \underline{v}< v< v_r \\ P_r & \text {if } v_r< v < \overline{v} \\ 0 & \text {if } v > \overline{v} \end{array}\right. }, \end{aligned}$$

where \(\underline{v}\) is the cut-in wind speed, \(\overline{v}\) is the cut-out wind speed, \(v_r\) is the rated velocity, and \(P_r\) is the rated capacity of the wind turbine. We set \(\underline{v} = 4\,m/s\), \(\overline{v} = 25\,m/s\), \(v_r = 13\,m/s\), and \(P_r =2MW\) (D’Amico et al., 2022a; Vergine et al., 2022).

The penalty fees are set to \(x_{+1} = 21.52\) €/MWh and \(x_{-1} = 26.50\) €/MWh. These values are the ones used in Hittinger et al. (2014) after being made proportional to the average electricity price in Italy.

Fig. 9
figure 9

Hourly average cumulative penalty and standard deviation of real and simulated data with ramp-rate limitation percentage equal to \(1\%\) (\(\ell = 0.02\))

Fig. 10
figure 10

Hourly average cumulative penalty and standard deviation of real and simulated data with ramp-rate limitation percentage equal to \(5\%\) (\(\ell = 0.1\))

Looking at Figs. 9, 10 and 11, we can notice that the simulations are less accurate for the ramp-rate limitation of 7%. This is due to the fact that a higher percentage corresponds to a less strict limitation and, consecutively, to a smaller number of times that the system does not comply with it, which leads to a smaller data-set and, consequently to more biased estimations.

This fact is supported by the Mean Absolute Percentage Error (MAPE) calculated for the hourly average between real and simulated data. It is a metric that defines how accurate the forecasted quantities are in comparison with the actual quantities and represents the average of the absolute percentage errors. We obtain the values of 2.54, 11.34, and 20.18 for the ramp-rate limitations of \(1\%\), \(5\%\), and \(7\%\), respectively. This confirms the behavior described above with the value of 2.54, which is very close to the value of 1.77 obtained in D’Amico et al. (2022a) with the same ramp-rate limitation, where the proposed model needs a larger number of parameters, being the charge/discharge values independent and not identically distributed at each time within a sojourn time length. The model proposed in this work gives similar results but captures better the correlation structure in the sample charge/discharge paths. The second-order moment is characterized by greater but contained values of MAPE, 5.56, 5.92, and 8.35 for the three studied limitations.

Fig. 11
figure 11

Hourly average cumulative penalty and standard deviation of real and simulated data with ramp rate limitation percentage equal to \(7\%\) (\(\ell = 0.14\))

6 Concluding remarks

We applied a discrete-time semi-Markov process to model the operations of charge and discharge of a battery storage system connected to a wind farm under a ramp-rate limitation strategy. Within each charging/discharging period, we model the charge/discharge process as a modified Brownian bridge with three parameters. The resulting semi-Markov-modulated modified Brownian bridge model was used, via Monte Carlo simulation, to estimate the first and second-order moments of the cumulative discounted penalty coming from violating up-ramp and down-ramp limitations. Not only the estimations are accurate when compared to real data, but they resemble the results obtained by D’Amico et al. (2022a), where the authors used a model with a large number of parameters. In particular, the results show average daily losses ranging from almost 30€ for a ramp rate limitation of \(7\%\) up to almost 150€ for the more strict limitation of \(1\%\).

Our results can be used to improve the management of the wind farm, since they allow us to obtain detailed information about the state of charge of the battery energy system, as well as the penalty dynamics associated to a ramp-rate limitation policy. The two algorithms we propose provide an accurate calculation of these variables over time.

Potential extensions of this work include exploring different limitation strategies and storage system technologies and estimating higher moments of the cumulative penalty process. The theoretical calculation of the cumulative penalty process moments is also a worthy path to explore. Finally, using the continuous-time version of the Brownian bridge process in (12) and (13), one might be able to come up with a continuous-time model for the battery charges/discharges.

This work represents the first step for alluring wind-power producers into accepting ramp-rate policies, by designing effective incentive systems to compensate the potential associated penalties. These systems have the complementary objective of ensuring the stability of the network by charging costs not only to wind-energy producers.