My Roomify is an interactive web application that implements the Top Trading Cycle (TTC) algorithm to optimize room allocations based on user preferences. Initially designed to address the challenges of hostel room swaps at SVNIT, this project has evolved into a powerful tool for solving similar allocation problems efficiently.
Try it out here: My Roomify
- Input the number of rooms/participants.
- Specify initial room allocations and members' preference lists.
- Use TTC to compute optimal reallocations.
- Visualize intermediate envy-graphs and cycles.
- See before-and-after improvements in room assignments.
The TTC algorithm solves the problem of matching participants to their preferred rooms by:
- Collecting participants' preferences and initial allocations.
- Iteratively removing cycles in envy-graphs to reallocate rooms.
- Producing a Pareto optimal, truthful, and core-selected solution.
- Truthfulness: Participants have no incentive to lie about their preferences.
- Pareto Optimality: Ensures that no reallocation can make one participant better off without making another worse off.
- Participation: Guarantees participants receive at least as good an outcome as opting out.
- Core Selection: Ensures no subset of participants can create a better reallocation among themselves.
My Roomify features interactive envy-graphs that allow users to:
- View envy relationships at each step.
- Hover over nodes to inspect details.
- Understand how cycles are eliminated and rooms are reassigned.
Beyond hostel room allocation, this project can be applied to:
- Course registrations.
- Resource assignments in organizations.
- Any scenario with n participants and n items, each with preferences.
- Frontend: Next.js, React, D3.js for interactive graphs.
- Backend: Flask for API and TTC algorithm implementation.
- TTC algorithm learnt during the ACM Summer School on Algorithmic Game Theory at IMSc.
- Featured in IMSc's Outreach Newsletter: Read here.
- Credits to Kahaan and Tanvi for the website logo.
This is a hybrid Next.js + Python app that uses Next.js as the frontend and Flask as the API backend. One great use case of this is to write Next.js apps that use Python AI libraries on the backend.
First, install the dependencies:
npm install
# or
yarn
# or
pnpm install
Then, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
Open http://localhost:3000 with your browser to see the result.
Run the backend flask server with
python api/index.py
The Flask server will be running on http://127.0.0.1:5328 – feel free to change the port in package.json
(you'll also need to update it in next.config.js
).
Contributions, issues, and feature requests are welcome!
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -m "Added feature XYZ"
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
If you have any ideas or suggestions, feel free to:
- Leave a comment.
- Open a GitHub issue.
Thank you for checking out My Roomify! Let’s make room allocations efficient and fair for everyone! 😊