1 / 29

Constraint Programming

Constraint Programming. Peter van Beek University of Waterloo. Applications. Reasoning tasks: abductive, diagnostic, temporal, spatial Cognitive tasks: machine vision, natural language processing Combinatorial tasks: scheduling, sequencing, planning. Constraint Programming.

camden
Download Presentation

Constraint Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Constraint Programming Peter van Beek University of Waterloo

  2. Applications • Reasoning tasks: • abductive, diagnostic, temporal, spatial • Cognitive tasks: • machine vision, natural language processing • Combinatorial tasks: • scheduling, sequencing, planning

  3. Constraint Programming • CP = solve problems by specifying constraints on acceptable solutions • Why CP? • constraints often a natural part of problems • once problem is modeled using constraints, wide selection of solution techniques available

  4. Constraint-based problem solving • Model problem • specify in terms of constraints on acceptable solutions • define variables (denotations) and domains • define constraints in some language • Solve model • define search space / choose algorithm • incremental assignment / backtracking search • complete assignments / stochastic search • design/choose heuristics • Verify and analyze solution

  5. Constraint-based problem solving • Model problem • specify in terms of constraints on acceptable solutions • define variables (denotations) and domains • define constraints in some language • Solve model • define search space / choose algorithm • incremental assignment / backtracking search • complete assignments / stochastic search • design/choose heuristics • Verify and analyze solution Constraint Satisfaction Problem

  6. Constraint satisfaction problem • A CSP is defined by • a set of variables • a domain of values for each variable • a set of constraints between variables • A solution is • an assignment of a value to each variable that satisfies the constraints

  7. Constraint-based problem solving • Model problem • specify in terms of constraints on acceptable solutions • define variables (denotations) and domains • define constraints in some language • Solve model • define search space / choose algorithm • incremental assignment / backtracking search • complete assignments / stochastic search • design/choose heuristics • Verify and analyze solution

  8. Example: Assembly line sequencing • What order should the cars be manufactured? • Constraints: • even distributions • changes in colors • run length constraints

  9. Example: Scheduling Four students, Algy, Bertie, Charlie, and Digby share a flat. Four newspapers are delivered. Each student reads the newspapers in a particular order and for a specified amount of time. Algy arises at 8:30, Bertie and Charlie at 8:45, Digby at 9:30. What is the earliest that they can all set of for school?

  10. Schedule Sun Express Guardian FT 8 am 9 10 11

  11. Example: Graph coloring Given k colors, does there exist a coloring of the nodes such that adjacent nodes are assigned different colors

  12. Example: 3-coloring Variables: v1, v2 , v3 , v4 , v5 Domains: {1, 2, 3} Constraints: vi  vjif vi and vj are adjacent v2 v1 v4 v3 v5

  13. Example: 3-coloring One solution: v1  1 v2  2 v3  2 v4  1 v5  3 v2 v1 v4 v3 v5

  14. Example: Boolean satisfiability Given a Boolean formula, does there exist a satisfying assignment (an assignment of true or false to each variable such that the formula evaluates to true)

  15. Example: 3-SAT Variables: x1, x2 , x3 , x4 , x5 Domains: {True, False} Constraints: (x1  x2  x4), (x2  x4  x5), (x3  x4  x5) (x1  x2  x4)  (x2  x4  x5)  (x3  x4  x5)

  16. Example: 3-SAT One solution: x1  False x2  False x3  False x4  True x5  False (x1  x2  x4)  (x2  x4  x5)  (x3  x4  x5)

  17. Example: n-queens Place n-queens on an n  n board so that no pair of queens attacks each other

  18. Example: 4-queens Variables: x1, x2 , x3 , x4 Domains: {1, 2, 3, 4} Constraints: xi  xjand | xi - xj | | i- j| x1 x2 x3 x4 1 2 3 4

  19. Example: 4-queens x1 x2 x3 x4 One solution: x1  2 x2  4 x3  1 x4  3 1 Q 2 Q 3 Q Q 4

  20. Search tree for 4-queens x1 1 2 3 4 x2 x3 x4 (1,1,1,1) (2,4,1,3) (3,1,4,2) (4,4,4,4)

  21. Specification of forward checking Invariant: 1 i c, cj n, (xj, xi) is arc-consistent x1 xc-1 xc xc+1 xn past current future

  22. Forward checking 1 2 3 4 5 6 x1 {1,4,6} Q x4 x2 1 1 1 Q x3 1 Q 1 2 2 {2} {5} {3} {1,3,4} x4 1 2 3 1 x5 x1 x2 x3 x5 3 1 3 2 1 {3,4,6} x6 2 1 3 2 3 x6

  23. Enforcing arc-consistency < {a, b, c} {a, b, c} xj xi

  24. {a, b, c} {a, b, c} {a, b, c} xk xj xi Enforcing path-consistency < < <

  25. Search graph for 4-queens (1,1,1,2) (1,1,4,2) 4 (1,1,1,1) 1 6 (1,1,1,3) 3 (3,1,4,2) 0 (1,1,1,4) 4 (1,4,1,3) 1 (4,1,4,2) 1 (2,4,1,3) 0

  26. Pick queen in conflict x1 Q x2 2 1 Q 1 x3 Q x4 Q Move to min. conflicts Pick queen in conflict x1 x1 Q Q x2 Q x2 Q x3 Q x3 0 2 2 Q x4 Q x4 Q Stochastic search Initial assignment x1 Q x2 Q x3 Q x4 Q

  27. Tractability NP NP-Complete (SAT, TSP, ILP, CSP, …) P

  28. CSP 3-SAT binary CSP ILP (0,1)-ILP Reducibility NP-Complete

  29. Options CSP, binary CSP, SAT, 3-SAT, ILP, ... • Model and solve in one of these languages • Model in one language, translate into another to solve

More Related