Skip to content

A repository simulating popular concepts in Soft Computing. Fuzzy Logic Controller: A Mamdani FLC (using scikit-fuzzy) to determine washing machine wash time based on dirt and grease inputs. Genetic Algorithm: A GA that solves the 16-city TSP from a user-input distance matrix, using elitism and roulette-wheel selection.

Notifications You must be signed in to change notification settings

sh4shv4t/FLC-and-GA-implementation

Repository files navigation

Soft Computing Project (FLC & GA)

This repository contains Python implementations for a Soft Computing project.
It includes two main programs:

  • Problem 1: flc_washing_machine.py — Fuzzy Logic Controller (FLC) for determining washing machine wash time
  • Problem 2: ga_travelling_salesman.py — Genetic Algorithm (GA) to solve a 16-city Travelling Salesman Problem (TSP)

Getting Started

1. Prerequisites

  • Python 3.x
  • pip (Python package installer)

2. Setup

  1. Place the project files (flc_washing_machine.py, ga_travelling_salesman.py) in a new folder.

  2. Open a terminal or command prompt in that folder.

  3. Create and activate a virtual environment (recommended):

# Create the environment
python -m venv venv

# Activate on Windows (PowerShell)
.\venv\Scripts\Activate.ps1

# Activate on Windows (Command Prompt)
.\venv\Scripts\activate.bat

# Activate on macOS/Linux
source venv/bin/activate
  1. Install required libraries:
pip install numpy matplotlib scikit-fuzzy scipy

How to Run

Problem 1: Fuzzy Logic Controller (Washing Machine)

Run the script:

python flc_washing_machine.py

You will be prompted to enter:

  • Dirt level (0–100)
  • Grease level (0–50)

The program will then:

  • Output the calculated wash time
  • Display graphs of membership functions and the defuzzification result

Problem 2: Genetic Algorithm (Travelling Salesman Problem)

Run the script:

python ga_travelling_salesman.py

You must input your 16 × 16 distance matrix, one row at a time.
Each row must contain 16 space-separated numbers.

After all 16 rows are entered:

  • The GA runs for 20 iterations
  • Prints the best distance found at each iteration
  • Outputs:
    • The best path (tour)
    • The total distance
  • Displays a convergence graph (distance decreasing over iterations)

About

A repository simulating popular concepts in Soft Computing. Fuzzy Logic Controller: A Mamdani FLC (using scikit-fuzzy) to determine washing machine wash time based on dirt and grease inputs. Genetic Algorithm: A GA that solves the 16-city TSP from a user-input distance matrix, using elitism and roulette-wheel selection.

Resources

Stars

Watchers

Forks

Languages