Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

PROBLEM SOLVING & UNINFORMED SEARCH

Gloria Virginia
UKDW - Genap 2022/2023

APPLYING AI CONCEPTS

Knowledge
base
Inference
mechanism

APPLYING AI CONCEPTS (2)

• Inference mechanism:
– A program that employs search and pattern matching
techniques

• Knowledge base & inference mechanism are separate but


very much interrelated

• The selection of a particular knowledge representation


method will greatly affect the type of search control strategy
used, and vice versa.

PROBLEM SOLVING BY HUMANS

• Fundamentally is a search process


– More random and less organized approach to problem
solving
– Using one or more algorithms
– Any solution is better than no solution at all
– Good solution is just as acceptable as the best solution,
moreover if the time & cost are less

Problem solving in AI is fundamentally


a search

PROBLEM SOLVING BY AI

Steps:
1. Problem formulation
➡ Process of deciding what conditions & states to consider,
given a goal

2. Searching
➡ Process of looking for subsequent stages of a
hypothetical journey (an action sequence)

3. Execution
➡ Implementation of the searching method chosen

SEARCHING

• Is a problem-solving technique that enumerates a problem


space from an initial position in search of a goal position (or
solution)

• The manner in which the problem space is explored is


defined by the search algorithm or strategy

• How well a strategy works is based on the problem at hand


➡ depends on the characteristic of the problem and the
algorithm

SEARCHING (2)
• When solving a problem, it’s convenient to think about the problem/
solution space
• The problem of search is to find a sequence of operators that
transition from the start to goal state

• Elements:
1. Problem state
• define the problem situation & existing condition, i.e. the initial state
2. Goal
• the objective to be achieved; can be more than one
3. Operator
• procedure used for changing from one state to another (an
algorithmic subroutine)

SEARCHING (3)
• Problem space representation:

1. State graph/state space

Ø A graph to define problem, visualize a solution, or select a


search method

2. Search tree

Ø A tree diagram of a problem

SEARCHING: STRATEGY

1. Uninformed search strategy


– Blind Search = naive search
– They are given no information other than its definition
– A general purpose search algorithm, operates in a brute-force
way

2. Informed search strategy


– could be a heuristic Search
– Have some knowledge or heuristics of where to look for solutions
– Widely used in optimization problem
– Heuristic: a rule of thumb or problem knowledge

UNINFORMED SEARCH

1. Generate and Test


2. Random search
3. Depth first search (DFS)
4. Breadth first search (BFS)
5. Non-Deterministic Search
6. Depth-Limited Search (DLS)
7. Iterative Deepening Search (IDS)
8. Bidirectional Search (BIDI)

10

GENERATE AND TEST

1. Generate a path serves as potential solution


2. IF solution found THEN done ELSE repeat by trying
another path

• We don’t keep track of what we’ve tried before


• Just move ahead with potential solutions

11

GENERATE AND TEST (2)

A B C

S G

D E F

Possible solutions:
• S-A-B • S-A-B-C
• S-D-A-B-E • S-D-E-B-C
• S-D-A-S-D-E • S-D-E-F-G
• S-A-S-A-S-A-S-A

12

RANDOM SEARCH

1. Randomly selects a new state from the current state


2. IF solution found THEN done ELSE randomly select
another new state or operator (leading to a new state)
and continue

13

RANDOM SEARCH (2)

A B C

S G

D E F

Process:
• S • S-A-D-E-B
• S-A • S-A-D-E-B-E
• S-A-D • S-A-D-E-B-E-F
• S-A-D-E • S-A-D-E-B-E-F-G

14

NOTES

• Generate and Test and Random Search are truly blind


methods of search

• They can get lost, get caught in loops, and potentially


never find a solution even though one exists within the
search space

15

DEPTH FIRST SEARCH (DFS)


• Begin with the root node then works downward to
successively deeper level
à expand the tree as deep as possible

• Returning to upper levels (backtracking) when needed


• Select a child : left-to-right (convention)

• Problem:
– It can often lead into deeper & deeper sub-network that
are far from the goal node which may exist at a much
higher level

16

DFS SEARCH TREE


Root node
(Start)
1

2 8 11

3 5 9 12 14

4 6 7 10 13 15 16
Goal
(End)

17

DFS ALGORITHM

1. QUEUE ← path only containing the root

2. WHILE QUEUE is not empty


AND goal is not reached

DO remove the first path from the QUEUE;


