Post

A Comprehensive Guide to the Takagi-Sugeno (T-S) Fuzzy Inference Model

Explore the Takagi-Sugeno (T-S) fuzzy inference model, a powerful tool for modeling and controlling complex nonlinear systems. This guide covers the structure, mathematical principles, step-by-step implementation, code examples in MATLAB and Python, and real-world applications across industries.

A Comprehensive Guide to the Takagi-Sugeno (T-S) Fuzzy Inference Model

Introduction

The Takagi-Sugeno (T-S) fuzzy inference model, first proposed by Japanese scholars Takagi and Sugeno in 1985, is a powerful and widely-used method for modeling and controlling complex nonlinear systems. Unlike traditional modeling techniques that often struggle with nonlinearity, the T-S model approximates a complex global nonlinear system by breaking it down into a collection of simpler, local linear models. These local models are then intelligently combined using fuzzy logic rules to provide a comprehensive and accurate system description.

The core idea behind the T-S model is “divide and conquer.” It identifies different operating regions of a system and creates a simple linear input-output relationship for each region. A fuzzy inference mechanism then determines the degree to which each local model contributes to the final output, resulting in a smooth and continuous representation of the system’s behavior.

Structure

In order to better understanding what Takagi-Sugeno inference is, before we go into the details, let’s first understand its structure.

A typical T-S fuzzy inference system is composed of the following modules:

  • Input Variables: The crisp (non-fuzzy) inputs to the system.

  • Rule Base: A T-S fuzzy rule takes the form: IF $x$ is $A$ THEN $y = f(x)$ Where:

    • $x$ is the input variable.

    • A is a fuzzy set (e.g., “Low,” “Medium,” “High”).

    • y = f(x) is a linear or constant function representing the local output for that rule. This is a key difference from other fuzzy models like Mamdani, where the output is also a fuzzy set.

  • Inference Engine: This component calculates the “firing strength” ($\omega$) for each rule based on the current system inputs.

  • Normalization: In this modeule, the firing strengths of the rules are normalized.

  • Local Linear Models: Each rule’s consequence part ($y = f(x)$) represents a distinct linear model that is valid under the conditions specified by the rule’s premise.

  • Defuzzification: The final system output is calculated as a weighted average of the outputs from all local linear models. The weight for each model is its normalized firing strength.

Process

The implementation of a T-S model follows these general steps:

  1. System Modeling: Define the input and output variables of the nonlinear system you wish to model.

  2. Rule Design: Partition the input space and define the fuzzy sets for each input. For each fuzzy region, create a rule with a corresponding linear output function.

  3. Inference Process: For a given set of crisp inputs, the system calculates the membership degree of the input for each fuzzy set, determining the firing strength of every rule.

  4. Defuzzification: The final output is computed by multiplying the output of each rule’s linear function by its firing strength and then dividing by the sum of all firing strengths.

Mathematical Details

Rule Representation

Suppose the system has $n$ input variables: $x = (x_1, x_2, …, x_n)$.

A typical T-S fuzzy rule (for rule $i$) is written as:

IF $x_1$ is $A_{1i}$ and $…$ and $x_n$ is $A_{ni}$, THEN
$y_i = f_i(x) = a_{i0} + a_{i1} x_1 + … + a_{in} x_n$

  • $A_{ji}$ is the fuzzy set for the j-th input in the i-th rule.
  • $f_i(x)$ is the local linear (or constant) function for the i-th rule.

Membership Calculation

For an input $x$, the degree to which $x_j$ belongs to $A_{ji}$ is given by the membership function:
$\mu_{A_{ji}}(x_j)$, where $\mu_{A_{ji}}$ is typically a function such as triangular, trapezoidal, or Gaussian.

Firing Strength

The firing strength (activation degree) of the i-th rule, $\omega_i$, is calculated as the product of all antecedent memberships:

