Escolar Documentos
Profissional Documentos
Cultura Documentos
Problem Solving
Definition of a problem
- Initial state (s)
- Actions (s) -> {a1, a2, a3, ...}, a (action)
- Result (s,a) -> s^1
- GoalTest (s) -> Boolean Value (T, F)
- PathCost (s -(action)> s -(action)> s) -> n (Number)
- StepCost (s, a, s^1) -> n (Number)
Explored | Frontier | Unexplored
Tree Search
Fuction TreeSearch(problem):
frontier = {[initial]}
loop:
if frontier is empty : return FAIL
path = remove_choice(frontier)
s = path.end
if s is a goal : return path
for a in actions:
add [path + a -> Result(s,a)]
to frontier
Breadth-First Search
Initial state A
|----Z
|---O
|
|
A---|----S---|---F
|
|
|----T
|---R---|
|
|---A
|---U
|---P---B---|
|---G
|---C
Cheapest-First
Depth-First
AI-Unit2
1
2
|0--|
|
|
3
...
|--0 ...
|--0 ...
0---|
... Goal
|
|
|0--|
|--0 ...
|--0 ...
Cheapest-First
1
3
...
|--0 ...
|0--|
|
|
|--0 ...
0---|
... Goal
|
|
|0--|
|--0 ...
|--0 ...
Depth-First
1
3
...
|--0 ...
|0--|
|
|
|--0 ...
0---|
... Goal
|
|
|0--|
|--0 ...
|--0 ...
AI-Unit2
h(s) < true cost s->g
Other State Spaces
Robot cleaning the dirty floor
A
B
Number of states
2*2*2 = 8 posible states
2 state A & B
2 posibilities of state A
2 posibilities of state B
Robot actions
-Light On/Off/Sleep
-Camera On/Off
-Brush Height 1/2/3/4/5
-Posibilities 2
-Positions 10
3*2*5*2^10*10
Number of States: 307,200
Sliding Blocks Puzzle (15 Puzzle)
h1 = #misplaced blocks
h2 = sum(distances of blocks)
a block can move A -> B if (A adjacent to B) and (B is blank)
h2 h1
h = max(h1, h2)
(0)-------->(0)-------->(0)
(0)-------------------->(0)
Problem-Solving works when:
-Fully Observable
-Known
-Discrete
-Deterministic
-Static
A -> S -> F
(Explored)
state
F
action SF
cost
234
parent
|
|
state
S
action
cost
parent
|
|
state
A
action
cost
parent Not
(Frontier)
Pgina 3