AI_Session 3 Problem Solving Agent and searching for solutions.pptx
1. ARTIFICAL INTELLIGENCE
(R18 III(II Sem))
Department of computer science and engineering
(AI/ML)
Session 3
by
Asst.Prof.M.Gokilavani
VITS
2/23/2023 Department of CSE (AI/ML) 1
2. TEXTBOOK:
• Artificial Intelligence A modern Approach, Third Edition, Stuart
Russell and Peter Norvig, Pearson Education.
REFERENCES:
• Artificial Intelligence, 3rd Edn, E. Rich and K.Knight (TMH).
• Artificial Intelligence, 3rd Edn, Patrick Henny Winston, Pearson
Education.
• Artificial Intelligence, Shivani Goel, Pearson Education.
• Artificial Intelligence and Expert Systems- Patterson, Pearson
Education.
2/23/2023 Department of CSE (AI/ML) 2
3. Topics covered in session 3
2/23/2023 Department of CSE (AI/ML) 3
• Problem solving by search-I: Introduction to AI, Intelligent Agents.
• Problem solving by search-II: Problem solving agents, searching
for solutions
• Uniformed search strategies: BFS, Uniform cost search, DFS, Iterative
deepening Depth-first search, Bidirectional search,
• Informed ( Heuristic) search strategies: Greedy best-first search, A*
search, Heuristic functions
• Beyond classical search: Hill- climbing Search, Simulated annealing
search, Local search in continuous spaces, Searching with non-
deterministic Actions, searching with partial observations, online
search agents and unknown environments.
4. Problem-solving agent
• An important application of Artificial
Intelligence is Problem Solving.
• Define problem statement first.
• Generating the solution by keeping the
different condition in mind.
• Searching is the most commonly used
technique of problem solving in artificial
intelligence.
• Problem solving agent: A problem-
solving agent is a goal-driven agent and
focuses on satisfying the goal.
2/23/2023 Department of CSE (AI/ML) 4
5. Problem Solving by Searching
Why Reflex agent is not used in AI?
• Base their actions on
• A direct mapping from states to actions
• But cannot work well in environments
• which this mapping would be too large to store
• would take too long to learn
• Hence, goal-based agent is used.
Problem-solving agent
• A kind of goal-based agent
• It solves problem by
• finding sequences of actions that lead to desirable states (goals).
• To solve a problem,
• the first step is the goal formulation, based on the current situation.
2/23/2023 Department of CSE (AI/ML) 5
6. Step perform by problem solving agent
2/23/2023 Department of CSE (AI/ML) 6
7. Goal Formulation
• The goal is formulated
• as a set of world states, in which the goal is satisfied
• Reaching from initial state goal state
• Actions are required
• Actions are the operators
• causing transitions between world states
• Actions should be abstract enough at a certain degree, instead of
very detailed.
• E.g., turn left VS turn left 30 degree, etc.
2/23/2023 Department of CSE (AI/ML) 7
8. Problem formulation
• The process of deciding
• what actions and states to consider
• E.g., driving Amman Zarqa
• In-between states and actions defined
• States: Some places in Amman & Zarqa
• Actions: Turn left, Turn right, go straight, accelerate & brake, etc.
2/23/2023 Department of CSE (AI/ML) 8
9. Search Algorithm
• Because there are many ways to achieve the same goal
• Those ways are together expressed as a tree
• Multiple options of unknown value at a point,
• The agent can examine different possible sequences of actions, and
choose the best
• This process of looking for the best sequence is called search.
• The best sequence is then a list of actions, called solution.
• Defined as
• taking a problem
• and returns a solution
• Once a solution is found
• the agent follows the solution
• and carries out the list of actions – execution phase
• Design of an agent
• “Formulate, search, execute”
2/23/2023 Department of CSE (AI/ML) 9
10. Well defined problems and solutions
A problem can be defined formally by five components:
• The initial state that the agent starts in. State Space
• A description of the possible actions available to the agent.
• A description of what each action does; the formal name for this is the
transition model.
• The goal test, which determines whether a given state is a goal state.
Sometimes there is an explicit set of possible goal states, and the test
simply checks whether the given state is one of them.
• A path cost function that assigns a numeric cost to each path. The
problem-solving agent chooses a cost function that reflects its own
performance measure.
2/23/2023 Department of CSE (AI/ML) 10
13. Example: Romania
• On holiday in Romania; currently in Arad.
• Flight leaves tomorrow from Bucharest
• Formulate goal:
• be in Bucharest
• Formulate problem:
• states: various cities
• actions: drive between cities
• Find solution:
• sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest
2/23/2023 Department of CSE (AI/ML) 13
14. Example Problems
• Toy problems
• those intended to illustrate or exercise various problem-solving methods
• E.g., puzzle, chess, etc.
• Real-world problems
• Tend to be more difficult and whose solutions people actually care about
• E.g., Design, planning, etc.
2/23/2023 Department of CSE (AI/ML) 14
15. Toy Problem
Number of states: 8
Initial state: Any
Number of actions: 4
left, right, suck,
noOperation
Goal: clean up all dirt
Goal states: {7, 8}
Path Cost:
Each step costs 1
2/23/2023 Department of CSE (AI/ML) 15
17. 8 Puzzle Problem
• State: 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. Different subsets of these
are possible depending on where the blank is. Goal State Initial State
2/23/2023 Department of CSE (AI/ML) 17
18. 8 Puzzle Problem
• Transition model: Given a state and action, this returns the resulting
state.
• Goal test: This check 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. Goal State Initial State.
Conclusion:
• the right formulation makes a big difference to the size of the
search space
2/23/2023 Department of CSE (AI/ML) 18
19. 8 Puzzle Problem
The goal of the 8-queens problem is to place
eight queens on a chess-board such that no
queen attacks any other.
• 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.
2/23/2023 Department of CSE (AI/ML) 19
21. Search for Solutions
• Finding out a solution is done by
• searching through the state space
• All problems are transformed
• as a search tree
• generated by the initial state and successor function
2/23/2023 Department of CSE (AI/ML) 21
22. Search Tree
• Initial state
• The root of the search tree is a search node
• Expanding
• applying successor function to the current state
• thereby generating a new set of states
• leaf nodes
• the states having no successors
Fringe : Set of search nodes that have not been expanded yet.
2/23/2023 Department of CSE (AI/ML) 22
25. Search Tree
• The essence of searching
• in case the first choice is not correct
• choosing one option and keep others for later inspection
• Hence we have the search strategy
• which determines the choice of which state to expand
• good choice fewer work faster
• Important:
• state space ≠ search tree
• State space
• has unique states {A, B}
• while a search tree may have cyclic paths: A-B-A-B-A-B- …
• A good search strategy should avoid such paths
2/23/2023 Department of CSE (AI/ML) 25
26. Search tree
2/23/2023 Department of CSE (AI/ML) 26
• A node is having five components:
• STATE: which state it is in the state
space
• PARENT-NODE: from which node
it is generated
• ACTION: which action applied to
its parent-node to generate it
• PATH-COST: the cost, g(n), from
initial state to the node n itself
• DEPTH: number of steps along the
path from the initial state
27. Measuring problem-solving performance
The evaluation of a search strategy
• Completeness:
• is the strategy guaranteed to find a solution when there is one?
• Optimality:
• does the strategy find the highest-quality solution when there
are several different solutions?
• Time complexity:
• how long does it take to find a solution?
• Space complexity:
• how much memory is needed to perform the search?
2/23/2023 Department of CSE (AI/ML) 27
28. Measuring problem-solving performance
• In AI, complexity is expressed in
• b, branching factor, maximum number of successors of any node
• d, the depth of the shallowest goal node. (depth of the least-cost solution)
• m, the maximum length of any path in the state space
• Time and Space is measured in
• number of nodes generated during the search
• maximum number of nodes stored in memory
• For effectiveness of a search algorithm
• we can just consider the total cost
• The total cost = path cost (g) of the solution found + search cost
• search cost = time necessary to find the solution
• Tradeoff:
• (long time, optimal solution with least g)
• vs. (shorter time, solution with slightly larger path cost g)
2/23/2023 Department of CSE (AI/ML) 28
29. Topics to be covered in next session 4
• Uniformed search strategies
2/23/2023 Department of CSE (AI/ML) 29
Thank you!!!