You are on page 1of 21

AI 1ST SESSIONAL SOLUTION

SECTION -C
Q12)ANS. Water Jug Problem:-

We are given two jugs, a 4-gallon one and 3-gallon one. Neither has any
measuring marked on it. There is a pump, which can be used to fill the jugs with water.
How can we get exactly 2 gallons of water into 4-gallon jug?

The state space for this problem can be described as the set of ordered pairs of
integers (X, Y) such that X = 0, 1, 2, 3 or 4 and Y = 0, 1, 2 or 3; X is the number of
gallons of water in the 4-gallon jug and Y the quantity of water in the 3-gallon jug.

The start state is (0, 0) and the goal state is (2, n) for any value of n, as the problem
does not specify how many gallons need to be filled in the 3-gallon jug (0, 1, 2, 3). So
the problem has one initial state and many goal states. Some problems may have
many initial states and one or many goal states.

The operators to be used to solve the problem can be described as shown in Fig.
2.3:

In order to describe the operators completely here are some assumptions, not
mentioned, in the problem state.
1. We can fill a jug from the pump.

2. We can pour water out a jug, onto the ground.

3. We can pour water out of one jug into the other.

4. No other measuring devices are available.

To solve the water jug problem, all we need, in addition to the problem description
given above, is a control structure which loops through a simple cycle in which some
rule whose left side matches the current state is chosen, the appropriate change to the
state is made as described in the corresponding right side and the resulting state is
checked to see if it corresponds to a goal state.

The loop continues as long as it does not lead to the goal. The speed with which the
problem is solved depends upon the mechanism, control structure, which is used to
select the next operation.

There are several sequences of operators which will solve the problem, two
such sequences are shown in Fig. 2.4:

In doing so some issues which affect the approach towards the solution are:
1. The rules should be stated explicitly and not written because they are allowable. For
example, the first rule states that “Fill the 4-gallon jug”, but it should have been written
as “if the 4-gallon jug is not already full, fill it” but the rule in its stated form is not wrong
as there is no condition that the already filled jug cannot be filled (may be after
emptying).

No doubt this is physically possible but not wise; as this won’t change the problem
state. In order to increase the efficiency of the problem solving program, it is imperative
to encode some constraints in the left side of the rules so that the rules should lead to
a solution that is the rules should be made more general.

2. Now consider the rules 3 and 4 should or should not these rules be included in the
list of available operators? Emptying an unmeasured amount of water onto the ground
is certainly allowed by the problem statement, but do these rules lead us near to a
solution. The answer is ‘no’ so these can be ignored. So, such rules which are really
applicable to the problem in arriving at the solution should be considered.

Q13) ans. Depth First Search

Depth-first search (DFS) is an algorithm for traversing or searching


tree or graph data structures. The algorithm starts at the root node
(selecting some arbitrary node as the root node in the case of a
graph) and explores as far as possible along each branch before
backtracking.

Time complexity: Equivalent to the number of nodes traversed in

DFS.
Space complexity: Equivalent to how large can the fringe

get.
Completeness: DFS is complete if the search tree is finite, meaning
for a given finite search tree, DFS will come up with a solution if it
exists.
Optimality: DFS is not optimal, meaning the number of steps in
reaching the solution, or the cost spent in reaching it is high.

Applications:-
The applications of DFS includes the inspection of two edge
connected graph, strongly connected graph, acyclic graph,
and topological order.

A graph is called two edges connected if and only if it remains


connected even if one of its edges is removed. This application is very
useful, in computer networks where the failure of one link in the
network will not affect the remaining network, and it would be still
connected.

Strongly connected graph is a graph in which there must exist a path


between ordered pair of vertices. DFS is used in the directed graph for
searching the path between every ordered pair of vertices. DFS can
easily solve connectivity problems.

It is implemented in recursion with LIFO stack data structure. It creates the


same set of nodes as Breadth-First method, only in the different order.

As the nodes on the single path are stored in each iteration from root to leaf
node, the space requirement to store nodes is linear. With branching
factor b and depth as m, the storage space is bm.

Disadvantage − This algorithm may not terminate and go on infinitely on


one path. The solution to this issue is to choose a cut-off depth. If the ideal
cut-off is d, and if chosen cut-off is lesser than d, then this algorithm may
fail. If chosen cut-off is more than d, then execution time increases.

Its complexity depends on the number of paths. It cannot check duplicate


nodes.

Breadth First Search

Breadth-first search (BFS) is an algorithm for traversing or


searching tree or graph data structures. It starts at the tree root (or
some arbitrary node of a graph, sometimes referred to as a ‘search
key’), and explores all of the neighbor nodes at the present depth
prior to moving on to the nodes at the next depth level.

Time complexity: Equivalent to the number of nodes traversed in


BFS until the shallowest

solution.
Space complexity: Equivalent to how large can the fringe

get.
Completeness: BFS is complete, meaning for a given search tree,
BFS will come up with a solution if it exists.
Optimality: BFS is optimal as long as the costs of all edges are equal.

BFS can be useful in finding whether the graph has connected


components or not. And also it can be used in detecting a bipartite
graph.

A graph is bipartite when the graph vertices are parted into two
disjoint sets; no two adjacent vertices would reside in the same set.
Another method of checking a bipartite graph is to check the
occurrence of an odd cycle in the graph. A bipartite graph must not
contain odd cycle.

It can be implemented using FIFO queue data structure. This method


provides shortest path to the solution.

If branching factor (average number of child nodes for a given node) = b and
depth = d, then number of nodes at level d = bd.

The total no of nodes created in worst case is b + b2 + b3 + … + bd.

Disadvantage − Since each level of nodes is saved for creating next one, it
consumes a lot of memory space. Space requirement to store nodes is
exponential.
Its complexity depends on the number of nodes. It can check duplicate
nodes.

Q14)ans. Types of Agents

Agents can be grouped into four classes based on their degree of


perceived intelligence and capability :

 Simple Reflex Agents


 Model-Based Reflex Agents
 Goal-Based Agents
 Utility-Based Agents
 Learning Agent

Simple reflex agents

Simple reflex agents ignore the rest of the percept history and act
only on the basis of the current percept. Percept history is the
history of all that an agent has perceived till date. The agent function
is based on the condition-action rule. A condition-action rule is a
rule that maps a state i.e, condition to an action. If the condition is
true, then the action is taken, else not. This agent function only
succeeds when the environment is fully observable. For simple reflex
agents operating in partially observable environments, infinite loops
are often unavoidable. It may be possible to escape from infinite loops
if the agent can randomize its actions. Problems with Simple reflex
agents are :

 Very limited intelligence.


 No knowledge of non-perceptual parts of state.
 Usually too big to generate and store.
 If there occurs any change in the environment, then the
collection of rules need to be updated.
Model-based reflex agents

It works by finding a rule whose condition matches the current


situation. A model-based agent can handle partially observable
environments by use of model about the world. The agent has to
keep track of internal state which is adjusted by each percept and
that depends on the percept history. The current state is stored
inside the agent which maintains some kind of structure describing
the part of the world which cannot be seen. Updating the state
requires information about :

 how the world evolves in-dependently from the agent, and


 how the agent actions affects the world.

Goal-based agents
These kind of agents take decision based on how far they are
currently from their goal(description of desirable situations). Their
every action is intended to reduce its distance from the goal. This
allows the agent a way to choose among multiple possibilities,
selecting the one which reaches a goal state. The knowledge that
supports its decisions is represented explicitly and can be modified,
which makes these agents more flexible. They usually require search
and planning. The goal-based agent’s behavior can easily be changed.

Utility-based agents

The agents which are developed having their end uses as building
blocks are called utility based agents. When there are multiple
possible alternatives, then to decide which one is best, utility-based
agents are used.They choose actions based on a preference
(utility) for each state. Sometimes achieving the desired goal is not
enough. We may look for a quicker, safer, cheaper trip to reach a
destination. Agent happiness should be taken into consideration.
Utility describes how “happy” the agent is. Because of the
uncertainty in the world, a utility agent chooses the action that
maximizes the expected utility. A utility function maps a state onto a
real number which describes the associated degree of happiness.

Learning Agent

A learning agent in AI is the type of agent which can learn from its
past experiences or it has learning capabilities.
It starts to act with basic knowledge and then able to act and adapt
automatically through learning.
A learning agent has mainly four conceptual components, which are:

1. Learning element :It is responsible for making improvements


by learning from the environment
2. Critic: Learning element takes feedback from critic which
describes how well the agent is doing with respect to a fixed
performance standard.
3. Performance element: It is responsile for selecting external
action
4. Problem Generator: This component is responsible for
suggesting actions that will lead to new and informative
experiences.
SECTION-B

Q8) ans. The heuristic function is a way to inform the search about the
direction to a goal.It can also be defined thus as a function that ranks
alternatives in search algorithms at each branching step based on
available information to decide which branch to follow.

 It provides an informed way to guess which neighbor of a node will


lead to a goal. It must use only information that can be readily
obtained about a node

 The objective of a heuristic is to produce a solution in a reasonable


time frame that is good enough for solving the problem at hand.

 This solution may not be the best of all the actual solutions to this
problem, or it may simply approximate the exact solution. But it
is still valuable because finding it does not require a prohibitively
long time.

 The representation may be approximate cost of the path from the


goal node or number of hopes required to reach to the goal.

 The heuristic function that we are considering, for a node n is, h


(n) =estimated cost of the cheapest path from the state at node n
to a goal.
 Example: For Travelling Salesman Problem, the sum of the
distances traveled so far can be a simple heuristic function.

 It is of two types: Maximize or Minimize function.

 In maximization, greater the cost of node, better is node while in


minimization, lower the cost better is the node.

Q9) ans. A production system (or production rule system) is a computer


program typically used to provide some form of artificial intelligence,
which consists primarily of a set of rules about behavior but it also includes
the mechanism necessary to follow those rules as the system responds to
states of the world[citation needed]. Those rules, termed productions, are a
basic representation found useful in automated planning, expert
systems and action selection.

OR

Production systems can be defined as a kind of cognitive architecture,


in which knowledge is represented in the form of rules. So, a system
that uses this form of knowledge representation is called a production
system. To simply put, production systems consists of rules and factors.
Knowledge is usually encoded in a declarative from which comprises of
a set of rules of the form.

The Major Components Of An AI Production System

 A global database

 A set of production rules

 A control system

The global database is the central data structure which used by an AI


production system. The production system. The production rules
operate on the global database. Each rule usually has a precondition
that is either satisfied or not by the global database. If the precondition
is satisfied, the rule is usually be applied. Application of the rule
changes the database. The control system then chooses which
applicable rule should be applied and ceases computation when a
termination condition on the database is satisfied. If multiple rules are
to fire at the same time, the control system resolves the conflicts.

4 Major Features Of Production System

 Simplicity

 Modularity

 Modifiability

 Knowledge Intensive

Advantages Of Production Systems In AI

 Provides excellent tools for structuring AI programs

 The system is highly modular because individual rules can be


added, removed or modified independently

 Expressed in natural form.

 Separation of knowledge and Control – Recognises Act Cycle

 A natural mapping onto state space research – data or


goal-driven

 Modularity of production rules

 The system uses pattern directed control which is more flexible


than algorithmic control

 Provides opportunities for heuristic control of search

 Tracing and Explanation – Simple Control, Informative rules

 Language Independence

 A plausible model of human problem solving -SOAR, ACT


 A good way to model the state-driven nature of intelligent
machines

 Quite helpful in real time in environment and applications.

Disadvantages Of Production Systems In AI

 It’s very difficult to analyse the flow of control within a


production system

 It describes the operations that can be performed in a search for


a solution to the problem. They can be classified as follows.

 There is an absence of learning due to a rule-based production


system which does not store the result of the problem for future
use.

 The rules in the production system should not have any type of
conflict resolution as when a new rule is added to the database
it should ensure that it does not have any conflict with any
existing rules.
ARCHITECTURE OF PRODUCTION SYSTEM

Q11) ans. Hill Climbing Algorithm in Artificial Intelligence


o Hill climbing algorithm is a local search algorithm which continuously moves in
the direction of increasing elevation/value to find the peak of the mountain or
best solution to the problem. It terminates when it reaches a peak value where
no neighbor has a higher value.

o Hill climbing algorithm is a technique which is used for optimizing the


mathematical problems. One of the widely discussed examples of Hill climbing
algorithm is Traveling-salesman Problem in which we need to minimize the
distance traveled by the salesman.

o It is also called greedy local search as it only looks to its good immediate neighbor
state and not beyond that.

o A node of hill climbing algorithm has two components which are state and value.

o Hill Climbing is mostly used when a good heuristic is available.

o In this algorithm, we don't need to maintain and handle the search tree or graph
as it only keeps a single current state.

Features of Hill Climbing:Following are some main features of Hill Climbing


Algorithm:

o Generate and Test variant: Hill Climbing is the variant of Generate and Test
method. The Generate and Test method produce feedback which helps to decide
which direction to move in the search space.

o Greedy approach: Hill-climbing algorithm search moves in the direction which


optimizes the cost.

o No backtracking: It does not backtrack the search space, as it does not remember
the previous states.

State-space Diagram for Hill Climbing:

The state-space landscape is a graphical representation of the hill-climbing algorithm


which is showing a graph between various states of algorithm and Objective
function/Cost.

On Y-axis we have taken the function which can be an objective function or cost function,
and state-space on the x-axis. If the function on Y-axis is cost then, the goal of search
is to find the global minimum and local minimum. If the function of Y-axis is Objective
function, then the goal of the search is to find the global maximum and local maximum.
Different regions in the state space landscape:

Local Maximum: Local maximum is a state which is better than its neighbor states, but
there is also another state which is higher than it.

Global Maximum: Global maximum is the best possible state of state space landscape. It
has the highest value of objective function.

Current state: It is a state in a landscape diagram where an agent is currently present.

Flat local maximum: It is a flat space in the landscape where all the neighbor states of
current states have the same value.

Shoulder: It is a plateau region which has an uphill edge.

Problems in Hill Climbing Algorithm:

1. Local Maximum: A local maximum is a peak state in the landscape which is better than
each of its neighboring states, but there is another state also present which is higher than
the local maximum.

Solution: Backtracking technique can be a solution of the local maximum in state space
landscape. Create a list of the promising path so that the algorithm can backtrack the
search space and explore other paths as well.

2. Plateau: A plateau is the flat area of the search space in which all the neighbor states
of the current state contains the same value, because of this algorithm does not find any
best direction to move. A hill-climbing search might be lost in the plateau area.
Solution: The solution for the plateau is to take big steps or very little steps while
searching, to solve the problem. Randomly select a state which is far away from the
current state so it is possible that the algorithm could find non-plateau region.

3. Ridges: A ridge is a special form of the local maximum. It has an area which is higher
than its surrounding areas, but itself has a slope, and cannot be reached in a single move.

Solution: With the use of bidirectional search, or by moving in different directions, we


can improve this problem.

SECTION-A

Q1)ANS. Local Maximum: A local maximum is a peak state in the landscape which is
better than each of its neighboring states, but there is another state also present which
is higher than the local maximum.

Solution: Backtracking technique can be a solution of the local maximum in state space
landscape. Create a list of the promising path so that the algorithm can backtrack the
search space and explore other paths as well.

2. Plateau: A plateau is the flat area of the search space in which all the neighbor states
of the current state contains the same value, because of this algorithm does not find any
best direction to move. A hill-climbing search might be lost in the plateau area.

Solution: The solution for the plateau is to take big steps or very little steps while
searching, to solve the problem. Randomly select a state which is far away from the
current state so it is possible that the algorithm could find non-plateau region.
3. Ridges: A ridge is a special form of the local maximum. It has an area which is higher
than its surrounding areas, but itself has a slope, and cannot be reached in a single move.

Solution: With the use of bidirectional search, or by moving in different directions, we


can improve this problem.

Q2) ANS. AI or artificial intelligence is the simulation of human intelligence

processes by machines, especially computer systems. These processes include


