Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Definition (1 mark)
According to the father of Artificial Intelligence, John McCarthy, it is “The science and
engineering of making intelligent machines, especially intelligent computer programs”.
Artificial Intelligence is a way of making a computer, a computer-controlled robot, or a software
think intelligently, in the similar manner the intelligent humans think.
Applications of AI (2 marks)
PEAS (1 mark)
Performance Measure: The objective function to judge the performance of the gent. Environment:
The real environment where the agent need to deliberate actions.
Actuators: These are the tools, equipment or organs using which agent perform actions in the
environment.
Sensors: These are tools, organs using which agent captures the state of the environment.
Performance Measure:
Safety: Automated system should be able to drive the car safely without dashing anywhere.
Optimum speed: Automated system should be able to maintain the optimal speed depending upon the
surroundings.
Comfortable journey: Automated system should be able to give a comfortable journey to the end user.
Environment:
Roads: Automated car driver should be able to drive on any kind of a road ranging from city roads to
highway.
Traffic conditions: You will find different sort of traffic conditions for different type of roads.
Actuators:
Sensors: To take input from environment in car driving example cameras, sonar system etc.
A. 1. Local Maxima: a local maximum as opposed to global maximum. A local maxima is a “peak”
that is higher than each of its neighboring states, but lowers than global maxima.
Hill climbing algorithm that reaches the vicinity of local maxima will be drawn upwards towards the
peak but will then be stuck with nowhere else to go.
2. Plateaus (flat local maxima): An area of the search space where evaluation function is flat, thus
requiring random walk.
3. Ridge: Where there are steep slopes and the search direction is not towards the top but towards the
side. Ridges result in a sequence of local maxima that is very difficult to navigate.
A. Map Coloring: Given a map of countries, and a fixed set of colors, assign a color to each region in
the map in such a way that no two adjacent regions have the same color
Example:
Variables WA, NT, Q, NSW, V, SA, T
• Breadth-first search is the most common search strategy for traversing a tree or graph. This
algorithm searches breadth wise in a tree or graph, so it is called breadth-first search.
• BFS algorithm starts searching from the root node of the tree and expands all successor nodes at
the current level before moving to nodes of next level.
• Breadth-first search implemented using FIFO queue data structure.
Algorithm:
Advantages: G
It requires lots of memory since each level of the tree must be saved into memory to expand the
next level.
BFS needs lots of time if the solution is far away from the root node.
Scheme: Statement 1M
Algorithm: 2M
Example: 2M
• A set of rules, each consisting of a left side that determines the applicability of the rule and a
right side that describes the operation to be performed if that rule is applied.
• One or more knowledge/databases that contain whatever information is appropriate for the
task. Some parts of the database may be permanent, while other parts of it may pertain only to
the solution of the current problem.
• A control strategy that specifies the order in which the rules will be compared to the database
and a way of resolving the conflicts that arise when several rules match at once.
• A rule applierwhich checks the capability of rule by matching the content state with the left-
handside of the rule and finds the appropriate rule from database of rules.
Ans:
In this algorithm, it holds k number of states at any given time. At the start, these states are generated
randomly. The successors of these k states are computed with the help of objective function. If any of
these successors is the maximum value of the objective function, then the algorithm stops.
Otherwise the (initial k states and k number of successors of the states = 2k) states are placed in
a pool. The pool is then sorted numerically. The highest k states are selected as new initial states. This
process continues until a maximum value is reached.[2M]
loop
end [3M]
Ans:
Constraint satisfaction problem (or CSP) is defined by a set of vari- CONSTRAINT SATISFACTION
PROBLEM VARIABLES, X1, X2, . . . , Xn, and a set of constraints, C1, C2, . . . , Cm. Each variable
Xi has a CONSTRAINTS nonempty domain Di of possible values. Each constraint C i involves some
subset of the DOMAIN VALUES variables and specifies the allowable combinations of values for that
subset. A state of the problem is defined by an assignment of values to some or all of the variables, {X i
= vi , Xj = ASSIGNMENT vj , . . .}. An assignment that does not violate any constraints is called a
consistent or legal CONSISTENT assignment. A complete assignment is one in which every variable is
mentioned, and a solution to a CSP is a complete assignment that satisfies all the constraints. Some
CSPs also require a solution that maximizes an objective function.[2M]
So what does all this mean? Suppose that, having tired of Romania, we are looking at a map of
Australia showing each of its states and territories, as in Figure 5.1(a), and that we are given the task of
coloring each region red, green, or blue in such a way that no neighboring regions have the same color.
To formulate this as a CSP, we define the variables to be the regions: WA, NT, Q, NSW , V , SA, and
T. The domain of each variable is the set {red, green, blue}. The constraints require neighboring
regions to have distinct colors; for example, the allowable combinations for WA and NT are the pairs
{(red, green),(red, blue),(green, red),(green, blue),(blue, red),(blue, green)} . (The constraint can also be
represented more succinctly as the inequality WA 6= NT, provided the constraint satisfaction algorithm
has some way to evaluate such expressions.) There are many possible solutions, such as {WA = red,
NT = green, Q = red, NSW = green, V = red, SA = blue, T = red }. CONSTRAINT GRAPH It is
helpful to visualize a CSP as a constraint graph, as shown in Figure.
The nodes of the graph correspond to variables of the problem and the arcs correspond to constraints.
Treating a problem as a CSP confers several important benefits. Because the representation of states in
a CSP conforms to a standard pattern—that is, a set of variables with assigned values—the successor
function and goal test can written in a generic way that applies to all CSPs. Furthermore, we can
develop effective, generic heuristics that require no additional, domain-specific expertise. Finally, the
structure of the constraint graph can be used to simplify the solution process, in some cases giving an
exponential reduction in complexity.
Final solution:
9. Water-Jug Problem
Water Jug Problem:
Example: You are given two jugs, a 4-gallon one and a 3-gallon one. Neither has any measuring mark
on it. There is a pump that can be used to fill the jugs with water. How can you get exactly 2 gallons of
water into the 4-gallon jug?
Solution:
The state space for this problem can be described as the set of ordered pairs of integers (x,y)
Where,
X represents the quantity of water in the 4-gallon jug X= 0,1,2,3,4
Y represents the quantity of water in 3-gallon jug Y=0,1,2,3
Start State: (0,0)
Goal State: (2,0)
Generate production rules for the water jug problem
Production Rules: 3MARKS
Initialization: 4Marks
Start State: (0,0)
Apply Rule 2:
(X,Y | Y<3) -> (X,3)
{Fill 3-gallon jug}
Now the state is (X,3)
Iteration 1:
Current State: (X,3)
Apply Rule 7:
(X,Y | X+Y<=4 (X+Y,0)
^Y>0) {Pour all water from 3-gallon jug into 4-gallon jug}
Now the state is (3,0)
Iteration 2:
Current State : (3,0)
Apply Rule 2:
(X,Y | Y<3) -> (3,3)
{Fill 3-gallon jug}
Now the state is (3,3)
Iteration 3:
Current State:(3,3)
Apply Rule 5:
(X,Y | X+Y>=4 ^ (4,Y-(4-X))
Y>0) {Pour water from 3-gallon jug into 4-gallon jug until 4-
gallon jug is full}
Now the state is (4,2)
Iteration 4:
Current State : (4,2)
Apply Rule 3:
(X,Y | X>0) (0,Y)
{Empty 4-gallon jug}
Now state is (0,2)
Iteration 5:
Current State : (0,2)
Apply Rule 9:
(0,2) (2,0)
{Pour 2 gallon water from 3 gallon jug into 4 gallon
jug}
Now the state is (2,0)
Goal Achieved.
10. Discuss the role of Agents, and the Environment in which they operate?
Diagram:
5
An agent is anything that can be viewed as perceiving its environment through sensors and
acting upon that environment through actuators. A human agent has eyes, ears, and other
organs for sensors and hands, legs, vocal tract, and so on for actuators. A robotic agent might
have cameras and infrared range finders for sensors and various motors for actuators.( 1M)
An agent's percept sequence is the complete history of everything the agent has ever
perceived. In general, an agent's choice of action at any given instant can depend on the
entire percept sequence observed to date, but not on anything it hasn't perceived.(1M)
An agent action always depends on the environment. There is to say about the agent.
Mathematically speaking, we say that an agent's behavior is described by the agent function
that maps any given percept sequence to an action.(1M)
A rational agent is one that does the right thing—conceptually speaking, every entry in the
table for the agent function is filled out correctly. Obviously, doing the right thing is better
than doing the wrong thing.(1M)
A robotic agent might have cameras and infrared range finders for sensors and various motors
for actuators. A software agent receives keystrokes, file contents, and network packets as
sensory inputs and acts on the environment by displaying on the screen, writing files, and
sending network packets (1M)
The agent function for an artificial agent will be implemented by an agent program. It is
important to keep these two ideas distinct. The agent function is an abstract mathematical
description. Agent program is a concrete implementation, running within some physical
system. (1M)
11. Consider the following game tree in which the static scores (at the tip nodes) are all from the first
player’s point of view. Assume that the first player is the maximizing player (i.e. MAX), and that high
numbers represent better scores for MAX
11 A) Use Mini-max algorithm to determine which move the first player should choose.
The mininiax algorithm is designed to determine the optimal strategy for MAX, and thus to decide what
the best first move is. The algorithm consists of five steps: 2M
• Generate the whole game tree, all the way down to the terminal states.
• Apply the utility function to each terminal state to get its value.
• Use the utility of the terminal states to determine the utility of the nodes one level higher
• Continue backing up the values from the leaf nodes toward the root, one layer at a time.
• Eventually, the backed-up values reach the top of the tree; at that point, MAX chooses the move that
leads to the highest value.
A two-ply game tree as generated by the minimax algorithm. The A nodes arsmoves by MAX and the
V nodes UK moves by MIN. The terminal nodes show the utility value forMAX computed by the utility
function (i.e., by the rules of the game), whereas the utilities of theother nodes are computed by the
minimax algorithm from the utilities of their successors. MAX'Sbest move is A\, andMlN's best reply
is A\\.Minimax maximizes the utility for the worst-case outcome for max.
11 B) Examine the nodes not needed to be pruned using the alpha-beta pruning algorithm assuming that
nodes are examined in left-to-right order?
Procedure: 2M
It is possible to compute the correct minimax decision without looking at every node in the search tree. The
process of eliminating a branch of the search tree from consideration without examining it is called pruning
the search tree. The particular technique we will examine is called alpha-beta pruning. When applied to a
standard minimax tree, it returns the same move as minimax would, but prunes away branches that cannot
possibly influence the final decision.
Explanation: 2.5M
Consider a node n somewhere in the tree, such that Player has a choice of moving to that node. If Player has a
better choice m either at the parent node of n, or at any choice point further up, then n will never be reached
in actual play. So once we have found out enough about n (by examining some of its descendants) to reach
this conclusion, we can prune it
12. Define the terminology used in Genetic Algorithms. Illustrate Genetic algorithm with an Example.
A genetic algorithm is a search heuristic that reflects the process of natural selection where
the fittest individuals are selected for reproduction in order to produce offspring of the next
generation. In this algorithm, successor states are generated by combining two parent states
rather than by modifying a single state.
2. Fitness function
3. Selection
4. Crossover
5. Mutation
Initial population
The process begins with a set of individuals which is called a Population. An individual is
characterized by a set of parameters (variables) known as Genes. Genes are joined into a string to
form a Chromosome (solution).
Fitness function
The fitness function determines how fit an individual is (The ability of an individual to compete
with other individuals). It gives a fitness score to each individual. The probability that an
individual will be selected for reproduction is based on its fitness score. We can consider
Hamming distance as fitness function for N-puzzle game.
Selection
The idea of selection phase is to select the fittest individuals and let them pass their genes to the next
generation. Two pairs of individuals (parents) are selected based on their fitness scores. Individuals
with high fitness have more chance to be selected.
For each pair of parents, a crossover point is chosen at random from within the genes.
Mutation
In certain new offspring formed, some of their genes can be subjected to a mutation with a low
random probability. This implies that some of the bits in the bit string can be flipped. Mutation
occurs to maintain diversity within the population and prevent premature convergence.
Termination
The algorithm terminates if the population has converged (does not produce offspring which
are significantly different from the previous generation). Then it is said that the genetic
algorithm has provided a set of solutions to our problem.
EXAMPLE
An 8-queens state must specify the positions of 8 queens, each in a column of 8 squares. The
state could be represented as 8 digits, each in the range from 1 to 8.