Ai - Unit-1
Ai - Unit-1
Page 1
III Year CSE II Sem Artificial Intelligence Unit II
Production System – PS
It consists of
Production Rules
A control strategy that specifies the order in which the rules will be
applied when several rules match at once.
Advantages of PS
Page 2
III Year CSE II Sem Artificial Intelligence Unit II
Problem statement:
Solution:
State for this problem can be described as the set of ordered pairs
of integers (X, Y) such that
Production Rules
Page 3
III Year CSE II Sem Artificial Intelligence Unit II
Page 4
III Year CSE II Sem Artificial Intelligence Unit II
Trace of steps involved in solving the water jug problem - First solution
Page 5
III Year CSE II Sem Artificial Intelligence Unit II
there are set of rules that describe the actions called production
rules.
Left side of the rules is current state and right side describes
new state that results from applying the rule.
Specify one or more states within that space that describe possible
situations from which the problem solving process may start.
These states are called initial states.
Control Strategy decides which rule to apply next during the process of
searching for a solution to a problem.
Page 6
III Year CSE II Sem Artificial Intelligence Unit II
Page 7
III Year CSE II Sem Artificial Intelligence Unit II
Page 8
III Year CSE II Sem Artificial Intelligence Unit II
Consider 5 cities.
The problem is to find the shortest route for the salesman who has
to
Explore the search tree of all possible paths and return the shortest
path.
Page 9
III Year CSE II Sem Artificial Intelligence Unit II
If number of cities grow, say 25 cities, then the time required to wait a
salesman to get the information about the shortest path is of 0(24!)
which is not a practical situation.
How should they use this boat to cross the river in such a way that
cannibals never outnumber missionaries on either side of the
river? If the cannibals ever outnumber the missionaries (on either
bank) then the missionaries will be eaten. How can they all cross
over without anyone being eaten?
PS for this problem can be described as the set of ordered pairs of left
and right bank of the river as (L, R) where each bank is represented as a
list [nM, mC, B]
Page 10
III Year CSE II Sem Artificial Intelligence Unit II
Page 11
III Year CSE II Sem Artificial Intelligence Unit II
In this method also problem is viewed as finding a path from start state
to goal state.
Page 12
III Year CSE II Sem Artificial Intelligence Unit II
Problem Statement:
Solving this problem involves arranging tiles in the goal state from
the start state.
Start state Goal state
3 7 6 5 3 6
5 1 2 7 2
4 8 4 1 8
The start state could be represented as: [ [3,7,2], [5,1, 2], [4,0,6] ]
The operators can be thought of moving {up, down, left, right}, the direction in
which blank space effectively moves.
Page 13
III Year CSE II Sem Artificial Intelligence Unit II
Initial State
3 7 6
5 1 2
6 8
up left right
3 7 6 3 7 6 3 7 6
5 2 5 1 2 5 1 2
6 1 8 6 8 6 8
up left right
3 6 3 7 6 3 7 6
5 7 2 5 2 5 2
6 1 8 6 1 8 6 1 8
Problem can have more than one intermediate states between start and
goal states.
All possible states of the problem taken together are said to form
a state space or
Page 14
III Year CSE II Sem Artificial Intelligence Unit II
It is a control strategy that starts with known facts and works towards a
conclusion.
For example in 8 puzzle problem, we start from initial state to goal state.
In this case we begin building a tree of move sequences with initial state
as the root of the tree.
Generate the next level of the tree by finding all rules whose left
sides match with root and use their right side to create the new state.
Language OPS5 uses forward reasoning rules. Rules are expressed in the
form of “if-then rule”.
Find out those sub-goals which could generate the given goal.
It is a goal directed control strategy that begins with the final goal.
Continue to work backward, generating more sub goals that must also be
satisfied in order to satisfy main goal.
It expands all the states one step away from the initial state, then
expands all states two steps from initial state, then three steps
etc., until a goal state is reached.
All nodes at the same level are searched before going to the next
level down.
Page 15
III Year CSE II Sem Artificial Intelligence Unit II
Algorithm (BFS)
Output: Yes or No
Method:
• Initially OPEN list contains a START node and CLOSED list is empty;
Found = false;
Do {
} } /* end while */
Depth-First Search
Page 16
III Year CSE II Sem Artificial Intelligence Unit II
So only path of nodes from the initial node to the current node is stored
in order to execute the algorithm.
For implementation, two lists called OPEN and CLOSED with the same
conventions explained earlier are maintained.
Algorithms (DFS)
Method:
Form a stack consisting of (START, nil) and call it OPEN list. Initially set
CLOSED list as empty; Found = false;
Else
Page 17
III Year CSE II Sem Artificial Intelligence Unit II
If Found = true then return the plan used /* find it by tracing through
the pointers on the CLOSED list */ else return No
Stop
Comparisons
DFS
is effective when there are few sub trees in the search tree
that have only one connection point to the rest of the states.
can be dangerous when the path closer to the START and farther
from the GOAL has been chosen.
Is best when the GOAL exists in the lower left portion of the search
tree.
BFS
Page 18
III Year CSE II Sem Artificial Intelligence Unit II
For a given depth d, DFID performs a DFS and never searches deeper
than depth d and d is increased by 1 in next iteration if solution is not
found.
Advantages:
It takes advantages of both the strategies (BFS & DFS) and suffers
neither the drawbacks of BFS nor of DFS on trees
Disadvantages:
Heuristic Search
Page 19
III Year CSE II Sem Artificial Intelligence Unit II
In many AI problems,
In AI approaches,
There are at least two reasons for the adhoc approaches in AI.
Page 20
III Year CSE II Sem Artificial Intelligence Unit II
Page 21