Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Module 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 87

Module II

Module 2- Problem Solving

• Solving Problems by searching-Problem solving Agents,


Example problems, Searching for solutions, Uninformed
search strategies, Informed search strategies, Heuristic
functions
Solving Problems by Searching

• Simple agents discussed were the reflex agents, which base their actions on a
direct mapping from states to actions.
• Such agents cannot operate well in environments for which this mapping would be
too large to store and would take too long to learn.
• Goal-based agents, on the other hand, consider future actions and the desirability
of their outcomes.
• Such a goal-based agent called a problem-solving agent
PROBLEM-SOLVING AGENTS

• Intelligent agents are supposed to maximize their performance measure.


• So they adopt a goal and aim at satisfying them.
• Goals helps to organize agent’s behavior by limiting the objectives that the
agent is trying to achieve and hence the actions needs to be considered.
Steps require to solve a problem
• Goal Formulation
➢ based on the current situation and the agent’s performance measure
➢ Organizes finite step to formulate a target/goals which require some action to
achieve the goal.
• Problem formulation
➢ process of deciding what actions and states to consider, given a goal
Goal formulation

• First step in problem solving is goal formulation


• It is based on the current situation and the agent’s performance measure
• Includes:-
❖ What is the goal state ?
❖ What are important characteristics of the goal state ?
❖ How does the agent know that it has reached the goal ?
❖ Are there several possible goal states ?
❖ Are they equal or are some more preferable ?
Problem Formulation
• Includes:-
❖ What are the possible states of the world relevant for solving the problem?
❖ What information is accessible to the agent ?
❖ How can the agent progress from state to state?
• The process of deciding
◦ what actions and states to consider
e.g., driving Ernakulam to Chennai
◦ states: Some places in Ernakulam and Chennai
◦ actions: Turn left, Turn right, go straight, accelerate & brake, etc.
agent will consider actions at the level of driving from one major
town to another . Each state therefore corresponds to being in a particular
town.
• An agent with several immediate options of unknown value
can decide what to do by first examining future actions that
eventually lead to states of known value
Components to formulate the associated problem
A problem can be defined formally by five components:
• Initial State
• Action
• Transition
• Goal Test
• Path Costing
Properties of the Environment

• Observable: agent always knows the current state of environment.


• Discrete: at any given state there are only finitely many actions to choose
from.
• Known: agent knows which states are reached by each action.
• Deterministic: each action has exactly one outcome
Search
• The process of looking for a sequence of actions that reaches the goal is
called search
• A search algorithm takes a problem as input and returns a solution in the
form of an action sequence
• Once a solution is found, the actions it recommends can be carried out.
• This is called the execution phase
• Thus, we have a simple “formulate, search, execute” design for the agent.
Searching Process

1. Formulate a goal and a problem to solve.


2. The agent calls a search procedure to solve it
3. Agent uses the solution to guide its actions
4. Do whatever the solution recommends typically, the first action of the sequence
5. Then remove that step from the sequence.
6. Once the solution has been executed, the agent will formulate a new goal.
Open-loop system

• While the agent is executing the solution sequence ,it ignores its
percepts when choosing an action because it knows in advance what
they will be.
• An agent that carries out its plans with its eyes closed, so to speak,
must be quite certain of what is going on.
• This an open-loop system, because ignoring the percepts breaks the
loop between agent and environment.
• A problem can be defined formally by following components:
1. The initial state that the agent starts in.
2. A description of the possible actions available to the agent.
◦ Eg:- from the state In(Ernakulam), the applicable actions are
{Go(Thrissur), Go(Palakkad), Go(Kozhikod)}.
3. Transition model: description of what each action does, specified by a
function RESULT(s, a) that returns the state that results from doing action
a in state s
4. Successor: any state reachable from a given state by a single action
RESULT(In(Ernakulam),Go(Thrissur)) = In(Thrissur)
5. State space: The set of all states reachable from the initial state by any
sequence of actions. forms a directed network or graph in which the nodes
are states and the links between nodes are actions.
6. A path in the state space is a sequence of states connected by a sequence of
actions.
7. The goal test, which determines whether a given state is a goal state
{In(Chennai)}
8. A path cost function that assigns a numeric cost to each path.
Cost of a path can be described as the sum of the costs of the individual actions
along the path.
9. The step cost of taking action a in state s to reach state s is denoted by c(s,a,s).
A solution to a problem is an action sequence that leads from the initial state to a
goal state. Solution quality is measured by the path cost function, and an
optimal solution having the lowest path cost among all solutions.
Formulating problems

