Skip to content

Commit 143490f

Browse files
Refactored Codes (#47)
* 🚀 [Update] Refactored Codes * 🚀 [Update] Indentation * 📖 [Update] README.md * resolve conflicts. correct some comments --------- Co-authored-by: sumanashrestha <[email protected]>
1 parent 9b3883f commit 143490f

File tree

2 files changed

+226
-133
lines changed

2 files changed

+226
-133
lines changed

README.md

Lines changed: 70 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Exam Center Randomization script
2-
The goal of this script is to assign exam centers to students.
1+
# Exam Center Randomization Script
2+
The goal of this script is to assign __exam centers__ to students.
33

44
## Steps
5-
1. Prepare input files in specified format
5+
1. Prepare input files in specified format.
66
2. Run program and re run if -
77
* Any school has students that have not been assigned a center.
8-
* Distribution across centers is uneven
9-
3. Perform sanity check of distributed centers
8+
* Distribution across centers is uneven.
9+
3. Perform sanity check of distributed centers.
1010
4. Manually reassign impractical centers and odd lot allocations. Keep changes to minimum.
1111

1212
## Allocation Guidelines
@@ -16,62 +16,76 @@ The goal of this script is to assign exam centers to students.
1616
- विद्यालयबाट नजिक पर्ने केन्द्रलाई प्राथमिकता दिनुपर्ने
1717
- एक विद्यालयको परिक्षार्थी संख्या हेरी सकभर १००, २०० भन्दा बढी परीक्षार्थी एकै केन्द्रमा नपर्ने गरी बाँढ्न पर्ने
1818
- आफ्नै विद्यालयमा केन्द्र पार्न नहुने
19-
- दुई विद्यालयका परीक्षार्थीको केन्द्र एक अर्कामा पर्न नहुने, अर्थात् कुनै विद्यालयका परीक्षार्थीको केन्द्र परेको विद्यालयका परीक्षार्थीहरूको केन्द्र अघिल्लो विद्यालयमा पार्न नहुने
20-
- एकै स्वामित्व / व्यवस्थापनको भनी पहिचान भएका केन्द्रमा पार्न नहुने
21-
- विगतमा कुनै विद्यालयको कुनै केन्द्रमा पार्दा समस्या देखिएकोमा केन्द्र दोहोऱ्याउन नहुने
22-
- प्रत्येक पटक केन्द्र तोक्ने प्रोग्राम चलाउदा फरक फरक नतिजा आउने गरी ऱ्यान्डमाइज भएको हुनु पर्ने
19+
- दुई विद्यालयका परीक्षार्थीको केन्द्र एक अर्कामा पर्न नहुने, अर्थात् कुनै विद्यालयका परीक्षार्थीको केन्द्र परेको विद्यालयका परीक्षार्थीहरूको केन्द्र अघिल्लो विद्यालयमा पार्न नहुने
20+
- एकै स्वामित्व / व्यवस्थापनको भनी पहिचान भएका केन्द्रमा पार्न नहुने
21+
- विगतमा कुनै विद्यालयको कुनै केन्द्रमा पार्दा समस्या देखिएकोमा केन्द्र दोहोऱ्याउन नहुने
22+
- प्रत्येक पटक केन्द्र तोक्ने प्रोग्राम चलाउदा फरक फरक नतिजा आउने गरी ऱ्यान्डमाइज भएको हुनु पर्ने
2323

2424
## Parameters
2525

26-
PREF_DISTANCE_THRESHOLD = 2 # Preferred threshold distance in kilometers, centers should be within this distance from school if possible
27-
28-
ABS_DISTANCE_THRESHOLD = 7 # Absolute threshold distance in kilometers
29-
30-
MIN_STUDENT_IN_CENTER = 10 # minimum number of students from a school to be assigned to a center under normal circumstances
31-
32-
STRETCH_CAPACITY_FACTOR = 0.02 # how much can center capacity be stretched if need arises
33-
34-
PREF_CUTOFF = -4 # Do not allocate students with pref score less than cutoff
35-
36-
37-
## Input files
38-
Files should be tab delimited
39-
40-
### school.tsv
41-
One entry per school.
42-
43-
scode count name-address lat long
44-
27101 1776 काठमाण्डौ मोडेल मा.वि., वागवजार 27.7067463495 85.3188922809
45-
27007 1700 ट्रिनीटी इन्टरनेशनल मा.वि., डिल्लीबजार 27.7038931952 85.3251961353
46-
27045 1278 साउथ वेस्टर्न स्टेट मा.वि., बसुन्धारा 27.7396600173 85.3254532539
47-
27127 1210 क्यापिटल मा.वि., कोटेश्वर 27.673541693 85.3449013829
48-
49-
### centers.tsv
50-
One entry per center. cscode should match scode
51-
52-
cscode capacity name address नाम ठेगाना lat long
53-
27003 500 NATIONAL SCHOOL OF SCIENCES SECONDARY SCHOOL LAINCHAUR नेशनल स्कुल अफ साइन्सेस मा.वि लैनचौर 27.71933026 85.31413793
54-
27051 500 UNIGLOBE MA VI KAMALADI युनिग्लोब मा.वि कमलादी 27.70792875 85.32068522
55-
27045 568 SOUTH WESTERN ACADEMY SECONDARY SCHOOL BASUNDHARA साउथ वेर्ष्टन एकेडेमी मा.वि. बसुन्धरा 27.74212647 85.33392421
56-
57-
### prefs.tsv
58-
Prioritize or deprioritize school and center pair. -ve pref score depriotizes. if pref score is less than `PREF_CUTOFF` center will be excluded from consideration
59-
60-
scode cscode pref reason
61-
27xxx 27yyy -5 same management
62-
27yyy 27xxx -5 same management
63-
27aaa 27bbb -1 last year's center
64-
26+
| Variable | Value | Description |
27+
|--------------------------|-------|---------------------------------------------|
28+
| `PREF_DISTANCE_THRESHOLD` | 2 | Preferred threshold distance in km |
29+
| `ABS_DISTANCE_THRESHOLD` | 7 | Absolute threshold distance in km |
30+
| `MIN_STUDENT_IN_CENTER` | 10 | Min. no of students from a school to be assigned to a center in normal circumstances |
31+
| `STRETCH_CAPACITY_FACTOR` | 0.02 | Factor determining how much center capacity can be stretched if needed |
32+
| `PREF_CUTOFF` | -4 | Cutoff value for preference score allocation |
33+
34+
### Input Files
35+
36+
#### school.tsv
37+
- One entry per school.
38+
39+
```tsv
40+
scode count name-address lat long
41+
27101 1776 काठमाण्डौ मोडेल मा.वि., वागवजार 27.7067463495 85.3188922809
42+
27007 1700 ट्रिनीटी इन्टरनेशनल मा.वि., डिल्लीबजार 27.7038931952 85.3251961353
43+
27045 1278 साउथ वेस्टर्न स्टेट मा.वि., बसुन्धारा 27.7396600173 85.3254532539
44+
27127 1210 क्यापिटल मा.वि., कोटेश्वर 27.673541693 85.3449013829
45+
```
46+
47+
#### centers.tsv
48+
- One entry per center.
49+
>`cscode == scode`
50+
51+
```tsv
52+
cscode capacity name address नाम ठेगाना lat long
53+
27003 500 NATIONAL SCHOOL OF SCIENCES SECONDARY SCHOOL LAINCHAUR नेशनल स्कुल अफ साइन्सेस मा.वि लैनचौर 27.71933026 85.31413793
54+
27051 500 UNIGLOBE MA VI KAMALADI युनिग्लोब मा.वि कमलादी 27.70792875 85.32068522
55+
27045 568 SOUTH WESTERN ACADEMY SECONDARY SCHOOL BASUNDHARA साउथ वेर्ष्टन एकेडेमी मा.वि. बसुन्धरा 27.74212647 85.33392421
56+
```
57+
58+
#### prefs.tsv
59+
- Prioritize or deprioritize school and center pair. Negative pref score deprioritizes.
60+
- If pref score is less than `PREF_CUTOFF` center will be excluded from consideration.
61+
62+
```tsv
63+
scode cscode pref reason
64+
27xxx 27yyy -5 same management
65+
27yyy 27xxx -5 same management
66+
27aaa 27bbb -1 last year's center
67+
```
68+
69+
## Command
70+
71+
To run `school_center.py` use the command below:
72+
73+
```bash
74+
python3 school_center.py sample_data/schools_grade12_2081.tsv sample_data/centers_grade12_2081.tsv sample_data/prefs.tsv
75+
```
6576

6677
## Output
67-
Console output contains information about center allocation run.
6878

69-
remaining capacity at center (-ve if stretched capacity is used)
70-
|
71-
(-11, '27022'), (-11, '27045'), (-11, '27057')
72-
|
73-
center code
79+
```
80+
🚀 24-04-22 20:40:27 - __main__ - INFO - Remaining capacity at each center (remaining_capacity cscode):
81+
82+
Remaining capacity at center (-ve if stretched capacity is used)
83+
|
84+
🚀 24-04-22 20:40:27 - __main__ - INFO - [(-11, '27022'), (-11, '27045'), (-11, '27057')]
85+
|
86+
center code
7487
75-
Total remaining capacity across all centers: 190
76-
Students not assigned: 29
88+
🚀 24-04-22 20:40:27 - __main__ - INFO - Total remaining capacity across all centers: 161
7789
90+
🚀 24-04-22 20:40:27 - __main__ - INFO - Students not assigned: 0
91+
```

0 commit comments

Comments
 (0)