A Direct Approach for Determining the Switch Points in the Karnik-Mendel Algorithm

—The Karnik-Mendel algorithm is used to compute the centroid of interval type-2 fuzzy sets, determining the switch points needed for the lower and upper bounds of the centroid, through an iterative process. It is commonly acknowledged that there is no closed-form solution for determining such switch points. Many enhanced algorithms have been proposed to improve the computational efﬁciency of the Karnik-Mendel algorithm. However, all of these algorithms are still based on iterative procedures. In this paper, a direct approach based on derivatives for determining the switch points without multiple iterations has been proposed, together with mathematical proof that these switch points are correctly determining the lower and upper bounds of the centroid. Experimental simulations show that the direct approach obtains the same switch points, but is more computationally efﬁcient than any of the existing (iterative) algorithms. Thus, we propose that this algorithm should be used in any application of interval type-2 fuzzy sets in which the centroid is required.


I. INTRODUCTION
T HE Karnik-Mendel (KM) algorithm was the first algo- rithm proposed to determine the switch points when computing the centroids of interval type-2 (IT2) fuzzy sets [1].With its fast convergence, it is still the most widely used algorithm for computing the switch points [2,3,4,5,6].It was originally shown that the maximum number of iterations of the KM algorithm is N , which is the number of discrete points in the universe of discourse for an IT2 fuzzy set.This was believed to be extremely conservative and it was subsequently proved by Liu [7] that the maximum number of iterations of the KM algorithm is (N + 1)/2.A much smaller number (N + 2)/4 was given in [8] as the maximum number of iterations, without proof.Though these numbers are much smaller than N , they are still believed to be conservative [3].Many studies by simulations show that the KM algorithm converges in from two to six iterations, regardless of N [9].
Many attempts have been made to improve the efficiency of the KM algorithm.The enhanced KM (EKM) algorithm introduces a better initialisation, which "on average ... can save about two iterations" [9].Also, some algorithmic improvements to simplify computations were introduced to reduce the computational cost for each iteration.An improved iterative algorithm with stopping condition (IASC) was first proposed in [10] and further refined in [11].Further improvements to the IASC have been made in the enhanced IASC (EIASC) in [12].Both the IASC and EIASC algorithms have been reported to be superior to the KM and EKM algorithms when N is small (e.g.N 100).However, their computational costs increase rapidly as N increases since many possible switch points have to be evaluated before finding the correct ones [3].
Rather than calculating the exact centroids, closed-form solutions, which are much more efficient than iterative algorithms, have been provided for approximations.For example, the Nie-Tan (NT) method as given in [13].It has been demonstrated that the NT method can give a very good approximation to the KM algorithm.As an extension of the NT method, a better approximation with Taylor-series is provided in [14].Closed-form formulae for calculating the centroids of a general type-2 fuzzy set are proposed in [15], where linear connections between the centroid endpoints of any α plane and that of α = 0 and α = 1 planes have been introduced.However, the calculations of the centroid end points of the α = 0 and α = 1 planes are still based on the iterative KM algorithm.Other algorithms to improve efficiency have also been proposed recently, such as [16] and [17], although these too are iterative.
To the best of our knowledge, all existing algorithms, such as the EKM and the EIASC, for determining the switch points are iterative-based methods.In this paper, a direct approach which can compute the switch points based on derivatives, without multiple iterations, is proposed.We use the term 'iteration' here to mean the repeated calculation of the position of the switch points.Within all approaches there are common calculations that require looping (e.g.cumulative sum), which we do not consider as iterations of the main algorithm.
The rest of the paper is organised as follows.The mathematical formulation of the KM algorithm is introduced in Section II.Section III briefly reviews some of the well-known iterative algorithms for the switch points in the KM algorithm.The new direct approach is introduced in Section IV, followed by a proof in Section V to show that the switch points calculated by the direct approach are the same as obtained via the KM algorithm.Experimental results for comparisons are shown and discussed in Sections VI and VII.Finally, a conclusion is provided in Section VIII.Note that all variables and constants defined in this paper are real numbers.

