|
1 | | -# Genetic-Algorithm-using-Python-Example |
| 1 | +# Python Video Selection Optimizer: High-Performance Genetic Algorithm |
| 2 | + |
| 3 | +[](https://colab.research.google.com/github/adhishagc/Genetic-Algorithm-using-Python-Example/blob/master/Video_Playlist_Optimizer_GA.ipynb) |
| 4 | + |
| 5 | +An advanced optimization tool designed to solve the **Constrained Video Selection Problem** using **Genetic Algorithms (GA)**. This project demonstrates how to maximize total playback duration within a fixed storage capacity (e.g., fitting the best playlist on a 4.5GB drive). |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +This repository implements a robust Genetic Algorithm in Python to optimize multi-variable selection problems. Specifically, it tackles a variation of the **0/1 Knapsack Problem** where the goal is to maximize the "value" (video duration) while staying under a "weight" limit (file size). |
| 10 | + |
| 11 | +### Key Optimization Features: |
| 12 | +- **Selection Methods**: Rank Selection, Roulette Wheel, and Tournament Selection. |
| 13 | +- **Crossover Operators**: Generalized N-Point Crossover and Uniform Crossover. |
| 14 | +- **Mutation**: Adaptive Bit-Flip Mutation. |
| 15 | +- **Survival Policy**: Elitism with FIFO replacement to ensure the best solutions are never lost. |
| 16 | + |
| 17 | +## Performance Results |
| 18 | + |
| 19 | +The algorithm was tested on a sample dataset of 10 high-definition video files with a storage constraint of **4500 MB**. |
| 20 | + |
| 21 | +| Metric | Result | |
| 22 | +|--------|--------| |
| 23 | +| **Total Optimized Duration** | **549 Minutes** | |
| 24 | +| **Storage Capacity Used** | **3950 / 4500 MB** | |
| 25 | +| **Algorithm Generations** | 100 | |
| 26 | +| **Population Size** | 50 | |
| 27 | + |
| 28 | +The results show a highly efficient selection that utilizes ~88% of the available storage while maximizing entertainment value, significantly outperforming random selection methods. |
| 29 | + |
| 30 | +### Convergence and Optimization Plots |
| 31 | + |
| 32 | +The following plots illustrate the algorithm's performance during the optimization process: |
| 33 | + |
| 34 | +#### 1. Fitness Convergence |
| 35 | +This plot shows how the fitness of the population improves over generations, indicating successful convergence towards an optimal solution. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +#### 2. Duration Optimization |
| 40 | +The total playback duration is maximized over time, reaching a peak of 549 minutes. |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +#### 3. Storage Size Constraints |
| 45 | +The algorithm ensures that the selected videos stay within the 4500 MB limit (indicated by the orange threshold line). |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +## Installation and Usage |
| 50 | + |
| 51 | +### Prerequisites |
| 52 | +Ensure you have Python 3.x installed along with the following libraries: |
| 53 | +```bash |
| 54 | +pip install pandas numpy matplotlib |
| 55 | +``` |
| 56 | + |
| 57 | +### Running the Optimizer |
| 58 | +1. Clone this repository: |
| 59 | + ```bash |
| 60 | + git clone https://github.com/adhishagc/Genetic-Algorithm-using-Python-Example.git |
| 61 | + ``` |
| 62 | +2. Navigate to the directory: |
| 63 | + ```bash |
| 64 | + cd Genetic-Algorithm-using-Python-Example |
| 65 | + ``` |
| 66 | +3. Open the Jupyter Notebook: |
| 67 | + ```bash |
| 68 | + jupyter notebook Video_Playlist_Optimizer_GA.ipynb |
| 69 | + ``` |
| 70 | + |
| 71 | +## Project Structure |
| 72 | +- `Video_Playlist_Optimizer_GA.ipynb`: The main algorithm implementation and analysis. |
| 73 | +- `dataset.csv`: Metadata for the video files (Size and Duration). |
| 74 | +- `results/`: Directory containing performance and convergence plots. |
| 75 | +- `README.md`: Project documentation and SEO overview. |
| 76 | + |
| 77 | +## About the Subject Matter |
| 78 | +Genetic Algorithms are search heuristics inspired by Charles Darwin’s theory of natural evolution. They are widely used in data science, logistics, and AI to find near-optimal solutions to complex optimization problems that are computationally expensive for traditional algorithms. |
| 79 | + |
| 80 | +--- |
| 81 | +*Optimized for High SEO and Research Usage.* |
0 commit comments