Griaß eich! 🐄 This solution to the GenDev Challenge 2024 employs ✨Mixed Integer Programming.✨
Demo: https://streaming-package-comperator.vercel.app/
(Note: This is hosted on a free tier. The first query may take up to one minute because the backend is automatically deactivated when idle.)
At the core of this application lies a mathematical model known as a Mixed Integer Program (MIP), which determines the optimal combination of streaming packages to minimize the cost of watching a given set of games. 📊
This mathematical model is solved using the PuLP solver in Python. 🐍
📽️ Watch this video where I showcase the application and delve deeper into the implementation and future improvements.
📚 For those who want to dive deeper into the mathematical details, see the explanation_for_nerds.ipynb file, which provides a detailed explanation of the underlying math.
Frontend 🖥️:
- 📋 Implement a table view where users can select specific games.
- 🏆 Add a tournament selection feature.
- 💰 Create a 'set maximum cost' option: Remove the worst deals iteratively until
total_cost < maximum_cost.
Backend 🛠️:
- 📂 Currently, each query accesses the CSV files as provided in the problem statement. Accessing the data through a merged CSV file or a database could significantly improve speed.
- 🔄 The backend processes the dataframe in multiple loops. Consolidating operations into fewer loops could enhance performance.
- ✂️ The pruning logic (removal of the worst deals) is currently implemented on the frontend. Moving this to the backend could further optimize performance.
- ⏰ Lower time granularity for large queries. Adjusting the timedelta to one week or month instead of daily intervals could dramatically reduce computational complexity.
- ⚡ Use a more advanced solver like Gurobi or CPLEX for faster and more efficient performance, especially for larger queries or more complex constraints.
Theory/Math 📐:
- ❓ After pruning, there is no guarantee that the model remains optimal. Implementing methods from Sensitivity Analysis could help verify if re-solving is necessary.
- 📦 There are alternative ways to model this use case and related scenarios. For example, if users set a maximum monthly or yearly budget, it could be modeled as a Cutting Stock Problem.
-
Ensure Python and pip are installed 🐍.
-
Install the required dependencies:
cd backend pip install -r requirements.txt -
Run the Flask application 🚀:
python app.py
The backend should now be running on http://127.0.0.1:5000.
-
Ensure Node.js and npm are installed 🌳.
-
Rename
example.envto.env:-
Linux/macOS 🐧:
cd frontend mv example.env .env -
Windows 🪟:
cd frontend ren example.env .env
-
-
Install the required dependencies:
npm i
-
Start the development server 🔥:
npm run dev
The frontend should now be running on http://localhost:5173/.