learning, reasoning and self-correction. Some of the applications of AI
include expert systems, speech recognition and machine vision. Artificial
Intelligence is advancing dramatically. It is already transforming our world
socially, economically and politically.

Applications of Artificial Intelligence:

1. Artificial Intelligence in Healthcare: Companies are applying


machine learning to make better and faster diagnoses than
humans. One of the best-known technologies is IBM’s Watson. It
understands natural language and can respond to questions
asked of it. The system mines patient data and other available
data sources to form a hypothesis, which it then presents with a
confidence scoring schema. AI is a study realized to emulate
human intelligence into computer technology that could assist
both, the doctor and the patients in the following ways:
 By providing a laboratory for the examination, representation
and cataloguing medical information
 By devising novel tool to support decision making and research
 By integrating activities in medical, software and cognitive
sciences
 By offering a content rich discipline for the future scientific
medical communities.
1. Artificial Intelligence in business: Robotic process automation is
being applied to highly repetitive tasks normally performed by
humans. Machine learning algorithms are being integrated into
analytics and CRM (Customer relationship management)
platforms to uncover information on how to better serve
customers. Chatbots have already been incorporated into
websites and e companies to provide immediate service to
customers. Automation of job positions has also become a talking
point among academics and IT consultancies.
2. AI in education: It automates grading, giving educators more
time. It can also assess students and adapt to their needs, helping
them work at their own pace.
3. AI in Autonomous vehicles: Just like humans, self-driving cars
need to have sensors to understand the world around them and
a brain to collect, processes and choose specific actions based on
information gathered. Autonomous vehicles are with advanced
tool to gather information, including long range radar, cameras,
and LIDAR. Each of the technologies are used in different
capacities and each collects different information. This
information is useless, unless it is processed and some form of
information is taken based on the gathered information. This is
where artificial intelligence comes into play and can be compared
to human brain. AI has several applications for these vehicles and
among them the more immediate ones are as follows:
 Directing the car to gas station or recharge station when it is
running low on fuel.
 Adjust the trips directions based on known traffic conditions to
find the quickest route.
 Incorporate speech recognition for advanced communication
with passengers.
 Natural language interfaces and virtual assistance technologies.
1. AI for robotics will allow us to address the challenges in taking
care of an aging population and allow much longer independence.
It will drastically reduce, may be even bring down traffic
accidents and deaths, as well as enable disaster response for
dangerous situations for example the nuclear meltdown at the
fukushima power plant.
2. Cyborg Technology: One of the main limitations of being
human is simply our own bodies and brains. Researcher Shimon
Whiteson thinksthat in the future, we will be able to augment
ourselves with computers and enhance many of our own natural
abilities. Though many of these possible cyborg enhancements
would be added for convenience, others may serve a more
practical purpose. Yoky Matsuka of Nest believes that AI will
become useful for people with amputated limbs, as the brain will
be able to communicate with a robotic limb to give the patient
more control. This kind of cyborg technology would significantly
reduce the limitations that amputees deal with daily.

Q5) ans. Agent Environment in AI


An environment is everything in the world which surrounds the agent, but it is not a part
of an agent itself. An environment can be described as a situation in which an agent is
present.

The environment is where agent lives, operate and provide the agent with something to
sense and act upon it. An environment is mostly said to be non-feministic.

Q6) ans. An agent can be anything that perceiveits environment through sensors and act
upon that environment through actuators. An Agent runs in the cycle
of perceiving, thinking, and acting.

Agent Function

 The agent function is a mathematical function that maps a sequence


of perceptions into action.
 The function is implemented as the agent program.
 The part of the agent taking an action is called an actuator.
 environment -> sensors -> agent function -> actuators -> environment

Q7) ans Rational Agent:

A rational agent is an agent which has clear preference, models uncertainty, and acts
in a way to maximize its performance measure with all possible actions.

A rational agent is said to perform the right things. AI is about creating rational agents
to use for game theory and decision theory for various real-world scenarios.

For an AI agent, the rational action is most important because in AI reinforcement


learning algorithm, for each best possible action, agent gets the positive reward and for
each wrong action, an agent gets a negative reward.

You might also like