Artificial Intelligence - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Artificial Intelligence

Description:

Arc consistency. The arc Xi Xj is consistent if for every value of Xj there exists some valid ... using the min-conflicts heuristic: Select the value that ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 32
Provided by: HH3
Category:

less

Transcript and Presenter's Notes

Title: Artificial Intelligence


1
Artificial Intelligence
  • Constraint satisfaction
  • Chapter 5, AIMA

2
Constraint Satisfaction Problem (CSP)
  • A set X X1,X2,...,Xn of variables
  • Each variable Xi has a nonempty domain Di
    v1,v2,...,vk(i) of possible values
  • A set C C1,C2,...,Cm of constraints
  • A solution is a complete assignment of values for
    the variables, which satisfies all the
    constraints.
  • Examples Map coloring, scheduling, logistics
    (transportation), N-queens, crossword puzzles,...

3
Map coloring
(Image borrowed from V. Pavlovic)
  • X WA, NT, Q, NSW, V, SA, T
  • D R,G,B (for all variables)
  • C WA ? NT, WA ? SA, NT ? SA, NT ? Q, SA ? Q,
    SA ? NSW, SA ? V, Q ? NSW, NSW ? V
    (Neighboring regions must have different colors)
  • Goal All regions must have a color

4
Map coloring
  • CSP can be visualized with constraint graph
  • Nodes variables
  • Arcs constraints

5
Types of constraints
  • Unary Xi ? vj
  • Binary Xi ? Xj
  • Higher order
  • Preferences

6
CSP cast as a search problem
  • Depth-first search (depth limit n)?
    Backtracking search
  • Initial state
  • Successor function
  • Goal test
  • Path cost (not relevant)

Very inefficient
7
Vanilla backtracking
NT
Q
WA
NSW
SA
V
Q
Animation adapted from V. Pavlovic
8
Improve vanilla Backtracking
  • Smart choice of next variable- Min. remaining
    values ( degree heuristic)- Least constraining
    value
  • Check consequences of choice- Forward checking-
    Arc consistency
  • Intelligent backtracking- Backjumping

9
Minimum remaining values
Choose next the variable that is most constrained
based on current assignment ( choose the one
with the highest degree first in ties)
NT
Q
WA
NSW
SA
V
T
Animation adapted from V. Pavlovic
10
Least constraining value
Select the value that least constrains the other
variables (rules our fewest other variables)
Image borrowed from V. Pavlovic
11
Forward checking
Delete values that are inconsistent with the last
selection
Stop search early, if necessary
Animation adapted from V. Pavlovic
12
Arc consistency
  • The arc Xi ? Xj is consistent if for every value
    of Xj there exists some valid value of Xi.
  • Detects failures sooner than forward checking.
  • Use as preprocessor or as check after each move
    (MAC)

Animation adapted from V. Pavlovic
13
4-queens
7888894 0q064 0 64 0 640q0 6122223
q1
q3
q2
q4
  • X q1, q2, q3, q4 (qi queen in column i)
  • D 1,2,3,4 (row for queen)
  • C No queen may attack another queen
  • Goal Place all queens on the board

14
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • F

Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
15
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
16
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
17
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
18
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
19
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
20
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
21
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
q4
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
22
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
23
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
24
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
25
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 1

7888894q0 0640 0 64 0 0640 0 6122223
The arc (i,j) is consistent if each value at the
tail jof the arc has at least one value at the
head i thatdoes not violate the constraints.
? No solution with q1 1
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
26
Arc consistency 4-queens
  • qi queen placed in column i
  • 1,2,3,4 The allowed values (row number) for
    the queen.
  • First move q1 2

7888894 0q064 0 64 0 640q0 6122223
Arc consistency (constraint propagation) finds
thesolution
Example from N.J. Nilsson, Artificial
Intelligence A New Synthesis, 1998
27
Local search Simple and efficient
  • Start with initial (invalid) state
  • Modify this state, using the min-conflicts
    heuristic Select the value that minimizes the
    number of conflicts
  • Continue until a solution is found

28
Local search 4-queens
7888894 0 064 0 64 0q0640q0q6122223
7888894 0 64 0 64 0q0640q0 6122223
7888894 0q64 0 64 0 0640q0 6122223
7888894 0q064 0 64 0 640q0 6122223
Stuck!
Choose random movethat does not
increaseconflicts.
Solution in three moves!
29
Map coloring Australia
  • Using Java code _at_ AIMA site, calling from within
    MATLAB.
  • Backtracking 1.5 sec

7 variables (countries) 9 constraints 3 values
(R,G,B)
30
Map coloring Africa
49 variables (countries) 107 constraints 4 values
(R,G,B,Y)
31
Map coloring Africa
  • Modified the AIMA Java code, calling from within
    MATLAB.
  • Backtracking 5.5 min
Write a Comment
User Comments (0)
About PowerShow.com