Ai 03
Ai 03
CSE 4205/CSE-3201
Problems, Problem Spaces and Search
Problem Solving
• We want:
– To automatically solve a problem
• We need:
– A representation of the problem
– Algorithms that use some strategy to solve the problem defined in
that representation
Problem Representation
• General:
– State space: Set of all possible states for a given problem is known as
state space of the problem.
A problem is divided into a set of resolution steps from the initial state
to the goal state.
– Reduction to sub-problems: a problem is arranged into a hierarchy of
sub-problems.
States
• A problem is defined by its elements and their relations.
• In each instant of the resolution of a problem, those elements have
specific descriptors (How to select them?) and relations.
• A state is a representation of those elements in a given moment.
• Example:
n=3, S=6, and w1=2, w2=4, w3=6
• Solutions:
{2,4} and {6}
Sum of subsets
• We will assume a binary state space tree.
• The nodes at depth 1 are for including (yes, no) item 1, the nodes at
depth 2 are for item 2, etc.
• The left branch includes wi, and the right branch excludes wi.
• The nodes contain the sum of the weights included so far.
Sum of subset Problem:State Space Tree
w1 = 2, w2 = 4, w3 = 6 and S = 6
0
yes no
i1 2 0
yes no yes no
i2 6 2 4 0
i3 12 6 8 2 10 4 6 0
• Main idea: Backtracking consists of doing a DFS of the state space tree,
checking whether each node is promising and if the node is non-
promising backtracking to the node’s parent.
Backtracking
• The state space tree consisting of expanded nodes only is called the
pruned state space tree.
• The following slide shows the pruned state space tree for the sum of
subsets example.
• There are only 15 nodes in the pruned state space tree.
• The full state space tree has 31 nodes.
A Pruned State Space Tree (find all solutions)
w1 = 3, w2 = 4, w3 = 5, w4 = 6; S = 13
0
3 0
3 0
4 0 4 0
7 3 4 0
5 0 5 0 5 0
12 7 8 3 9 4
6 0
13 7