\[\omega_i = \prod_{j=1}^n \mu_{A_{ji}}(x_j)\]

Normalization of Firing Strengths

To ensure comparability and to use them as weights, the activation degrees are normalized:

\[h_i = \frac{\omega_i}{\sum_{k=1}^m \omega_k}\]

where $m$ is the total number of rules.

Calculation for Each Rule

Each rule produces an output according to its conclusion:

\[y_i = f_i(x) = a_{i0} + a_{i1} x_1 + ... + a_{in} x_n\]

Defuzzification

The final output $y$ is a weighted sum (or weighted average) of the individual outputs from all rules:

\[y = \sum_{i=1}^m h_i \cdot y_i = \sum_{i=1}^m h_i f_i(x)\]

This is often called the weighted average defuzzification method.

Example

Let’s consider a T-S fuzzy inference system with two input variables, $x_1$ and $x_2$, and two fuzzy rules.

Fuzzy Rules:

  1. Rule 1: IF $x_1$ is Low ($M_{11}$) and $x_2$ is High ($M_{12}$), THEN $y = f_1(x_1, x_2)$
  2. Rule 2: IF $x_1$ is High ($M_{21}$) and $x_2$ is Low ($M_{22}$), THEN $y = f_2(x_1, x_2)$

Membership Functions:

  • $M_{11}(x_1) = \max(0, \min(1 - x_1, 1))$
  • $M_{12}(x_2) = \max(0, \min(x_2 - 0.3, 1))$
  • $M_{21}(x_1) = \max(0, \min(x_1 - 0.3, 1))$
  • $M_{22}(x_2) = \max(0, \min(1 - x_2, 1))$

Let’s use the input values: $x_1 = 0.6$ and $x_2 = 0.8$

Step 1: Calculate Membership Values

  • $M_{11}(0.6) = \max(0, 0.4) = 0.4$
  • $M_{12}(0.8) = \max(0, 0.5) = 0.5$
  • $M_{21}(0.6) = \max(0, 0.3) = 0.3$
  • $M_{22}(0.8) = \max(0, 0.2) = 0.2$

Step 2: Firing Strengths

  • For Rule 1:

    \[\omega_1 = M_{11}(0.6) \times M_{12}(0.8) = 0.4 \times 0.5 = 0.2\]
  • For Rule 2:

    \[\omega_2 = M_{21}(0.6) \times M_{22}(0.8) = 0.3 \times 0.2 = 0.06\]

Step 3: Normalize

  • Total fire strength:

    \[\omega_1 + \omega_2 = 0.2 + 0.06 = 0.26\]
  • Normalized for Rule 1:

    \[h_1 = \frac{0.2}{0.26} \approx 0.769\]
  • Normalized for Rule 2:

    \[h_2 = \frac{0.06}{0.26} \approx 0.231\]

Step 4: Calculate Each Rule

Let’s assign linear functions for each rule:

  • For Rule 1:

    \[y_1 = 1.0 \times x_1 + 2.0 \times x_2 + 0.5\]
  • For Rule 2:

    \[y_2 = 2.0 \times x_1 + 1.0 \times x_2 + 0.2\]

Plug in the values:

\[y_1 = 1.0 \times 0.6 + 2.0 \times 0.8 + 0.5 = 0.6 + 1.6 + 0.5 = 2.7\] \[y_2 = 2.0 \times 0.6 + 1.0 \times 0.8 + 0.2 = 1.2 + 0.8 + 0.2 = 2.2\]

Step 5: Aggregate Outputs

\[y = h_1 \times y_1 + h_2 \times y_2 = 0.769 \times 2.7 + 0.231 \times 2.2\] \[y = 2.0763 + 0.5082 = 2.5845\]

Final Result:
Given inputs $x_1 = 0.6$, $x_2 = 0.8$, the T-S fuzzy system’s output is approximately 2.58.

Scenario: Thermal Control

Scenario Overview

