Lecture 2

advertisement
INC 551 Artificial
Intelligence
Lecture 2
Review
Deliberative Agent
Agent
Action
Make
Decision
Environment
World
Model
Sense, Perceive
Problem Solving Agents
Agents with world model
State-Action Model
(Finite State Machine)
Action
Action
State1
State2
อยู่ในรู ปของ state - action
State3
Search for Solutions
Tree Structure
Parent
node
Child
ขั้นตอนในการทา Problem Solving
1. Define Environment
2. Build/Implement Agent with search techniques
Define Environment
• Define Problems and solutions
Initial state, goal, path cost
• Define measuring performance
• Choose states and actions
Example
States: Location of each 8 tiles
Initial state: as in picture
Action: blank moves left, right, up ,down
Goal state: all tiles match the position
Path cost: 1
Example
Vacuum problem
States: Agent in 1 of 2 locations, Dirt can be
anywhere, total of 8 possible states
Initial state: Any
Action: left, right, suck
Goal state: all space are clean
Path cost: each step cost 1
Example
Search Techniques
Uninformed search
• Breadth first
• Uniform cost search
• Depth first
• Depth-limit search
• Bidirectional search
Informed search
• Greedy best-first
• A* search
Problems
• Memory
• Time
เช่ นที่ 12 depth, branching factor = 10, ใช้ 35 ปี 10000 tetrabytes
Start
d
e
p
Start
d
b
c
e
e
p
Start
d
b
c
e
e
h
p
r
Start
d
b
c
e
e
h
p
r
q
Start
d
b
a
c
e
e
h
p
r
q
Start
d
b
c
a
a
e
e
h
p
r
q
Start
d
b
c
a
a
e
e
h
r
p
r
q
Start
d
b
c
a
a
e
e
h
r
q
p
r
q
Depth 0
Start
d
b
c
a
a
e
e
h
r
q
r
f
p
Depth 1
q
Depth 2
Depth 3
Search Technique Properties
• Completeness – guarantee ว่ าจะเจอ solution ถ้ า exist
• Time Complexity – เวลาทีใ่ ช้ ในการ search
• Space Complexity – memory ทีใ่ ช้ ในการ search
• Optimality – solution ทีไ่ ด้ guarantee ว่ าดีทสี่ ุ ด
Characteristic of Breadth-first search
Complete – yes ถ้ า branching factor มีค่าจากัด
Search Time - มาก
1  b  b  b  ... b  O(b )
2
3
d
d
Space - มาก
1  b  b  b  ... b  O(b )
2
3
d
d
Optimal – no in general
(optimal ถ้ า cost =1 ทุก step)
State = Volume of water in each bottle
(0,0)
Action = How many ways to make state change?
1. Empty Bottle 1
2. Empty Bottle 2
3. Fill in Bottle 1
4. Fill in Bottle 2
5. Pour Bottle 1 to 2
6. Pour Bottle 2 to 1
Transition
(0,0)
(3,0)
Empty Bottle 1
Fill in Bottle 2
Empty Bottle 2
Pour Bottle 1 to 2
(0,5)
Fill in Bottle 1
Pour Bottle 2 to 1
(0,0)
(3,0)
(3,5)
Empty Bottle 1
Fill in Bottle 2
(0,3)
Empty Bottle 2
Pour Bottle 1 to 2
(0,5)
(3,2)
Fill in Bottle 1
Pour Bottle 2 to 1
(0,0)
(0,5)
(3,0)
(3,5)
(0,3)
(3,3)
Empty Bottle 1
Fill in Bottle 2
(3,2)
(0,2)
Empty Bottle 2
Pour Bottle 1 to 2
Fill in Bottle 1
Pour Bottle 2 to 1
(0,0)
(0,5)
(3,0)
(3,5)
(0,3)
(3,3)
(1,5)
Empty Bottle 1
Fill in Bottle 2
(3,2)
(0,2)
(2,0)
Empty Bottle 2
Pour Bottle 1 to 2
Fill in Bottle 1
Pour Bottle 2 to 1
(0,0)
(0,5)
(3,0)
(3,5)
(0,3)
(3,3)
(1,5)
(1,0)
Empty Bottle 1
Fill in Bottle 2
(3,2)
(0,2)
(2,0)
(2,3)
Empty Bottle 2
Pour Bottle 1 to 2
(2,5)
Fill in Bottle 1
Pour Bottle 2 to 1
Depth 0
(0,0)
(0,5)
(3,0)
(3,5)
(0,3)
(3,3)
(1,5)
(1,0)
Empty Bottle 1
Fill in Bottle 2
(3,2)
Depth 1
Depth 2
(0,2)
Depth 3
(2,0)
Depth 4
(2,5)
Depth 5
(3,4)
Depth 6
(2,3)
Empty Bottle 2
Pour Bottle 1 to 2
Fill in Bottle 1
Pour Bottle 2 to 1
Experiment
Each student bring a paper
Water Jug puzzle 19,13,7
(0,13,7)
Actions
Pour 1 to 2
Pour 1 to 3
Pour 2 to 1
Pour 2 to 3
Pour 3 to 1
Pour 3 to 2
How many
minimum move
required to solve
the puzzle?
How to write a computer program to do this for you?
Memory - > Paper to write something down
Node structure
State + Action + Back pointer
Build tree until the goal is met
0-13-7,x,x
0-13-7,x,x 13-0-7,3,1 7-13-0,5,1
Search technique
Uninformed search
• Breadth first
• Uniform cost search
• Depth first
• Depth-limit search
• Bidirectional search
Informed search
• Greedy best-first
• A* search
ต่ างกันตรงที่
จะ expand node
ไหนต่ อไป
Uniform-cost search
จะ expand node ที่มี cost รวมมาจากจุดเริ่มต้ น
(accumulative cost) น้ อยทีส่ ุ ด
Example
Characteristic of Uniform-cost search
Complete – yes ถ้ า step cost ทุกอัน > 0
Search Time – มาก (ขึน้ กับปัญหา)
# node ที่ cost < optimal solution
Space – มาก (ขึน้ กับปัญหา)
# node ที่ cost < optimal solution
Optimal – yes
Note: ถ้ าทุก step มี cost เท่ ากันหมด Uniform-cost search
จะเหมือนกับ Breadth-first search
Search technique
Uninformed search
• Breadth first
• Uniform cost search
• Depth first
• Depth-limit search
• Bidirectional search
Informed search
• Greedy best-first
• A* search
Depth-first Search
จะ expand node ทีล่ กึ ทีส่ ุ ด
Characteristic of Depth-first search
Complete – no
Search Time – มาก
O(bd )
Space – น้ อย (linear space)
O(bd )
Optimal – no
Download