中南大学学报(英文版)

J. Cent. South Univ. Technol. (2008) 15: 694-699

DOI: 10.1007/s11771-008-0129-1

Artificial emotional model based on finite state machine

MENG Qing-mei(孟庆梅), WU Wei-guo(吴伟国)

(Department of Mechanism Design, Harbin Institute of Technology, Harbin 150001, China)

                                                                                                

Abstract:

According to the basic emotional theory, the artificial emotional model based on the finite state machine(FSM) was presented. In finite state machine model of emotion, the emotional space included the basic emotional space and the multiple emotional spaces. The emotion-switching diagram was defined and transition function was developed using Markov chain and linear interpolation algorithm. The simulation model was built using Stateflow toolbox and Simulink toolbox based on the Matlab platform. And the model included three subsystems: the input one, the emotion one and the behavior one. In the emotional subsystem, the responses of different personalities to the external stimuli were described by defining personal space. This model takes states from an emotional space and updates its state depending on its current state and a state of its input (also a state-emotion). The simulation model realizes the process of switching the emotion from the neutral state to other basic emotions. The simulation result is proved to correspond to emotion-switching law of human beings.

Key words:

finite state machine; artificial emotion model; Markov chain; simulation

                                                                                                           

1 Introduction

The importance role played by emotion in artificial intelligence (AI) has received more and more concerns from the scholars over the last decade. Establishing emotional model is a main aspect in the study of artificial emotion. PICARD[1] noted that affective computing included implementing emotion and also included many other things, such as recognizing and expressing emotion, developing its ability to respond intelligently to human emotion, and enabling it to regulate and utilize its emotion. Although the field is still in its infancy, the model of emotion contributes a lot to emotional research, and the contributions manifest themselves in the following three aspects.

1) It is a valid tool to validate emotional theory[2-5]. The emotional model of robot can serve as “virtual laboratory” for the study of emotion. It not only tests the existing theories, but studies problems that would be difficult to solve in human emotion, such as the nature of isolation and repetitiveness of the task that generates the emotion-related factors.

2) From the engineering point of view, emotional model could improve the system performance, and enhance the autonomy and flexibility. So the emotional model would strengthen system real-time behavioral responses to adapt the dynamics of the environment.

At present, most emotional models have still been in theoretical stage, and difficult to apply. Robots, “Kismet” and “WE4” are some of the best known projects in this area[6-7]. The main disadvantage of the selected approach is its inflexibility. That is, if a new drive should be integrated the complete system has to be changed. A better approach that they use a “maximum fusion” was present in Ref.[8]. In humanoid robot head “ROMAN”, the actual emotional model was defined according to the emotion cube[9]. The calculation of the emotion state is done similar to Kismet.

In this work, the emotional state-switching model was developed based on the finite state machine. The finite state machine is a major form of model-building in discrete event system, and it is close to human thinking pattern, thus easy to build and understand. The emotion-switching diagram and transition function were adopted to express the emotion-switching. Through simulation tests, the model was proved to correspond to emotion-switching law of human beings.

2 Establishment of artificial emotional model

2.1 Artificial emotion model

Based on “emotional theory” in the psychology of emotion[10-12], human emotion includes basic emotion and multiple emotions. Basic emotion is basic element in human emotion, while multiple emotions are complicated and changeable, which could be taken as combination of basic emotions. Let Cj be a multiple emotion, then

                (1)

where  ai denotes a set corresponding to the basic emotions E (E{anger, surprise, neutrality, sadness, joy, fear, and disgust}); l denotes the number of basic emotions; and ki is the affective coefficient corresponding to basic emotions.

Emotion is considered to express different mental perception (such as mood and preference)[1]. Emotion refers to the maintenance and change of some relations between human beings and external environment. Positive emotions were elicited when the external environment or context corresponded to personal need or desire. Otherwise, negative emotions would come along. The emotional model was computed as follows.

Suppose E(t) represents the degree of expectation to do something at time t, and let Ig(t) be the degree of satisfaction to the expectation, and pj(s(t), I(t)) be the probability to generate an emotion. s(t) is an emotional state at time t and I(t) is external environment. Then the emotional model is defined as

             (2)

where Fj denotes the function of a basic emotion. When Ij(t) is defined as emotional intensity, and a threshold Tj(t) is given, then there exist

                          (3)

              (4)

