This presentation discusses the state space problem formulation and different search techniques to solve these. Techniques such as Breadth First, Depth First, Uniform Cost and A star algorithms are covered with examples. We also discuss where such techniques are useful and the limitations.
2. Credits
• The figures pertaining to Romania maps are referred/copied from Peter Norvig,
Sebastian Thrun, Russel books and Udacity courses.
• Some of the figures are attributable to the EDX AI by Columbia University
• A big THANKS to the original authors for these figures and wonderfully articulated
concepts through their books and courses.
3. Agents
• Reflex Agents
• Action depends only on the current input or percept
• Goal based agents
• Agents attempt to achieve a goal through a series of actions
• Agents consider the impact of actions on future states
• Often the requirement is not only to reach the goal state but do so as per an optimality
condition
• Approach: Search through the solution space
5. Example: Eight Queen Problem
• On the chess board place the 8 queens so that
no queen is attacked by any other queen
• Number of possible sequences: 64 * 63 * 62…*
57 = 1.8 × 1014
6. Problem Solving Approach
• Define the problem
• Formulate the goal
• Problem formulation
• Solve the problem as a two
stage process
• Perform the search through
the search space
• Execute the action
7. Defining the problem
• Initial State
• ACTIONS(s) = {a1, a2…an} set of possible actions the agent can execute when it is
in a particular state – possible actions may depend on the state
• RESULT(s, a) = s’
• GOALTEST(s) = True if it the state s is a goal state or not
• PATHCOST(path) = cost of the path
• STEPCOST(s, a, s’) = n
8. Problem Formulation: Arad to Bucharest
• Goal: Reach Bucharest from
Arad
• State Space: Cities
• Initial state: Arad
• Actions: Go to adjacent city
with cost = distance
• Goal test: Is the state we
reached == Bucharest?
9. Example
• Problem of going from Arad to Bucharest
• All cities constitute the state space, we need to navigate through the state space
and reach the goal
• In our case Bucharest is the goal state and all other states are non-goal state
• There are many possible actions that we can take when in a given state
• Assume each edge is a path of length 1, we can compute the number of edges to
traverse before reaching the goal state
10. Regions
• Explored
• Refers to the states already explored
• Frontier
• Farthest point in the explored space, also called fringe
• It is the leaves of the partially constructed tree
• This constitutes the partial plan as we explore through the search space
• Unexplored
• Unexplored states
12. Exercise
• Draw the tree for the Arad to
Bucharest problem
• Build the tree one step at a
time and show the explored
states, frontier and
unexplored states
13. Graph Search : Avoid repeated visits to same state
Fig Credits: EDX AI Course –
Columbia University
17. Uniform Cost Search – cheapest path
• In the breadth first search algorithm we considered each edge to have same cost
• Breadth first search algorithm will find the shortest path to the goal state
• Now we can consider each edge to have some step cost
• Uniform cost search is guaranteed to find the cheapest path provided the paths
are non-negative
19. Uniform Cost Search : Cheapest cost solution
Fig Credits: EDX AI Course –
Columbia University
20. Optimality
• Out of the 3 algorithms we looked at, which satisfy optimality property? That is,
finding the best solution?
• Are they complete? – i.e if there is a goal somewhere, will the algorithm find it?
• Depth First: No guarantee it will find the optimal path, but has n nodes of storage
for frontier. If the tree has infinite nodes, the DFS is not complete either.
• Breadth First: Guaranteed optimality but requires 2 ** n nodes to keep the
explored paths
21. Uniform Cost Search
• The search process proceeds in an uniform manner
while exploring the search space towards the goal
• The search is not directed or guided
• If the goal is far away, the search wouldn’t find it
quickly enough.
• If we want to more efficiently find the goal, we need to
add more “knowledge” that directs the search process.
G
S
22. Informed Search
• The search for the goal state is
directed using some knowledge
• In our example, the piece of
knowledge we may add is the
shortest (straight line) distance
between each state to the goal state.
• If Bucharest is the goal state and if it is
towards the south east of the start state
Arad, it makes sense to direct the
search towards the south east first,
instead of trying all possible directions
23. Exercise
• Suppose you are to walk from this building to the main building how many ways
you can do that and which path you would select?
24. Greedy Best First Search
• Key Idea: Always expand the node that is closer
to the goal
• This runs in to problems when there are
obstacles (dead ends). As the search is greedy,
the solution may not be optimal
S
G
25. A* Search : Key idea
• Greedy best search may not satisfy optimality
• What might help is to combine the two approaches:
• “knowledge” that helps us to minimize the number of nodes to explore
• Uniform cost search that is guaranteed to find the path of minimum cost
• A* algorithm is based on this key idea
26. A* algorithm
• A* algorithm works by choosing to expand the node that has the minimum cost of a
function f, where f is defined as:
𝑓 = 𝑔 + ℎ 𝑤ℎ𝑒𝑟𝑒 𝑔 𝑖𝑠 𝑡ℎ𝑒 𝑝𝑎𝑡ℎ 𝑐𝑜𝑠𝑡 𝑎𝑛𝑑 ℎ 𝑖𝑠 𝑡ℎ𝑒 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒𝑑 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑡𝑜 𝑔𝑜𝑎𝑙
𝑔 𝑝𝑎𝑡ℎ = 𝑝𝑎𝑡ℎ 𝑐𝑜𝑠𝑡, ℎ 𝑝𝑎𝑡ℎ = ℎ 𝑠 = 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒𝑑 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑡𝑜 𝑡ℎ𝑒 𝑔𝑜𝑎𝑙
• g(x) ensures that the path to X from S is kept to minimum and h(s) helps keeping
focus on the goal
29. Constraints on h-function
• Is the algorithm guaranteed to find the optimal path? : It depends on the h-
function
• A* algorithm finds the lowest cost path if: h(s) < true cost
• h should never overestimate the distance to the goal – that is h should be
optimistic. This is referred as h being admissible.
• Since in our case, the heuristic is to choose h as the straight line distance, the
required condition is satisfied
30. Admissiblity Intuition
• We have: f = g + h and at the goal state h(s) = 0.
• Hence at the goal state : f = g. That is, the total estimated distance is exactly same
as the path computed.
• Our algorithm always selects the node to expand based on the path cost f.
• Any other node in the frontier has a higher cost compared to the selected node
that has g and h.
• By stipulating that h is the shortest distance, what we are saying is that no other
node in the frontier can have a distance to goal smaller than the selected node.
31. State Spaces
• State spaces can be more diverse, not just the cities that we just discussed
• They also can have abstract properties, not just coordinates information
• Consider the problem of a vacuum cleaner that can be in one of the 2 chambers.
Each chamber may have dirt or not. How many states this system represent and
what are the state transitions?
32. Exercise
• What is the size of the state space when:
• There are 10 chambers, each can be clean or dirty
• The vacuum cleaner has a power switch with 3 positions (On/Off/Sleep)
• The machine also has a camera that has 2 positions
• Brush height can be in one of 5 positions
33. Sliding Blocks Problem
• Heuristics (h)
• h1 : # misplaced blocks
• h2 : Sum(distance of blocks to their right
position)
• Are they admissible heuristics?
• How do we arrive at the “right” heuristics?
34. Exercise
• Implement a solution to the Sliding block puzzle. Assume a 3 x 3 grid with blocks
1 to 8 and a blank block. Use BFS and A* algorithms.
• What is the size of state space?
35. Sliding puzzle heuristics
• Key rule:
A block can move from A to B if (A is adjacent to B) AND B is blank
• By crossing out B, we get the heuristic h2
• By also crossing out the first part of the rule we get h1
• We can then treat the problem as the minimization problem
36. Summary: Problem Solving using Search
• The methodology works for problems that have the following characteristics:
• Fully observable
• Known
• Discrete
• Deterministic
• Static
• We will look at Probability Theory and other techniques that help address
partially observable, stochastic and dynamic natured problems