PyIT2FLS: A New Python Toolkit for Interval Type 2 Fuzzy Logic Systems
Fuzzy logic is an accepted and well-developed approach for constructing verbal models. Fuzzy based methods are getting more popular, while the engineers deal with more daily life tasks. This paper presents a new Python toolkit for Interval Type 2 Fuz…
Authors: Amir Arslan Haghrah, Sehraneh Ghaemi
PyIT2FLS: A New Python T o olkit for In terv al T yp e 2 F uzzy Logic Systems Arslan A. Haghrah F acult y of Electrical and Computer Engineering Univ ersity of T abriz T abriz, Iran haghrah@tabrizu.ac.ir Sehraneh Ghaemi F acult y of Electrical and Computer Engineering Univ ersity of T abriz T abriz, Iran ghaemi@tabrizu.ac.ir April 10, 2025 Abstract F uzzy logic is an accepted and well-dev elop ed approach for constructing verbal mo dels. F uzzy based metho ds are getting more p opular, while the engineers deal with more daily life tasks. This pap er presen ts a new Python to olkit for Interv al T yp e 2 F uzzy Logic Systems (IT2FLS). Developing soft ware to ols is an imp ortant issue for facilitating the practical use of theoretical results. There are limited to ols for implemen ting IT2FLSs in Python. The developed PyIT2FLS is providing a set of to ols for fast and easy mo deling of fuzzy systems. This pap er includes a brief description of how dev elop ed to olkit can be used. Also, three examples are given sho wing the usage of the developed to olkit for sim ulating IT2FLSs. First, a simple rule-based system is developed and it’s co des are presen ted in the pap er. The second example is the prediction of the Mac key-Glass chaotic time series using IT2FLS. In this example, the Particle Swarm Optimization (PSO) algorithm is used for determining system parameters while minimizing the mean square error. In the last example, an IT2FPID is designed and used for con trolling a linear time-delay system. The co de for the examples are av ailable on to olkit’s GitHub page: https://github.com/Haghrah/PyIT2FLS . The simulations and their results confirm the abilit y of the developed toolkit to b e used in a wide range of the applications. 1 In tro duction While the fuzzy logic had not attracted many researchers in the first years of its presentation, the usage of the fuzzy approaches in science and engineering applications has raised ov er time. By increasing the n umber of successful applications of this approach on real-world problems, research on analyzing and design of fuzzy systems has flourished [ 1 ]. The key idea of the fuzzy systems is approximate reasoning, whic h is based on IF-THEN rules. A fuzzy IF-THEN rule is defined as a statement built of words, expressed b y membership functions [ 2 ]. Measuring the mem b ership grade using crisp num b ers yields type 1 fuzzy sets. But when the mem b ership grade is also uncertain and is represented using fuzzy mem b ership functions, the concept of type 2 and higher t yp es of fuzzy sets are introduced [ 3 ]. It must b e noticed that, b y increasing the t yp e of a fuzzy set, the computational burden significantly grows. Therefore researchers 1 ha ve in tro duced the concept of interv al type 2 fuzzy sets for decreasing the computational load, in which the secondary membership v alue is alwa ys considered to b e equal to one [4]. T yp e-2 fuzzy systems are applied widely to solve engineering and industrial problems, whic h among them con trol of buck and b oost DC-DC conv erters [ 5 ], coiler entry temp erature prediction [ 6 ], levelling the cable-driv en parallel mechanism [ 7 ], control of induction motor [ 8 ], and digital image filtering [ 9 ] can b e mentioned. Similar applications of type 2 fuzzy systems are adv ancing rapidly . Ho wev er, compared with t yp e 1 fuzzy systems, type 2 fuzzy systems hav e b een used very limitedly [ 10 ]. Public access and use of an approac h, deriv ed from theoretical results, is mainly affected by the av ailabilit y of softw are implemen tations. There are some to olkits developed for utilizing type 2 fuzzy sets and systems in science and engineering applications. In [ 11 ], a new MA TLAB to olb o x for interv al type 2 fuzzy logic systems has b een in tro duced. In addition to basic features for designing IT2FLSs, this to olb o x includes a graphical user interface for construction, edition, and observ ation of the fuzzy systems. Also, the men tioned paper studies both educational and research sides of developing the to olbox. The results of the exp erimen ts, in addition to the effectiveness of the to olbox, indicate the technical impro vemen t of the students who hav e used the to ol. Another to olb o x which is designed to b e used with MA TLAB, like the previous one, has b een presen ted in [ 12 ]. In this to olbox, in addition to the graphic user in terface for designing and editing fuzzy systems, a Simulink mo del is also presented whic h can b e mentioned as its adv an tage. As an example of using the to olbox, in this pap er, an IT2-F uzzy PID controller is designed for controlling a system in the presence of time delay . Another Jav a-based fuzzy logic to olkit, named Juzzy , is presen ted in [ 10 ]. Juzzy supp orts type 1, in terv al type 2 and general t yp e 2 fuzzy logic systems. The aim of the dev elop ers of Juzzy to olkit is facilitating the application of fuzzy logic systems in real-world problems, along with improving accessibility to the type 2 fuzzy logic systems for academic purp oses. Recently a new Python-based to olkit for automatically generating and analyzing data-driv en fuzzy sets has b een dev elop ed and presen ted in [ 13 ]. The introduced to olkit, fuzzycreator, provides many routines for creating con ven tional and non-conv en tional type 1, interv al t yp e 2 and general type 2 fuzzy sets from data. It m ust b e noticed that the developed to olbox fo cuses on fuzzy sets rather than fuzzy systems. Due to the increasing p opularit y of the Python programming language and its frequent use for scientific and engineering applications, the need for a to ol for providing IT2FLSs supp ort has b een felt. T o resp ond to this need, the PyIT2FLS to olkit is dev elop ed and presented in this pap er. This to olkit provides man y useful functions for creating and pro cessing fuzzy sets and systems. There are tw o core classes, which the features of the to olb o x are av ailable through them, IT2FS and IT2FLS . The first one for mo deling the fuzzy sets and the latter for the systems. It must b e noticed that the ease of use is considered as the main criterion in the developmen t of the to olkit. In the rest of the pap er when a keyw ord refers to a function, v ariable or class it is written in italic form. The rest of the pap er is organized as follows. The second section consists of a brief discussion on the to olkit and ho w to use it. In Section 3, three examples of using the PyIT2FLS are provided. Finally , Section 4 presents some conclusions. 2 PyIT2FLS This section presents ho w to use the new developed Python to olkit, PyIT2FLS, for mo deling and sim ulation of interv al type 2 fuzzy systems. PyIT2FLS is developed to resp ond to the lack of an integrated to ol for facilitating the use of IT2FLSs. This to olkit, which its developmen t will not stop in this stage, will allo w the users to apply IT2FL based metho ds for solving issues encountered in science and engineering problems. PyIT2FLS is based on well-kno wn n umeric library NumPy [ 14 ] and plotting library Matplotlib [ 15 ]. It consists of tw o main classes, IT2FS for interv al type 2 fuzzy sets and IT2FLS for interv al t yp e 2 fuzzy logic systems, and many utility functions concerning the interv al type 2 fuzzy logic. As a starting p oin t, we introduce some of the utility functions defined in the to olkit, which are used in creating in terv al type 2 fuzzy sets. These are general mem b ership functions, whic h would b e used as the low er mem b ership function (LMF) and the upp er membership function (UMF) for IT2FS s. T able 1 represen ts these functions with a brief description. All these functions hav e tw o inputs, v ector-like input x indicating 2 T able 1: List of functions whic h can b e used as LMFs and UMFs. Name Description zero mf All zero membership function singleton mf Singleton membership function const mf Constan t membership function tri mf T riangular membership function trap ezoid mf T rap ezoidal membership function gaussian mf Gaussian membership function gauss uncert mean umf UMF of Gaussian membership function with uncertain mean v alue gauss uncert mean lmf LMF of Gaussian membership function with uncertain mean v alue gauss uncert std umf UMF of Gaussian membership function with uncertain std. v alue gauss uncert std lmf LMF of Gaussian membership function with uncertain std. v alue 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 Do m a i n 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 M e m b e r sh i p d e g r e e Figure 1: An IT2FS with trap ezoidal UMF, and triangular LMF. p oin ts from the domain whic h the function must b e ev aluated, and par ams indicating the function’s parameters. It should b e noted that the latter parameter must b e a list, and for eac h function its items are describ ed in its corresp onding do cstring. 2.1 In terv al type 2 fuzzy sets The IT2FS class defines interv al type 2 fuzzy sets by sp ecifying the domain, UMF, parameters of UMF function, LMF, and parameters of LMF function. The first example in app endix shows how to define an IT2FS using aforemen tioned membership functions. The only constrain t for using these functions is to c ho ose the function parameters in suc h a wa y that for all points in the universe of discourse, U M F ( x ) > LM F ( x ) b e satisfied. The set defined using the co de is depicted in Figure. 1. There are t wo conv entional types of IT2FSs whic h can b e defined easily using tw o other functions av ailable in PyIT2FLS. In order to define Gaussian IT2FS with uncertain mean v alue and uncertain standard deviation v alue, users can call I T 2 F S Gaussian U ncer tM ean and I T 2 F S Gaussian U ncer tS td functions, resp ectiv ely . The parame- ters of the b oth functions are domain and par ams . F or the first function, the second parameter consists of the mean v alue center, mean v alue spread, and standard deviation and for the second function, the second parameter consists of the mean v alue, standard deviation cen ter, and standard deviation spread (for b oth as lists). Each IT2FS in PyIT2FLS contains some parameters and functions which are indicated in T able 2 and T able 3, resp ectively . More detailed descriptions and instruction for each of them are a v ailable in docstrings. The next function to b e introduced is I T 2 F S pl ot whic h plots a num b er of IT2FS s together in the same figure. The main inputs of this function are a n umber of IT2FS s, but title and legends can also b e assigned. F urthermore if the user wishes to sav e the plotted figure in pd f format, he/she can set the filename input v ariable. More detailed description and examples are a v ailable in do cstrings. 3 T able 2: List of parameters defined in IT2FS class. P arameter Description domain Defines the universe of discourse umf Defines upp er membership function umf params Defines upp er membership function parameters lmf Defines low er mem b ership function lmf params Defines low er membership function parameters upp er Upp er membership function v alues in the discrete universe of discourse lo wer Lo wer membership function v alues in the discrete univ erse of discourse T able 3: List of functions defined in IT2FS class. F unction Description cop y Returns a copy of the IT2FS plot Plots the IT2FS in the universe of discourse 2.2 T-norms, s-norms, join and meet As basic op erators in fuzzy c alculations, t-norms and s-norms hav e sp ecial imp ortance. PyIT2FLS b y default con tains tw o t-norm functions, min t nor m and pr oduct t nor m for minimum and pro duct t-norms resp ectiv ely , and a s-norm, max s nor m for maximum s-norm. How ev er, new t-norm and s-norm functions can b e defined by users. In the standard form, these functions must hav e tw o array-lik e inputs for calculating t-norm or s-norm, element-wise on them. The next tw o main op erators in type 2 fuzzy logic are meet and join op erators which are defined by tw o functions with the same names, me et and join . The inputs of these op erators are domain, first and second IT2FS, and norm operator. F or the me et , norm op erator m ust b e a t-norm and for the join , norm op erator must b e a s-norm. The second co de in the app endix sho ws ho w to use meet and join op erators and plotting multiple sets together. The results are demonstrated in Figure 2. 2.3 In terv al type 2 fuzzy logic systems The most imp ortan t part of the developed to olkit, the IT2FLS class, is prepared for mo deling the interv al t yp e 2 fuzzy logic systems. Each IT2FLS has three parameters, inputs , outputs , and rules . There are fiv e functions defined in IT2FLS class for utilizing it which are presented in T able 4. No construction parameters are needed when an IT2FLS is created. The input parameters of the functions for adding inputs and outputs are only the names. In order to define the rule base of the fuzzy system add r ule function is used. This function accepts t wo lists as input which the first one indicates anteceden t part of the rule and the second one indicates conclusion part of the rule. Each list consists of tuples indicating the attachmen t of input v ariables to corresp onding IT2FS s. Assume that a fuzzy type 2 IF-THEN rule 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 Do m a i n 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 M e m b e r sh i p d e g r e e S m a l l M e d i u m L a r g e (a) The IT2FSs used in example. 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 Do m a i n 0 . 0 0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 M e m b e r sh i p d e g r e e (b) Meet of Small and Medium sets. 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 Do m a i n 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 M e m b e r sh i p d e g r e e (c) Join of Medium and Large sets. Figure 2: Sample outputs for IT2FS plot , meet and join functions. 4 T able 4: List of functions defined in IT2FLS class. F unction Description add input v ariable Adds a new input v ariable to IT2FLS add output v ariable Adds a new output v ariable to IT2FLS add rule Adds a new rule to IT2FLS’s rule base ev aluate Ev aluates the IT2FLS with sp ecific inputs cop y Returns a copy of the defined IT2FLS b e as b elow: IF x 1 is ˜ A 1 AND x 2 is ˜ A 2 AND ... AND x n is ˜ A n THEN y 1 is ˜ B 1 , y 2 is ˜ B 2 , ... y m is ˜ B m (1) So this rule can b e added to an IT2FLS named myIT2FLS as pseudo-co de b elow: my I T 2 F LS.add r ul e ([(” x 1” , A 1) , (” x 2” , A 2) , ..., (” xn ” , An )] , [(” y 1” , B 1) , (” y 2” , B 2) , ..., (” y m ” , B m )]) In order to ev aluate an IT2FLS for arbitrary inputs the evaluate function must b e used. The inputs of this function are v alues of the system inputs as a dict, t-norm, s-norm, domain, and the type reduction algorithm and metho d. The default output of the evaluate function is dep ended on the type reduction metho d and the algorithm sp ecified b y the user and is describ ed in details in do cstrings. In most of cases the output v ariable of this function is of dict data t yp e. In the output dict, tuples are corresp onded with the output v ariable names which are added by add output variable function in initial definition of the system. These tuples represen t type reduced outputs of the fuzzy system. In order to obtain crisp output of the system, eac h tuple can b e given as input of the crisp function. Also, in order to plot the type reduced output the TR plot function cab ne used. The third co de in the app endix section sho ws how to plot the t yp e reduced outputs and calculate the crisp outputs for the result of evaluate function. 2.4 T yp e reduction A very imp ortan t concept in type 2 fuzzy systems is type reduction algorithms and metho ds. Nine type reduction algorithms are provided in PyIT2FLS which are KM [ 16 ], EKM, WEKM, TWEKM [ 17 , 18 ], EIASC[ 19 ], WM [ 20 ], BMM [ 21 ], LBMM [ 22 ], and NT [ 23 ]. These type reduction algorithms can b e used alongside the metho ds Centroid, Center of sets, Cen ter of sum, Heigh t, and Mo dified height. The functions corresp onding with these algorithms and metho ds and their brief description are presented in T ables 5 and T able 6, resp ectively . These functions and metho ds are not called directly by the user most of the times, but their name is passed to the evaluate function of IT2FLS class as parameters, metho d and algorithm . The aforementioned tables also contain the names which the algorithms and metho ds are passed to the evaluate function. Do cstrings are also av ailable for a more detailed explanation o f the instructions. 3 Examples In this section three examples of using prop osed PyIT2FLS are under study . First a simple example for using the to olkit to ev aluate fuzzy IF-THEN rules as a fuzzy logic system is given. After that an example of using the to olkit for prediction of chaotic time series is given, in which the parameters of fuzzy system are determined using PSO algorithm to ha ve minimum mean square error. And finally , the to olkit is used for mo deling an interv al type 2 fuzzy PID (IT2FPID) controller, and using it to control a time-delay linear system. 5 T able 5: List of type reduction algorithms for evaluate function of IT2FLS class. Algorithm Description Name KM Karnik-Mendel algorithm KM EKM Enhanced KM algorithm EKM WEKM W eighted EKM algorithm WEKM TWEKM T rap ezoidal WEKM algorithm TWEKM EIASC Enhanced IASC algorithm EIASC WM W u-Mendel algorithm WM BMM Begian-Melek-Mendel algorithm BMM LBMM BMM metho d edited by Li et al. LBMM NT Nie-T an algorithm NT T able 6: List of type reduction metho ds for evaluate function of IT2FLS class. Metho d Description Name Cen troid Cen troid type reduction metho d Centroid Cen ter of sets Cen tr of sets type reduction metho d CoSet Cen ter of sum Cen ter of sums t yp e reduction metho d CoSum Heigh t Heigh t type reduction metho d Heigh t Mo dified height Mo dified height type reduction metho d Mo diHe 3.1 A simple example for using PyIT2FLS Assume an IT2FLS with tw o inputs and tw o outputs. Let the universe of discourse in this example b e the interv al [0 , 1]. Assume that three IT2FSs are defined in the universe of discourse which are Gaussian IT2FS with uncertain standard deviation v alues. Also let the rule base of the IT2FLS b e as b elo w: IF x 1 is Small AN D x 2 is Small THEN y 1 is Small AN D y 2 is Large IF x 1 is Medium AN D x 2 is Medium THEN y 1 is Medium AN D y 2 is Small IF x 1 is Large AN D x 2 is Large THEN y 1 is Large AN D y 2 is Small With these assumptions, the co des for mo deling this IT2FLS w ould b e as provided in fourth subsection of the app endix. The discrete domain is defined as 100 equal-distance p oin ts in the interv al [0 , 1]. The sets defining the universe of discourse are constructed using the function IT2FS Gaussian Unc ertStd and are plotted. The inputs x 1 and x 2 , and the outputs y 1 and y 2 are added to the system. Based on defined IT2FS s and input and output v ariables, fuzzy IF-THEN rules are defined. Finally the output is ev aluated and represented for x 1 , x 2 = 0 . 9. The outputs generated by running this co de are demonstrated in Figure. 3. IT2FS output for first and second outputs of the system are illustrated in Figures 3a and 3b, resp ectiv ely . Also type reduced outputs are shown in Figures 3c and 3d. 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 Do m a i n 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 M e m b e r sh i p d e g r e e (a) y 1 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 Do m a i n 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 M e m b e r sh i p d e g r e e (b) y 2 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 Do m a i n 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 M e m b e r sh i p d e g r e e (c) Type reduced y 1 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 Do m a i n 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 M e m b e r sh i p d e g r e e (d) Type reduced y 2 Figure 3: Outputs of the provided example. 6 T able 7: F uzzy If-Then rule base of IT2FLS. Rule An tecedent Conclusion A B C O Rule 1 A1 B1 C1 O1 Rule 2 A2 B2 C2 O2 Rule 3 A3 B3 C3 O3 2 0 0 2 4 0 2 8 0 3 2 0 3 6 0 4 0 0 4 4 0 4 8 0 5 2 0 5 6 0 6 0 0 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 1 . 2 1 . 4 1 . 6 1 . 8 M a c k e y - G l a ss d y n a m i c s γ = 1 , β = 2 , τ = 2 , a n d n = 9 . 6 5 Figure 4: Resp onse of the Mack ey-Glass nonlinear time delay differential equation for exact parameters. 3.2 Prediction of Mac k ey-Glass Chaotic Time Series In this section, the results achiev ed by using the dev eloped PyIT2FLS in a practical application, prediction of Mac key-Glass c haotic time series, is sho wn. The Mack ey-Glass nonlinear time dela y differen tial equation is defined as: dx dt = β x τ 1 + x n τ − γ x γ , β , n > 0 (2) in which the parameters β , γ , τ and n are real n umbers. In addition, x τ sho ws the delay ed v alue of v ariable x at time t − τ [ 24 ]. The resp onse of the Mack ey-Glass dynamic equation is demonstrated in Figure. 4 for parameters β = 2, γ = 1, τ = 2, and n = 9 . 65 and random initial conditions. The Mack ey-Glass Equation alongside the logistic map, Lorenz equations, and Chen systems is known as a paragon of c haotic systems [ 25 ]. Due to the chaotic b eha vior of the Mack ey-Glass time series, it has b een the sub ject of many scien tific studies. These studies mainly concern the prediction of time series [26, 27] and the sync hronization of chaotic systems [28, 29]. Let mg indicate the time series, in order to predict the Mack ey-Glass time series using IT2FLS, three inputs are considered which are consecutiv e samples mg [ t − 2], mg [ t − 1], and mg [ t ]. Assume that inputs are named as A, B, and C. Each input in its univ erse of discourse is expressed by three IT2FSs, which can b e shown b y indices 1 to 3 (as an example for the input A there will b e three sets A 1 , A 2 , and A 3 ). The output of system, named O, is mg [ t + 1] and is expressed using three IT2FSs, O 1 , O 2 , and O 3 . All the fuzzy sets are Gaussian IT2FS with uncertain standard deviation v alues. The rule base of the system is demonstrated in T able 7. All the parameters of the fuzzy sets are selected b y PSO algorithm to hav e minim um Mean Square Error (MSE) in prediction. In this step, 100 samples are used for optimizing the selected parameters. Also the prediction is rep eated on an other 100 samples in order to guarantee the p erformance of the IT2FLS. The result of prediction, real v alue of time series and absolute error are illustrated in Figure 5a. F urther more the con vergence diagram of the PSO algorithm is demonstrated in Figure 5b. The co des used for simulating this example are op enly accessible ov er the to olkit’s GitHub page. 3.3 In terv al Type 2 F uzzy PID Con troller for Time Delay Linear System In this section in order to show the generality of the prop osed to olkit, it is used to mo del an IT2FPID con troller. It must b e noted that this case study is adopted from [ 12 ]. Let’s consider the transfer function 7 0 2 0 4 0 6 0 8 0 1 0 0 t 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 1 . 2 1 . 4 y ( t ) Pr e d i c t e d R e a l E r r o r (a) Prediction output ac hieved using the PyIT2FLS. 0 2 0 4 0 6 0 8 0 1 0 0 I t e r a t i o n 0 . 0 0 0 . 0 2 0 . 0 4 0 . 0 6 0 . 0 8 0 . 1 0 0 . 1 2 0 . 1 4 0 . 1 6 M S E (b) Conv ergence of the PSO algorithm. Figure 5: Outputs achiev ed for the predictiin of Mack ey-Glass time series using PyIT2FLS. Figure 6: Blo c k diagram of the system under study with IT2FPID controller. of the system under study as b elo w: G ( s ) = K T s + 1 e − Ls (3) And let the blo c k diagram represen tation of the ov erall system b e as illustrated in Figure. 6. As it can b e seen in Figure. 6, the inputs of the IT2FPID are the scaled verions of the error signal ( e ) and its deriv ativ e ( ˙ e ). F or each input there are three IT2FSs, Negative (N), Zero (Z), and Positiv e (P). The single output of the IT2FPID is used with scaling factors for achieving the prop ortional and integral terms co efficien ts. The output is demonstrated using five IT2FSs, Negative Big (NB), Negative Medium (NM), Zero (Z), P ositive Medium (PM), and Positiv e Big (PB). All input and output sets are Gaussian ones with uncertain standard deviation. Also, the universe of discourse is defined as the interv al [ − 1 , 1]. I nput and output sets are illustrated in Figures 7a and 7b, resp ectiv ely . The IT2FLS is constructed using 9 rules whic h are shown in T able. 8. Parameters of the nominal system are set as L = 0 . 2, T = 1, and K = 1. In order to study the effect of parameters uncertaint y on the controller’s p erformance, tw o more parameter settings are considered; L = 0 . 4, T = 1 . 9, K = 1 . 3 (Perturbed System-1) and L = 0 . 45, T = 1 . 3, K = 1 . 1 (P erturb ed System-2). The scaling factors of the IT2FPID are set and fixed as K a = 0 . 25, K b = 4 . 25, − 1 . 0 0 − 0 . 7 5 − 0 . 5 0 − 0 . 2 5 0 . 0 0 0 . 2 5 0 . 5 0 0 . 7 5 1 . 0 0 Do m a i n 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 M e m b e r sh i p d e g r e e Ne g a t i v e Z e r o Po si t i v e (a) Sets defined for the inputs of IT2FPID − 1 . 0 0 − 0 . 7 5 − 0 . 5 0 − 0 . 2 5 0 . 0 0 0 . 2 5 0 . 5 0 0 . 7 5 1 . 0 0 Do m a i n 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 M e m b e r sh i p d e g r e e Ne g a t i v e B i g Ne g a t i v e M e d i u m Z e r o Po si t i v e M e d i u m Po si t i v e Bi g (b) Sets defined for the output of IT2FPID Figure 7: Input sets and output sets defined for PyIT2FLS. 8 T able 8: F uzzy If-Then rule base of IT2FPID. ˙ e/e N Z P N NB NM Z Z NM Z PM P Z NM PB 0 . 0 2 . 5 5 . 0 7 . 5 1 0 . 0 1 2 . 5 1 5 . 0 1 7 . 5 2 0 . 0 T i m e ( s) 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 S y st e m r e sp o n se R e fe r e n c e K M E I A S C W M B M M NT (a) Main system 0 . 0 2 . 5 5 . 0 7 . 5 1 0 . 0 1 2 . 5 1 5 . 0 1 7 . 5 2 0 . 0 T i m e ( s) 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 S y st e m r e sp o n se R e fe r e n c e K M E I A S C W M B M M NT (b) Perturbed system 1. 0 . 0 2 . 5 5 . 0 7 . 5 1 0 . 0 1 2 . 5 1 5 . 0 1 7 . 5 2 0 . 0 T i m e ( s) 0 . 0 0 . 2 0 . 4 0 . 6 0 . 8 1 . 0 S y st e m r e sp o n se R e fe r e n c e K M E I A S C W M B M M NT (c) Perturbed system 2. Figure 8: The closed lo op step resp onse for main system, p erturb ed system-1, and p erturbed system-2. K e = 0 . 8, and K d = 0 . 5. The p erformance of the designed control system is measured based on ov ersho ot, settling time, and Integral Time Absolute Error (IT AE) v alues. The step resp onse of the systems are illustrated in Figure. 8, and the p erformance measures are rep orted in T able. 9. As it can b e seen, in terv al type 2 fuzzy logic system impro ves the robustness of the system resp onse faced with system parameters p erturbation. The sim ulations are done with multiple type reduction algorithms alongside with Centroid metho d. The results sho w that WM and BMM type reduction algorithms demonstrate b etter p erformance facing with control problems. 4 Conclusion In this pap er a new Python to olkit for utilizing interv al type 2 fuzzy logic systems is presented. This to olkit facilitates the use of IT2FLSs in practical scien tific and engineering applications. How to use this library and its features are briefly describ ed in this pap er. Also, several examples are included for b etter understanding. Prediction of time series is one of the most common applications of fuzzy systems. PyIT2FLS used to predict the chaotic Mack ey-Glass time series. Also a IT2FPID controller designed to con trol a time delay linear system. As the results show, the presented to olkit is able to b e used in complex applications of the IT2FLSs. The developmen t of the provided to olkit here is not o ver, but will contin ue to cov er a wider v ariety of systems, metho ds and applications. Compared with other Python to olkits for t yp e 2 fuzzy logic, PyIT2FLS supports b oth fuzzy sets and fuzzy systems and that is while t yp e 2 fuzzy systems are not supp orted by other Python to olkits. It should b e noted that the developers of the PyIT2FLS are ready to receiv e commen ts and suggestions ab out the to olkit and p ossible bug rep orts. The PyIT2FLS is op enly accessible on the GitHub page: https://github.com/Haghrah/PyIT2FLS . App endix: Python codes Simple python co des used in the pap er for generating outputs are provided here. The co des for the tw o last complete examples are accessible in PyIT2FLS GitHub page. Defining an IT2FS using PyIT2FLS 9 T able 9: Performance measure of designed IT2FPID in contact with system. System TR Settling time Ov ersho ot IT AE Nominal system KM 5.1125 2.2287% 2.7967 EIASC 5.1225 2.2302% 2.7970 WM 5.3926 2.0904% 3.2899 BMM 5.0925 2.1204% 2.8455 NT 5.1325 2.5284% 2.7554 P erturb ed system-1 KM 13.1765 9.3269% 5.9002 EIASC 13.1765 9.3291% 5.8978 WM 9.0545 6.8808% 5.4139 BMM 10.2951 7.6610% 5.3664 NT 13.4267 10.0322% 6.2336 P erturb ed system-2 KM 7.5437 3.7081% 3.3893 EIASC 7.5437 3.7139% 3.3908 WM 8.1940 3.4181% 3.7504 BMM 6.8834 2.2547% 3.0258 NT 7.6738 3.9807% 3.4711 f r o m p y i t 2 f l s i m p o r t I T 2 F S , t r a p e z o i d _ m f , t r i _ m f f r o m n u m p y i m p o r t l i n s p a c e m y S e t = I T 2 F S ( l i n s p a c e ( 0 . , 1 . , 1 0 0 ) , t r a p e z o i d _ m f , [ 0 , 0 . 4 , 0 . 6 , 1 . , 1 . ] , t r i _ m f , [ 0 . 2 5 , 0 . 5 , 0 . 7 5 , 0 . 6 ] ) Plotting the meet and join of IT2FSs f r o m p y i t 2 f l s i m p o r t I T 2 F S _ G a u s s i a n _ U n c e r t M e a n , I T 2 F S _ p l o t , m e e t , \ j o i n , m i n _ t _ n o r m , m a x _ s _ n o r m f r o m n u m p y i m p o r t l i n s p a c e d o m a i n = l i n s p a c e ( 0 . , 1 . , 1 0 0 ) A = I T 2 F S _ G a u s s i a n _ U n c e r t M e a n ( d o m a i n , [ 0 . , 0 . 1 , 0 . 1 ] ) B = I T 2 F S _ G a u s s i a n _ U n c e r t M e a n ( d o m a i n , [ 0 . 3 3 , 0 . 1 , 0 . 1 ] ) C = I T 2 F S _ G a u s s i a n _ U n c e r t M e a n ( d o m a i n , [ 0 . 6 6 , 0 . 1 , 0 . 1 ] ) I T 2 F S _ p l o t ( A , B , C , t i t l e = " " , l e g e n d s = [ " S m a l l " , " M e d i u m " , " L a r g e " ] , f i l e n a m e = " m u l t i S e t " ) A B = m e e t ( d o m a i n , A , B , m i n _ t _ n o r m ) A B . p l o t ( f i l e n a m e = " m e e t " ) B C = j o i n ( d o m a i n , B , C , m a x _ s _ n o r m ) B C . p l o t ( f i l e n a m e = " j o i n " ) Plotting the t yp e reduced output of IT2FLS and calculating the crisp output T R _ p l o t ( d o m a i n , T R [ " y 1 " ] , f i l e n a m e = " y 1 _ t r " ) p r i n t ( c r i s p ( T R [ " y 1 " ] ) ) T R _ p l o t ( d o m a i n , T R [ " y 2 " ] , f i l e n a m e = " y 2 _ t r " ) p r i n t ( c r i s p ( T R [ " y 2 " ] ) ) 10 F ull example of defining and using an IT2FLS f r o m p y i t 2 f l s i m p o r t I T 2 F L S , I T 2 F S _ G a u s s i a n _ U n c e r t S t d , I T 2 F S _ p l o t , \ m i n _ t _ n o r m , m a x _ s _ n o r m , T R _ p l o t f r o m n u m p y i m p o r t l i n s p a c e d o m a i n = l i n s p a c e ( 0 . , 1 . , 1 0 0 ) S m a l l = I T 2 F S _ G a u s s i a n _ U n c e r t S t d ( d o m a i n , [ 0 , 0 . 1 5 , 0 . 1 ] ) M e d i u m = I T 2 F S _ G a u s s i a n _ U n c e r t S t d ( d o m a i n , [ 0 . 5 , 0 . 1 5 , 0 . 1 ] ) L a r g e = I T 2 F S _ G a u s s i a n _ U n c e r t S t d ( d o m a i n , [ 1 . , 0 . 1 5 , 0 . 1 ] ) I T 2 F S _ p l o t ( S m a l l , M e d i u m , L a r g e , l e g e n d s = [ " S m a l l " , " M e d i u m " , " l a r g e " ] , f i l e n a m e = " s i m p _ e x _ s e t s " ) m y I T 2 F L S = I T 2 F L S ( ) m y I T 2 F L S . a d d _ i n p u t _ v a r i a b l e ( " x 1 " ) m y I T 2 F L S . a d d _ i n p u t _ v a r i a b l e ( " x 2 " ) m y I T 2 F L S . a d d _ o u t p u t _ v a r i a b l e ( " y 1 " ) m y I T 2 F L S . a d d _ o u t p u t _ v a r i a b l e ( " y 2 " ) m y I T 2 F L S . a d d _ r u l e ( [ ( " x 1 " , S m a l l ) , ( " x 2 " , S m a l l ) ] , [ ( " y 1 " , S m a l l ) , ( " y 2 " , L a r g e ) ] ) m y I T 2 F L S . a d d _ r u l e ( [ ( " x 1 " , M e d i u m ) , ( " x 2 " , M e d i u m ) ] , [ ( " y 1 " , M e d i u m ) , ( " y 2 " , S m a l l ) ] ) m y I T 2 F L S . a d d _ r u l e ( [ ( " x 1 " , L a r g e ) , ( " x 2 " , L a r g e ) ] , [ ( " y 1 " , L a r g e ) , ( " y 2 " , S m a l l ) ] ) i t 2 o u t , t r = m y I T 2 F L S . e v a l u a t e ( { " x 1 " : 0 . 9 , " x 2 " : 0 . 9 } , m i n _ t _ n o r m , m a x _ s _ n o r m , d o m a i n , m e t h o d = " C e n t r o i d " ) i t 2 o u t [ " y 1 " ] . p l o t ( f i l e n a m e = " y 1 _ o u t " ) T R _ p l o t ( d o m a i n , t r [ " y 1 " ] , f i l e n a m e = " y 1 _ t r " ) i t 2 o u t [ " y 2 " ] . p l o t ( f i l e n a m e = " y 2 _ o u t " ) T R _ p l o t ( d o m a i n , t r [ " y 2 " ] , f i l e n a m e = " y 2 _ t r " ) References [1] Kazuo T anak a and Hua O W ang. F uzzy c ontr ol systems design and analysis: a line ar matrix ine quality appr o ach , page 5. John Wiley & Sons, 2004. [2] Li-Xin W ang and Li-Xin W ang. A c ourse in fuzzy systems and c ontr ol , v olume 2, pages 2–3. Pren tice Hall PTR Upp er Saddle River, NJ, 1997. [3] Lotfi Ask er Zadeh. The concept of a linguistic v ariable and its application to approximate reasoning—i. Information scienc es , 8(3):199–249, 1975. [4] Jerry Mendel, Hani Hagras, W o ei-W an T an, William W Melek, and Hao Ying. Intr o duction to typ e-2 fuzzy lo gic c ontr ol: the ory and applic ations , page 43. John Wiley & Sons, 2014. [5] Ismail Atacak and Omer F aruk Bay . A type-2 fuzzy logic controller design for buck and b oost dc–dc con verters. Journal of intel ligent manufacturing , 23(4):1023–1034, 2012. [6] GM Mendez, L Leduc-Lezama, R Colas, G Murillo-Perez, J Ramirez-Cuellar, and JJ Lop ez. Mo delling and control of coiling entry temp erature using in terv al type-2 fuzzy logic systems. Ir onmaking & Ste elmaking , 37(2):126–134, 2010. [7] Li Cheng-Dong, Yi Jian-Qiang, Y u Yi, and Zhao Dong-Bin. Inv erse con trol of cable-driv en parallel mec hanism using type-2 fuzzy neural netw ork. A cta Automatic a Sinic a , 36(3):459–464, 2010. [8] S Bark ati, EM Berkouk, and MS Boucherit. Application of type-2 fuzzy logic controller to an induction motor drive with seven-lev el dio de-clamped inv erter and controlled infeed. Ele ctric al Engine ering , 90(5):347–359, 2008. 11 [9] Vik as Singh, Ragha v Dev, Narendra K Dhar, Poo ja Agraw al, and Nishchal K V erma. Adaptiv e t yp e-2 fuzzy approac h for filtering salt and p epper noise in grayscale images. IEEE T r ansactions on F uzzy Systems , 26(5):3170–3176, 2018. [10] Christian W agner. Juzzy-a ja v a based to olkit for type-2 fuzzy logic. In 2013 IEEE Symp osium on A dvanc es in T yp e-2 F uzzy L o gic Systems (T2FUZZ) , pages 45–52. IEEE, 2013. [11] Oscar Castillo, Patricia Melin, and Juan R Castro. Computational intelligence softw are for interv al t yp e-2 fuzzy logic. Computer Applic ations in Engine ering Educ ation , 21(4):737–747, 2013. [12] Ahmet T askin and T ufan Kum basar. An op en source matlab/sim ulink to olb o x for interv al type-2 fuzzy logic systems. In 2015 IEEE Symp osium Series on Computational Intel ligenc e , pages 1561–1568. IEEE, 2015. [13] Josie McCullo c h. F uzzycreator: A python-based to olkit for automatically generating and analysing data-driv en fuzzy sets. In 2017 IEEE International Confer enc e on F uzzy Systems (FUZZ-IEEE) , pages 1–6. IEEE, 2017. [14] T ravis E Oliphant. A guide to NumPy , v olume 1. T relgol Publishing USA, 2006. [15] John D Hunter. Matplotlib: A 2d graphics environmen t. Computing in scienc e & engine ering , 9(3):90, 2007. [16] Nilesh Nav al Karnik, Jerry M Mendel, and Qilian Liang. T yp e-2 fuzzy logic systems. IEEE tr ansactions on F uzzy Systems , 7(6):643–658, 1999. [17] K Duran, H Bernal, and M Melgarejo. Improv ed iterative algorithm for computing the generalized cen troid of an in terv al t yp e-2 fuzzy set. In NAFIPS 2008-2008 Annual Me eting of the North A meric an F uzzy Information Pr o c essing So ciety , pages 1–5. IEEE, 2008. [18] Dongrui W u and Jerry M Mendel. Enhanced k arnik–mendel algorithms. IEEE T r ansactions on F uzzy Systems , 17(4):923–934, 2008. [19] Dongrui W u and Maow en Nie. Comparison and practical implementation of type-reduction algorithms for t yp e-2 fuzzy sets and systems. In 2011 IEEE International Confer enc e on F uzzy Systems (FUZZ- IEEE 2011) , pages 2131–2138. IEEE, 2011. [20] Hongw ei W u and Jerry M Mendel. Uncertaint y b ounds and their use in the design of interv al type-2 fuzzy logic systems. IEEE T r ansactions on fuzzy systems , 10(5):622–639, 2002. [21] Mohammad Biglar Begian, William W Melek, and Jerry M Mendel. Stabilit y analysis of t yp e-2 fuzzy systems. In 2008 IEEE International Confer enc e on F uzzy Systems (IEEE World Congr ess on Computational Intel ligenc e) , pages 947–953. IEEE, 2008. [22] Chengdong Li, Jianqiang Yi, and Tiechao W ang. Stability analysis of sirms based type-2 fuzzy logic con trol systems. In International Confer enc e on F uzzy Systems , pages 1–7. IEEE, 2010. [23] Mao wen Nie and W o ei W an T an. T o w ards an efficient t yp e-reduction metho d for interv al type-2 fuzzy logic systems. In 2008 IEEE International Confer enc e on F uzzy Systems (IEEE World Congr ess on Computational Intel ligenc e) , pages 1425–1432. IEEE, 2008. [24] Leon Glass and Mic hael Mack ey . Mack ey-glass equation. Scholarp e dia , 5(3):6908, 2010. [25] Marc R Roussel. The mack ey-glass mo dels, 40 years later. Biomath Communic ations , 5(2):140–158, 2018. [26] Tian Zhongda, Li Shujiang, W ang Y anhong, and Sha Yi. A prediction metho d based on wa velet transform and multiple mo dels fusion for chaotic time series. Chaos, Solitons & F r actals , 98:158–172, 2017. 12 [27] Gholamali Heydari, MohammadAli V ali, and Ali Akbar Gharav eisi. Chaotic time series prediction via artificial neural square fuzzy inference system. Exp ert Systems with Applications , 55:461–468, 2016. [28] EM Shahv erdiev, RA Nuriev, RH Hashimov, and KA Shore. Chaos synchronization b et ween the mac key–glass systems with multiple time delays. Chaos, Solitons & F r actals , 29(4):854–861, 2006. [29] Hong-jun Shi, Lian-ying Miao, and Y ong-zheng Sun. Sync hronization of time-delay ed systems with discon tinuous coupling. Kyb ernetika , 53(5):765–779, 2017. 13
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment