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

Problem Solving by Searhing

Uploaded by

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

Problem Solving by Searhing

Uploaded by

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

Problem

Solving by
Searching

1
2
Disclaimer Statement
In preparation of these slides, materials have been taken from
different online sources in the shape of books, websites,
research papers and presentations etc. However, the author
does not have any intention to take any benefit of these in
her/his own name. This lecture (audio, video, slides etc) is
prepared and delivered only for educational purposes and is
not intended to infringe upon the copyrighted material.
Sources have been acknowledged where applicable. The
views expressed are presenter’s alone and do not necessarily
represent actual author(s) or the institution.
SEARCH
Search involves trying to find a particular object
from a large number of such objects.
A search space defines the set of objects that we are
interested in searching among.
A few Examples:

Board games. The system searches for a move


that is likely to lead to winning configuration.
Theorem proving. Given the axioms and the rules
of inference, the objective in this case is to find a
proof whose last line is the formula that one
wishes to prove.
3
STATE SPACE PROBLEM
DEFINITION
• One widely used way to describe
problems is by listing or describing
all possible states.
• Solving a problem means moving
through the state space from a start
state to a goal state.
• Need to devise a set of operators that
move from one state to another. 4
STATE SPACE PROBLEM
DEFINITION
• Set of possible states.
• Set of possible operations that
change the state.
• Specification of a starting
state(s).
• Specification of a goal state(s).
5
STATE SPACE
• It is usually not possible to list all
possible states because of various
constraints:
– Use abstractions to describe states.
– Use a general description of the state
space.
– Describe set of constraints.

6
OPERATIONS
• The problem solving system moves from
one state to another according to well
defined operations.
• Typically these operations are described as rules
.
• A control system decides which rules are
applicable at any state, and resolves conflicts
and/ or ambiguities.

7
EXAMPLE: WATER JUG PROBLEM

4 Gal 3 Gal

Goal: 2 Gallons Water in the 4 Gallon Jug


8
WATER JUG STATE SPACE
•The state can be represented by 2
integers x and y:
•x = gallons in the 4 gallon jug
•y = gallons in the 3 gallon jug
•State Space = (x, y)
•Such that:
•x = {0,1,2,3,4}
•y = {0,1,2,3}
9
WATER JUG PROBLEM
START AND GOAL STATES

• The start state is when both jugs are


empty:
(0,0)
• The goal state is any state that has 2
gallons in the 4 gallon jug:
(2, n) for any n
10
WATER JUG OPERATIONS

• Fill 3 gal. jug from pump (x, y) -> (x, 3)


• Fill 4 gal. jug from pump (x, y) -> (4, y)
• Empty 3 gal. Jug (x, y) -> (x, 0)
• Empty 4 gal. Jug (x, y) -> (0, y)
• Pour contents of 3 gal. Jug (x, y) -> (y+n ,y-n) into
4 gal. Jug

11
Start State WATER JUG STATE SPACE

(0,0) (1,0) (2,0) (3,0) (4,0)

(0,1) (1,1) (2,1) (3,1) (4,1)

(0,2) (1,2) (2,2) (3,2) (4,2)

(0,3) (1,3) (2,3) (3,3) (4,3)


12
Goal States
WATER JUG TREE (PARTIAL)
0,0

4,0 0,3

4,1 4,2 4,3 1,3 2,3 3,3

13
SEARCH TREES
• The search for a solution can be described by
a tree - each node represents one state.
• The path from a parent node to a child node
represents an operation.
• Search Trees provide a convenient
description of the search space, they are not
a data structure stored in memory!!!

14
GRAPH THEORY
A graph consists of :-
• A set of nodes N1, N2, N3, … , Nn…
• A set of arcs that connects pair of nodes.
• Arcs are ordered pairs of nodes, i.e. the arc (N3, N4)
connects node N3 to node N4. This means a directed
connection from N3 to N4.
• If a directed arc connects node Nj to node Nk,
– Then Nj is called parent of Nk
– And Nk is called child of Nj.
• If the graph also contains an arc (Nj, Nl) then Nk and
Nl are called siblings.
15
GRAPH THEORY
A graph consists of :-
• A rooted graph has a unique node Ns. All paths in the
graph originates from this node. That means Ns has
no parents.
• A tip of a leaf node has no children.
• A path that contains any node more than once, is said
to contain a cycle or loop.
• A tree is a graph in which there is a unique path
between each pair of nodes. The paths in a tree
therefore contains no cycles or loops.
16
GRAPH THEORY
• A graph consists of a set of nodes and a set of arcs or
links connecting pairs of nodes.

• In the state space model of problem solving the nodes of


a graph are taken to represent discrete states of a
problem solving process. Such as:-

– Results of logical inferences

– Configurations of a game board.

17
GRAPH THEORY
• The arcs of graph represent transitions between states
or the act of applying a rule, such as:-

– Logical inferences.

– Legal moves of a game.

18
GRAPH THEORY

A labeled directed graph. 19


GRAPH THEORY

20
A rooted tree, exemplifying family relationships.
STATE SPACE SEARCH

21
STATE SPACE SEARCH
• The theory of state space search is our
primary tool for successful design and
implementation of search algorithms.

• We can use graph theory to analyze the


structure and complexity of both the
problem and the procedure used to solve
it by representing the problem as a state
space graph.
22
EXAMPLES OF
STATE SPACE

23
STATE SPACE
• We studied predicate calculus as an example of an
artificial intelligence representational language.

• Well formed predicate calculus expressions provides a


means of describing objects and relations in a problem
domain, and inference rules such as modus ponens
allow us to infer new knowledge from these
descriptions.

• These inferences define a space that is searched to find


a problem solution.

24
Slide II.7
Figure II.5: Portion of the state space for tic-tac-toe.

25
A R T I F I C I A L I N T E L L I G E N C E: Structure and Strategies for Complex ProblemSolving, 4th Edition George F. Luger © 2002 Addison Wesley
DESCRIPTION OF STATE SPACE
TIC- TAC-TOE
•There are 39 (19683) ways to arrange (Blank, X, O) in nine
spaces.
•State space is a graph.
•The graph is a “directed acyclic graph”.
•Complexity of Problem (No of possible move paths)
•Nine possible first moves.
•Eight possible responses to each first move at 2nd
level.
•Seven possible responses to each 2nd level move at
3rd level. And so on …
•So 9 x 8 x 7 …, or 9! = 362,880 possible games paths
can be generated. 26
DESCRIPTION OF STATE SPACE
TIC- TAC-TOE
•Tic-Tac-Toe has 9! possible games paths.
•Chess has 10120 possible game paths.
•Checker has 1040 possible game paths.
•Problem spaces with these large number of possible
paths, are difficult or impossible to search
exhaustively.
•Strategies must be defined to reduce the complexity
of the problem.
•These strategies, however, rely on heuristics to
reduce the complexity of the search.
27
State space of the 8-puzzle generated by “move blank” operations.

28
EXAMPLE OF 8- PUZZLE.
4 possible moves for Blank , , , 

State space is a graph.

More than one paths may exist to reach to one node


(state) or most states may have multiple parents.
Therefore cycles are possible.

GD is a particular state or board configuration.


When this state is found on a path the search
terminates.

The path from START to the GOAL is the desired


series of moves. 29
THE TRAVELING SALESPERSON
A salesperson needs to visit five cities and then
return home.
GD Find shortest possible path for the sales
person to travel to cities and then return home.
Sales person lives in city ‘A’. He will return to city ‘A’
after completing the tour. So the state space consists
of (n-1) nodes.
One possible path.A, D, C, B, E, A = 450 miles.

GD requires a complete circuit with minimum


distance covered.
GD in this example is a property of entire path. 30
An instance of the traveling salesperson problem.

31
Search of the traveling salesperson problem. Each arc is marked with the
total weight of all paths from the start node (A) to its endpoint.

32
THE TRAVELING SALESPERSON
Complexity

 Complexity of exhaustive search in this problem is (N-


1)!, i.e. 5! (120) paths.

 For small number of cities the search is possible


exhaustively.

 But for, problem instances, for example, where N = 50


simple exhaustive search cannot be restored to.

 For a N! search grows so fast that very soon the


search combinations become intractable.
33
STRATEGIES FOR STATE SPACE SEARCH

Data Driven and Goal Driven Search


•State space may be searched in two directions:-

•From given data of a problem instance towards a goal

Data of a problem Goal

•From a goal back to the data

Goal Data

34
STRATEGIES FOR STATE SPACE SEARCH
Data Driven Search (Also Called Forward Chaining)
The problem solver begins with given facts of the problem and
a set of legal moves or rules for changing states.

Search proceeds as follows:-

Applying rules to facts to produce new facts.

New facts are used by rules to produce more new facts.

Process continues until it generates a path or state that


satisfies the goal condition.

Data driven search uses the knowledge and constraints found


in the given data of a problem to guide search along lines known
to be true.
35
STRATEGIES FOR STATE SPACE SEARCH
Goal Driven Search (Also Called Backward Chaining)
Take the goal that we want to solve.

See what rules or legal moves could be used to generate this


goal. Also determine what conditions must be true to use
these rules.
These conditions become the new goals or subgoals for the
search.
Reaching subgoals, determining new subgoals and so on…

Search continues, working backward through successive


subgoals until it works back to the facts of the problem.
Goal driven search thus uses knowledge of the desired goal
to guide the search through relevant rules and eliminate
branches of the space.
36
STRATEGIES FOR STATE SPACE SEARCH
• Both data-driven an goal-driven problem solvers
search the same state space graph, however, the
order and actual number of states searched can be
different.

• The preferred strategy is determined by the


properties of the problem itself. These includes:-

– The complexity of the rules.

– The shape of the state space.

– The nature and availability of the problem data.

37
STRATEGIES FOR STATE SPACE SEARCH
• Data-driven search will by preferred for
problems in which:-
– All are most of the data are given in the initial problem
statement.
– There are a large number of potential goals, but there
are only a few ways to use the facts and given
information of a particular problem instance.
– It is difficult to form a goal or hypothesis.

38
STRATEGIES FOR STATE SPACE SEARCH
• Goal-driven search will be preferred for
problems in which:-
– A goal or hypothesis is given in the initial problem
statement or can easily be formulated.
– There are a large number of rules that match the facts
of the problem and thus produce an increasing
number of conclusions or goals. Early selection of a
goal can eliminate most of these branches, making
goal driven search more effective.
– Problem data are not given but must be acquired by
the problem solver. In this case goal driven search
can help guide data acquisition.
39
State space in which goal-directed search effectively prunes extraneous
search paths.

40
State space in which data-directed search prunes irrelevant data and
their consequents and determines one of a number of possible goals.

41

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy