0% found this document useful (0 votes)
32 views39 pages

Ai-Week8-Ch3-Solving Problems by Searching - Part A

The document covers problem-solving agents in artificial intelligence, focusing on how agents can search for sequences of actions to achieve goals. It discusses various search algorithms, including uninformed and informed strategies, and defines key components of search problems such as search space, initial state, and goal test. Additionally, it highlights the importance of measuring the performance of search algorithms based on completeness, optimality, time complexity, and space complexity.

Uploaded by

Qalandar Bux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views39 pages

Ai-Week8-Ch3-Solving Problems by Searching - Part A

The document covers problem-solving agents in artificial intelligence, focusing on how agents can search for sequences of actions to achieve goals. It discusses various search algorithms, including uninformed and informed strategies, and defines key components of search problems such as search space, initial state, and goal test. Additionally, it highlights the importance of measuring the performance of search algorithms based on completeness, optimality, time complexity, and space complexity.

Uploaded by

Qalandar Bux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

Artificial Intelligence

CSC-350

Teacher: Dr Muhammad Ismail Mangrio


[email protected]

Week 8
Chapter #3
Solving Problems by
Searching

Artificial Intelligence CSC-350 2


This Chapter Covers

3.1 Problem-Solving Agents


3.2 Example Problems
3.3 Search Algorithms
3.4 Uninformed Search Strategies
3.5 Informed (Heuristic) Search Strategies

Artificial Intelligence CSC-350 3


Solving Problems by Searching
• How an agent can look ahead to find:
• a sequence of actions to achieve goal.

• Reflex agent directly maps states to actions


• Agent can not perform well
• when too large mapping to store and need longer time to learn

• Goal-based agent consider future actions and desirable outcomes


• Known as problem-solving agents.

Artificial Intelligence CSC-350 4


Solving Problems by Searching
• Problem solving agents use atomic representation structure.
• states of world are considered as wholes
• no internal structure visibility to the problem-solving algorithm

• Goal-based agents that use more advanced factored or structured


representation are called planning agents.

• We define problems of an agent and their solutions.


• We describe general-purpose search algorithms to solve problems of agent.

Artificial Intelligence CSC-350 5


3.1 Problem-Solving
Agents

Artificial Intelligence CSC-350 6


3.1 Problem-Solving Agents
• Intelligent agents are assumed to maximize their performance.
• It is simple if agent adopt a goal and aim at satisfying it.

• Goal formulation is based on current situation and performance measure.


• Goal is a set of world states to be satisfied/achieved.
• Agent’s task is to find how to act (now or in future) to reach goal’s states.

• Problem formulation
• is the process of deciding what actions and states to consider to achieve a
goal.

Artificial Intelligence CSC-350 7


• The process of looking for a sequence of
actions that reaches the goal is called search.
• A search algorithm takes a problem as input
3.1 Problem- and returns a solution in the form of an action
Solving sequence.
• Actions taken based on found solution is called
Agents… execution phase.
• We have a simple “formulate, search, execute”
design for the agent.

Artificial Intelligence CSC-350 8


3.1 Problem-
Solving
Agents…

Artificial Intelligence CSC-350 9


3.1 Problem-Solving Agents…
• Search: Searching is a step by step procedure to solve a search-problem in a given search space.
A search problem can have three main factors:
• Search Space: Search space represents a set of possible solutions, which a system may
have.
• Start State: It is a state from where agent begins the search.
• Goal test: It is a function which observe the current state and returns whether the goal state is
achieved or not.
• Search tree: A tree representation of search problem is called Search tree. The root of the search
tree is the root node which is corresponding to the initial state.
• Actions: It gives the description of all the available actions to the agent.
• Transition model: A description of what each action do, can be represented as a transition model.
• Path Cost: It is a function which assigns a numeric cost to each path.
• Solution: It is an action sequence which leads from the start node to the goal node.
• Optimal Solution: If a solution has the lowest cost among all solutions.
Artificial Intelligence CSC-350 10
3.1.1 Well-defined problems and solutions
A problem can be defined by five components:
1. The initial state the agent starts in.
2. Possible actions available to the agent.
ACTIONS(s) returns the set of actions that can be executed in s state.
{Go(up), Go(down),Go(left),Go(right)}
3. Transition Model needed to describe what each action do.
RESULT(s, a), return the next state after input a on s
These three components defines state space of the problem.
State space form a directed graph contains nodes, links and actions
4. A path connects the states in state space.
5. The goal test, 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.
Artificial Intelligence CSC-350 11
12

Path cost assign the numeric cost to each


path.

3.1.1 Well- An agent chooses a cost function as


defined performance measure.
problems and C(s, a, s’) cost applied from state s to s’
solutions on action a.

C is called the optimal solution when it


has lowest path cost among all solutions.

Artificial Intelligence CSC-350


Romania Problem
• An agent is in the city of Arad, Romania,
enjoying a touring holiday
• The agent has a nonrefundable ticket to fly
out of Bucharest the following day

• Goal:
• Reach Bucharest on time, so that the
agent can catch the flight the next day.

Artificial Intelligence CSC-350 13


3.1.1 Well-defined problems and solutions
A problem can be defined by five components:
1. The initial state the agent starts in.
• Initial state for our agent = In (Arad)
2. A description of possible actions available to the agent.
• E.g., From the state In(Arad) the applicable actions are {Go(Sibiu, Go(Timisoara), Go(Zerind)}
3. A description of Transition Model (what each action does).
• What happen when you are in s state and your take a action
• RESULT(s, a), return the next state after input a on s
• RESULT(In(Arad), Go(Zerind)) = In(Zerind)

4. A path connects the states in state space.


5. The goal test, determines whether a given state is a goal state.
• Goal states = {In(Bucharest)}

Artificial Intelligence CSC-350 14


3.1.1 Well-defined problems and solutions (Optimal Solution)
• A solution to a problem is:
• An action sequence that leads
from initial state to goal state
• Solution quality is measured by the
path cost function
• Path cost assign the numeric cost to
each path.
• C(s, a, s’) cost applied from state s to
s’ on action a.
• C is called the optimal solution when
it has lowest path cost among all
solutions.

Artificial Intelligence CSC-350 15


3.1.2 Abstraction when formulating problem
• So many details in the actual world!
• Actual World State = the traveling with companions, the scenery out of the
window, etc
• Abstract Mathematical State = In(Arad)
• We left out all other considerations in the state description because they
are irrelevant to the problem of finding a route to Bucharest.
• The things ignored in abstraction can be considered while calculating the
cost of action. E.g., the cost of going from Arad to Sibiu is 140 might not
reflect the miles but all other aspects as well.
• This process of removing details from the representation is called
abstraction.
• Choosing the level of abstraction
• How many details do we need to consider
Artificial Intelligence CSC-350 16
3.2 Example Problem

Artificial Intelligence CSC-350 17


3.2.1 toy problem
• Sliding-block puzzle
• 3x3 board with eight numbered tiles and a blank space
• A tile adjacent to the blank space can slide into the space
• The objective is to reach a specified goal state

Artificial Intelligence CSC-350 18


3.2.1 Formulating the Vacuum World problem

Artificial Intelligence CSC-350 19


3.2.1 The Vacuum World Problem

Artificial Intelligence CSC-350 20


3.2.2 Real-world problem: route-finding problem
• Airline travel problems for a travel-planning Website:

Artificial Intelligence CSC-350 21


3.2.2 Real World Problem (touring problem)

Artificial Intelligence CSC-350 22


3.2.2 Real World Problem (Touring problem)
• The touring problems are slightly different from the route-finding problems
• E.g., the agent wants to visit every species of animal at a Zoo at least once,
starting and ending Ostrich cage
• The state space is quite different. Each state must include not just the current
location but also the set of cities the agent has visited.
• Initial state
• In(Ostrich-house), Visited({Ostrich-house}),
• a typical intermediate state
• In(Giraffe-house), Visited({Ostrich-house, Gorilla-house, Elephant-house}),
• Goal test
• Check whether the agent is in Ostrich-house and visited all houses of animals in
the Zoo
Artificial Intelligence CSC-350 23
3.3 Searching Algorithms

Artificial Intelligence CSC-350 24


3.3 Searching Algorithms
• State Space = {“All possible configurations”}

Artificial Intelligence CSC-350 25


3.3 What exactly is “Searching for
Solution”
• Having formulated some problems, we now
need to solve them.
• A solution is an action sequence,
• search algorithms work by considering
various possible action sequences.
• Possible action sequences, starting at the
initial state form a search tree with
• Initial state at the root
• Branches are the actions
• Nodes correspond to states in the state
space of the problem

Artificial Intelligence CSC-350 26


3.3 What exactly is “Searching for Solution” example
• Root node corresponds to initial state, In(Arad)
• First step is to test whether this is a goal state?
• Then we need to consider taking various
actions
• We do this by expanding the current state
• i.e., applying each legal action to the current state,
thereby generating a new set of states (Transition
model)
• We add three branches from the parent node
In(Arad) leading to three new child nodes
• In(Sibiu), In(Timisoara) and In(Zerind)
• Now we must choose which of these three
possibilities to consider further

Artificial Intelligence CSC-350 27


3.3 What exactly is “Searching for Solution” example
• Suppose we choose Sibiu first
• Check to see whether it is a goal state(it is
not) and then expand it to get In(Arad),
In(Fagaras), In(Oradea) and
In(RimnicuVilcea)
• We can then choose any of these four or go
back and choose Timisoara or Zerind
• Each of these six node is a leaf node
• 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
• Tree consists of those nodes with bold
outlines

Artificial Intelligence CSC-350 28


3.3 What exactly is “Searching for Solution” example

Artificial Intelligence CSC-350 29


3.3 Searching Algorithms
• A search algorithm takes a search problem as input and returns a solution, or
an indication of failure.
• We map on search tree over the state-space graph
• Creating paths from initial state
• Find a path that reaches a goal state
• Tree node corresponds to a state, Tree edges correspond to actions, Tree
root corresponds to initial state of the problem, Leaf Node is a node with no
children in the tree.
• Why we need search tree instead state space?
• State space possibly shows infinite states, and allow transition from one state to
another
• The search tree may have multiple paths to any particular state but each node has one
path to its root.

Artificial Intelligence CSC-350 30


3.3.1 Data structure to keep track of the search tree
• 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
• A node is a bookkeeping data structure used to represent the search tree
• A state corresponds to a configuration of the world

Artificial Intelligence CSC-350 31


3.3 Searching Algorithms

Artificial Intelligence CSC-350 32


3.3 Searching Algorithms

Figure 3.4 shows the first few steps in finding a path


from Arad to Bucharest.

Artificial Intelligence CSC-350 33


3.3 Searching Algorithms
Figure 3.4 shows the first few steps in finding a path
from Arad to Bucharest.
- Root node is Arad
- Expand Node based on ACTIONS of RESULT
function to generate new Node called child node.

Artificial Intelligence CSC-350 34


3.3 Searching Algorithms
Tree generated by graph search

Artificial Intelligence CSC-350 35


3.3 Searching Algorithms

Artificial Intelligence CSC-350 36


3.3.2 Measuring problem-solving performance
• Evaluation of search algorithm’s performance:
1. COMPLETENESS: Is the algorithm guaranteed to find a solution when there
is one?
2. OPTIMALITY: Does the strategy find the optimal solution, i.e. a solution posses
lowest path cost among all solutions.
3. TIME COMPLEXITY: How long does it take to find a solution?
4. SPACE COMPLEXITY: How much memory is needed to perform the search?
For S&T complexity, the typical measure is size of the state space graph.

Artificial Intelligence CSC-350 37


3.3.2 Measuring problem-solving performance…
• In AI, the graph is often represented implicitly by the initial state, actions, and transition
model and is frequently infinite.

• For these reasons, complexity is expressed in terms of three quantities:


a) branching factor (b) or maximum number of successors of any node
b) depth (d) of the shallowest goal node (i.e., the number of steps along the path
from the root)
c) maximum length (m) of any path in the state space (may be infinite).

• Time is often measured as number of nodes generated during the search, and
space as maximum number of nodes stored in memory.

Artificial Intelligence CSC-350 38


• We can compute search cost to assess search
3.3.2 algorithms effectiveness.
Measuring • Search cost can be time complexity or memory
usage.
problem- • Or otherwise we can use the total cost:
solving • Which combines, search cost and path cost of
the solution found.
performance… • Like path cost can be in kilometers

Artificial Intelligence CSC-350 39

You might also like