constraint-env / helper_functions.py
DecentSanage's picture
Upload folder using huggingface_hub
f823a82 verified
raw
history blame contribute delete
671 Bytes
def occupies_teacher(schedule, slots, b, sub, teacher, d, t):
# If this teacher does not teach this subject → no contribution
if teacher not in sub["teachers"]:
return 0
duration = sub["duration"]
terms = []
for s in slots:
if (b['name'], sub['name'], d, s) in schedule:
if s <= t < s + duration:
terms.append(schedule[b['name'], sub['name'], d, s])
return sum(terms)
def getSubject(data, b, sub):
for item in data:
if item['name'] == b:
for subjects in item['subjects']:
if subjects['name'] == sub:
return subjects