0% found this document useful (0 votes)
58 views36 pages

AI Chapter 3

1) The document discusses problem solving by intelligent agents. It defines a problem as the gap between the actual and desired situation. 2) There are two main types of problems - toy problems that test algorithms, and real-life problems that are more complex with no agreed description. Problem solving involves searching for a solution. 3) A problem solving agent formulates a goal, represents the problem as initial state, actions, transition model and path costs, then searches for a solution path and executes it. Real-world problems like navigating between cities can be modeled this way.

Uploaded by

Mulugeta Hailu
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)
58 views36 pages

AI Chapter 3

1) The document discusses problem solving by intelligent agents. It defines a problem as the gap between the actual and desired situation. 2) There are two main types of problems - toy problems that test algorithms, and real-life problems that are more complex with no agreed description. Problem solving involves searching for a solution. 3) A problem solving agent formulates a goal, represents the problem as initial state, actions, transition model and path costs, then searches for a solution path and executes it. Real-world problems like navigating between cities can be modeled this way.

Uploaded by

Mulugeta Hailu
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/ 36

CHAPTER - 3

SOLVING PROBLEMS BY SEARCHING AND


CONSTRAINT SATISFACTION PROBLEM
 problem solving agent
 How to formulate a problem
 Search strategies
INTRODUCTION
 What is a Problem?

 It is a gap between what actually is and what is desired.

 A problem exists when an individual becomes aware of the existence of a


significant difference between the expected and the actual situation, which
is an obstacle and makes it difficult to achieve a desired goal or objective.
 A number of problems are addressed by designing intelligent agent.
2
Types of problems
Toy problems: are problems that are useful to test and demonstrate methodologies and can be
used by researchers to compare the performance of different algorithms.
 is intended to illustrate or exercise various problem solving methods.
e.g. 8-puzzle, n-queens, vacuum cleaner world, towers of Hanoi, river crossing etc.…
Real-life problems: are problems that have much greater commercial/economic impact if
solved.
Such problems are more difficult and complex to solve, and there is no single agreed-upon
description. but we can give the general flavor/taste of their formulations.
E.g. Route finding, Traveling sales person, etc.
3
Problem solving by searching:

 Most real world problems are solved by searching for solution.


 Problem solving by searching: How an agent can find a sequence of actions
that achieve its goals when no single action will do.
 Our aim is building Goal-based Intelligent Agent
Building Goal-Based Agents
 An agent which has a goal to reach by applying a sequence of actions
starting the initial state
 To build a goal based agent, which solves certain problems, we need to answer the following basic
questions:
 What is the goal to be achieved?
 What are the actions?
 What relevant information is necessary to encode about the world to describe the state of the
world, describe the available transitions, and solve the problem?

Here are some examples of goals to be achieved by an intelligent goal based agents.
 To drive from city A to city B crossing many intermediate transition states.

 To put 8 queens on a chess board such that no one attacks another


Problem-Solving Agents

 is a kind of goal based agent


 It is known as, if the agent can adopt a goal and aim at satisfying it.
Steps in problem solving
1. Goal formulation
isa step that specifies exactly what the agent is trying to achieve by limiting the objective of
the agent.
This step narrows down the scope that the agent has to look at

2. Problem formulation
is a step that puts down the actions and states that the agent has to consider given a goal.
3. Search
isthe process of looking for the various sequence of actions that lead to a goal state,
evaluating them and choosing the optimal sequence.
4. Execute
isthe final step that the agent executes the chosen sequence of actions to get it to the
solution/goal
6
Real World problem: Examples

1.Touring Problem:

Imagine an agent in the city of Arad, Romania enjoying a touring holiday. The
agent’s performance measure contain many factors - enjoying, sights visited etc.,

 Now, suppose the agent has a nonrefundable ticket to fly out to Bucharest the
following day. In that case, it makes sense for the agent to adopt the goal of
getting to Bucharest.
1.Goal Formulation

 Based on the current situation and the agent’s performance


measure, it is the first step in problem solving.

 We will consider a goal to be a set of world states exactly


those states in which the goal is satisfied.

T he agent’s goal is reach Bucharest.

8
2. Problem Formulation

 It is the process of deciding what actions and states


to consider, given a goal.
Example: Let us assume that the agent will consider actions at the
level of driving from one major town to another. Each state
corresponds to being in a particular town.

 While “examining future actions”, we have to be more specific


about properties of the environment.
9
In our example, we assume that the environment is:-

 Observable:- the agent always knows the current state.

 For the agent driving in Romania, it’s reasonable to suppose that each
city on the map has a sign indicating its presence to arriving drivers.

 Discrete:- at any given state there are only finitely many actions to
choose from.

 This is true for navigating in Romania because each city is connected to


a small number of other cities.
10
Con’t…
 Known:- the agent has known which states are reached by each action.

 Having an accurate map suffices to meet this condition.

 Deterministic:- each action has exactly one outcome.

 It means that if an agent chooses to drive from Arad to Sibiu, it does end
up in Sibiu.

3. Search: The process of looking for a sequence of actions that reaches the
goal is called search.
11
Con’t…

Solution: A search algorithm takes a problem as input and returns a


solution in the form of an action sequence.

4. Execution: Once a solution is found, the action it recommends can be


carried out. This is called the execution phase.

Open-Loop: 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 is called open-loop system, because ignoring the percepts breaks
the loop between agent and environment.
12
Fig. 1 A simple problem solving agent. It first formulates a goal and a problem,
searches for a sequence of actions that would solve the problem, and then executes
the actions one at a time. When this is complete, it formulates another goal and starts
over

13
Well-defined problems and solutions(Problem
Formulation
A problem can be defined formally by five components.
1. Initial State: That the agent starts in.
 In our example, the initial state for our agent in Romania might be described as In
(Arad).
2. Actions: A description of possible actions available to the agent.
 Given a particular state s, ACTIONS (s) returns the set of actions that can be
executed in s. We say that each of these actions is applicable in s.
 In our example, from the state In (Arad), the applicable actions are
{Go (Sibiu), Go (Timisoara), Go (Zerind)}
14
Con’t…
3. Transition model or Successor: A 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.

 In our example, if RESULT (In (Arad), Go (Zerind)) = In


(Zerind).
15
Con’t…
4. 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.

 In our example, the agent’s goal in Romania is the singleton set {In (Bucharest)}.

5. Path Cost: A function that assigns a numeric cost to each path.

 For the agent trying to get to Bucharest, time is of the essence, so the cost of a path might
be its length in kilometers.

 We assume that the cost of a path can be described as the sum of the costs of the
individual actions along the path. The step cost of taking action a in state s to reach state s1
is denoted by c(s, a, s1).
16
State Space
 Together the initial state, actions and transition model implicitly define the state
space of the problem -the set of all states reachable from the initial state by any
sequence of actions.
 It represents a problem in terms of states and operators that change states.
 The state space forms a directed network or graph in which the nodes are
states and the links between nodes are actions. (The map of Romania shown
in Figure below can be interpreted as a state-space graph)
 Generally, A state space is a graph, (V, E), where V is a set of nodes and E is
a set of arcs, where each arc is directed from a node to another node
For example, consider the map of Romania in Figure.2

18
The problem formulation is therefore:

Initial state: at Arad

Actions: with the successor function S:

 S(Arad) = {<AradZerind, Zerind>, <AradSibiu, Sibiu>,<AradTimisoara,


Timisoara}

Goal test: at Bucharest

Path cost: c(Arad, AradZerind, Zerind) = 75, c(Arad, AradSibiu, Sibiu) = 140,
c(Arad, Arad Timisoara, Timisoara) = 118, etc.

19
Con’t…

 For example, if the agent is in the state Arad, there are 3 possible
actions,

 Arad  Zerind, Arad  Sibiu and Arad  Timisoara, resulting


in the states Zerind, Sibiu and Timisoara respectively.

20
Cont…
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.


 An optimal solution has the lowest path cost among all solutions.

There fore, The solution to drive from Arad to Bucharest is


Arad Sibiu Rimnicu Vicea Pitesti Bucharest must be a solution.
Example 2. Route-finding problem:

Route- finding problem: is defined in terms of specified locations


and transitions along links between them.

 Route-finding algorithms are used in a variety of applications


such as, websites, in car systems to provide driving directions,
routing video streams in computer networks, military operations
planning, airline travel planning systems.
22
Consider the air line travel problems: that must be solved by a travel-
planning web site:

States: Each state obviously includes a location (airport) and the current
time. Furthermore, the state must record extra information like, base fare,
flight segment, their status as domestic or international, to decide the cost
of an action.
Initial state: This is specified by the user’s query.

Actions: Take any flight from the current location, in any seat class,
leaving the current time, leaving enough time for within airport
transfer if needed.
23
Con’t…

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 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.
24
Toy problems: Example

1. 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 objective is to reach a specified goal state.

25
Con’t…

 States: 3 x 3 array configuration each of the eight tiles on the board and
the blank in one of the nine squares.

 Initial State: a figure given in the initial state configuration.

 Actions: The simplest formulation defines the action on movements of the


blank space Left, Right, Up or Down.

 Transition Model: Given a state and action, this returns the resulting state.
Example: If we apply left to the start state in figure, the resulting state has
the 5 and the blank switched.
26
Con’t…

 Goal Test: This checks whether the state matches the goal
configuration as shown in figure.

 Path cost: Each cost costs 1, so the path cost in the number of steps
in the path.

Note: The 8-puzzle belongs to the family of sliding-block puzzles,


which are often used as test problems for new search algorithms in
AI.
27
Example2. Vacuum cleaner world:
I have a vacuum cleaner agent and the goal of this agent, is to clean up my house.
The house has a total of two rooms and there is only one vacuum cleaner. The
vacuum cleaner is present in any one of these rooms and each of the room can be
in to different states(clean, dirty).

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 × 2 2 = 8 possible world states. A larger environment with n
locations has n · 2 n states where n is the number of rooms.
28
Con’t…
Con’t…
 Initial state: Any state can be designated and taken as the initial state.

 Actions: In this simple environment, each state has just three actions: move Left, Right, and
Suck. However, larger environments can also include other actions such as move Up and
move Down in the state space.

 Transition State: 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 rooms are clean or not.

 Path Cost: Each step costs a unit cost (1), so the path cost is the number of steps in the path.
Move right cost=>1, Move Left cost=>1.
30
Fig . The state space for the vacuum world
 Links denote actions: L = Left, R = Right, S = Suck
Con’t…

 What will happen if the agent is initially at [state = 5] and formulates action
sequence [Right, Suck]? Agent calculates and knows that it will get to a goal state.
 If the agent moves Right then, it is on state  {6}

 After taking the action Suck the dirt in state six, the agent is finally on state  {8}

N.B: If the environment is completely observable, the vacuum cleaner always knows
where it is and where the dirt is. The solution then is reduced to searching for a path
from the initial state to the goal state easily.
Exercise: River Crossing Puzzles

Missionary-and-cannibal problem
 Three missionaries and three cannibals are on one side of a river that they wish to
cross. There is a boat that can hold one or two people. Find an action sequence that
brings everyone safely to the opposite bank (i.e. Cross the river). But you must never
leave a group of missionaries outnumbered by cannibals on the same bank (in any
place).
 Identify the set of possible states and operators
 Construct the state space of the problem using suitable representation
Exercise:

Goat, Wolf and Cabbage problem

 A farmer returns from the market, where he bought a goat, a cabbage and a wolf. On
the way home he must cross a river. His boat is small and unable to transport more
than one of his purchases. He cannot leave the goat alone with the cabbage (because
the goat would eat it), nor he can leave the goat alone with the wolf (because the
goat would be eaten). How can the farmer get everything safely on the other side?

 Identify the set of possible states and operators

 Construct the state space of the problem using suitable representation


Cont…
36

CONT….
THANK YOU
?

You might also like