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).
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).
- Selection Methods: Rank Selection, Roulette Wheel, and Tournament Selection.
- Crossover Operators: Generalized N-Point Crossover and Uniform Crossover.
- Mutation: Adaptive Bit-Flip Mutation.
- Survival Policy: Elitism with FIFO replacement to ensure the best solutions are never lost.
The algorithm was tested on a sample dataset of 10 high-definition video files with a storage constraint of 4500 MB.
| Metric | Result |
|---|---|
| Total Optimized Duration | 549 Minutes |
| Storage Capacity Used | 3950 / 4500 MB |
| Algorithm Generations | 100 |
| Population Size | 50 |
The results show a highly efficient selection that utilizes ~88% of the available storage while maximizing entertainment value, significantly outperforming random selection methods.
The following plots illustrate the algorithm's performance during the optimization process:
This plot shows how the fitness of the population improves over generations, indicating successful convergence towards an optimal solution.
The total playback duration is maximized over time, reaching a peak of 549 minutes.
The algorithm ensures that the selected videos stay within the 4500 MB limit (indicated by the orange threshold line).
Ensure you have Python 3.x installed along with the following libraries:
pip install pandas numpy matplotlib- Clone this repository:
git clone https://github.com/adhishagc/Genetic-Algorithm-using-Python-Example.git
- Navigate to the directory:
cd Genetic-Algorithm-using-Python-Example - Open the Jupyter Notebook:
jupyter notebook Video_Playlist_Optimizer_GA.ipynb
Video_Playlist_Optimizer_GA.ipynb: The main algorithm implementation and analysis.dataset.csv: Metadata for the video files (Size and Duration).results/: Directory containing performance and convergence plots.README.md: Project documentation and SEO overview.
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.
Optimized for High SEO and Research Usage.