II. THE KM ALGORITHM
Let an IT2 fuzzy set Ã be based on where x i is the primary variable in the discrete universe of discourse X (note that x i is in ascending order for i from 1 to N ), J i represents the membership grade interval for the primary variable x i , and N is the number of discrete points in the universe of discourse.
For any given embedded type-1 fuzzy set, with membership grades u i ∈ J i for all i, of such an IT2 fuzzy set Ã, the centroid is defined as: If the above centroid c is computed for all embedded type-1 fuzzy sets, a centroid interval C = [c l , c r ] can be obtained where In fact, there is no need to compute the centroids for all embedded type-1 fuzzy sets to get the centroid interval.It is well known that the endpoints c l and c r of the centroid interval can also be expressed as (the derivation can be found in [9]): where L and R, which are integer indices in the range of [1, N − 1], are the switch points for selecting ūi or ūi .
As stated by Mendel [3], there is no closed-form solution for such switch points L and R, and hence, for c l and c r .By utilising the properties of the switch points such that the KM algorithm can be used to find them iteratively [1].

III. THE ITERATIVE ALGORITHMS
In this section, two commonly used iterative algorithms are briefly introduced, to establish terminology and notation.Rather than introduce the original KM and IASC algorithms, their enhancements (the EKM and EIASC algorithms) are reviewed as they are more efficient than the original algorithms.

A. The EKM algorithm
The EKM algorithm is summarised in Table I.Compared to the original KM algorithm, the EKM algorithm introduces a better initialisation (Step 2) for the starting position and a change of the termination condition (Step 4) to remove an unnecessary iteration [9].The EKM algorithm can save, on average, about two iterations.Simplified calculations (Step 5) are also introduced to save computational costs for each iteration.

B. The EIASC algorithm
The EIASC algorithm is summarised in Table II.Compared to the original IASC algorithm, the EIASC algorithm introduced a new stopping criterion (Step 4) [12].Also, the starting point for computing c r has been changed to N (Step 2) since the switch point R for c r has been shown to be generally greater than N/2 [9].

IV. THE DIRECT APPROACH (DA) ALGORITHM
An arbitrary c in the centroid interval C, represented as Equation 3, can be expanded to Equation 4. Equation 4can then be transformed to Equation 5 by substituting x 1 + i j=2 δx j for all corresponding x i (i > 1), where δx j = x j − x j−1 .
For example, x 3 in Equation 4 is represented as (x 1 + δx 2 + δx 3 ) in Equation 5. Note that δx j is always positive since x i (defined in Section II), and hence x j , is in ascending order.This transformation is made to allow the sign of the partial derivatives to be easily identified, as shown in Equations 7 to 11.After the transformation, by rearranging and aggregating all the items with x 1 and δx j for j = 2, 3, ..., N in Equation 5, c can finally be represented as Equation 6.We can then compute the partial derivative of c with respect to u j in the pattern of Equations 7 to 8.Then, this partial derivative ∂c ∂uj can be represented as Equation 9for specific j ∈ It is noted by Karnik and Mendel [1] and Wu and Mendel [9] that equating the partial derivative of c with respect to u j to zero does not give us any information about the value of u j that maximises or minimises c.However, it can be observed that the sign of the partial derivative of c with respect to u j does not depend on the value of u j .Hence, it is clear that, when the partial derivative is negative, it is necessary to take the largest possible value of u j in order to minimise c.When the partial derivative is positive, it is necessary to take the smallest possible value of u j in order to minimise c.That is, to obtain c l (the minimum centroid), one must set u j to ūj when the partial derivative is negative, and to ūj when the partial derivative is positive.We observe that for any given value of u j , this partial derivative is monotonically increasing with j (from 1 to N ).Hence, for c l , there must be a switch point k ∈ [1, N ] for which ∂c ∂u k ≤ 0 and ∂c ∂u k+1 ≥ 0. Based on the above, it is possible to find the switch point directly by locating the value of k where the sign of the partial derivative changes.The same principles can be used to find the switch point k for the maximum centroid c r , swapping ūj and ūj in u j .The DA algorithm is such an algorithm, deploying the derivatives of

