Solving Problems by Searching

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Artificial Intelligence

Solving problems by searching

B E (CSE) B Section, Semester 5


T. T. Mirnalinee
Department of Computer Science and Engineering
SSN College of Engineering
12th August 2020
Outline
• Problem solving agent – goal based,atomic representation
• Planning agents – factored/structures
• Problems and their solutions
• Uninformed search – no information about the problem apart from
its definition
• Informed – some guidance on where to look for solutions
Steps in problem solving agents

• Goal formulation – based on current situation and agents


performance – agents task is how to act to reach the goal
• Problem formulation – process of deciding what actions and states to
consider given a goal - state is the teown
• Travelling from one city to other, no idea about the city (which road
leads to the city) – unknown (environment)
• If map of the city is available he has some information
Problem solving agent - Formulation
• Solution is a fixed sequence of actions
• Environment is observable, discrete (at any state, finite actions to
choose from), known – what state to reach after every action,
deterministic – each action has one outcome
Problem solving agent - Search
• The process of looking for a sequence of actions that reaches the goal
is called search.
• Input: problem
• Output: solution in the form of action sequence
• Execution phase: once solution is found, the action it recommends
can be carried out
• Formulate, search, execute – after formulating a goal and problem –
agent calls a search procedure to solve it, after a solution is identified,
formulate new goal
Problem solving agent
function SIMPLE-PBM-SOL-AGT(percept) returns an action
persistent: seq-an action sequence, state- description of world state, goal –
a goal, problem – initial problem formulation
State<- UPDATE-STATE(state,percept)
If seq is empty then
goal<- FORMULATE-GOAL(state)
problem<- FORMULATE-PROBLEM(state,goal)
seq<- SEARCH(problem)
If seq = failure then return a null action
Action <- FIRST(seq)
Seq<- REST(seq)
return action
Well defined problems
• Five components
Initial state
Actions – all possible actions from state s
Transition model – description of what action does
Goal test – given state is goal?
Pathcost – function assigns cost to each path, cost function reflects the
performance measure

• State space – initialstate, actions, transition model together form a graph (nodes:
states, link:actions, path: sequence of states connected by a sequence of actions
Solution
• 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,
• optimal solution has the lowest path cost among all solutions
Problem formulation
• Toy problem – exact descriptions, compare the performance of
various algorithms
• Real world problem – no single exact definition, can have general
flavour of their formulation
Vacuum Cleaner
Vacuum Cleaner
• 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 × 22 = 8 possible world states.
• A larger environment with n locations has n * 2n states.
• Initial state: Any state can be designated as the initial state.
• Actions: In this simple environment, each state has just three actions: Left, Right, and
Suck. Larger environments might also include Up and Down.
• Transition model: 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 squares are clean.
• Path cost: Each step costs 1, so the path cost is the number of steps in the path.
States: A state description specifies the location of each

8 Puzzle 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 (Exercise 3.4).
• 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.
• Transition model: Given a state and action, this returns
the resulting state; for example,
if we apply Left to the start state in Figure 3.4, the
resulting state has the 5 and the blank
switched.
• Goal test: This checks whether the state matches the
goal configuration shown in Figure
3.4. (Other goal configurations are possible.)
• Path cost: Each step costs 1, so the path cost is the
number of steps in the path.
8-Queens problem
• The goal of the 8-queens problem is to place eight queens on a
chessboard such that no queen attacks any other. (A queen attacks
any piece in the same row, column or diagonal.)
• An incremental formulation : starting with an empty state; for the 8-
queens problem, this means that each action adds a queen to the
state
• complete-state formulation starts with all 8 queens on the board and
moves them around. In either case, the path cost is of no interest
because only the final state counts.
8-Queens problem
• 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.
Real World Problems
• Routing video streams in computer networks,
• Military operations planning,
• Airline travel-planning systems
• Touring problems
• Traveling salesperson problem
• VLSI layout
• Robot navigation
• Automatic assembly sequencing
Airline travel-planning systems
• States: Each state obviously includes a location (e.g., an airport) and the current time.
Furthermore, because the cost of an action (a flight segment) may depend on previous
segments, their fare bases, and their status as domestic or international, the state must
record extra information about these “historical” aspects.
• Initial state: This is specified by the user’s query.
• Actions: Take any flight from the current location, in any seat class, leaving after the
current time, leaving enough time for within-airport transfer if needed.
• 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 we at 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.

You might also like