[SOLVED] Problem Solving and Search

$25

File Name: Problem_Solving_and_Search.zip
File Size: 244.92 KB

5/5 - (1 vote)

Problem Solving and Search

Chapter 3, Sections 14

Copyright By Assignmentchef assignmentchef

AIMA Slides and; Chapter 3, Sections 14 1

Problem-solving agents

Problem types

Problem formulation

Example problems

Basic search algorithms

AIMA Slides and; Chapter 3, Sections 14 2

Problem-solving agents

Restricted form of general agent:

function Simple-Problem-Solving-Agent( p) returns an action
inputs: p, a percept
static: s, an action sequence, initially empty

state, some description of the current world state
g, a goal, initially null
problem, a problem formulation

stateUpdate-State(state, p)
if s is empty then

gFormulate-Goal(state)
problemFormulate-Problem(state, g)
sSearch( problem)

actionRecommendation(s, state)
sRemainder(s, state)
return action

Note: this is offline problem solving.
Online problem solving involves acting without complete knowledge of the
problem and solution.

AIMA Slides and; Chapter 3, Sections 14 3

Example: Romania

On holiday in Romania; currently in Arad.
Flight leaves tomorrow from Bucharest

Formulate goal:
be in Bucharest

Formulate problem:
states: various cities
operators: drive between cities

Find solution:
sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest

AIMA Slides and; Chapter 3, Sections 14 4

Example: Romania

AIMA Slides and; Chapter 3, Sections 14 5

Single-state problem formulation

A problem is defined by four items:

initial state e.g., at Arad

actions (or successor function S(x))
e.g., Arad Sibiu etc.

goal test, can be
explicit, e.g., x = at Bucharest
implicit, e.g., Checkmate in chess

path cost (additive)
e.g., sum of distances, number of actions executed, etc.

A solution is a sequence of actions
leading from the initial state to a goal state

Note: we sometimes refer to actions as operators

AIMA Slides and; Chapter 3, Sections 14 6

Selecting a state space

Real world is absurdly complex
state space must be abstracted for problem solving

(Abstract) state = set of real states

(Abstract) action = complex combination of real actions
e.g., Arad Zerind represents a complex set

of possible routes, detours, rest stops, etc.
For guaranteed realizability, any real state in Arad

must get to some real state in Zerind

(Abstract) solution =
set of real paths that are solutions in the real world

Each abstract action should be easier than the original problem!

AIMA Slides and; Chapter 3, Sections 14 7

Example: The 8-puzzle

Start State Goal State

goal test??
path cost??

[Note: optimal solution of n-Puzzle family is NP-hard]

AIMA Slides and; Chapter 3, Sections 14 8

Example: The 8-puzzle

Start State Goal State

states??: integer locations of tiles (ignore intermediate positions)
actions??: move blank left, right, up, down (ignore unjamming etc.)
goal test??: = goal state (given)
path cost??: 1 per move

[Note: optimal solution of n-Puzzle family is NP-hard]

AIMA Slides and; Chapter 3, Sections 14 9

Example: robotic assembly

states??: real-valued coordinates of
robot joint angles
parts of the object to be assembled

actions??: continuous motions of robot joints

goal test??: complete assembly with no robot included!

path cost??: time to execute

AIMA Slides and; Chapter 3, Sections 14 10

Search algorithms

Basic idea:
offline, simulated exploration of state space
by generating successors of already-explored states

(a.k.a. expanding states)

function General-Search( problem, strategy) returns a solution, or failure
initialize the search tree using the initial state of problem

if there are no candidates for expansion then return failure
choose a leaf node for expansion according to strategy
if the node contains a goal state then return the corresponding solution
else expand the node and add the resulting nodes to the search tree

AIMA Slides and; Chapter 3, Sections 14 11

General search example

AIMA Slides and; Chapter 3, Sections 14 12

General search example

AIMA Slides and; Chapter 3, Sections 14 13

General search example

AIMA Slides and; Chapter 3, Sections 14 14

General search example

AIMA Slides and; Chapter 3, Sections 14 15

Implementation of search algorithms

function General-Search( problem,Queuing-Fn) returns a solution, or failure

nodesMake-Queue(Make-Node(Initial-State[problem]))

if nodes is empty then return failure
nodeRemove-Front(nodes)
if Goal-Test[problem] applied to State(node) succeeds then return node
nodesQueuing-Fn(nodes,Expand(node,Operators[problem]))

AIMA Slides and; Chapter 3, Sections 14 16

Implementation contd: states vs. nodes

A state is a (representation of) a physical configuration
A node is a data structure constituting part of a search tree

includes parent, children, depth, path cost g(x)
States do not have parents, children, depth, or path cost!

The Expand function creates new nodes, filling in various fields and using
Operators (or Actions) of problem to create the corresponding states.

AIMA Slides and; Chapter 3, Sections 14 17

Search strategies

A strategy is defined by picking the order of node expansion

Strategies are evaluated along the following dimensions:
completenessdoes it always find a solution if one exists?
time complexitynumber of nodes generated/expanded
space complexitymaximum number of nodes in memory
optimalitydoes it always find a least-cost solution?

Time and space complexity are measured in terms of
bmaximum branching factor of the search tree
ddepth of the least-cost solution
mmaximum depth of the state space (may be )

AIMA Slides and; Chapter 3, Sections 14 18

Uninformed search strategies

Uninformed strategies use only the information available
in the problem definition

