## 5 Implementing the Emotional Model in the Personal Assistant Robot
### Fuzzy Logic for Modeling Emotions  
The technique for modeling emotions depends largely on the method of knowledge acquisition employed. In this case, the rules were obtained from the experience of a psychologist who provided the linguistic values for each emotion, as well as the inference rules to be implemented in the model. Clearly, fuzzy logic is the most appropriate technique to handle vague concepts and to perform the approximate reasoning required by the information obtained from the human expert [64; 65]. Let \(u(k)\) be the vector of stimuli, \(x(k)\) the vector of emotions, and \(y(k)\) the vector of robot output variables. It is proposed to use a state variable model to define the dynamic behavior of the emotional system, in which each emotional dimension \(x_{i}(k+1)\) depends on its previous state and the stimulus vector \(u(k)\), according to Equation (1) [66]. \[x_{i}(k+1)=f(x_{i}(k),u(k)) \tag{1}\]  
where \(i\) corresponds to each of the emotional dimensions that integrate the vector of emotions. Likewise, each output is a function of the emotional state, as shown in Equation (2) [66]. \[y_{j}(k+1)=g(x(k+1)) \tag{2}\]  
Figure 5: Connection between stimuli, emotions, and responses. where \(j\) corresponds to each of the robot outputs that integrate the vector of the robot output variables. In this way, the function \(f\) is therefore responsible for relating the input stimuli produced in the robot to its emotional state, while function \(g\) is in charge of relating the emotional state with the emotional responses of the robot, i.e., its outputs. Without a precise mathematical model of the above functions \(f\) and \(g\), using artificial intelligence heuristic techniques to obtain them is interesting. Specifically, it is proposed to use a rule-based system using fuzzy logic as an inference mechanism. In previous work, a dynamic model in state-space had already been used to represent the emotional state of a robot [67]; however, the model (\(f\) and \(g\)) was linear and fuzzy logic was used only to compute the coefficients in each iteration. This time, this work proposes to use rules directly and obtain them empirically based on consultation with an expert in the field, specifically a psychologist. In this way, the functions \(f\) and \(g\) can be modeled using two tables of rules that look similar to Tables 2 and 3. The use of fuzzy logic for the inference mechanism on these rules is justified by the fact that the transitions from one state to another (low, normal, high) are not abrupt, as well as that both the data coming from the stimuli \(u(k)\) and the output \(y(k)\) take quantitative values [68; 69; 70]. The model is dynamic since the table of rules corresponding to the function \(g\) (the state depends on its previous value) corresponds to the temporal evolution of a being's emotions, as they do not normally change their state instantaneously. This leads to addressing the stability of the presented dynamical model with some care. It is a first-order dynamical system that, starting from a stable state (e.g., \(u(k)\) low and \(x(k)=u(k+1)\) normal), if the input does not change, the state does not change either, while if the input changes (to, e.g., \(u(k)\) normal), the state must evolve until it stabilizes at a new value (e.g., \(x(k)=x(k+1)\) low). In Table 4, these stable equilibrium positions have been marked in bold. A scheme of the model can be seen in Figure 6. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \(x(k)\)/\(u(k)\) & **Very Low** & **Low** & **Normal** & **High** & **Very High** \\ \hline Low & Normal & Normal & **Low** & **Low** & **Low** \\ \hline Normal & High & Normal & Low & Low & Low \\ \hline High & High & Normal & Normal & Normal & Normal \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Example of a state table for a component of the vector of emotions \(x(k+1)\) (function \(f\)). The gray cells represent the different input and states allowed by the system.