Add School Enrollment model#301
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #301 +/- ##
==========================================
+ Coverage 91.20% 92.10% +0.90%
==========================================
Files 19 19
Lines 1592 1698 +106
==========================================
+ Hits 1452 1564 +112
+ Misses 140 134 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 146b545f10
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if len(applicants) <= self.capacity: | ||
| return applicants |
There was a problem hiding this comment.
Enforce remaining capacity when selecting students
matching() runs in multiple rounds and appends newly accepted students to school.students each round, but select_students() always compares only len(applicants) against the full self.capacity. If a school fills in an early round and later receives applicants rejected elsewhere, this method can still admit more students, violating the school capacity constraint and distorting enrollment outcomes.
Useful? React with 👍 / 👎.
| for student in self.students: | ||
| if student.state == StudentState.APPLIED: | ||
| student.state = StudentState.ENROLLED | ||
| student.refresh_internal_state() |
There was a problem hiding this comment.
Keep unplaced applicants out of ENROLLED state
At the end of matching, every student still in APPLIED is force-converted to ENROLLED even when current_school is None (for example, when choose_school() returns None because their choice set is exhausted). This creates an inconsistent state where students are counted as enrolled and continue progressing academically without any school assignment, which corrupts model metrics and dynamics.
Useful? React with 👍 / 👎.
|
Hey @niteshver, this looks interesting but would love to see some of your own tests for the model. They make it easier to understand the logic. |
|
Hi @IlamaranMagesh , thanks for the feedback! That makes sense — I’ll add some tests to better demonstrate the model logic. |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
Hi @IlamaranMagesh |

Overview
This PR introduces a School Enrollment Agent-Based Model (ABM) that simulates interactions between students and schools in a competitive education system.
The model captures how decentralized student decisions and school constraints lead to emergent enrollment patterns over time.
Key Features
Student agents with:
School agents with:
Probabilistic school selection using a softmax-based utility function
Iterative matching process:
Motivation
This model aims to explore how:
interact to produce system-level outcomes such as: