Lesson 1&2

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 48

Artificial Intelligence

Lesson 1

1
About
• Lecturers: Prof. Sarit Kraus, Mr. Ariel Rosenfeld
• TA: Ariel Rosenfeld: arielros1@gmail.com
– Write 89-570 in the header.
• (almost) All you need can be found on the
course website:
– http://u.cs.biu.ac.il/~rosenfa5/
– Artificial Intelligence - a modern
approach (3rd edition)
– How to get it?
2
Course Requirements 1
• The grade is comprised of 70% exam and 30% exercises.
• 3 programming exercises will be given. Work individually.
• All the exercises are counted for the final grade.
• 10% each.
• Exercises will be written in C++ or JAVA only. It should
be compiled and run on planet machine, and will be
submitted via “submit”. Be precise!
– Details will be provided in the following tirgulim!

3
Course Requirements 2
• Exercises are not hard, but work is required. Plan your
time ahead!
• When sending me mail please include the course number
(89-570) in the header, to pass the automatic spam filter.
• You will be required to participate in a few AI
experiments.
– Chats.
– Lab experiments (e.g., robots).
– Participation is MANDATORY!

4
Course Schedule (Tentative)
• Lesson 1:
– Introduction
– Transferring a general problem to a graph
search problem.
• Lesson 2
– Uninformed Search (BFS, DFS etc.).
• Lesson 3
– Informed Search (A*,Best-First-Search etc.).

5
Course Schedule – Cont.
• Lesson 4
– Local Search (Hill Climbing, Genetic
algorithms etc.).
• Lesson 5
– “Search algorithms” chapter summary.
• Lesson 6-7
– Game-Trees: Min-Max & Alpha-Beta
algorithms.

6
Course Schedule – Cont.
• Lesson 8-9
– Planning: STRIPS algorithm
• Lesson 10-11-12
– Learning: Decision-Trees, Neural Network,
Naïve Bayes, Bayesian Networks and more.
• Lesson 13: Robotics
• Lesson 14
– Questions and exercise.
7
AI – Alternative Definitions
• Elaine Rich and Kevin Knight: AI is the study of how to
make computers do things at which, at the moment, people
are better.
• Stuart Russell and Peter Norvig: [AI] has to do with
smart programs, so let's get on and write some.
• Claudson Bornstein: AI is the science of common sense.
• Douglas Baker: AI is the attempt to make computers do
what people think computers cannot do.
• Astro Teller: AI is the attempt to make computers do what
they do in the movies.

8
Examples
https://www.youtube.com/watch?v=3EQA679D
FRg
https://www.youtube.com/watch?v=8RWo8LCg
JPc
https://www.youtube.com/watch?v=qv6UVOQ0
F44
https://www.youtube.com/watch?v=mSh67zb0Z
m4
Practical problems – Scheduling
http://www.airplanegame.us/air-traffic-chief-
flight-control-games/?play=game
So what is AI all about?
• We will talk about it in the lecture…
• But…

11
Are we there yet?

12
AI & Search
• "The two most fundamental concerns of AI
researchers are knowledge representation and
search”
• “knowledge representation … addresses the
problem of capturing in a language…suitable for
computer manipulation”
• “Search is a problem-solving technique that
systematically explores a space of problem
states”.Luger, G.F. Artificial Intelligence: Structures and Strategies for
Complex Problem Solving

13
Solving Problems with Search
Algorithms
• Input: a problem P.
• Preprocessing:
– Define states and a state space
– Define Operators
– Define a start state and goal set of states.
• Processing:
– Activate a Search algorithm to find a path from
start to one of the goal states.

14
Example - Missionaries & Cannibals
http://www.novelgames.com/en/spg
ames/missionaries/
Example - Missionaries & Cannibals
• State space – [M,C,B]
• Initial State – [3,3,1]
• Goal State – [0,0,0]
• Operators – adding or subtracting the
vectors [1,0,1], [2,0,1], [0,1,1], [0,2,1] or
[1,1,1]
• Path – moves from [3,3,1] to [0,0,0]
• Path Cost – river trips
• http://www.plastelina.net/game2.html
• http://www.youtube.com/watch?v=W9NEWxabGmg

16
Let’s try a more difficult one…

17
18
Breadth-First-Search Pseudo code
• Intuition: Treating the graph as a tree and scanning top-
down.
• Algorithm:
BFS(Graph graph, Node start, Vector Goals)
1. L make_queue(start)
2. While L not empty loop
1. n  L.remove_front()
2. If goal (n) return true
3. S  successors (n)
4. L.insert(S)
3. Return false
19
Breadth-First-Search Attributes
• Completeness – yes (b  , d  )
• Optimality – yes, if graph is un-
weighted.
• Time Complexity: O(b d )
• Memory Complexity: O(b d )
– Where b is branching factor and d is the
solution depth

20
Exam Q
• 2015 B

21
Artificial Intelligence

Lesson 2

22
Uninformed Search
• Uninformed search methods use only
information available in the problem
definition.
– Breadth First Search (BFS)
– Depth First Search (DFS)
– Iterative DFS (IDA)
– Bi-directional search
– Uniform Cost Search (a.k.a. Dijkstra alg.)

23
Depth-First-Search Pseudo code
DFS(Graph graph, Node start, Vector Goals)
1. L make_stack(start)
2. While L not empty loop
2.1 n  L.remove_front()
2.2 If goal (n) return true
2.3 S  successors (n)
2.4 L.insert(S)
3. Return false

