ID2204: Constraint Programming
Introduction & Overview
Lecture 01, 2018-03-19
Christian Schulte
cschulte@kth.se
Software and Computer Systems School of Electrical Engineering and Computer Science KTH Royal Institute of Technology Sweden
Introduction & Overview Lecture 01, 2018-03-19 Christian - - PowerPoint PPT Presentation
ID2204: Constraint Programming Introduction & Overview Lecture 01, 2018-03-19 Christian Schulte cschulte@kth.se Software and Computer Systems School of Electrical Engineering and Computer Science KTH Royal Institute of Technology Sweden
Lecture 01, 2018-03-19
Christian Schulte
cschulte@kth.se
Software and Computer Systems School of Electrical Engineering and Computer Science KTH Royal Institute of Technology Sweden
2018-03-19
Assign blank fields digits such that:
9 2
2 5 9 7 3 6
2 6 9 7 4 9 1 8 6 3 4 6 8 1 8
ID2204, L01, Christian Schulte, EECS, KTH 4
2018-03-19
Prune digits from fields such that:
9 2
2 5 9 7 3 6
2 6 9 7 4 9 1 8 6 3 4 6 8 1 8
1,2,3,4,5,6,7,8,9
ID2204, L01, Christian Schulte, EECS, KTH 10
2018-03-19
Prune digits from fields such that:
9 2
2 5 9 7 3 6
9 6 2 7 1 9 4 8 6 3 4 6 8 1 8
1,3,5,6,7,8
ID2204, L01, Christian Schulte, EECS, KTH 11
2018-03-19
Prune digits from fields such that:
9 2
9 5 2 7 3 6
2 6 9 7 4 9 1 8 6 3 8 6 4 1 8
1,3,6,7
ID2204, L01, Christian Schulte, EECS, KTH 12
2018-03-19
Prune digits from fields such that:
9 2
2 5 9 7 3 6
2 6 9 7 4 9 1 8 6 3 4 6 8 1 8
1,3,6
ID2204, L01, Christian Schulte, EECS, KTH 13
2018-03-19
Iterate propagation for rows, columns, blocks What if no assignment: search... later
9 2
2 5 9 7 3 6
2 6 9 7 4 9 1 8 6 3 4 6 8 1 8
ID2204, L01, Christian Schulte, EECS, KTH 14
2018-03-19
Find distinct digits for letters, such that
ID2204, L01, Christian Schulte, EECS, KTH 19
2018-03-19
Variables:
Constraints:
ID2204, L01, Christian Schulte, EECS, KTH 20
2018-03-19
Compute with possible values
rather than enumerating assignments
Prune inconsistent values
constraint propagation
Search
branch:
define search tree
explore:
explore search tree for solution
ID2204, L01, Christian Schulte, EECS, KTH 22
2018-03-19
Maps variables to possible values Others: finite sets, intervals, trees, ...
finite domain constraints
ID2204, L01, Christian Schulte, EECS, KTH 26
2018-03-19
Implement (non-basic) constraints
ID2204, L01, Christian Schulte, EECS, KTH 27
2018-03-19
Amplify store by constraint propagation
ID2204, L01, Christian Schulte, EECS, KTH 29
2018-03-19
Amplify store by constraint propagation
ID2204, L01, Christian Schulte, EECS, KTH 30
2018-03-19
Amplify store by constraint propagation
ID2204, L01, Christian Schulte, EECS, KTH 31
2018-03-19
Amplify store by constraint propagation
ID2204, L01, Christian Schulte, EECS, KTH 32
2018-03-19
Amplify store by constraint propagation Disappear when done (subsumed, entailed)
ID2204, L01, Christian Schulte, EECS, KTH 33
2018-03-19
Amplify store by constraint propagation Disappear when done (subsumed, entailed)
ID2204, L01, Christian Schulte, EECS, KTH 34
2018-03-19
Results in store
S{9} E{4,…,7} N{5,…,8} D{2,…,8} M{1} O{0} R{2,…,8} Y{2,…,8}
Propagation alone not sufficient!
create simpler sub-problems branching
ID2204, L01, Christian Schulte, EECS, KTH 35
2018-03-19
Constraints state relations among variables
which value combinations satisfy constraint
Propagators implement constraints
prune values in conflict with constraint
Constraint propagation drives propagators for
ID2204, L01, Christian Schulte, EECS, KTH 36
2018-03-19
Create subproblems with additional information
x{4,5} y{4,5} xy x{4} y{4} xy x{5} y{4,5} xy
x=4 x4
ID2204, L01, Christian Schulte, EECS, KTH 39
2018-03-19
Pick variable x with at least two values Pick value n from domain of x Branch with
Part of model
ID2204, L01, Christian Schulte, EECS, KTH 40
2018-03-19
Iterate propagation and branching Orthogonal: branching exploration Nodes:
Unsolved Failed Succeeded
ID2204, L01, Christian Schulte, EECS, KTH 41
2018-03-19
ID2204, L01, Christian Schulte, EECS, KTH 42
2018-03-19
Which variable
least possible values (first-fail) application dependent heuristic
Which value
minimum, median, maximum
x=m
xm
split with median m
x<m
xm
Problem specific
ID2204, L01, Christian Schulte, EECS, KTH 43
2018-03-19
ID2204, L01, Christian Schulte, EECS, KTH 44
2018-03-19
Find distinct digits for letters, such that
ID2204, L01, Christian Schulte, EECS, KTH 45
2018-03-19
Naïve approach:
compute all solutions choose best
Branch-and-bound approach:
compute first solution add “betterness” constraint to open nodes next solution will be “better” prunes search space
ID2204, L01, Christian Schulte, EECS, KTH 46
2018-03-19
Find first solution
ID2204, L01, Christian Schulte, EECS, KTH 47
2018-03-19
Explore with additional constraint
ID2204, L01, Christian Schulte, EECS, KTH 49
2018-03-19
Guarantees better solutions
ID2204, L01, Christian Schulte, EECS, KTH 51
2018-03-19
Last solution best
ID2204, L01, Christian Schulte, EECS, KTH 52
2018-03-19
Proof of optimality
ID2204, L01, Christian Schulte, EECS, KTH 53
2018-03-19
Constraints and branching as before Order among solutions with constraints
so-far-best solution
S,E,N,D,M,O,T,Y
current node
S,E,N,D,M,O,T,Y
constraint added
10000×M+1000×O+100×N+10×E+Y < 10000×M+1000×O+100×N+10×E+Y
ID2204, L01, Christian Schulte, EECS, KTH 54
2018-03-19
ID2204, L01, Christian Schulte, EECS, KTH 55
2018-03-19
ID2204, L01, Christian Schulte, EECS, KTH 63
2018-03-19
I am grateful to Pierre Flener for helpful
ID2204, L01, Christian Schulte, EECS, KTH 97