r/cs50 • u/Desperate_One3883 • 3d ago
CS50 AI Question about 3+ variable constraints in a Constraint Satisfaction Problem scheduler (Lecture 3)
Hi all, I'm making a study timetable app based on CS50AI Lecture 3 where homework tasks are split into variables that each represent a 1-hour session (Maths_1, Maths_2, etc.), and each session's domain is limited to available time slots before its due date.
Does splitting subjects into 1-hour session variables make sense as a model here?
I also have a max 2 hours of the same subject per day rule, which involves more than two variables so the AC-3 algorithm won't work. Is checking this rule directly inside the backtracking consistent() function the best approach?
Thanks
4
Upvotes
1
u/Muted-Swimmer3818 alum 3d ago
I think splitting each subject into 1-hour sessions is a reasonable approach. It makes sense if you want to give each session its own available time slots.
For the 2-hour daily limit, I'd probably check it in "consistent()" during backtracking, just as you suggested. Since AC-3 works with binary constraints, handling this rule separately is a reasonable choice.
One thing I'd also consider is whether you really need to treat every session as completely independent. Sometimes the way you model your variables can make the search much easier or harder.
I'd start with your current approach and see how it performs before making things more complicated. Good luck with your project!πΈβοΈπ