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

Module-1 AIML

Artificial intelligence (AI) refers to simulating human intelligence through machine processes like thinking and acting. The key aspects of AI systems include: 1. Perception - AI systems experience the world through sensors like cameras to gather input data. 2. Reasoning - AI reasons and makes inferences about the input data using techniques like neural networks, logical rules, or machine learning algorithms. 3. Action - AI can take actions in the real world like controlling vehicles or making medical diagnoses based on its reasoning. The goal of AI is to build machines that can think and act intelligently, learn from experience, and solve complex problems. AI has applications in many fields like business, engineering, manufacturing,
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Module-1 AIML

Artificial intelligence (AI) refers to simulating human intelligence through machine processes like thinking and acting. The key aspects of AI systems include: 1. Perception - AI systems experience the world through sensors like cameras to gather input data. 2. Reasoning - AI reasons and makes inferences about the input data using techniques like neural networks, logical rules, or machine learning algorithms. 3. Action - AI can take actions in the real world like controlling vehicles or making medical diagnoses based on its reasoning. The goal of AI is to build machines that can think and act intelligently, learn from experience, and solve complex problems. AI has applications in many fields like business, engineering, manufacturing,
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Artificial Intelligence Artificial Intelligence

Artificial Intelligence world through their sensors (senses). For an autonomous vehicle, input might be images
1.Introduction: from a camera and range information from a rangefinder. For a medical diagnosis
system,perception is the set of symptoms and test results that have been obtained and input
Artificial intelligence or AI refers to the simulation of human intelligence in machines that are
to thes ystem manually.
programmed to think and act like humans.. The term was coined by John McCarthy in 1956.
AI is the ability to acquire, understand and apply the knowledge to achieve goals in the 2) Reasoning

world. Inference, decision-making, classification from what is sensed and what the internal "model" is of

➢ AI is unique, sharing borders with Mathematics, Computer Science, the world. Might be a neural network, logical deduction system, Hidden Markov Model

Philosophy, Psychology, Biology, Cognitive Science and many induction,heuristic searching a problem space, Bayes Network inference, genetic algorithms, etc.

others. Includes areas of knowledge representation, problem solving, decision theory, planning, game

➢ Although there is no clear definition of AI or even Intelligence, it can be described as an theory, machine learning, uncertainty reasoning, etc.

attempt to build machines that like humans can think and act, able to learn and use 3)Action

knowledge to solve problems on their own. Biological systems interact within their environment by actuation, speech, etc. All behavior is centered

1.1.2 Applications of AI: around actions in the world. Examples include controlling the steering of a Mars rover or autonomous
vehicle, or suggesting tests and making diagnoses for a medical diagnosis system. Includes areas of robot
AI algorithms have attracted close attention of researchers and have also been applied
actuation, natural language generation, and speech synthesis.
successfully to solve problems in engineering. Nevertheless, for large and complex problems,
1.1.4 The definitions of AI:
AIalgorithms consume considerable computation time due to stochastic feature of the search
approaches
a) "The exciting new effort to make b) "The study of mental faculties

1. Business; financial strategies computers think . . . machines with through the use of computational

2. Engineering: check design, offer suggestions to create new product, expert systems for minds,in the full and literal sense" models" (Charniak and McDermott,

all engineering problems


3. Manufacturing: assembly, inspection and maintenance "The automation of] activities that we "The study of the computations
4. Medicine: monitoring, diagnosing
associate with human thinking, activities
that make it possible to perceive,
5. Education: in teaching
such as decision-making, problem solving,
6. Fraud detection reason,and act" (Winston, 1992)

7. Object identification
8. Information retrieval
9. Space shuttle scheduling
1.1.3 Building AI Systems:
1) Perception
Intelligent biological systems are physically embodied in the world and experience the

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