Step
The EKM Algorithm for computing c l The EKM Algorithm for computing cr 1 Sort x i (i = 1, 2, ..., N ) in ascending order and match ūi and ūi accordingly with their respective x i . 2 Set k = [N/2.4],which is the nearest integer to N/2.4, and compute Set k = [N/1.7],which is the nearest integer to N/1.7, and compute

TABLE I:
The EKM algorithm for computing the centroid end points (c l and c r ) of an IT2 Fuzzy Set.Note that for the case described in Section II, Step 1 is not necessary since x i has already been defined in ascending order.Table I is adapted from [3,9].
Step The EIASC Algorithm for computing c l The EIASC Algorithm for computing c r 1 Sort x i (i = 1, 2, ..., N ) in ascending order and match ūi and ūi accordingly with their respective x i . 2 Initialise k = 0 and Initialise k = N and If c x k+1 , set c l = c and stop; If c x k , set c r = c and stop; Otherwise, go to Step 3; TABLE II: The EIASC algorithm for computing the centroid end points (c l and c r ) of an IT2 Fuzzy Set.Note that for the case described in Section II, Step 1 is not necessary since x i has already been defined in ascending order.Table II is adapted from [3,12].c with respect to each u j , and hence providing a method for directly obtaining the switch points.Figure 1 illustrates the monotonically increasing trend of the partial derivative ∂c ∂uj and the location of the switch point.
Since δx j is always positive, it can be observed in Equation 9 that the partial derivative consists of two parts, which are the positive part pos j and the negative part neg j : ∂c ∂u j = pos j + neg j where pos j and neg j are presented in Equations 10 and 11, which can be summarised as Equations 12 and 13.Having all the partial derivatives, the switch points L for c l and R for c r can be obtained as follows.
For L and hence c l : 1) Calculate pos j by setting all the u i to be ūi and calculate neg j by setting all the u i to be ūi , for all j ∈ [1, N ]. 2) Calculate all the partial derivatives ∂c ∂uj as For R and hence c r : 1) Calculate pos j by setting all the u i to be ūi and calculate neg j by setting all the u i to be ūi , for all j ∈ [1, N ]. 2) Calculate all the partial derivatives ∂c ∂uj as It should be noted that the denominator ( N i=1 u i ) 2 in Equations 12 and 13, which must be positive, can be neglected in calculations to save computational costs.In other words, without the risk of changing the sign of ∂c ∂uj , pos j and neg j can be simplified as presented in Equations 14 and 15.Also, in practice, there is no need to calculate the partial derivatives one by one, as cumulative sums and vectorised operations can be used.The pseudo-code for obtaining L and c l is shown in Algorithm 1. R and c r are calculated in a similar manner, making the substitutions as described above (pseudo-code is omitted due to space constraints).
V. PROOF OF THE DA ALGORITHM Proposition 1.It is clear that when ∂c ∂uj < 0, u j should be its maximum value, ūj , to minimise c and it should be its minimum value, ūj , to maximise c.Conversely, when ∂c ∂uj > 0, u j should be ūj to minimise c and it should be ūj to maximise c.When ∂c ∂uj = 0, c is not dependent on the value of u j .Theorem 1.The index L obtained by the DA algorithm, as described in Section IV, is the correct switch point for calculating the minimum centroid c l .Proof.Given that δx i is always positive, it is clear (from Equations 14 and 15) that for any j ∈ [1, N ], pos j attains its maximum value when u i is ūi and neg j attains its maximum value when u i is ūi ; hence ∂c ∂uj is also maximal.It can be observed from Equation 8 that ∂c ∂uj is monotonically increasing in j.This is because the only difference of ∂c ∂uj for j = n − 1 and j = n is the n th term (n ∈ [2, N ]), which is negative for j = n − 1 and positive for j = n.
If there exists a smallest k ∈ [1, N −1] such that ∂c ∂u k+1 0, then k is the correct switch point L (for calculating c l ) on the basis that: 1) L cannot be less than k, for the following reason.For every j ∈ [1, k], it must be the case that ∂c ∂uj < 0. Therefore, by proposition 1, u j should be its maximum value ūj to minimise c.Now suppose L is less than k.Then, as L is the switch point, every u j∈[L+1,k] should be its minimum value ūj , which by contradiction is not possible.
2) L cannot be greater than k, for the following reason.
Assume L is greater than k.Then, as L is the switch point every u j∈[k+1,L] should be its maximum value ūj .
By proposition 1, it must be the case that ∂c ∂u k+1 < 0, in which case u k+2 must be changed from ūk+2 to ūk+2 .This means ∂c ∂u k+2 , if it exists, must also be negative.By induction, it can be deduced that ∂c ∂u N must be negative.This is in contradiction to the fact that ∂c ∂u N 0. Thus, the assumption is incorrect.Hence, L cannot be greater than k.If there does not exist a k ∈ [1, N −1] such that ∂c ∂u k+1 > 0, then for every j ∈ [1, N − 1], again it must be the case that ∂c ∂uj < 0. Also, ∂c ∂u N must be 0. Thus, there is no contradiction for the switch point L to be N − 1.
Theorem 2. The index R obtained by the DA algorithm, as described in Section IV, is the correct switch point for calculating the maximum centroid c r .
Proof.The proof is similar to above.

