1 / 151

Finite Constraint Domains

Explore the world of finite constraint domains and discover clever ways to solve complex scheduling, routing, and timetabling problems. This course covers binary CSPs, graph-related concepts, CSP solution techniques, and more.

ckoehler
Télécharger la présentation

Finite Constraint Domains

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. Finite Constraint Domains Where we meet the simplest and yet the most difficult constraints, and some clever and not so clever ways to solve them. CSC5240 - Finite Constraint Domains

  2. Finite Constraint Domains • An important class of constraint domains • Modeling constraint problems involving choice: e.g. scheduling, routing and timetabling • The greatest industrial impact of constraint programming has been on these problems CSC5240 - Finite Constraint Domains

  3. Finite Domain CSPs • A FD CSP (or simply CSP hereafter) is a triple áZ,D,Cñ • Z is a finite set of variables {x1,x2,…,xn} • D is a function that maps each variable x to its domain D(x), a finite set of objects • C is a constraint, each primitive constraint of which on an arbitrary subsets of Z • It is understood as the constraint CSC5240 - Finite Constraint Domains

  4. Binary CSPs • A binary CSP is a CSP with unary or binary constraints only • A CSP with more than unary and binary constraints are general CSPs • Theoretically speaking, every general CSP can be transformed to an “equivalent” binary CSP • How?? CSC5240 - Finite Constraint Domains

  5. Graph-Related Concepts • A graph (directed or undirected) is a pair (V,U), where V is a set of nodes and U (VV) is a set of arcs, each of which is a pair of adjacent nodes • For undirected graphs, (j,k) and (k,j) denote the same arc for every pair of adjacent nodes j and k CSC5240 - Finite Constraint Domains

  6. Graph-Related Concepts (cont’d) • A hypergraph is a pair (V,U), where V is a set of nodes and U is a set of hyper-arcs, each of which is a set of nodes • A constraint hypergraph of a CSP áZ,D,Cñ is a hypergraph in which each node denote a variable in Z, and each hyper-arc denote a primitive constraint in C CSC5240 - Finite Constraint Domains

  7. Graph-Related Concepts (cont’d) • A path in a graph (or hypergraph) is a sequence of nodes drawn from the graph, where every pair of adjacent nodes in this sequence forms an arc (or hyper-arc) • A path of lengthn is a path which goes thru n+1 (not necessarily distinct) nodes • Draw the constraint hypergraphs of previous CSP examples CSC5240 - Finite Constraint Domains

  8. CSP Solution Techniques • A CSP-solving algorithm is sound if every answer returned by the algorithm is indeed a solution of the CSP • A CSP-solving algorithm is complete if every solution can be found by the algorithm • Soundness and completeness are desirable properties of CSP-solving algorithms CSC5240 - Finite Constraint Domains

  9. CSP Solution Techniques (cont’d) • CSPs are NP-complete in general • In some real-life problems, an incomplete (and sometimes even unsound) but efficient algorithm is acceptable CSC5240 - Finite Constraint Domains

  10. Domain Specific .vs. General • Encoding domain specific knowledge can gain efficiency: e.g. the N-Queen problem • But … • Tailor-made algorithms are costly • Tailor-made algorithms are not adaptable in (even slight) change of problem specification • General algorithms can often form the basis of specialized algorithms • CSPs are NP-complete anyway!!! CSC5240 - Finite Constraint Domains

  11. Three Classes of Techniques • Generate-and-Test (not really a technique) • Searching • Problem reduction • Solution Synthesis CSC5240 - Finite Constraint Domains

  12. Generate-and-Test • Systematically generating all combinations of values from domains of variables • For each generated valuation , where var() = Z, test whether  satisfies all primitive constraints in C • Highly combinatorial and impractical even for small problems CSC5240 - Finite Constraint Domains

  13. Searching - 1 • Searching is fundamental in almost all areas of computer science, including AI • Chronological backtracking search • Labeling a variable • Pick a variable x • Pick an available value v from D(x), making sure that is compatible with the current valuation • Consider an alternative available value in D(x) if current variable labeling violates some constraints CSC5240 - Finite Constraint Domains

  14. Searching - 2 • If all the variables are labelled, then a solution is found • If, at any stage, no available value can be assigned to a variable, the label that was last picked is revised • Repeat until either a solution is found or all possible combinations of labels have been tried CSC5240 - Finite Constraint Domains

  15. A Simple Backtracking Solver • The backtracking solver: • enumerates values for one variable at a time • checks that no primitive constraint is false at each stage • Assume satisfiable(c) returns false when primitive constraint c with no variables is unsatisfiable; and true otherwise CSC5240 - Finite Constraint Domains

  16. Partial Satisfiability • Check if a constraint is made unsatisfiable by a primitive constraint with no variables • partial_satisfiable(C) • for each primitive constraint c in C • if vars(c) is empty then • ifsatisfiable(c) = falsethenreturnfalse • returntrue CSC5240 - Finite Constraint Domains

  17. Backtracking Solve - 1 • back_solve(C,D) • ifvars(C) is empty return partial_satisfiable(C) • choose x in vars(C) • for each value d in D(x) • let C1 be C with x replaced by d • if partial_satisfiable(C1) then • if back_solve(C1,D) then returntrue • returnfalse CSC5240 - Finite Constraint Domains

  18. Backtracking Solve - 2 CSC5240 - Finite Constraint Domains

  19. Backtracking Solve - 2 Choose var X domain {1,2} CSC5240 - Finite Constraint Domains

  20. Backtracking Solve - 2 Choose var X domain {1,2} CSC5240 - Finite Constraint Domains

  21. Backtracking Solve - 2 CSC5240 - Finite Constraint Domains

  22. Backtracking Solve - 2 Choose var Y domain {1,2} CSC5240 - Finite Constraint Domains

  23. Backtracking Solve - 2 Choose var Y domain {1,2} CSC5240 - Finite Constraint Domains

  24. Backtracking Solve - 2 CSC5240 - Finite Constraint Domains

  25. Backtracking Solve - 2 partial_satisfiablefalse CSC5240 - Finite Constraint Domains

  26. Backtracking Solve - 2 Choose var Y domain {1,2} CSC5240 - Finite Constraint Domains

  27. Backtracking Solve - 2 Choose var Y domain {1,2} CSC5240 - Finite Constraint Domains

  28. Backtracking Solve - 2 CSC5240 - Finite Constraint Domains

  29. Backtracking Solve - 2 Choose var Z domain {1,2} CSC5240 - Finite Constraint Domains

  30. Backtracking Solve - 2 Choose var Z domain {1,2} CSC5240 - Finite Constraint Domains

  31. Backtracking Solve - 2 CSC5240 - Finite Constraint Domains

  32. Backtracking Solve - 2 No variables, and false CSC5240 - Finite Constraint Domains

  33. Backtracking Solve - 2 Choose var Z domain {1,2} CSC5240 - Finite Constraint Domains

  34. Backtracking Solve - 2 Choose var Z domain {1,2} CSC5240 - Finite Constraint Domains

  35. Backtracking Solve - 2 CSC5240 - Finite Constraint Domains

  36. Backtracking Solve - 2 No variables, and false CSC5240 - Finite Constraint Domains

  37. Backtracking Solve - 2 Choose var X domain {1,2} CSC5240 - Finite Constraint Domains

  38. Backtracking Solve - 2 Choose var X domain {1,2} CSC5240 - Finite Constraint Domains

  39. Backtracking Solve - 2 CSC5240 - Finite Constraint Domains

  40. Backtracking Solve - 2 Choose var Y domain {1,2} CSC5240 - Finite Constraint Domains

  41. Backtracking Solve - 2 CSC5240 - Finite Constraint Domains

  42. Backtracking Solve - 2 Choose var Y domain {1,2} CSC5240 - Finite Constraint Domains

  43. Backtracking Solve - 2 CSC5240 - Finite Constraint Domains

  44. Searching - 3 • Complexities of chronological backtracking • n: number of variables • e: the number of contraints • a: the size of the largest domain • b: the size of the largest constraint • Time complexity: O(aneb) • Space complexity: O(na+eb) CSC5240 - Finite Constraint Domains

  45. Search Space - 1 • Z={x,y,z}, D(x)={a,b,c,d}, D(y)={e,f,g}, D(Z)={p,q} CSC5240 - Finite Constraint Domains

  46. Search Space - 2 • Fixed variable ordering: x, y, z CSC5240 - Finite Constraint Domains

  47. Search Space - 3 • Fixed variable ordering: z, y, x CSC5240 - Finite Constraint Domains

  48. Characteristics of Search Space • The size of search space is finite • # of leaves: • # of internal nodes: • Variable ordering is important. Why??? • Problem still dominated by • The depth of the tree is fixed • The number of variables with ordering • Twice the number of variables without ordering CSC5240 - Finite Constraint Domains

  49. More Characteristics • Subtrees are similar • With fixed variable ordering, subtrees under each branch of the same level are identical in topology • Experience in searching one subtree may be useful in subsequently searching its siblings CSC5240 - Finite Constraint Domains

  50. Problem Reduction - 1 • Idea: transform a CSP into another which is hopefully easier to solve or recognizable as insoluble. For example: 3X1 + 4X2 = 5 3X1 + 4X2 = 5  4X1 - 2X2 = 7 11X1 = 19 CSC5240 - Finite Constraint Domains

More Related