• The formulation of the problem can be done in terms of the initial state,
actions, transition model, goal test, and path cost.
• Some of the considerations are left out from state descriptions because they
are irrelevant to the problem formulation.
eg:- In the travel from Ernakulam to Thrissur , can include : the traveling
companions, the current radio program, the scenery out of the window,
the proximity of law enforcement officers, the distance to the next rest
stop, the condition of the road, the weather, and so on
• The process of removing irrelevant details from a representation is called
abstraction and leaving most essential parts of the description.
• Conclusion: Only the most important parts that are contributing to search are
used.
• Example: Romania
Example Problems
• The problem-solving approach has been applied to a vast array of task
environments.
• The best known are, distinguishing between toy and real-world problems.
• A toy problem is intended to illustrate or exercise various problem-solving
methods.
• Its concise, exact description makes it usable to compare the performance
of algorithms.
e.g., puzzle, chess, etc
• A real-world problem is one whose solutions people actually care about.
e.g., Design, planning, etc.
Toy problems
a)Vacuum World
• States: The state is determined by both the agent location and the dirt locations.
The agent is in one of two locations, each of which might or might not
contain dirt. Thus, there are 2 × 22 = 8 possible world states. A larger
environment with n locations has n · 2n states.
• Initial state: Any state can be designated as the initial state.
• Actions: In this simple environment, each state has just three actions:
Left, Right, and Suck. Larger environments might also include
` Up and Down.
• Transition model: The actions have their expected effects, except that
moving Left in the leftmost square, moving Right
in the rightmost square, and Sucking in a clean
square have no effect.
• Goal test: This checks whether all the squares are clean.
• Path cost: Each step costs 1, so the path cost is the number of steps in the
path.
Compared with the real world, this toy problem has discrete locations,
discrete dirt, reliable cleaning, and it never gets any dirtier.
b) 8-puzzle
The 8-puzzle consists of a 3×3 board with eight numbered tiles and a blank space
A tile adjacent to the blank space can slide into the space. The object is to reach a
specified goal state.
• States: A state description specifies the location of each of the eight tiles and
the blank in one of the nine squares.
• Initial state: Any state can be designated as the initial state.
• Actions: The simplest formulation defines the actions as movements of the
blank space Left, Right, Up, or Down.
• Transition model: Given a state and action, this returns the resulting state; for
example, if we apply Right to the start state, the resulting state has
the 5 and the blank switched.
• Goal test: This checks whether the state matches the goal configuration (Other goal
configurations are possible.)
• Path cost: Each step costs 1, so the path cost is the number of steps in the path.
• The 8-puzzle has 9!/2 = 181, 440 reachable states and is easily solved.
• The 15-puzzle (on a 4×4 board) has around 1.3 trillion states, and random instances
can be solved optimally in a few milliseconds by the best search algorithms.
• The 24-puzzle (on a 5 × 5 board) has around 1025 states, and random instances take
several hours to solve optimally
c) 8-queens problem
• The goal of the 8-queens problem is to place eight queens on a chessboard
such that no queen attacks any other.
• A queen attacks any piece in the same row, column or diagonal.
• Figure shows an attempted solution that fails: the queen in the rightmost
column is attacked by the queen at the top left.
• Although efficient special-purpose algorithms exist for this problem and for
the whole n-queens family, it remains a useful test problem for search
algorithms.
• There are two main kinds of formulation.
• Incremental formulation
➢ involves operators that augment the state description, starting with an
empty state.
➢Each action adds a queen to the state
• Complete-state formulation
➢starts with all 8 queens on board and moves them around.
• Incremental Formulation
States: Any arrangement of 0 to 8 queens on the board is a state.
• Initial state: No queens on the board.
• Actions: Add a queen to any empty square.
• Transition model: Returns the board with a queen added to the specified square.
• Goal test: 8 queens are on the board, none attacked
In this formulation, we have 64 · 63 ··· 57 ≈ 1.8 × 1014 possible sequences to
investigate
Complete state formulation
• States: All possible arrangements of n queens (0 ≤ n ≤ 8), one per
column in the leftmost n columns, with no queen attacking another.
• Actions: Add a queen to any square in the leftmost empty column such
that it is not attacked by any other queen.
This formulation reduces the 8-queens state space from 1.8 × 1014 to
just 2,057, and solutions are easy to find.
Real-world problems
• Route-finding problems
• Touring problems
• Traveling Salesman problem
• VLSI layout problem
• Robot navigation
• Automatic assembly sequencing
• Internet searching
a) Route-Finding problem
• used in a variety of applications.
• such as Web sites and in-car systems that provide driving directions.
eg:- Airline travel problems
• States: Each state obviously includes a location (e.g., an airport) and the current
time.
• Initial state: This is specified by the user’s query.
• Actions: Take any flight from the current location leaving after the current time,
leaving enough time for within-airport transfer if needed.
• Transition model: The state resulting from taking a flight will have the flight’s
destination as the current location and the flight’s arrival time as
the current time.
• Goal test: Are we at the final destination specified by the user?
• Path cost: This depends on monetary cost, waiting time, flight time, customs and
immigration procedures, seat quality, time of day, type of airplane,
frequent-flyer mileage awards, and so on
b) Touring problems
• “Visit every city in at least once, starting and ending in Bucharest.”
• Actions correspond to trips between adjacent cities
• Each state must include not just the current location but also the set of
cities the agent has visited.
• So the initial state would be In(Bucharest), Visited({Bucharest}), a typical
intermediate state would be In(Vaslui), Visited({Bucharest, Urziceni,
Vaslui}).
• Goal test would check whether the agent is in Bucharest and all 20 cities
have been visited.
c) Traveling salesperson problem
• The traveling salesperson problem (TSP) is a touring problem
in which each city must be visited exactly once.
• The aim is to find the shortest tour.
d)VLSI layout problem
• VLSI layout problem requires positioning millions of components and
connections on a chip to minimize area, minimize circuit delays, minimize stray
capacitances, and maximize manufacturing yield.
• The layout problem comes after the logical design phase and is usually split into
two parts: ◦ cell layout and channel routing.
• Cell layout –
➢ The primitive components of the circuit are grouped into cells, each of which
performs some recognized function.
➢ Each cell has a fixed footprint and requires a certain number of connections to
each of the other cells.
➢The aim is to place the cells on the chip so that they do not overlap and so that
there is room for the connecting wires to be placed between the cells.
• Channel routing –
➢ finds a specific route for each wire through the gaps between the cells.
e) Robot navigation

• Robot navigation is a generalization of the route-finding problem.


• Rather than following a discrete set of routes, a robot can move in a
continuous space with an infinite set of possible actions and states.
• For a circular robot moving on a flat surface, the space is essentially
two dimensional.
• When the robot has arms and legs or wheels that must also be
controlled, the search space becomes many-dimensional.
f) Automatic assembly sequencing

• Aim is to find an order in which to assemble the parts of some object.


• If the wrong order is chosen, there will be no way to add some part
later in the sequence without undoing some of the work already done.
• Checking a step in the sequence for feasibility is a difficult
geometrical search problem.
• Protein design is an automatic assembly problem in which the goal is
to find a sequence of amino acids that will fold into a three-
dimensional protein with the right properties to cure some disease
Searching for Problems

• A solution is an action sequence, so search algorithms work by considering


various possible action sequences.
• The possible action sequences starting at the initial state form a search tree
with the initial state at the root; the branches are actions and the nodes
correspond to states in the state space of the problem.
• The below figure shows the first few steps in growing the search tree for
finding a route from Arad to Bucharest.
➢ The root node of the tree corresponds to the initial state, In(Arad).
➢ The first step is to test whether this is a goal state.
➢ Next we need to expand the current state, thereby generating a new set of
states.
➢From the parent node three branches are added In(Arad) leading to three
new child nodes: In(Sibiu), In(Timisoara), and In(Zerind).
➢Then Sibiu is expanded to get In(Arad), In(Fagaras), In(Oradea), and
In(RimnicuVilcea).
➢Each of these six nodes is a leaf node, that is, a node with no children in the
tree.
➢The set of all leaf nodes available for expansion at any given point is called
the frontier.
➢The process of expanding nodes on the frontier continues until either a
solution is found or there are no more states to expand.
• Search algorithms all share this basic structure; called search strategy.
• Loopy path: path from Arad to Sibiu and back to Arad again is a repeated
state in the search tree, generated in this case by a loopy path.
• The complete search tree for Romania is infinite because there is no limit to
how often one can traverse a loop.
• Loopy paths are a special case of redundant paths, which exist whenever there
is more than one way to get from one state to another.
Tree-Search algorithm
• Every expanded node is known as the explored set.
• Newly generated nodes that match previously generated nodes in the
explored set or the frontier can be discarded instead of being added to the
frontier.
• Algorithm
Graph-Search algorithm
• Each state appears in the graph only once. But, it may appear in the tree
multiple times
• Contains at most one copy of each state.
• The algorithm has another nice property: the frontier separates the state-
space graph into the explored region and the unexplored region.
• A node is not added if its state has already been expanded.
• Every path from the initial state to an unexplored state has to pass through a
state in the frontier.
• As every step moves a state from the frontier into the explored region while
moving some states from the unexplored region into the frontier, we see that
the algorithm is systematically examining the states in the state space, one
by one, until it finds a solution.
Infrastructure for search algorithms
• Search algorithms require a data structure to keep track of the search tree that
is being constructed. For each node n of the tree, we have a structure that
contains four components:
• n. STATE: the state in the state space to which the node corresponds;
• n. PARENT: the node in the search tree that generated this node;
• n. ACTION: the action that was applied to the parent to generate the
node;
• n. PATH-COST: the cost, traditionally denoted by g(n), of the path from
the initial state to the node, as indicated by the parent pointers
The node data structure is depicted in Figure
Measuring problem-solving performance
• An algorithm’s performance can be evaluated in four ways:
• Completeness: Is the algorithm guaranteed to find a solution when
there is one?
• Optimality: Does the strategy find the optimal solution
• Time complexity: How long does it take to find a solution?
• Space complexity: How much memory is needed to perform the
search?
Different types of searching
Informed Search and Uninformed Search

• Uninformed search is also called blind search.


• Blind Search has got no information about states beyond that provided in the
problem definition.
• All they can do is generate successors and distinguish a goal state from a
non-goal state.
• All search strategies are distinguished by the order in which nodes are
expanded.
• Strategies that know whether one non-goal state is “more promising” than
another are called informed search or heuristic search strategies.
Breadth-first search
• Breadth-first search is a simple strategy in which the root node is expanded first,
then all the successors of the root node are expanded next, then their successors,
and so on.
• In general, all the nodes are expanded at a given depth in the search tree before any
nodes at the next level are expanded.
• Breadth-first search is an instance of the general graph-search algorithm in which
the shallowest unexpanded node is chosen for expansion.
• This is achieved very simply by using a FIFO queue for the frontier.
• Thus, new nodes (which are always deeper than their
• parents) go to the back of the queue, and old nodes, which are shallower than the
new nodes, get expanded first.
• There is one slight weak on the general graph-search algorithm, which is that the
goal test is applied to each node when it is generated rather than when it is selected
for expansion.
• Breadth-first search always has the shallowest path to every node on the frontier.
Problem solving performance-BFS
• complete—if the shallowest goal node is at some finite depth d, breadth-first
search will eventually find it after generating all shallower nodes.
• not optimal one: breadth-first search is optimal if the path cost is a
nondecreasing function of the depth of the node. The most common such
scenario is that all actions have the same cost.
• Time Complexity: The root of the search tree generates b nodes at the first
level, each of which generates b more nodes, for a total of b2 at the second
level. Each of these generates b more nodes, yielding b3 nodes at the third level,
and so on. Now suppose that the solution is at depth d. In the worst case, it is
the last node generated at that level. Then the total number of nodes generated
is b + b2 + b3 + ··· + bd = O(bd )
• Space Complexity: every node generated remains in memory. There will be
O(bd−1) nodes in the explored set and O(bd ) nodes in the frontier so the space
complexity is O(bd ), exponential complexity.
• The memory requirements are a bigger problem for breadth-first search
than is the execution time.
• One might wait 13 days for the solution to an important problem with
search depth 12, but no personal computer has the petabyte of memory
it would take.
• If your problem has a solution at depth 16, then it will take about 350
years for breadth-first search to find it.
• In general, exponential-complexity search problems cannot be solved
by uninformed methods for any but the smallest instances.
Depth-first search
• Depth-first search always expands the deepest node in the current frontier of the
search tree.
• The search proceeds immediately to the deepest level of the search tree, where the
nodes have no successors.
• As those nodes are expanded, they are dropped from the frontier, so then the search
“backs up” to the next deepest node that still has unexplored successors.
• The depth-first search algorithm is an instance of the graph-search algorithm which
uses a LIFO queue.
• A LIFO queue means that the most recently generated node is chosen for
expansion.
• This must be the deepest unexpanded node because it is one deeper than its parent
Problem solving performance-DFS
• Completeness:
• Depth-first search is implemented with a recursive function that calls itself on each
of its children in turn.
• The properties of depth-first search depend strongly on whether the graph-search or
tree-search version is used.
• The graph-search version, which avoids repeated states and redundant paths, is
complete in finite state spaces because it will eventually expand every node.
• The tree-search version, on the other hand, is not complete.
• Depth-first tree search can be modified at no extra memory cost so that it checks
new states against those on the path from the root to the current node; this avoids
infinite loops in finite state spaces but does not avoid the proliferation of redundant
paths.
• In infinite state spaces, both versions fail if an infinite non-goal path is
encountered.
Not optimal
• Depth- first search will explore the entire left subtree even if node C is a goal node.
• If node J were also a goal node, then depth-first search would return it as a solution instead of C,
which would be a better solution; hence, depth-first search is not optimal.
Time complexity
• Depth-first graph search is bounded by the size of the state space.
• A depth-first tree search, on the other hand, may generate all of the O(bm) nodes in the search tree,
where m is the maximum depth of any node; this can be much greater than the size of the state
space.
• m itself can be much larger than d (the depth of the shallowest solution) and is infinite if the tree is
unbounded.
Space complexity
• A depth-first tree search needs to store only a single path from the root to a leaf node, along with
the remaining unexpanded sibling nodes for each node on the path.
• Once a node has been expanded, it can be removed from memory as soon as all its descendants
have been fully explored.
• For a state space with branching factor b and maximum depth m, depth-first search requires storage
of only O(b m) nodes , assuming that nodes at the same depth.
• As the goal node have no successors, we find that depth-first search would require 156 kilobytes
instead of 10 exabytes at depth d = 16, a factor of 7 trillion times less space.
Uniform-Cost Search
• When all step costs are equal, breadth-first search is optimal because it always
expands the shallowest unexpanded node.
• Instead of expanding the shallowest node, uniform-cost search expands the node
‘n’ with the lowest path cost g(n).
• This is done by storing the frontier as a priority queue ordered by g.
• In addition to the ordering of the queue by path cost, there are two other
significant differences from breadth-first search.
• The first is that the goal test is applied to a node when it is selected for
expansion(The reason is that the first goal node that is generated may be on a suboptimal path)
• The second difference is that a test is added in case a better path is found to a
node currently on the frontier.
• An example can be considered which is shown in below figure, where the problem is to get from Sibiu to Bucharest.

• The successors of Sibiu are Rimnicu Vilcea and Fagaras, with costs 80 and 99, respectively.
• The least-cost node, Rimnicu Vilcea, is expanded next, adding Pitesti with cost 80 + 97 = 177.
• The least-cost node is now Fagaras, so it is expanded, adding Bucharest with cost 99 + 211 =
310.
• Now a goal node has been generated, but uniform-cost search keeps going, choosing Pitesti for
expansion and adding a second path to Bucharest with cost 80+ 97+ 101 = 278.
• Now the algorithm checks to see if this new path is better than the old one; it is, so the old one is
discarded. Bucharest, now with g-cost 278, is selected for expansion and the solution is returned
Problem solving performance-UCS

• Complete: guaranteed provided the cost of every step exceeds some small
positive constant ε
• Optimal: optimal path to that node has been found, because step costs are
nonnegative, paths never get shorter as nodes are added. Uniform-cost search
expands nodes in order of their optimal path cost.
• Time Complexity: of nodes with g ≤ cost of optimal solution, O(bceiling(C*/ ε) )
where C* is the cost of the optimal solution
• Space Complexity: of nodes with g ≤ cost of optimal solution, O(bceiling(C*/ε) )
• Uniform-cost search is guided by path costs rather than depths, so its complexity
is not easily characterized in terms of b and d.
• Let C∗ be the cost of the optimal solution and that every action costs at least ε,
then the algorithm’s worst-case time and space complexity is can be much greater
than bd
• When all step costs are equal then complexity is just bd+1
• Also uniform-cost search is similar to breadth-first search, except that bfs stops as
soon as it generates a goal, whereas uniform-cost search examines all the nodes at
the goal’s depth to see if one has a lower cost thus uniform-cost search does
strictly more work by expanding nodes at depth d.
Depth-limited search
• The embarrassing failure of depth-first search in infinite state spaces can be
alleviated by supplying depth-first search with a predetermined depth limit ‘l’.
• That is, nodes at depth are treated as if they have no successors.
• This approach is called depth-limited search.
• The depth limit solves the infinite-path problem.
• But it also introduces an additional source of incompleteness, if we choose l <d,
that is, the shallowest goal is beyond the depth limit. (This is likely when d is
unknown.).
• Depth-limited search will also be nonoptimal if we choose l >d
• Its time complexity is O(b l) and its space complexity is O(b l). Depth-first search
can be viewed as a special case of depth-limited search with l =∞.
• Depth-limited search can be implemented as a simple modification to the general tree or
graph-search algorithm.
• Alternatively, it can be implemented as a simple recursive algorithm .
• The depth-limited search can terminate with two kinds of failure: the standard failure value
indicates no solution; the cutoff value indicates no solution within the depth limit.
Iterative deepening depth-first search

• Iterative deepening search (or iterative deepening depth-first search) is a


general strategy, used in combination with depth-first tree search, that finds
the best depth limit.
• Iterative deepening search (or iterative deepening depth-first search) is a
general strategy often used in combination with depth-first tree search, that
finds the best depth limit.
• Iterative deepening combines the benefits of depth-first and breadth-first
search.
• Like depth-first search, its memory requirements are modest: O(bd) to be
precise.
• Like breadth-first search, it is complete when the branching factor is finite
and optimal when the path cost is a nondecreasing function of the depth of
the node.
• Iterative deepening search may seem wasteful because states are generated
multiple times.
• But it turns out this is not too costly.
• The reason is that in a search tree with the same (or nearly the same)
branching factor at each level, most of the nodes are in the bottom level, so it
does not matter much that the upper levels are generated multiple times.
• In general, iterative deepening is the preferred uninformed search method
when the search space is large and the depth of the solution is not known.
Informed Search Strategies

• an informed search strategy—one that uses problem-specific


knowledge beyond the definition of the problem itself
• can find solutions more efficiently than can an uninformed strategy.
• The general approach we consider is called best-first search.
Best-First Search
• instance of the general Tree-Search or Graph-Search algorithm in which a
node is selected for expansion based on an evaluation function, f(n).
• Evaluation function is construed as a cost estimate, so the node with the
lowest evaluation is expanded first.
• The implementation of best-first graph search is identical to that for uniform-
cost search except for the use of ‘f’ instead of ‘g’ to order the priority queue.
• The choice of f determines the search strategy.
• Most best-first algorithms include as a component of “f” a heuristic function,
denoted h(n):
• h(n) = estimated cost of the cheapest path from the state at node n to a goal
state.
• if n is a goal node, then h(n)=0
Greedy best-first search

• This method tries to expand the node that is closest to the goal, on the
grounds that this is likely to lead to a solution quickly.
• It evaluates nodes by using just the heuristic function; that is, f(n) = h(n).
Greedy best-first search- Route finding problems in Romania
• Here we use the straight line
distance heuristic, which we
will call hSLD .
• If the goal is Bucharest, we
need to know the straight-
line distances to Bucharest,
which are shown in table.
• hsld is correlated with actual
road distances and is,
therefore, a useful heuristic
A* search: Minimizing the total estimated solution cost

• The most widely known form of best-first search is called A∗ search


(pronounced “A-star)
• It evaluates nodes by combining g(n), the cost to reach the node, and h(n),
the cost to get from the node to the goal:
f(n) = g(n) + h(n)
g(n) -> path cost from the start node to node n
h(n) -> estimated cost of the cheapest path from n to the goal
f(n) = estimated cost of the cheapest solution through n
• If we are trying to find the cheapest solution, a reasonable thing to try first is
the node with the lowest value of g(n) + h(n).
• This strategy is more than just reasonable: provided that the heuristic function
h(n) satisfies certain conditions,
• A∗ search is both complete and optimal.
• The algorithm is identical to Uniform-Cost-Search except that A∗ uses g + h
instead of g.
Conditions for optimality: Admissibility and Consistency

Admissibility

• The first condition we require for optimality is that h(n) be an admissible heuristic.
• An admissible heuristic is one that never overestimates the cost to reach the goal.
• Admissible heuristics are by nature optimistic because they think the cost of solving
the problem is less than it actually is.
• Eg:- of admissible heuristic is the straight-line distance hSLD that we used in getting
to Bucharest. Straight-line distance is admissible because the shortest path between
any two points is a straight line, so the straight line cannot be an overestimate.
Consistency

• A second, slightly stronger condition called consistency (or sometimes


monotonicity) is required only for applications of A∗ to graph search.
• A heuristic h(n) is consistent if, for every node n and every successor n| of
n generated by any action a, the estimated cost of reaching the goal from n
is not greater than the step cost of getting to n| plus the estimated cost of
reaching the goal from n| :
h(n) ≤ c(n, a, n| ) + h(n|) .
• This is a form of the general triangle inequality.
Contours in the state space
• Inside the contour labeled 400, all nodes have f(n) less than or equal to 400, and
so on.
• A∗ expands the frontier node of lowest f-cost, we can see that an A∗ search fans
out from the start node, adding nodes in concentric bands of increasing f-cost.
• Contours – labelled region
Disadvantages of A* Algorithm
• the number of states within the goal contour search space is still
exponential in the length of the solution.
Admissible Heuristics
• h1 = the number of misplaced tiles.
• Here all of the eight tiles are out of position, so the start state would have h1
= 8. h1 is an admissible heuristic because it is clear that any tile that is out of
place must be moved at least once.
• h2 = the sum of the distances of the tiles from their goal positions.
• Here tiles cannot move along diagonals, the distance we will count is the
sum of the horizontal and vertical distances. This is sometimes called the
city block distance or Manhattan distance. h2 is also admissible because all
any move can do is move one tile one step closer to the goal. Tiles 1 to 8 in
the start state give a Manhattan distance of
• h2 = 3 + 1 + 2 + 2 + 2 + 3 + 3 + 2 = 18
Heuristic Performance
• Experiments on sample problems can determine the number of nodes searched
and CPU time for different strategies.
• One other useful measure is effective branching factor:
• If a method expands N nodes to find solution of depth d, and a uniform tree of
depth d would require a branching factor of b* to contain N nodes, the effective
branching factor is b*
• N = 1 + b* + (b*)2 + ...+ (b*)d

You might also like