CS 730/830: Intro AI CSPs 1 handout: slides asst 4 posted Wheeler Ruml (UNH) Lecture 8, CS 730 – 1 / 14
EOLQs CSPs Wheeler Ruml (UNH) Lecture 8, CS 730 – 2 / 14
CSPs ■ Other Problems ■ Types of Problems ■ UNH ■ Backtracking ■ Break ■ Forward Checking ■ ‘Heuristics’ ■ Example Results Constraint Satisfaction Problems ■ MAC ■ Other Algorithms ■ EOLQs Wheeler Ruml (UNH) Lecture 8, CS 730 – 3 / 14
Beyond Planning Map coloring: Given a map of n countries and a set of k CSPs colors, color every country differently from its neighbors. ■ Other Problems ■ Types of Problems n -queens : Given an n × n chessboard, arrange n queens so ■ UNH ■ Backtracking that none is attacking another. ■ Break configuration : Given d i options for each of the n components ■ Forward Checking ■ ‘Heuristics’ of a computer system (CPU, backplane, storage system, ■ Example Results NICs), find a set of options compatible with the choices the ■ MAC ■ Other Algorithms customer has already made. ■ EOLQs scheduling : Given a set of temporal constraints (eg, t 2 ≥ t 1 + 30 ), find a feasible set of times. What algorithm would you use? Wheeler Ruml (UNH) Lecture 8, CS 730 – 4 / 14
Types of Search Problems Shortest-path (vacuum, tile puzzle, M&C) ■ CSPs ■ Other Problems given operators and their costs ◆ ■ Types of Problems ■ UNH want least-cost path to a goal ◆ ■ Backtracking goal depth/cost unknown ◆ ■ Break ■ Forward Checking Decisions with an adversary (chess, tic-tac-toe) ■ ‘Heuristics’ ■ ■ Example Results ■ MAC adversary might prevent path to best goal ◆ ■ Other Algorithms want best assured outcome ◆ ■ EOLQs Constraint satisfaction (map coloring, n -queens) ■ any goal is fine ◆ fixed depth ◆ explicit constraints on partial solutions ◆ Wheeler Ruml (UNH) Lecture 8, CS 730 – 5 / 14
Gene Freuder: Father of Constraint Programming CSPs ■ Other Problems ■ Types of Problems ■ UNH ■ Backtracking ■ Break ■ Forward Checking ■ ‘Heuristics’ ■ Example Results ■ MAC ■ Other Algorithms ■ EOLQs Gene Freuder (UNH 1977?–2001) Wheeler Ruml (UNH) Lecture 8, CS 730 – 6 / 14
Chronological Backtracking Do not expand any partial solution that violates a constraint. CSPs ■ Other Problems ■ Types of Problems ■ UNH ■ Backtracking ■ Break ■ Forward Checking ■ ‘Heuristics’ ■ Example Results ■ MAC ■ Other Algorithms ■ EOLQs Wheeler Ruml (UNH) Lecture 8, CS 730 – 7 / 14
Break asst 3? control? games? ■ CSPs asst 4 ■ Other Problems ■ ■ Types of Problems projects ■ ■ UNH ■ Backtracking ■ Break ■ Forward Checking ■ ‘Heuristics’ ■ Example Results ■ MAC ■ Other Algorithms ■ EOLQs Wheeler Ruml (UNH) Lecture 8, CS 730 – 8 / 14
Forward Checking When assigning a variable, remove the conflicting values for all CSPs connected variables. Backtrack on domain wipeout. ■ Other Problems ■ Types of Problems ■ UNH ■ Backtracking Arc consistency: for every value in the domain of x , there exists ■ Break a value in the domain of y that satisfies all the constraints. ■ Forward Checking ■ ‘Heuristics’ ■ Example Results ■ MAC ■ Other Algorithms ■ EOLQs Wheeler Ruml (UNH) Lecture 8, CS 730 – 9 / 14
Heuristics for CSPs Variable choice: choose most constrained variable (smallest CSPs domain) ■ Other Problems ■ Types of Problems ■ UNH want to keep tree small, failing quickly ■ ■ Backtracking ■ Break Value choice: try least constraining value first (fewest ■ Forward Checking removals) ■ ‘Heuristics’ ■ Example Results ■ MAC might as well succeed sooner if possible ■ ■ Other Algorithms ■ EOLQs Wheeler Ruml (UNH) Lecture 8, CS 730 – 10 / 14
Example Results BT FC FC+MCV CSPs ■ Other Problems USA > 1 M 2K 60 ■ Types of Problems n-Queens > 40 M > 40 M 820K ■ UNH ■ Backtracking Zebra 3.9M 35K 500 ■ Break Random 1 420K 26K 2K ■ Forward Checking ■ ‘Heuristics’ Random 2 940K 77K 15K ■ Example Results ■ MAC ■ Other Algorithms ■ EOLQs Wheeler Ruml (UNH) Lecture 8, CS 730 – 11 / 14
Maintaining Arc Consistency Ensure every value for x has a legal value in all neighbors y . If CSPs one doesn’t, remove it and ensure consistency of all y . ■ Other Problems ■ Types of Problems ■ UNH ■ Backtracking ■ Break ■ Forward Checking ■ ‘Heuristics’ ■ Example Results ■ MAC ■ Other Algorithms ■ EOLQs Wheeler Ruml (UNH) Lecture 8, CS 730 – 12 / 14
Maintaining Arc Consistency Ensure every value for x has a legal value in all neighbors y . If CSPs one doesn’t, remove it and ensure consistency of all y . ■ Other Problems ■ Types of Problems ■ UNH while Q is not empty ■ Backtracking ( x, y ) ← pop Q ■ Break ■ Forward Checking if revised ( x, y ) then ■ ‘Heuristics’ ■ Example Results if x ’s domain is now empty, return failure ■ MAC for every other neighbor z of x ■ Other Algorithms ■ EOLQs push ( z, x ) on Q revise ( x, y ) revised ← false foreach v in x ’s domain if no value in domain of y is compatible with v remove v from x ’s domain revised ← true return revised Wheeler Ruml (UNH) Lecture 8, CS 730 – 12 / 14
Other Algorithms for CSPs (Conflict-directed) Backjumping ■ CSPs Dynamic backtracking ■ Other Problems ■ ■ Types of Problems Randomized restarting ■ ■ UNH ■ Backtracking ■ Break ■ Forward Checking Course projects! ■ ‘Heuristics’ ■ Example Results ■ MAC ■ Other Algorithms ■ EOLQs Wheeler Ruml (UNH) Lecture 8, CS 730 – 13 / 14
EOLQs Please write down the most pressing question you have about CSPs the course material covered so far and put it in the box on your ■ Other Problems ■ Types of Problems way out. ■ UNH ■ Backtracking ■ Break Thanks! ■ Forward Checking ■ ‘Heuristics’ ■ Example Results ■ MAC ■ Other Algorithms ■ EOLQs Wheeler Ruml (UNH) Lecture 8, CS 730 – 14 / 14
Recommend
More recommend