call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
AI Searching Techniques and State Space Representation
1. Artificial Intelligence Searching
Problem Solving by Searching.
Reading: Section 3.1 – 3.4 of Textbook R&N
Intelligence is often displayed during problem-solving
processes.
How an agent can find a sequence of actions
that achieves its goal?
By Bal Krishna Subedi 1
2. Artificial Intelligence Searching
State Space Representation
In many situations, "to solve a problem" can be described
as to change the current situation, step by step, from
an initial state to a final state.
If each state is represented by a node, and each possible change is represented by
a link, then a "problem" can be represented as a graph (the "state space"), with a
"solution" corresponding to a path from the initial state to a final state.
In this way, a solution consists of a sequence of operations, each of which changes
one state into another one, and the whole sequence changes the initial state into a
final state in multiple steps.
By Bal Krishna Subedi 2
3. Artificial Intelligence Searching
Problem-Solving Agents
Task: To solve a particular problem by searching state space.
function simple-problem-solving-agent (percept) returns an action
inputs: percept, a percept
static: seq, an action sequence, initially empty
state, some description of current world state
goal, a goal, initially empty
problem, a problem formulation
state update-state (state, percept)
if seq is empty then do
goal formulate-goal (state)
problem formulate-problem (state, goal)
seq search (problem)
action first (seq)
seq rest (seq)
return action
Assume the environment is:
Static, Observable, Discrete &
Deterministic.
By Bal Krishna Subedi 3
4. Artificial Intelligence Searching
Defining Search Problems
A statement of a Search problem has four components:
1. initial state: starting point from which the agent sets out
2. actions (operators, successor functions):
• describe the set of possible actions
3. goal test: determines if a given state is the goal state.
4. path cost:
• determines the expenses of the agent for executing the actions in a path
• sum of the costs of the individual actions in a path
Solution quality is measured by the path cost function, and an
optimal solution has the lowest path cost
among all solutions.
By Bal Krishna Subedi 4
5. Artificial Intelligence Searching
Example: Route Finding Problem
By Bal Krishna Subedi 5
• states
– Locations (e.g: A, B, …)
• initial state
– starting point (e.g: S)
• successor function (operators)
– move from one location to another
• goal test
– arrive at a certain location (e.g: G)
• path cost
– Total distance, money, time, travel
comfort etc. (here distance in km)
S
A
D
B
E
C
F
G
3
4 4
5 5
42
4
3
Problem Formulation:
To find the route from city S to city G
6. Artificial Intelligence Searching
Searching for Solutions
1. Start from initial state, test, is it goal? If not expand the current state.
(i.e. from S get A, D).
2. Move to anyone of new states to proceed further (i.e move to A or D).
3. Continue choosing, testing, and expending until either a solution is
found or no more state to be expanded.
For this example there are 8 states & infinite number of paths to
check.
By Bal Krishna Subedi 6
7. Artificial Intelligence Searching
Search Method’s Performance
The choice of which state is to expand – search methods.
Search methods are evaluated along the following dimensions:
completeness:- does it always find a solution if one exists?
time complexity:- number of nodes generated/expanded
space complexity:- maximum number of nodes in memory
optimality:- does it always find a least-cost solution?
Time and space complexity are measured in terms of
b -- maximum branching factor (number of successor of any
node) of the search tree
d -- depth of the least-cost solution.
m -- maximum length of any path in the space (may be ∞)
By Bal Krishna Subedi 7
8. Artificial Intelligence Searching
Search Methods
There are two broad classes of search methods:
- uninformed (or blind) search methods;
In the case of the uninformed search methods the order in which potential
solution paths are considered is arbitrary, using no domain-specific
information to judge where the solution is likely to lie.
• Breadth-first Search
• Uniform-cost search
• Depth-first search
• Depth-limited search.
• Interative deepening depth-first search.
• Bidirectional search
- informed (heuristic) search methods.
Use domain specific heuristic to find solution.
• Discussed later.
By Bal Krishna Subedi 8
9. Artificial Intelligence Searching
Breadth-first search (BFS)
All nodes are expended at a given depth in the search tree before any nodes at
the next level are expanded until the goal reached.
S
A D
B
E
C
F
G
D A
E E B B
A CECFBFD
S
A
D
B
E
C
F
G
3
4 4
5 5
42
4
3
Find path from S to G
Constraint: Do not generate as child
node if the node is already parent to
avoid more loop.
By Bal Krishna Subedi 9
10. Artificial Intelligence Searching
BFS: Discussion
• Complete? Yes, if b is finite (i.e goal is in some finite depth)
• Optimal? Yes, if steps are identical not optimal in general.
• Time complexity? 1 + b + b2 + b3 + . . . + bd = O(bd), i.e.,
exponential in d
• Space complexity? O(bd) (keeps every node in memory)
Lets assume a b= 10 at depth 10, number of nodes = 1011 time required for
processing (with processor can process 10,000 nodes per sec) = 129 days
and memory requirement = 101 TB (1 node = 1KB)
Required another solution!
By Bal Krishna Subedi 10
11. Artificial Intelligence Searching
Uniform-Cost Search
Modified version of BFS to make optimal.
Expand the node n with lowest path cost.
By Bal Krishna Subedi 11
S
A
D
B
E
C
F
G
3
4 4
5 5
42
4
3
S
A D
3 4
3 4
B D
54
87
C E
4 5
11 12
G
3
13
B F
45
1011
A E
5 2
69
C(i,j) = cost of an arc from node i to node j
C(x,z) = C(x,y) + C(y,z)
Find the minimum cost path from S to G:
12. Artificial Intelligence Searching
Uniform-Cost Search: Discussion
Does not care about the number of steps, only care about total cost.
• Complete? Yes, if step cost ≥ ε (small positive number).
• Time? Maximum as of BFS
• Space? Maximum as of BFS.
• Optimal? Yes
By Bal Krishna Subedi 12
13. Artificial Intelligence Searching
Depth First Search
DFS expand the deepest unexpanded node.
By Bal Krishna Subedi 13
S
A
B
C
G
E
FD
S
A
D
B
E
C
F
G
3
4 4
5 5
42
4
3
Find a path from S to G.
14. Artificial Intelligence Searching
DFS: Discussion
• Complete? Yes: in finite state, No, if fall in infinite depth.
• Time? O(bm): terrible if m is much larger than d
• but if solutions are dense, may be much faster than breadth-first
• Space? O(bm), i.e., linear space!
• Optimal? No
The problem of unbounded trees can be solve by supplying depth-
first search with a determined depth limit (nodes at depth are treated
as they have no successors) – Depth limited search
By Bal Krishna Subedi 14
15. Artificial Intelligence Searching
Iterative deepening depth-first search
S
A
D
B
E
C
F
G
3
4 4
5 5
42
4
3
Performs successive depth-first searches,
considering increasing depth searches, until
a goal node is reached.
Depth 0: S
Depth 1: S
A
S
DA
S
D
A
A
B D
Depth 2: S
A
B
S
A
B D
S
D
A
A
B D
By Bal Krishna Subedi15
Depth 3: S
A
B
C
S
A
B
C E
S
A
B
E
D
E
S
A
B
C E
D
D
A
…
16. Artificial Intelligence Searching
Iterative deepening DFS: Discussion
Combine the benefits of DFS and BFS.
• Complete? Yes
• Time? O(bd)
• Space? O(bd)
• Optimal? Yes, if steps costs are all identical
• Can be modified to explore uniform-cost tree
By Bal Krishna Subedi 16
17. Artificial Intelligence Searching
Bidirectional Search
• Search simultaneously forwards from the start
point, and backwards from the goal, and stop
when the two searches meet in the middle.
• Problems: generate predecessors; many goal
states; efficient check for node already visited
by other half of the search; and, what kind of
search.
By Bal Krishna Subedi 17
18. Artificial Intelligence Searching
Bidirectional Search: Discussion
• Complete? Yes
• Time? O(bd/2)
• Space? O(bd/2)
• Optimal? Yes (if done with correct strategy -
e.g. breadth first).
By Bal Krishna Subedi 18