Sie sind auf Seite 1von 55

Introduction to

Artificial Intelligence
Lecture 1 Problem Solving A*

Fall 2015
fang.liu@hust.edu.

Outline - Lecture 02
Problem Solving
Search
Graph Search - Review
Heuristic Search

State Space
Discussion: Where is the intelligence in searching

Problem Solving
Introduction to Artificial Intelligence

Problem Solving

Given a map, to make correct decision at each step


Sequence of actions

Partially observable, to make decision


under uncertainty

Path Finding
Task of the agent is to find a Sequence of Action

Definition of a Problem

Initial State

ACTIONS(s) {a1, a2, }

RESULT(s, a) s

GOALTEST(s) F | T

PATHCOST(path) n

(s : state)
(s: new state)

State Space for Path Finding

Search
Introduction to Artificial Intelligence

BFS Breath First Search


Open:
Arad
Close:

BFS Breath First Search


Open: Zerind Sibiu
Timisoara
Close:
Arad
When node moves from Open to Close, it should be
Goal Tested first. If the node is the goal node, then the
algorithm should be terminated.

BFS Breath First Search


Open: Sibiu Timisoara
Oradea
Close: Arad Zerind

In this step, Zerind is expanded. Both Arad and Oradea


are its neighbors. However only Oradea is added in the
search tree cause Arad is already in the close list
which means Arad has been expanded before

BFS Breath First Search


Open: Timisoara Oradea
Fagras Rimnicu
Close: Arad Zerind
Sibiu

BFS Breath First Search


Open: Oradea Fagras
Rimnicu
Lugoj
Close: Arad Zerind
Sibiu Timisoara

BFS Breath First Search


Open: Fagras Rimnicu
Lugoj
Close: Arad Zerind
Sibiu Timisoara
Oradea

BFS Breath First Search


Open: Rimnicu Lugoj
Bucharest
Close: Arad Zerind
Sibiu Timisoara
Oradea Fagras

BFS Breath First Search


Open: Lugoj Bucharest
Pitesi Craiova
Close: Arad Zerind
Sibiu Timisoara
Oradea Fagras
Rimnicu

BFS Breath First Search


Open: Bucharest Pitesi
Craiova Mehadia
Close: Arad Zerind
Sibiu Timisoara
Oradea Fagras
Rimnicu Lugoi

BFS Breath First Search


Open: Bucharest Pitesi
Craiova Mehadia
Close: Arad Zerind
Sibiu Timisoara
Oradea Fagras
Rimnicu Lugoi

Best First Search


Open: Arad(0)
Close:

Best First Search


Open: Zerind(75)
Timisoara(118)
Sibiu(140)
Close: Arad(0)

Best First Search


Open:
Timisoara(118)
Sibiu(140)
Oradea (146)
Close: Arad(0)
Zerind(75)

Best First Search


Open:Sibiu(140)
Oradea (146)
Lugoj(229)
Close: Arad(0)
Zerind(75)
Timisoara(118)

Best First Search


Open:Oradea (min(146,291) )
Rimnicu(220)
Lugoj(229)
Fagaras(239)
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)

Best First Search


Open:Rimnicu(220)
Lugoj(229)
Fagaras(239)
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)
Oradea(146)

Best First Search


Open:Lugoj(229)
Fagaras(239)
Pitesti(317)
Craiova(366)
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)
Oradea(146)
Rimnicu(220)

Best First Search


Open:Fagaras(239)
Mehadia(299)
Pitesti(317)
Craiova(366)
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)
Oradea(146)
Rimnicu(220)
Lugoj(229)

Best First Search


Open:Mehadia(299)
Pitesti(317)
Craiova(366)
Bucharest(450)
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)
Oradea(146)
Rimnicu(220)
Lugoj(229)
Fagaras(239)

Best First Search


Open:Pitesti(317)
Craiova(366)
Drobeta(374)
Bucharest(450)
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)
Oradea(146)
Rimnicu(220)
Lugoj(229)
Fagaras(239)
Mehadia(299)

Best First Search


Open:Craiova(min(366,455))
Drobeta(374)
Bucharest(min(450,418))
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)
Oradea(146)
Rimnicu(220)
Lugoj(229)
Fagaras(239)
Mehadia(299)
Pitesti(317)

Best First Search


Open:Drobeta(min(374,486))
Bucharest(min(450,418))
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)
Oradea(146)
Rimnicu(220)
Lugoj(229)
Fagaras(239)
Mehadia(299)
Pitesti(317)
Craiova(366)

Best First Search


Open:Bucharest(min(450,418
))
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)
Oradea(146)
Rimnicu(220)
Lugoj(229)
Fagaras(239)
Mehadia(299)
Pitesti(317)
Craiova(366)
Drobeta(374)

Best First Search


Open:Bucharest(418)
Close: Arad(0)
Zerind(75)
Timisoara(118)
Sibiu(140)
Oradea(146)
Rimnicu(220)
Lugoj(229)
Fagaras(239)
Mehadia(299)
Pitesti(317)
Craiova(366)
Drobeta(374)

Heuristic Information
f=g+h
g(path) = path cost
h(path) = h(s) = estimated distance from current node to the goal

Map with Heuristic Information


h is not larger than true distance

A* Search
Open: Arad(0+366)
Close:

A* Search
Open:Sibiu(393)
Timisoara(447)
Zerid(449)
Close: Arad(366)

A* Search
Open: Rimnicu(413)
Fagaras(415)
Timisoara(447)
Zerid(449)
Oradea(671)
Close: Arad(366)
Sibiu(393)

A* Search
Open:Fagaras(415)
Pitesti(417)
Timisoara(447)
Zerid(449)
Craiova(526)
Oradea(671)
Close: Arad(366)
Sibiu(393)
Rimnicu(413)

A* Search
Open:Pitesti(417)
Timisoara(447)
Zerid(449)
Bucharest(450)
Craiova(526)
Oradea(671)
Close: Arad(366)
Sibiu(393)
Rimnicu(413)
Fagaras(415)

A* Search
Open:Bucharest(min(450,41
8))
Timisoara(447)
Zerid(449)
Craiova(min(526,715))
Oradea(671)
Close: Arad(366)
Sibiu(393)
Rimnicu(413)
Fagaras(415)
Pitesti(417)

A* Search
Open:Bucharest(418)
Timisoara(447)
Zerid(449)
Craiova(min(526,715))
Oradea(671)
Close: Arad(366)
Sibiu(393)
Rimnicu(413)
Fagaras(415)
Pitesti(417)

BFS DFS A*
Optimal Solution

BFS: Shortest Steps


DFS: can not guarantee
Best First Search: least cost
A*: least cost with condition

Storage

Optimal

Storage

BFS

2n

DFS

Best First

2n

2n
Better than
Best First

A*

A* - Condition
Does the Search stratage f=g+h always
find the optimal solution ?
1 Yes, always.
2 No, depends on problem
3 No, depends on h

A* - Condition
The answer is: 3. depends on h
h(s) should be less than the true cost from s to goal
When A* terminate p is found, and q is any other nodes than p in Open list
According to A* strategy, we have
f(q) > Cp(S->G)
(Cp(S->G) : Cost of p solution)
g(S->q) + h(q->G) > Cp(S->G)
We want to make sure that Cost of p solution is the least cost, i.e.
Cq(S->G) > Cp(S->G)
If we make Cq(S->G) > g(S->q) + h(q->G) then we can say Cq(S->G) ) > Cp(S->G)
Cq(S->G) > g(S->q) + h(q->G)

g(S->q) + g(q->G) > g(S->q) + h(q->G)


g(q->G) > h(q->G)

State Space
Introduction to Artificial Intelligence

Vacuum World
1 two places: A & B
2 clean or dirty for each place
How many states in the state space?

State Space with 8 states

More Complex Vacuum World


1 Robot has Power. Power is: On/Off/Sleep
2 Camera to see if the place is dirty or not. Camera is: On/Off
3 Brush has different height. Height level is: 1,2,3,4,5
4 the number of places is 10 now
How many states now?

15 puzzle
h1 = the number of misplaced blocks
h2 = the sum of distances each block have to move to
the right position

Discussion:
where is the intelligence?
Introduction to Artificial Intelligence

Smart in A*
Compared to blind search, A* is viewed as intelligence.
It can get to the goal fast.(eg. Compare A* with BFS or Cheapest Cost)
But as we see, the heuristic information h is defined by human being.
The agent does not show the ability of finding the heuristic information.
Is it possible that the agent can find the heuristic information?

Restraint Relaxation
A block can move from square A to square B if (A is adjacent to B) and if (B is blank)
(to relax the restraint)
A block can move from square A to square B if (A is adjacent to B)

h2

(to relax the restraint)


A block can move from square A to square B
h=max(h1, h2)

h1

Conclusion Problem Solving

What can search do?


Fully observable
we have to know the exact available actions
Discrete
Determininstic: we have to know the result of taking an action

Question A*
1

Admissable? (Yes or No)

First node to expand? (b1 or a2)

Second node to expand? (b1, c1, a2, a3, b2)

Third node to expand? (a1, c2, b3, a4)

Reading

Part2 Chap 3 Solving Problems by Searching (Review)

Part2 Chap 5 Adversarial Search

Das könnte Ihnen auch gefallen