1 / 44

CS3243: Introduction to Artificial Intelligence

CS3243: Introduction to Artificial Intelligence. Semester 2, 2017/2018. Previously…. Minimax algorithm What if MIN plays sub-optimally and MAX plays MINIMAX strategy? Generalize to non-zero-sum, multi-player game? See section 5.2.2 of AIMA 3rd Ed. - pruning algorithm

tjohn
Download Presentation

CS3243: Introduction to Artificial Intelligence

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. CS3243: Introduction to Artificial Intelligence Semester 2, 2017/2018

  2. Previously… • Minimax algorithm • What if MIN plays sub-optimally and MAX plays MINIMAX strategy? • Generalize to non-zero-sum, multi-player game?See section 5.2.2 of AIMA 3rd Ed. • - pruning algorithm • Prune subtrees that won’t affect minimax decision • -Minimax algorithm • Use heuristic functions and impose depth limit • Expected Minimax algorithm • Solve stochastic games

  3. Constraint Satisfaction Problems AIMA Chapter 6.1 – 6.4

  4. Outline • Constraintsatisfaction problems (CSPs) • Backtracking search for CSPs • Local consistency in constraint propagation • Local search for CSPs

  5. Constraint Satisfaction Problems (CSPs) • Standard search problem: • state is atomic – any data structure that supports transition function, heuristic function, and goal test • CSP • Variables ; each variable has a domain • Constraints : what variable combinations are allowed? • Constraint scope: which variables are involved • Constraint relation: what is the relation between them. • Objective: find a legal assignment of values to variables • for all • Constraints are all satisfied.

  6. CSP: a Broad Modelling Framework

  7. Example: Graph Coloring

  8. Example: Graph Coloring • Find a complete, consistent assignment • Complete: all variables are set • Consistent: no constraint is violated

  9. Constraint Graph • Binary CSP: each constraint relates two variables • Constraint graph: nodes are variables, links are constraints

  10. Example: Job-Shop Scheduling • Car assembly consists of 15 tasks • Variables: ,,,,,,,,,,, , , , • Domain: • Precedenceconstraints • e.g., • Disjunctive constraint • e.g.,

  11. CSP Variants

  12. Constraint Variants

  13. Cryptarithmetic Puzzles

  14. Sudoku

  15. Standard Search Formulation (Incremental) • Each state is a partial variable assignment • Initial state: the empty assignment • Transition function: assign a valid value to an unassigned variable  fail if no valid assignments • Goal test: all variables have been assigned. • Uniform model for all CSPs; not domain-specific. • Every solution appears at depth (variables assigned) • Search path is irrelevant, can also use complete-state formulation. What’s the best search technique?

  16. CSP Search Tree Size … … … … at depth = variables values states at depth = variables values states at depth = variables values states at depth =variable values states At depth : Total number of leaves =

  17. Backtracking Search

  18. Backtracking Search

  19. Backtracking Example Assign variables in the order of WA, NT, Q, …

  20. Improving Backtracking Efficiency • General-purpose heuristics can give huge time gains: • Select-Unassigned-Variable: Which variable should be assigned next? • Order-Domain-Values: In what order should its values be tried? • Inference: How can domain reductions on unassigned variables be inferred? • Can we detect inevitable failure early?

  21. Most Constrained Variable • Most constrained variable: • choose the variable with fewest legal values • a.k.a. minimum-remaining-values (MRV)heuristic

  22. Most Constraining Variable • Most constraining variable: • choose the variable with most constraints on remaining unassigned variables • Tie-breaker among most constrained variables • a.k.a. degree heuristic

  23. Least Constraining Value • Given a variable, choose the least constraining value: • the one that rules out the fewest values for neighboring unassigned variables

  24. Forward Checking Idea: • Keep track of remaining legal values for unassigned variables • Terminate search when any variable has no legal values

  25. Forward Checking Idea: • Keep track of remaining legal values for unassigned variables • Terminate search when any variable has no legal values

  26. Forward Checking Idea: • Keep track of remaining legal values for unassigned variables • Terminate search when any variable has no legal values

  27. Forward Checking Idea: • Keep track of remaining legal values for unassigned variables • Terminate search when any variable has no legal values

  28. Constraint Propagation • Problem: Forward checking propagates information from assigned to unassigned variables, but doesn't provide early detection for all failures: • NT and SA cannot both be blue! • Solution: Constraint propagation repeatedly locally enforces constraints.

  29. Inference in CSPs Searching Constraint Propagation

  30. Arc Consistency • Simplest form of propagation makes each arc consistent • is arc-consistent wrt (the arc is consistent) iff for every value there exists some value that satisfies the binary constraint on the arc

  31. More on Arc Consistency • Arc consistency is based on a very simple conceptIf by looking at just one constraint we see thatis impossible, we can remove the valuefrom consideration! • How do we know that a value is impossible? • If the constraint provides no support for the value • E.g. and we have ; then is impossible.

  32. Arc Consistency • Simplest form of propagation makes each arc consistent • is arc-consistent wrt (the arc is consistent) iff for every value there exists some value that satisfies the binary constraint on the arc • Arcs are directed, a binary constraint becomes two arcs • Arc is originally not consistent, but is consistent after deleting blue

  33. Arc Consistency • Simplest form of propagation makes each arc consistent • is arc-consistent wrt (the arc is consistent) iff for every value there exists some value that satisfies the binary constraint on the arc • If loses a value, neighbors of need to be (re)checked • Arc is originally not consistent, but is consistent after deleting red

  34. Arc Consistency Propagation • Reducing may result in domain reductions for other variables. • E.g. , , • Constraints: , • As before we can remove from , so • But now there is no support for • We can remove those values: • Before applying AC to arc , we cannot reduce • This can cause a chain reaction

  35. Sudoku Chain Reaction • constraint on middle box makes domain of redsquare . Column constraint reduces domain to . • Consider orangesquare. Original column and box constraints yield domain of . Red square forces . • Bluebox must be as column already has eight values.

  36. Arc Consistency • Simplest form of propagation makes each arc consistent • is arc-consistent wrt (the arc is consistent) iff for every value there exists some value that satisfies the binary constraint on the arc • Arc consistency propagation detects failure earlier than forward checking • Can be run as a preprocessing step or after each assignment

  37. Arc Consistency Algorithm AC-3 Time complexity:

  38. Time Complexity of AC-3 • CSP has at most directed arcs • Each arc can be inserted at most times because has at most values to delete. • Revise: Checking the consistency of an arc takes time

  39. Maintaining AC (MAC) • Like any other propagation, we can use AC in search • i.e., search proceeds as follows: • establish AC at the root • when AC-3 terminates, choose a new variable/value • re-establish AC given the new variable choice (i.e. maintain AC) • repeat; • backtrack if AC givesempty domain • Exception: initially, insert into queue only arcs of neighboring unassigned variables/nodes • The hard part of implementation is undoing effects of AC

  40. Special Types of Consistency • Some types of constraints lend themselves to special types of arc-consistency • Consider the constraint • the named variables must all take different values • not a binary constraint • can be expressed as not-equal binary constraints • We can apply, e.g., AC-3 as usual • But there is a much better option

  41. Generalized Arc Consistency and -Consistency • Suppose and . • The constraints are arc-consistent • e.g., supports the value • The single ternary constraint is not! • We must reduce . • A special-purpose algorithm exists for Alldiff constraint to establish generalized arc consistency in efficient time • Special-purpose propagation algorithms are vital • Arc Consistency (2-consistency) can be extended to k-consistency

  42. Local Search for CSPs • Hill-climbing, simulated annealing typically work with “complete” states, i.e., all variables assigned • To apply to CSPs: • allow states that violate constraints • operators reassign variable values • Variable selection: randomly select any conflicted variable • Value selection by min-conflicts heuristic: • choose value that violates the fewest constraints • i.e., hill-climb with = total # of violated constraints

  43. Min-Conflicts

  44. Example: 4-Queens • States: queens in columns ( states) • Actions: move queen in column • Goal test: no attacks • Evaluation: = number of attacks • Given random initial state, can solve -queens in almost constant time for arbitrary with high probability (e.g., )

More Related