0% found this document useful (0 votes)
34 views

Chapter 3 (Part 1) - Solving Problems by Searching

Uploaded by

Queen Malik
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Chapter 3 (Part 1) - Solving Problems by Searching

Uploaded by

Queen Malik
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 35

CS-2103

ARTIFICIAL INTELLIGENCE

Chapter 3: Solving Problems by Searching


Instructor: Dr. Shafina
Overview

 Problem-Solving Agents
 Example Problems
 Searching for Solutions
 Uninformed Search Strategies
 Avoiding Repeated States

Dr. Shafina, Department of CS&IT, UOK


Problem-Solving Agents
 Problem-solving agent in AI is goal-based agent that focus on goal
 An agent that tries to come up with a sequence of actions that will bring
the environment into a desired state.
 Reach goals through sequences of actions
 Steps
 Formulate the goal(s) and the problem
 Search for a sequence of actions to reach a goal state
 A solution is a sequence of actions from initial state to a goal state
 Execute the sequence of actions

Dr. Shafina, Department of CS&IT, UOK


Steps of Problem solving in AI
 The problem of AI is directly associated with the nature of humans and
their activities.
 So we need a number of finite steps to solve a problem which makes
human easy works.

 These are the following steps which require to solve a problem :


 Goal Formulation: This one is the first and simple step in problem-solving. It
organizes finite steps to formulate a target/goals which require some action to
achieve the goal. Today the formulation of the goal is based on AI agents.
 Problem formulation: It is one of the core steps of problem-solving which
decides what action should be taken to achieve the formulated goal. In AI this
core part is dependent upon software agent.

Dr. Shafina, Department of CS&IT, UOK


Goal Formulation

 To solve a problem, The first step is Goal Formulation


 In goal formulation, the goal is to be set and we should assess
those states in which the goal is satisfied.
 Actions are required to reach from initial state to goal state

Dr. Shafina, Department of CS&IT, UOK


Formulating the Problem, Contd….
The problem is define by five components:
1. Initial state: start state
2. Actions: set of all possible actions
3. Transition model: The description of what each action does
 Successor refers to any state reachable from a give state by a single action
 Together, the initial state, actions and transition model implicitly define the
state space of the problem.
 State Space: the set of all states reachable from the initial state by any
sequence of actions
4. The goal test determines if a state is a goal state
A path is a particular sequence of states, connected by particular actions
5. The path cost function assigns a numeric cost to each path

Dr. Shafina, Department of CS&IT, UOK


Solution of a Problem

 A solution to a problem is an action sequence that leads from


initial state to a goal state
 Solution quality is measured by the path cost function
 Optimal solution: a solution with minimal path cost

Dr. Shafina, Department of CS&IT, UOK


Problem-Solving Agents

Dr. Shafina, Department of CS&IT, UOK


Example Problems
 “Toy” Problems:
 intended to illustrate or exercise various problem-solving methods
 Simple, but useful for theory and analysis
 Vacuum world, Sliding-block puzzles, N-Queens
 Real Problems or Real-world Problems:
 Whose solutions people actually care about
 The solutions are more useful, but not as helpful to theory
 Route-finding, touring, assembly sequencing, Internet searching

Dr. Shafina, Department of CS&IT, UOK


Example: The Vacuum World
 Vacuum cleaner problem is a well-known search problem for an agent
which works on Artificial Intelligence. In this problem, our vacuum
cleaner is our agent. It is a goal based agent, and the goal of this agent,
which is the vacuum cleaner, is to clean up the whole area.

 States: Location, dirt or not


 Initial State: Given by problem
 Goal: No dirt in any location
 Actions: Left, Right, Vacuum, NoOp
 Path Cost: 1 per action (0 for NoOp)

Dr. Shafina, Department of CS&IT, UOK


Example: The Vacuum World

 States
 8 states
 Initial state
 Any state
 Actions
 Left, Right, Vacuum, noop
 Goal test
 Whether both squares are clean
 Path cost
 Each step costs 1

Dr. Shafina, Department of CS&IT, UOK


State Space for the Vacuum
World

Dr. Shafina, Department of CS&IT, UOK


The Vacuum World
 This can be formulate as a problem as follows

Dr. Shafina, Department of CS&IT, UOK


Example: Driving in Romania

 On holiday in Romania, Currently in Arad


 No-refundable ticket to fly out of Bucharest tomorrow
 Formulate goal: be in Bucharest before the flight
 Formulate Problem:
 States: Various cities
 Actions: drive between cities
 Search: Sequence of cities

Dr. Shafina, Department of CS&IT, UOK


Example: Driving in Romania

Dr. Shafina, Department of CS&IT, UOK


 Arad to Sibiu to Fagaras
 140+99+211=450

Dr. Shafina, Department of CS&IT, UOK


Example: 8-Puzzle
 Also known as N- Puzzle problem or sliding puzzle
problem
 Played on 3x3 grid with 8 square blocks labelled 1
through 8 and a blank square

Dr. Shafina, Department of CS&IT, UOK


Problem Formulation

 States:- A state description specifies the location of each of the eight tiles and the
blank in one of the nine squares
 Initial state: – start sate
 Actions: Blank moves left, right, up, or down.
 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 (from book), the resulting
state has the 5 and the blank switched.
 Goal test: – Checks whether the states matches the goal configured in the goal state
shown in the picture (other goal configurations are possible)
 Path cost: – Each step costs 1, so the path cost is the sum of steps in the path

Dr. Shafina, Department of CS&IT, UOK


Abstraction
 The process of removing detail from a representation is
called abstraction.

 What abstractions have we included here?


 The actions are abstracted to their beginning and final states, ignoring the
intermediate locations where the block is sliding. We have abstracted away actions
such as shaking the board when pieces get stuck and ruled out extracting the pieces
with a knife and putting them back again. We are left with a description of the rules
of the puzzle, avoiding all the details of physical manipulations.

Dr. Shafina, Department of CS&IT, UOK


Example: Robotic Assembly

 States:- Real-valued coordinates of robot joint angles; parts of the object to be


assembled
 Actions:- continuous motions of robot joints
 Transition model:- States of robot joints after each action
 Goal test:- complete assembly
 Path cost: time to execute

Dr. Shafina, Department of CS&IT, UOK


Example: River Crossing

 Items: Man, Wolf, Corn, Chicken.


 Man wants to cross river with all items.
 Wolf will eat Chicken
 Chicken will eat corn.
 Boat will take max of two

Dr. Shafina, Department of CS&IT, UOK


Dr. Shafina, Department of CS&IT, UOK
Dr. Shafina, Department of CS&IT, UOK
Dr. Shafina, Department of CS&IT, UOK
Dr. Shafina, Department of CS&IT, UOK
Real-world Problems

 Touring Problem
 Travelling sales problem
 Robot navigation
 Internet searching

Dr. Shafina, Department of CS&IT, UOK


Task of the week

 What is :
 Touring problem
 Travelling sales person problem
 VLSI layout
 Robot navigation
 Protein Design

Dr. Shafina, Department of CS&IT, UOK


Searching for Solutions
 State space can be represented as a search tree
(or graph) of search nodes
 Each node represents a state
 Many nodes can represent the same state
 Each arc represents a valid action from one state
to another
 A solution is a path from initial to goal nodes

Dr. Shafina, Department of CS&IT, UOK


Search Nodes

 A search node is a data structure that contains


 The real-world state represented by the node
 The parent node that generated it
 The action that lead to it
 The path cost to get to it (from the initial state)
 Its depth (the number of steps to reach it from the initial state)

Dr. Shafina, Department of CS&IT, UOK


Searching for solution
 Generating
Generating new set of states by expanding the current state
 Leaf node
A node with no children in the tree
 Frontier
The set of all leaf nodes available for expansion at any given point is
called the frontier.
 Repeated state
The state generated by loopy path
 Loopy path
a loopy path is a special case of redundant paths, where there are more
than one paths from one state to another

Dr. Shafina, Department of CS&IT, UOK


Searching for Solutions
 The search tree starts with just the root node, which
represents the initial state
 First, use the goal test to see if the root is a goal
 If not, expand this node, which generates new nodes
 Use successor function to apply valid actions. The results of
these actions lead to new states, represented by new nodes
 Nodes that are generated, but not yet expanded are in the
fringe, (physically a queue data structure)

Dr. Shafina, Department of CS&IT, UOK


Search Strategies

 Given several states, which to consider (i.e., goal test, expand,


etc.) first?
 This is determined by the particular search strategy being used in the
algorithm

Dr. Shafina, Department of CS&IT, UOK


General Idea

Dr. Shafina, Department of CS&IT, UOK


Search Algorithm Performance
 Performance measured along four dimensions:
 Completeness: Will the algorithm always return a solution, if one exists?
 Optimality: Will it always return the optimal solution, if one exists?
 Time complexity: How long does it take?
 Space complexity: How much memory does it take?
 Complexity is expressed in terms of three quantities:
 Branching factor (b)or maximum number of successors of any node
 Depth of shallowest goal node i.e (the number of steps along the path from the root
(d)
 Maximum length of any path in the state space (m)
 Search cost vs. total cost
 to assess the performance of a search algorithm, we can consider just the
search cost. OR
 Total Cost: includes the search cost and path cost of the solution found

Dr. Shafina, Department of CS&IT, UOK


Uninformed Search

 Uninformed (or “blind”) search algorithms can only


generate successor nodes and do the goal test
 No other “problem insight”, common sense, etc. is used in finding a
solution
 Search strategies differ in how they choose which node to
check/expand next

Dr. Shafina, Department of CS&IT, UOK

You might also like