AI Notes11
AI Notes11
1. Explain Steepest Assent Hill Climbing with advantages and disadvantages with
solution
Ans:
A useful variation on simple hill climbing considers all the moves from the
current state and selects the best one as the next state. This method is called
Steepest Assent Hill Climbing or Gradient Search. This is contrasts with the
basic method in which the first state is better than the current state is selected.
This algorithm works as follows
Steepest-Ascent Hill Climbing
1. Evaluate the initial state. It is also a goal state them return it and quit.
Otherwise continue with the initial state as the current state
2. Loop the Solution is found or a complete iteration produces no change to the
current state
(a) Let SUCC be a state such that any possible successor to the current state will
be better than the SUCC
(b) For each operator that applies to the current state do:
i. Apply the operator and generate new state
ii. Evaluate the new state.
If it is the goal state then return it and quit .
If not compare it to SUCC
If it is better then set SUCC to this state.
If it is not better then leave SUCC alone
( c ) If SUCC is better than the current state, then set current state to
the SUCC
Advantages:
1. Considers all the moves from the current state.
2. Selects the best one as the next state.
Disadvantages:
1. Both Simple and Steepest Ascent Hill Climbing may fail to find a solution,
i.e., both may terminate by not finding a goal state but land to a state
from no better state can be generated.
2. This will happen if the program reaches local maxima, a plateau or a ridge.
Local Maxima:
1. Local maximum is a state that is better than all its neighbors but not better than
other states far away.
2. In a local maximum all moves appears to make things worse.
3. Local maximum is frustrating because they almost appear within sight of
solution,
4. This case is called foothills
A plateau:
1. A plateau is a flat area is a search state in which whole set of neighbor states
have a same value
2. It is not possible to determine the best direction of move by local comparison
A ridge:
1. Ridge is a special kind of local maximum
2. It is the area of the search space which is higher than the surrounding area
which has a slope
3. But due to orientation in high region, set of available moves and the direction of
the move it is difficult to traverse in single direction
Assign a decimal digit to each of the letters in such a way that the answer to the
problem is correct. If the same letter occurs more than once, it must be assigned the
same digit each time. No two different letters may be assigned the same digit
Step 1:
In the above problem, M must be 1,. You can visulazise that, this is an addition
problem. The sum of two digit numbers cannot be more than ),000. Also M cannot
be zero according to the rules, since it is the first letter.
Step 2:
Now in the column s10,s+1>_10 . S must be 8 because there is a 1 carried over from
the column EON or 9. O must be 0(if s=8 and there is a 1 carried or s=9 and there is
no 1 carried) or 1(if S=9 and there is a 1 carried). But 1 is already taken, so O must
be 0
Step 3:
There cannot be a carry from the column EON because In the column EON, E
cannot be equal to N. So there must be any digit +0<10, unless there is a carry
from the column NRE and E=9. But this cannot be the case because then N
would be 0 and 0 is already taken. So E<9 and there is no carry from this
column. Therefore S=9 because 9+1=10
Step 4:
Step 5:
Now just think what are the digits we have left? They are 7,6,5,4,3,and 2. We
know there must be a carry from the column DEY. So D+E>10. N=E+1, So E
cannot be 7 because then N would be 8 which is already taken , D is almost 7, so
E cannot be 2 because then D+E<10 and E cannot be 3 because then D+E=10 and
Y=0, but 0 is already taken. Also E cannot be 4 because if D>6, D+E<10 and D\id
D=6 or D=7 then Y=0or Y=1 which are both taken. So E is 5 or 6
If E=6 then D=7 and Y=3. So this part will work but look the column N8E. Point
that there is a carry from the column D5YN+8+1=16( As there is a carry from
this column) But then N=7 and 7 is taken by D there E=5
Step 6:
We now have goten theis important digit, it gets much rasuer from here
N+8+1=15,N=6
Step 7:
The digits left are 7,4,3 and 2. We know there is a carry form the column D5Y, so
the only pair that works is D=7 and Y=2
Path:
Single Path:
Two Path:
Classification:
Ans:
Mundane Tasks
Perception
Vision
Speech
Natural Language
Understanding
Generation
Translation
Commonsense Reasoning
Robot Control
Formal Tasks
Games
Chess
Backgammon
Checker, Go
Mathematics
Geometry
Logic
Integral Calculus
Proving Property of Programs
Expert Tasks
Engineering
Design
Fault Finding
Manufacturing Planning
Scientific Analysis
Medical Diagnosis
Financial Analysis
5. Explain production system in detail with its categories
Ans:
Diagram:
Example:
Approaches of reasoning:
Three approaches
1. Symbolic reasoning
2. Statistical reasoning
3. Fuzzy logic reasoning
6. Write the algorithm for conversion of clause form along with example
7. Write the algorithm to unify(L1,L2)/Explain unification algorithm
Ans: Algorithm:
Algorithm Unify(L1,L2)
1. If L1 or L2 are both variables or constants, then:
(a) If L1 and L2 are identical, then return NIL
(b) Else if L1 is a variable, then if L1 occurs in L2 then return (FAIL),
else return (L2/L1)
(c ) Else if L1 is a variable, then if L2 occurs in L1 then return (FAIL),
else return (L1/L2)
(d) Else return (FAIL)
2. If the initial predicate symbols in L1 and L2 are not identical, then return (FAIL)
3. If L1 and L2 have different numbers of arguments, then return (FAIL)
4. Set SUBST to NIL. (At the end of this procedure, SUBST will contain all the
substitutions used to unify L1 and L2)
5. For i←1 to number of arguments in L1:
(a) Call Unify with the arguments of L1 and the i th argument of L2, putting result
in S
(b) If S contains FAIL, then return (FAIL)
(c) If S is not equal to NIL then:
(i) Apply S to the remainder to both L1 and L2
(ii) SUBST: = APPEND(S<SUBST)
6. Return SUBST
Explanation-Unification Algorithm:
Given two terms T1 and T2 which are to be unified
If T1 is a variable then instance of T1 to T2
Otherwise, T2 is a variable then instance of T2 to T1
Otherwise ,if T1 and T2 are complex terms with the same number /arguments
Find the principle factor of F1 in T1 and principal factor of F2 in T2
If these are the same then take the ordered set of arguments (A1,…..,AN) of T1
and ordered set of arguments (B1,…., BN ) of T2.For each pair of arguments AM
and BM from same position of the term AM must unify with BM
Otherwise fail
8. State and explain algorithm for best first search with an example
Ans: Best-First Search:
OPEN: nodes that have been generated, but have not examined.
This is organized as a priority queue.
CLOSED: nodes that have already been examined.
Whenever a new node is generated, check whether it has been
generated before.
Algorithm:
1. OPEN = {initial state}.
2. Loop until a goal is found or there are no nodes left in OPEN:
- Pick the best node in OPEN
- Generate its successors
- For each successor:
new evaluate it, add it to OPEN, record its parent
generated before change parent, update successors
f(n) (heuristic function) = g(n) + h(n)
h(n) (heuristic factor) = estimated cost of the cheapest path from node n to a goal
state.
g(n) (depth factor) = cost of the cheapest path from the initial state to node n.
Greedy search:
h(n) = estimated cost of the cheapest path from node n to a goal state.
Neither optimal nor complete
Uniform-cost search:
g(n) = cost of the cheapest path from the initial state to node n.
Optimal and complete, but very inefficient
Ans:
Explanation
10. What are properties of good system for representation of knowledge? Explain
approaches to knowledge representation. List the issues of Knowledge
representation
Ans:
Representation of knowledge :
Using mathematical logic as the representational formalism I English sentence
Spot is a Dog –
English sentences can be represented as logic
Dog(Spot)
logical representation as facts
x:dog(x) ->hastail(x)
using deductive mechanism as logic and generating new representation object
hastail(Spot)
Using backward mapping function
Spot has a tail
11. A water jug problem ststes “You are given two jugs, first one with 4-gallon
capacity and the second one with 3-galloncapacity. Neither have any measuring
markers on it. There is a pump that can be used to fill the jugs with water. How
can you get exactly 2 gallon of water into 4-gallon jug.”
Ans: Definition
Example: State Space Search: Water Jug Problem
Rules:
The role of the condition in the left side of a rule
restrict the application of the rule
more efficient
1. (x, y) (4, y) Fill the 4 gallon jug
if x 4
2. (x, y) (x, 3) Fill the 3 gallon jug
if y 3
3. (x, y) (x d, y) Pour some water out of 4 gallon jug
if x 0
4. (x, y) (x, y d) Pour some water out of 3 gallon jug
if y 0
5. (x, y) (0, y) Empty 4 gallon jug to the ground
if x 0
6. (x, y) (x, 0) Empty 4 gallon jug to the ground
if y 0
7. (x, y) (4, y (4 x)) Pour water from 3 gallon jug into 4 gallon jug
if x y 4, y 0 until 4 gallon jug is full
8. (x, y) (x (3 y), 3) Pour water from 4 gallon jug into 3 gallon
if x y 3, x 0 jug until3 gallon jug is full
10. (x, y) (0, x y) 0) Pour all water from 4 gallon jug into3 gallon
if x y 3, x 0 jug
11. (0, 2) (2, 0) Pour 2 gallons from the 3- gallon jug into
the 4-gallon jug
Steps:
1. Both empty
2. fill three gallon jug
3. Pour water from 3 gallon jug to 4 gallon jug
4. Fill 3 gallon jug
5. Pour water from 3 gallon jug to 4 gallon jug
6. Empty 4 gallon water to the ground
7. Pour all water from 3 gallon jug to 4 gallon jug
One Path:
We initially set the temperature high and then allow it to ‘cool' slowly as the
algorithm proceeds. When the temperature is high, the algorithm is allowed to accept
worse solutions with high frequency.
A variation of hill climbing in which, at the beginning of the process, some
downhill moves may be made.
To do enough exploration of the whole space early on, so that the final
solution is relatively insensitive to the starting state.
Lowering the chances of getting caught at a local maximum, or plateau, or a
ridge.
Physical Annealing:
Comes from the physical process of annealing in which substances are raised
to high energy levels (melted) and then cooled to solid state.
The probability of moving to a higher energy state, instead of lower is
p = e^(-E/kT)
where E is the positive change in energy level, T is the temperature,
and k is Boltzmann’s constant.
Process:
Physical substances are melted and then gradually cooled until some solid
state is reached.
The goal is to produce a minimal-energy state.
Annealing schedule: if the temperature is lowered sufficiently slowly, then the
goal will be attained.
Nevertheless, there is some probability for a transition to a higher energy state:
e-E/kT.
At the beginning, the temperature is high.
As the temperature becomes lower
kT becomes lower
E/kT gets bigger
(-E/kT) gets smaller
e^(-E/kT) gets smaller
As the process continues, the probability of a downhill move gets smaller and smaller
Algorithm:
1. Evaluate the initial state.
2. Loop until a solution is found or there are no new operators left to be applied:
- Set T according to an annealing schedule
- Selects and applies a new operator
- Evaluate the new state:
goal quit
E = Val(current state) - Val(new state)
E < 0 new current state
else new current state with probability e-E/kT.
E represents the change in the value of the objective function.
Since the physical relationships no longer apply, drop k. So p = e^(-E/T)
We need an annealing schedule, which is a sequence of values of T: T0, T1, T2,
...
Here, the Inference Engine follows the chain of conditions and derivations and
finally deduces the outcome. It considers all the facts and rules, and sorts them
before concluding to a solution.
This strategy is followed for working on conclusion, result, or effect. For
example, prediction of share market status as an effect of changes in interest
rates.
Backward Chaining:
An alternative method, backward chaining, starts from a conclusion and
tries to show it by following a logical path backward from the conclusion
to a set of antecedents that are in the database of facts.
With this strategy, an expert system finds out the answer to the question,
“Why this happened?”
On the basis of what has already happened, the Inference Engine tries to
find out which conditions could have happened in the past for this result.
This strategy is followed for finding out cause or reason. For example,
diagnosis of blood cancer in humans.
Facts:
1. A (headache)
2. B (fever)
3. F (heart problem)
Goal:
1. H (heart patient)
Convert the above facts into wff hen in clause form and prove “Did Marcus hate
Caesar” using resolution
Convert the above facts into wff hen in clause form and prove “Was Marcus
loyal to Caesar” using resolution