Você está na página 1de 3

AI-Unit2

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

Path --function GraphSearch(problem):


frontier = {[initial]}; explored = {}
loop:
if frontier is empty : return FAIL
path = remove_choice(frontier)
s = path.end; add s to explored
if s is a goal : return path
for a in actions:
add [path + a -> Result(s,a)]
to frontier
unless Result(s,a) in frontier + explored
Uniform-Cost Search (Cheavest-First)
*Explored
Frontier
Breadth-First

Cheapest-First

Depth-First

What is the optimal?... guaranty the optimal goal


* Breadth-First
* Cheapest-First
Breadth-First
Pgina 1

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 ...

Greedy Best-First Search


Start -----------------------------------------> Goal
A* Search
f = g + h
g(path) = path cost
h(path) = h(state) = estimated distance to goal
(s)___________________(x)--------------------------->(g)
g
A*
h = straight line distance
f = g + h
A* finds lowest cost path if:
- h(s) < True Cost
- h never overestimate
- h optimistic
- h admissable
Optimistic "h" finds lowest-cost path
f = g + h
Pgina 2

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

Você também pode gostar