<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Autoregressive Time Series</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Taras Mykhailovych</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mykhailo Fryz</string-name>
          <email>mykh.fryz@gmail.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Iaroslav Lytvynenko</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Ternopil 'Ivan Puluj' National Technical University</institution>
          ,
          <addr-line>Rus'ka st., 56, Ternopil, 46001</addr-line>
          ,
          <country country="UA">Ukraine</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Problems of urban water provision enterprises, such as: geographical zoning, pressure normalization, emergency detection, were stated. Water consumption of such an urban water provision enterprise is being studied by the authors. Water consumption mathematical model was presented and justified as cyclostationary. Hourly water consumption time series were justified in terms of linear forecasting. Water consumption operative interval forecasting method and its existing authors' information technology were presented and revised. Problems of existing information technology were stated. Improvements to information technology were proposed. The advantages of the iterative forecasting method were explained. Streaming algorithm of water consumption forecasting was proposed and presented. Algorithm implementation and deployment preferences were proposed. Next steps of the research were defined.</p>
      </abstract>
      <kwd-group>
        <kwd>1 Water consumption</kwd>
        <kwd>cyclostationary process</kwd>
        <kwd>operative linear forecasting</kwd>
        <kwd>time series</kwd>
        <kwd>periodic autoregressive</kwd>
        <kwd>prediction interval</kwd>
        <kwd>streaming algorithm</kwd>
        <kwd>iterative method</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        The practical value of the urban water consumption forecasting technology is providing efficient
management of clean water supply at the pressure, needed by customers [
        <xref ref-type="bibr" rid="ref1 ref2">1, 2</xref>
        ]. As per [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], an
information technology, which implements hourly water consumption operative interval forecasting
method, may solve the significant problems of urban water provision enterprises, such as:
geographical zoning, pressure normalization, emergency detection. It may be mostly useful in scaling
ahead the water pipeline systems and their emergency states detection.
      </p>
      <p>Subjects of study are as following.
 Water consumption — a stochastic process: an oscillation of water flow (measured in liters per
hour) in time
 Hourly water consumption — a stochastic time series: hourly water volume (measured in liters)
 Unit water consumption — one short-term consumption session (i.e. temporary valve opening)
by any impartible user (i.e. a person). Example of unit water consumption is “Mr. John Smith
washes his hands after returning home at 9pm, Sep 18, 2021”</p>
      <p>First two items above describe the consumption from urban water provision enterprise in a broad
sense: by some user: a person, an apartment, a building, a zone (geographic or logistic group of
buildings) etc., and of any scope (any combination of consumption sessions by that user).</p>
      <p>Object of study is operative (one step ahead) interval forecasting. Resulting prediction intervals are
considered as highly likely expected water consumption bounds and are “red lines” of theoretically
normal operation of the water provision system. Falling out from the prediction interval is a display of
probable emergency, which may be false positive due to the human factor, yet another reason to
ensure the sanity of the related system node.</p>
      <p>
        In [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] the authors described an information technology: it was developed for specific needs of an
urban water provision enterprise. It allows the collection and processing of data from water
consumption monitoring hardware.
      </p>
      <p>The most computation-heavy part of information technology is PAR (periodic autoregressive
model) parameters estimation method, which requires inversions and multiplications of very big
matrices on a regular basis (every hour). This computation improves the PAR parameters estimates
after acquiring each new hourly water consumption value. The updated parameter estimates are then
used to compute prediction intervals for the next hours.</p>
      <p>Recurring processing of all available historical data for PAR parameters estimation have
introduced a problem: the computation became slower for each next cycle of estimation, and kept
requiring more and more runtime and computing resources. This is so, because the calculation was
done using all available historical data from scratch, without reusing the results from previous
computations.</p>
      <p>
        This paper proposes developing a method to update the PAR parameters estimates, without need to
recompute them from a whole range of historical data. This will be achieved by developing an
onepass streaming algorithm for real-time PAR parameter estimation upon the iterative method of least
squares updating, proposed in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
      <p>Another problem is current deployment of mentioned information technology on a custom