VI. EXPERIMENTAL COMPARISON
To further investigate the performance of the new DA, comparisons in terms of time efficiency between the new approach and two of the most widely used algorithms (the EKM and the EIASC algorithms) were conducted.The platform was a laptop with Intel Core i7-3720QM CPU @ 2.60GHz and 8GB memory, running Windows 7 Professional 64bit Service Pack 1.The programming language and software environment is R x64 version 3.2.3.Computational costs were measured by the user time returned by the built-in function proc.time() in the R environment.

A. Examples of IT2 fuzzy sets
In this section, three example IT2 fuzzy sets are used to verify the correctness of the DA algorithm by comparing the switch points with the EKM algorithm and the EIASC algorithm.Specifically, the vector X, containing x i , has 101 discrete values from 0 to 10 by a step size of 0.1.ūi and ūi are obtained by the following membership functions for each type of example IT2 fuzzy sets.
1) Symmetric Gaussian membership functions with uncertain deviation: ūi = exp −0.5 input : X, Ū, Ū , vectors of the primary variable, the upper membership grades, and the lower membership grades, respectively; x i , ūi , and ūi denote elements of the respective vectors; output: L, the switch point; c l , the lower bound of the centroid; , ..., N − 1}, where x i and s 1 i are the i th element of vectors X and S 1 respectively ; where s 2 i is the i th element of the vector S 2 ; 6 D P ← {0, As shown in Table III  B. Generalised IT2 fuzzy sets 1) Generalised bell-shaped IT2 fuzzy sets: It was assumed that the vector X, containing x i , is uniformly distributed from 0 to 10. ūi and ūi are defined by generalised bell-shaped function: and stop; If k = k, set cr = c and stop; Otherwise, go to Step 5; 5 Compute s = sign(k − k), and

Fig. 1 :
Fig. 1: An illustration of the DA algorithm showing the position of the switch point for an arbitrary example where N is 10.

j i=1 t P i | j = 1 , 2 , 1 : 2 ) 2 0
..., N − 1}, where t P i is the i th element of the vectorT P ; 7 D N ← { j i=1 −t N i , 0 | j = N − 1, ..., 2, 1}, where t N i is the i th element of the vectorT N ; 8 D ← {d P i + d N i | i = 1,2, ..., N }, where d P i and d N i are the i th element of vectors D P and D N respectively ; 9 Find the smallest k ∈ 1, 2, ..., N − 1 such that d k+1 0, where d k+1 , which represents ∂c l ∂u k+1 , is the (k + 1) th element of the vector D ; 10 if k exists then L ← k else L ← N − 1; 11 Compute c l by Equation 1; Algorithm Pseudo code for obtaining L, the switch point; and c l , the lower bound of the centroid.Gaussian upper membership function and triangular lower membership function: exp − xi−3 √ 2 .4exp − xi−6 √ 2 2 , the switch points L and R obtained with the examples by three algorithms are all the same.

TABLE III :
The switch points L and R obtained by three algorithms based on the example fuzzy sets.