c) "The art of creating machines that d) "A field of study that seeks to explain
and emulate intelligent behavior in Cognitive Science: Think Human-Like
perform functions that require
terms of computational processes"
intelligence when performed by people" a. Requires a model for human cognition. Precise enough models
(Schalkoff, 1 990) allow simulation by computers.
(Kurzweil, 1990)
"The branch of computer science b. Focus is not just on behavior and I/O, but looks like reasoning process.
"The study of how to make
that is concerned with the
c. Goal is not just to produce human-like behavior but to produce a sequence of steps of
Computers do things at which, at
automation of intelligent the reasoning process, similar to the steps followed by a human in solving the same task.
themoment, people are better"
behavior"
(Rich and Knight, 1 Laws of thought: Think Rationally
(Luger and Stubblefield, 1993)
99 1 ) a. The study of mental faculties through the use of computational models; that it is,
the study of computations that make it possible to perceive reason and act.
The definitions on the top, (a) and (b) are concerned with reasoning, whereas those on the
bottom, (c) and (d) address behavior. The definitions on the left, (a) and (c) measure success b. Focus is on inference mechanisms that are probably correct and guarantee an optimal solution.

interms of human performance, and those on the right, (b) and (d) measure the ideal concept of
c. Goal is to formalize the reasoning process as a system of logical rules and procedures
intelligence called rationality of inference.
1.1.5 Intelligent Systems:
d. Develop systems of representation to allow inferences to be like
In order to design intelligent systems, it is important to categorize them into four
“Socrates is a man. All men are mortal. Therefore Socrates is mortal”
categories(Luger and Stubberfield 1993), (Russell and Norvig, 2003)
Turing Test: Act Human-Like
1. Systems that think like humans
2. Systems that think rationally
a. The art of creating machines that perform functions requiring intelligence when performed
3. Systems that behave like humans by people; that it is the study of, how to make computers do things which, at the moment,
4. Systems that behave rationally people do better.

Human Rational b. Focus is on action, and not intelligent behavior centered around the representation of the world
- Like ly
c. Example: Turing Test
Cognitive Science Approach Laws of thought Approach
Think:
“Machines that think like humans” “ Machines that think Rationally” o 3 rooms contain: a person, a computer and an interrogator.

o The interrogator can communicate with the other 2 by teletype (to


avoid the machine imitate the appearance of voice of the person)
Turing Test Approach Rational Agent Approach
Act:
“Machines that behave like humans” “Machines that behave Rationally” o The interrogator tries to determine which the person is and which
the machine is.
o The machine tries to fool the interrogator to believe that it is the
human, and the person also tries to convince the interrogator that it is
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

the human. • How should we do this when the payoff may be far in the future?
1.2.4 Neuroscience
o If the machine succeeds in fooling the interrogator, then conclude that
the machine is intelligent. • How do brains process information?

Rational agent: Act Rationally NEUROSCIENCE


Neuroscience is the study of the nervous system, particularly the brain. Although the exact way in which the
a. Tries to explain and emulate intelligent behavior in terms of computational process; brain enables thought is one of the great mysteries of science, the fact that it does enable thought has been
that it is concerned with the automation of the intelligence.
appreciated for thousands of years because of the evidence that strong blows to the head can lead to mental
b. Focus is on systems that act sufficiently if not optimally in all situations.

c. Goal is to develop systems that are rational and sufficient

1.2 The Foundations of Artificial Intelligence


1.2.1 Philosophy
• Can formal rules be used to draw valid conclusions?
• How does the mind arise from a physical brain?
• Where does knowledge come from? • How does knowledge lead to action?
i) Dualism
ii)rationalism
iii)materialism
iv)emperism in capacitation.

v)induction 1.2.5 Psychology

1.2.2 Mathematics • How do humans and animals think and act?

• What are the formal rules to draw valid conclusions? Cognitive psychology, which views the brain as an information-processing device, COGNITIVE

• What can be computed? PSYCHOLOGY an be traced back at least to the works of William James (1842–1910). Helmholtz also

• How do we reason with uncertain information? insisted that perception involved a form of unconscious logical inference.

i)Algorithm
ii)Incompleteness 1.2.6 Computer engineering

iii)Traceability • How can we build an efficient computer?

1.2.3 Economics For artificial intelligence to succeed, we need two things: intelligence and an artifact. The computer has been

• How should we make decisions so as to maximize payoff? the artifact of choice. The modern digital electronic computer was invented independently and almost

• How should we do this when others may not go along? simultaneously

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

by scientists in three countries embattled in world war II. From the beginning, AI researchers were not shy about making predictions of their coming successes. The
1.2.7 Control theory and cybernetics following statement by Herbert Simon in 1957 is often quoted:Terms such as “visible future” can be interpreted
• How can artifacts operate under their own control? in various ways, but Simon also made more concrete predictions: that within 10 years a computer would be
Modern control theory, especially the branch known as stochastic optimal control, has as its goal the design of chess champion, and a significant mathematical theorem would be proved by machine
systemsthat maximize an objective function over time. 1.3.5 Knowledge-based systems: The key to power? (1969–1979)
1.2.8 Linguistics The picture of problem solving that had arisen during the first decade of AI research was of a general-purpose
• How does language relate to thought? In 1957, B. F. Skinner published Verbal Behavior. This was a search mechanism trying to string together elementary reasoning steps to WEAK METHOD find complete
comprehensive, solutions. Such approaches have been called weak methods because, although general, they do not scale up to
detailed account of the behaviorist approach to language learning, written by the foremost expert in The field. large or difficult problem instances. The alternative to weak methods is to use more powerful, domain-specific
Modern linguistics and AI, then, were “born” at about the same time, and grew up together, intersecting in a knowledge that allows larger reasoning steps and can more easily handle typically occurring cases in narrow
hybrid field called computational linguistics or natural language COMPUTATIONAL LINGUISTICS processing. areas of expertise.
The problem of understanding language soon turned out to be considerably more complex than it seemed in 1957. 1.3.6 AI becomes an industry (1980–present)

1.3 The History of Artificial Intelligence The first successful commercial expert system, R1, began operation at the Digital Equipment Corporation

1.3.1 The gestation of artificial intelligence (1943–1955) (McDermott, 1982). The program helped configure orders for new computer systems; by 1986, it was saving the

The first work that is now generally recognized as AI was done by Warren McCulloch and Walter Pitts (1943). company an estimated $40 million a year.

They drew on three sources: knowledge of the basic physiology and function of neurons in the brain; a formal 1.3.7 The return of neural networks (1986–present)

analysis of propositional logic due to Russell and Whitehead; and Turing’s theory of computation. They BACK-PROPAGATION In the mid-1980s at least four different groups reinvented the back-propagation

proposed a model of artificial neurons in which each neuron is characterized as being “on” or “off,” with a learning algorithm first found in 1969 by Bryson and Ho. The algorithm was applied to many learning problems

switch to “on” occurring in response to stimulation by a sufficient number of neighboring neurons. in computer science and psychology, and the widespread dissemination of the results in the collection Parallel

1.3.2 The birth of artificial intelligence (1956) Distributed Processing (Rumelhart and McClelland, 1986) caused great excitement. CONNECTIONIST These

Princeton was home to another influential figure in AI, John McCarthy. After receiving his PhD there in 1951 and so-called connectionist models of intelligent systems were seen by some as direct competitors both to the

working for two years as an instructor, McCarthy moved to Stanford and then to Dartmouth College, which symbolic models promoted by Newell and Simon and to the logicist approach of McCarthy and others.

was to become the official birthplace of the field. 1.3.8 AI adopts the scientific method (1987–present)

1.3.3 Early enthusiasm, great expectations (1952–1969) In recent years, approaches based on hidden Markov models (HMMs) have come to dominate the area

GPS was probably the first program to embody the “thinking humanly” approach. The success of GPS and 1.3.9 The emergence of intelligent agents (1995–present)

subsequent programs as models of cognition led Newell and Simon (1976) to formulate the famous physical Perhaps encouraged by the progress in solving the subproblems of AI, researchers have also started to look at the

symbol system hypothesis, which states that “a physical symbol system has the necessary and PHYSICAL “whole agent” problem again. The work of Allen Newell, John Laird, and Paul Rosenbloom on SOAR (Newell,

SYMBOL SYSTEM sufficient means for general intelligent action.” 1990; Laird et al., 1987) is the best-known example of a complete agent architecture.

1.3.4 A dose of reality (1966–1973) 1.3.10 The availability of very large data sets (2001–present)

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

some recent work in AI suggests that for many problems, it makes more sense to worry about the data and be Mathematically speaking, we say that an agent's behavior is described by the agent
less picky about what algorithm to apply. This is true because of the increasing availability of very large data functionthat maps any given percept sequence to an action.

sources: for example, trillions of words of English and billions of images from the Web . Agent program
1.4 Agents and Environments: Internally, 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; the agent program is a concrete implementation,
running on theagent architecture.
To illustrate these ideas, we will use a very simple example-the vacuum-cleaner world shown in
Fig 1.4.5. This particular world has just two locations: squares A and B. The vacuum agent
perceives which square it is in and whether there is dirt in the square. It can choose to move
left,move right, suck up the dirt, or do nothing. One very simple agent function is the
following: ifthe current square is dirty, then suck, otherwise move to the other square. A partial

Fig 1.1: Agents and Environments tabulation ofthis agent function is shown in Fig 1.4.6.

Agent:
An Agent is anything that can be viewed as perceiving its environment through sensors
andacting upon that environment through actuators.

✓ A human agent has eyes, ears, and other organs for sensors and hands, legs,
mouth,and other body parts for actuators.
Fig 1.4.5: A vacuum-cleaner world with just two locations.
✓ A robotic agent might have cameras and infrared range finders for sensors
andvarious motors foractuators.
✓ 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.

Percept:
We use the term percept to refer to the agent's perceptual inputs at any given instant.

Percept Sequence:
An agent's percept sequence is the complete history of everything the agent has ever perceived.

Agent function:

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

The Performance measure, the environment and the agents actuators and sensors comes under the
Agent function heading task environment. We also call this as
Percept Sequence Action PEAS(Performance,Environment,Actuators,Sensors)
[A, Clean] Right

[A, Dirty] Suck

[B, Clean] Left

[B, Dirty] Suck

[A, Clean], [A, Right


Clean]
[A, Clean], [A, Suck
Dirty]

Fig 1.4.6: Partial tabulation of a simple agent function for the example: vacuum-cleaner world shown in the
Fig1.4.5
Goal-based agents:
Function REFLEX-VACCUM-AGENT ([location, status]) returns an 10
➢ A goal-based agent has an agenda.
action If status=Dirty then return Suck
➢ It operates based on a goal in front of it and makes decisions based on how best to reach that goal.
➢ A goal-based agent operates as a search and planning function, meaning it targets the goal ahead
else if location = A then return Right
andfinds the right action in order to reach it.

else if location = B then return Left 1.5 Problem Solving Agents:


➢ Problem solving agent is a goal-based agent.
➢ Problem solving agents decide what to do by finding sequence of actions that lead to desirable states.
Fig 1.4.6(i): The REFLEX-VACCUM-AGENT program is invoked for each new percept
Goal Formulation:
(location, status) and returns an action each time
It organizes the steps required to formulate/ prepare one goal out of multiple goals available.
• A Rational agent is one that does the right thing. we say that the right action is the one that Problem Formulation:
willcause the agent to be most successful. That leaves us with the problem of deciding how
and when to evaluate the agent's success. It is a process of deciding what actions and states to consider to follow goal
We use the term performance measure for the how—the criteria that determine how formulation.The process of looking for a best sequence to achieve a goal is called
successful an agent is. Search.
✓ Ex-Agent cleaning the dirty floor
A search algorithm takes a problem as input and returns a solution in the form of action sequences.
✓ Performance Measure-Amount of dirt collected
✓ When to measure-Weekly for better results Once the solution is found the action it recommends can be carried out. This is called Execution
phase.
ENVIRONMENTS:

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

