AIML Chapter 2
AIML Chapter 2
1.Define Problem: it include precise specification about Initial State as well as Final State.
2.Problem Analysis: Analyze the problem according to the available possible techniques to
solve a particular problem.
3.Identify and Represent the task knowledge that is necessary to solve the problem.
4.Choose the best problem solving technique and Apply to solve particular problem.
State Representation & Define Problem
State is represented as problem at a given time.
Define the initial state from where the solving process may start.
State Space (initial State): Set of ordered pair of integer (x,y) where x represents the
amount of water in 4-gallon jug and y represents the amount of water in 3 gallon jug.
Initial state is (0,0).
Goal state is (2,n) for any value of n.
Cont.
Production Rules
Current State Next State Description
(x,y) if x>0 (x-d,y) Pour some water out of the 4-gallon jug
(x,y) if y>0 (x,y-d) Pour some water out of the 3-gallon jug
(x,y)if x+y >=4 & y>0 (4,y-(4-x)) Pour water from the 3-gallon jug into 4-gallon until 4-gallon jug
is full
Current State Next State Description
(x,y)if x+y >=3 & (x-(3- Pour water from the 4-gallon jug into 3-gallon until
x>0 y),3)) 3-gallon jug is full
(x,y) if x+y <=4 & ((x+y),0) Pour all the water from the 3-gallon jug into the 4-
y>0 gallon jug
(x,y) if x+y <=3 & (0,(x+y)) Pour all the water from the 4-gallon jug into the 3-
x>0 gallon jug
(0,2) (2,0) Pour the 3 gallon jug into the 4-gallon jug
Water Jug – Solution
Gallons in 4-gallon Jug Gallons in the 3-gallon jug Rule Applied
0 0
0 3 2
3 0 9
3 3 2
4 2 7
0 2 5 or 12
2 0 9 or 11
8 Puzzle Problem
A non-monotonic production system is one which is not true. The production system increases the
problem-solving efficiency of the machine by not keeping a record of the changes made in previous
search process.
A partially communicative production system is a production system with the property that if the
application of particular sequence of rules transforms state X into state Y then any combination of those
rules that also transforms state X into state Y.
A commutative production system is a production system that is both monotonic and partially
commutative.
Problem Characteristics
To choose the appropriate method for a problem, it is necessary to analyze the problem
along several key dimensions.
1) Is the problem decomposable into a set of independent smaller or easier sub problems?
4) Is a good solution to a problem obvious without comparison to all other possible solutions?
6) Is a large amount of knowledge absolutely require to solve the problem or is knowledge important only to constrain
the search?
7) Can a computer that is simply given the problem return the solution or will the solution of the problem require
interaction between the computer and a person?
Issue in Design of Search Program
The direction in which to conduct the search (Forward & backward
reasoning). we can search forward through the state space from the start to
goal state or we can search backward from the goal.
Problem Decomposition
BFS DFS
Breadth First Search
What is BFS?
Breadth-first search as the name suggests itself will search breadth-wise
to find the shortest path in the graph. BFS is an Uninformed but systematic search
algorithm that explores level by level.
How BFS works
To implement this algorithm, we need to use a Queue data
structure that follows the FIFO first in first out methodology. In BFS, one vertex
is selected at a time and when it is visited and marked then its adjacent are
visited and stored in the queue and the visited one, we can remove from queue if
all the adjacent vertices are stored or explored.
In BFS we expand all possible moves from the current state before progressing to
the next level, prioritizing solutions at shallower depths.
Does BFS promise Optimal Results?
BFS promises optimal or guaranteed results always as it goes level by
level so, the result is sure, but it could lead to more time & and space complexity
to reach the goal (Only if it is solvable).
BFS Example: 8-puzzle problem
solving using BFS
BFS Example (For understanding)
Applications Of Breadth-First Search
Algorithm
1
1 2 4
1 5
3 5
3 4
Generate and Test
The generate-and-test strategy is the simple technique.
Algorithm:
2. Test to see if this is actually a solution by comparing the chosen point or the
endpoint of the chosen path to the set of acceptable goal state.
4. return to step 1.
Hill Climbing
Hill climbing is variant of generate-and-test in which feedback from the test procedure
is used to help the generator decide which direction to move in the search space.
Algorithm:
1. Evaluate the initial state. If it is a goal state, then return it and quit. Otherwise continue with
the initial state as current state.
2. Loop until a solution found or until there are no new operator s left to be applied in the
current state:
a) Select an operator that has not been applied to the current state and apply it to procedure
a new state.
b) Evaluate the new state.
a) If it is a goal state, then return it and quit
b) If it is goal state but it is better than the current state, then make it the current state.
c) If it is not better than the current state, then continue in the loop.
Limitation of Hill Climbing
• Local Maxima: it is a state that is better than all its
neighbour But is not better than some other state.
To overcome local maximum problem
backtracking is required, make a list of visited not
and explore a new path
A* Example
Set that node’s g value to 0, its h’ value to whatever it is, and its f’ value to h’+0 or h’.
Otherwise, generate the successors of BESTNODE but do not set the BESTNODE to point to them yet.
Step 3: For each of the SUCCESSOR, do the following steps
1. Set SUCCESSOR to point back to BESTNODE. These backwards links will make it possible to recover the path once a solution
is found.
3. See if SUCCESSOR is the same as any node on OPEN. If so call the node OLD.
Check whether it is cheaper to get to OLD via its current parent or to SUCESSOR via BESTNODE by comparing their g
values.
If OLD is cheaper, then do nothing. If SUCCESSOR is cheaper then reset OLD’s parent link to point to BESTNODE.
If SUCCESSOR was not on OPEN, see if it is on CLOSED. If so, call the node on CLOSED OLD and add OLD to the list of
BESTNODE’s successors.
If SUCCESSOR was not already on either OPEN or CLOSED, then put it on OPEN and add it to the list of BESTNODE’s
successors.
This decomposition or reduction generates arcs that we call AND arcs. One AND arc may
point to any numbers of successor nodes. All of which must then be solved in order for the
arc to point solution.
In order to find solution in an AND-OR graph we need an algorithm similar to best –first
search but with the ability to handle the AND arcs appropriately.
We define FUTILITY, if the estimated cost of solution becomes greater than the value of
FUTILITY then we abandon the search, FUTILITY should be chosen to correspond to a
threshold.
AND-OR Graph
AO* Algorithm
traverse the graph starting at the initial node and following the current best path, and accumulate the
set of nodes that are on the path and have not yet been expanded.
Pick one of these best unexpanded nodes and expand it. Add its successors to the graph and compute f
‘ (cost of the remaining distance) for each of them.
Change the f ‘ estimate of the newly expanded node to reflect the new information produced by its
successors. Propagate this change backward through the graph. Decide which of the current best path.
The propagation of revised cost estimation backward is in the tree is not necessary in A*
algorithm. This is because in AO* algorithm expanded nodes are re-examined so that the
current best path can be selected.
AO* Example
Advantages of AO*:
It is Complete
Will not go in infinite loop
Less Memory Required
Disadvantages of AO*:
It is not optimal as it does not explore all the path once it find a solution.
What is the difference between A* Algorithm and AO*
algorithm?
As compared with a straightforward search procedure, viewing a problem as one of the constraint satisfaction can
substantially reduce the amount of search.
Two-step process:
If there is still not a solution, then search begins, adding new constraints.
Example: The goal is to discover some problem state that satisfies the given set of constraints.
Means End Analysis
Most of the search strategies either reason forward of backward, Often a mixture of the two directions is
appropriate.
Such mixed strategy would make it possible to solve the major parts of problem first and solve the smaller
problems the arise when combining them together, Such a technique is called Means - Ends Analysis.
The means -ends analysis process centers around finding the difference between current state and goal state.
a set of operate with a set of preconditions their application and difference functions that computes the
Following are the main Steps which describes the working of MEA technique for solving a
problem.
First, evaluate the difference between Initial State and final State.
Select the various operators which can be applied for each difference.
Apply the operator at each difference, which reduces the difference between the current
state and goal state.
In the MEA process, we detect the differences between the
current state and goal state.
2. Else, select the most significant difference and reduce it by doing the following steps until the success or failure
occurs.
a) Select a new operator O which is applicable for the current difference, and if there is no such operator, then
signal failure.
c) If (First-Part <------ MEA (CURRENT, O-START) And (LAST-Part <----- MEA(O-Result, GOAL), are
successful, then signal Success and return the result of combining FIRST-PART, O, and LAST-PART.
Example (Mean & Analysis)
https://youtu.be/POM4mmLctyo?si=Hcbb-TQbXlrfAI9t
Uniform Cost Search Introduction to AI. Uniform cost search A breadth
-first search finds the shallowest goal state and will therefore be the c
heapest. - ppt download (slideplayer.com)
Thank You!