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/.