solution.
PROBLEM DEFINITION • Execution: It executes the best optimal solution from the searching algorithms to reach the goal state from the
To build a system to solve a particular problem, we need to do four things: current state.
(i) Define the problem precisely. This definition must include specification of the initial situations and
1.6 Example Problems
also final situations which constitute (i.e) acceptable solution to the problem.
(ii) Analyze the problem (i.e) important features have an immense (i.e) huge impact on the appropriateness Basically, there are two types of problem approaches:

of various techniques for solving the problems.


• Toy Problem: It is a concise and exact description of the problem which is used by the researchers to compare
(iii) Isolate and represent the knowledge to solve the problem.
(iv) Choose the best problem – solving techniques and apply it to the particular problem. the performance of algorithms.
• Real-world Problem: It is real-world based problems which require solutions. Unlike a toy problem, it does not

Steps performed by Problem-solving agent depend on descriptions, but we can have a general formulation of the problem.

• Goal Formulation: It is the first and simplest step in problem-solving. It organizes the steps/sequence
Some Toy Problems
required to formulate one goal out of multiple goals as well as actions to achieve that goal. Goal formulation is
based on the current situation and the agent’s performance measure (discussed below). • 8 Puzzle Problem: Here, we have a 3×3 matrix with movable tiles numbered from 1 to 8 with a blank space.
• Problem Formulation: It is the most important step of problem-solving which decides what actions The tile adjacent to the blank space can slide into that space. The objective is to reach a specified goal state
should be taken to achieve the formulated goal. There are following five components involved in problem similar to the goal state, as shown in the below figure.
formulation: • In the figure, our task is to convert the current state into goal state by sliding digits into the blank space.
• Initial State: It is the starting state or initial step of the agent towards its goal.
• Actions: It is the description of the possible actions available to the agent.
• Transition Model: It describes what each action does.
• Goal Test: It determines if the given state is a goal state.
• Path cost: It assigns a numeric cost to each path that follows the goal. The problem- solving agent selects
a cost function, which reflects its performance measure. Remember, an optimal solution has the lowest path
cost among all the solutions.
Note: Initial state, actions, and transition model together define the state-space of the problem implicitly. State-
space of a problem is a set of all states which can be reached from the initial state followed by any sequence of actions.
The state-space forms a directed map or graph where nodes are the states, links between the nodes are actions, and In the above figure, our task is to convert the current(Start) state into goal state by sliding digits into the blank space.

the path is a sequence of states connected by the sequence of actions.


The problem formulation is as follows:
• Search: It identifies all the best possible sequence of actions to reach the goal state from the current state. It
takes a problem as an input and returns solution as its output. • States: It describes the location of each numbered tiles and the blank tile.
• Solution: It finds the best algorithm out of various algorithms, which may be proven as the best optimal • Initial State: We can start from any state as the initial state.
• Actions: Here, actions of the blank space is defined, i.e., either left, right, up or down
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

• Transition Model: It returns the resulting state as per the given state and actions. • Goal test: Checks whether 8-queens are placed on the chessboard without any attack.
• Goal test: It identifies whether we have reached the correct goal-state. • Path cost: There is no need for path cost because only final states are counted. In this formulation,
• Path cost: The path cost is the number of steps in the path where the cost of each step is 1. Note: The 8-puzzle there is approximately 1.8 x 1014 possible sequence to investigate.
problem is a type of sliding-block problem which is used for testing new search algorithms in artificial
2. Complete-state formulation: It starts with all the 8-queens on the chessboard and moves them around, saving
intelligence.
from the attacks.
• 8-queens problem: The aim of this problem is to place eight queens on a chessboard in an order where no queen
may attack another. A queen can attack other queens either diagonally or in same row and column. Following steps are involved in this formulation
From the following figure, we can understand the problem as well as its correct solution.
• States: Arrangement of all the 8 queens one per column with no queen attacking the other queen.
• Actions: Move the queen at the location where it is safe from the attacks.
This formulation is better than the incremental formulation as it reduces the state space from 1.8 x 1014 to 2057, and

it is easy to find the solutions.

Some Real-world problems


• Traveling salesperson problem(TSP): It is a touring problem where the salesman can visit each city
only once. The objective is to find the shortest tour and sell-out the stuff in each city.
• VLSI Layout problem: In this problem, millions of components and connections are positioned on a chip
in order to minimize the area, circuit-delays, stray-capacitances, and maximizing the manufacturing yield.
The layout problem is split into two parts:
It is noticed from the above figure that each queen is set into the chessboard in a position where no other queen is • Cell layout: Here, the primitive components of the circuit are grouped into cells, each performing its
placed diagonally, in same row or column. Therefore, it is one right approach to the 8-queens problem. specific function. Each cell has a fixed shape and size. The task is to place the cells on the chip without overlapping
each other.
For this problem, there are two main kinds of formulation:

1. Incremental formulation: It starts from an empty state where the operator augments a queen at each step.
• Channel routing: It finds a specific route for each wire through the gaps between the cells.
Following steps are involved in this formulation :
• ROBOT NAVIGATION :It is a generalization of the route-finding problem described earlier. Rather than following a
• States: Arrangement of any 0 to 8 queens on the chessboard. discrete set of routes, a robot can move in a continuous space with (in principle) an infinite set of possible actions
and states.
Initial State: An empty chessboard
• Actions: Add a queen to any empty box. • Automatic assembly sequencing: In assembly problems, the aim is to find an order in which to assemble the
• Transition model: Returns the chessboard with the queen added in a box. parts of some object. If the wrong order is chosen, there will be no way to add some part later in the sequence without

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

undoing some of the work already done. Search algorithms require a data structure to keep track of the search tree that is being constructed. For
each node n of the tree, we have a structure that contains four components:
Protein Design: The objective is to find a sequence of amino acids which will fold into 3D protein having a
property to cure some disease. • n.STATE: the state in the state space to which the node corresponds;

• n.PARENT: the node in the search tree that generated this node

; • n.ACTION: the action that was applied to the parent to generate the node;

• n.PATH-COST: the cost, traditionally denoted by g(n), of the path from the initial state to the node, as
1.7 Searching for solutions
indicated by the parent pointers.
We have seen many problems. Now, there is a need to search for solutions to solve them.In this section, we
will understand how searching can be used by the agent to solve a problem. Well Defined problems and solutions:

A problem can be defined formally by 4 components:


For solving different kinds of problem, an agent makes use of different strategies to reach the goal by
➢ The initial state of the agent is the state where the agent starts in. In this case, the initial state can be
searching the best possible algorithms. This process of searching is known as search strategy.
described as In: Arad
➢ The possible actions available to the agent, corresponding to each of the state the agent
residesin.
For example, ACTIONS(In: Arad) = {Go: Sibiu, Go: Timisoara, Go:
Zerind}. Actions are also known as operations.
➢ A description of what each action does.the formal name for this is Transition model,Specified
bythefunction Result(s,a) that returns the state that results from the action a in state s.
We also use the term Successor to refer to any state reachable from a given state by a single
action.
For EX: Result(In(Arad),GO(Zerind))=In(Zerind)

Infrastructure for search algorithms/Data structure

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

Together the initial state,actions and transition model implicitly defines the state space of the
problemState space: set of all states reachable from the initial state by any sequence of actions
➢ The goal test, determining whether the current state is a goal state. Here, the goal state is
{In:Bucharest} State Space Search/Problem Space Search:

➢ The path cost function, which determine the cost of each path, which is reflecting in The state space representation forms the basis of most of the AI methods.
theperformance measure. • Formulate a problem as a state space search by showing the legal problem states, the legal
we define the cost function as c(s, a, s’), where s is the current state and a is the action performed by operators, and the initial and goal states.