create new paths (to all children);
reject the new paths with loops;
add the new paths to front of the QUEUE;

3. IF goal reached THEN success ELSE failure

18


BREADTH FIRST SEARCH (BFS)

• Begin with the root node then examine all nodes in each level
before moving onto the next level
à expand the tree layer by layer, progressing in depth,
until goal is reached

• Always find the shortest path

19

BFS SEARCH TREE


Root node
(Start)

2 3 4

5 6 7 8 9 10

Goal
(End)

20

BFS ALGORITHM

1. QUEUE ← path only containing the root

2. WHILE QUEUE is not empty


AND goal is not reached

DO remove the first path from the QUEUE;


create new paths (to all children);
reject the new paths with loops;
add the new paths to back of the QUEUE;

3. IF goal reached THEN success ELSE failure

21

NON-DETERMINISTIC SEARCH (NDS)

• Similar with DFS/BFS


• Except that the new paths being added are located
randomly in the stack/queue

22



NDS ALGORITHM

1. QUEUE ← path only containing the root

2. WHILE QUEUE is not empty


AND goal is not reached

DO remove the first path from the QUEUE;


create new paths (to all children);
reject the new paths with loops;
add the new paths in random places in the QUEUE;

3. IF goal reached THEN success ELSE failure

23

DEPTH-LIMITED SEARCH (DLS)

• A modification of Depth First Search (DFS)

• Restrict a DFS to a fixed depth

• Minimize the depth of the tree that the search

algorithm may go

24



DLS ALGORITHM

1. DEPTH ← some_natural_number
QUEUE ← path only containing the root;

2. WHILE QUEUE is not empty


AND goal is not reached

DO remove the first path from the QUEUE;


IF path_length ≤ DEPTH THEN
create new paths (to all children);
reject the new paths with loops;
add the new paths to front of the QUEUE;

3. IF goal reached THEN success ELSE failure

25

ITERATIVE DEEPENING SEARCH (IDS)

• A derivative of Depth-Limited Search (DLS)

• Combine the feature of DFS and BFS

• Performing DLS with increased depth until the goal is


found

26





IDS ALGORITHM
1. DEPTH ← 1
QUEUE ← path only containing the root;

2. WHILE QUEUE is not empty


AND goal is not reached

DO remove the first path from the QUEUE;


IF path_length ≤ DEPTH THEN
create new paths (to all children);
reject the new paths with loops;
add the new paths to front of the QUEUE;
IF goal is not reached AND open_node in DEPTH is
empty THEN increase DEPTH by 1;

3. IF goal reached THEN success ELSE failure

27

BIDIRECTIONAL SEARCH (BIDI)

• A derivative of Breadth First Search (BFS)

• Compute the tree using BFS both from the start-node

and from a goal-node, until these searches meet in a

common node (a node visited by both searches)

• When the 2 searches meet in a common node, a path

can be reconstructed from the root to the goal

28






BIDI ALGORITHM

1. QUEUE1 ← path only containing the root;


QUEUE2 ← path only containing the goal;

2. WHILE both QUEUEi are not empty


AND QUEUE1 and QUEUE2 do not share a state

DO remove their first paths;


create their new paths (to all children);
reject their new paths with loops;
add their new paths to back of the QUEUE;

3. IF goal reached THEN success ELSE failure

29

METRICS
1. Time complexity
‣ Measure the worst-case time required to find a solution

2. Space complexity
‣ Measure the memory required during the search

3. Completeness
‣ Measure whether the algorithm find a path of solution

4. Optimality
‣ Measure whether the algorithm find the ‘optimal’ solution
available

30



BIG-O NOTATION
• A common comparison tool for algorithms
• Provides a worst-case measure of the complexity of a search
algorithm

No. Algorithm Time Space Complete Optimal


1 DFS O(bd) O(bd) No/Yes No/Yes
2 BFS O(bm) O(bm) Yes Yes
3 DLS O(bl) O(bl) No/Yes No/Yes
4 IDS O(bm) O(bm) Yes Yes
5 BIDI O(bm/2) O(bm/2) Yes Yes

b = branching factor m = tree depth of solution


d = tree depth l = search depth limit

31

PROBLEM IN UNINFORMED SEARCH

• Combinatorial explosion:
– It occurs when a small increase in the number of elements
that can be combined increase the number of combinations
to be computed so fast that it quickly reaches computational
limits
– So much time taken by blind search

32

You might also like