constraint programming for timetabling
TRANSCRIPT
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Constraint Programming for Timetabling
Hana Rudová
Faculty of Informatics, Masaryk UniversityBrno, Czech Republic
http://www.fi.muni.cz/~hanka
ASAP Seminar, 2004
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Purdue University Timetabling Problem
Course demands for individual studentsconflicts among classes of one student minimized
Timetable for large lecture classesFall 2001
manually created: slightly smaller (750 classes),less constrained (about 40 assigned prior search)
Fall 2004830 classes .
= 1500 meetings50 classrooms89,633 course demands for 29,808 studentsabout 350 classes assigned before search
Spring 2005easier data setno freshmen consideration, about 780 classes
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Outline
1 Purdue University Timetabling Problem
2 Constraint Satisfaction Problem
3 Over-Constrained ProblemSoft Constraints
4 Ill-defined problemSearchInconsistencies
5 Summary
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Constraint Satisfaction Problem (CSP)
Constraint satisfaction problem (X , D, C)
finite set of domain variables X = {V1, . . . , Vn}finite set of values (domain) D = D1 ∪ . . . ∪ Dnfinite set of constraints C = {c1, . . . , cm}
relations over subsets of variables
Partial assignment of variables (d1, . . . , dk ), k ≤ n
Complete assignment of variables (d1, . . . , dn)
Solution of CSPcomplete assignment which satisfies all constraints
Constrain & Search constraint propagationTimetabling example
variables: time T and classroom R for each classdomains: possible starting times, possible classroomsconstraints: required classrooms, precedence relationsamong times
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Constraint Satisfaction Problem (CSP)
Constraint satisfaction problem (X , D, C)
finite set of domain variables X = {V1, . . . , Vn}finite set of values (domain) D = D1 ∪ . . . ∪ Dnfinite set of constraints C = {c1, . . . , cm}
relations over subsets of variables
Partial assignment of variables (d1, . . . , dk ), k ≤ n
Complete assignment of variables (d1, . . . , dn)
Solution of CSPcomplete assignment which satisfies all constraints
Constrain & Search constraint propagationTimetabling example
variables: time T and classroom R for each classdomains: possible starting times, possible classroomsconstraints: required classrooms, precedence relationsamong times
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Constraint Satisfaction Problem (CSP)
Constraint satisfaction problem (X , D, C)
finite set of domain variables X = {V1, . . . , Vn}finite set of values (domain) D = D1 ∪ . . . ∪ Dnfinite set of constraints C = {c1, . . . , cm}
relations over subsets of variables
Partial assignment of variables (d1, . . . , dk ), k ≤ n
Complete assignment of variables (d1, . . . , dn)
Solution of CSPcomplete assignment which satisfies all constraints
Constrain & Search constraint propagation
Timetabling examplevariables: time T and classroom R for each classdomains: possible starting times, possible classroomsconstraints: required classrooms, precedence relationsamong times
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Constraint Satisfaction Problem (CSP)
Constraint satisfaction problem (X , D, C)
finite set of domain variables X = {V1, . . . , Vn}finite set of values (domain) D = D1 ∪ . . . ∪ Dnfinite set of constraints C = {c1, . . . , cm}
relations over subsets of variables
Partial assignment of variables (d1, . . . , dk ), k ≤ n
Complete assignment of variables (d1, . . . , dn)
Solution of CSPcomplete assignment which satisfies all constraints
Constrain & Search constraint propagationTimetabling example
variables: time T and classroom R for each classdomains: possible starting times, possible classroomsconstraints: required classrooms, precedence relationsamong times
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Global Constraints
serialized
classes of the same instructorat different times
disjoint2
two classes must have differenttime or classrooms ?
cumulative
for approximation (?)– classes change classroom– example: big classrooms
on time variables only
3 4 5 6
2
3
2
1
1
3 4 5 6
2
3
2
1
1
3 4 5 6
2
3
2
1
1
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Over-Constrained Problems
Over-constrained problemthere is no solution with all constraints satisfied
Solution:constraint modeling by hard and soft constraints
hard constraints = everything what must be satisfiedsoft constraints = optimization part
part of the problem which can be unsatisfiedoptimization for preferential requirements
Example of soft constraintstoo many preferential time requirementstwo classes share some students
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Soft Constraints
Weighted constraints
each constraint associated with the weight
example: V1#\ = V2@weight
aim: minimize weighted sum of unsatisfied constraints
Weighted constraints + hard constraints
stronger propagation for hard constraints
optimization for weighted constraints
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Soft Constraints
Weighted constraints
each constraint associated with the weight
example: V1#\ = V2@weight
aim: minimize weighted sum of unsatisfied constraints
Weighted constraints + hard constraints
stronger propagation for hard constraints
optimization for weighted constraints
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Solver for Soft Constraints
Each value of the variable associated with a weightunary soft constraints
Soft constraint propagationunsatisfied c @ weight increases weights of valuesfor variables in c
Evaluation of the solution [V1 = v1, . . . , Vn = vn]:∑∀i
w [Vi , vi ]
Aim: minimize evaluation of the solution
Example: V1#\ = V2@weightV1 or V2 is instantiated to value v
⇒ weight of the value v for second variable Vi
increased by weight w [Vi , v ] + weightpartial forward checking
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Solver for Soft Constraints
Each value of the variable associated with a weightunary soft constraints
Soft constraint propagationunsatisfied c @ weight increases weights of valuesfor variables in c
Evaluation of the solution [V1 = v1, . . . , Vn = vn]:∑∀i
w [Vi , vi ]
Aim: minimize evaluation of the solutionExample: V1#\ = V2@weight
V1 or V2 is instantiated to value v⇒ weight of the value v for second variable Vi
increased by weight w [Vi , v ] + weightpartial forward checking
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Examples of Soft Constraints
Unary soft constrainttimes or locations are preferred or discouraged
Soft serialized constraintclass A should not overlap with Bweight is the number of students in common
Soft cumulative constraintAt most N classes of some department are taught at thesame timeN is a soft limit
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Ill-defined problems
Ill-defined problemmistakes in the problem definition
Mistake = contradiction of hard constraintsExample
constraint propagation ⇒ two teachers requirethe same classroom at the same time
Mistakes must be removedfrom the problem definition to find a solutionSolution: detection of mistakes
during searchduring posting hard constraints
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Ill-defined problems
Ill-defined problemmistakes in the problem definition
Mistake = contradiction of hard constraintsExample
constraint propagation ⇒ two teachers requirethe same classroom at the same time
Mistakes must be removedfrom the problem definition to find a solutionSolution: detection of mistakes
during searchduring posting hard constraints
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Tree Search
Complete searchDepth First Search
Incomplete search: cutoff strategyconstrain some of the available resources
Depth Bounded Search
DBS(1)
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Tree Search
Complete searchDepth First Search
Incomplete search: cutoff strategyconstrain some of the available resources
Depth Bounded Search
DBS(1)
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Limited Assignment Number Search
LAN(2)
Constraint propagationvalues incompatible with the current partial assignmentare removed from the domains
LAN(3) + constraint propagation
do not waste time on „hard” variablesexplore various parts of the search tree
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Limited Assignment Number Search
LAN(2)
Constraint propagationvalues incompatible with the current partial assignmentare removed from the domains
LAN(3) + constraint propagation
do not waste time on „hard” variablesexplore various parts of the search tree
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Maximal Consistent Assignment
Unassigned variables
second variable V2 unassignedsome constraint(s) on V2 remain(s) unsatisfied
Consistent assignmentsatisfy (at least) all constraints over assigned variables
Maximal consistent assignmentconsistent assignment of the largest cardinality
Locally maximal consistent assignmentassignment which can not be extended tonon-instantiated variable
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Maximal Consistent Assignment
Unassigned variables
second variable V2 unassignedsome constraint(s) on V2 remain(s) unsatisfied
Consistent assignmentsatisfy (at least) all constraints over assigned variables
Maximal consistent assignmentconsistent assignment of the largest cardinality
Locally maximal consistent assignmentassignment which can not be extended tonon-instantiated variable
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Restart for LAN Search
1 restart algorithm with different settingunassigned variables firstuntried values for unassigned values firstsuccessful values for assigned variables
2 automated restart until the number of assigned variablesincreases
3 detection of possible problems over unassigned variables+ hard to solve parts, weak propagation
4 continue with restart with the problem changesproblem redefinition does not introduce any changes in restartstrategy
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Restart for LAN Search
1 restart algorithm with different settingunassigned variables firstuntried values for unassigned values firstsuccessful values for assigned variables
2 automated restart until the number of assigned variablesincreases
3 detection of possible problems over unassigned variables+ hard to solve parts, weak propagation
4 continue with restart with the problem changesproblem redefinition does not introduce any changes in restartstrategy
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
How to Discover Inconsistencies?
Undesirable inconsistenciesMistakes in data input
minimize by user interfacetypes of mistakes
introduced during data entrynaturally included as a part of the problem
Explanationscomputationally expensivenot available in standalone constraint solvers
During searchLAN search
user need some partial solutionuser can change the problem
Before searchmanual processautomated process
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
How to Discover Inconsistencies?
Undesirable inconsistenciesMistakes in data input
minimize by user interfacetypes of mistakes
introduced during data entrynaturally included as a part of the problem
Explanationscomputationally expensivenot available in standalone constraint solvers
During searchLAN search
user need some partial solutionuser can change the problem
Before searchmanual processautomated process
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Preconditions for Detection of Inconsistencies
Detail (print) information aboutposting each constraintseach value removal
Post constraints in specific ordermost complex first, most simple last
Complex constraintsdisjoint2, cumulativedetection of a conflict here is not easy
Simple constraintsconstraints over small set of variablesunary constraints over location or time
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Towards Automated Process of Detection
1 Fail during constraint posting2 Last posted constraint cLAST failed3 Variables in cLAST are problem variables4 Tracking of value removals for problem variables5 Value removal was due to constraint cREMOVE
6 Check consistency of cLAST and cREMOVE
In our problem, conflict between cLAST and cREMOVE wasalways source of a mistake.
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Conclusion
Over-constrained, ill-defined problems
solver for weighted soft constraints
locally maximal consistent assignment during search
detection of mistakes for standalone constraint solvers
Optimization
multi-criteria optimization
minimal perturbation problem
CP forTimetabling
Hana Rudová
PurdueProblem
Outline
CSP
Over-ConstrainedProblemSoft Constraints
Ill-definedproblemSearch
Inconsistencies
Summary
Conclusion
Over-constrained, ill-defined problems
solver for weighted soft constraints
locally maximal consistent assignment during search
detection of mistakes for standalone constraint solvers
Optimization
multi-criteria optimization
minimal perturbation problem