dedicated server, which is not reliable, because it has following limitations.</p>
      <p> Requires specific computational hardware (a video card)
 Requires extreme electric energy consumption (for video card)
 Requires 24/7 unchoked operation
 Is not horizontally scalable
 Is not backed by a replica server</p>
      <p>A new water consumption operative interval forecasting method, upon updating streaming
algorithm implementation (which is low-memory and low-CPU consuming), allows to take advantage
of cloud environments and move the deployment to a serverless computing platform, in order to do
the following.</p>
      <p> Conserve the energy resources
 Conserve the costs on hardware wearout and development operations
 Scale the computations horizontally by users
 Have reliable 24/7 service and backing from the platform</p>
      <p>An approach of deployment transition to such a platform is also proposed in this paper.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Related Works</title>
      <p>
        Recently known water consumption models, short-term forecasting methods, and current state of
research in the field were described in a digest [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] of considered publications. They were analyzed by
authors in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], in respect to stated in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] problems of urban water provisioning on an enterprise, and
are considered as incomplete for the following reasons.
      </p>
      <p> Not being stochastic
 Not being cyclostationary
 Having insufficient theoretical background</p>
      <p>
        In [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], the authors defined the water consumption as an additive stochastic mathematical model of
unit water consumptions. Each unit water consumption ξ˘ k (t ), k ∈ℤ is approximated by scaled
ϕ ( s ; l)={ 1 , if s ∈[0 , l ) , l ∈( 0 , ∞) .
      </p>
      <p>0 , otherwise
are T-periodic by their time arguments:</p>
      <p>
        f ξ (u1 , u2 , ... , un ; t1 , t2 , ... , tn)= f ξ (u1 , u2 , ... , un ; t1+T , t 2+T , ... , t n+T ), n ∈ℕ, (5)
since intensity λ (τ ) of unit water consumers connection to a water provision system, is
(theoretically) daily periodic: λ (τ )=λ (τ +T ), T = 24 h. Thus, process (3) is cyclostationary [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
      </p>
      <p>
        In [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], hourly water consumption ξ t , t ∈ℤ was represented as periodic autoregressive (PAR)
time series (with period T = 24 h), adequate to (3) in terms of linear forecasting approach [8]:
t p (6)
ξ t=t∫−1 ξ ( s ) ds , t ∈ℤ , ξ t= mt +ξt , ξ t=k∑=1 ak ,t ξ t−k + bt ηt ,
where mt — periodic mean of hourly water consumption: periodic (with period T ) time series,
expectation E ξ t+kT = mt , t ∈[1 , T ], k ∈ℤ and mt= mt+T ∀ t ; ξ t — centered PAR time series with
period T , E ξ t=0 , ∀ t ; ak ,t — a-parameters of PAR: weights of dependency from sample
{ξ k∣k ∈[t− p , t−1]}, containing previous p number of values before ξ t , ak ,t =ak ,t +nT ∀ t ,
k ∈[1 , p], n∈ ℤ; p — PAR model order: number of a-parameters, p ∈ℕ ; bt — b-parameter of
PAR: periodic standard deviation of generating time series (a white noise bt ηt , which is a stochastic
component of PAR model), bt=bt +T ∀ t , E bt=0 , Var (bt)&lt; ∞; η t — basic white noise, E ηt =0 ,
Var (ηt )=1.
      </p>
      <p>
        A method of hourly water consumption operative forecasting was proposed in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. According to
this method, an operative forecast (one hour ahead prediction value) is a point estimate ξ t of
stochastic value ξ t , and is determined from: recent p number of centered values
{ξ k∣k ∈[t− p , t−1]} of hourly water consumption historical data, mean estimates m^ t , and
aparameters estimates a^k ,t :
p
ξ^ t= m^t + ξ^ t , ξ^ t=k∑=1 a^k ,t ξ t−k .
      </p>
      <p>For each period index t , mean estimates m^ t are determined from historical data as:
1 q−1
m^ t= q k∑=0 ξ t+k T , t =[1 , T ] , m^t =m^ t+nT , n∈ℤ ,
(7)
(8)
q=[ nξ −Tt −1 ], (9)
where q — size of historical data periodic sample for period t ; nξ — size of all historical data;
[ x ] — floor integer of x .</p>
      <p>The a-parameters estimates a^k ,t are determined from centered (by periodic mean estimates)
historical data ξ t=ξt− m^t ∀ t , by solving the matrix equation:</p>
      <p>A^ t=(W tT Wt )−1 W tT Xt , t=[1 , T ] , (10)</p>
      <p>A^ tT=( a^1, p+t
X tT=(ξ p+t</p>
      <p>a^2 , p+t ... a^ p , p+t ) ,
ξ p+t +T</p>
      <p>... ξ p+t+(q−1)T ) ,
W t=(
ξ t+T + p−1
...</p>
      <p>ξ t+ p−2
ξ t+T+ p−2
...</p>
      <p>ξt
ξ t+T</p>
      <p>...
ξt +( q−1) T+ p−1
ξ t+(q−1) T+ p−2
... ξt +( q−1) T
).</p>
      <p>Mean estimates m^ t and a-parameters estimates a^k ,t are improved every hour for corresponding
period index t .</p>
      <p>The b-parameter estimates b^t are used once to determine the best-fit PAR order p by applying
the method of minimal description length (MDL) [9], and was calculated from centered (by mean
estimate) historical data and a-parameters estimates a^k ,t :
b^ p+t= 1 q∑−1 (ξ p+ xT+t−∑n a^k , p+t ξ p +xT +t−k )2 , t=[ 1 , T ] , b^t= b^t+nT , n∈ℤ . (12)
q−1 x=0 k=1</p>
      <p>
        A method of hourly water consumption operative interval forecasting was proposed in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
According to it, each prediction interval is determined from prediction errors εt , t ∈ℤ . Each
prediction error εt is a difference of hourly water consumption ξ t from its most recent forecast ξ^ t
(which is the only one in operative forecasting):
      </p>
      <p>εt =ξ t− ξ^ t . (13)</p>
      <p>Analysis of (13) using known "portmanteau" test [10] has shown that its empirical distribution is
not Gaussian. Therefore, the interval forecasting is based on methods of non-parametric statistics.
Thus, for some preset confidence probability γ , prediction interval [ Lt , H t ] of water consumption
ξ t , is:</p>
      <p>Lt= ξ^ t + hε , 1−2γ ;</p>
      <p>H t= ξ^ t + hε , 1+2γ ,
where Lt — lower bound of prediction interval; H t — upper bound of prediction interval; hε , x —
x-quantile estimate of time series εt distribution (known to be symmetric):</p>
      <p>hε , x=ε ([nε x+1])−2ε( [nε(1−x )+1]) , (15)
where ε( k) — k-th order statistic of time series εt (array of all its values sorted ascending); nε —
size of ε( k ) ; [ x ] — floor integer of x.</p>
      <p>The above hourly water consumption operative interval forecasting method was developed into
information technology and tested on an urban water provision enterprise. Two versions of software,
implementing the PAR parameter high-performance estimation parallel algorithm, had been
developed and split-tested. Those versions differ by the following parallel computation technologies.
 OpenCL — allows more precise computations (double-precision floating point), but requires
specific drivers (i.e. CUDA for nVidia) and Node.js OpenCL bindings (“node-opencl” [11] was
used)
 OpenGL — utilizes vertex shaders and GLSL and is widely available without specific
computational drivers. It may use WebGL interface of modern web-browsers (this is handy to
offload the computations onto the web clients), and headless Node.js module [12]; yet this method
is limited in precision (usually only single-precision floating point computations are available)
Despite the simplicity of OpenGL-based software integration, the authors considered it’s precision
as insufficient for big ranges of historical data, used for PAR parameters estimation, so this version of
software has been deprecated in favor of its OpenCL-based version.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Proposed methodology</title>
      <p>The improvement, described in this paper, concerns updating ( 8) and (10) without recalculation
from scratch. This is achieved by using iterative methods of real-time estimates updating,
programmed into a one-pass streaming algorithm, which is based on iterative data processing, without
need to store them all (only a small recent fixed-length subset of them is stored, which is a sliding
(11)
(14)
window) [13]. The OpenCL-based algorithm will be used once for initial a-parameter estimation (10);
all subsequent updating will be done using the proposed iterative method.</p>
    </sec>
    <sec id="sec-4">
      <title>3.1. Mean estimates updating</title>
      <p>Mean estimation method, used in water consumption forecasting information technology, can be
depicted as follows: for period iteration q (which is algorithm iteration t +(q−1)T ), equation (8) is
represented as:
m^ t= S t , t ∈[1 , T ], (16)</p>
      <p>q
where S t — cumulative sum of data samples by period index t , defined as:</p>
      <p>q−1 (17)
S t=∑ ξt +k T .</p>
      <p>k =0</p>
      <p>Persistent variables t , q , and {S t∣t ∈[1 , T ]} are defined and preserved between algorithm
iterations in a fail-safe storage (i.e. “Redis” key-value storage), and in runtime cache. Such estimation
algorithm consumes only 2 integer, and T double precision floating point values of memory and
storage.</p>
    </sec>
    <sec id="sec-5">
      <title>3.2. The a-parameters estimates updating</title>
      <p>
        According to [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], a-parameters estimates a^k ,t , k ∈[1 , p], t ∈[1 , T ], can be improved, using least
squares updating method, which can be depicted in matrix form, for period iteration q (not less than
p ), as:
      </p>
      <p>A^ t ,q+1=A^ t ,q+ Pt ,q Qt ,q( QtT, q Pt ,q Qt , q+1)−1 (ξ p+t +qT−QtT,q A^t , q), (18)</p>
      <p>T T
Pt ,q+1= Pt ,q−Pt ,q Qt , q( Qt ,q Pt ,q Qt , q+1)−1 Qt , q Pt ,q ,</p>
      <p>QtT,q=(ξ t +qT + p−1 ξ t+qT + p−2 ... ξ t+qT ) ,</p>
      <p>q≥ p , t ∈[1 , T ],
where A^ t ,q — column matrix of a-parameters estimates (10) before an update (for iteration q of
^
period index t ); A t ,q+1 — updated column matrix of a-parameters estimates (for iteration q +1 of
period index t ); Qt ,q — column matrix of size p×1 ; Pt ,q — symmetric square matrix of size
p× p .</p>
      <p>
        In (18), A^ t ,q and Pt ,q are defined as recurrence relations. According to [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], their initial values
can be calculated from scratch by using the historical data, using matrix equations, compatible with
(10):
      </p>
      <p>W t ,q=(
^
A t ,q=Pt , q W tT,q Xt ,q ,</p>
      <p>−1</p>
      <p>Pt ,q=( WtT, q W t ,q ) ,
X tT,q=( ξ p+t</p>
      <p>ξ p+t +T ... ξ p+t +(q−1) T ) .</p>
      <p>According to (18), A^ t ,q can be additively updated. So, its current state can be preserved in
persistent variables {A^ t∣t ∈[1 , T ]}. In each algorithm iteration, deltas</p>
      <p>Δ A^t , q= Pt , q Qt ,q (QtT,q Pt , q Qt ,q +1)−1(ξ p+t+qT −QtT,q A^ t ,q) (20)
may be calculated for period index t into a temporary matrix Δ A^ , and used to update matrix A^ t
inplace. Variables {A^ t∣t ∈[1 , T ]} consume p T double precision floating point values of memory and
storage.</p>
      <p>The same, additive updating is also applied to Pt ,q , current state of which can be preserved in
persistent variables {Pt∣t ∈[1 , T ]}. In each algorithm iteration, deltas</p>
      <p>Δ Pt ,q=− Pt , q Qt ,q (QtT,q Pt , q Qt ,q +1)−1 QtT,q Pt , q (21)
may be calculated for period index t into a temporary matrix Δ P , and used to update matrix Pt
inplace. Variables {Pt∣t ∈[1 , T ]} consume p2 T double precision floating point values of memory and
storage. Also, they can be compressed by deduplicating the symmetric entries of matrices, to consume
T p (1+ p)</p>
      <p>double precision floating point values.</p>
      <p>2</p>
      <p>
        As it concluded from [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], the current state of matrices Qt ,q can be represented by a single sliding
window [13]: on each algorithm iteration, one element is appended to its rear (this value is the current
hourly water consumption value ξ ), and one element is removed from its front (the oldest value in it).
An iterable queue of fixed length p is enough to preserve the state of this sliding window between
algorithm iterations. This queue can be defined in persistent variable Q (which is considered in
calculations as column matrix, where the bottom entry of the matrix is the front element of the queue).
It consumes p double precision floating point values of memory and storage.
      </p>
      <p>Persistent variables t , Q , {Pt∣t ∈[1 , T ]}, and {A^ t∣t ∈[1 , T ]} are defined and preserved
between algorithm iterations in a fail-safe storage, and in runtime cache. Such estimation algorithm
p (3+ p )
consumes 1 integer and T ( p2+ p+1) (or T ( + 1) with deduplication of symmetric entries)
2
double precision floating point values of memory and storage.</p>
    </sec>
    <sec id="sec-6">
      <title>3.3. Streaming algorithm of operative forecasting method</title>
      <p>The a-parameters estimation algorithm uses mean estimates, and the operative forecast from
previous iteration. So, streaming algorithms for mean and a-parameters estimation are combined
along with an operative forecasting algorithm. The generalized algorithm is optimized by computation
complexity to minimize the number of floating-point divisions and multiplications, thus conserving
the cost of CPU usage in serverless computing environments, for which the algorithm is targeted. It’s
a one-pass streaming algorithm, which means that it inputs each hourly water consumption value only
once. This value is latched to a sliding window Q , and persists there only during next p iterations.
Thus, algorithm iterations of the improved forecasting method don’t require the whole array of
historical data values anymore.</p>
      <p>Streaming algorithm of water consumption operative interval forecasting has two phases [14]:
setup and iteration. Setup phase is performed at start; then, after its successful completion, algorithm
iterations (recurring runs of iteration phase) are performed. The algorithm doesn’t need a wrap-up
phase, as persistent variables are stored after each iteration to a fail-safe storage. Algorithm can be
applied to any water consumption user, for which the scope of available contiguous historical data
ξ t , T ∈[1 , nξ ] allows inversion in matrix Pt ,q calculation (19), i.e. matrix (WtT,q Wt , q) is not
singular.</p>
      <p>Subsequent iteration phase runs for the same user must not overlap or fail: each next run must
happen only after successful completion of its predecessor. So these runs must not be triggered
directly by hourly water consumption value arrival, but backed by fail-safe execution queue (i.e.
“Google PubSub”); so that arrival event pushes the input value to this queue and then the queued
values get processed strictly sequentially by the platform. If the run fails, it should be retried until the
success. Such architecture may lead to the chokes, especially when backing services experiencing
long-term connectivity issues. To minimize such risks, all backing services of information technology
(i.e. fail-safe storage) must persist on the same platform, region, and network; and forecast demanding
client should either be backed by outgoing queue, or do not require contiguous forecast delivery
(treating delivery failures as success, allowing algorithm to continue).</p>
      <p>This algorithm may be horizontally scaled by water consumption users, as their water
consumptions (and thus, parameters and forecasts) are independent.</p>
    </sec>
    <sec id="sec-7">
      <title>Setup phase</title>
      <p>This phase must be performed prior to recurring runs of the iteration phase for each user. It
organizes the operating state of computing environment, and prepares the persistent variables by the
following actions.</p>
      <p> Reserving space for them in fail-safe storage
 Reserving space for them in runtime cache (if setup and iterative phase runtimes are sharing
operative memory within one execution space)
 Setting their initial values
 Saving them to runtime cache and fail-safe storage
 Using them for initial estimation and forecasting (optional)
Setup phase steps of water consumption streaming algorithm are as follows.
1. Input initial historical data array ξ t , T ∈[1 , nξ ]
2. Define persistent variables t , q , {S t∣t ∈[1 , T ]}, {m^ t∣t ∈[1 , T ]}, Q , {Pt∣t ∈[1 , T ]},
{A^ t∣t ∈[1 , T ]}, and ξ^ ; and reserve them in storage
3. Calculate period index t :=(nξ −1) mod T + 1
4. Calculate period iteration index q :=[ nξ −t−1 ]</p>
      <p>T
W t ( y , x )=ξ t+ p−x+(y−1)T =ξt + p−x+( y−1)T − m^t + p−x ,
X t ( y )=ξ p+t+( y−1)T=ξ p+t+(y−1)T− m^t+ p−x ,
where W t ( y , x ) — row y column x entry of matrix W t ; X t ( y ) — row y entry of X t
8. Define matrices {W tT∣t ∈[1 , T ] } as views of matrices {W t∣t ∈[1 , T ] }, using function
V t ( y , x )= Wt ( x , y),
where V t ( y , x ) — row y column x entry of W tT
9. Define variables {Sk∣k ∈[1 , T ]}, and calculate them, using a parallel computing algorithm for
matrix multiplication [12], as:
a. {Sk = WkT, q W k ,q∣k ∈[1 , t ]},
b. {Sk = WkT, q−1 W k ,q−1∣k ∈[ t+ 1 , T ]},
where W k ,n= Wk ( y , x )∣x∈[1, p] , y ∈[1 ,n] ; W kT,n= Vk ( y , x )∣x∈[1 , p], y∈[1, n]
10. Calculate matrices {P k=Sk−1∣k ∈[1 , T ]}, using a parallel computing algorithm for matrix
inversion [12].
11. Create queue Q , and fill it with elements {ξ t+qT +k=ξ t+qT +k −m^ t +k∣k ∈[0 , p−1]}, inserted
in order of growing k
12. Calculate a-parameters estimates:
a. {A^ k=Pk W kT,q X k ,q∣k ∈[ 1 , t ] },
b. {A^ k=Pk W kT,q−1 Xk , q−1∣k ∈[t +1 , T ]},
where X k ,m= Xk ( y )∣y ∈[1 ,m]
13. Calculate operative forecast ξ^ =m^ t +QT A^ t . Output it to the client
14. Receive feedback from client, that output was either successfully consumed or failed. This
step is optional
15. Store modified persistent variables t , q , {S t∣t ∈[1 , T ]}, {m^ t∣t ∈[1 , T ]}, Q ,
{Pt∣t ∈[1 , T ]}, {A^ t∣t ∈[1 , T ]}, and ξ^ into runtime cache and fail-safe storage
16. Allow iterator phase runs</p>
      <p>Variables S u , m^ k , Sk , and A^ k are calculated in two passes, because they can have different q
within period index intervals [1 , t ] and [t +1 , T ], for historical data not aligned by period T . If
historical data are aligned by period T , steps 5.b, 6.b, 9.b, and 12.b are not performed.</p>
      <p>Step 14 is optional, and allows the algorithm to continue after a failure. This is so, because the
failure to deliver this initial forecast won’t violate contiguity of subsequent forecasts (which may be
required by the client).</p>
      <p>There is no concern about computation complexity of setup phase, as this phase is performed once
per algorithm run (thus once for each water consumption user), and affords more budget for
computation.
3.3.2.</p>
    </sec>
    <sec id="sec-8">
      <title>Iteration phase</title>
      <p>After acquiring each next hourly water consumption value ξ from the sensor, the iteration phase
is performed. Persistent variables get loaded by either of the following ways.</p>
      <p> From fail-safe storage — for first run on new execution context (and then are preserved in
runtime cache)
 From runtime cache — for recurring runs on the same execution context</p>
      <p>As the iteration phase is recurring in real-time, it’s memory consumption and computing
complexity are minimized as much as possible.</p>
      <p>Iteration phase steps of water consumption streaming algorithm are as follows:
1. Input hourly water consumption value ξ
2. Load persistent variables t , q , {S t∣t ∈[1 , T ]}, {m^ t∣t ∈[1 , T ]}, Q , {Pt∣t ∈[1 , T ]},
{A^ t∣t ∈[1 , T ]}, and ξ^
3. If t=T : reset period index t :=1, increase period iteration index q :=q+ 1; else: increase
period index t :=t +1
4. Update cumulative sum for period index t : S t := St +ξ
5. Update mean estimate for period index t : m^ t := S t . This needs one floating-point division
q
6. Define and calculate variable R =Pt Q . Multiplication of these matrices may be done using the
classic algorithm. It needs p2 multiplications of floating-point values
7. Define and calculate variable Y =R (QT R +1)−1 . Calculation of this expression needs 2 p
multiplications and one division (to calculate reciprocate number) of floating-point values
8. Define and calculate variable ε=ξ −ξ^ k . Its value is operative forecasting error
9. Define and calculate variable Δ A^= Yε . This needs p floating-point multiplications
10. Update a-parameters estimate A^ t := A^ t + Δ A^
11. Define and calculate variable Δ P=−Y R T . This needs p2 floating-point multiplications
12. Update matrix Pt := Pt +Δ P
13. Push ξ to rear of queue Q , and remove one element from its front
14. Calculate operative forecast ξ^ =m^ t +QT A^ t . This needs p floating-point multiplications.
Output it to the client
15. Receive acknowledgment (feedback of success) from client, that output was successfully
consumed. If it has failed, terminate the algorithm run
16. Store modified persistent variables t , q , {S t∣t ∈[1 , T ]}, {m^ t∣t ∈[1 , T ]}, Q ,
{Pt∣t ∈[1 , T ]}, {A^ t∣t ∈[1 , T ]}, and ξ^ to runtime cache and fail-safe storage</p>
      <p>Computation of iteration phase needs 2 p2 +4 p multiplications and two divisions of
floatingpoint values.</p>
      <p>Step 15 preserves the client’s concern about contiguity of subsequent forecasts. If the client
doesn’t have such a concern, this step does not terminate the algorithm run on forecast delivery
failure.</p>
      <p>Operative forecasting error ε (calculated on step 8) will be useful in further development of this
algorithm to support interval forecasting.</p>
    </sec>
    <sec id="sec-9">
      <title>3.4. Algorithm implementation and deployment</title>
      <p>In ECMAScript (JavaScript), which is used as a high-level programming language in water
consumption forecasting information technology, the streaming algorithms can be effectively
implemented using asynchronous iterators [15]. The information technology is proposed to be
deployed using Cloud Functions on Google Cloud Platform [16], selected as best-fit serverless
computing environment. It also has a rich variety of backing services, which may be used as
inplatform fail-safe storage (“Datastore”, “Firestore” etc.).</p>
    </sec>
    <sec id="sec-10">
      <title>4. Conclusion</title>
      <p>
        Since memory consumption of iteration phase is constantly low, computing operations are simple
(not so many multiplications and couple of divisions), and computing complexity is low, the
algorithm iteration phase of information technology is suitable to be deployed on wide range of
computing environments: dedicated servers, serverless clouds, and even embedded devices. For
instance, in the studied water provision enterprise [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], this phase can be integrated directly into Fargo
Maestro 100 GSM modems, which are used to transfer the hourly water consumption data.
      </p>
      <p>Setup phase (even with any number of subsequent iterations) may be done externally, and then
initial values of persistent variables may be copied into fail-safe memory of embedded device before
running iteration phase on it. This may be used for off-line automated emergency detection, and for
sealing the potentially damaged nodes of the water provision system.</p>
      <p>Authors plan to improve this algorithm to support water consumption operative interval
forecasting. This will require implementing a non-parametric quantile estimation method into both
phases.</p>
    </sec>
    <sec id="sec-11">
      <title>5. References</title>
      <p>Radioelectronics, Telecommunications and Computer Engineering, TCSET 2020, IEEE,
LvivSlavske, Ukraine, 2020, pp. 166–171. doi:10.1109/TCSET49122.2020.235415.
[8] W. A. Gardner, A. Napolitano, and L. Paura, Cyclostationarity: Half a century of research, ISSN
0165-1684: Signal Processing, Elsevier, vol.86, no. 4, 639–697, 2006.
[9] S. L. Marple, Digital Spectral Analysis with Applications, New Jersey: Prentice Hall, 1987.
[10] A. I. McLeod, Diagnostic checking periodic autoregression models with application, ISSN
01439782: Journal of Time Series Analysis, vol. 15, no. 2, 221–233, 1995.
[11] Mikeseven, Node OpenCL, 2020. URL: https://github.com/mikeseven/node-opencl .
[12] T. Mykhailovych, GPU-EZ: Easy GLSL parallel computing on GPU.JS, 2019. URL:
https://github.com/tarquas/gpu-ez .
[13] N. Alon, Y. Matias, M. Szegedy, The space complexity of approximating the frequency
moments, Journal of Computer and System Sciences, 58 (1999) 137–147.
doi:10.1006/jcss.1997.1545.
[14] M. Wolf, High-Performance Embedded Computing, ISSN 978-0-12-410511-9: Morgan</p>
      <p>Kaufmann, Elsevier, Second Edition, 139–200, 2014.
[15] I. Kantor, Async iteration and generators, 2021. URL:
https://javascript.info/async-iteratorsgenerators .
[16] Google Inc., Cloud Functions, 2021. URL: https://cloud.google.com/functions .</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>A.</given-names>
            <surname>Candelieri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Soldi</surname>
          </string-name>
          and
          <string-name>
            <given-names>F.</given-names>
            <surname>Archetti</surname>
          </string-name>
          ,
          <article-title>Short-term forecasting of hourly water consumption by using automatic metering readers data</article-title>
          ,
          <source>Procedia Engineering</source>
          <volume>119</volume>
          (
          <year>2015</year>
          )
          <fpage>844</fpage>
          -
          <lpage>853</lpage>
          . doi:
          <volume>10</volume>
          .1016/j.proeng.
          <year>2015</year>
          .
          <volume>08</volume>
          .948.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>E.</given-names>
            <surname>Pacchin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Alvisi</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Franchini</surname>
          </string-name>
          ,
          <article-title>A Short-Term Water Demand Forecasting Model Using a Moving Window on Previously Observed Data, Water 9 (</article-title>
          <year>2017</year>
          )
          <fpage>1</fpage>
          -
          <lpage>15</lpage>
          . doi:
          <volume>10</volume>
          .3390/w9030172.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>T.</given-names>
            <surname>Mykhailovych</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Fryz</surname>
          </string-name>
          ,
          <article-title>Model and Information Technology for Hourly Water Consumption Interval Forecasting</article-title>
          ,
          <source>in: Proceedings of the 15th International Conference on Advanced Trends in Radioelectronics</source>
          , Telecommunications and Computer Engineering, TCSET
          <year>2020</year>
          , IEEE, LvivSlavske, Ukraine,
          <year>2020</year>
          , pp.
          <fpage>341</fpage>
          -
          <lpage>346</lpage>
          . doi:
          <volume>10</volume>
          .1109/TCSET49122.
          <year>2020</year>
          .
          <volume>235452</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>A.</given-names>
            <surname>Kapustinskas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Nemura</surname>
          </string-name>
          , Identification of Linear Random Processes, Vilnius „Mokslas" Publishers,
          <year>1983</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>R.</given-names>
            <surname>Benítez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Ortiz-Caraballo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. C.</given-names>
            <surname>Preciado</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. M.</given-names>
            <surname>Conejero</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F. S.</given-names>
            <surname>Figueroa</surname>
          </string-name>
          ,
          <string-name>
            <surname>Alvaro RubioLargo</surname>
          </string-name>
          ,
          <article-title>A short-term data based water consumption prediction approach</article-title>
          ,
          <source>Energies</source>
          <year>2019</year>
          , Vol.
          <volume>12</volume>
          ,
          <issue>2359</issue>
          (
          <year>2019</year>
          ), doi:10.3390/en12122359.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>E. W.</given-names>
            <surname>Weisstein</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Boxcar</given-names>
            <surname>Function. From MathWorld - A Wolfram Web Resource</surname>
          </string-name>
          ,
          <year>2013</year>
          . URL: https://mathworld.wolfram.com/BoxcarFunction.html .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Fryz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Mlynko</surname>
          </string-name>
          ,
          <article-title>Properties of Stationarity and Cyclostationarity of Conditional Linear Random Processes</article-title>
          ,
          <source>in: Proceedings of the 15th International Conference on Advanced Trends in</source>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>