Summary of Chapter 2
- 3 major types of agents:
- reflex agents
- goal-based agents
- utility-based agents
- Choice of agent depends on:
- the architecture
- the goals
- the environment (accessibility, deterministic, episodic, static, and discrete)
- the performance measure
Wumpus World Agent
Search
- Search is the fundamental technique for building goal-based agents
- the process of looking for a sequence of actions that leads to the goal state is called search
- Problem formulation
- problem types
- goals, states and actions
- Search strategies
- breath-first, uniform cost, depth-first, iterative deepening
Problem solving agents
- Basic problem solving agent finds sequences of actions that lead to desirable states; 4 steps
- 1. assess the state of the world
- 2. formulate the problem and goal
- 3. search for a solution
- 4. execute the solution
Types of Problems
- single state (world is accessible)
- multiple state (non-accessibility makes distinction between states impossible)
- contingency requiring the interleaving of search and execution --- not covered in this section
Problem formulation
- Basic constituents: states, goals, and actions
- states: descriptions of the world (representation of the important properties only)
- goals: sets of world states that have desirable properties
- actions: actions cause transitions between states
- Problem formulation comprises decisions about which properties of the world matter
- Abstraction is the process of removing detail
Data structures for problem definition
- initial-state (state representation in general)
- operators (successor functions)
- path cost (a function to compute this)
Terminology
- state space: the set of all states reachable from the initial state by any sequence of actions
- path: a sequence of actions leading from one state to the next
- solution: a path from the initial state to the state that satisfies the goal test
Two kinds of single- or multi-state problems
- Problems where the solution path matters:
- Examples: route finding, 8-puzzle, missionaries and cannibals
- Problems where the path does not matter (path cost = 0); these are typically constraint satisfaction problems
- Examples: 8-queens problem, VLSI, cryptarithmetic
Example problem (path matters): Missionaries and cannibals
- First studied in 1971. Definition:
- 3 missionaries and 3 cannibals, 1 boat that can carry up to 2 people.
- Must move missionaries and cannibals across the river
- missionaries should never be outnumbered by cannibals
Example continued
- Representation:
- represent states with three-digit code, (mcb), that indicates the number of missionaries, cannibals and boats on the starting (say left) bank of the river
- Questions: Why not distinguish between M’s and C’s? Why not represent M’s and C’s in boat? Why not represent both sides of the river?
Example continued
- Represent actions with 5 operators: 1M, 1C; 2M; 2C; 1M; 1C
- But legal successors can be computed by add and subtracting some number <= 2 with the restriction that: (ML = 0) | (ML = 3) | (ML > CL)
- path cost: each action (trip across the river) costs 1
8-Puzzle
Basic search algorithm
- Let node-list be a list containing the initial state
loop
if node-list is empty, return failure
node <= pop(node-list)
if node is a goal
return (path from initial state to) node
else apply applicable operators to node and merge the newly generated states into node-list
end loop
Search Trees
Search strategies
- search proceeds by expanding or generating new states from the current state using the operators (allowable actions)
- the search strategy determines which of the newly generated states is explored first; this is controlled by how the new states are added and removed from the node-list
- node-list is viewed as a queue
Issues in selecting a strategy
- Is the goal the minimum cost path or any path as quickly as possible
- Important note: because of loops search trees may be infinite even if the search space is small
Evaluation criteria
- Completeness: is the strategy guaranteed to find a solution if there is one
- Time complexity (worst case)
- Space complexity (worse case)
- Optimality: does the strategy find the best solution when there are several.
Four uninformed search strategies
- depth-first and depth limited
Breath-first
- Expand the shallowest nodes first. New nodes are added to the back of nodelist
- BFS is complete and it is optimal for unweighted graphs
- Space and Time complexity: O(bd) where b is the branching factor and d is the solution depth
Uniform cost
- a generalization of breath-first search to weighted graphs; expands the minimum cost node first where the cost of a node is taken to be the cost of the path to the node
- in an unweighted tree the shallowest node is the minimum cost node --- breath-first search
- for uniform cost, new nodes are added to node-list and then the list (queue) is sorted according to cost so that the lowest cost nodes are first in the queue
Uniform cost continued
- uniform cost is optimal provided the cost of a path never decreases as you go along the path
- space and time complexity: O(bd)
Depth-first
- depth-first always expands one of the nodes at the deepest level of the tree; new nodes are added to the front of node-list
- DFS is not complete or optimal
- space complexity: O(bm) where b is the branching factor, and m is the maximum depth of the tree
Depth-limited and Iterative deepening
- depth-limited search is DFS with an imposed maximum path depth cutoff
- properties are similar to DFS
- iterative deepening can be thought of as repetitive depth-limited search with each repetition extending the depth limit by one
for depth <= 0 to infinity
if depth-limited-search(problem, depth) succeeds then return its result
end
return failure