Some emotions are activated by the rule described in Eqns.(3) and (4). When probability Pj(s(t), I(t)) is greater than threshold Tj, intensity Ij(t) is not equal to zero. Different intensities Ij(t) maps different emotional classes in the emotional set.

2.2 Emotional state-switching model based on FSM

Finite state machine(FSM)[13-14] is a mathematical model that can describe complex system through simplified hypothesis. In other words, state is a status that can be kept identifiable in the finite time. Transition is the reaction to the event, which shifts one state to the other. In any definite moment, FSM can be in one definite state only and accept a definite input. At some time, if FSM receives an input character in some state, it will produce a definite state at the next moment.

An artificial emotion model is defined by the model <S, Y, O, f, s0>, in which S is a finite emotional state space (including basic emotion space and multiple emotion space); Y represents the external stimuli  O represents the output emotion state, f:S×S→S is the state transition function; s0 is the initial emotional state. The switching process of emotions can be seen as a Markov process[15-17], so the transition process of finite states can be described by Markov chain. Suppose an external stimulus is defined in a random environment, then the probability of any stimulus is 1/N, and N is the number of S. Let the emotional state at time t be s(t), and the external stimuli be y(t), then the emotional state at time t+1 is

s(t+1)=(1-θ)s(t)+ θy(t) (0≤θ≤1)               (5)

where  θ denotes influencing factor of y(t) in the emotional state s(t+1).

The model-switching is determined by distribution of probabilities π and the initial state s0.

Based on the linear interpolation (Eqn.(5)) and Chapman-Kolmogorov equation[15], the transition function can be determined and the calculating process is as follows.

1) Calculation of transition matrix A

                                           (6)

2) Calculation of An

Suppose matrix A is similar to the diagonal matrix . Based on Q-1AQ=, then we have

A=QQ-1                                  (7)

A=An=QQ-1                               (8)

where

; Q=(e1, …, en);

λi is the eigenvalue of matrix A; and ei is eigenvector corresponding to λi.

3) Calculation of probability distribution π

                               (9)

where   is the distribution of the model in its initial state.

3 Simulation of artificial emotion system model

The purpose of establishing the simulation model is to verify the validity of the artificial emotion system. The simulation model was built by using the Stateflow toolbox and the Simulink toolbox based on the Matlab platform. The artificial emotion system is shown in Fig.1. It is composed of the following three subsystems.

1) Input subsystem: It generates an emotional state according to the external stimuli.

2) Emotion subsystem: It indicates the artificial emotion-switching based on FSM. That is, under the initial emotional sate, emotions would be switched from a state to other one corresponding to different external stimuli.

3) Behavior subsystem: It refers to the behavioral reflections corresponding to different emotional states, which include facial expression, speech, behavior, et al.

Fig.1 Artificial emotion system model

3.1 Input subsystem

The input subsystem model in the emotional system is shown in Fig.2. In Fig.2, fcn is the embedded Matlab function in the Simulink toolbox; I and U denote the input of image feature and the phonetic feature signal respectively. As shown in Fig.2, the input subsystem includes three modules: external stimulus module, feature extraction module and emotion active module. External stimuli module includes visual signal, auditory signal, olfactory signal and tactile signal and so on. The emotional active module includes emotional appraisal module and emotional arbitration module. The principle of emotional appraisal and emotional arbitration can be expressed in Eqns.(2) and (3).

Taking the emotion of joy as an example, the working process of the input subsystem is shown in Fig.3. When the signals of external stimuli are to extract feature and to fit signal based on the criterions, the joy signal will be produced. The joy state will be generated by the emotional signal according to the emotional appraisal and the emotional arbitration.

The feature extraction of the signal and the algorithm of emotional arbitration in the Input subsystem were not introduced in detail in this work.

Fig.2 Input subsystem model in emotional system

Fig.3 Working process of input subsystem

3.2 Emotional subsystem

Emotional subsystem was built by using Stateflow toolbox[18-19]. In Stateflow toolbox, flowchart and state transition can be used to describe physical model, by adopting the programming idea which is object-oriented. The finite state and the transition condition can be built by using diagram design, thus constructing the finite state machine system. State, transition and event are the basic modules in Stateflow, and the decision-making point can be expressed by linking them all.

Discrete numerical calculation was adopted in the process of simulation, so emotion was thought to be discrete when defining the interaction of different emotions. Because human beings’ emotions constitute basic emotions and multiple emotions, the emotion space in the simulation model can be simplified into the following 7 emotional states: J(joy), S(sadness), A(anger), D(disgust), F(fear), Su(surprise), N(neutral). 7 emotional states will be exchanged under different conditions. The emotional state transition diagram is shown in Fig.4.

Fig.4 Transition diagram of artificial emotion

The transition matrix of emotion was calculated according to Eqn.(5) as follows:

           (10)

  Based on the emotional state transition diagram, emotion-switching model was established according to Stateflow toolbox. The transition model of artificial emotion based on FSM is shown in Fig.5. In Fig.5, CLK is the default settings for general HDL code in Matlab; temp denotes temporal logic event on the Stateflow toolbox of the Matlab. As shown in Fig.5, the model realizes the transition of the seven emotional states.

In the model, probability distribution π was calculated in the “eM” module, the threshold T(t) was defined in function f1; the history module  in  Stateflow toolbox was added, thus increasing the efficiency of transition. Moreover, in the process of simulation, time function “after( )” was used in the model to solve real-time restraint in the state diagram. However, simulating time would be increased if smaller time reference was adopted.

The working process of the emotion model is as follows: under the operation of the external input (expressional and speech signal), the emotional state switches from the initial state to the emotional state s(t). And when there is a change in the external input, the emotional state s(t) will switch to another state s(t+1). The state transition process conforms to Markov process. And state transition occurs according to transition function. In addition, when input y(t) is kept constant, the state s(t+1) will be kept in a periodicity, then transfer to initial state.

In every emotion, three personal spaces {θ1, θ2, θ3} are defined. {θ1, θ2, θ3} represent the positive, neutral and negative attitudes to external stimuli, respectively. That is, different personalities will express different emotional classes stimulated by the same external stimuli. The case is reflected by the fact that the rates of decay of the emotion state (the time that the basic emotion transfers to its initial state) are different and the behavioral reflections corresponding to an emotion state are different.

Take the emotion of joy as an example: the three personal spaces {θ1, θ2, θ3} are defined in the joy state, as shown in Fig.6. Different functions are defined to express different boundaries of personal space. In each personal space, variable i is defined to express the emotion-switching velocity; positive( ) and negative( ) are defined to the personal function; d1, d2 and d3 are the thresholds corresponding to different personalities. Personal space in other emotional state, which is similar to the joy state, is not introduced in detail in this paper.

3.3 Simulation results and analysis

The aim of simulation is to realize the model and analyze the emotion-switching process and the law of transition. In Fig.7, the simulation model represents somewhat a “positive” kind of emotional interaction. Thus, when a neutral emotion meets with a stimulus of joy, it transfers to joy corresponding to the behavioral responses. In Fig.7, external stimuli include expressional signal and speech signal. Expressional signal is represented by the feature points[20] (round spots in Fig.7) in facial expression, which express the positions of lids, eyes and eyebrows. Speech signal is fundamental tone statistical model[21]. Three personal spaces are defined in joy state (see Fig.6). The behavioral reflections corresponding to a personal space were differently stimulated by the same external stimuli. Different behavioral reflections represent different facial expresses and tones.

Fig.8 shows the emotion attenuation curves of different personal spaces {θ1, θ2, θ3}. The curve   shows the changing tendency of the emotional state. The emotional intensity will tend to exponential decrease. θi is defined to express different characters. The curves only adapt to joy.

Fig.5 Transition model of artificial emotion based on FSM (Function f1 presents threshold of emotion; eM is a module in the Stateflow toolbox, which presents M-file and will be embedded in the Stateflow; P presents probability distribution of emotion; Function f2 denotes present driver; I(t) presents external stimuli.)

Fig.6 Emotional personal space for joy

Fig.7 Simulation of artificial emotion system


 

Fig.8 Emotional attenuation process

The emotional intensity can arrive to the maximal value of 1.0, and decrease slowly in state θ1. The state will transfer to initial state after 100 s. However, in state θ3 the emotional intensity can arrive to 0.3 only and transfer to the initial state in 40 s according to the same stimuli.

The simulation model realizes the process of switching the emotion from the neutral state to other basic emotions, the process of simulating the emotion-switching and its corresponding behavioral reflections in a dynamic way. In the final phase of this model, the emotion state will be switched to the initial emotion state, which is neutral emotion. Other emotion state-switching forms have not been taken into consideration.

