Presentation is loading. Please wait.

Presentation is loading. Please wait.

University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture.

Similar presentations


Presentation on theme: "University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture."— Presentation transcript:

1 University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture 4

2 University College Cork (Ireland) Department of Civil and Environmental Engineering Today’s class o Constraint satisfaction problems (CSP) R. Marinescu October-2009page 2

3 University College Cork (Ireland) Department of Civil and Environmental Engineering Each row, column and major block must be alldifferent “Well posed” if it has unique solution: 27 constraints 2 3 4 6 2 Constraint propagation Variables: 81 slots Domains = {1,2,3,4,5,6,7,8,9} Constraints: 27 not-equal Sudoku

4 University College Cork (Ireland) Department of Civil and Environmental Engineering Sudoku Each row, column and major block must be alldifferent “Well posed” if it has unique solution: 27 constraints

5 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint satisfaction problems o CSP state – is defined by variable X i with values from domain D i goal test – is a set of constraints specifying allowable combinations of values for subsets of variables o Applications for CSPs Scheduling tasks (transportation, maintenance) Robot planning tasks Puzzles Tail-Gate assignment (airports) Radio-link frequency assignment (telecom) … R. Marinescu October-2009page 5

6 University College Cork (Ireland) Department of Civil and Environmental Engineering Example: map coloring o variables: WA, NT, Q, SA, NSW, V, T o domains: Di = {red, green, blue} o constraints: adjacent regions must have different colors e.g., WA ≠ NT or (WA, NT) in {( red, green ), ( red, blue ), ( green, red ), ( green, blue ), ( blue, red ), ( blue, green )} R. Marinescu October-2009page 6

7 University College Cork (Ireland) Department of Civil and Environmental Engineering Example: map coloring o Solutions are complete and consistent assignments E.g., WA = red, NT = green, SA = blue, Q = red, NSW = green, V = red, T = green R. Marinescu October-2009page 7

8 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint graph R. Marinescu October-2009page 8 Binary CSP variable V i with values in domain D i General class of problems: Unary constraint arc Binary constraint arc (Unary constraint just cut down domains) This diagram is called a constraint graph

9 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint graph R. Marinescu October-2009page 9 Binary CSP variable V i with values in domain D i General class of problems: Unary constraint arc Binary constraint arc (Unary constraint just cut down domains) This diagram is called a constraint graph Basic problem: Find d j in D i for each V i s.t. all constraints satisfied (finding consistent labeling for variables)

10 University College Cork (Ireland) Department of Civil and Environmental Engineering N-Queens as CSP R. Marinescu October-2009page 10 1Q 2Q 3Q 4Q 1234 Place N queens on an NxN chessboard so that none can attack the other Classic “benchmark” problem Variables Domains Constraints are board positions in NxN chessboard Queen or blank Two positions on a line (vertical, horizontal, diagonal) cannot both be Q

11 University College Cork (Ireland) Department of Civil and Environmental Engineering Scheduling as CSP R. Marinescu October-2009page 11 Choose time for activities e.g., observations on Hubble telescope, or terms to take required classes 5 4 3 2 1 time activity Variables Domains Constraints are activities sets of start times (or “chunks” of time) 1. Activities that use the same resource cannot overlap in time 2. Preconditions satisfied

12 University College Cork (Ireland) Department of Civil and Environmental Engineering 3-SAT as CSP R. Marinescu October-2009page 12 Variables Domains Constraints clauses Boolean variable assignments that make clauses true Clauses with shared Boolean variables must agree on value of variables Find values for Boolean variables A, B, C, … that satisfy the formula The original NP-complete problem

13 University College Cork (Ireland) Department of Civil and Environmental Engineering Varieties of CSPs o Discrete variables Finite domains  n variables, domain size d → O(d n ) complete assignments  E.g., map coloring, n-queens, … Infinite domains  Integers, strings  E.g., job scheduling (variables are start/end days of each job) o Continuous variables Usually, the domain of the variables are real numbers R. Marinescu October-2009page 13

14 University College Cork (Ireland) Department of Civil and Environmental Engineering Varieties of constraints o Unary constraints involve one variable E.g., SA ≠ green o Binary constraints involve pairs of variables E.g., SA ≠ WA o Higher-order constraints involve 3 or more variables E.g., crypt-arithmetic column constraints (see next) R. Marinescu October-2009page 14

15 University College Cork (Ireland) Department of Civil and Environmental Engineering Example: crypt-arithmetic puzzle R. Marinescu October-2009page 15 Variables Domains Constraints F T U O R W X 1 X 2 X 3 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} AllDiff(F, T, U, O, R, W) O + O = R + 10∙X 1 X 1 + W + W = U + 10∙X 2 X 2 + T + T = O + 10∙X 3 X 3 = F F ≠ 0 T ≠ 0

16 University College Cork (Ireland) Department of Civil and Environmental Engineering Good news / Bad news o Good news – very general & interesting class problems o Bad news – includes NP-hard (intractable) problems So, good behavior is a function of domain not the formulation as a CSP R. Marinescu October-2009page 16

17 University College Cork (Ireland) Department of Civil and Environmental Engineering CSP example Given 40 courses (8.01, 8.02, …, 6.840) and 10 terms (Fall 1, Spring 1,,,, Spring 5). Find a legal schedule Constraints Pre-requisites Courses offered on limited terms Limited number of courses per term Avoid time conflicts Note: CSPs are not for expressing (soft) preferences, e.g. minimize difficulty, balance subject areas, etc R. Marinescu October-2009page 17

18 University College Cork (Ireland) Department of Civil and Environmental Engineering Choice of variables & values VARIABLESDOMAINS R. Marinescu October-2009page 18 A. Terms? Legal combinations of for example 4 courses (but this is huge set of values) B. Terms Slots? Courses offered during that term Subdivide terms into slots e.g. 4 of them (Fall 1,1) (Fall 1,2) (Fall 1,3) C. Courses? Terms or term slots (Term slots allow expressing constraints on limited number of courses/term)

19 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraints R. Marinescu October-2009page 19 Use courses as variables and term slots as values Prerequisite > 6.0016.034 Term before Term after For pairs of courses that must be ordered Courses offered only in some terms > Filter domain Avoid time conflicts> 6.0016.034 Term not equal For pairs offered at same or overlapping times

20 University College Cork (Ireland) Department of Civil and Environmental Engineering Solving CSPs o Solving CSPs involve some combination of: Constraint propagation, to eliminate values that could not be part of any solution Search, to explore valid assignments R. Marinescu October-2009page 20

21 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation (aka Arc Consistency) o Arc consistency eliminates values from domain of variable that can never be part of a consistent solution o Directed arc (V i, V j ) is arc consistent if R. Marinescu October-2009page 21

22 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation (aka Arc Consistency) o Arc consistency eliminates values from domain of variable that can never be part of a consistent solution o Directed arc (V i, V j ) is arc consistent if o We can achieve consistency on arc by deleting values from D i (domain of variable at tail of constraint arc) that fail condition R. Marinescu October-2009page 22

23 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation (aka Arc Consistency) o Arc consistency eliminates values from domain of variable that can never be part of a consistent solution o Directed arc (V i, V j ) is arc consistent if o We can achieve consistency on arc by deleting values from D i (domain of variable at tail of constraint arc) that fail condition o Assume domain size at most d and there are e binary constraints o A simple algorithm for arc consistency is O(ed 3 ) – note that just verifying arc consistency takes O(ed 2 ) for each arc R. Marinescu October-2009page 23

24 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 24 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint

25 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 25 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted R, G, B R, GG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

26 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 26 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none R, G, B R, GG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

27 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 27 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) R, B R, GG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

28 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 28 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) V 2 – V 3 V2(G)V2(G) R, B RG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

29 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 29 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) V 2 – V 3 V2(G)V2(G) V 1 – V 2 V1(R)V1(R) B RG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

30 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 30 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) V 2 – V 3 V2(G)V2(G) V 1 – V 2 V1(R)V1(R) V 1 – V 3 none B RG V1V1 V2V2 V3V3 Each undirected arc is really two directed constraint arcs, the effects shown above are from examining BOTH arcs.

31 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint propagation example R. Marinescu October-2009page 31 Graph coloring initial domains are indicated R, G, B R, GG V1V1 V2V2 V3V3 different-color constraint Arc examinedValue deleted V 1 – V 2 none V 1 – V 3 V1(G)V1(G) V 2 – V 3 V2(G)V2(G) V 1 – V 2 V1(R)V1(R) V 1 – V 3 none V 2 – V 3 none B RG V1V1 V2V2 V3V3 CSP is arc-consistent

32 University College Cork (Ireland) Department of Civil and Environmental Engineering But, arc consistency is not enough in general R. Marinescu October-2009page 32 R, G arc consistent but no solutions Graph coloring

33 University College Cork (Ireland) Department of Civil and Environmental Engineering But, arc consistency is not enough in general R. Marinescu October-2009page 33 R, G arc consistent but no solutions Graph coloring B, G R, G arc consistent but 2 solutions: B,R,G; B,G,R

34 University College Cork (Ireland) Department of Civil and Environmental Engineering But, arc consistency is not enough in general R. Marinescu October-2009page 34 R, G arc consistent but no solutions Graph coloring B, G R, G arc consistent but 2 solutions: B,R,G; B,G,R B, G R, G arc consistent but 1 solutions: B,R,G; Assume B, R not allowed

35 University College Cork (Ireland) Department of Civil and Environmental Engineering But, arc consistency is not enough in general R. Marinescu October-2009page 35 R, G arc consistent but no solutions Graph coloring B, G R, G arc consistent but 2 solutions: B,R,G; B,G,R B, G R, G arc consistent but 1 solutions: B,R,G; Assume B, R not allowed Need to search to find solutions (if any)

36 University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) o Standard search formulation Initial state : the empty assignment {} Successor function : assign a value to an unassigned variable that does not conflict with the current assignment  fail is no legal assignments Goal test : the current assignment is complete 1.This is the same for all CSPs 2.Every solution appears at depth n (for n variables) 3.Path is irrelevant 4.Depth-first search for CSPs is called backtracking 5.Variable assignments are commutative (e.g., [WA=red then NT=blue] is the same as [NT=blue then WA=red] R. Marinescu October-2009page 36

37 University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 37 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3

38 University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 38 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 Inconsistent with V 1 = R Backup at inconsistent assignment

39 University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 39 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 Inconsistent with V 1 = R Backup at inconsistent assignment

40 University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 40 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 Inconsistent with V 1 = R Backup at inconsistent assignment Inconsistent with V 2 = G

41 University College Cork (Ireland) Department of Civil and Environmental Engineering Searching for solutions – backtracking (BT) R. Marinescu October-2009page 41 When we have too many values in domain (and/or constraints are weak) arc consistency doesn’t do much, so we need to search. Simplest approach is pure backtracking (depth-first search) R G B RG RG RG RG RG RG RG V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 Inconsistent with V 1 = R Backup at inconsistent assignment Inconsistent with V 2 = G consistent

42 University College Cork (Ireland) Department of Civil and Environmental Engineering Combine backtracking and constraint propagation o A node in BT tree is partial assignment in which the domain of each variable has been set (tentatively) to singleton set o Use constraint propagation (arc-consistency) to propagate the effect of this tentative assignment i.e., eliminate values inconsistent with current values R. Marinescu October-2009page 42

43 University College Cork (Ireland) Department of Civil and Environmental Engineering Combine backtracking and constraint propagation o A node in BT tree is partial assignment in which the domain of each variable has been set (tentatively) to singleton set o Use constraint propagation (arc-consistency) to propagate the effect of this tentative assignment i.e., eliminate values inconsistent with current values o Question: how much propagation to do? R. Marinescu October-2009page 43

44 University College Cork (Ireland) Department of Civil and Environmental Engineering Combine backtracking and constraint propagation o A node in BT tree is partial assignment in which the domain of each variable has been set (tentatively) to singleton set o Use constraint propagation (arc-consistency) to propagate the effect of this tentative assignment i.e., eliminate values inconsistent with current values o Question: how much propagation to do? o Answer: not much, just local propagations from domains with unique assignments, which is called forward checking (FC). This conclusion is not necessarily obvious, but it generally holds in practice R. Marinescu October-2009page 44

45 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 45 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph R V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3

46 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 46 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph R V 1 assignments V 2 assignments V 3 assignments R GG V1V1 V2V2 V3V3 G

47 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 47 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph R V 1 assignments V 2 assignments V 3 assignments R G V1V1 V2V2 V3V3 G We have a conflict whenever a domain becomes empty

48 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 48 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments When backing up, need to restore domain values, since deletions were done to reach consistency with tentative assignments considered during search G R, G, B R, G V1V1 V2V2 V3V3

49 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 49 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments G G RR V1V1 V2V2 V3V3

50 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 50 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments G G RR V1V1 V2V2 V3V3 R

51 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 51 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments G G RR V1V1 V2V2 V3V3 R

52 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 52 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments R, G, B R, G V1V1 V2V2 V3V3 B

53 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 53 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B R, G V1V1 V2V2 V3V3 B R

54 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 54 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B RG V1V1 V2V2 V3V3 B R

55 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 55 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B RG V1V1 V2V2 V3V3 B R G

56 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 56 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B GR V1V1 V2V2 V3V3 B G R

57 University College Cork (Ireland) Department of Civil and Environmental Engineering Backtracking with forward checking (BT-FC) R. Marinescu October-2009page 57 When examining assignment V i = d k, remove any values inconsistent with that assignment From neighboring domains in the constraint graph V 1 assignments V 2 assignments V 3 assignments B GR V1V1 V2V2 V3V3 B G R No need to check previous assignments Generally preferable to pure BT

58 University College Cork (Ireland) Department of Civil and Environmental Engineering BT-FC with dynamic ordering o Traditional backtracking uses fixed ordering of variables & values, e.g., random order or place variables with many constraints first o We can usually do better by choosing an order dynamically as the search proceeds R. Marinescu October-2009page 58

59 University College Cork (Ireland) Department of Civil and Environmental Engineering BT-FC with dynamic ordering o Traditional backtracking uses fixed ordering of variables & values, e.g., random order or place variables with many constraints first o We can usually do better by choosing an order dynamically as the search proceeds 1. Most constrained variable When doing forward-checking, pick variable with fewest legal values to assign next (minimizes branching factor) R. Marinescu October-2009page 59

60 University College Cork (Ireland) Department of Civil and Environmental Engineering BT-FC with dynamic ordering o Traditional backtracking uses fixed ordering of variables & values, e.g., random order or place variables with many constraints first o We can usually do better by choosing an order dynamically as the search proceeds 1. Most constrained variable When doing forward-checking, pick variable with fewest legal values to assign next (minimizes branching factor) 2. Least constraining value Choose value that rules out the fewest values from neighboring domains R. Marinescu October-2009page 60

61 University College Cork (Ireland) Department of Civil and Environmental Engineering Constraint optimization problems o COP formulation Variables: X 1, X 2, …, X n with domains D 1, D 2, …, D n Constraints: C 1, C 2, …, C m Objective function: f(X 1, …, X n ) o Goal: find a solution that satisfies all constraints and minimizes the objective function o Example Maintenance scheduling in smart buildings: schedule a set of maintenance tasks (eg, clean rooms, repair outlet) such that there is no overlap between tasks and the sum of costs is minimized o Solution techniques Depth-first Branch-and-Bound search R. Marinescu October-2009page 61

62 University College Cork (Ireland) Department of Civil and Environmental Engineering Local search o In many problems, the path to the goal is irrelevant; the goal state itself is the solution o State space = set of "complete" configurations o Find configuration satisfying constraints, e.g., n- queens o In such cases, we can use local search algorithms which keep a single "current" state, try to improve it o Constant space. Good for offline and online search R. Marinescu October-2009page 62

63 University College Cork (Ireland) Department of Civil and Environmental Engineering Local search for CSPs o Hill-climbing, simulated annealing typically work with “complete” states, i.e., all variables assigned o Apply to CSPs Allow states with unsatisfied constraints Operators reassign variable values Variable selection  Randomly select any conflicted variable Value selection by min-conflict heuristic  Choose value that violates the fewest constraints  i.e., hill climbing: h(n) = total number of violated constraints R. Marinescu October-2009page 63

64 University College Cork (Ireland) Department of Civil and Environmental Engineering Example: 4-Queens problem o States: 4 queens in 4 columns (4 4 = 256 states) o Actions: move queen to column o Goal test: no attacks o Evaluation: h(n) = number of attacks o Given random initial state, can solve n-queens in almost constant time for arbitrary n with high probability (e.g., n = 10,000,000) R. Marinescu October-2009page 64

65 University College Cork (Ireland) Department of Civil and Environmental Engineering Summary o 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 o Backtracking = depth-first search with one variable assigned per node o Variable ordering and value selection heuristics help significantly o Forward checking prevents assignments that guarantee later failure o Constraint propagation (e.g., arc consistency) does additional work to constrain values and detect inconsistencies R. Marinescu October-2009page 65


Download ppt "University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture."

Similar presentations


Ads by Google