Introduction to State Space
Search
1AI, Subash Chandra Pakhrin
Instructional Objectives for this module
• The student should be familiar with the
following algorithms, and should be able to
code the algorithms
– Greedy search
– DFS
– BFS
– Uniform cost search
– Iterative deepening search
– Bidirectional search
2AI, Subash Chandra Pakhrin
Instructional Objectives for this module
• The student should understand the state space
representation, and gain familiarity with some
common problems formulated as state space
search problems.
• Given a problem description, the student should
be able to formulate it in terms of a state space
search problem.
• The student should understand how implicit state
spaces can be unfolded during search.
• Understand how states can be represented by
features.
3AI, Subash Chandra Pakhrin
Intelligent Agent
4AI, Subash Chandra Pakhrin
Goal Directed Agent
• A goal directed agent needs to achieve certain
goals.
• Many problems can be represented as a set of
states and a set of rules of how one state is
transformed to another
• The agent must choose a sequence of actions
to achieve the desired goal.
5AI, Subash Chandra Pakhrin
Problem Solving
• It is a systematic search through range of
possible actions in order to reach some
predefined goal or solution.
There are two kinds of problem solving
methods:
– Special-purpose method
– General-purpose method
AI, Subash Chandra Pakhrin 6
Problem Solving
• Special-purpose method:
– It is made for particular problem and often
exploits very specific features of the situation in
which the problem is embedded.
• General-purpose method:
– It is applicable for wide variety of problems.
– End analysis
• A step by step
• Difference between the current state and the final state
AI, Subash Chandra Pakhrin 7
General steps in problem solving:
• Goal formulation
– What are successful world states
• Problem formulation
– What actions and states to consider given the goal
• Search
– Determine the possible sequence of actions that lead
to the state of known values and then choosing the
best sequence.
• Execute
– Give the solution perform the actions.
AI, Subash Chandra Pakhrin 8
Problem Formulation:
• A problem is defined by:
– An initial state
– Successor function
– Goal Test
– Path Cost:
• Sum of cost of each path from initial state to the given state.
• A solution is a sequence of actions from initial to
goal state
• Optimal solution has the lowest path cost.
AI, Subash Chandra Pakhrin 9
• Each state is an abstract representation of the
agent’s environment. It is an abstraction that
denoted a configuration of the agent.
• Initial state: The description of the starting
configuration of the agent.
• An action/operator takes the agent from one
state to another state. A state can have a
number of successor states.
• A plan is a sequence of actions.
10AI, Subash Chandra Pakhrin
• A goal is a description of a set of desirable
states of the world. Goal states are often
specified by a goal test which any goal state
must satisfy
• Path cost: path -> positive number
Usually path cost = sum of step costs
11AI, Subash Chandra Pakhrin
• Problem formulation: means choosing a
relevant set of states to consider, and a
feasible set of operators for moving from one
state to another.
• Search is the process of imagining sequences
of operators applied to the initial state, and
checking which sequence reaches a goal state.
12AI, Subash Chandra Pakhrin
Why Search ?
• To achieve goals or to maximize our utility we
need to predict what the result of our actions
in the future will be.
• There are many sequences of actions, each
with their own utility.
• We want to find, or search for, the best one.
AI, Subash Chandra Pakhrin 13
Example: Romania
• On holiday in Romania; currently in Arad.
• Flight leaves tomorrow from Bucharest
• Formulate goal:
– Be in Bucharest
• Formulate problem:
– States: various cities
– Actions: drive between cities or choose next city
• Find solution:
– Sequence of cities, e.g., Arad, Sibiu, Fagaras,
Bucharest
AI, Subash Chandra Pakhrin 14
Example: Romania
AI, Subash Chandra Pakhrin 15
Search Problem
• S: the full set of states
• S0 : the initial state
• A: S -> S set of operators
• G: the set of final states. G
is subset of S
• Search problem: Find a
sequence of actions
which transforms the
agent from the initial
state to a goal state gє G
16AI, Subash Chandra Pakhrin
Searching process
• Check the current state
• Execute allowable action to move to the next
state
• Check if the new state is a solution state
– If it is not, the new state becomes the current
state and the process is repeated until a solution is
found or the state space is exhausted.
17AI, Subash Chandra Pakhrin
State Space
18AI, Subash Chandra Pakhrin
State Space
• Commonly defined as a directed graph in
which each node is a state and each arc
represents the application of an operator
transforming a state to a successor state.
• A solution is a path from the initial state to a
goal state.
AI, Subash Chandra Pakhrin 19
Vacuum World State Space
Representation :
AI, Subash Chandra Pakhrin 20
Vacuum World State Space
Representation :
• States ?
___2___ X ___ 2___X ___2___ = 8
Dirty/clean Suck / remain ideal move left / right
• Initial States ? Any state can be initial
• Actions ? { Left, Right, Suck }
• Goal Test ? Check whether squares are clean.
• Path cost ? Number of actions to reach goal.
AI, Subash Chandra Pakhrin 21
Vacuum World
AI, Subash Chandra Pakhrin 22
Vacuum World
AI, Subash Chandra Pakhrin 23
Pegs and Disks / Tower of Hanoi
• Consider the
following
problem. We
have three pegs
and 3 disks.
• Operators: one
may move the
topmost disk
on any needle
to the topmost
position to any
other needle
Goal Configuration
Initial State
24AI, Subash Chandra Pakhrin
Actions
• Move top most peg from start to end
• Move From start to auxiliary
• Move from start to End
• Move from auxiliary to start
• Move form end to auxiliary
• Move from start to auxiliary
• Move from end to auxiliary
And finally we have the desired configuration
AI, Subash Chandra Pakhrin 25
Production System
• A production system (or production rule system)
is a computer program typically used to provide
some form of AI, which consists primarily of a set
of rules about behavior but it also includes the
mechanism necessary to follow those rules as the
system responds to states of the.
• Productions systems, are found useful
in automated planning, expert
systems and action selection.
AI, Subash Chandra Pakhrin 26
Production System
• Productions consist of two parts: a sensory precondition
(or "IF" statement) and an action (or "THEN").
• If a production's precondition matches the current
state of the world, then the production is said to
be triggered. If a production's action is executed, it is said
to have fired.
• A production system also contains a database,
sometimes called working memory, which maintains data
about current state or knowledge, and a rule interpreter.
• The rule interpreter must provide a mechanism for
prioritizing productions when more than one is triggered.
AI, Subash Chandra Pakhrin 27
Production System
• Production systems represents knowledge in
the form of condition – action pairs called
production rules:
• If the condition C is satisfied then the action A
is appropriate.
AI, Subash Chandra Pakhrin 28
Types of Production rules
• Situation-action rule
– If it is raining then open the umbrella.
• Inference rules
– If Hari is a man then Hari is a person
• Production system is also called rule-based
system
AI, Subash Chandra Pakhrin 29
Architecture of Production System
AI, Subash Chandra Pakhrin 30
Short
Term Memory
Architecture of Production System
• Short Term Memory
– Contains the description of current state.
• Set of production rules
– Set of condition-action pairs
– It defines a single chunk of problem solving
knowledge.
• Interpreter
– A mechanism to examine the short term memory and
to determine which rules to fire (BFS, DFS, A* etc)
AI, Subash Chandra Pakhrin 31
Production System:
The water Jug Problem
AI, Subash Chandra Pakhrin 32
The water Jug Problem
You are given two jugs, a 4-gallon one and a 3-
gallon one, a pump which has unlimited water
which you can use to fill the jug, and the
ground on which water may be poured.
Neither jug has any measuring markings on it.
How can you get exactly 2 gallons of water in
the 4-gallon jug?
AI, Subash Chandra Pakhrin 33
The water Jug Problem
• we will represent a state of the problem as a
ordered pair (x, y) where x represents the
amount of water in the 4-gallon jug and y
represents the amount of water in the 3-
gallon jug.
• Note 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3.
• Initial state: (0,0)
• Goal Predicate – state = (2,y) where 0 ≤ y ≤ 3
AI, Subash Chandra Pakhrin 34
The water Jug Problem
Define a set of operators that will take us from one state to another:
1. Fill 4-gal jug (x, y) → (4,y) x < 4
2. Fill 3-gal jug (x, y) → (x,3) y < 3
3. Empty 4-gal jug on ground (x, y) → (0,y) x > 0
4. Empty 3-gal jug on ground (x, y) → (x,0) y > 0
5. Pour water from 3-gal jug (x, y) → (4, y - (4 - x)) to fill 4-gal jug 0 <
x + y ≥ 4 and y > 0
6. Pour water from 4-gal jug (x, y) → (x - (3-y), 3) to fill 3-gal-jug 0 <
x + y ≥ 3 and x > 0
7. Pour all of water from 3-gal jug (x, y) → (x+ y, 0) into 4-gal jug
0 < x + y ≤ 4 and y ≥ 0
8. Pour all of water from 4-gal jug (x, y) → (0, x + y) into 3-gal jug 0 <
x + y ≤ 3 and x ≥ 0
AI, Subash Chandra Pakhrin 35
The water Jug Problem
Through Graph Search, the following solution is
found :
Gals in 4-gal jug Gals in 3-gal jug Rule Applied
0 0 1. Fill 4
4 0 6. Pour 4 into 3 to fill
1 3 4. Empty 3
1 0 8. Pour all of 4 into 3
0 1 1. Fill 4
4 1 6. Pour into 3
2 3
AI, Subash Chandra Pakhrin 36
The water Jug Problem:
Representation
AI, Subash Chandra Pakhrin 37
8 Queens
• The N Queens Problem
is the problem of
placing eight queens on
an N×N chessboard
such that none of them
attack one another (no
two are in the same
row, column, or
diagonal). Alongside
we can see the
arrangements of an
N=8 queen solution:
AI, Subash Chandra Pakhrin 38
N queen problem formulation 1
• Any arrangement of 0 to 8 queens on the
board
• Initial state: 0 queens on the board
• Successor function: Add a queen in any square
• Goal test: 8 queens on the board, none are
attacked
AI, Subash Chandra Pakhrin 39
N queen problem formulation 1
• States: Any arrangement of 8 queens on the
board
• Initial state: All queens are at column 1
• Successor function: Change the position of
any one queen
• Goal test: 8 queens on the board, none are
attacked
AI, Subash Chandra Pakhrin 40
N queens problem formulation 3
• States: Any arrangement of k queens in the
first k rows such that none are attacked
• Initial state: 0 queens on the board
• Successor function: Add a queen to the (k+1)th
row so that none are attacked.
• Goal test: 8 queens on the board, none are
attacked
AI, Subash Chandra Pakhrin 41
Explicit vs. Implicit state space
• The state space may be explicitly represented
• Typically it is implicitly represented and
generated when required.
• The agents knows
– The initial state
– The operators
• An operator is a function which “expands” a node
– Compute the successor node(s)
AI, Subash Chandra Pakhrin 42
Problem Definition – Example, 8 puzzle
1 2 3
4 8 -
7 6 5
AI, Subash Chandra Pakhrin 43
1 2 3
4 5 6
7 8 -
Start State Goal State
Initial State: {(1,2,3), (4,8,0), (7,6,5)}
Successor State: {(1,2,3), (4,8,5), (7,6,-)}; move 5 up or – down
Successor State: {(1,2,3), (4,8,5), (7,-,6)}; move 6 right or – to left
Successor State: {(1,2,3), (4,-,5), (7,8,6)}; move – up or 8 down
Successor State: {(1,2,3), (4,5,-), (7,8,6)}; move 5 to left or – to right
Goal State: {(1,2,3), (4,5,-), (7,8,6)}; move – down or 6 up
PATH COST = 5
Problem Definition – Example, 8 puzzle
/ n2-1 puzzle
• States
– A description of each of the eight tiles in each
location that it can occupy.
• Operation/Action
– The blank moves left, right, up or down
• Goal Test
– The current state matches a certain goal state.
• Path Cost
– Each move of the blank costs 1
AI, Subash Chandra Pakhrin 44
Problem Definition – Example, tic-tac-toe
AI, Subash Chandra Pakhrin 45
Search Through a state space
• Input
– Set of states
– Operators [and costs]
– Start state
– Goal state [test]
• Output
– Path: start => a state satisfying goal test
– [May require shortest path]
AI, Subash Chandra Pakhrin 46
Basic Search algorithm
Let fringe be a list containing the initial state
LOOP
if fringe is empty return failure
Node <- remove – first (fringe)
if Node is a goal
then return the path from initial state to Node
else generate all successors of Node,
and merge the newly generated nodes into fringe
END LOOP
AI, Subash Chandra Pakhrin 47
Basic Search Algorithm: Key Issues
• Search tree may be unbounded
– Because of loops
– Because state space is infinite
• Return a path or a node ?
• How are merge and select done ?
– Is the graph weighted or un weighted ?
– How much is known about the quality of intermediate
states?
– Is the aim to find a minimal cost path or any path as
soon as possible ?
AI, Subash Chandra Pakhrin 48
Search strategy
• Measuring problem solving performance:
– Completeness: Is the strategy guaranteed to find a
solution if one exists ?
– Optimality: Does the solution have low cost or the
minimal cost ?
– What is the search cost associated with the time
and memory required to find a solution ?
AI, Subash Chandra Pakhrin 49
Search Strategies
• Blind Search
– Depth First Search
– Breadth First Search
– Iterative Deepening Search
– Iterative Broadening Search
• Informed Search
• Constraint Satisfaction
• Adversary Search
AI, Subash Chandra Pakhrin 50
Questions for Lecture 3
• Given the initial state, goal test, successor function,
and cost function for each of the following.
Choose a formulation that is precise enough to be
implemented.
1. You have to color a planar map using only four
colors, in such a way that no two adjacent regions
have the same color.
2. In the travelling salesperson problem (TSP) there
is a map involving N cities some of which are
connected by roads. The aim is to find the shortest
tour that starts from a city, visits all the cities
exactly once and comes back to the starting city.
AI, Subash Chandra Pakhrin 51
Questions for Lecture 3
• Missionaries & Cannibals problem: 3
missionaries & 3 cannibals are on one side of
the river. 1 boat carries 2.
Missionaries must never be outnumbered by
cannibals. Give a plan for all to cross the river.
AI, Subash Chandra Pakhrin 52

