center-randomize
center-randomize copied to clipboard
[TODO] avoid allotting small number of students last center
School A has 207 students. Current script will
- allot first 100 students to Center A
- allot next 100 to center B
- remaining 7 to center C
It is undesirable to separate just 7 students. They are reassigned to either Center A or B during manual inspection. Automate this step.
Also refrain from distributing those 7 students among center A and B ie Center A - 107 Center B - 100 is preferred over center A - 103, center B - 104 as it results in cleaner symbol number distribution
may chose to use existing MIN_STUDENTS_IN_CENTER parameter
The main change is in the block that reassigns the remaining students to Center A or Center B. Instead of iterating over the centers list and checking for the center codes 'A' and 'B', modified the code to directly check if the center codes 'A' and 'B' exist in the centers_remaining_cap dictionary and if they have enough remaining capacity.
Here's how the updated code works:
The for loop iterates over the center codes 'A' and 'B'. For each center code, it checks if the code exists in the centers_remaining_cap dictionary, and if the remaining capacity for that center is greater than or equal to MIN_STUDENT_IN_CENTER. If both conditions are met, it allocates the remaining students (to_allot) to that center using the allocate function. It updates the centers_remaining_cap for the allocated center by subtracting the allocated students. It sets to_allot to 0 and breaks out of the loop since all remaining students have been allocated. This approach directly checks for the existence of Center A and Center B in the centers_remaining_cap dictionary, which should be more efficient than iterating over the centers list and checking the center codes.
Note: This code assumes that the center codes 'A' and 'B' exist in the centers_remaining_cap dictionary. If you want to handle the case where these center codes are not present, you'll need to add additional checks or modify the code accordingly.
I would be really excited to work on this issue. Can you please assign it to me. 🙂
I would be really excited to work on this issue. Can you please assign it to me. 🙂
@ashiishme please feel free to submit a pull request. looking for multiple solutions, so not assigning to a single individual.
I have the PR opened but it hasn't been reviewed yet.