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)
- Python 3.x
- pip (Python package installer)
-
Place the project files (
flc_washing_machine.py,ga_travelling_salesman.py) in a new folder. -
Open a terminal or command prompt in that folder.
-
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- Install required libraries:
pip install numpy matplotlib scikit-fuzzy scipyRun the script:
python flc_washing_machine.pyYou 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
Run the script:
python ga_travelling_salesman.pyYou 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)