4 Conclusions

1) According to the theory of finite state machine, an emotional state-switching model <S, Y, O, f, s0> is proposed. The transition function in this model is developed using Markov chain and linear interpolation algorithm.

2) The simulation model is built using Stateflow toolbox and Simulink toolbox based on the Matlab platform. And it includes three subsystems: the input one, the emotion one and the behavior one. In emotional subsystem, the simulation results are proved to correspond to emotion-switching law of human beings.

3) The simulation model realizes the process of switching the emotion from the neutral state to other basic emotions, the process of simulating the emotion-switching and its corresponding behavioral reflections in a dynamic way.

4) The emphasis and also the sticky problem in future study will be to establish a more complicated and extendable emotion FSM and to realize the match and correlation between different state machines in the emotion FSM system.

References

[1] PICARD R W. Affective computing [M]. London: MIT Press, 1997.

[2] CAI Zi-xing. Some issues for discipline of intelligence science [J]. Journal of Central South University of Technology, 2006, 13(5): 525-528.

[3] CANNAMERO L. Emotion understanding from the perspective of autonomous robots research [J]. Neural Networks, 2005, 18(4): 445-455.

[4] ZITAR R A, MARIA K A. Emotion agents: A modeling and an application [J]. Information and Software Technology, 2007, 49(7): 695-716.

[5] BATES J. The role of emotion in believable agents [J]. Communications of the ACM, 1994, 37(7): 122-125.

[6] BREAZEAL C. Emotion and social humanoid robots [J]. International Journal of Human-Computer Studies, 2003, 59(1/2): 119-155.

[7] MIMWA H, IOH K, ITO D, TAKANOBU H, TANKANISHI A. Introduction of the need model for humanoid robots to generate active behavior [C]// 2003 IEEE international Conference on Intelligent Robots and Systems(IROS). Piscataway: IEEE, 2003: 1400-1406.

[8] MALFAZ M, SALICHS M A. Design of an architecture based on emotions for autonomous robots [C]// 2004 AAAI Spring Symposium. Menlo Park: AAAI, 2004: 198-204.

[9] HIRTH J, SCHMITA N, BERNS K. Emotional architecture for the humanoid robot head ROMAN [C]// 2007 IEEE International Conference on Robotics and Automation. Piscataway: IEEE, 2007: 2150-2155.

[10] MENG Zhao-lan. Human emotion [M]. Shanghai: Shanghai People Press, 1989. (in Chinese)

[11] WANG Zhi-liang. Artificial emotion [M]. Beijing: China Machine Press, 2007. (in Chinese)

[12] WANG Guo-jiang, WANG Zhi-liang, YANG Guo-liang, WANG Yu-jie, CHEN Yu-feng. Survey of artificial emotion [J]. Application Research of Computers, 2006, 23(11): 7-11. (in Chinese)

[13] WANG Bo. Formal language and automata [M]. Beijing: Beijing Post and Telecom Press, 2003. (in Chinese)

[14] ADAMATAKY A. Affections: Automata models of emotion interactions [J]. Applied Mathematics and Computation, 2003, 146(2): 579-594.

[15] GONG Guang-lu, QIAN Min-ping. Application on random process [M]. Beijing: Tsinghua University Press, 2004.

[16] WU Xiao-hong, WANG Pei-liang, WANG Zhi-liang. An artificial emotion model based on state-space method [J]. Microcomputer Information, 2007, 23(5/2): 243-245.

[17] TAN Wen-zhao, RONG Gang. A real-time head nod and shake detector using HMMS [J]. Expert Systems with Applications, 2003, 25(3): 461-466.

[18] XUE Ding-yu, CHEN Yang-gui. System simulation and application based on the MATLAB/Simulink [M]. Beijing: Tsinghua University Press, 2002. (in Chinese)

[19] HUANG Yong-an, MA Lu, LIU Min-hui. Simulink 6.0 Simulink modeling and engineering application [M]. Beijing: Tsinghua University Press, 2007. (in Chinese)

[20] ZHANG Hong-liang, ZOU Zhong, LI Jie, CHEN Xiao-tao. Flame image recognition of alumina rotary kiln by artificial neural network and support vector machine methods [J]. Journal of Central South University of Technology, 2008, 15(1): 39-45.