The system controls the opening degree of an air conditioning valve (output $Y$) based on two environmental inputs: temperature ($T$) and humidity ($H$). Each variable is described by three fuzzy sets (Low, Medium, High). The system uses three T-S fuzzy rules:

  • Rule 1: IF $T$ is Low and $H$ is High, THEN $Y$ = 0.2
  • Rule 2: IF $T$ is Medium and $H$ is Medium, THEN $Y$ = 0.5
  • Rule 3: IF $T$ is High and $H$ is Low, THEN $Y$ = 0.8

Steps in the T-S Fuzzy

  1. Fuzzification:
    For a given temperature and humidity, calculate their membership degrees in each fuzzy set.

  2. Rule Activation:
    For each rule, multiply the relevant membership degrees to get the rule’s activation (firing strength).

  3. Normalization:
    Normalize the activations

  4. Output:
    Multiply each rule’s output by its normalized activation. Sum these products to get the final output.

Example Input

Suppose $T = 23$ (°C) and $H = 60$ (%). Membership functions are defined as follows for a typical case:

  • For Temperature ($T$ in °C):

    • Low: peak at 16, zero at 20 and below 12
    • Medium: peak at 24, zero at 18 and 30
    • High: peak at 32, zero at 26 and above 36
  • For Humidity ($H$ in %):

    • Low: peak at 40, zero at 55 and below 25
    • Medium: peak at 60, zero at 45 and 75
    • High: peak at 80, zero at 65 and above 95

You can use triangular membership functions for each.

Code

Matlab:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
T_values = linspace(0, 30, 100); % Temperature range (°C)
H_values = linspace(0, 100, 100); % Humidity range (%)

[T_grid, H_grid] = meshgrid(T_values, H_values);
Y_out = zeros(size(T_grid));

for i = 1:numel(T_grid)
    T = T_grid(i);
    H = H_grid(i);

    % Membership functions (triangular)
    Low_T = max(min((20-T)/(20-16), 1), 0); 
    % Low T: 16 (peak), 12-20 (base)
    Med_T = max(min((T-18)/(24-18), (30-T)/(30-24)), 0); 
    % Medium T: 24 (peak), 18-30 (base)
    High_T = max(min((T-26)/(32-26), (36-T)/(36-32)), 0);
    % High T: 32 (peak), 26-36 (base)

    Low_H = max(min((55-H)/(55-40), 1), 0); 
    % Low H: 40 (peak)
    Med_H = max(min((H-45)/(60-45), (75-H)/(75-60)), 0); 
    % Medium H: 60 (peak)
    High_H = max(min((H-65)/(80-65), (95-H)/(95-80)), 0); 
    % High H: 80 (peak)

    % Firing Strengths
    w1 = Low_T * High_H;
    w2 = Med_T * Med_H;
    w3 = High_T * Low_H;

    sum_w = w1 + w2 + w3 + 1e-8; % Avoid division by zero

    % Normalization
    h1 = w1 / sum_w;
    h2 = w2 / sum_w;
    h3 = w3 / sum_w;

    y1 = 0.2;
    y2 = 0.5;
    y3 = 0.8;

    % Final output
    Y_out(i) = h1*y1 + h2*y2 + h3*y3;
end

figure;
surf(T_grid, H_grid, Y_out);
xlabel('Temperature (°C)');
ylabel('Humidity (%)');
zlabel('Valve Opening Degree');
title('T-S Fuzzy Inference: Valve Opening Surface vs Temperature and Humidity');
colorbar;
grid on;

Python:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import numpy as np
import matplotlib.pyplot as plt

def tri_mf(x, a, b, c):
    # Membership functions (triangular)
    if x <= a or x >= c:
        return 0.0
    elif a < x < b:
        return (x - a) / (b - a)
    elif b <= x < c:
        return (c - x) / (c - b)
    else:
        return 0.0

T_values = np.linspace(0, 30, 100)  # Temperature range (°C)
H_values = np.linspace(0, 100, 100) # Humidity range (%)

T_grid, H_grid = np.meshgrid(T_values, H_values)
Y_out = np.zeros(T_grid.shape)

for i in range(T_grid.shape[0]):
    for j in range(T_grid.shape[1]):
        T = T_grid[i, j]
        H = H_grid[i, j]

        Low_T = tri_mf(T, 12, 16, 20) 
        Med_T = tri_mf(T, 18, 24, 30)
        High_T = tri_mf(T, 26, 32, 36)

        Low_H = tri_mf(H, 40, 55, 70)
        Med_H = tri_mf(H, 45, 60, 75)
        High_H = tri_mf(H, 65, 80, 95)

        # Firing Strengths
        w1 = Low_T * High_H
        w2 = Med_T * Med_H
        w3 = High_T * Low_H

        sum_w = w1 + w2 + w3 + 1e-8 # Avoid division by zero

        # Normalization
        h1 = w1 / sum_w
        h2 = w2 / sum_w
        h3 = w3 / sum_w

        y1 = 0.2
        y2 = 0.5
        y3 = 0.8

        # Final output
        Y_out[i, j] = h1*y1 + h2*y2 + h3*y3

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
surf = ax.plot_surface(T_grid, H_grid, Y_out, cmap='viridis')
ax.set_xlabel('Temperature (°C)')
ax.set_ylabel('Humidity (%)')
ax.set_zlabel('Valve Opening Degree')
ax.set_title('T-S Fuzzy Inference: Valve Opening Surface vs Temperature and Humidity')
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()

Applications

The T-S fuzzy model is widely applied in various fields that demand robust, interpretable, and accurate modeling of nonlinear, multivariable systems. Typical application scenarios include industrial process control, intelligent vehicles, robotics, time series prediction, risk assessment, and medical or environmental systems. Its main advantage lies in the ability to effectively combine expert knowledge with data-driven modeling, providing smooth and reliable decision-making even in complex, uncertain environments.

Industrial Automatic Control

  • Temperature Control Systems (e.g., boilers, air conditioning):
    The T-S model is applied to adjust heating or cooling devices based on temperature, humidity, or other variables, ensuring stable and precise control.
  • Motor Speed Control:
    It is used to regulate the speed of electric motors under varying loads and reference speeds.
  • Chemical Process Control:
    T-S models handle nonlinear and coupled parameters in reactors or distillation columns, improving overall process stability and product quality.

Intelligent Transportation and Automotive

  • Vehicle Stability and Automatic Driving:
    The T-S model fuses information from speed, steering angle, and slip angle to control braking or steering, enhancing vehicle safety and stability.
  • Traffic Flow Prediction and Signal Optimization:
    It models complex urban intersections or traffic networks for better traffic light control and congestion management.

Robotics and Motion Control

  • Robotic Arm Trajectory Tracking:
    T-S models generate smooth and accurate control signals for multi-joint robot arms based on position and velocity errors.
  • Drone Attitude and Path Control:
    Used for nonlinear modeling and control of UAVs, improving flight stability and path accuracy.

Prediction and Diagnosis Systems

  • Time Series Forecasting:
    The T-S model is effective for forecasting complex, nonlinear time series such as stock prices, weather, or electrical loads.
  • Fault Diagnosis:
    It helps detect or predict equipment faults by analyzing signals like vibration, temperature, or current.

Finance and Economic Modeling

  • Risk Assessment and Credit Scoring:
    Various financial indicators are combined using the T-S model for credit rating or risk analysis.

Biomedical and Environmental Engineering

  • Drug Dosage Adjustment:
    Patient vital signs and drug concentrations are evaluated to provide personalized dosage recommendations.
  • Environmental Pollution Control:
    The T-S model optimizes emission control for multi-source pollutants.
This post is licensed under CC BY 4.0 by the author.