Presentation is loading. Please wait.

Presentation is loading. Please wait.

Toy Problem: Missionaries and Cannibals

Similar presentations


Presentation on theme: "Toy Problem: Missionaries and Cannibals"— Presentation transcript:

1 Toy Problem: Missionaries and Cannibals
On one bank of a river are three missionaries (black triangles) and three cannibals (red circles). There is one boat available that can hold up to two people and that they would like to use to cross the river. If the cannibals ever outnumber the missionaries on either of the river’s banks, the missionaries will get eaten. How can the boat be used to safely carry all the missionaries and cannibals across the river? Solving Problems by Searching

2 Solving Problems by Searching
Search Problems initial state set of possible actions/applicability conditions successor function: state  set of <action, state> successor function + initial state = state space path (solution) goal goal test function or goal state path cost function assumption: path cost = sum of step costs for optimality Initial state: current state the world is in (state = situation) States: symbol structures representing real world objects and relations  physical symbols systems; Possible actions aka. operators or production rules (problem formulation) Successor function: action is applicable in given state; result of applying action in given state is paired state State space: directed graph with states as nodes and actions as arcs Path: in the graph Goal (goal formulation) Function for multiple goal states (chess) or state for unique goal state (Bucharest) solution path from initial state to goal state Path cost function Step cost: cost of applying a given action in a given state Optimality: solution path with minimal path cost Solving Problems by Searching

3 Missionaries and Cannibals: Initial State and Actions
all missionaries, all cannibals, and the boat are on the left bank 5 possible actions: one missionary crossing one cannibal crossing two missionaries crossing two cannibals crossing one missionary and one cannibal crossing Actions: not every action applicable in every state Example: first action not applicable in initial state Solving Problems by Searching

4 Missionaries and Cannibals: State Space
1m 1c 1m 1m 1m 1c 2c 2c 1c 1c 16 possible world states Actions reversible and reversing action is same action; hence bidirectional arcs 1c 1c 2m 2m 1m 1c Solving Problems by Searching

5 Solving Problems by Searching
Breadth-First Search strategy: expand root node expand successors of root node expand successors of successors of root node etc. implementation: use FIFO queue to store fringe nodes in general tree search algorithm Strategy: all nodes at one level are expanded before any nodes at the next level are expanded FIFO queue: new nodes queued at the end of the queue meaning shallower nodes will get expanded first Solving Problems by Searching

6 Breadth-First Search: Missionaries and Cannibals
depth = 0 depth = 1 depth = 2 depth = 3 Solving Problems by Searching

7 Solving Problems by Searching
Depth-First Search strategy: always expand the deepest node in the current fringe first when a sub-tree has been completely explored, delete it from memory and “back up” implementation: use LIFO queue (stack) to store fringe nodes in general tree search algorithm alternative: recursive function that calls itself on each of its children in turn Strategy: Search proceeds immediately to the deepest level of the tree, where the nodes have no successors; Deletion of (unsuccessfully) explored sub-trees saves memory; “backing up” means going to a shallower node in the search tree that will be expanded next; LIFO queue: New nodes queued at the beginning of the queue meaning deeper nodes will get expanded first; Effectively, this is a stack; Solving Problems by Searching

8 Depth-First Search: Missionaries and Cannibals
Always expand one of the newly generated children until progress is blocked depth = 2 depth = 3 Solving Problems by Searching

9 Depth-First Search: Finding the Optimal Path
first solution discovered may not be optimal  must keep searching continued search: assumption: non-decreasing path costs remember path cost of cheapest path found so far do not expand nodes for which path cost exceeds cheapest found so far General problem: need to search complete tree with DF search to find optimal path  use BF search instead Solving Problems by Searching


Download ppt "Toy Problem: Missionaries and Cannibals"

Similar presentations


Ads by Google