Final slide (bsc csit) chapter 3

  • 1.
    Introduction to StateSpace Search 1AI, Subash Chandra Pakhrin
  • 2.
    Instructional Objectives forthis module • The student should be familiar with the following algorithms, and should be able to code the algorithms – Greedy search – DFS – BFS – Uniform cost search – Iterative deepening search – Bidirectional search 2AI, Subash Chandra Pakhrin
  • 3.
    Instructional Objectives forthis module • The student should understand the state space representation, and gain familiarity with some common problems formulated as state space search problems. • Given a problem description, the student should be able to formulate it in terms of a state space search problem. • The student should understand how implicit state spaces can be unfolded during search. • Understand how states can be represented by features. 3AI, Subash Chandra Pakhrin
  • 4.
  • 5.
    Goal Directed Agent •A goal directed agent needs to achieve certain goals. • Many problems can be represented as a set of states and a set of rules of how one state is transformed to another • The agent must choose a sequence of actions to achieve the desired goal. 5AI, Subash Chandra Pakhrin
  • 6.
    Problem Solving • Itis a systematic search through range of possible actions in order to reach some predefined goal or solution. There are two kinds of problem solving methods: – Special-purpose method – General-purpose method AI, Subash Chandra Pakhrin 6
  • 7.
    Problem Solving • Special-purposemethod: – It is made for particular problem and often exploits very specific features of the situation in which the problem is embedded. • General-purpose method: – It is applicable for wide variety of problems. – End analysis • A step by step • Difference between the current state and the final state AI, Subash Chandra Pakhrin 7
  • 8.
    General steps inproblem solving: • Goal formulation – What are successful world states • Problem formulation – What actions and states to consider given the goal • Search – Determine the possible sequence of actions that lead to the state of known values and then choosing the best sequence. • Execute – Give the solution perform the actions. AI, Subash Chandra Pakhrin 8
  • 9.
    Problem Formulation: • Aproblem is defined by: – An initial state – Successor function – Goal Test – Path Cost: • Sum of cost of each path from initial state to the given state. • A solution is a sequence of actions from initial to goal state • Optimal solution has the lowest path cost. AI, Subash Chandra Pakhrin 9
  • 10.
    • Each stateis an abstract representation of the agent’s environment. It is an abstraction that denoted a configuration of the agent. • Initial state: The description of the starting configuration of the agent. • An action/operator takes the agent from one state to another state. A state can have a number of successor states. • A plan is a sequence of actions. 10AI, Subash Chandra Pakhrin
  • 11.
    • A goalis a description of a set of desirable states of the world. Goal states are often specified by a goal test which any goal state must satisfy • Path cost: path -> positive number Usually path cost = sum of step costs 11AI, Subash Chandra Pakhrin
  • 12.
    • Problem formulation:means choosing a relevant set of states to consider, and a feasible set of operators for moving from one state to another. • Search is the process of imagining sequences of operators applied to the initial state, and checking which sequence reaches a goal state. 12AI, Subash Chandra Pakhrin
  • 13.
    Why Search ? •To achieve goals or to maximize our utility we need to predict what the result of our actions in the future will be. • There are many sequences of actions, each with their own utility. • We want to find, or search for, the best one. AI, Subash Chandra Pakhrin 13
  • 14.
    Example: Romania • Onholiday in Romania; currently in Arad. • Flight leaves tomorrow from Bucharest • Formulate goal: – Be in Bucharest • Formulate problem: – States: various cities – Actions: drive between cities or choose next city • Find solution: – Sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest AI, Subash Chandra Pakhrin 14
  • 15.
    Example: Romania AI, SubashChandra Pakhrin 15
  • 16.
    Search Problem • S:the full set of states • S0 : the initial state • A: S -> S set of operators • G: the set of final states. G is subset of S • Search problem: Find a sequence of actions which transforms the agent from the initial state to a goal state gє G 16AI, Subash Chandra Pakhrin
  • 17.
    Searching process • Checkthe current state • Execute allowable action to move to the next state • Check if the new state is a solution state – If it is not, the new state becomes the current state and the process is repeated until a solution is found or the state space is exhausted. 17AI, Subash Chandra Pakhrin
  • 18.
    State Space 18AI, SubashChandra Pakhrin
  • 19.
    State Space • Commonlydefined as a directed graph in which each node is a state and each arc represents the application of an operator transforming a state to a successor state. • A solution is a path from the initial state to a goal state. AI, Subash Chandra Pakhrin 19
  • 20.
    Vacuum World StateSpace Representation : AI, Subash Chandra Pakhrin 20
  • 21.
    Vacuum World StateSpace Representation : • States ? ___2___ X ___ 2___X ___2___ = 8 Dirty/clean Suck / remain ideal move left / right • Initial States ? Any state can be initial • Actions ? { Left, Right, Suck } • Goal Test ? Check whether squares are clean. • Path cost ? Number of actions to reach goal. AI, Subash Chandra Pakhrin 21
  • 22.
    Vacuum World AI, SubashChandra Pakhrin 22
  • 23.
    Vacuum World AI, SubashChandra Pakhrin 23
  • 24.
    Pegs and Disks/ Tower of Hanoi • Consider the following problem. We have three pegs and 3 disks. • Operators: one may move the topmost disk on any needle to the topmost position to any other needle Goal Configuration Initial State 24AI, Subash Chandra Pakhrin
  • 25.
    Actions • Move topmost peg from start to end • Move From start to auxiliary • Move from start to End • Move from auxiliary to start • Move form end to auxiliary • Move from start to auxiliary • Move from end to auxiliary And finally we have the desired configuration AI, Subash Chandra Pakhrin 25
  • 26.
    Production System • Aproduction system (or production rule system) is a computer program typically used to provide some form of AI, which consists primarily of a set of rules about behavior but it also includes the mechanism necessary to follow those rules as the system responds to states of the. • Productions systems, are found useful in automated planning, expert systems and action selection. AI, Subash Chandra Pakhrin 26
  • 27.
    Production System • Productionsconsist of two parts: a sensory precondition (or "IF" statement) and an action (or "THEN"). • If a production's precondition matches the current state of the world, then the production is said to be triggered. If a production's action is executed, it is said to have fired. • A production system also contains a database, sometimes called working memory, which maintains data about current state or knowledge, and a rule interpreter. • The rule interpreter must provide a mechanism for prioritizing productions when more than one is triggered. AI, Subash Chandra Pakhrin 27
  • 28.
    Production System • Productionsystems represents knowledge in the form of condition – action pairs called production rules: • If the condition C is satisfied then the action A is appropriate. AI, Subash Chandra Pakhrin 28
  • 29.
    Types of Productionrules • Situation-action rule – If it is raining then open the umbrella. • Inference rules – If Hari is a man then Hari is a person • Production system is also called rule-based system AI, Subash Chandra Pakhrin 29
  • 30.
    Architecture of ProductionSystem AI, Subash Chandra Pakhrin 30 Short Term Memory
  • 31.
    Architecture of ProductionSystem • Short Term Memory – Contains the description of current state. • Set of production rules – Set of condition-action pairs – It defines a single chunk of problem solving knowledge. • Interpreter – A mechanism to examine the short term memory and to determine which rules to fire (BFS, DFS, A* etc) AI, Subash Chandra Pakhrin 31
  • 32.
    Production System: The waterJug Problem AI, Subash Chandra Pakhrin 32
  • 33.
    The water JugProblem You are given two jugs, a 4-gallon one and a 3- gallon one, a pump which has unlimited water which you can use to fill the jug, and the ground on which water may be poured. Neither jug has any measuring markings on it. How can you get exactly 2 gallons of water in the 4-gallon jug? AI, Subash Chandra Pakhrin 33
  • 34.
    The water JugProblem • we will represent a state of the problem as a ordered pair (x, y) where x represents the amount of water in the 4-gallon jug and y represents the amount of water in the 3- gallon jug. • Note 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3. • Initial state: (0,0) • Goal Predicate – state = (2,y) where 0 ≤ y ≤ 3 AI, Subash Chandra Pakhrin 34
  • 35.
    The water JugProblem Define a set of operators that will take us from one state to another: 1. Fill 4-gal jug (x, y) → (4,y) x < 4 2. Fill 3-gal jug (x, y) → (x,3) y < 3 3. Empty 4-gal jug on ground (x, y) → (0,y) x > 0 4. Empty 3-gal jug on ground (x, y) → (x,0) y > 0 5. Pour water from 3-gal jug (x, y) → (4, y - (4 - x)) to fill 4-gal jug 0 < x + y ≥ 4 and y > 0 6. Pour water from 4-gal jug (x, y) → (x - (3-y), 3) to fill 3-gal-jug 0 < x + y ≥ 3 and x > 0 7. Pour all of water from 3-gal jug (x, y) → (x+ y, 0) into 4-gal jug 0 < x + y ≤ 4 and y ≥ 0 8. Pour all of water from 4-gal jug (x, y) → (0, x + y) into 3-gal jug 0 < x + y ≤ 3 and x ≥ 0 AI, Subash Chandra Pakhrin 35
  • 36.
    The water JugProblem Through Graph Search, the following solution is found : Gals in 4-gal jug Gals in 3-gal jug Rule Applied 0 0 1. Fill 4 4 0 6. Pour 4 into 3 to fill 1 3 4. Empty 3 1 0 8. Pour all of 4 into 3 0 1 1. Fill 4 4 1 6. Pour into 3 2 3 AI, Subash Chandra Pakhrin 36
  • 37.
    The water JugProblem: Representation AI, Subash Chandra Pakhrin 37
  • 38.
    8 Queens • TheN Queens Problem is the problem of placing eight queens on an N×N chessboard such that none of them attack one another (no two are in the same row, column, or diagonal). Alongside we can see the arrangements of an N=8 queen solution: AI, Subash Chandra Pakhrin 38
  • 39.
    N queen problemformulation 1 • Any arrangement of 0 to 8 queens on the board • Initial state: 0 queens on the board • Successor function: Add a queen in any square • Goal test: 8 queens on the board, none are attacked AI, Subash Chandra Pakhrin 39
  • 40.
    N queen problemformulation 1 • States: Any arrangement of 8 queens on the board • Initial state: All queens are at column 1 • Successor function: Change the position of any one queen • Goal test: 8 queens on the board, none are attacked AI, Subash Chandra Pakhrin 40
  • 41.
    N queens problemformulation 3 • States: Any arrangement of k queens in the first k rows such that none are attacked • Initial state: 0 queens on the board • Successor function: Add a queen to the (k+1)th row so that none are attacked. • Goal test: 8 queens on the board, none are attacked AI, Subash Chandra Pakhrin 41
  • 42.
    Explicit vs. Implicitstate space • The state space may be explicitly represented • Typically it is implicitly represented and generated when required. • The agents knows – The initial state – The operators • An operator is a function which “expands” a node – Compute the successor node(s) AI, Subash Chandra Pakhrin 42
  • 43.
    Problem Definition –Example, 8 puzzle 1 2 3 4 8 - 7 6 5 AI, Subash Chandra Pakhrin 43 1 2 3 4 5 6 7 8 - Start State Goal State Initial State: {(1,2,3), (4,8,0), (7,6,5)} Successor State: {(1,2,3), (4,8,5), (7,6,-)}; move 5 up or – down Successor State: {(1,2,3), (4,8,5), (7,-,6)}; move 6 right or – to left Successor State: {(1,2,3), (4,-,5), (7,8,6)}; move – up or 8 down Successor State: {(1,2,3), (4,5,-), (7,8,6)}; move 5 to left or – to right Goal State: {(1,2,3), (4,5,-), (7,8,6)}; move – down or 6 up PATH COST = 5
  • 44.
    Problem Definition –Example, 8 puzzle / n2-1 puzzle • States – A description of each of the eight tiles in each location that it can occupy. • Operation/Action – The blank moves left, right, up or down • Goal Test – The current state matches a certain goal state. • Path Cost – Each move of the blank costs 1 AI, Subash Chandra Pakhrin 44
  • 45.
    Problem Definition –Example, tic-tac-toe AI, Subash Chandra Pakhrin 45
  • 46.
    Search Through astate space • Input – Set of states – Operators [and costs] – Start state – Goal state [test] • Output – Path: start => a state satisfying goal test – [May require shortest path] AI, Subash Chandra Pakhrin 46
  • 47.
    Basic Search algorithm Letfringe be a list containing the initial state LOOP if fringe is empty return failure Node <- remove – first (fringe) if Node is a goal then return the path from initial state to Node else generate all successors of Node, and merge the newly generated nodes into fringe END LOOP AI, Subash Chandra Pakhrin 47
  • 48.
    Basic Search Algorithm:Key Issues • Search tree may be unbounded – Because of loops – Because state space is infinite • Return a path or a node ? • How are merge and select done ? – Is the graph weighted or un weighted ? – How much is known about the quality of intermediate states? – Is the aim to find a minimal cost path or any path as soon as possible ? AI, Subash Chandra Pakhrin 48
  • 49.
    Search strategy • Measuringproblem solving performance: – Completeness: Is the strategy guaranteed to find a solution if one exists ? – Optimality: Does the solution have low cost or the minimal cost ? – What is the search cost associated with the time and memory required to find a solution ? AI, Subash Chandra Pakhrin 49
  • 50.
    Search Strategies • BlindSearch – Depth First Search – Breadth First Search – Iterative Deepening Search – Iterative Broadening Search • Informed Search • Constraint Satisfaction • Adversary Search AI, Subash Chandra Pakhrin 50
  • 51.
    Questions for Lecture3 • Given the initial state, goal test, successor function, and cost function for each of the following. Choose a formulation that is precise enough to be implemented. 1. You have to color a planar map using only four colors, in such a way that no two adjacent regions have the same color. 2. In the travelling salesperson problem (TSP) there is a map involving N cities some of which are connected by roads. The aim is to find the shortest tour that starts from a city, visits all the cities exactly once and comes back to the starting city. AI, Subash Chandra Pakhrin 51
  • 52.
    Questions for Lecture3 • Missionaries & Cannibals problem: 3 missionaries & 3 cannibals are on one side of the river. 1 boat carries 2. Missionaries must never be outnumbered by cannibals. Give a plan for all to cross the river. AI, Subash Chandra Pakhrin 52

Editor's Notes

  • #11 Abstract: existing in thought or as an idea but not having a physical or concrete existence.