Que.6 Que.6 A.
A. Explain nearest neighbour algorithm with example.Explain nearest neighbour algorithm with example. Ans.
The nearest neighbor algorithm and the closely related repetitive nearest neighbor algorithm is The nearest neighbor algorithm and the closely related repetitive nearest neighbor algorithm is aa greedy algorithm for finding candidate solutions to the traveling salesman problem.
greedy algorithm for finding candidate solutions to the traveling salesman problem. The nearestThe nearest neighbor algorithm begins at the first city in your list of cities to visit. It then selects the closest city to neighbor algorithm begins at the first city in your list of cities to visit. It then selects the closest city to visit next. From the remaining unvisited cities
visit next. From the remaining unvisited cities it selects the citit selects the cit y closest to city two and so on.y closest to city two and so on. The nearest neighbour algorithm was one of the first
The nearest neighbour algorithm was one of the first algorithms used to determine a solution to the algorithms used to determine a solution to the travellingtravelling salesman problem. It quickly yields a short tour,
salesman problem. It quickly yields a short tour, but usually not the optimal one.but usually not the optimal one. Below is the application of nearest neighbour algorithm
Below is the application of nearest neighbour algorithm on TSPon TSP These are the steps of the al
These are the steps of the al gorithm:gorithm: 1.
1. stand on an arbitrary vertex as current vertex.stand on an arbitrary vertex as current vertex. 2.
2. find out the lightest edge connecting current vertex and an unvisited find out the lightest edge connecting current vertex and an unvisited vertex V.vertex V. 3.
3. set current vertex to V.set current vertex to V. 4.
4. mark V as visited.mark V as visited. 5.
5. if all the vertices in dif all the vertices in d omain are visited, then terminate.omain are visited, then terminate. 6.
6. Go to step 2.Go to step 2.
The sequence of the visited vertices is t
The sequence of the visited vertices is t he output of the algorithm.he output of the algorithm. The nearest neighbour algorithm is easy to implement and e
The nearest neighbour algorithm is easy to implement and e xecutes quickly, but it can sometimes miss shorterxecutes quickly, but it can sometimes miss shorter routes which are easily noticed with human insight, due t
routes which are easily noticed with human insight, due t o its "greedy" nature. As a o its "greedy" nature. As a general guide, if the last fewgeneral guide, if the last few stages of the tour are comparable in length
stages of the tour are comparable in length to the first stages, tto the first stages, t hen the tour is reasonable; if they are hen the tour is reasonable; if they are muchmuch greater, then it is likel
greater, then it is likel y that there are much better tours. Any that there are much better tours. An other check is to use an algorithm such as tother check is to use an algorithm such as t he lowerhe lower bound algorithm to estimate if this tour
bound algorithm to estimate if this tour is good enough.is good enough. In the worst case, the al
In the worst case, the al gorithm results in a tour that is gorithm results in a tour that is much longer than the optimal tour. To much longer than the optimal tour. To be precise, forbe precise, for every constant r there is an instance
every constant r there is an instance of the traveling salesman problem such that the length of the traveling salesman problem such that the length of the tour lengthof the tour length computed by the nearest neighbour algorithm is greater than r t
computed by the nearest neighbour algorithm is greater than r t imes the length of the optimal times the length of the optimal t our. Moreover,our. Moreover, for each number of cities there is
for each number of cities there is an assignment of distances between the cities for wan assignment of distances between the cities for w hich the nearest neighborhich the nearest neighbor heuristic produces the unique worst possible tour
heuristic produces the unique worst possible tour B.
B. Explain architecture of ANN.Explain architecture of ANN. Ans.
Ans. 1.1
1.1 Feed-forward networksFeed-forward networks
Feed-forward ANNs (figure 1) allow signals to tr
Feed-forward ANNs (figure 1) allow signals to tr avel one way only; from input to output. avel one way only; from input to output. There isThere is no feedback (loops) i.e. the output of any la
no feedback (loops) i.e. the output of any la yer does not affect that same layer. Feed-forwardyer does not affect that same layer. Feed-forward ANNs tend to be straight forward
ANNs tend to be straight forward networks that associate inputs with outputs. They are extensivelynetworks that associate inputs with outputs. They are extensively used in pattern recognition. This type
used in pattern recognition. This type of organisation is also referred to as bottom-up or of organisation is also referred to as bottom-up or top-down.top-down. 1.2
1.2 Feedback networksFeedback networks
Feedback networks (figure 1) can have signals travelling in both directions b
Feedback networks (figure 1) can have signals travelling in both directions b y introducing loops iny introducing loops in the network. Feedback networks are very powerful and can get extremely complicated.
the network. Feedback networks are very powerful and can get extremely complicated. Feedback Feedback networks are dynamic; their 'state' is
networks are dynamic; their 'state' is changing continuously until they reach an equilibrium point.changing continuously until they reach an equilibrium point. They remain at the equilibrium point until
They remain at the equilibrium point until the input changes and a new equilibrium needs to bethe input changes and a new equilibrium needs to be found. Feedback architectures are also referred to as interactive or
found. Feedback architectures are also referred to as interactive or recurrent, although the latterrecurrent, although the latter term is often used to denote feedback connections in single-la
Figure 1.1 An example of a simple feedforward Figure 1.1 An example of a simple feedforward
network
network Figure 1.2 An example of a complicated network Figure 1.2 An example of a complicated network 1.3
1.3 Network layersNetwork layers
The commonest type of artificial neural network consists
The commonest type of artificial neural network consists of three groups, or layers, of units: of three groups, or layers, of units: aa layer of "input" units is c
layer of "input" units is c onnected to a layer of "hidden" units, which is onnected to a layer of "hidden" units, which is connected to a layer of connected to a layer of "output" units. (see Figure 1.1)
"output" units. (see Figure 1.1) The activity of the input units r
The activity of the input units r epresents the raw information that is fed iepresents the raw information that is fed i nto the network.nto the network. The activity of each hidden unit is determined
The activity of each hidden unit is determined by the activities of the input units by the activities of the input units and the weights on theand the weights on the connections between the input and the hidden units.
connections between the input and the hidden units.
The behaviour of the output units depends on the activity of
The behaviour of the output units depends on the activity of the hidden units and the weights betweenthe hidden units and the weights between the hidden and output units.
the hidden and output units. This simple type of network is
This simple type of network is interesting because the hidden units are free to construct tinteresting because the hidden units are free to construct t heir ownheir own representations of the input. The weights between the input
representations of the input. The weights between the input and hidden units determine when each hiddenand hidden units determine when each hidden unit is active, and so by modifying t
unit is active, and so by modifying t hese weights, a hidden unit can choose what it hese weights, a hidden unit can choose what it representsrepresents We also distinguish single-layer and multi-layer architectures. The s
We also distinguish single-layer and multi-layer architectures. The s ingle-layer organisation, in which allingle-layer organisation, in which all units are connected to one another, constitutes the most general case and i
units are connected to one another, constitutes the most general case and i s of more potential computationals of more potential computational power than hierarchically structured multi-layer organisations. In multi-layer networks, units are
power than hierarchically structured multi-layer organisations. In multi-layer networks, units are oftenoften numbered by layer, instead of following a global numbering.
numbered by layer, instead of following a global numbering. 1.4
1.4 PerceptronsPerceptrons
The most influential work on neural nets i
The most influential work on neural nets i n the 60's went under the heading of n the 60's went under the heading of 'perceptrons' a term'perceptrons' a term coined by Frank Rosenblatt. The perceptron (figure 4.4) turns out to
coined by Frank Rosenblatt. The perceptron (figure 4.4) turns out to be an MCP model ( neuronbe an MCP model ( neuron with weighted inputs ) with some additional, fixed, pre--processing. Units labelled A1, A2, Aj ,Ap with weighted inputs ) with some additional, fixed, pre--processing. Units labelled A1, A2, Aj ,Ap are called association units and their task is
are called association units and their task is to extract specific, localised featured frto extract specific, localised featured fr om the inputom the input images. Perceptrons mimic the basic idea behind the
images. Perceptrons mimic the basic idea behind the mammalian visual system. They were mainlymammalian visual system. They were mainly used in pattern recognition even though their capabilities extended a lot
used in pattern recognition even though their capabilities extended a lot more.more.
Figure 1.4 Figure 1.4
C.
C. Explain fuzzy set and crisp set. Mention application of fuzzy logic.Explain fuzzy set and crisp set. Mention application of fuzzy logic. Ans.
Ans.
Fuzzy set: Fuzzy set: A
A fuzzy fuzzy set set is is a a pair pair (A,m) (A,m) where where A A is is a a set set and and .. For
For each each , , m(x) m(x) is is called called the the grade grade of of membership membership of of x x in in (A,m). (A,m). For For a a finite finite set set A A == {x
{x11,...,x,...,xnn}, the fuzzy set (A,m) is }, the fuzzy set (A,m) is often denoted by {m(xoften denoted by {m(x11) / x) / x11,...,m(x,...,m(xnn) / x) / xnn}.}.
Let
Let . . Then Then x x is is called called not not included included in in the the fuzzy fuzzy set set (A,m) (A,m) if if m(x) m(x) = = 0, 0, x x is is called called fullyfully included if m(x) = 1, and x i
included if m(x) = 1, and x i s called fuzzy member if 0 <s called fuzzy member if 0 < m(x) < 1.m(x) < 1.[4][4]The setThe set is called the support of (A,m) and t
is called the support of (A,m) and t he sethe set is called its kernel.
is called its kernel.
Sometimes, more general variants of the notion of fuzzy set
Sometimes, more general variants of the notion of fuzzy set are used, with membershipare used, with membership functions taking values in a (fixed or variable) al
functions taking values in a (fixed or variable) al gebra or structureL of a given kind; usually it gebra or structureL of a given kind; usually it isis required that L be at least a
required that L be at least a poset or latticeposet or lattice Crisp set:
Crisp set:
Application of fuzzy logic
Application of fuzzy logic: There are countless applications : There are countless applications for fuzzy logic. In fact, some claim tfor fuzzy logic. In fact, some claim t hathat fuzzy logic is the encompassing theory over all t
fuzzy logic is the encompassing theory over all t ypes of logic. The items in this ypes of logic. The items in this list are more commonlist are more common applications that one may encounter in everyday life.
applications that one may encounter in everyday life. Bus Time Tables
Bus Time Tables
How accurately do the schedules predict the actual travel ti
How accurately do the schedules predict the actual travel ti me on the bus?me on the bus? Bus schedules are formulated on information that does not remain constant.
Bus schedules are formulated on information that does not remain constant. They use fuzzy logicThey use fuzzy logic because it is impossible to give an exact answer t
because it is impossible to give an exact answer t o when the bus will be at o when the bus will be at a certain stop. Manya certain stop. Many unforseen incidents can occur. There can be accidents, abnormal traffic backups, or the
unforseen incidents can occur. There can be accidents, abnormal traffic backups, or the bus could break bus could break down. An observant scheduler would take all these possibilities
down. An observant scheduler would take all these possibilities into account, and include them in ainto account, and include them in a formula for figuring out the approximate schedule. It is t
formula for figuring out the approximate schedule. It is t hat formula which imposes the fuzzinesshat formula which imposes the fuzziness Temperature control (heating/cooling)
Temperature control (heating/cooling) The trick in temperature control is t
The trick in temperature control is t o keep the room at the same temperature consistently. o keep the room at the same temperature consistently. Well, thatWell, that seems pretty easy, right? But how much does a
seems pretty easy, right? But how much does a room have to cool off before the heat room have to cool off before the heat kicks in again?kicks in again? There must be some standard, so the heat (
There must be some standard, so the heat ( or air conditioning) isn't in a or air conditioning) isn't in a constant state of turning on andconstant state of turning on and off. Therein lies the fuzzy logic.
off. Therein lies the fuzzy logic. The set is determined by what The set is determined by what the temperature is actually set to.the temperature is actually set to. Membership in that set weakens as the room temperature
Membership in that set weakens as the room temperature varies from the set temperature. Oncevaries from the set temperature. Once membership weakens to a certain point, temperature control kicks in t
membership weakens to a certain point, temperature control kicks in t o get the room back to theo get the room back to the temperature it should be.
temperature it should be. Medical diagnoses Medical diagnoses
How many of what kinds of symptoms will
How many of what kinds of symptoms will yield a diagnosis? How often are doctors in error?yield a diagnosis? How often are doctors in error? Surely everyone has seen those lists of symptoms for a horrible
Surely everyone has seen those lists of symptoms for a horrible disease that say "if disease that say "if you have at least 5you have at least 5 of these symptoms, you are at risk". It
of these symptoms, you are at risk". It is a hypochondriac's haven. The question is, how do doctors gois a hypochondriac's haven. The question is, how do doctors go from that list of s
from that list of s ymptoms to a diagnosis? Fuzzy logic. There is no guaranteed system to ymptoms to a diagnosis? Fuzzy logic. There is no guaranteed system to reach areach a diagnosis. If there were, we wouldn't
diagnosis. If there were, we wouldn't hear about cases of medical misdiagnosis. The diagnosis can onlyhear about cases of medical misdiagnosis. The diagnosis can only be some degree within the fuzzy set.
be some degree within the fuzzy set. Predicting travel time
Predicting travel time This is especially difficult for
This is especially difficult for driving, since there are plenty of traffic driving, since there are plenty of traffic situations that can occur to slowsituations that can occur to slow down travel.
down travel.
As with bus timetabling, predicting ETA's is a great exercise in fuzzy logic. That's why it is called an As with bus timetabling, predicting ETA's is a great exercise in fuzzy logic. That's why it is called an estimated time of arrival. A major
estimated time of arrival. A major player in predicting travel time is player in predicting travel time is previous experience. It took me sixprevious experience. It took me six hours to drive to Philadelphia last time,
hours to drive to Philadelphia last time, so it should take me about that so it should take me about that amount of time when I make theamount of time when I make the trip again. Unfortunately, other factors are not t
trip again. Unfortunately, other factors are not t ypically considered. Weather, traffic, construction,ypically considered. Weather, traffic, construction, accidents should all be added into the fuzzy equation to deliver
accidents should all be added into the fuzzy equation to deliver a true estimate.a true estimate. Antilock Braking System
Antilock Braking System
It's probably something you hardly think about when you're slamming on the
The point of an ABS is
The point of an ABS is to monitor the braking system on the to monitor the braking system on the vehicle and release the brakes just beforevehicle and release the brakes just before the wheels lock. A computer is involved i
the wheels lock. A computer is involved i n determining when the best time to do tn determining when the best time to do t his is. Two mainhis is. Two main factors that go into determining this are t
factors that go into determining this are t he speed of the car when the brakes are he speed of the car when the brakes are applied, and how fastapplied, and how fast the brakes are depressed. Usually, the times
the brakes are depressed. Usually, the times you want the ABS to really work are wyou want the ABS to really work are w hen you're drivinghen you're driving fast and slam on the brakes. There is,
fast and slam on the brakes. There is, of course, a margin for error. It of course, a margin for error. It is the job of tis the job of t he ABS to behe ABS to be "smart" enough to never allow the error
"smart" enough to never allow the error go past the point when the wheels will lgo past the point when the wheels will l ock ock D.
D. Explain cut predicate in detail.Explain cut predicate in detail. Ans.
Ans.
Prolog provides a predicate that performs this function. It i
Prolog provides a predicate that performs this function. It i s called the cut/1, represented by ans called the cut/1, represented by an