\section{Customer's Dynamic Behaviour}
\label{sec:6}

In this section we want to address the problem of uncertainty or time--varying of customers' behaviour. We model this feature by considering
different value functions taken within the same family, characterized by a gradual variation of a certain parameter. In particular, we want to test if
the algorithms for price stabilization, presented in Section \ref{sec:3} of this article, are able to follow the consumers' behaviour evolution, by
simply taking into account the available past data, and control the dynamics of prices with the goal to stabilize
 them.
We have studied two different approaches to this problem, obtaining some nontrivial results.\\
Let's start with describing the dynamics of the problem: we have considered four different value functions
$v_{i}(x), i \in [1,2,3,4]$, corresponding to four different consumers' behaviours during different
hours of the day. We divided one day (24 hours) in four periods, each made up of
six hours, corresponding to early morning (4.00:10.00), midday (10.00:16.00), evening (16.00:22.00) and night
(22.00:4.00). Consumers are in fact supposed to make different use of energy (electricity), with respect to
 different moments of the day.\\
The first approach employs the main result proposed in Section \ref{sec:3}, i.e.\ the algorithm that calculates the retail price for the next time
interval (hour) using a fixed parameter ($\gamma$) in order to stabilize the prices. From simulations we have obtained the algorithm convergence,
both when starting far from each equilibrium point and when starting close to one of the four points of equilibrium. After each value function
switch, the algorithm quickly settles on the new equilibrium point, until the next switch. This behaviour is shown in Figure
\ref{fig:prezzi_sett}. The evolution starts from the curve number 1. The arrows show the algorithm chasing the dynamics of the consumers after
each slot switch. The trajectory of the retail prices is not shown here, as it emerges quite clearly from Fig. \ref{fig:prezzi_sett}.\\
\begin{figure}[ht!]
    \begin{center}
        \includegraphics[width=10cm]{cambio_prezzi_settling}
    \end{center}
  \caption{Behaviour of the algorithm while chasing $\dot v(x)$ with fixed $\gamma$.}\label{fig:prezzi_sett}
\end{figure}
The second approach uses weighted least squares interpolation of the data recorded during the previous 24 hours, weighting them according to the time
slots they belong to. The first problem we encountered was that we were considering points taken from four different curves, and the results were not
satisfactory until we introduced a weighting scheme that matched current and past data belonging to the same time slots. Observations made during the
current time slot and during the same period of the previous day are preferred to the data corresponding to different slots. This approach is
justified by the fact that we modeled the customers' behaviour evolution with a periodic function, which is a reasonable choice, as the energy
request is similar at the same time during different days. A good weighting factor can be obtained by sampling the function $f(x) = \cos^{10}{x}$,
suitably scaled in frequency (see Figure \ref{fig:wf}).\\
When starting close to one of the four equilibrium points (corresponding to the four different value functions), we interpolated the past 24 hours
data (pairs of [energy, retail price]) with an hyperbola, which is a good approximation of the derivative of the chosen value functions. At first
iteration, we used 24 data --from an execution of the previous algorithm-- as a fictitious data history. The trajectory of the retail prices is shown
in Figure \ref{fig:prezzi_mq}. After each switch, the algorithm gradually moves towards the next equilibrium point, rather then reaching it in just
one or two steps. This behaviour is due to the symmetric form of the weighting factor, which provides to the algorithm some information about the
\virg{future} evolution of the target. In other words, the algorithm is able to predict the customers' behaviour, and thanks to this feature it
starts moving towards the next equilibrium point even before the switching takes place. Such a trend could result very useful in a practical
application, as we can assume that, in a real energy market, the value function varies in a continuous way.

\begin{figure}[ht!]
    \begin{center}
        \includegraphics[width=10cm]{Weighting_factor}
    \end{center}
  \caption{Weighting factor.}\label{fig:wf}
\end{figure}

\begin{figure}[ht!]
    \begin{center}
        \includegraphics[width=10cm]{mq_una_giornata_settling}
    \end{center}
  \caption{Trajectory of the retail prices while chasing $\dot v(x)$ with weighting factor.}\label{fig:prezzi_mq}
\end{figure}
