introduction overview
play

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


  1. 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

  2. Sudoku 2 5 9 7 3 2 9 6 2 4 9 7 6 9 1 8 4 1 6 3 8 6 8 � Assign blank fields digits such that: digits distinct per rows, columns, blocks 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 4

  3. Propagation 2 5 9 7 3 2 9 6 2 4 9 7 1,2,3,4,5,6,7,8,9 6 9 1 8 4 1 6 3 8 6 8 � Prune digits from fields such that: digits distinct per rows, columns, blocks 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 10

  4. Propagation 2 5 9 7 3 2 9 6 2 4 9 7 1,3,5,6,7,8 6 9 1 8 4 1 6 3 8 6 8 � Prune digits from fields such that: digits distinct per rows , columns, blocks 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 11

  5. Propagation 2 5 9 7 3 2 9 6 2 4 9 7 1,3,6,7 6 9 1 8 4 1 6 3 8 6 8 � Prune digits from fields such that: digits distinct per rows, columns , blocks 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 12

  6. Propagation 2 5 9 7 3 2 9 6 2 4 9 7 1,3,6 6 9 1 8 4 1 6 3 8 6 8 � Prune digits from fields such that: digits distinct per rows, columns, blocks 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 13

  7. Iterated Propagation 2 5 9 7 3 2 9 6 2 4 9 7 6 9 1 8 4 1 6 3 8 6 8 � Iterate propagation for rows, columns, blocks � What if no assignment: search... later 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 14

  8. Running Example: SMM � Find distinct digits for letters, such that SEND + MORE = MONEY 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 19

  9. Constraint Model for SMM � Variables: S,E,N,D,M,O,R,Y � {0,…,9} � Constraints: distinct(S,E,N,D,M,O,R,Y) 1000 × S+100 × E+10 × N+D + 1000 × M+100 × O+10 × R+E = 10000 × M+1000 × O+100 × N+10 × E+Y S � 0 M � 0 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 20

  10. Finding a Solution � Compute with possible values � rather than enumerating assignments � Prune inconsistent values � constraint propagation � Search � branch: define search tree � explore: explore search tree for solution 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 22

  11. Constraint Propagation

  12. Constraint Store finite domain constraints x � {3,4,5} y � {3,4,5} � Maps variables to possible values � Others: finite sets, intervals, trees, ... 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 26

  13. Propagators � Implement (non-basic) constraints distinct(x 1 ,…,x n ) x + 2*y = z 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 27

  14. Propagators x � y y>3 x � {3,4,5} y � {3,4,5} � Amplify store by constraint propagation 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 29

  15. Propagators x � y y>3 x � {3,4,5} y � {4,5} � Amplify store by constraint propagation 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 30

  16. Propagators x � y y>3 x � {3,4,5} y � {4,5} � Amplify store by constraint propagation 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 31

  17. Propagators x � y y>3 x � {4,5} y � {4,5} � Amplify store by constraint propagation 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 32

  18. Propagators x � y y>3 x � {4,5} y � {4,5} � Amplify store by constraint propagation � Disappear when done (subsumed, entailed) no more propagation possible � 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 33

  19. Propagators x � y x � {4,5} y � {4,5} � Amplify store by constraint propagation � Disappear when done (subsumed, entailed) no more propagation possible � 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 34

  20. Propagation for SMM � 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 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 35

  21. Constraints and Propagators � Constraints state relations among variables � which value combinations satisfy constraint � Propagators implement constraints � prune values in conflict with constraint � Constraint propagation drives propagators for several constraints 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 36

  22. Search

  23. Search: Branching x � y x � {4,5} y � {4,5} x � 4 x=4 x � y x � y x � {4} y � {4} x � {5} y � {4,5} � Create subproblems with additional information enable further constraint propagation � 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 39

  24. Example Branching Strategy � Pick variable x with at least two values � Pick value n from domain of x � Branch with x � n x=n and � Part of model 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 40

  25. Search: Exploration � Iterate propagation and branching � Orthogonal: branching � exploration � Nodes: � Unsolved � Failed � Succeeded 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 41

  26. SMM: Unique Solution SEND + MORE = MONEY 9567 + 1085 = 10652 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 42

  27. Heuristics for Branching � Which variable � least possible values (first-fail) � application dependent heuristic � Which value � minimum, median, maximum x � m x=m or � split with median m x � m x<m or � Problem specific 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 43

  28. SMM: Solution With First-fail SEND + MORE = MONEY 9567 + 1085 = 10652 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 44

  29. Send Most Money (SMM++) � Find distinct digits for letters, such that SEND + MOST = MONEY and MONEY maximal 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 45

  30. Best Solution Search � 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 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 46

  31. Branch-and-bound Search � Find first solution 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 47

  32. Branch-and-bound Search � Explore with additional constraint 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 49

  33. Branch-and-bound Search � Guarantees better solutions 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 51

  34. Branch-and-bound Search � Last solution best 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 52

  35. Branch-and-bound Search � Proof of optimality 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 53

  36. Modelling SMM++ � 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 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 54

  37. SMM++: Branch-and-bound SEND + MOST = MONEY 9782 + 1094 = 10876 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 55

  38. SMM: Strong Propagation SEND + MORE = MONEY 9567 + 1085 = 10652 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 63

  39. Acknowledgments � I am grateful to Pierre Flener for helpful comments and bugreports on these slides 2018-03-19 ID2204, L01, Christian Schulte, EECS, KTH 97

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend