Skip to content

eleanazeri/Computational-Intelligence

Repository files navigation

Computational Intelligence

Institution: Aristotle University of Thessaloniki — Department of Electrical and Computer Engineering
Course: Computational Intelligence (2024–2025)
Author: Eleana Zeri — AEM: 10811


Overview

This repository documents the implementation of Fuzzy Logic controllers (Mamdani/Larsen type) applied to closed-loop control problems, and Takagi-Sugeno-Kang (TSK) fuzzy inference systems applied to supervised learning tasks. The work spans four projects covering DC motor control, autonomous vehicle navigation, regression on benchmark datasets, and binary/multi-class classification. All implementations are carried out in MATLAB, with Simulink used where continuous-time system modeling is required.


Project 1 — Fuzzy Control of a DC Motor

Overview

A Fuzzy Logic PI (FZ-PI) controller is designed to regulate the angular velocity of a DC motor. The controller is evaluated across three distinct operating scenarios — step response, trajectory tracking, and external disturbance rejection — to assess steady-state accuracy, transient performance, and robustness. The Mamdani inference scheme is employed, with rule bases and membership functions defined using domain knowledge.

Workflow

  1. Model the DC motor plant in Simulink as a continuous-time transfer function.
  2. Define the FIS structure (inputs, outputs, membership functions) using the Fuzzy Logic Toolbox.
  3. Encode the linguistic rule base in the .fis file reflecting PI control logic (error and change-in-error as inputs).
  4. Integrate the FIS block into each Simulink scenario model.
  5. Simulate all three scenarios and log system response (velocity vs. time).
  6. Evaluate performance using metrics: rise time, settling time, steady-state error, and disturbance rejection amplitude.

Libraries and Tech Stack

  • MATLAB: Scripting environment used to orchestrate simulation runs, load .fis files, and post-process logged signal data.
  • Simulink: Used for modeling the continuous-time dynamics of the DC motor and constructing the closed-loop control block diagram for all three scenarios.
  • Fuzzy Logic Toolbox: Used to define, store, and load the Mamdani FIS (dc_motor_flc.fis), and to embed the fuzzy inference block within the Simulink feedback loop.

Code Files

File Description
simulate_dc_motor_control.m Main script; loads the FIS, runs all three Simulink scenarios, and plots response metrics.
dc_motor_flc.fis Mamdani FIS definition file encoding membership functions and the linguistic rule base.
scenario_1_step_response.slx Simulink model for evaluating step reference tracking.
scenario_2_trajectory_tracking.slx Simulink model for evaluating reference trajectory following.
scenario_3_disturbance_rejection.slx Simulink model for evaluating rejection of external load disturbances.
report_fuzzy_control_dc_motor.pdf Technical report documenting design choices, simulation results, and analysis.

Project 2 — Fuzzy Control for Car Navigation

Overview

A Mamdani-type Fuzzy Logic Controller is designed to enable autonomous obstacle avoidance for a simulated vehicle. Sensor distance readings (front, left, right) serve as controller inputs, and the steering angle is the output. Two controller variants are compared: an untuned baseline and a manually tuned version, with performance evaluated against the same navigation scenarios.

Workflow

  1. Define the simulation environment and sensor geometry for distance measurement.
  2. Implement the sensor distance calculation logic to map obstacle proximity to scalar inputs.
  3. Design the untuned FIS: define input/output universe of discourse, membership functions, and rule base.
  4. Refine the tuned FIS by adjusting membership function parameters and rule weights based on observed navigation failures.
  5. Simulate both controllers across standard obstacle course scenarios.
  6. Compare navigation success rate, minimum clearance distance, and trajectory smoothness between the two variants.

Libraries and Tech Stack

  • MATLAB: Used for running the simulation loop, calling the sensor geometry calculations, invoking evalfis for control output, and generating trajectory plots.
  • Fuzzy Logic Toolbox: Used to define and evaluate both the untuned (car_controller_untuned.fis) and tuned (car_controller_tuned.fis) Mamdani FIS objects, and to inspect membership function distributions during manual tuning.

Code Files

File Description
simulate_obstacle_avoidance.m Main simulation script; runs the vehicle navigation loop using both FIS variants and plots trajectories.
calculate_sensor_distances.m Computes front, left, and right sensor distances from the vehicle's current position and heading.
car_controller_untuned.fis Baseline Mamdani FIS prior to parameter tuning.
car_controller_tuned.fis Refined Mamdani FIS after manual membership function and rule weight adjustment.
report_fuzzy_control_car_navigation.pdf Technical report covering FIS design, tuning rationale, and comparative evaluation.

Project 3 — TSK Fuzzy Regression

Overview

Takagi-Sugeno-Kang (TSK) fuzzy models are trained to predict continuous target variables on two benchmark datasets: the UCI Airfoil Self-Noise dataset and the Superconductivity dataset. The study compares model structures generated via grid partitioning and subtractive clustering, and evaluates generalization performance using k-fold cross-validation. Metrics reported include RMSE and the coefficient of determination $R^2$.

