1 / 131

Lecture 01 – Part C Constraint Satisfaction Problems

Lecture 01 – Part C Constraint Satisfaction Problems. Dr. Shazzad Hosain Department of EECS North South Universtiy shazzad@northsouth.edu. Constraint Satisfaction Problems (CSPs). Standard search problem:

brandy
Download Presentation

Lecture 01 – Part C Constraint Satisfaction Problems

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. Lecture 01 – Part CConstraint Satisfaction Problems Dr. Shazzad Hosain Department of EECS North South Universtiy shazzad@northsouth.edu

  2. Constraint Satisfaction Problems (CSPs) • Standard search problem: • state is a "black box“ – any data structure that supports successor function, heuristic function, and goal test • CSP: • state is defined by variablesXi with values from domainDi • goal test is a set of constraints specifying allowable combinations of values for subsets of variables

  3. Constraint satisfaction problem • A CSP is defined by • a set of variables • a domain of possible values for each variable • a set of constraints between variables • An assignment that does not violate any constraints is called a consistent or legal CONSISTENT assignment. • A complete assignment is one in which every variable is mentioned. • A solution to a CSP is • A complete assignment that satisfies all the constraints

  4. Example: Map-Coloring • VariablesWA, NT, Q, NSW, V, SA, T • DomainsDi = {red, green, blue} • Constraints: adjacent regions must have different colors • e.g., WA ≠ NT

  5. Example: Map-Coloring • Solutions are complete and consistent assignments, e.g., WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue, T = green • A state may be incomplete e.g., just WA=red

  6. T NSW WA NT SA Q V Constraint graph • It is helpful to visualize a CSP as a constraint graph • Binary CSP: each constraint relates two variables • Constraint graph: nodes are variables, arcs are constraints

  7. Varieties of CSPs • Discrete variables • finite domains: • n variables, domain size d  O(dn) complete assignments • e.g., Boolean CSPs, incl. Boolean satisfiability (NP-complete) • infinite domains: • integers, strings, etc. • e.g., job scheduling, variables are start/end days for each job • need a constraint language, e.g., StartJob1 + 5 ≤ StartJob3 • Continuous variables • e.g., start/end times for Hubble Space Telescope observations • linear constraints solvable in polynomial time by linear programming

  8. Varieties of constraints • Unary constraints involve a single variable, • e.g., SA ≠ green • Binary constraints involve pairs of variables, • e.g., SA ≠ WA • Higher-order constraints involve 3 or more variables, • e.g., cryptarithmetic column constraints

  9. Constraint Satisfaction problem Backtracking Search

  10. NxD WA WA WA NT T [NxD]x[(N-1)xD] WA NT WA NT WA NT NT WA Standard search formulation • Let’s try the standard search formulation. • We need: • Initial state: none of the variables has a value (color) • Successor state: one of the variables without a value will get some value. • Goal: all variables have a value and none of the constraints is violated. N layers N! x DN Equal! There are N! x DN nodes in the tree but only DN distinct states??

  11. Backtracking search • Every solution appears at depth n with n variables use depth-first search • Depth-first search for CSPs with single-variable assignments is called backtracking search • Backtracking search is the basic uninformed algorithm for CSPs • Can solve n-queens for n ≈ 25

  12. NT WA WA NT = Backtracking (Depth-First) search • Special property of CSPs: They are commutative: • This means: the order in which we assign variables • does not matter. • Better search tree: First order variables, then assign them values one-by-one. D WA WA WA WA NT D2 WA NT WA NT DN

  13. Backtracking search

  14. Backtracking example

  15. Backtracking example

  16. Backtracking example

  17. Backtracking example

  18. G F A B C E N D H I J K L M O Depth First Search (DFS) • Application: • Given the following state space (tree search), give the sequence of visited nodes when using DFS (assume that the nodeO is the goal state):

  19. A B C E D Depth First Search • A,

  20. A B C E D F G Depth First Search • A,B,

  21. A B C E D F G Depth First Search • A,B,F,

  22. A B C E D F G K L Depth First Search • A,B,F, • G,

  23. A B C E D F G K L Depth First Search • A,B,F, • G,K,

  24. A B C E D F G K L O Depth First Search • A,B,F, • G,K, • L,

  25. A B C E D F G K L O Depth First Search • A,B,F, • G,K, • L, O: Goal State

  26. A B C E D F G K L O Depth First Search • The returned solution is the sequence of operators in the path: A, B, G, L, O : assignments when using CSP !!!

  27. Backtracking Example 1

  28. Example of a csp A B E C D H F G 3 colour me!

  29. {blue, green, red} {blue, green, red} A B {blue, green, red} E C {blue, green, red} D {blue, green, red} H {blue, green, red} F G {blue, green, red} {blue, green, red} Example of a csp 3 colour me!

  30. A B E C D H F G Example of a csp 1 = red 2 = blue 3 = green

  31. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  32. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  33. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  34. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  35. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  36. Example of a csp A B E C D H F G Dead end → backtrack 1 = red 2 = blue 3 = green

  37. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  38. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  39. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  40. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  41. Example of a csp A B E C D H F G 1 = red 2 = blue 3 = green

  42. Example of a csp A B E C D H Solution !!!! F G 1 = red 2 = blue 3 = green

  43. Backpropagation Example 2

  44. Backpropagation [R,B,G] [R,B,G] [R] [R,B,G] [R,B,G]

  45. Backpropagation [R,B,G] [R,B,G] [R] [R,B,G] [R,B,G]

  46. Backpropagation [R,B,G] [R,B,G] [R] [R,B,G] [R,B,G]

  47. Backpropagation [R,B,G] [R,B,G] [R] [R,B,G] [R,B,G]

  48. Backpropagation [R,B,G] [R,B,G] [R] [R,B,G] [R,B,G]

  49. Backpropagation [R,B,G] [R,B,G] [R] [R,B,G] [R,B,G] Dead End → Backtrack

  50. Backpropagation [R,B,G] [R,B,G] [R] [R,B,G] [R,B,G]

More Related