Back to CSP Topics

CSP Exercise: Exam Scheduling

Interactive Problem Solving with Constraint Satisfaction

Problem Overview

Scenario: A university must schedule exams for three subjects: Math, Physics, and Computer Science.

Key Constraints:

  • A single student is enrolled in all three subjects → no two exams can be at the same time
  • The Math professor is only available in the Morning

We'll explore two versions: 2-slot scheduling (impossible) and 3-slot scheduling (solvable).

Part A: 2-Slot Exam Scheduling (Unsolvable)

Available slots: Morning and Afternoon

Question 1: CSP Modeling
1(a) CSP Variables

Q: What are the variables in this CSP?

CSP Variables:
Math
Exam Variable
Physics
Exam Variable
Computer Science
Exam Variable
1(b) Variable Domains

Q: What are the initial domains for each variable before applying constraints?

Initial Domains (before constraints):
Math
Morning Afternoon
Physics
Morning Afternoon
CS
Morning Afternoon
1(c) Constraints

Q: List all constraints in this CSP.

CSP Constraints:
Math ≠ Physics (student can't take both exams simultaneously)
Math ≠ CS (student can't take both exams simultaneously)
Physics ≠ CS (student can't take both exams simultaneously)
Math = Morning (professor availability)
Question 2: Forward Checking
2(a) Forward Checking Domains

Q: After assigning Math = Morning, what are the updated domains for Physics and CS using forward checking?

Math
Morning
ASSIGNED
Physics
Morning Afternoon
CS
Morning Afternoon
2(b) Empty Domain After Forward Checking?

Q: Does any variable have an empty domain after forward checking with Math = Morning?

1 Math Domain Size
1 Physics Domain Size
1 CS Domain Size
Question 3: MRV Heuristic

Q: After assigning Math = Morning, which variable(s) would the MRV (Minimum Remaining Values) heuristic select next?

MRV Analysis:
Math
Morning
Domain: 1 (assigned)
Physics
Afternoon
MRV Candidate: 1 value
CS
Afternoon
MRV Candidate: 1 value
Question 4: LCV Applicability

Q: Is the LCV (Least Constraining Value) heuristic applicable when choosing a value for Physics or CS after Math = Morning?

LCV Analysis for Physics:

Available values: {Afternoon}

Number of choices: 1


LCV Analysis for CS:

Available values: {Afternoon}

Number of choices: 1

Question 5: Impossibility Analysis
5(a) Is a valid schedule possible?

Q: Is there a valid exam schedule using only two slots under the given rules?

Attempted Schedule:
Math
Morning
Physics
Afternoon
Ready to assign
CS
Afternoon
Ready to assign
5(b) Explain Impossibility

Q: Explain clearly why no valid schedule exists.

3 Exams (Pigeons)
📚
🔬
💻
Math, Physics, CS
2 Slots (Holes)
🌅
🌇
Morning, Afternoon
5(c) Bonus: Minimum Number of Slots

Q: What is the minimum number of exam slots required to schedule all three exams without conflicts?

1 Slot
2 Slots
3 Slots
4 Slots

Part B: 3-Slot Exam Scheduling (Solvable)

Available slots: Morning, Afternoon, and Evening

Question 6: Forward Checking with 3 Slots

Q: After assigning Math = Morning, what are the domains of Physics and CS?

Math
Morning
ASSIGNED
Physics
Morning Afternoon Evening
CS
Morning Afternoon Evening
Question 7: Valid Schedules Count

Q: How many complete valid exam schedules satisfy all constraints?

Possible Valid Schedules:
Schedule 1:
Math = Morning
Physics = Afternoon
CS = Evening
Schedule 2:
Math = Morning
Physics = Evening
CS = Afternoon
Question 8: Key Difference Analysis

Q: Explain the key reason why the 2-slot version is unsolvable but the 3-slot version is solvable.

2-Slot Version
📚
🔬
💻
🌅
🌇
IMPOSSIBLE
3 exams, 2 slots
3-Slot Version
📚
🔬
💻
🌅
🌇
🌃
SOLVABLE
3 exams, 3 slots

Learning Summary

Key Takeaways from this Exercise:
  • CSP Modeling: Identifying variables, domains, and constraints is crucial for problem formulation
  • Forward Checking: Constraint propagation can reveal conflicts early but doesn't guarantee solvability
  • Heuristics: MRV and LCV help guide search but may not apply when domains are too constrained
  • Pigeonhole Principle: Sometimes problems are fundamentally impossible due to mathematical constraints
  • Problem Scaling: Adding resources (slots) can transform impossible problems into solvable ones