0% found this document useful (0 votes)
11 views

IS&MLA_Module 2

The document outlines the syllabus and key concepts for the Intelligent Systems and Machine Learning Algorithms course, focusing on problem-solving agents and search strategies. It describes the formulation of problems, the components of problem-solving, and provides examples of toy and real-world problems, including the 8-puzzle and traveling salesperson problem. Additionally, it introduces the concept of searching for solutions through action sequences and search trees.

Uploaded by

deekshakn9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

IS&MLA_Module 2

The document outlines the syllabus and key concepts for the Intelligent Systems and Machine Learning Algorithms course, focusing on problem-solving agents and search strategies. It describes the formulation of problems, the components of problem-solving, and provides examples of toy and real-world problems, including the 8-puzzle and traveling salesperson problem. Additionally, it introduces the concept of searching for solutions through action sequences and search trees.

Uploaded by

deekshakn9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

S.D.M.

Jainmatt Trust®
A.G.M RURAL COLLEGEOFENGINEERINGANDTECHNOLOGY, VARUR,
HUBLI
DEPARTMENTOFELECTRONICS AND COMMUNICATION ENGINEERING

NOTES

Subject with code: Intelligent Systems and Machine Learning Algorithms (BEC515A)

Module 2

Prepared By

Prof. ASIF IQBAL MULLA


Department of Electronics and Communication

Syllabus :

Problem- solving: Problem- solving agents, Example problems, Searching for Solutions
Uninformed Search Strategies: Breadth First search, Depth First Search, Iterative
deepening depth first search;

Text book 1: Chapter 3- 3.1, 3.2, 3.3, 3.4

Text Book 1 :

1. Stuart J. Russell and Peter Norvig , Artificial Intelligence, 3rd Edition, Pearson,2015
Intelligent Systems and Machine Learning Algorithms (BEC515A)

A. PROBLEM SOLVING

1. PROBLEM-SOLVING AGENTS

Intelligent agents are supposed to maximize their performance measure. Achieving this is
sometimes simplified if the agent can adopt a goal and aim at satisfying it. Let us first look at
why and how an agent might do this.
Imagine an agent in the city of Arad, Romania, enjoying a touring holiday. It wants to
improve its suntan, improve its Romanian, take in the sights, enjoy the nightlife (such as it is),
avoid hangovers, and so on. Now, suppose the agent has a nonrefundable ticket to fly out of
Bucharest the following day. In that case, it makes sense for the agent to adopt the goal of
getting to Bucharest. Goal formulation, based on the current situation and the agent’s
performance measure, is the first step in problem solving.
Problem formulation is the process of deciding what actions and states to consider,
given a goal. Let us assume that the agent will consider actions at the level of driving from one
major town to another. Our agent has now adopted the goal of driving to Bucharest and is
considering where to go from Arad. Three roads lead out of Arad, one toward Sibiu, one to
Timisoara, and one to Zerind. None of these achieves the goal, so unless the agent is familiar
with the geography of Romania. But suppose the agent has a map of Romania. The point of a
map is to provide the agent with information about the states.
The agent can use this information to consider subsequent stages of a hypothetical
journey via each of the three towns, trying to find a journey that eventually gets to Bucharest.
Once it has found a path on the map from Arad to Bucharest, it can achieve its goal by carrying
out the driving actions that correspond to the legs of the journey. In general, an agent with
several immediate options of unknown value can decide what to do by first examining future
actions that eventually lead to states of known value.
For now, we assume that the environment is observable, discrete and deterministic.
Under these assumptions, the solution to any problem is a fixed sequence of actions.

 The process of looking for a sequence of actions that reaches the goal is called search.
 A search algorithm takes a problem as input and returns a solution in the form of an
action sequence.
 Once a solution is found, the actions it recommends can be carried out.
 This is called the execution phase.
 Thus, we have a simple “formulate, search, execute” design for the agent, as shown in
Figure 3.1.
 After formulating a goal and a problem to solve,

The agent calls a search procedure to solve it. It then uses the solution to guide its actions,
doing whatever the solution recommends as the next thing to do—typically, the first action of the
sequence—and then removing that step from the sequence. Once the solution has been executed,
the agent will formulate a new goal.

Prof. Asif Iqbal M, Dept of ECE 2


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Well-defined problems and solutions

A problem can be defined formally by five components:

1.The initial state that the agent starts in. For example, the initial state for our agent in Romania
might be described as In(Arad).

2.A description of the possible actions available to the agent. Given a particular state s,
ACTIONS(s) returns the set of actions that can be executed in s. We say that each of these
actions is applicable in s. For example, from the state In(Arad), the applicable actions are
{Go(Sibiu), Go(Timisoara), Go(Zerind)}.

3.A description of what each action does; the formal name for this is the transition model,
specified by a function RESULT(s, a) that returns the state that results from doing action a in
state s. For example, we have.
RESULT(In(Arad),Go(Zerind)) = In(Zerind) .

4.The goal test, which determines whether a given state is a goal state. Sometimes there is an
explicit set of possible goal states, and the test simply checks whether the given state is one of
them. The agent’s goal in Romania is the singleton set {In(Bucharest )}.

5.A path cost function that assigns a numeric cost to each path. The problem solving agent
chooses a cost function that reflects its own performance measure. For the agent trying to get to
Bucharest, it is length in kilometers. The cost of a path can be described as the sum of the costs
of the individual actions along the path.

Prof. Asif Iqbal M, Dept of ECE 3


Intelligent Systems and Machine Learning Algorithms (BEC515A)

The step cost of taking action a in state s to reach state s` is denoted by c(s, a, s`). The step costs
for Romania are shown in Figure 3.2 as route distances. We assume that step costs are
nonnegative.

2. EXAMPLE PROBLEMS

The problem-solving approach has been applied to a vast array of task environments. We list
some of the best known here, distinguishing between toy and real-world problems.

A toy problem is intended to illustrate or exercise various problem-solving methods. It can be


given a concise, exact description and hence is usable by different researchers to compare the
performance of algorithms.
A real-world problem is one whose solutions people actually care about. Such problems tend
not to have a single agreed-upon description, but we can give the general flavor of their
formulations.

TOY PROBLEMS

vacuum world

This can be formulated as a problem as follows:

States: The state is determined by both the agent location and the dirt locations. The agent is in
one of two locations, each of which might or might not contain dirt. Thus, there are 2 × 22 = 8
possible world states. A larger environment with n locations has n2n states.

Prof. Asif Iqbal M, Dept of ECE 4


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Initial state: Any state can be designated as the initial state.


Actions: In this simple environment, each state has just three actions: Left, Right, and Suck.
Larger environments might also include Up and Down.
Transition model: The actions have their expected effects, except that moving Left in the
leftmost square, moving Right in the rightmost square, and Sucking in a clean square have no
effect. The complete state space is shown in Figure 3.3.
Goal test: This checks whether all the squares are clean.
Path cost: Each step costs 1, so the path cost is the number of steps in the path.

The 8-puzzle

The 8-puzzle, an instance of which is shown in Figure 3.4, consists of a 3×3 board with eight
numbered tiles and a blank space. A tile adjacent to the blank space can slide into the space. The
object is to reach a specified goal state, such as the one shown on the right of the figure. The
standard formulation is as follows:

Prof. Asif Iqbal M, Dept of ECE 5


Intelligent Systems and Machine Learning Algorithms (BEC515A)

States: A state description specifies the location of each of the eight tiles and the blank in
one of the nine squares.
Initial state: Any state can be designated as the initial state. Note that any given goal can be
reached from exactly half of the possible initial states (Exercise 3.4).
Actions: The simplest formulation defines the actions as movements of the blank space Left,
Right, Up, or Down.
Transition model: Given a state and action, this returns the resulting state; for example, if
we apply Left to the start state in Figure 3.4, the resulting state has the 5 and the blank
switched.
Goal test: This checks whether the state matches the goal configuration shown in Figure 3.4.
(Other goal configurations are possible.)
Path cost: Each step costs 1, so the path cost is the number of steps in the path.

The 8-queens problem

The goal of the 8-queens problem is to place eight queens on a chessboard such that no queen
attacks any other. (A queen attacks any piece in the same row, column or diagonal.) Figure 3.5
shows an attempted solution that fails: the queen in the rightmost column is attacked by the
queen at the top left.

Prof. Asif Iqbal M, Dept of ECE 6


Intelligent Systems and Machine Learning Algorithms (BEC515A)

A complete-state formulation starts with all 8 queens on the board and moves them around. In
either case, the path cost is of no interest because only the final state counts. The first
incremental formulation one might try is the following:

States: Any arrangement of 0 to 8 queens on the board is a state.


Initial state: No queens on the board.
Actions: Add a queen to any empty square.
Transition model: Returns the board with a queen added to the specified square.
Goal test: 8 queens are on the board, none attacked.

In this formulation, we have 1.8×1014 possible sequences to investigate. A better formulation


would prohibit placing a queen in any square that is already attacked:
• States: All possible arrangements of n queens (0 ≤ n ≤ 8), one per column in the leftmost n
columns, with no queen attacking another.
• Actions: Add a queen to any square in the leftmost empty column such that it is not attacked by
any other queen.

This formulation reduces the 8-queens state space from 1.8×1014 to just 2,057, and solutions are
easy to find.

Donald knuth’s factorial square root

Our final toy problem was devised by Donald Knuth (1964) and illustrates how infinite state
spaces can arise. Knuth conjectured that, starting with the number 4, a sequence of factorial,
square root, and floor operations will reach any desired positive integer. For example, we can
reach 5 from 4 as follows:

Prof. Asif Iqbal M, Dept of ECE 7


Intelligent Systems and Machine Learning Algorithms (BEC515A)

The problem definition is very simple:


• States: Positive numbers.
• Initial state: 4.
• Actions: Apply factorial, square root, or floor operation (factorial for integers only).
• Transition model: As given by the mathematical definitions of the operations.
• Goal test: State is the desired positive integer.

REAL-WORLD PROBLEMS

We have already seen how the route-finding problem is defined in terms of specified locations
and transitions along links between them. Route-finding algorithms are used in a variety of
applications.

The airline travel problems

The airline travel problems that must be solved by a travel-planning Web site:
• States: Each state obviously includes a location (e.g., an airport) and the current time.
Furthermore, because the cost of an action (a flight segment) may depend on previous segments,
their fare bases, and their status as domestic or international, the state must record extra
information about these “historical” aspects.
• Initial state: This is specified by the user’s query.
• Actions: Take any flight from the current location, in any seat class, leaving after the current
time, leaving enough time for within-airport transfer if needed.
• Transition model: The state resulting from taking a flight will have the flight’s destination as
the current location and the flight’s arrival time as the current time.
• Goal test: Are we at the final destination specified by the user?
• Path cost: This depends on monetary cost, waiting time, flight time, customs and immigration
procedures, seat quality, time of day, type of airplane, frequent-flyer mileage
awards, and so on.

Touring problems

Touring problems are closely related to route-finding problems, but with an important
difference. Consider, for example, the problem “Visit every city in Figure 3.2 at least once,
starting and ending in Bucharest.” As with route finding, the actions correspond to trips between
adjacent cities. The state space, however, is quite different. Each state must include not just the
current location but also the set of cities the agent has visited. So the initial state would be
In(Bucharest ), Visited({Bucharest}), a typical intermediate state would be In(Vaslui ),
Visited({Bucharest , Urziceni , Vaslui}), and the goal test would check whether the agent is in
Bucharest and all 20 cities have been visited.

Prof. Asif Iqbal M, Dept of ECE 8


Intelligent Systems and Machine Learning Algorithms (BEC515A)

The traveling salesperson problem (TSP)

The traveling salesperson problem (TSP) is a touring problem in which each city must be
visited exactly once. The aim is to find the shortest tour. The problem is known to be NP-hard,
but an enormous amount of effort has been expended to improve the capabilities of TSP
algorithms. In addition to planning trips for traveling salespersons, these algorithms have been
used for tasks such as planning movements of automatic circuit-board drills and of stocking
machines on shop floors.

VLSI layout

VLSI LAYOUT A VLSI layout problem requires positioning millions of components and
connections on a chip to minimize area, minimize circuit delays, minimize stray capacitances,
and maximize manufacturing yield. The layout problem comes after the logical design phase and
is usually split into two parts: cell layout and channel routing. In cell layout, the primitive
components of the circuit are grouped into cells, each of which performs some recognized
function. Each cell has a fixed footprint (size and shape) and requires a certain number of
connections to each of the other cells. The aim is to place the cells on the chip so that they do not
overlap and so that there is room for the connecting wires to be placed between the cells.
Channel routing finds a specific route for each wire through the gaps between the cells.

Prof. Asif Iqbal M, Dept of ECE 9


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Robot navigation

ROBOT NAVIGATION Robot navigation is a generalization of the route-finding problem


