1 / 21

Constraint Satisfaction & Knowledge Representation

Constraint Satisfaction & Knowledge Representation. Outline. Constraint Satisfaction Problems (CSP) Knowledge Representation in Prolog Backtracking search for CSPs. Constraint satisfaction problems (CSPs). Standard search problem: state goal test successor function CSP:

kedma
Télécharger la présentation

Constraint Satisfaction & Knowledge Representation

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 Satisfaction & Knowledge Representation CS 3243 - Constraint Satisfaction

  2. Outline • Constraint Satisfaction Problems (CSP) • Knowledge Representation in Prolog • Backtracking search for CSPs CS 3243 - Constraint Satisfaction

  3. Constraint satisfaction problems (CSPs) • Standard search problem: • state • goal test • successor function • 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 • Simple example of a formal representation language • Allows useful general-purpose algorithms with more power than standard search algorithms CS 3243 - Constraint Satisfaction

  4. Example: Map-Coloring • Variables? • Domains? • Constraints? CS 3243 - Constraint Satisfaction

  5. Example: Map-Coloring • Solutions are complete and consistent assignments CS 3243 - Constraint Satisfaction

  6. Constraint graph • Binary CSP: each constraint relates two variables • Constraint graph: nodes are variables, arcs are constraints CS 3243 - Constraint Satisfaction

  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 CS 3243 - Constraint Satisfaction

  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 CS 3243 - Constraint Satisfaction

  9. Example: Cryptarithmetic • Variables: F T U W R O X1 X2 X3 • Domains: {0,1,2,3,4,5,6,7,8,9} • Constraints: Alldiff (F,T,U,W,R,O) • O + O = R + 10 · X1 • X1 + W + W = U + 10 · X2 • X2 + T + T = O + 10 · X3 • X3 = F, T ≠ 0, F≠ 0 CS 3243 - Constraint Satisfaction

  10. Knowledge Representation • How you choose to represent the world • Often bound by the software you want to use • Prolog predicates • Logic problem, 8-queens problem, farmer problem CS 3243 - Constraint Satisfaction

  11. Real-world CSPs • Assignment problems • e.g., who teaches what class • Timetabling problems • e.g., which class is offered when and where? • Transportation scheduling • Factory scheduling • Notice that many real-world problems involve real-valued variables CS 3243 - Constraint Satisfaction

  12. Backtracking search • Variable assignments are commutative • Only need to consider assignments to a single variable at each node  branching factor = d and there are dn leaves • Depth-first search for CSPs with single-variable assignments is called backtracking search • Backtracking search is the basic uninformed algorithm for CSPs CS 3243 - Constraint Satisfaction

  13. Backtracking example CS 3243 - Constraint Satisfaction

  14. Backtracking example CS 3243 - Constraint Satisfaction

  15. Backtracking example CS 3243 - Constraint Satisfaction

  16. Backtracking example CS 3243 - Constraint Satisfaction

  17. Improving backtracking efficiency • General-purpose methods can give huge gains in speed: • Which variable should be assigned next? • In what order should its values be tried? • Can we detect inevitable failure early? CS 3243 - Constraint Satisfaction

  18. Minimum-Remaining-Values • MRV: choose the variable with the fewest legal values CS 3243 - Constraint Satisfaction

  19. Degree Heuristic • Tie-breaker among most constrained variables • Degree Heuristic: • choose the variable with the most constraints on remaining variables CS 3243 - Constraint Satisfaction

  20. Least constraining value • Given a variable, choose the least constraining value: • the one that rules out the fewest values in the remaining variables • Combining these heuristics makes 1000 queens feasible CS 3243 - Constraint Satisfaction

  21. Summary • CSPs are a special kind of problem: • states defined by values of a fixed set of variables • goal test defined by constraints on variable values • Backtracking = depth-first search with one variable assigned per node • Prolog does this naturally • Variable ordering and value selection heuristics help significantly CS 3243 - Constraint Satisfaction

More Related