KEMBAR78
PROBLEM SOLVING AGENTS - SEARCH STRATEGIES | PPTX
ARTIFICIAL
INTELLIGENCE
PROBLEM SOLVING AGENTS
◦ One of the Goal Based Agent is Problem Solving Agent
◦ Problem-solving agents decide what to do by finding sequences of actions
that lead to desirable states.
◦ It uses atomic representation i.e., states of world are considered as whole
with no internal structure.
◦ Goal formulation, based on the current situation, is the first step in problem
solving. The agents task is to find out actions in present and future so that it
reaches a goal state
◦ Problem formulation is the process of deciding what actions and states to
consider, and follows goal formulation.
◦ After goal formulation and problem formulation the agent has to look for a
sequence of actions that reaches the goal . This process 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.
Well-Defined Problems & Solutions
A well defined problem is specified by 5 components
◦ The initial state – represents starting state of an agent
◦ Actions – A description of possible actions to the agent.
◦ Transition Model – A description of what action does . It is specified by
function RESULT(s,a)that returns the state that results from doing the
action.
◦ Goal test – determines whether a given state is a goal state
◦ Path cost – IT is a function that assigns a numeric cost to each path.
◦ A solution to a problem is an action sequence that leads from initial
state to goal state .
◦ Example :
◦ Consider an Agent in the city of Arad, Romania . The goal of the agent
is to reach Bucharest
Well-Defined Problems & Solutions
Well-Defined Problems & Solutions
o Initial state : The initial state for agent is in Romania is described as
In(Arad)
o Actions: In(Arad) , the applicable actions are {Go(Sibiu),
Go(Timisoara), Go(Zerind)}
o Transition model : RESULT(In(Arad), Go(Zerind)) = In(Zerind)
RESULT(In(Sibiu), Go(Fabaras))= in(Fabaras)
And so on
o Goal Test: In (Bucharest)
Example Problems
1. Toy Problem :
o Vacuum World:
o It involves discrete locations, discrete dirt etc., the problem for vacuum
cleaner world is specified as
o States: The states is determined by agent location and 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 states.
o Initial state: Any state can be designated as the initial state
o Actions : In this environment each state has three actions: LEFT, RIGHT
and SUCK .
o Transition model: the actions have their effects except that movinf
LEFT in the leftmost square , moving RIGHT in the rightmost square and
SUCKing in a clean square have no effect. The complete state space is
as shown below
Example Problems
oGoal Test : This checks whether all the squares are clean
oPath cost: Each step costs 1 so the path cost is the number of steps in the path
Example Problems
1. Toy Problem :
o 8-puzzle problem :
o A 8-puzzle problem consists of a 3×3 board with eight numbered tiles
and a blank space . A tile adjacent to blank space can slide in all four
directions . The objective is to reach the specified goal state .
o States: State description specifies the location of each 8 tiles and blank
tile in one of the 9 squares.
o Initial state : Any state can be designated as the initial state.
o Actions: Actions are defined as the movements of the blank space.
LEFT, RIGHT, UP or DOWN.
Example Problems
1. Toy Problem :
o 8-puzzle problem :
o Goal Test : It checks whether the state matches with goal state
o Path cost: Each step cost 1. So the path cost is number of steps in the
path
o 8-Queens Problem :
o The goal of 8-queens problem is to place eight queens on a chess
board such that no queen attacks any other.
Example Problems
o A queen attacks any piece in same row, column or diagonal
o There are two kinds of formulation for this problem
o 1. Incremental Formulation: It involves operators that augment the
state description starting with an empty state . One queen is placed at
a time in a incremental order
o 2. Complete State Formulation: It starts with all 8 queens placed
randomly on board and moves them around to reach goal state.
o The incremental formulation is specified as
o States: In which position the queen has to be placed
o Initial state: No queen is on the board
o Action : add a queen to the empty square
o Transition model: Returns the board with a queen added to the
specified square.
o Goal Test: 8 queens are on the board non attacked
Searching for Solutions
o A solution is an action sequence, so search algorithms work by
considering various possible action sequences.
o The action sequences starting at the initial state form a search tree with
the initial state at the root, The branches are the actions and nodes
correspond to the states in the state space of the problem.
o An explicit search tree is generated by initial state and successor function
o This method is used to find the path from state state to goal state.
o The tree is expanded by applying successor function to the current state
there by generating a new set of states . The choice of which state to
expand is determined by search strategy
o Root of the tree is the initial state . The first step is to test whether the
current state is goal state or not.
o The current state of the tree is expanded by applying each legal action
there by generating a new set states.
o The node with no children in the tree is called the leaf node. The set of
nodes available for expansion at any given point is called the frontier
NODE as DATA STRUCTURE
◦ 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.
NODE as DATA STRUCTURE
Node Vs State
◦ A node is a bookkeeping data structure used to represent the
search tree.
◦ A state corresponds to a configuration of the world.
◦ Thus, nodes are on particular paths, as defined by PARENT
pointers, whereas states are not.
◦ Furthermore, two different nodes can contain the same world
state if that state is generated via two different search paths.
Nodes stored into Queue
◦ Now that we have nodes, we need somewhere to put them.
◦ The frontier needs to be stored in such a way that the search algorithm
can easily choose the next node to expand according to its preferred
strategy. The appropriate data structure for this is a queue.
◦ The operations on a queue are as follows:
EMPTY?(queue) returns true only if there are no more elements in the
queue.
POP(queue) removes the first element of the queue and returns it.
INSERT(element , queue) inserts an element and returns the resulting
queue.
Nodes stored into Queue
◦ Queues are characterized by the order in which they store the inserted
nodes.
◦ Three common variants are the
first-in, first-out or FIFO queue, which pops the oldest element of the
queue;
the last-in, first-out or LIFO queue (also known as a stack), which pops
the newest element of the queue; and
the priority queue, which pops the element of the queue with the
highest priority according to some ordering function.
Measuring problem-solving performance
◦ We can evaluate an algorithm’s performance 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?
Measuring problem-solving performance
◦ Time and space complexity are always considered with respect to some
measure of the problem difficulty.
◦ In theoretical computer science, the typical measure is the size of the
state space graph, |V | + |E|, where V is the set of vertices (nodes) of
the graph and E is the set of edges (links).
◦ Complexity is expressed in terms of three quantities: b, the branching
factor or maximum number of successors of any node; d, the depth of the
shallowest goal node (i.e., the number of steps along the path from the
root); and m, the maximum length of any path in the state space.
◦ Time is often measured in terms of the number of nodes generated during
the search, and space in terms of the maximum number of nodes stored
in memory.
Measuring problem-solving performance
◦ To assess the effectiveness of a search algorithm, we can consider just
the search cost or we can use the total cost, which combines the
search cost and the path cost of the solution found.
◦ the search cost is the amount of time taken by the search and the
solution cost is the total length of the path in kilometers. Thus, to
compute the total cost, we have to add milliseconds and kilometers.
UNINFORMED SEARCH STRATEGIES
Comparing uninformed search
strategies
PROBLEM SOLVING AGENTS - SEARCH STRATEGIES

PROBLEM SOLVING AGENTS - SEARCH STRATEGIES

  • 1.
  • 2.
    PROBLEM SOLVING AGENTS ◦One of the Goal Based Agent is Problem Solving Agent ◦ Problem-solving agents decide what to do by finding sequences of actions that lead to desirable states. ◦ It uses atomic representation i.e., states of world are considered as whole with no internal structure. ◦ Goal formulation, based on the current situation, is the first step in problem solving. The agents task is to find out actions in present and future so that it reaches a goal state ◦ Problem formulation is the process of deciding what actions and states to consider, and follows goal formulation. ◦ After goal formulation and problem formulation the agent has to look for a sequence of actions that reaches the goal . This process 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.
  • 3.
    Well-Defined Problems &Solutions A well defined problem is specified by 5 components ◦ The initial state – represents starting state of an agent ◦ Actions – A description of possible actions to the agent. ◦ Transition Model – A description of what action does . It is specified by function RESULT(s,a)that returns the state that results from doing the action. ◦ Goal test – determines whether a given state is a goal state ◦ Path cost – IT is a function that assigns a numeric cost to each path. ◦ A solution to a problem is an action sequence that leads from initial state to goal state . ◦ Example : ◦ Consider an Agent in the city of Arad, Romania . The goal of the agent is to reach Bucharest
  • 4.
  • 5.
    Well-Defined Problems &Solutions o Initial state : The initial state for agent is in Romania is described as In(Arad) o Actions: In(Arad) , the applicable actions are {Go(Sibiu), Go(Timisoara), Go(Zerind)} o Transition model : RESULT(In(Arad), Go(Zerind)) = In(Zerind) RESULT(In(Sibiu), Go(Fabaras))= in(Fabaras) And so on o Goal Test: In (Bucharest)
  • 6.
    Example Problems 1. ToyProblem : o Vacuum World: o It involves discrete locations, discrete dirt etc., the problem for vacuum cleaner world is specified as o States: The states is determined by agent location and 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 states. o Initial state: Any state can be designated as the initial state o Actions : In this environment each state has three actions: LEFT, RIGHT and SUCK . o Transition model: the actions have their effects except that movinf LEFT in the leftmost square , moving RIGHT in the rightmost square and SUCKing in a clean square have no effect. The complete state space is as shown below
  • 7.
    Example Problems oGoal Test: This checks whether all the squares are clean oPath cost: Each step costs 1 so the path cost is the number of steps in the path
  • 8.
    Example Problems 1. ToyProblem : o 8-puzzle problem : o A 8-puzzle problem consists of a 3×3 board with eight numbered tiles and a blank space . A tile adjacent to blank space can slide in all four directions . The objective is to reach the specified goal state . o States: State description specifies the location of each 8 tiles and blank tile in one of the 9 squares. o Initial state : Any state can be designated as the initial state. o Actions: Actions are defined as the movements of the blank space. LEFT, RIGHT, UP or DOWN.
  • 9.
    Example Problems 1. ToyProblem : o 8-puzzle problem : o Goal Test : It checks whether the state matches with goal state o Path cost: Each step cost 1. So the path cost is number of steps in the path o 8-Queens Problem : o The goal of 8-queens problem is to place eight queens on a chess board such that no queen attacks any other.
  • 10.
    Example Problems o Aqueen attacks any piece in same row, column or diagonal o There are two kinds of formulation for this problem o 1. Incremental Formulation: It involves operators that augment the state description starting with an empty state . One queen is placed at a time in a incremental order o 2. Complete State Formulation: It starts with all 8 queens placed randomly on board and moves them around to reach goal state. o The incremental formulation is specified as o States: In which position the queen has to be placed o Initial state: No queen is on the board o Action : add a queen to the empty square o Transition model: Returns the board with a queen added to the specified square. o Goal Test: 8 queens are on the board non attacked
  • 11.
    Searching for Solutions oA solution is an action sequence, so search algorithms work by considering various possible action sequences. o The action sequences starting at the initial state form a search tree with the initial state at the root, The branches are the actions and nodes correspond to the states in the state space of the problem. o An explicit search tree is generated by initial state and successor function o This method is used to find the path from state state to goal state. o The tree is expanded by applying successor function to the current state there by generating a new set of states . The choice of which state to expand is determined by search strategy o Root of the tree is the initial state . The first step is to test whether the current state is goal state or not. o The current state of the tree is expanded by applying each legal action there by generating a new set states. o The node with no children in the tree is called the leaf node. The set of nodes available for expansion at any given point is called the frontier
  • 12.
    NODE as DATASTRUCTURE ◦ 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.
  • 13.
    NODE as DATASTRUCTURE
  • 14.
    Node Vs State ◦A node is a bookkeeping data structure used to represent the search tree. ◦ A state corresponds to a configuration of the world. ◦ Thus, nodes are on particular paths, as defined by PARENT pointers, whereas states are not. ◦ Furthermore, two different nodes can contain the same world state if that state is generated via two different search paths.
  • 15.
    Nodes stored intoQueue ◦ Now that we have nodes, we need somewhere to put them. ◦ The frontier needs to be stored in such a way that the search algorithm can easily choose the next node to expand according to its preferred strategy. The appropriate data structure for this is a queue. ◦ The operations on a queue are as follows: EMPTY?(queue) returns true only if there are no more elements in the queue. POP(queue) removes the first element of the queue and returns it. INSERT(element , queue) inserts an element and returns the resulting queue.
  • 16.
    Nodes stored intoQueue ◦ Queues are characterized by the order in which they store the inserted nodes. ◦ Three common variants are the first-in, first-out or FIFO queue, which pops the oldest element of the queue; the last-in, first-out or LIFO queue (also known as a stack), which pops the newest element of the queue; and the priority queue, which pops the element of the queue with the highest priority according to some ordering function.
  • 17.
    Measuring problem-solving performance ◦We can evaluate an algorithm’s performance 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?
  • 18.
    Measuring problem-solving performance ◦Time and space complexity are always considered with respect to some measure of the problem difficulty. ◦ In theoretical computer science, the typical measure is the size of the state space graph, |V | + |E|, where V is the set of vertices (nodes) of the graph and E is the set of edges (links). ◦ Complexity is expressed in terms of three quantities: b, the branching factor or maximum number of successors of any node; d, the depth of the shallowest goal node (i.e., the number of steps along the path from the root); and m, the maximum length of any path in the state space. ◦ Time is often measured in terms of the number of nodes generated during the search, and space in terms of the maximum number of nodes stored in memory.
  • 19.
    Measuring problem-solving performance ◦To assess the effectiveness of a search algorithm, we can consider just the search cost or we can use the total cost, which combines the search cost and the path cost of the solution found. ◦ the search cost is the amount of time taken by the search and the solution cost is the total length of the path in kilometers. Thus, to compute the total cost, we have to add milliseconds and kilometers.
  • 20.
  • 54.