Workflow

  1. Load and inspect raw dataset; identify input features and target variable.
  2. Preprocess data: apply stratified train/test splitting and z-score normalization via preprocess_split_scale.m.
  3. Generate candidate FIS structures using grid partitioning (varying MF count) and subtractive clustering (varying cluster radius).
  4. Train each TSK model using ANFIS on the training partition.
  5. Evaluate each trained model on the held-out test set; compute RMSE and $R^2$.
  6. Perform k-fold cross-validation on the best-performing configuration to obtain a robust generalization estimate.

Libraries and Tech Stack

  • MATLAB: Used for data loading, calling preprocessing routines, orchestrating ANFIS training loops across model configurations, and aggregating cross-validation results.
  • Fuzzy Logic Toolbox: Used to generate initial FIS structures via genfis1 (grid partitioning) and genfis2 (subtractive clustering), and to train TSK models using anfis.
  • Statistics and Machine Learning Toolbox: Used for k-fold cross-validation partitioning (cvpartition) and to apply zscore normalization to input features.

Code Files

File Description
tsk_regression_airfoil.m TSK regression pipeline applied to the UCI Airfoil Self-Noise dataset.
tsk_regression_superconduct.m TSK regression pipeline applied to the Superconductivity dataset.
preprocess_split_scale.m Shared utility for stratified train/test splitting and z-score feature normalization.
airfoil_self_noise.dat Airfoil Self-Noise dataset (UCI repository).
superconduct.csv Superconductivity dataset (UCI repository).
report_tsk_regression.pdf Technical report detailing model selection, cross-validation methodology, and results.

Project 4 — TSK Fuzzy Classification

Overview

TSK fuzzy models are applied to binary and multi-class classification tasks using Haberman's Survival dataset and the Epileptic Seizure Recognition dataset. The FIS structure is generated via subtractive clustering applied independently per class (class-dependent partitioning), which produces a rule base that reflects the geometric distribution of each class in the feature space. Model performance is assessed using classification accuracy and confusion matrices.

Workflow

  1. Load dataset and perform exploratory class distribution analysis.
  2. Preprocess data using preprocess_split_scale.m: stratified splitting to preserve class ratios, followed by feature normalization.
  3. Apply subtractive clustering separately on each class subset to generate class-dependent cluster centers.
  4. Construct the TSK FIS with one rule per cluster, using linear consequents.
  5. Train the combined FIS using ANFIS and evaluate on the test partition.
  6. Report per-class precision, recall, overall accuracy, and the confusion matrix.

Libraries and Tech Stack

  • MATLAB: Core scripting environment for data manipulation, class-wise clustering, ANFIS training invocation, and performance metric computation.
  • Fuzzy Logic Toolbox: Used to generate class-dependent FIS structures via subclust, to assemble the combined rule base, and to train the TSK classifier using anfis.

Code Files

File Description
tsk_classification_haberman.m TSK classification pipeline applied to Haberman's Survival dataset.
tsk_classification_epileptic.m TSK classification pipeline applied to the Epileptic Seizure Recognition dataset.
preprocess_split_scale.m Shared utility for stratified splitting and feature normalization.
haberman.data Haberman's Survival dataset (UCI repository).
epileptic_seizure_data.csv Epileptic Seizure Recognition dataset (UCI repository).
report_tsk_classification.pdf Technical report covering FIS design, class-dependent clustering, and evaluation results.

How to Run

1. Clone the repository:

git clone https://github.com/eleanazeri/Computational-Intelligence.git
cd Computational-Intelligence

2. Navigate to the desired project directory in MATLAB:

cd('01-Fuzzy-Control-DC-Motor')

3. Run the main script:

run('simulate_dc_motor_control.m')

4. To open a Simulink model directly:

open('scenario_1_step_response.slx')

All scripts are self-contained. Dataset files are included in the respective project directories and are referenced via relative paths. No additional configuration is required beyond a standard MATLAB installation with the Fuzzy Logic Toolbox and the Statistics and Machine Learning Toolbox.

Project Directory Entry Point
Fuzzy Control — DC Motor 01-Fuzzy-Control-DC-Motor/ simulate_dc_motor_control.m
Fuzzy Control — Car Navigation 02-Fuzzy-Control-Car-Navigation/ simulate_obstacle_avoidance.m
TSK Regression 03-TSK-Regression/ tsk_regression_airfoil.m, tsk_regression_superconduct.m
TSK Classification 04-TSK-Classification/ tsk_classification_haberman.m, tsk_classification_epileptic.m

License

This repository constitutes academic coursework submitted for the Computational Intelligence course, Department of Electrical and Computer Engineering, Aristotle University of Thessaloniki. All rights are reserved by the author. This work is not intended for redistribution, reuse, or commercial application.

About

Fuzzy Logic controllers (Mamdani/Larsen) and TSK fuzzy models for regression and classification. ECE AUTH Computational Intelligence coursework.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages