My AI CH 3

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

1

DEBRE TABOR UNIVERSITY


FACULTY OF TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE

Artificial Intelligence (CoSc4142)

Slides by: Wondifraw Manaye


2

CHAPTER - 3

SOLVING PROBLEMS BY SEARCHING AND


CONSTRAINT SATISFACTION PROBLEM

Slides By: Wondifraw Manaye


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.
3
Problem-Solving Agents
 An agent that tries to come up with a sequence of actions that will bring
the environment into a desired state.
 The process of looking for such a sequence, involving a systematic
exploration of alternative actions.
 A problem-solving agent is a kind of goal based agent.
 Goal based agents: consider future actions and desirability of their
outcomes.
4
Problem-Solving Agents (Cont’d…)

 It is known as, if the agent can adopt a goal and aim at satisfying it.

Example: 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.
5
Problem-Solving Agent
Four general steps in problem solving:

 Goal formulation
 What are the successful world states
 Problem formulation
 What actions and states to consider given the goal
 Search
 Examine different possible sequences of actions that lead to states
of known value and then choose the best sequence
 Execute
 Perform actions on the basis of the solution
6
Goal Formulation

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


measure, 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.
 The agent’s task is to find out how to act, now and in the
future, so that it reaches a goal state.
7
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.
8
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.
9
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.

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

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


solution in the form of an action sequence.

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
11 environment.
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

12
Well-defined problems and solutions

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
13
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, RESULT (In (Arad), Go (Zerind)) = In (Zerind).
 Together the initial state, actions and transition model implicitly define
the state space of the problem the set of all states reachable from the
14
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
15
of taking action a in state s to reach state s1
For example, consider the map of Romania in Figure

16
The problem formulation is therefore:

Initial state: at Arad

Actions: the successor function S:


 S(Arad) = {<AradZerind, Zerind>, <AradSibiu, Sibiu>,<AradTimisoara,
Timisoara}
 S(Sibiu) = {<SibiuArad, Arad>, <SibiuOradea, Oradea>, < Sibiu Fagaras,
Fagaras>, SibiuRimnicu Vilcea, Rimnicu Vilcea>}, etc.

Goal test: at Bucharest

Path cost: c(Arad, AradZerind, Zerind) = 75, c(Arad, AradSibiu, Sibiu) = 140,
c(Arad, Arad Timisoara, Timisoara)17= 118, etc.
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.
 The solution to drive from Arad to Bucharest is Arad to Sibiu to
Rimnicu Vicea to Pitesti to Bucharest must be a solution.
18
Example problems:

 Toy problem: is intended to illustrate or exercise various problem


solving methods.
 It can be given a brief, exact description and hence is usable by different
researchers to compare the performance of algorithms.
 Real world problems: is one whose solutions people actually care
about.
 Such problem tends not to have a single agreed-upon description, but we
19
Toy problems:

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.

20
Con’t…
 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. Note that
any given goal can be reached from exactly half of the possible initial
states.
 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.
21
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. 22
Real World problems:

1. 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.
23
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
24
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
25
and so on.
Basic Search Algorithms (Group Assignment)
26

1. Breadth-First Search
2. Uniform-Cost Search
3. Depth-First Search
4. Depth Limited Search
5. Iteratively Deepening Search
6. Bidirectional Search
27

THANK YOU
Q&A
?

You might also like