[21] WANG Zhi-ping, ZHAO Li, ZOU Cai-rong. Emotional speech recognition based on modified parameter and distance of statistical model of pitch [J]. Acta Acustica, 2006, 31(1): 28-34. (in Chinese)

(Edited by ZHAO Jun)

                     

Foundation item: Project(2006AA04Z201) supported by the National High-Tech Research and Development Program of China

Received date: 2007-12-15; Accepted date: 2008-04-09

Corresponding author: WU Wei-guo, Professor; Tel: +86-13039978495; E-mail: wuwg666@yahoo.com.cn

[1] PICARD R W. Affective computing [M]. London: MIT Press, 1997.

[2] CAI Zi-xing. Some issues for discipline of intelligence science [J]. Journal of Central South University of Technology, 2006, 13(5): 525-528.

[3] CANNAMERO L. Emotion understanding from the perspective of autonomous robots research [J]. Neural Networks, 2005, 18(4): 445-455.

[4] ZITAR R A, MARIA K A. Emotion agents: A modeling and an application [J]. Information and Software Technology, 2007, 49(7): 695-716.

[5] BATES J. The role of emotion in believable agents [J]. Communications of the ACM, 1994, 37(7): 122-125.

[6] BREAZEAL C. Emotion and social humanoid robots [J]. International Journal of Human-Computer Studies, 2003, 59(1/2): 119-155.

[7] MIMWA H, IOH K, ITO D, TAKANOBU H, TANKANISHI A. Introduction of the need model for humanoid robots to generate active behavior [C]// 2003 IEEE international Conference on Intelligent Robots and Systems(IROS). Piscataway: IEEE, 2003: 1400-1406.

[8] MALFAZ M, SALICHS M A. Design of an architecture based on emotions for autonomous robots [C]// 2004 AAAI Spring Symposium. Menlo Park: AAAI, 2004: 198-204.

[9] HIRTH J, SCHMITA N, BERNS K. Emotional architecture for the humanoid robot head ROMAN [C]// 2007 IEEE International Conference on Robotics and Automation. Piscataway: IEEE, 2007: 2150-2155.

[10] MENG Zhao-lan. Human emotion [M]. Shanghai: Shanghai People Press, 1989. (in Chinese)

[11] WANG Zhi-liang. Artificial emotion [M]. Beijing: China Machine Press, 2007. (in Chinese)

[12] WANG Guo-jiang, WANG Zhi-liang, YANG Guo-liang, WANG Yu-jie, CHEN Yu-feng. Survey of artificial emotion [J]. Application Research of Computers, 2006, 23(11): 7-11. (in Chinese)

[13] WANG Bo. Formal language and automata [M]. Beijing: Beijing Post and Telecom Press, 2003. (in Chinese)

[14] ADAMATAKY A. Affections: Automata models of emotion interactions [J]. Applied Mathematics and Computation, 2003, 146(2): 579-594.

[15] GONG Guang-lu, QIAN Min-ping. Application on random process [M]. Beijing: Tsinghua University Press, 2004.

[16] WU Xiao-hong, WANG Pei-liang, WANG Zhi-liang. An artificial emotion model based on state-space method [J]. Microcomputer Information, 2007, 23(5/2): 243-245.

[17] TAN Wen-zhao, RONG Gang. A real-time head nod and shake detector using HMMS [J]. Expert Systems with Applications, 2003, 25(3): 461-466.

[18] XUE Ding-yu, CHEN Yang-gui. System simulation and application based on the MATLAB/Simulink [M]. Beijing: Tsinghua University Press, 2002. (in Chinese)

[19] HUANG Yong-an, MA Lu, LIU Min-hui. Simulink 6.0 Simulink modeling and engineering application [M]. Beijing: Tsinghua University Press, 2007. (in Chinese)

[20] ZHANG Hong-liang, ZOU Zhong, LI Jie, CHEN Xiao-tao. Flame image recognition of alumina rotary kiln by artificial neural network and support vector machine methods [J]. Journal of Central South University of Technology, 2008, 15(1): 39-45.

[21] WANG Zhi-ping, ZHAO Li, ZOU Cai-rong. Emotional speech recognition based on modified parameter and distance of statistical model of pitch [J]. Acta Acustica, 2006, 31(1): 28-34. (in Chinese)