described earlier. Rather than following a discrete set of routes, a robot can move in a continuous
space with (in principle) an infinite set of possible actions and states. For a circular robot moving
on a flat surface, the space is essentially two-dimensional. When the robot has arms and legs or
wheels that must also be controlled, the search space becomes many-dimensional. Advanced
techniques are required just to make the search space finite.

Automatic assembly sequencing

Automatic assembly sequencing of complex objects by a robot was first demonstrated by


FREDDY (Michie, 1972). In assembly problems, the aim is to find an order in which to
assemble the parts of some object. If the wrong order is chosen, there will be no way to add some
part later in the sequence without undoing some of the work already done. Checking a step in the
sequence for feasibility is a difficult geometrical search problem closely related to robot
navigation.

Another important assembly problem is protein design, in which the goal is to find a sequence
of amino acids that will fold into a three-dimensional protein with the right properties to cure
some disease.

3. SEARCHING FOR SOLUTIONS

Having formulated some problems, we now need to solve them. A solution is an action sequence,
so search algorithms work by considering various possible action sequences. The possible action
sequences starting at the initial state form a search tree with the initial state at the root; the
branches are actions and the nodes correspond to states in the state space of the problem.

Figure 3.6 shows the first few steps in growing the search tree for finding a route from
Arad to Bucharest. The root node of the tree corresponds to the initial state, In(Arad). The first
step is to test whether this is a goal state. Then we need to consider taking various actions. We
do this by expanding the current state; that is, applying each legal action to the current state,
thereby generating a new set of states. In this case, we add three branches from the parent
node In(Arad) leading to three new child nodes: In(Sibiu), In(Timisoara), and In(Zerind). Now
we must choose which of these three possibilities to consider further.
Suppose we choose Sibiu first. We check to see whether it is a goal state (it is not) and
then expand it to get In(Arad), In(Fagaras), In(Oradea), and In(RimnicuVilcea). We can then
choose any of these four or go\ back and choose Timisoara or Zerind. Each of these six nodes is
a leaf node, that is, a node with no children in the tree. The set of all leaf nodes available for
expansion at any given point is called the frontier. In Figure 3.6, the frontier of each tree
consists of those nodes with bold outlines. The process of expanding nodes on the frontier
continues until either a solution is found or there are no more states to expand. The general
algorithm is shown informally in Figure 3.7.

Prof. Asif Iqbal M, Dept of ECE 10


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Loopy paths are a special case of the more general concept of redundant paths, which
exist whenever there is more than one way to get from one state to another. Consider the paths
Arad–Sibiu (140 km long) and Arad–Zerind–Oradea–Sibiu (297 km long). Obviously, the
second path is redundant—it’s just a worse way to get to the same state.
The way to avoid exploring redundant paths is to remember where one has been. To do
this, we augment the TREE-SEARCH algorithm with a data structure called the explored set
(also CLOSED LIST known as the closed list), which remembers every expanded node. Newly
generated nodes that match previously generated nodes—ones in the explored set or the
frontier—can be discarded instead of being added to the frontier. The new algorithm, called
GRAPH-SEARCH, is shown informally in Figure 3.7.

Prof. Asif Iqbal M, Dept of ECE 11


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Clearly, the search tree constructed by the GRAPH-SEARCH algorithm contains at most
one copy of each state, so we can think of it as growing a tree directly on the state-space graph,
SEPARATOR as shown in Figure 3.8. The algorithm has another nice property: the frontier
separates the state-space graph into the explored region and the unexplored region, so that every
path from the initial state to an unexplored state has to pass through a state in the frontier. This
property is illustrated in Figure 3.9. As every step moves a state from the frontier into the
explored region while moving some states from the unexplored region into the frontier, we see
that the algorithm is systematically examining the states in the state space, one by one, until it
finds a solution.

Prof. Asif Iqbal M, Dept of ECE 12


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Infrastructure for search algorithms

Prof. Asif Iqbal M, Dept of ECE 13


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Measuring problem-solving performance

Time and space complexity are always considered with respect to some measure of the
problem difficulty. In theoretical computer science, the typical measure is the size of the state
space graph, |V | + |E|, where V is the set of vertices (nodes) of the graph and E is the set of
edges (links).

Prof. Asif Iqbal M, Dept of ECE 14


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Time is often measured in terms of the number of nodes generated during the search, and
space in terms of the maximum number of nodes stored in memory.

B. UNINFORMED SEARCH STRATEGIES

This section covers several search strategies that come under the heading of uninformed
search (also called blind search). The term means that the strategies have no additional
information about states beyond that provided in the problem definition. All they can do is
generate successors and distinguish a goal state from a non-goal state.

1. Breadth-first search

Breadth-first search is an instance of the general graph-search algorithm (Figure 3.7) in


which the shallowest unexpanded node is chosen for expansion. This is achieved very simply by
using a FIFO queue for the frontier. Thus, new nodes (which are always deeper than their
parents) go to the back of the queue, and old nodes, which are shallower than the new nodes, get
expanded first. There is one slight tweak on the general graph-search algorithm, which is that the
goal test is applied to each node when it is generated rather than when it is selected for
expansion. Now, the shallowest goal node is not necessarily the optimal one; technically,
breadth-first search is optimal if the path cost is a non decreasing function of the depth of the
node.

Pseudocode is given in Figure 3.11. Figure 3.12 shows the progress of the search on a simple
binary tree.

The time complexity would be Obd+1 and space complexity is Obd of DFS.
Two lessons can be learned from Figure 3.13. First, the memory requirements are a bigger
problem for breadth-first search than is the execution time. The second lesson time is still a major
factor.

Prof. Asif Iqbal M, Dept of ECE 15


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Uniform-cost search

Prof. Asif Iqbal M, Dept of ECE 16


Intelligent Systems and Machine Learning Algorithms (BEC515A)

When all step costs are equal, breadth-first search is optimal because it always expands
the shallowest unexpanded node. By a simple extension, we can find an algorithm that is optimal
with any step-cost function. Instead of expanding the shallowest node, expands the node n with
the lowest path cost g(n). This is done by storing the frontier as a priority queue ordered by g.
The algorithm is shown in Figure 3.14.
In addition to the ordering of the queue by path cost, there are two other significant
differences from breadth-first search. The first is that the goal test is applied to a node when it is
selected for expansion (as in the generic graph-search algorithm shown in Figure 3.7) rather than
when it is first generated. The reason is that the first goal node that is generated may be on a
suboptimal path. The second difference is that a test is added in case a better
path is found to a node currently on the frontier.
Both of these modifications come into play in the example shown in Figure 3.15, where
the problem is to get from Sibiu to Bucharest. The successors of Sibiu are Rimnicu Vilcea and
Fagaras, with costs 80 and 99, respectively. The least-cost node, Rimnicu Vilcea, is expanded
next, adding Pitesti with cost 80 + 97=177. The least-cost node is now Fagaras, so it is expanded,
adding Bucharest with cost 99+211=310. Now a goal node has been generated, but uniform-cost
search keeps going, choosing Pitesti for expansion and adding a second path to Bucharest with
cost 80+97+101= 278. Now the algorithm checks to see if this new path is better than the old
one; it is, so the old one is discarded. Bucharest, now with g-cost 278, is selected for expansion
and the solution is returned.

Prof. Asif Iqbal M, Dept of ECE 17


Intelligent Systems and Machine Learning Algorithms (BEC515A)

2. Depth-first search

In Figure 3.16, depth first search will explore the entire left subtree even if node C is a
goal node. If node J were also a goal node, then depth-first search would return it as a solution
instead of C, which would be a better solution; hence, depth-first search is not optimal.
The time complexity of depth-first graph search is bounded by the size of the state space
(which may be infinite, of course). A depth-first tree search, on the other hand, may generate all
of the O(bm) nodes in the search tree, where m is the maximum depth of any node; this can be
much greater than the size of the state space. Note that m itself can be much larger than d (the
depth of the shallowest solution) and is infinite if the tree is unbounded. So far, depth-first search
seems to have no clear advantage over breadth-first search, so why do we include it? The reason
is the space complexity. For a graph search, there is no advantage, but a depth-first tree search
needs to store only a single path from the root to a leaf node, along with the remaining
unexpanded sibling nodes for each node on the path.

Prof. Asif Iqbal M, Dept of ECE 18


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Depth-limited search

Prof. Asif Iqbal M, Dept of ECE 19


Intelligent Systems and Machine Learning Algorithms (BEC515A)

3. Iterative deepening depth-first search

Prof. Asif Iqbal M, Dept of ECE 20


Intelligent Systems and Machine Learning Algorithms (BEC515A)

Iterative deepening search may seem wasteful because states are generated multiple times. It
turns out this is not too costly.

Prof. Asif Iqbal M, Dept of ECE 21

You might also like