24
Depth-First-Search Attributes
• Completeness – No. Infinite loops or
Infinite depth can occur.
• Optimality – No.
m
• Time Complexity: O (b )
• Memory Complexity: O (bm ) 1
– Where b is branching factor and m is the
2 5
maximum depth of search tree
• See water tanks example 3

4
25
Limited DFS Attributes
• Completeness – Yes, if d≤l
• Optimality – No.
• Time Complexity: O(bl )
– If d<l, it is larger than in BFS
• Memory Complexity: O(bl )
– Where b is branching factor and l is the
depth limit.

26
Depth-First Iterative-Deepening
0
1,3, 2,6,16
9

4,10 c
5,13 7,17c 8,20

11 12 14 c
15 18 19 21 22

The numbers represent the order generated by DFID


27
Iterative-Deepening Attributes
• Completeness – Yes
• Optimality – yes, if graph is un-weighted.
• Time Complexity:
O(( d )b  (d  1)b 2  ...  (1)b d )  O(b d )

• Memory Complexity: O ( db)


– Where b is branching factor and d is the maximum
depth of search tree
28
State Redundancies
• Closed list - a hash table which holds the
visited nodes.
– Prevent re-exploring of nodes.
– Hold solution path from start to Closed List
goal

• For example BFS:


Open List (Frontier)

29
Duplicate Pruning
• Do not enter the father of the current state
– With or without using closed-list

• Using a closed-list, check the closed list before


entering new nodes to the open list

• Using a stack, check the current branch and stack


status before entering new nodes

30
Bi-directional Search
• Search both from initial state to goal state.
• Operators must be symmetric.

S G

31
Bi-directional Search Attributes
• Completeness – Yes, if both directions use BFS
• Optimality – yes, if graph is un-weighted and both
directions use BFS.
d /2
• Time and memory Complexity: O (b )
• Pros.
– Cuts the search tree by half (at least theoretically).
• Cons.
– Frontiers must be constantly compared.

32
Minimum cost path
• General minimum cost path-search
problem:
– Find shortest path form start state to one of the
goal states in a weighted graph.
– Path cost function is g(n): sum of weights from
start state to goal.

33
Uniform Cost Search
• Also known as Dijkstra’s algorithm.
• Expand the node with the minimum path
cost first.
• Implementation: priority queue.

34
Example of Uniform Cost Search
• Assume an example tree with different edge costs, represented by
numbers next to the edges.

2 a
1
b c
1 2 1 2
f gc dc ec

Notations for this example:


generated node
expanded node
35
Example of Uniform Cost Search

2 a
1

Closed list:
a
0
Open
36
list:
Example of Uniform Cost Search
2 a
1
b c

1 2 1 2

a
Closed list:
b c
2 1
Open
37
list:
Example of Uniform Cost Search
2 a
1
b c

1 2 1 2
dc ec

a c
Closed list:
b d e
2 2 3
Open
38
list:
Example of Uniform Cost Search
2 a
1
b c

1 2 1 2
f gc dc ec

a c b
Closed list:
d e f g
2 3 3 4
Open
39
list:
Example of Uniform Cost Search
2 a
1
b c

1 2 1 2
f gc dc ec

a c b d
Closed list:
e f g
3 3 4
Open
40
list:
Example of Uniform Cost Search
2 a
1
b c

1 2 1 2
f gc dc ec

a c b d e
Closed list:
f g
3 4
Open
41
list:
Example of Uniform Cost Search
2 a
1
b c

1 2 1 2
f gc dc ec

a c b d e f
Closed list:
g
4
Open
42
list:
Example of Uniform Cost Search
2 a
1
b c

1 2 1 2
f gc dc ec

a c b d e f g
Closed list:

Open
43
list:
Uniform Cost Search Attributes
• Completeness: yes, for positive weights
• Optimality: yes
c / e 
• Time & Memory complexity: O(b )
– Where b is branching factor, c is the optimal solution cost
and e is the minimum edge cost (each operator cost at
least e).
– UCS uses cost path and not length path, therefore, the ‘d’
term is not used here.

44
Informed Search
• Incorporate additional measure of a
potential of a specific state to reach the
goal.
• A potential of a state to reach a goal is
measured through a heuristic function h(n).
• An evaluation function is denoted f(n).

45
Best First Search Algorithms
• Principle: Expand node n with the best
evaluation function value f(n).
• Implement via a priority queue
• Algorithms differ with definition of f :
– Greedy Search: f (n)  h(n)
– A*: f ( n)  g ( n)  h( n)
– IDA*: iterative deepening version of A*
– Etc’
46
Exercise
• Q: Does a Uniform-Cost search be considered as
a Best-First algorithm?
• A: Yes. It can be considered as a Best-First
algorithm with evaluation function f(n)=g(n).
• Q: In what scenarios IDS outperforms DFS?,
BFS?
• A:
– IDS outperforms DFS when the search tree is a lot
deeper than the solution depth.
– IDS outperforms BFS when BFS run out of memory.

47
Exercise – Cont.
• Q: Why do we need a closed list?
• A: Generally a closed list has two main functionalities:
– Prevent re-exploring of nodes.
– Hold solution path from start to goal (DFS based algorithms have
it anyway).
• Q: Does Breadth-FS find optimal path length in general?
• A: No, unless the search graph is un-weighted.
• Q: Will IDS always find the same solution as BFS given
that the nodes expansion order is deterministic?
• A: Yes. Each iteration of IDS explores new nodes the same
order a BFS does.
48

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy