{"id":22059663,"url":"https://github.com/amin-mashayekhan/rsd-algorithm-in-python-and-php","last_synced_at":"2025-10-11T14:31:19.896Z","repository":{"id":136435089,"uuid":"422947059","full_name":"Amin-Mashayekhan/RSD-Algorithm-in-Python-and-PHP","owner":"Amin-Mashayekhan","description":"Simulate the RSD (Random Serial Dictatorships) algorithm.","archived":false,"fork":false,"pushed_at":"2023-04-01T12:35:53.000Z","size":208,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-30T17:38:08.866Z","etag":null,"topics":["algorithm","economics","economics-models","market-design","mechanism","mechanism-design","php","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Amin-Mashayekhan.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-30T17:25:52.000Z","updated_at":"2024-09-27T06:22:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"b6e3f49f-f8cb-4699-933a-78ed97a35a7f","html_url":"https://github.com/Amin-Mashayekhan/RSD-Algorithm-in-Python-and-PHP","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amin-Mashayekhan%2FRSD-Algorithm-in-Python-and-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amin-Mashayekhan%2FRSD-Algorithm-in-Python-and-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amin-Mashayekhan%2FRSD-Algorithm-in-Python-and-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amin-Mashayekhan%2FRSD-Algorithm-in-Python-and-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Amin-Mashayekhan","download_url":"https://codeload.github.com/Amin-Mashayekhan/RSD-Algorithm-in-Python-and-PHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236102626,"owners_count":19095206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","economics","economics-models","market-design","mechanism","mechanism-design","php","python"],"created_at":"2024-11-30T17:30:29.777Z","updated_at":"2025-10-11T14:31:19.891Z","avatar_url":"https://github.com/Amin-Mashayekhan.png","language":"Python","readme":"## 🧮 Random Serial Dictatorship (RSD) Algorithm\n\nWelcome! This repository implements the **Random Serial Dictatorship (RSD)** algorithm for resource allocation problems.\n\n### Applications\n\nThe Random Serial Dictatorship (RSD) algorithm has various scientific and practical applications, including:\n\n- **Assigning dormitories:** Used for assigning dormitories to students in universities.\n- **School choice systems:** Applied in school choice systems to allocate students to schools.\n- **Economics:** Utilized in economic models for allocating limited resources fairly.\n\nThis algorithm’s simplicity and fairness make it a valuable tool in resource allocation problems.\n\n### 📌 About the Project\n\nThis project contains **two versions** of the RSD algorithm:\n\n* **Python version**\n* **PHP version**\n\nYou can specify the input data at the top of each code file using the `agents` variable. This variable maps each agent (by index) to their **ranked preferences** of goods or services.\n\n### ✅ Input Format\n\n* The number of agents must be **greater than 1**.\n* Each agent’s preferences must:\n\n  * Include **non-duplicate items**\n  * Be equal in length to the number of agents\n\n**Example input definition** (as comments at the top of the file):\n\n```python\n# agents = {\n#   0: [2, 1, 0],\n#   1: [0, 2, 1],\n#   2: [1, 0, 2]\n# }\n```\n\n### 📤 Output Format\n\nThe output of the algorithm is:\n\n* In **Python**: a dictionary → `agent_index =\u003e allocation_probability`\n* In **PHP**: an associative array → `agent_index =\u003e allocation_probability`\n\n### 💡 IDE Recommendation\n\nWe recommend using **Visual Studio Code** with the **Code Runner** extension:\n\n* Easy variable editing\n* Quick output view\n\n### 🎨 Visualization of RSD\n\nBelow is a illustration about the RSD algorithm working. Four agents select their preferred houses in a randomly assigned order, with arrows indicating allocations, showing each agent’s choice from the available options in a non-reversible process.:\n\n\u003cimg src=\"ReadmeImage.jpg\" alt=\"Cartoon visualization of RSD algorithm\" width=\"600\"\u003e\n\n### 🧪 Input \u0026 Output Sample\n\nPython Version: \u003cimg src=\"Python-input-\u0026-output-sample.jpg\" width=\"350\" height=\"560\" alt=\"Python sample input-output\"\u003e\n\nPHP Version: \u003cimg src=\"PHP-input-\u0026-output-sample.JPG\" width=\"350\" height=\"560\" alt=\"PHP sample input-output\"\u003e\n\n### 👨‍💻 Credits\n\nThis project was created and developed by **Mohammad Amin Mashayekhan**.\nGuidance and assistance resources:\n\n* Assistant Professor **Mehdi Feizi**\n* [Stack Overflow](https://stackoverflow.com)\n* [php2python.com](https://www.php2python.com)\n* And other online resources\n\n### 📬 Contact\n\nIf you have any questions, feedback, or would like to discuss this project further, feel free to get in touch:\n\n- 📧 Email: [amin.mashayekhan@gmail.com](mailto:amin.mashayekhan@gmail.com)\n- 📅 Schedule a quick tech call: [Book a 15-minute meeting](https://calendly.com/amin-mashayekhan/15min-tech-call)\n\n---\n\nThank you for visiting this repository!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famin-mashayekhan%2Frsd-algorithm-in-python-and-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famin-mashayekhan%2Frsd-algorithm-in-python-and-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famin-mashayekhan%2Frsd-algorithm-in-python-and-php/lists"}