theagent to reach state s’. • A state is defined by the specification of the values of all attributes of interest in the world
• An operator changes one state into the other; it has a precondition which is the value of
certain attributes prior to the application of the operator, and a set of effects, which are the
attributes altered by the operator
• The initial state is where you start
• The goal state is the partial description of the solution

Formal Description of the problem:


1. Define a state space that contains all the possible configurations of the relevant objects.
2. Specify one or more states within that space that describe possible situations from
which the problem solving process may start ( initial state)
3. Specify one or more states that would be acceptable as solutions to the problem. ( goal states)
Specify a set of rules that describe the actions (operations) available

State-Space Problem Formulation:


ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

Example: A problem is defined by four items:


1. initial state e.g., "at Arad“ 1.8 Search strategies:
2. actions or successor function : S(x) =set of action–state Search: Searching is a step by step procedure to solve a search-problem in a given search space. A
pairse.g., S(Arad) = {<Arad → Zerind, Zerind>, … search problem can have three main factors:
} Search Space: Search space represents a set of possible solutions, which a system may have.
3. goal test (or set of goal states) Start State: It is a state from where agent begins the search.
e.g., x = "at Bucharest”, Checkmate(x) Goal test: It is a function which observe the current state and returns whether the goal state is
4. path cost (additive) achieved or not.
e.g., sum of distances, number of actions executed, etc.
Properties of Search Algorithms/Measuring problem-solving performance
c(x,a,y) is the step cost, assumed to be ≥ 0
A solution is a sequence of actions leading from the initial state to a goal state Which search algorithm one should use will generally depend on the problem
domain. T
There are four important factors to consider:
• Completeness: Is the algorithm guaranteed to find a solution when there is one?
• Optimality: Does the strategy find the optimal solution?
• Time complexity: How long does it take to find a solution?
• Space complexity: How much memory is needed to perform the search?
State Spaces versus Search Trees:
• State Space
o Set of valid states for a problem
o Linked by operators
o e.g., 20 valid states (cities) in the Romanian travel problem
• Search Tree
– Root node = initial state
– Child nodes = states that can be visited from parent
– Note that the depth of the tree can be infinite
• E.g., via repeated states
– Partial search tree
• Portion of tree that has been expanded so far
– Fringe
• Leaves of partial search tree, candidates fo r expansion
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

Search trees = data structure to search state- space

Searching
Many traditional search algorithms are used in AI applications. For complex problems, the traditional
algorithms are unable to find the solution within some practical time and space limits. Consequently,
many special techniques are developed; using heuristic functions. The algorithms that use heuristic

functions are called heuristic algorithms. Heuristic algorithms are not really intelligent; they appear to
be intelligent because they achieve better performance.Heuristic algorithms are more efficient because
they take advantage of feedback from the data to direct the search path.

Uninformed search

Also called blind, exhaustive or brute-force search, uses no information about the problem to guide
the search and therefore may not be very efficient.

Informed Search:

Also called heuristic or intelligent search, uses information about the problem to guide the search, usually
BFS illustrated:
guesses the distance to a goal state and therefore efficient, but the search may not be always possible.
Step 1: Initially frontier contains only one node corresponding to the source state A.
1.9 Uninformed Search (Blind searches):

1. Breadth First Search:

➢ One simple search strategy is a breadth-first search. In this strategy, the root node is
expanded first, then all the nodes generated by the root node are expanded next, and
then their successors, and so on.
➢ In general, all the nodes at depth d in the search tree are expanded before the nodes at depth d Figure 1
+ 1.
Frontier: A
Breadth-first search is an instance of the general graph-search algorithmin which the shallowest
unexpanded node is chosen for expansion,.This is achieved very simply by using a FIFO queue
Step 2: A is removed from fringe. The node is expanded, and its children B and C are generated.
for the frontier. Thus, new nodes (which are always deeper than their parents) go to the back of They are placed at the back of fringe.
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

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence

Step 4: Node C is removed from fringe and is expanded. Its children D and G are added to
the back of fringe.

Figure 2
Frontier: B C
Figure 4

Step 3: Node B is removed from fringe and is expanded. Its children D, E are generated and Frontier: D E D G

Step 5: Node D is removed from fringe. Its children C and F are generated and added to the
back of fringe.

Put at the back of fringe. Figure 3


Figure 5
Frontier: C D E Frontier: E D G C F

Step 6: Node E is removed from fringe. It has no children.

Figure 6
Frontier: D G C F

Step 7: D is expanded; B and F are put in OPEN.

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence

Figure 7
Frontier: G C F B F

Step 8: G is selected for expansion. It is found to be a goal node. So the algorithm returns the
path A C G by following the parent pointers of the node corresponding to G. The algorithm
terminates.

Breadth first search is:

One of the simplest search strategies


• Complete. If there is a solution, BFS is guaranteed to find it.
• If there are multiple solutions, then a minimal solution will be found
• The algorithm is optimal (i.e., admissible) if all operators have the same
cost.

• Otherwise, breadth first search finds a solution with the shortest path length.
• Time complexity : O(bd )
• Space complexity : O(bd )
• Optimality :Yes
b - branching factor(maximum no of successors of
any node), d – Depth of the shallowest goal node
Maximum length of any path (m) in search space

Advantages:

ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof


➢ BFS will provide a solution if any solution exists.
➢ If there are more than one solutions for a given problem, then BFS will provide the minimal DFS illustrated:
solution which requires the least number of steps.

Disadvantages:
➢ Requires the generation and storage of a tree whose size is exponential the depth of
the shallowest goal node.
A State Space Graph
➢ The breadth first search algorithm cannot be effectively used unless the search space is
quite small. Step 1: Initially fringe contains only the node for A.
Applications Of Breadth-First Search Algorithm
GPS Navigation systems: Breadth-First Search is one of the best algorithms used to find neighboring
locations by using the GPS system.
Broadcasting: Networking makes use of what we call as packets for communication. These packets
follow a traversal method to reach various networking nodes. One of the most commonly used traversal
methods is Breadth-First Search. It is being used as an algorithm that is used to communicate Figure 1
broad casted packets across all the nodes in a network. FRINGE: A

1.10 Depth- First- Search.


Step 2: A is removed from fringe. A is expanded and its children B and C are put in front of
Depth-first search always expands the deepest node in the current frontier of the search tree. fringe.
DEPTH-FIRST SEARCH The progress of the search is illustrated in Figure The search proceeds
immediately to the deepest level of the search tree, where the nodes have no successors. As those
nodes are expanded, they are dropped from the frontier, so then the search “backs up” to the next
deepest node that still has unexplored successors. The depth-first search algorithm is an instance
of the graph-search algorithm in Figure ; whereas breadth-first-search uses a FIFO queue, depth-
first search uses a LIFO queue. A LIFO queue means that the most recently generated node is Figure 2

chosen for expansion. This must be the deepest unexpanded node because it is one deeper than its FRINGE: B C

parent—which, in turn, was the deepest unexpanded node when it was selected. Step 3: Node B is removed from fringe, and its children D and E are pushed in front of fringe.
FRINGE: D E C FRINGE: G F E C

Step 4: Node D is removed from fringe. C and F are pushed in front of fringe. The solution path A-B-D-C-G is returned and the algorithm terminates.

Depth first search


1. takes exponential time.
2. If N is the maximum depth of a node in the search space, in the worst case the algorithm will
d

take time O(b ).

Figure 4 3. The space taken is linear in the depth of the search tree, O(bN).

FRINGE: C F E C Note that the time taken by the algorithm is related to the maximum depth of the search tree. If the search
tree has infinite depth, the algorithm may not terminate. This can happen if the search space is infinite. It
Step 5: Node C is removed from fringe. Its child G is pushed in front of fringe. can also happen if the search space contains cycles. The latter case can be handled by checking for cycles
in the algorithm. Thus Depth First Search is not complete.
Figure 5

Figure 5

FRINGE: G F E C
Step 6: Node G is expanded and found to be a goa node.

You might also like