Breadth-first search

Uniform-cost search

Depth-first search

Depth-limited search

Iterative deepening search

AIMA Slides and; Chapter 3, Sections 14 19

Breadth-first search

Expand shallowest unexpanded node

Implementation:
QueueingFn = put successors at end of queue

AIMA Slides and; Chapter 3, Sections 14 20

Breadth-first search

Expand shallowest unexpanded node

Implementation:
QueueingFn = put successors at end of queue

AIMA Slides and; Chapter 3, Sections 14 21

Breadth-first search

Expand shallowest unexpanded node

Implementation:
QueueingFn = put successors at end of queue

AIMA Slides and; Chapter 3, Sections 14 22

Breadth-first search

Expand shallowest unexpanded node

Implementation:
QueueingFn = put successors at end of queue

AIMA Slides and; Chapter 3, Sections 14 23

Properties of breadth-first search

Complete??

AIMA Slides and; Chapter 3, Sections 14 24

Properties of breadth-first search

Complete?? Yes (if b is finite)

Time?? 1 + b + b2 + b3 + . . . + bd = O(bd), i.e., exponential in d

Space?? O(bd) (keeps every node in memory)

Optimal?? Yes (if cost = 1 per step); not optimal in general

Space is the big problem; can easily generate nodes at 1MB/sec
so 24hrs = 86GB.

AIMA Slides and; Chapter 3, Sections 14 25

Romania with step costs in km

AIMA Slides and; Chapter 3, Sections 14 26

Uniform-cost search

Expand least-cost unexpanded node

Implementation:
QueueingFn = insert in order of increasing path cost

AIMA Slides and; Chapter 3, Sections 14 27

Uniform-cost search

Expand least-cost unexpanded node

Implementation:
QueueingFn = insert in order of increasing path cost

AIMA Slides and; Chapter 3, Sections 14 28

Uniform-cost search

Expand least-cost unexpanded node

Implementation:
QueueingFn = insert in order of increasing path cost

AIMA Slides and; Chapter 3, Sections 14 29

Uniform-cost search

Expand least-cost unexpanded node

Implementation:
QueueingFn = insert in order of increasing path cost

AIMA Slides and; Chapter 3, Sections 14 30

Properties of uniform-cost search

Complete?? Yes, if step cost

Time?? # of nodes with g cost of optimal solution

Space?? # of nodes with g cost of optimal solution

Optimal?? Yes

AIMA Slides and; Chapter 3, Sections 14 31

Depth-first search

Expand deepest unexpanded node

Implementation:
QueueingFn = insert successors at front of queue

AIMA Slides and; Chapter 3, Sections 14 32

Depth-first search

Expand deepest unexpanded node

Implementation:
QueueingFn = insert successors at front of queue

AIMA Slides and; Chapter 3, Sections 14 33

Depth-first search

Expand deepest unexpanded node

Implementation:
QueueingFn = insert successors at front of queue

AIMA Slides and; Chapter 3, Sections 14 34

Depth-first search

Expand deepest unexpanded node

Implementation:
QueueingFn = insert successors at front of queue

I.e., depth-first search can perform infinite cyclic excursions
Need a finite, non-cyclic search space (or repeated-state checking)

AIMA Slides and; Chapter 3, Sections 14 35

Properties of depth-first search

Complete??

AIMA Slides and; Chapter 3, Sections 14 36

Properties of depth-first search

Complete?? No: fails in infinite-depth spaces, spaces with loops
Modify to avoid repeated states along path
complete in finite spaces

Time?? O(bm): terrible if m is much larger than d
but if solutions are dense, may be much faster than breadth-first

Space?? O(bm), i.e., linear space!

Optimal?? No

AIMA Slides and; Chapter 3, Sections 14 37

Depth-limited search

= depth-first search with depth limit l

Implementation:
Nodes at depth l have no successors

AIMA Slides and; Chapter 3, Sections 14 38

Iterative deepening search

function Iterative-Deepening-Search( problem) returns a solution sequence
inputs: problem, a problem

for depth 0 to do
resultDepth-Limited-Search( problem, depth)
if result = cutoff then return result

AIMA Slides and; Chapter 3, Sections 14 39

Properties of iterative deepening search

Complete?? Yes

Time?? (d + 1)b0 + db1 + (d 1)b2 + . . . + bd = O(bd)

Space?? O(bd)

Optimal?? Yes, if step cost = 1
Can be modified to explore uniform-cost tree

AIMA Slides and; Chapter 3, Sections 14 40

Bidirectional Search

Search simultaneously forwards from the start point, and backwards from
the goal, and stop when the two searches meet in the middle.

Problems: generate predecessors; many goal states; efficient check for node
already visited by other half of the search; and, what kind of search.

AIMA Slides and; Chapter 3, Sections 14 41

Properties of Bidirectional Search

Complete?? Yes

Time?? O(b

Space?? O(b

Optimal?? Yes (if done with correct strategy e.g. breadth first).

AIMA Slides and; Chapter 3, Sections 14 42

Problem formulation usually requires abstracting away real-world details to
define a state space that can feasibly be explored

Variety of uninformed search strategies

Iterative deepening search uses only linear space
and not much more time than other uninformed algorithms

Examples of skills expected:

Formulate single-state search problem

Apply a search strategy to solve problem

Analyse complexity of a search strategy

AIMA Slides and; Chapter 3, Sections 14 43

CS: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Problem Solving and Search
$25