Ai Unit 1
Ai Unit 1
Ai Unit 1
Introduction
1
What is AI?
• For any given class of environments and tasks, we seek the agent (or class of agents) with the best
performance
• computational limitations make perfect rationality unachievable
design best program for given machine resources
12
The Disadvantages
• increased costs
• difficulty with software development - slow and expensive
• few experienced programmers
• few practical products have reached the market as yet.
13
AI Technique
• AI deals with a large spectrum of Problems
• Applications spread across the domains, from medical to manufacturing with their own
complexities
• AI Deals with
• Various Day-to-day Problem
• Different identification and authentication problems (in security)
• Classification problems in Decision-making systems
• Interdependent and cross-domain problems (Such as Cyber-Physical
• Systems)
• The problems faced by AI is hard to resolve and also computationally
14
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
AI Technique
• Intelligence requires knowledge
(less desirable properties)
– voluminous
– hard to characterize accurately
– constantly changing
– differ from data by being organized in a way that
corresponds to the ways it will be used
17
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
State space: Tic-Tac-Toe
20
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Search
• Strategies to explore the states
• Informed search – No guarantee for solution but high probability of getting solution
-heuristic approach is used to control the flow of solution path
-heuristic approach is a technique based on common sense, rule of
thumb, educated guesses or intuitive judgment
• Uninformed search – generates all possible states in the state space and checks for
the goal state.
- time consuming due to large state space
- used where error in the algorithm has severe consequences
21
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Problem solving with AI
Well structured problems- yield right answer or inference for an algorithm
Ex:
• Quadratic equation-find value of x
• Speed of ball when reaches to batsman
• Network flow analysis
Ill structured problems-do not yield a particular answer
Ex:
• How to dispose wet waste safely
• Security threats in big social gathering
Unstructured problems- exact goal state not known(many goal states)
Ex: improve life expectancy of human being
Linear problems-have a solution or will not have
Non Linear problems-relationship between input and output are not linear
22
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
23
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
AI Applications
• Credit granting
• Information management and retrieval
• AI and expert systems embedded in products
• Plant layout
• Help desk and assistance
• Employee performance evaluation
• Shipping
• Marketing
• Warehouse optimization
• In space workstation maintainance
• Satellite controls
• Network developments
• Nuclear management
24
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
AI Models
27
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Problem Solving: Definition
A problem exists when you want to get from “here” (a knowledge state) to “there” (another
knowledge state) and the path is not immediately obvious.
Makes optimal use of knowledge and information to select set of actions for reaching the goal.
What are problems?
Everyday experiences
How to get to the airport?
How to study for a quiz, complete a paper, and finish a lab before
recitation?
Domain specific problems
Physics or math problems
Puzzles/games
Crossword, anagrams, chess
Categories of problem solving
• General purpose: means-end analysis
present situation is compared with the goal to detect the difference
select action that reduces the difference
Ex:select the mode of transport
• Special purpose-modelled for the specific problem, which have specific features
Ex: classify legal document reference to particular case
28
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Problem solving process
• Problem solving-process of generating solutions for the given situation
• Problem is defined,
1. in a context
2. has well defined objective
3. solution has set of activities
4. uses previous knowledge and domain knowledge
Primary objective-problem identification
29
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Problem solving process
• Problem solving technique involves
1. problem definition
2. problem analysis and representation
3. planning
4. execution
5. evaluating solution
6. consolidating gains
• A search algorithm takes a problem as input and returns a solution in the form of
an action sequence.
• execution phase-Once a solution is found, the actions it recommends can be
carried out.
30
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Formulating problems
• Problem formulation is the process of deciding what actions and states to consider, and follows
goal formulation.
• Goal formulation-the agent may wish to decide on some other factors that affect the desirability
of different ways of achieving the goal.
• Knowledge and problem types
single-state problem-Agent knows exactly what each of its actions does and it can
calculate exactly which state it will be in after any sequence of actions.
multiple-state problem-when the world is not fully accessible, the agent must reason
about sets of states that it might get to, rather than single states.
contingency problem-the agent may be in need to now calculate a whole tree of actions,
rather than a single action sequence in which each branch of the tree deals with a possible
contingency that might arise.
exploration problem-the agent learns a "map" of the environment, which it can then use
to solve subsequent problems.
31
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Formulating problems
• Well-defined problems and solutions
A problem is really a collection of information that the agent will use to decide what to do.
Elements of a problem:
1. The initial state that the agent knows itself to be in.
2. The set of possible actions available to the agent.
operator is used to denote the description of an action to
reach a state.
state space-the set of all states reachable from the initial state by
any sequence of actions.
A path in the state space is simply any sequence of actions
leading from one state to another.
3. The goal test, which the agent can apply to a single state description to determine if it is
a goal state.
4. A path cost function is a function that assigns a cost to a path.
The output of a search algorithm is a solution, that is, a path from the initial state to a state that
satisfies the goal test.
32
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Formulating problems
• Measuring problem-solving performance
Solution is obtained or not
Obtained solution is good solution or not(with a low path cost)
Search cost-associated with the time and memory required to find a solution.
total cost of the search is the sum of the path cost and the search cost
• Choosing states and actions
To decide a better solution, determine the measurement of path cost function
The process of removing detail from a representation is called abstraction
33
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Problem Formulation and Representation
• Example: Water jug problem-find out a way to empty 2 galloon jug and fill 5 galloon jug with 1
galloon of water
states: Amount of water in the jugs
actions: 1. empty the big jug
2. empty the small jug
3. pour water from small jug to big jug
4. . pour water from big jug to small jug
Goal: 1 galloon of water in big jug and empty the small jug
path cost: number of actions(minimum number of actions->better solution)
Representation: jugs(b,s), where b-amount of water in bigger jug, s- b-amount of water in
smaller jug
initial state: (5,2)
goal state: (1,0)
operators: i) empty the jug
ii) fill the jug
34
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Problem Formulation and Representation
• Solution:
initial state: (5,2)
goal state: (1,0)
operators:
i) empty big(remove water from big jug)
ii) empty small(remove water from small jug)
iii) big is empty(pour water from small jug to big jug)
iv) small is empty(pour water from big jug to small jug)
actions of sequence: 2,4,2,4,2
35
Parag Kulkarni, Prachi Joshi, Artificial Intelligence –Building Intelliegent Systems
Toy problems
Intended to illustrate or exercise various problem-solving methods
The 8-puzzIe
• 3x3 board with eight numbered tiles and a blank space.
• A tile adjacent to the blank space can slide into the space.
• objective-to reach the configuration shown on the right of the figure.
Problem formulation:
• States: a state description specifies the location of each of the eight tiles in one of the nine
squares. For efficiency, it is useful to include the location of the blank.
• Operators: blank moves left, right, up, or down.
• Goal test: state matches the goal configuration shown in Figure.
• Path cost: each step costs 1, so the path cost is just the length of the path.
36
Stuart J. Russell, Peter Norwig , Artificial Intelligence –A Modern approach
Toy problems
The 8-queens problem
• Place eight queens on a chessboard such that no queen attacks any other.
• There are two main kinds of formulation
The incremental formulation involves placing queens one by one
the complete-state formulation starts with all 8 queens on the board and moves
them around.
• Goal test: 8 queens on board, none attacked.
• Path cost: zero.
There are also different possible states and operators.
Consider the following for incremental formulation:
• States: any arrangement of 0 to 8 queens on board.
• Operators: add a queen to any square.
Consider the following for complete state formulation:
• States: arrangements of 8 queens, one in each column.
• Operators: move any attacked queen to another square in the same column.
Kevin Night and Elaine Rich, Nair B., “Artificial Intelligence (SIE)”, Mc Graw Hill- 2008. 41
Problem Characteristics
Kevin Night and Elaine Rich, Nair B., “Artificial Intelligence (SIE)”, Mc Graw Hill- 2008. 42
Problem Characteristics
Kevin Night and Elaine Rich, Nair B., “Artificial Intelligence (SIE)”, Mc Graw Hill- 2008. 43
Problem Characteristics
Kevin Night and Elaine Rich, Nair B., “Artificial Intelligence (SIE)”, Mc Graw Hill- 2008. 44
Problem Characteristics
4.Is a good solution absolute or relative?
Eg: Marcus was a man.
Marcus was a Pompeian.
Marcus was born in 40 A.D.
All men are mortal.
All Pompeians died when the volcano erupted in 79 A.D.
No mortal lives longer than 150 years.
It is now 2004 A.D.
Is Marcus alive? (relative)
Different reasoning paths lead to the answer.
It does not matter which path we follow.
The Travelling Salesman Problem (absolute)
We have to try all paths to find the shortest one.
• Any‐path problems can be solved using heuristics that suggest good paths to
explore.
• For best‐path problems, much more exhaustive search will be performed.
Kevin Night and Elaine Rich, Nair B., “Artificial Intelligence (SIE)”, Mc Graw Hill- 2008. 45
Problem Characteristics
Kevin Night and Elaine Rich, Nair B., “Artificial Intelligence (SIE)”, Mc Graw Hill- 2008. 47
Problem Characteristics
Kevin Night and Elaine Rich, Nair B., “Artificial Intelligence (SIE)”, Mc Graw Hill- 2008. 48
Agents
• An agent is anything that can be viewed as perceiving its environment
through sensors and acting upon that environment through actuators
• Human agent:
– eyes, ears, and other organs for sensors;
– hands, legs, mouth, and other body parts for actuators
• Robotic agent:
– cameras and infrared range finders for sensors
– various motors for actuators
• Ideal Rational Agent: For each possible percept sequence, an ideal rational agent
should select an action that is expected to maximize its performance measure,
given the evidence provided by the percept sequence and whatever built-in
knowledge the agent has.
Intelligent Agent
Intelligent Agent
I Entity that works without assistance, interprets inputs, senses
the environment, make choices and acts to achieve the goal
f :P→A
I Agent consists of architecture and program
Agents in AI
I Performance Measures is used to track the performance of an
agent
I The selected action by the agents changes the state of
environment
I If the sequence of selected actions is desirable, agent did very
well
I Performance measure based on what one actually wants from
environment
SRM
Types of Agents
I Types based on Complexity and functionality (Expected
Intelligence) of agent
I Complexity of the environment contributes contributes to
complexity of the agent architecture
I Types of Agents are,
I Table-driven agents
I Simple Reflex Agents
I Model-based reflex Agents
I Goal-based Agents
I Utility-based Agents
SRM
Table-driven Agents
I Agents are based on simple table which entries determine the
action (Percept to Percept Sequence)
I Drawbacks:
I Size of the Table
I Time to build the table
I No Autonomy
I Time required for learning
SRM
Goal-based Agents
I Goal of Decision-Making is considered
I Goal based action is very complicated and need a sequence of
actions
I Decision-Making checks the impact of actions with reference
to the goal
I Less efficient but more flexible
I More time is required for reasoning process
I Resemblance of Model-Based agents
I Goal based agents require
I Require search and planning to drive the goal
I Need to be more flexible, as knowledge supports action
SRM
SRM
Utility-Based Agents
I Selection is described by the utility function
I Utility Function is most often a real number that maps to
degree of happiness
I Complete specification of utility function helps in rational
decision-making
I Utility-based Agents can help in decision-making in following
cases
I Only certain goals could be achieved in conflicting goals with
respect to some performance measure
I Utility function maps to likelihood of success and importance
of goal in order to take decision when goals are uncertain
I Problems related to route selection and modification
SRM
Learning Agent
I Learning agent responds new or unknown scenarios in a
logical way
I Agents learn from experiences
I Two important elements in leanring agents
I Performance Agents - selection of external actions
I Learning Agents - Responsible for making improvements
I Feedback is provided for learning which makes improvements
in name of penalty or reward
I Task Generator or Problem Generator suggests actions that
generate new experiences
I Learning is the process of modification of each component of
agent to bring to reach the expected
SRM
SRM
CSP
I Any problem in the world can be mathematically represented
as CSP
I Hypothetical problem does not have constraints
I Constraint restricts movement, arrangement, possibilities and
solutions
I Example: if only concurrency notes of 2,5,10 reupees are
available and we need to give certain amount of money, say
Rs. 111 to a salesman and the total number of notes should
be between 40 and 50.
I Expressed as, Let n be number of notes,
40 < n < 50
and
c1 X1 + c2 X2 + c3 X3 = 111
SRM
CSP
I Types of Constraints
I Unary Constraints - Single variable
I Binary Constraints - Two Variables
I Higher Order Constraints - More than two variables
I CSP can be represented as Search Problem
I Initial state is empty assignment, while successor function is a
non-conflicting value assigned to an unassigned variables
I Goal test checks whether the current assignment is complete
and path cost is the cost for the path to reach the goal state
I CSP Solutions leads to the final and complete assignment
with no exception
SRM
Crypt-arithmetic Puzzles
I Cryptarithmetic puzzles are also represented as CSP
I Example:
MIKE +
JACK =
JOHN
I Replace every letter in puzzle with single number (number
should not be repeated for two different alphabets)
I The domain is { 0,1, ... , 9 }
I Often treated as the ten-variable constraint problem where
the constraints are:
I All the variables should have a different value
I The sum must work out
SRM
Cryptarithmetic Puzzles
I M * 1000 + I * 100 + K * 10 + E + J * 1000 + A * 100 +
C * 10 + K = J * 1000 + O * 100 + H * 10 + N
I Constraint Domain is represented by Five-tuple and
represented by,
D = {var , f , O, dv , rg }
I Var stands for set variables, f is set functions, O stands for
the set of legitimate operators to be used, dv is domain
variable and rg is range of function in the constraint
I Constraint without conjunction is referred as Primitive
constraint (for Eg., x < 9 )
I Constraint with conjunction is called as non-primitive
constraint or a generic constraint (For Eg., x < 9 and x > 2)
SRM
Heuristics
I MRV cannot have hold on initial selection process
I Node with maximum constraint is selected over other
unassigned variables - Degree Heuristics
I By degree heuristics, branching factor can not be reduced
I Selection of variables are considered not the values for it, so
the order in which the values of particular variable can be
arranged is tackled by least constraining value heuristic
SRM
SRM
Forward Checking
I To understand the forward checking, we shall see 4 Queens
problem
I If an arrangement on the board of a queen x, hampers the
position of queensx+1 , then this forward check ensures that
the queen x should not be placed at the selected position and
a new position is to be looked upon
SRM
SRM
Foward Checking
I Q1 and Q2 are placed in row 1 nad 2 in the left sub-tree, so,
search is halted, since No positions are left for Q3 and Q4
I Forward Checking keeps track of the next moves that are
available for the unassigned variables
I The search will be terminated when there is no legal move
available for the unassigned variables
SRM
Forward Checking
I For Room Coloring problem, Considering all the constraints
the mapping can be done in following ways;
I At first, B2 is selected with Red (R). Accordingly, R is deleted
from the adjacent nodes
I Kitchen is assigned with Blue (B). So, B is deleted form the
adjacent Nodes
I Furthermore, as MB1 is selected green, no color is left for D.
SRM
Constraint Propagation
I There is no early detection of any termination / failure that
would possible occur even though the information regarding
the decision is propagated
I Constraint should be propagated rather than the information
SRM
Constraint Propagation
I Step 2 shows the consistency propagated from D to B2
I Since D is can have only G value and B2 being adjacent to it,
the arc is drawn
I It is mapped as D → B2 or Mathematically,
non-conflicting value b ∈ B
I Failure detection can take place at early stage
SRM
Constraint Propagation
I Algorithm for arc assignment is:
I Let C be the variable which is being assigned at a given
instance
I X will have some value from D{} where D is domain
I For each and every assigned variable, that is adjacent to X,
Say X 0
1 Perform forward check (remove values from domain D that
conflict the decision of the current assignment)
2 For every other variable X 00 that are adjacent or connected to
X0 ;
i Remove the values from D from X 00 that can’t be taken as
further unassigned variables
ii Repeat step 2, till no more values can be removed or discarded
I Inconsistency is considered and constraints are propagated in
Step (2)
SRM
Intelligent Backtracking
57