ch1 2 3 AI
ch1 2 3 AI
4/27/2024 AI/CSEg3206 1
Introduction to Artificial Intelligence (CSEg3206)
Instructor: Dr.T.GopiKrishna
Assistant Professor
ASTU
4/27/2024 AI/CSEg3206 2
Introduction
• Chapter Objectives
– Define intelligence
– Define AI
– Describe what an agent is
– State what rational agent is
– Identifying areas and achievements of AI
– Explain AI history and trends
4/27/2024 AI/CSEg3206 3
Artificial Intelligence is composed of two
words Artificial and Intelligence, where Artificial
defines "man-made," and intelligence
defines "thinking power",
hence AI means "a man-made thinking power."
4/27/2024 AI/CSEg3206 4
What is Artificial Intelligence (AI)?
Def-1:"It is a branch of computer science by which
we can create intelligent machines which can behave
like a human, think like humans, and able to make
decisions."
Def-2: Programs that behave (externally) like humans.
Programs that operate (internally) the way humans do
(Another way is to make computational models of human
thought processes.)
What does it mean to behave intelligently?(Another
thing that we could do is build computational systems
that behave intelligently.)
4/27/2024 AI/CSEg3206 5
AI applications
Monitor trades,
Detect fraud,
schedule shuttle loading, etc.
Software that gathers information about an
environment and takes actions based on that (Agent)
• a robot
• web shopping program
• a factory
• a traffic control system…
4/27/2024 AI/CSEg3206 6
AI applications
4/27/2024 AI/CSEg3206 7
History of AI
4/27/2024 AI/CSEg3206 8
The emergence of intelligent agents (1993-2011)
Year 1997: In the year 1997, IBM Deep Blue beats
world chess champion, Gary Kasparov, and became the
first computer to beat a world chess champion.
Year 2002: for the first time, AI entered the home in the
form of Roomba, a vacuum cleaner.
Year 2006: AI came in the Business world till the year
2006. Companies like Facebook, Twitter, and Netflix
also started using AI.
Nowadays companies like Google, Facebook, IBM, and
Amazon are working with AI and creating amazing
devices. The future of Artificial Intelligence is inspiring
and will come with high intelligence.
4/27/2024 AI/CSEg3206 9
Why Artificial Intelligence?
4/27/2024 AI/CSEg3206 11
Types of AI
AI type-1: Based on Capabilities
Reactive Machines
• Reactive MachinReactive Machines
Es, EX:Theory of Mind
4/27/2024 AI/CSEg3206 12
Data…..contd
•Information
•Is data that has been given meaning by way of relational
connection
•This "meaning" can be useful, but does not have to be
•A relational database makes information from the data stored
within it
4/27/2024 AI/CSEg3206 13
Data…..contd
4/27/2024 AI/CSEg3206 14
Data…..contd
4/27/2024 AI/CSEg3206 15
Data…..contd
•Knowledge
• It is the appropriate collection of information, such that it's intent is to
be useful.
• Knowledge is a deterministic process.
• Most of the applications we use (modeling, simulation, etc.) exercise
some type of stored knowledge.
Understanding
•is a true cognitive and analytical ability
•Understanding is an interpolative and probabilistic process
•Synthesize new knowledge from the previously held knowledge
4/27/2024 AI/CSEg3206 16
Data…..contd
• Wisdom
• Is an extrapolative and non-deterministic, non probabilistic
process
• It calls upon all the previous levels of consciousness, and specifically upon
special types of human programming (moral, ethical codes, etc.).
• Most people believe that computers do not have, and will never have the
ability to posses wisdom.
• The following diagram represents the transitions from data, to
information, to knowledge, and finally to wisdom. It is called as
knowledge hierarchy
4/27/2024 AI/CSEg3206 17
Data…..contd
Knowledge Hierarchy
4/27/2024 AI/CSEg3206 18
Data…..contd
• The first four categories relate to the past.
• Only the fifth category, wisdom, deals with the future because it
incorporates vision and design.
• With wisdom, people can create the future rather than just grasp the
present and past.
• But achieving wisdom isn't easy.
• People must move successively through the other categories.
• The most important is, it is very hard to represent wisdom with a
computer system
4/27/2024 AI/CSEg3206 19
Data…..contd
Knowledge Hierarchy
4/27/2024 AI/CSEg3206 20
Data…..contd
4/27/2024 AI/CSEg3206 22
Views ….contd
• Think Like Humans: The cognitive modeling approach
4/27/2024 AI/CSEg3206 24
Views ….contd
• Think Rationally : the laws of thought
• Instead of thinking like a human , think rationally
– Find out how correct thinking must proceed
– Syllogism: “Socrates is a man; all men are mortal, therefore Socrates is
mortal.”
– These laws of thought were supposed to govern the operation of the
mind; their study initiated the field called logic
• A traditional and important branch of mathematics and computer
science.
– Problem:
• It is not always possible to model thought as a set of rules;
sometimes there is uncertainty.
• Even when a modeling is available, the complexity of the problem
may be too large to allow for a solution.
4/27/2024 AI/CSEg3206 25
Views ….contd
• Act Rationally: The rational agent approach
– An agent is an entity that perceives and acts.
– Rational agent: acts as to achieve the best outcome or, when
there is uncertainty, the best expected outcome.
– Logical thinking is only one aspect of appropriate behavior:
reactions like getting your hand out of a hot place is not the
result of a careful deliberation, yet it is clearly rational.
– Sometimes there is no correct way to do, yet something must be
done.
– Instead of insisting on how the program should think, there fore
it is better to insist on how the program should act: caring only
about the final result(goal).
4/27/2024 AI/CSEg3206 26
Views ….contd
•Summary of Views of AI
4/27/2024 AI/CSEg3206 27
Views ….contd
• Modeling exactly how humans actually think
– cognitive models of human reasoning
• Modeling exactly how humans actually act
– models of human behavior (what they do, not how they think)
• Modeling how ideal agents “should think”
– models of “rational” thought (formal logic)
– NB: humans are often not rational!
• Modeling how ideal agents “should act”
– rational actions but not necessarily formal rational reasoning
– i.e., more of a black-box/engineering approach
• Modern AI focuses on the last definition
– A focus on this “engineering” approach
– Success is judged by how well the agent performs
-- Modern methods are also inspired by cognitive & neuroscience (how people
think).
4/27/2024 AI/CSEg3206 28
Views ….contd
AI is an attempt of the reproduction of human reasoning and
intelligent behavior by computational methods
The goal of AI is to create computer systems(Machines) that
perform tasks regarded as requiring intelligence when done by
humans
Take a task at which people are better, e.g.:
• Prove a theorem
• Play chess
• Plan a surgical operation
• Diagnose a disease
• Navigate in a building
and build a computer system that does it automatically
4/27/2024 AI/CSEg3206 29
Views ….contd
• There fore,
–AI involves modeling Human (Activities, behaviour, thoughts,
etc) and even other animals
• The systems that are built act optimally given the limited
information and computational resources available. .
4/27/2024 AI/CSEg3206 30
Foundations of Artificial Intelligence
Philosophy Knowledge Rep., Logic, Foundation of AI (is AI possible?)
Mathematics Search, Analysis of search algos., logic
Economics Expert Systems, Decision Theory, Principles of Rational
Behavior
Psychology Behaviorist insights into AI programs
Brain Science Learning, Neural Nets
(Neuroscience)
Physics Learning, Information Theory & AI, Entropy, Robotics,
Image Processing
Computer Engg. Systems for AI
Linguistics Natural Language Processing(NLP), Speech Recognition,
Computational Linguistics, Knowledge Representation,
Expert systems, etc
4/27/2024 AI/CSEg3206 31
What can AI do today?(Roles of AI)
A concise answer is difficult, because there are so many activities in so
many subfields.
• Autonomous planning and scheduling
• Game playing(person Garry Kasparov, etc)
• Autonomous control
• Diagnosis
• Logistics Planning
• Robotics
• Language understanding and problem solving
4/27/2024 AI/CSEg3206 32
Some Achievements
Computers have won over world
champions in several games,
including Checkers, Othello, and
Chess, but still do not do well in
Go
AI techniques are used in many
systems: formal calculus, video
games, route planning, logistics
planning, pharmaceutical drug
design, medical diagnosis,
hardware and software trouble-
shooting, speech recognition,
traffic monitoring, facial
recognition,
medical image analysis, part
inspection, etc...
Stanford’s robotic car, Stanley,
autonomously traversed 132 miles
of desert
Some industries (automobile,
electronics) are highly robotized,
while other robots perform brain
and heart surgery, are rolling
on Mars, fly autonomously, …,
but home robots still remain
a thing of the future
4/27/2024 AI/CSEg3206 33
Some Big Open Questions
AI (especially, the “rational agent” approach) assumes that
intelligent behaviors are only based on information processing?
Is this a valid assumption?
If yes, can the human brain machinery solve problems that are
inherently intractable for computers?
In a human being, where is the interface between “intelligence”
and the rest of “human nature”, e.g.:
• How does intelligence relate to emotions felt?
• What does it mean for a human to “feel” that he/she
understands something?
Is this interface critical to intelligence? Can there exist a
general theory of intelligence independent of human beings?
What is the role of the human body?
4/27/2024 AI/CSEg3206 34
Some…contd
AI (especially, the “rational agent” approach) assumes that
intelligent behaviors are based on information processing? Is this
a valid assumption?
In the movie I, Robot, the most impressive
If yes, canofthethe
feature human brain
robots is machinery
not theirsolve problems
ability to that are
solve
inherently intractable for computers?
complex problems, but how they blend human-
like
In reasoning
a human being, with
whereother key aspects
is the interface betweenof “intelligence”
human
and the rest(especially,
beings of “human nature”, e.g.:
self-consciousness, fear of
How does
dying, intelligence
distinction relate toright
between emotions
andfelt?
wrong)
What does it mean for a human to “feel” that he/she
understands something?
Is this interface critical to intelligence? Can there exist a general
theory of intelligence independent of human beings? What is the
role of the human body?
4/27/2024 AI/CSEg3206 35
Some…contd
AI contributes to building an information processing model of
human beings, just as Biochemistry contributes to building a
model of human beings based on bio-molecular interactions
Both try to explain how a human being operates
Both also explore ways to avoid human imperfections (in Biochemistry, by
engineering new proteins and drug molecules; in AI, by designing rational
reasoning methods)
Both try to produce new useful technologies
4/27/2024 AI/CSEg3206 36
Main Areas of AI
Knowledge representation
(including formal logic)
Search, especially Agent Perception
heuristic search (puzzles, Robotics
games)
Planning Reasoning
Reasoning under Search
uncertainty, including Learning
probabilistic reasoning
Learning Knowledge Constraint
Planning rep. satisfaction
Agent architectures
Robotics and perception
Natural language
processing Natural
Expert
language
Systems
...
4/27/2024 AI/CSEg3206 37
Bits of History
1956: The name “Artificial Intelligence” is coined
4/27/2024 AI/CSEg3206 38
Programming Without and With AI
The programming without and with AI is different in following ways −
A computer program without AI can answer A computer program with AI can answer
the specific questions it is meant to solve. the generic questions it is meant to solve.
4/27/2024 AI/CSEg3206 39
What is Intelligence Composed of ?
• Reasoning
• Learning
• Problem Solving
• Perception
• Linguistic Intelligence
4/27/2024 AI/CSEg3206 40
Difference between Human and Machine Intelligence
4/27/2024 AI/CSEg3206 41
Task Classification of AI
4/27/2024 AI/CSEg3206 42
Questions are
Welcome
4/27/2024 AI/CSEg3206 43
Artificial Intelligence(AI)
Chapter Two : Intelligent Agent
4/27/2024 AI/CSEg3206 44
Chapter Objectives
4/27/2024 AI/CSEg3206 45
4/27/2024 AI/CSEg3206 46
4/27/2024 AI/CSEg3206 47
Understanding AI Intelligent Agent
4/27/2024 AI/CSEg3206 48
4/27/2024 AI/CSEg3206 49
What is an Agent?
4/27/2024 AI/CSEg3206 50
What is…..contd
• We use the term percept to refer to the agent's perceptual
inputs at any given instant.
• 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.
• If we can specify the agent's choice of action for every possible
percept sequence, then we have said more or less everything
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. [f: P* A]
4/27/2024 AI/CSEg3206 51
What is…..contd
4/27/2024 AI/CSEg3206 53
What is…..contd
• An intelligent agent perceives its environment via sensors and
acts rationally upon that environment with its effectors.
• A discrete agent receives percepts one at a time, and maps this
percept sequence to a sequence of discrete actions.
• Properties
–Reactive to the environment
–Pro-active or goal-directed
–Interacts with other agents through
communication or in the environment
–Autonomous
4/27/2024 AI/CSEg3206 54
What is…..contd
• So, any agent consists of two parts:
– Agent architecture Agents are usually directed by Humans
– Agent program
• The architecture is the hardware and the program is the
software.
• The role of the agent program is to implement the agent
function.
• The agent function is a mapping from percept histories to
actions.
4/27/2024 AI/CSEg3206 55
VCW example
4/27/2024 AI/CSEg3206 56
Vacuum Cleaner World Example
4/27/2024 AI/CSEg3206 57
4/27/2024 AI/CSEg3206 58
4/27/2024 AI/CSEg3206 59
4/27/2024 AI/CSEg3206 60
4/27/2024 AI/CSEg3206 61
4/27/2024 AI/CSEg3206 62
4/27/2024 AI/CSEg3206 63
4/27/2024 AI/CSEg3206 64
What is…..contd
Ideal Example of Agent
Vacuum-cleaner world
• Percepts: location and contents
– e.g., [A,B, Dirty, Clean]
Actions:[ Left, Right, Suck, Do Nothing]
4/27/2024 AI/CSEg3206 66
What is…..contd
How should Agents act?
A rational agent is an agent that does the right thing for the
perceived data from the environment
What is right is an ambiguous concept but we can consider
the right thing as the one that makes the agent more
successful.
Success is also measured by using performance measure
and a performance measure embodies the criterion for
success of an agent's behavior
Question
How and when do you measure success in performance?
4/27/2024 AI/CSEg3206 67
What is…..contd
Performance measure (how?)
– Subjective Measure using the Agent
• How happy is the agent at the end of the action
• Agent should answer based on its opinion
• Some agents are unable to answer, some delude them
selves, some over estimate and some under estimate their
success
• Therefore, subjective measure is not a better way.
– Objective Measure imposed by Some Authority is an
alternative
– The selection of a performance measure is not always easy.
4/27/2024 AI/CSEg3206 68
What is…..contd
Objective Measure
◦ Needs standard to measure success
◦ Provides quantitative value of success measure of an agent
◦ Involves factors that affect performance and weight to each factors
E.g., performance measure of a vacuum-cleaner agent could be
amount of dirt cleaned up, (average but way to achieve)
amount of time taken,
amount of electricity consumed,
amount of noise generated, etc.
Time factor in measuring performance is also important for
success.
It may include knowing starting time, finishing time, duration of job, etc
•Which is better-an economy where everyone lives in moderate poverty,
or one in which some live in plenty while others are very poor?
4/27/2024 AI/CSEg3206 69
What is…..contd
Omniscience versus Rational Agent
– Omniscience agent is distinct from Rational agent
– An omniscient agent knows the actual outcome of its actions
and can act accordingly
– Is impossible in reality
– However, rational agent is an agent that tries to achieve
more success from its decision.
– Rational agent could make a mistake because of
unpredictable factors at the time of making decision.
– For each possible percept sequence, a rational agent should
select an action that is expected to maximise its
performance
4/27/2024 AI/CSEg3206 70
What is…..contd
4/27/2024 AI/CSEg3206 72
What is…..contd
Ideal rational Agent
4/27/2024 AI/CSEg3206 74
What is…..contd
Structure of Intelligent Agent
Structure of AI Agent refers to the design of intelligent agent program (function that
implement agent mapping from percept to actions) that will run on some sort of
computing device called architecture
This course focus on intelligent agent program function theory, design and
implementation plunk
Design of intelligent agent needs prior knowledge of
◦ Performance measure or Goal the agent supposed to achieve,
◦ On what kind of Environment it operates
◦ What kind of Actuators it has (what are the possible Actions),
◦ What kind of Sensors the agent has (what are the possible Percepts)
Performance measure Environment Actuators Sensors are abbreviated as
PEAS
Percepts Actions Goal Environment are abbreviated as PAGE
4/27/2024 AI/CSEg3206 75
What is…..contd
4/27/2024 AI/CSEg3206 76
What is…..contd
Examples of agents structure and sample PEAS
Agent: Interactive English tutor
◦ Environment: Set of students, testing agency
◦ Sensors: Keyboard (typed words)
◦ Actuators: Screen display (exercises, suggestions, corrections)
◦ Performance measure: Maximize student's score on test
Agent: Satellite image analysis system
◦ Environment: Images from orbiting
◦ Sensors: Pixels of varying intensity, color
◦ Actuators: print categorization of scene
◦ Performance measure: Correct categorization
4/27/2024 AI/CSEg3206 77
What is…..contd
4/27/2024 AI/CSEg3206 78
4/27/2024 AI/CSEg3206 79
4/27/2024 AI/CSEg3206 80
What is…..contd
Agent programs
Skeleton of the Agent
FUNCTION SKELETON-AGENT (percept) returns action
static memory, the agent’s memory of the world
memory UPDATE-MEMORY (memory, percept)
action CHOOSE-BEST-ACTION (memory)
memory UPDATE-MEMORY (memory, action)
RETURN action
Note:
1. the function gets only a single percept at a time
Q: how to get the percept sequence?
2. The goal or performance measure is not part of the skeleton
4/27/2024 AI/CSEg3206 81
What is…..contd
Table-lookup agent
• Table look up agent store all the percept sequences –action pair into the
table
• For each percept, this type of agent will search for the percept entry and
return the corresponding actions.
• Table look up couldn’t be the right option to implement successful agent
• Why?
• Drawbacks:
– Huge table
– Take a long time to build the table
– No autonomy
– Even with learning, need a long time to learn the table entries
4/27/2024 AI/CSEg3206 82
What is…..contd
Agent types
• Based on memory of the agent, and they way the agent takes action we
can divide agents into five basic types:
• These are (according to their increasing order of generality) :
1. Simple reflex agents
2. Model-based reflex agents
3. Goal-based agents
4. Utility-based agents
5. Learning agent
Notation of model:
• Rectangles: used to represent the current internal state of the agent
decision process
• Ovals: used to represent the background information used in the process
4/27/2024 AI/CSEg3206 83
What is…..contd
Simple Reflex Agents
• It is the simplest type of Agent.
• It uses a set of condition-action rules.
• It uses only the current precepts .
• The rules are of the form “if this is the percept then this is the best
action”. which does not depend on the rest of the percept
history.
• They cannot make decisions on things that they cannot directly
perceive, i.e. they have no model of the state of the world.
• Simple reflex agents have the admirable property of being simple, but
they turn out to be of very limited intelligence
• Works only if the correct decision can be made on the basis of only the
current percept-that is, only if the environments is fully observable.
4/27/2024 AI/CSEg3206 84
What is…..contd
Simple reflex agents
4/27/2024 AI/CSEg3206 85
What is…..contd
stateINTERPRET-INPUT(percept)
ruleRULE-MATCH(state, rules)
ActionRULE-ACTION[rule]
Return action
4/27/2024 AI/CSEg3206 86
What is…..contd
– They live in the present only and do not think about the future.
4/27/2024 AI/CSEg3206 87
What is…..contd
Model-based reflex agents (also called a reflex agent
with internal state)
4/27/2024 AI/CSEg3206 88
What is…..contd
Model-based reflex agents
• Function MODEL_BASED_AGENT(PERCEPT) return action
static state, a description of the current world state
rules, a set of condition action rules
stateUPDATE_STATE(state, percept)
ruleRULE_MATCH(state, rues)
actionRULE_ACTION[rule]
stateUPDATE_STATE(state,action)
return action
4/27/2024 AI/CSEg3206 89
What is…..contd
Goal-based agents
• Knowing about the current state of the environment is not always
enough to decide what to do.
• For example, at a road junction, the taxi can turn left, turn right, or
go straight on.
• The correct decision depends on where the taxi is trying to get
to(Goal).
• That is, the agent needs some sort of goal information that
describes situations that are desirable
• It is a model-based, goal-based agent.
• It keeps track of the world state as well as a set of goals it is trying
to achieve, and chooses an action that will (eventually) lead to the
achievement of its goals
– Is it easy always?
4/27/2024 AI/CSEg3206 90
What is…..contd
Goal-based agents
Notice that decision making of this kind is fundamentally different from the
condition action rules described earlier, in that it involves consideration of the
future-both "What will happen if I do such-and-such?' and "Will that make me
happy?'
4/27/2024 AI/CSEg3206 91
What is…..contd
Goal-based agents structure
• Function GOAL_BASED_AGENT(PERCEPT) return action
static state, a description of the current world state
goal, a description of the goal to achieve may be in
terms of state
stateUPDATE_STATE(state, percept)
actionSetPOSSIBLE_ACTIONS(state)
actionACTION_THAT_LEADS_TO_GOAL(actionSet)
stateUPDATE_STATE(state,action)
return action
4/27/2024 AI/CSEg3206 92
What is…..contd
Utility Based Agents
• Goals alone are not really enough to generate high-quality behavior in
most environments.
• Goal can be useful, but are sometimes too simplistic.
• Clearly there can be many actions that lead to a goal being achieved, but
some are better than others.
• Utility based agents deal with this by assigning a utility to each state of
the world.
– This utility defines how “happy” the agent will be in such a state.
• Goal based agents implicitly contain a utility function which is difficult
to define more complex “desires”.
• Explicitly stating the utility function also makes it easier to define the
desired behaviour of utility based agents.
4/27/2024 AI/CSEg3206 93
What is…..contd
4/27/2024 AI/CSEg3206 94
What is…..contd
Utility-based agents structure
• Function UTILITY_BASED_AGENT(PERCEPT) return action
static state, a description of the current world state
goal, a description of the goal to achieve may be in
terms of state
stateUPDATE_STATE(state, percept)
actionSetPOSSIBLE_ACTIONS(state)
actionBEST_ACTION(actionSet)
stateUPDATE_STATE(state,action)
return action
Remark:
• A utility function maps a state (or a sequence of states) onto a
real number, which describes the associated degree of happiness.
• A complete specification of the utility function allows rational
decisions in two kinds of cases where goals are inadequate(many,
4/27/2024 AI/CSEg3206 95
What is…..contd
Learning Agents
• In many areas of AI, this is now the preferred method for
creating state-of-the-art systems
• A learning agent can be divided into four conceptual
components
• Learning Element
– Suggesting improvements to any part of the performance
element.
– The input to the learning element comes from the
Critic.(on how the agent is doing and determines how the
performance element should be modified to do better in the
future)
4/27/2024 AI/CSEg3206 96
What is…..contd
• Learning Agent
• Performance element
– Responsible for selecting external actions(it takes in percepts
and decides on actions)
• Critic
– Analyses incoming precepts and decides if the actions of the
agent have been good or not.
– To decide this it will use an external performance standard.
• Problem Generator
– Responsible for suggesting actions that will result in new
knowledge about the world being acquired.
4/27/2024 AI/CSEg3206 97
What is…..contd
Learning agents
4/27/2024 AI/CSEg3206 98
Types of environments:
4/27/2024 AI/CSEg3206 99
Fully Observable vs Partially-Observable
In a fully observable environment, The Agent is familiar with the complete
state of the environment at a given time. There will be no portion of the
environment that is hidden for the agent.
Known vs Unknown :-
• In a known environment, the output for all probable actions is given.
Obviously, in case of unknown environment, for an agent to make a
decision, it has to gain knowledge about how the environment works.
Remark:
• The environment type largely determines the agent design
• The real world is (of course) partially observable, stochastic,
sequential, dynamic, continuous, multi-agent
• As one might expect, the hardest case is partially observable,
stochastic, sequential, dynamic, continuous, and multi agent.
• It also turns out that most real situations are so complex that
whether they are really deterministic is a moot point.
• For practical purposes, they must be treated as stochastic. Taxi
driving is hard in all these senses.
Questions are
Welcome
Chapter III
(Problem Solving: Uninformed Search)
States
Actions
Start Solution
Goal
• Problem formulation:
– For vacuum world problem, the problem formulation involve:
• States: The agent is in one of two locations, each of which
might or might not contain dirt. Thus there are 2 x 2^2 = 8
possible world states.
• Initial state: Any state can be designated as the initial state.
• Successor function: This generates the legal states that result
from trying the three actions (Left, Right, and Suck).
• 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.
4/27/2024 AI/CSEg3206 133
Problem…contd
Agent Program
200
Mekele
80
180
Lalibela
110 250
150
Bahr dar
Dessie
170
400
330
Addis Ababa
100
430 Adama 370
Awasa
4/27/2024 AI/CSEg3206 138
Problem…contd
Types of Problems
• Four types of problems exist in the real situations:
1. Single-state problem
– The environment is Deterministic and fully observable
– Out of the possible state space, agent knows exactly which
state it will be in; solution is a sequence
2. Sensor less problem (conformant problem)
– The environment is non-observable
– It is also called multi-state problem
– Agent may have no idea where it is; solution is a sequence
3. Contingency problem
– The environment is nondeterministic and/or partially
observable
– It is not possible to know the effect of the agent action
– percepts provide new information about current state
4. Exploration problem
– The environment is partially observable
– It is also called unknown state space
Single-state
– Starting state us known
say in #5.
– What is the Solution?
Sensorless
• Solution
• Right goes to {2,4,6,8}
Solution?
• [Right,Suck,Left,Suck]
• Contingency Solution
[Right, if dirt then Suck] Move right
suck
• States??
• Initial state??
• Actions??
• Goal test??
• Path cost??
Example: 8-puzzle
• States??
• Initial state??
• Actions??
• Goal test??
• Path cost??
Example: 8-puzzle
Example: 8-puzzle
8 2 1 2 3
3 4 7 4 5 6
5 1 6 7 8
8 2 7
3 4
8 2 5 1 6
3 4 7
5 1 6 8 2 8 2
3 4 7 3 4 7
5 1 6 5 1 6
Example: 8-puzzle
Size of the state space = 9!/2 = 181,440
0.18 sec
24-puzzle .5 x 1025
6 days
12 billion years
10 million states/sec
Example: 8-queens
Place 8 queens in a chessboard so that no two queens
are in the same row, column, or diagonal.
Example: 8-queens
Formulation #1:
• States: any arrangement of 0 to 8 queens on
the board
• Initial state: 0 queens on the board
• Actions: add a queen in any square
• Goal test: 8 queens on the board, none
attacked
• Path cost: none
Example: 8-queens
Formulation #2:
• States: any arrangement of k = 0 to 8
queens in the k leftmost columns with
none attacked
• Initial state: 0 queens on the board
• Successor function: add a queen to any
square in the leftmost empty column such
that it is not attacked by any other
queen
• Goal test: 8 queens on the bord
2,067 states
4/27/2024 AI/CSEg3206 162
Problem…contd
• States??
• Initial state??
• Actions??
• Goal test??
• Path cost??
• The Successor-Fn generate all the successors state and the action
that leads moves the current state into the successor state
• The Expand function creates new nodes, filling in the various fields
of the node using the information given by the Successor-Fn and the
input parameters
4/27/2024 AI/CSEg3206 167
Problem…contd
Gambela
Dire Nekemt Debre Awasa
Gambela AA Adama Jima
Dawa Markos
Dessie
Awasa
BahrDar AA
Lalibela AA Gondar
Gondar Debre M.
m
b
G
In general, all the nodes are expanded at a given depth in the
search tree before any nodes at the next level are expanded.
A D • Move
downwards,
B D A E level by
level, until
C E E B B F goal is
reached.
D F B F C E A C G
G C G F
G
4/27/2024 AI/CSEg3206 178
Breadth…contd
Algorithm for Breadth-first search(FIFO)
• Blind search in which the list of nodes is a queue
• To solve a problem using breadth-first search:
1.Set L to be a list of the initial node in the problem.
2.If L is empty, return failure otherwise pick the first
node n from L
3.If n is a goal state, quit and return the path from initial
node to n
4.Otherwise remove n from L and add to the end of L all
of n's children. Label each child with its path from initial
node
5.Return to 2.
3. IF goal reached
THEN success;
ELSE failure;
S
• Select a child
A • convention: left-to-right or
may be alphabetical order
B D
• Repeatedly go to next child, as
long as possible.
C E • Return to left-over alternatives
(higher-up) only when needed.
D F
G
DFS Evaluation:
• DFS is a method of choice when there is a known (and
reasonable) depth bound, and finding any solution is sufficient
1.Depth-first search:
IF the search space contains very deep branches without
solution, THEN Depth-first may waste much time in them.
2. Breadth-first search:
Is VERY demanding on memory !
Solutions ??
Iterative deepening
The order of expansion of states is similar to BFS, except
that some states are expanded multiple times
4/27/2024 AI/CSEg3206 189
Iterative Deepening Search l = 0
• Limit = 0
• Limit = 1
• Limit = 2
• Limit = 3
•As can be seen, from the three iterations, the order of expansion
of states is similar to BFS, except that some states are expanded
multiple
4/27/2024 times AI/CSEg3206 193
Iterative Deepening Search l = 1 to l=4
1. DEPTH <-- 1
• Completeness
– It is complete
– It finds a solution if exists
• Optimality
– It is optimal
– Finds the shortest path (like breadth first)
• Guarantee shortest path
• Guarantee for goal node of minimal depth
A, 1 B, 5 C, 15
A
1 10 S
5 B 5
S G
A, 1 B, 5 C, 15
15 C 5
G, 11
S
A, 1 B, 5 C, 15
G, 11 G, 10
B D A E
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17 G 25
4/27/2024 AI/CSEg3206 199
Bidirectional…contd
Bi-directional Search
* Completeness: yes
d/2
* Optimality: yes
* Time complexity: O(bd/2)
d
* Space complexity: O(bd/2)
O(bd) vs. O(bd/2) ? with b=10 and d=6 results in 1,111,111 vs. 2,222.