SlideShare a Scribd company logo
1 of 51
Download to read offline
Module 3
PROBLEM
SOLVING
PART I
SOLVING PROBLEMS BY SEARCHING
shiwani gupta 3
Agents
• An agent is an entity that can be viewed as perceiving its
environment through sensors and acting upon that environment
through effectors/actuators to achieve goals
• Ideal, rational, human, robotic, software, autonomous
• Simple reflex, Model Based, Goal based, Utility based
• The Simple Reflex Agent will work only if the correct decision
can be made on the basis of the current percept.
SHIWANI GUPTA 4
Drawback of Simple reflex agents (Module2)
• unable to plan ahead
• limited in what they can do because their actions are determined
only by the current percept
• have no knowledge of what their actions do nor of what they are
trying to achieve.
Solution:
one kind of goal-based agent… problem-solving agent.
(Problem-solving agents decide what to do by finding sequences of
actions that lead to desirable states)
• Goal formulation based on current situation
• Problem Formulation is the process of deciding what actions and
states to consider
• Search is the process of looking for different possible sequences of
actions leading to goal state
• Execution is carrying out actions recommended as solution by search
algorithm
A goal and a set of means for achieving the goal is called a problem, and
the process of exploring what the means can do is called search
SHIWANI GUPTA 5
Problem-solving agents
(formulate - search – execute)
Problem-Solving Agent
environment
agent
?
sensors
actuators
Problem-Solving Agent
environment
agent
?
sensors
actuators
• Formulate Goal
• Formulate Problem
•States
•Actions
• Find Solution
8
Toy Problems vs.
Real-World Problems
Toy Problems
– concise and exact
description
– used for illustration
purposes
– used for performance
comparisons
• Simple to describe
• Trivial to solve
Real-World Problems
– no single, agreed-upon
description
– people care about the
solutions
• Hours to define
SHIWANI GUPTA 9
Toy problems
– Touring in Romania
– 8-Puzzle/Sliding Block Puzzle
– Robotic Assembly
– 8 Queen
– Missionaries and Cannibals
– Cryptarithmetic
– Water Jug Problem
10
Real-World Problem:
Touring in Romania
Oradea
Bucharest
Fagaras
Pitesti
Neamt
Iasi
Vaslui
Urziceni
Hirsova
Eforie
Giurgiu
Craiova
Rimnicu Vilcea
Sibiu
Dobreta
Mehadia
Lugoj
Timisoara
Arad
Zerind
120
140
151
75
70
111
118
75
71
85
90
211
101
97
138
146
80
99
87
92
142
98
86
Aim: find a course of action that satisfies a number of specified conditions
13
Touring in Romania:
Search Problem Definition
• initial state:
– In(Arad)
• possible Actions:
– DriveTo(Zerind), DriveTo(Sibiu), DriveTo(Timisoara), etc.
• goal state:
– In(Bucharest)
• step cost:
– distances between cities
SHIWANI GUPTA 14
Example: 8-puzzle
• states?
• actions?
• goal test?
• path cost?
SHIWANI GUPTA 15
8-puzzle contd.
• states? locations of tiles
• actions? move blank left, right, up, down
• goal test? = goal state (given)
• path cost? 1 per move
[Note: optimal solution of n-Puzzle family is NP-hard]
SHIWANI GUPTA 16
Example: robotic assembly
• states?
• actions?
• goal test?
• path cost?
SHIWANI GUPTA 17
Example: robotic assembly
• states?: real-valued coordinates of robot joint angles; parts of the
object to be assembled
• actions?: continuous motions of robot joints
• goal test?: complete assembly
• path cost?: time to execute
SHIWANI GUPTA 18
Example: 8 queens problem
The incremental formulation involves placing queens one by one,
whereas
the complete-state formulation starts with all 8 queens on the board
and moves them around.
In either case, the path cost is of no interest because only the final
state counts; algorithms are thus compared only on search cost.
Goal test: 8 queens on board, none attacked.
Path cost: zero.
States: any arrangement of 0 to 8 queens on board.
Operators: add a queen to any square.
SHIWANI GUPTA 19
Incremental formulation
The fact that placing a queen where it is already attacked cannot work,
because subsequent placing of other queens will not undo the attack.
So we might try the following:
States: arrangements of 0 to 8 queens with none attacked
Operators: place a queen in the left-most empty column such that it is not
attacked by any other queen
It is easy to see that the actions given
can generate only states with no attacks;
but sometimes no actions will be possible.
For example, after making the first seven
choices (left-to-right)
A quick calculation shows that there are only
Much fewer sequences to investigate.
The right formulation makes a big
difference to the size of the search space.
SHIWANI GUPTA 20
Complete formulation
• States: arrangements of 8 queens, one in each column.
• Operators: move any attacked queen to another square in the
same column.
SHIWANI GUPTA 21
Example: Missionaries and cannibals problem
(Three missionaries and three cannibals are on one side of a river, along with a boat that can
hold max two people. Find a way to get everyone to the other side, without ever leaving a group
of missionaries in one place outnumbered by the cannibals in that place)
States: a state consists of an ordered sequence of three numbers representing
the number of missionaries, cannibals, and boats on the bank of the river
from which they started. Thus, the start state is (3,3,1)
Operators: from each state the possible operators are to take either one
missionary, one cannibal, two missionaries, two cannibals, or one of each
across in the boat. Thus, there are at most five operators, although most
states have fewer because it is necessary to avoid illegal states. Note that if
we had chosen to distinguish between individual people then there would
be 27 operators instead of just 5
Goal test: reached state (0,0,1)
Path cost: number of crossings
22
Missionaries and Cannibals:
Successor Function
state set of <action, state>
(L:3m,3c,b-R:0m,0c) → {<2c, (L:3m,1c-R:0m,2c,b)>,
<1m1c, (L:2m,2c-R:1m,1c,b)>,
<1c, (L:3m,2c-R:0m,1c,b)>}
(L:3m,1c-R:0m,2c,b) → {<2c, (L:3m,3c,b-R:0m,0c) >,
<1c, (L:3m,2c,b-R:0m,1c)>}
(L:2m,2c-R:1m,1c,b) → {<1m1c, (L:3m,3c,b-R:0m,0c) >,
<1m, (L:3m,2c,b-R:0m,1c)>}
23
Missionaries and Cannibals: State
Space
1c
1m
1c
2c
1c
2c
1c
2m
1m
1c
1m
1c
1c
2c
1m
2m
1c
2c
1c
1m
SHIWANI GUPTA 24
LEFT BANK RIGHT BANK
0 Initial setup: MMMCCC B -
1 Two cannibals cross over: MMMC B CC
2 One comes back: MMMCC B C
3 Two cannibals go over again: MMM B CCC
4 One comes back: MMMC B CC
5 Two missionaries cross: MC B MMCC
6 A missionary & cannibal return: MMCC B MC
7 Two missionaries cross again: CC B MMMC
8 A cannibal returns: CCC B MMM
9 Two cannibals cross: C B MMMCC
10 One returns: CC B MMMC
11 And brings over the third: - B MMMCCC
25
Missionaries and Cannibals: Goal
State and Path Cost
• goal state:
– all missionaries, all
cannibals, and the
boat are on the right
bank.
• path cost
– step cost: 1 for each
crossing
– path cost: number of
crossings = length of path
• solution path:
– 4 optimal solutions
– cost: 11
SHIWANI GUPTA 30
Example: Cryptarithmetic
States: a cryptarithmetic puzzle with some letters replaced by digits.
Operators: replace all occurrences of a letter with a digit not already
appearing in the puzzle.
Goal test: puzzle contains only digits, and represents a correct sum.
Path cost: zero. All solutions equally valid.
One way to do this is to adopt a fixed order, e.g., alphabetical order.
A better choice is to do whichever is the most constrained substitution,
that is, the letter that has the fewest legal possibilities given the
constraints of the puzzle.
Crypt-Arithmetic puzzle
• Problem Statement:
– Solve the following puzzle by assigning numeral (0-9) in such a way that
each letter is assigned unique digit which satisfy the following addition.
– Constraints : No two letters have the same value. (The constraints of
arithmetic).
• Initial Problem State
– S = ? ; E = ? ;N = ? ; D = ? ; M = ? ;O = ? ; R = ? ;Y = ?
S E N D
+ M O R E
_________________________________
M O N E Y
_________________________________
Carries:
C4 = ? ;C3 = ? ;C2 = ? ;C1 = ?
Constraint equations:
Y = D + E C1
E = N + R + C1 C2
N = E + O + C2 C3
O = S + M + C3 C4
M = C4
C4 C3 C2 C1 Carry
S E N D
+ M O R E
_________________________________
M O N E Y
_________________________________
• We can easily see that M has to be non zero
digit, so the value of C4 =1
1. M = C4  M = 1
2. O = S + M + C3 → C4
For C4 =1, S + M + C3 > 9 
S + 1 + C3 > 9  S+C3 > 8.
If C3 = 0, then S = 9 else if C3 = 1,
then S = 8 or 9.
• We see that for S = 9
– C3 = 0 or 1
– It can be easily seen that C3 = 1 is not
possible as O = S + M + C3  O = 11 
O has to be assigned digit 1 but 1 is
already assigned to M, so not possible.
– Therefore, only choice for C3 = 0, and
thus O = 10. This implies that O is
assigned 0 (zero) digit.
• Therefore, O = 0
M = 1, O = 0
C4 C3 C2 C1 Carry
S E N D
+ M O R E
_________________________________
M O N E Y
_________________________________
Y = D + E → C1
E = N + R + C1 → C2
N = E + O + C2 → C3
O = S + M + C3 → C4
M = C4
3. Since C3 = 0; N = E + O + C2 produces no
carry.
• As O = 0, N = E + C2 .
• Since N  E, therefore, C2 = 1.
Hence N = E + 1
• Now E can take value from 2 to 8 {0,1,9
already assigned so far }
– If E = 2, then N = 3.
– Since C2 = 1, from E = N + R + C1 ,
we get 12 = N + R + C1
• If C1 = 0 then R = 9, which is not
possible as we are on the path with
S = 9
• If C1 = 1 then R = 8, then
» From Y = D + E , we get 10 +
Y= D + 2 .
» For no value of D, we can get Y.
– Try similarly for E = 3, 4. We fail in
each case.
C4 C3 C2 C1 Carry
S E N D
+ M O R E
_________________________________
M O N E Y
_________________________________
Y = D + E → C1
E = N + R + C1 → C2
N = E + O + C2 → C3
O = S + M + C3 → C4
M = C4
• If E = 5, then N = 6
– Since C2 = 1, from E = N + R + C1 ,
we get 15 = N + R + C1 ,
– If C1 = 0 then R = 9, which is not
possible as we are on the path with
S = 9.
– If C1 = 1 then R = 8, then
• From Y = D + E , we get 10 + Y=
D + 5 i.e., 5 + Y = D.
• If Y = 2 then D = 7. These values
are possible.
• Hence we get the final solution as
given below and on backtracking, we
may find more solutions.
S = 9 ; E = 5 ; N = 6 ; D = 7 ;
M = 1 ; O = 0 ; R = 8 ;Y = 2
C4 C3 C2 C1 Carry
S E N D
+ M O R E
_________________________________
M O N E Y
_________________________________
Y = D + E → C1
E = N + R + C1 → C2
N = E + O + C2 → C3
O = S + M + C3 → C4
M = C4
Constraints:
Y = D + E C1
E = N + R + C1 C2
N = E + O + C2 C3
O = S + M + C3 C4
M = C4
Initial State
M = 1 → C4 = 1
O = 1 + S + C3
O
S = 9 S = 8
O
C3 = 0 C3 = 1
O = 0 O = 1
Fixed 
M = 1
O = 0
N = E + O + C2 = E + C2 → C2 = 1 (must) → N = E + 1
E = 2 E = 3 ….. E = 5
N = 3 N = 6
E = N + R + C1 E = N + R + C1
10 + 2 = 3 + R + C1 10 + 5 = 6 + R + C1
O  O
R = 9 R = 8 R = 9 R = 8
C1 =0 C1 = 1 C1 = 0 C1 = 1
 O  O
10 + Y = D + E = D + 2 10 + Y = D + E = D + 5
O O
D = 8 D = 9 D = 7
Y = 0 Y = 1 Y = 2
   
The first solution obtained is:
M = 1, O = 0, S = 9, E = 5, N = 6, R = 8, D = 7, Y = 2
C4 C3 C2 C1  Carries
B A S E
+ B A L L
_________________________________
G A M E S
_________________________________
Constraints equations are:
E + L = S → C1
S + L + C1= E → C2
2A + C2 = M → C3
2B + C3 = A → C4
G = C4
Initial Problem State
G = ?; A = ?;M = ?; E = ?; S = ?; B = ?; L = ?
1. G = C4  G = 1
2. 2B+ C3 = A → C4
2.1 Since C4 = 1, therefore, 2B+ C3 > 9  B can take values from 5 to 9.
2.2 Try the following steps for each value of B from 5 to 9 till we get a
possible value of B.
if C3 = 0 A = 0  M = 0 for C2 = 0 or M = 1 for C2 = 1 
• If B = 5
if C3 = 1  A = 1  (as G = 1 already)
• For B = 6 we get similar contradiction while generating the search tree.
• If B = 7 , then for C3 = 0, we get A = 4  M = 8 if C2 = 0 that leads to
contradiction, so this path is pruned. If C2 = 1, then M = 9 .
3. Let us solve S + L + C1 = E and E + L = S
• Using both equations, we get 2L + C1 = 0  L = 5 and C1 = 0
• Using L = 5, we get S + 5 = E that should generate carry C2 = 1 as shown
above
• So S+5 > 9  Possible values for E are {2, 3, 6, 8} (with carry bit C2 = 1 )
• If E = 2 then S + 5 = 12  S = 7  (as B = 7 already)
• If E = 3 then S + 5 = 13  S = 8.
• Therefore E = 3 and S = 8 are fixed up.
4. Hence we get the final solution as given below and on backtracking, we may find
more solutions. In this case we get only one solution.
G = 1; A = 4; M = 9; E = 3; S = 8;B = 7; L = 5
SHIWANI GUPTA 39
MARS Each of the ten letters (m, a, r, s, v, e,
+ VENUS n, u, t, and p) represents a unique number
+ URANUS in the range 0 .. 9.
+ SATURN
------------
NEPTUNE Solution: NEPTUNE = 1078610
M=4, A=5, R=9, etc.
Water Jug Problem
• Problem Statement: "You are given two jugs, a
4-gallon one and a 3-gallon one. Neither has
any measuring markers on it. There is a tap
that can be used to fill the jugs with water.
How can you get exactly 2 gallons of water
into the 4-gallon jug?"
SHIWANI GUPTA 40
Production Rules
Rules Conclusions
R1:(X, Y | X < 4) → (4, Y) {Fill 4-gallon jug}
R2:(X, Y | Y < 3) →(X, 3) {Fill 3-gallon jug}
R3:(X, Y | X > 0) →(0, Y) {Empty 4-gallon jug}
R4:(X, Y | Y > 0) →(X, 0) {Empty 3-gallon jug}
R5:(X, Y | X+Y >= 4 ΛY > 0) →(4, Y –(4 –X)) {Pour water from 3-gallon jug into 4-
gallon jug until 4-gallon jug is full}
R6:(X, Y | X+Y >= 3 ΛX > 0) →(X –(3 –Y), 3)) {Pour water from 4-gallon jug into 3-
gallon jug until 3-gallon jug is full}
R7:(X, Y | X+Y <= 4 ΛY > 0) → (X+Y, 0) {Pour all water from 3-gallon jug into 4- gallon jug }
R8:(X, Y | X+Y <= 3 ΛX > 0) →(0, X+Y) {Pour all water from 4-gallon jug into 3- gallon jug }
R9:(X, Y | X > 0) → (X –D, Y) {Pour some water D out from 4- gallon jug}
R10:(X, Y | Y > 0) →(X, Y -D) {Pour some water D out from 3- gallon jug}
SHIWANI GUPTA 41
SHIWANI GUPTA 42
2 0
Number Rules applied 4-g jug 3-g jug
of steps
1 Initial State 0 0
2 R1 {Fill 4-gallon jug} 4 0
3 R6 {Pour from 4 to 3-g jug until it is full } 1 3
4 R4 {Empty 3-gallon jug} 1 0
5 R8 {Pour all water from 4 to 3-gallon jug} 0 1
6 R1 {Fill 4-gallon jug} 4 1
7 R6 {Pour from 4 to 3-g jug until it is full} 2 3
8 R4 {Empty 3-gallon jug}
Goal State
Solution
Water Jug Problem
Given a full 5-gallon jug and a full 2-gallon jug, fill the 2-gallon jug with
exactly one gallon of water.
• State: ?
• Initial State: ?
• Operators: ?
• Goal State: ?
5
2
SHIWANI GUPTA 45
Real World problems
• Route Finding applications, such as routing in computer networks,
automated travel advisory systems, and airline travel planning systems.
• Touring and traveling salesperson problem is a famous touring problem
in which each city must be visited exactly once. The aim is to find the
shortest tour.
• VLSI layout with cell layout and channel routing.
• Robot navigation is a generalization of the route-finding problem
described earlier. Rather than a discrete set of routes, a robot can move in a
continuous space with (in principle) an infinite set of possible actions and
states.
• Assembly sequencing of complex objects by a robot, the problem is to
find an order in which to assemble the parts of some object. If the wrong
order is chosen, there will be no way to add some part later in the sequence
without undoing some of the work already done.
• Monkey Banana Problem
General Route Finding Problem
• Problem Statement
• States: Locations
• Initial State: Starting Point
• Successor Function(Operators): Move from one location
to other
• Goal Test: Arrive at certain location
• Path Cost: Money, time, travel, comfort, scenery,…
SHIWANI GUPTA 46
Travelling Salesman Problem
• Problem Statement
• States: Locations/cities
• Initial State: Starting Point
• Successor Function(Operators): Move from one location
to other
• Goal Test: All locations visited, Agent at initial location
• Path Cost: Distance between locations
SHIWANI GUPTA 47
VLSI layout problem
• Problem Statement
• States: Positions of components, wires on chip
• Initial State:
– Incremental
– Complete State
• Successor Function(Operators)
– Incremental
– Complete State
• Goal Test: All components placed and connected as specified
• Path Cost: distance, capacity, no. of connections per component
SHIWANI GUPTA 48
Robot Navigation
• Problem Statement
• States: Locations, Position of actuator
• Initial State: Start pos
• Successor Function(Operators): Movement, actions of
actuators
• Goal Test: Task Dependent
• Path Cost: Distance, Energy consumption
SHIWANI GUPTA 49
Assembly Sequencing
• Problem Statement
• States: Location of components
• Initial State: No components assembled
• Successor Function(Operators): Place component
• Goal Test: System fully assembled
• Path Cost: Number of moves
SHIWANI GUPTA 50
Monkey Banana Problem
• Problem Statement
• States:
• Initial State: Monkey on the floor without bananas
• Successor Function(Operators)
• Goal Test
• Path Cost: The number of moves by monkey to get bananas
SHIWANI GUPTA 51
Search Problem
• State space
– each state is an abstract representation of the
environment
– the state space is discrete
• Initial state
• Successor function
• Goal test
• Path cost
Search Problem
• State space
• Initial state:
– usually the current state
– sometimes one or several hypothetical states
(“what if …”)
• Successor function
• Goal test
• Path cost
Search Problem
• State space
• Initial state
• Successor function:
– [state → subset of states]
– an abstract representation of the possible actions
• Goal test
• Path cost
Search Problem
• State space
• Initial state
• Successor function
• Goal test:
– usually a condition
– sometimes the description of a state
• Path cost
Search Problem
• State space
• Initial state
• Successor function
• Goal test
• Path cost:
– [path → positive number]
– usually, path cost = sum of step costs
– e.g., number of moves of the empty tile
Assumptions in Basic Search
• The environment is static
• The environment is discretizable
• The environment is observable
• The actions are deterministic
University Questions
• Solve the following Crypt arithmetic problem:
FORTY
CROSS SEND BASE TEN EAT
ROADS MORE BALL TEN THAT
DANGER MONEY GAMES SIXTY APPLE
• You are given 2 jugs of cap 4l and 3l each. Neither of the jugs have
any measuring markers on them. There is a pump that can be used to
fill jugs with water. How can u get exactly 2l of water in 4l jug?
Formulate the problem in state space and draw complete diagram
• Consider jugs of volumes 3 and 7 units are available. Show the trace
to measure 2 and 5 units.
• Solve Wolf Goat Cabbage problem.

More Related Content

What's hot

What's hot (20)

Logical Agents
Logical AgentsLogical Agents
Logical Agents
 
First order logic
First order logicFirst order logic
First order logic
 
Adversarial search
Adversarial search Adversarial search
Adversarial search
 
AI simple search strategies
AI simple search strategiesAI simple search strategies
AI simple search strategies
 
Lecture 06 production system
Lecture 06 production systemLecture 06 production system
Lecture 06 production system
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptx
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Artificial intelligence- Logic Agents
Artificial intelligence- Logic AgentsArtificial intelligence- Logic Agents
Artificial intelligence- Logic Agents
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
8 queens problem using ga
8 queens problem using ga8 queens problem using ga
8 queens problem using ga
 
Backtracking
Backtracking  Backtracking
Backtracking
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search Strategies
 
Planning
Planning Planning
Planning
 
A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
 
Knowledge Representation & Reasoning
Knowledge Representation & ReasoningKnowledge Representation & Reasoning
Knowledge Representation & Reasoning
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
 
Knapsack problem using fixed tuple
Knapsack problem using fixed tupleKnapsack problem using fixed tuple
Knapsack problem using fixed tuple
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy Algorithm
 

Similar to Problem solving

AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjekAIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjekpavan402055
 
Popular search algorithms
Popular search algorithmsPopular search algorithms
Popular search algorithmsMinakshi Atre
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Techglyphs
 
Lecture is related to the topic of Artificial intelligence
Lecture is related to the topic of Artificial intelligenceLecture is related to the topic of Artificial intelligence
Lecture is related to the topic of Artificial intelligencemohsinwaseer1
 
May 19, 2014
May 19, 2014May 19, 2014
May 19, 2014khyps13
 
Discrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryDiscrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryMark Simon
 
Circle & curve clipping algorithm
Circle & curve clipping algorithmCircle & curve clipping algorithm
Circle & curve clipping algorithmMohamed El-Serngawy
 
Reinfrocement Learning
Reinfrocement LearningReinfrocement Learning
Reinfrocement LearningNatan Katz
 
5.5 back track
5.5 back track5.5 back track
5.5 back trackKrish_ver2
 
Unit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxUnit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxssuser01e301
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematicsMark Simon
 
Spearman's Rank calculations
Spearman's Rank calculationsSpearman's Rank calculations
Spearman's Rank calculationsGuerillateacher
 

Similar to Problem solving (20)

chapter3part1.ppt
chapter3part1.pptchapter3part1.ppt
chapter3part1.ppt
 
Lop1
Lop1Lop1
Lop1
 
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjekAIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
 
Lec2 state space
Lec2 state spaceLec2 state space
Lec2 state space
 
Popular search algorithms
Popular search algorithmsPopular search algorithms
Popular search algorithms
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1
 
Lecture is related to the topic of Artificial intelligence
Lecture is related to the topic of Artificial intelligenceLecture is related to the topic of Artificial intelligence
Lecture is related to the topic of Artificial intelligence
 
May 19, 2014
May 19, 2014May 19, 2014
May 19, 2014
 
Discrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryDiscrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata Theory
 
Circle & curve clipping algorithm
Circle & curve clipping algorithmCircle & curve clipping algorithm
Circle & curve clipping algorithm
 
Lecture 3 Problem Solving.pptx
Lecture 3 Problem Solving.pptxLecture 3 Problem Solving.pptx
Lecture 3 Problem Solving.pptx
 
Reinfrocement Learning
Reinfrocement LearningReinfrocement Learning
Reinfrocement Learning
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
 
Unit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxUnit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptx
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematics
 
algorithm Unit 3
algorithm Unit 3algorithm Unit 3
algorithm Unit 3
 
Spearman's Rank calculations
Spearman's Rank calculationsSpearman's Rank calculations
Spearman's Rank calculations
 
state-spaces29Sep06.ppt
state-spaces29Sep06.pptstate-spaces29Sep06.ppt
state-spaces29Sep06.ppt
 
CRYPTO 2.pptx
CRYPTO 2.pptxCRYPTO 2.pptx
CRYPTO 2.pptx
 

More from Shiwani Gupta

module6_stringmatchingalgorithm_2022.pdf
module6_stringmatchingalgorithm_2022.pdfmodule6_stringmatchingalgorithm_2022.pdf
module6_stringmatchingalgorithm_2022.pdfShiwani Gupta
 
module5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdfmodule5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdfShiwani Gupta
 
module4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfmodule4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfShiwani Gupta
 
module3_Greedymethod_2022.pdf
module3_Greedymethod_2022.pdfmodule3_Greedymethod_2022.pdf
module3_Greedymethod_2022.pdfShiwani Gupta
 
module2_dIVIDEncONQUER_2022.pdf
module2_dIVIDEncONQUER_2022.pdfmodule2_dIVIDEncONQUER_2022.pdf
module2_dIVIDEncONQUER_2022.pdfShiwani Gupta
 
module1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdfmodule1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdfShiwani Gupta
 
ML MODULE 1_slideshare.pdf
ML MODULE 1_slideshare.pdfML MODULE 1_slideshare.pdf
ML MODULE 1_slideshare.pdfShiwani Gupta
 
Functionsandpigeonholeprinciple
FunctionsandpigeonholeprincipleFunctionsandpigeonholeprinciple
FunctionsandpigeonholeprincipleShiwani Gupta
 
Uncertain knowledge and reasoning
Uncertain knowledge and reasoningUncertain knowledge and reasoning
Uncertain knowledge and reasoningShiwani Gupta
 

More from Shiwani Gupta (20)

ML MODULE 6.pdf
ML MODULE 6.pdfML MODULE 6.pdf
ML MODULE 6.pdf
 
ML MODULE 5.pdf
ML MODULE 5.pdfML MODULE 5.pdf
ML MODULE 5.pdf
 
ML MODULE 4.pdf
ML MODULE 4.pdfML MODULE 4.pdf
ML MODULE 4.pdf
 
module6_stringmatchingalgorithm_2022.pdf
module6_stringmatchingalgorithm_2022.pdfmodule6_stringmatchingalgorithm_2022.pdf
module6_stringmatchingalgorithm_2022.pdf
 
module5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdfmodule5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdf
 
module4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfmodule4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdf
 
module3_Greedymethod_2022.pdf
module3_Greedymethod_2022.pdfmodule3_Greedymethod_2022.pdf
module3_Greedymethod_2022.pdf
 
module2_dIVIDEncONQUER_2022.pdf
module2_dIVIDEncONQUER_2022.pdfmodule2_dIVIDEncONQUER_2022.pdf
module2_dIVIDEncONQUER_2022.pdf
 
module1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdfmodule1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdf
 
ML MODULE 1_slideshare.pdf
ML MODULE 1_slideshare.pdfML MODULE 1_slideshare.pdf
ML MODULE 1_slideshare.pdf
 
ML MODULE 2.pdf
ML MODULE 2.pdfML MODULE 2.pdf
ML MODULE 2.pdf
 
ML Module 3.pdf
ML Module 3.pdfML Module 3.pdf
ML Module 3.pdf
 
Problem formulation
Problem formulationProblem formulation
Problem formulation
 
Simplex method
Simplex methodSimplex method
Simplex method
 
Functionsandpigeonholeprinciple
FunctionsandpigeonholeprincipleFunctionsandpigeonholeprinciple
Functionsandpigeonholeprinciple
 
Relations
RelationsRelations
Relations
 
Logic
LogicLogic
Logic
 
Set theory
Set theorySet theory
Set theory
 
Uncertain knowledge and reasoning
Uncertain knowledge and reasoningUncertain knowledge and reasoning
Uncertain knowledge and reasoning
 
Introduction to ai
Introduction to aiIntroduction to ai
Introduction to ai
 

Recently uploaded

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 

Problem solving

  • 2. PART I SOLVING PROBLEMS BY SEARCHING
  • 3. shiwani gupta 3 Agents • An agent is an entity that can be viewed as perceiving its environment through sensors and acting upon that environment through effectors/actuators to achieve goals • Ideal, rational, human, robotic, software, autonomous • Simple reflex, Model Based, Goal based, Utility based • The Simple Reflex Agent will work only if the correct decision can be made on the basis of the current percept.
  • 4. SHIWANI GUPTA 4 Drawback of Simple reflex agents (Module2) • unable to plan ahead • limited in what they can do because their actions are determined only by the current percept • have no knowledge of what their actions do nor of what they are trying to achieve. Solution: one kind of goal-based agent… problem-solving agent. (Problem-solving agents decide what to do by finding sequences of actions that lead to desirable states) • Goal formulation based on current situation • Problem Formulation is the process of deciding what actions and states to consider • Search is the process of looking for different possible sequences of actions leading to goal state • Execution is carrying out actions recommended as solution by search algorithm A goal and a set of means for achieving the goal is called a problem, and the process of exploring what the means can do is called search
  • 5. SHIWANI GUPTA 5 Problem-solving agents (formulate - search – execute)
  • 7. Problem-Solving Agent environment agent ? sensors actuators • Formulate Goal • Formulate Problem •States •Actions • Find Solution
  • 8. 8 Toy Problems vs. Real-World Problems Toy Problems – concise and exact description – used for illustration purposes – used for performance comparisons • Simple to describe • Trivial to solve Real-World Problems – no single, agreed-upon description – people care about the solutions • Hours to define
  • 9. SHIWANI GUPTA 9 Toy problems – Touring in Romania – 8-Puzzle/Sliding Block Puzzle – Robotic Assembly – 8 Queen – Missionaries and Cannibals – Cryptarithmetic – Water Jug Problem
  • 10. 10 Real-World Problem: Touring in Romania Oradea Bucharest Fagaras Pitesti Neamt Iasi Vaslui Urziceni Hirsova Eforie Giurgiu Craiova Rimnicu Vilcea Sibiu Dobreta Mehadia Lugoj Timisoara Arad Zerind 120 140 151 75 70 111 118 75 71 85 90 211 101 97 138 146 80 99 87 92 142 98 86 Aim: find a course of action that satisfies a number of specified conditions
  • 11. 13 Touring in Romania: Search Problem Definition • initial state: – In(Arad) • possible Actions: – DriveTo(Zerind), DriveTo(Sibiu), DriveTo(Timisoara), etc. • goal state: – In(Bucharest) • step cost: – distances between cities
  • 12. SHIWANI GUPTA 14 Example: 8-puzzle • states? • actions? • goal test? • path cost?
  • 13. SHIWANI GUPTA 15 8-puzzle contd. • states? locations of tiles • actions? move blank left, right, up, down • goal test? = goal state (given) • path cost? 1 per move [Note: optimal solution of n-Puzzle family is NP-hard]
  • 14. SHIWANI GUPTA 16 Example: robotic assembly • states? • actions? • goal test? • path cost?
  • 15. SHIWANI GUPTA 17 Example: robotic assembly • states?: real-valued coordinates of robot joint angles; parts of the object to be assembled • actions?: continuous motions of robot joints • goal test?: complete assembly • path cost?: time to execute
  • 16. SHIWANI GUPTA 18 Example: 8 queens problem The incremental formulation involves placing queens one by one, whereas the complete-state formulation starts with all 8 queens on the board and moves them around. In either case, the path cost is of no interest because only the final state counts; algorithms are thus compared only on search cost. Goal test: 8 queens on board, none attacked. Path cost: zero. States: any arrangement of 0 to 8 queens on board. Operators: add a queen to any square.
  • 17. SHIWANI GUPTA 19 Incremental formulation The fact that placing a queen where it is already attacked cannot work, because subsequent placing of other queens will not undo the attack. So we might try the following: States: arrangements of 0 to 8 queens with none attacked Operators: place a queen in the left-most empty column such that it is not attacked by any other queen It is easy to see that the actions given can generate only states with no attacks; but sometimes no actions will be possible. For example, after making the first seven choices (left-to-right) A quick calculation shows that there are only Much fewer sequences to investigate. The right formulation makes a big difference to the size of the search space.
  • 18. SHIWANI GUPTA 20 Complete formulation • States: arrangements of 8 queens, one in each column. • Operators: move any attacked queen to another square in the same column.
  • 19. SHIWANI GUPTA 21 Example: Missionaries and cannibals problem (Three missionaries and three cannibals are on one side of a river, along with a boat that can hold max two people. Find a way to get everyone to the other side, without ever leaving a group of missionaries in one place outnumbered by the cannibals in that place) States: a state consists of an ordered sequence of three numbers representing the number of missionaries, cannibals, and boats on the bank of the river from which they started. Thus, the start state is (3,3,1) Operators: from each state the possible operators are to take either one missionary, one cannibal, two missionaries, two cannibals, or one of each across in the boat. Thus, there are at most five operators, although most states have fewer because it is necessary to avoid illegal states. Note that if we had chosen to distinguish between individual people then there would be 27 operators instead of just 5 Goal test: reached state (0,0,1) Path cost: number of crossings
  • 20. 22 Missionaries and Cannibals: Successor Function state set of <action, state> (L:3m,3c,b-R:0m,0c) → {<2c, (L:3m,1c-R:0m,2c,b)>, <1m1c, (L:2m,2c-R:1m,1c,b)>, <1c, (L:3m,2c-R:0m,1c,b)>} (L:3m,1c-R:0m,2c,b) → {<2c, (L:3m,3c,b-R:0m,0c) >, <1c, (L:3m,2c,b-R:0m,1c)>} (L:2m,2c-R:1m,1c,b) → {<1m1c, (L:3m,3c,b-R:0m,0c) >, <1m, (L:3m,2c,b-R:0m,1c)>}
  • 21. 23 Missionaries and Cannibals: State Space 1c 1m 1c 2c 1c 2c 1c 2m 1m 1c 1m 1c 1c 2c 1m 2m 1c 2c 1c 1m
  • 22. SHIWANI GUPTA 24 LEFT BANK RIGHT BANK 0 Initial setup: MMMCCC B - 1 Two cannibals cross over: MMMC B CC 2 One comes back: MMMCC B C 3 Two cannibals go over again: MMM B CCC 4 One comes back: MMMC B CC 5 Two missionaries cross: MC B MMCC 6 A missionary & cannibal return: MMCC B MC 7 Two missionaries cross again: CC B MMMC 8 A cannibal returns: CCC B MMM 9 Two cannibals cross: C B MMMCC 10 One returns: CC B MMMC 11 And brings over the third: - B MMMCCC
  • 23. 25 Missionaries and Cannibals: Goal State and Path Cost • goal state: – all missionaries, all cannibals, and the boat are on the right bank. • path cost – step cost: 1 for each crossing – path cost: number of crossings = length of path • solution path: – 4 optimal solutions – cost: 11
  • 24. SHIWANI GUPTA 30 Example: Cryptarithmetic States: a cryptarithmetic puzzle with some letters replaced by digits. Operators: replace all occurrences of a letter with a digit not already appearing in the puzzle. Goal test: puzzle contains only digits, and represents a correct sum. Path cost: zero. All solutions equally valid. One way to do this is to adopt a fixed order, e.g., alphabetical order. A better choice is to do whichever is the most constrained substitution, that is, the letter that has the fewest legal possibilities given the constraints of the puzzle.
  • 25. Crypt-Arithmetic puzzle • Problem Statement: – Solve the following puzzle by assigning numeral (0-9) in such a way that each letter is assigned unique digit which satisfy the following addition. – Constraints : No two letters have the same value. (The constraints of arithmetic). • Initial Problem State – S = ? ; E = ? ;N = ? ; D = ? ; M = ? ;O = ? ; R = ? ;Y = ? S E N D + M O R E _________________________________ M O N E Y _________________________________
  • 26. Carries: C4 = ? ;C3 = ? ;C2 = ? ;C1 = ? Constraint equations: Y = D + E C1 E = N + R + C1 C2 N = E + O + C2 C3 O = S + M + C3 C4 M = C4 C4 C3 C2 C1 Carry S E N D + M O R E _________________________________ M O N E Y _________________________________
  • 27. • We can easily see that M has to be non zero digit, so the value of C4 =1 1. M = C4  M = 1 2. O = S + M + C3 → C4 For C4 =1, S + M + C3 > 9  S + 1 + C3 > 9  S+C3 > 8. If C3 = 0, then S = 9 else if C3 = 1, then S = 8 or 9. • We see that for S = 9 – C3 = 0 or 1 – It can be easily seen that C3 = 1 is not possible as O = S + M + C3  O = 11  O has to be assigned digit 1 but 1 is already assigned to M, so not possible. – Therefore, only choice for C3 = 0, and thus O = 10. This implies that O is assigned 0 (zero) digit. • Therefore, O = 0 M = 1, O = 0 C4 C3 C2 C1 Carry S E N D + M O R E _________________________________ M O N E Y _________________________________ Y = D + E → C1 E = N + R + C1 → C2 N = E + O + C2 → C3 O = S + M + C3 → C4 M = C4
  • 28. 3. Since C3 = 0; N = E + O + C2 produces no carry. • As O = 0, N = E + C2 . • Since N  E, therefore, C2 = 1. Hence N = E + 1 • Now E can take value from 2 to 8 {0,1,9 already assigned so far } – If E = 2, then N = 3. – Since C2 = 1, from E = N + R + C1 , we get 12 = N + R + C1 • If C1 = 0 then R = 9, which is not possible as we are on the path with S = 9 • If C1 = 1 then R = 8, then » From Y = D + E , we get 10 + Y= D + 2 . » For no value of D, we can get Y. – Try similarly for E = 3, 4. We fail in each case. C4 C3 C2 C1 Carry S E N D + M O R E _________________________________ M O N E Y _________________________________ Y = D + E → C1 E = N + R + C1 → C2 N = E + O + C2 → C3 O = S + M + C3 → C4 M = C4
  • 29. • If E = 5, then N = 6 – Since C2 = 1, from E = N + R + C1 , we get 15 = N + R + C1 , – If C1 = 0 then R = 9, which is not possible as we are on the path with S = 9. – If C1 = 1 then R = 8, then • From Y = D + E , we get 10 + Y= D + 5 i.e., 5 + Y = D. • If Y = 2 then D = 7. These values are possible. • Hence we get the final solution as given below and on backtracking, we may find more solutions. S = 9 ; E = 5 ; N = 6 ; D = 7 ; M = 1 ; O = 0 ; R = 8 ;Y = 2 C4 C3 C2 C1 Carry S E N D + M O R E _________________________________ M O N E Y _________________________________ Y = D + E → C1 E = N + R + C1 → C2 N = E + O + C2 → C3 O = S + M + C3 → C4 M = C4
  • 30. Constraints: Y = D + E C1 E = N + R + C1 C2 N = E + O + C2 C3 O = S + M + C3 C4 M = C4 Initial State M = 1 → C4 = 1 O = 1 + S + C3 O S = 9 S = 8 O C3 = 0 C3 = 1 O = 0 O = 1 Fixed  M = 1 O = 0 N = E + O + C2 = E + C2 → C2 = 1 (must) → N = E + 1 E = 2 E = 3 ….. E = 5 N = 3 N = 6 E = N + R + C1 E = N + R + C1 10 + 2 = 3 + R + C1 10 + 5 = 6 + R + C1 O  O R = 9 R = 8 R = 9 R = 8 C1 =0 C1 = 1 C1 = 0 C1 = 1  O  O 10 + Y = D + E = D + 2 10 + Y = D + E = D + 5 O O D = 8 D = 9 D = 7 Y = 0 Y = 1 Y = 2     The first solution obtained is: M = 1, O = 0, S = 9, E = 5, N = 6, R = 8, D = 7, Y = 2
  • 31. C4 C3 C2 C1  Carries B A S E + B A L L _________________________________ G A M E S _________________________________ Constraints equations are: E + L = S → C1 S + L + C1= E → C2 2A + C2 = M → C3 2B + C3 = A → C4 G = C4 Initial Problem State G = ?; A = ?;M = ?; E = ?; S = ?; B = ?; L = ?
  • 32. 1. G = C4  G = 1 2. 2B+ C3 = A → C4 2.1 Since C4 = 1, therefore, 2B+ C3 > 9  B can take values from 5 to 9. 2.2 Try the following steps for each value of B from 5 to 9 till we get a possible value of B. if C3 = 0 A = 0  M = 0 for C2 = 0 or M = 1 for C2 = 1  • If B = 5 if C3 = 1  A = 1  (as G = 1 already) • For B = 6 we get similar contradiction while generating the search tree. • If B = 7 , then for C3 = 0, we get A = 4  M = 8 if C2 = 0 that leads to contradiction, so this path is pruned. If C2 = 1, then M = 9 . 3. Let us solve S + L + C1 = E and E + L = S • Using both equations, we get 2L + C1 = 0  L = 5 and C1 = 0 • Using L = 5, we get S + 5 = E that should generate carry C2 = 1 as shown above • So S+5 > 9  Possible values for E are {2, 3, 6, 8} (with carry bit C2 = 1 ) • If E = 2 then S + 5 = 12  S = 7  (as B = 7 already) • If E = 3 then S + 5 = 13  S = 8. • Therefore E = 3 and S = 8 are fixed up. 4. Hence we get the final solution as given below and on backtracking, we may find more solutions. In this case we get only one solution. G = 1; A = 4; M = 9; E = 3; S = 8;B = 7; L = 5
  • 33. SHIWANI GUPTA 39 MARS Each of the ten letters (m, a, r, s, v, e, + VENUS n, u, t, and p) represents a unique number + URANUS in the range 0 .. 9. + SATURN ------------ NEPTUNE Solution: NEPTUNE = 1078610 M=4, A=5, R=9, etc.
  • 34. Water Jug Problem • Problem Statement: "You are given two jugs, a 4-gallon one and a 3-gallon one. Neither has any measuring markers on it. There is a tap that can be used to fill the jugs with water. How can you get exactly 2 gallons of water into the 4-gallon jug?" SHIWANI GUPTA 40
  • 35. Production Rules Rules Conclusions R1:(X, Y | X < 4) → (4, Y) {Fill 4-gallon jug} R2:(X, Y | Y < 3) →(X, 3) {Fill 3-gallon jug} R3:(X, Y | X > 0) →(0, Y) {Empty 4-gallon jug} R4:(X, Y | Y > 0) →(X, 0) {Empty 3-gallon jug} R5:(X, Y | X+Y >= 4 ΛY > 0) →(4, Y –(4 –X)) {Pour water from 3-gallon jug into 4- gallon jug until 4-gallon jug is full} R6:(X, Y | X+Y >= 3 ΛX > 0) →(X –(3 –Y), 3)) {Pour water from 4-gallon jug into 3- gallon jug until 3-gallon jug is full} R7:(X, Y | X+Y <= 4 ΛY > 0) → (X+Y, 0) {Pour all water from 3-gallon jug into 4- gallon jug } R8:(X, Y | X+Y <= 3 ΛX > 0) →(0, X+Y) {Pour all water from 4-gallon jug into 3- gallon jug } R9:(X, Y | X > 0) → (X –D, Y) {Pour some water D out from 4- gallon jug} R10:(X, Y | Y > 0) →(X, Y -D) {Pour some water D out from 3- gallon jug} SHIWANI GUPTA 41
  • 36. SHIWANI GUPTA 42 2 0 Number Rules applied 4-g jug 3-g jug of steps 1 Initial State 0 0 2 R1 {Fill 4-gallon jug} 4 0 3 R6 {Pour from 4 to 3-g jug until it is full } 1 3 4 R4 {Empty 3-gallon jug} 1 0 5 R8 {Pour all water from 4 to 3-gallon jug} 0 1 6 R1 {Fill 4-gallon jug} 4 1 7 R6 {Pour from 4 to 3-g jug until it is full} 2 3 8 R4 {Empty 3-gallon jug} Goal State Solution
  • 37. Water Jug Problem Given a full 5-gallon jug and a full 2-gallon jug, fill the 2-gallon jug with exactly one gallon of water. • State: ? • Initial State: ? • Operators: ? • Goal State: ? 5 2
  • 38. SHIWANI GUPTA 45 Real World problems • Route Finding applications, such as routing in computer networks, automated travel advisory systems, and airline travel planning systems. • Touring and traveling salesperson problem is a famous touring problem in which each city must be visited exactly once. The aim is to find the shortest tour. • VLSI layout with cell layout and channel routing. • Robot navigation is a generalization of the route-finding problem described earlier. Rather than a discrete set of routes, a robot can move in a continuous space with (in principle) an infinite set of possible actions and states. • Assembly sequencing of complex objects by a robot, the problem is to find an order in which to assemble the parts of some object. If the wrong order is chosen, there will be no way to add some part later in the sequence without undoing some of the work already done. • Monkey Banana Problem
  • 39. General Route Finding Problem • Problem Statement • States: Locations • Initial State: Starting Point • Successor Function(Operators): Move from one location to other • Goal Test: Arrive at certain location • Path Cost: Money, time, travel, comfort, scenery,… SHIWANI GUPTA 46
  • 40. Travelling Salesman Problem • Problem Statement • States: Locations/cities • Initial State: Starting Point • Successor Function(Operators): Move from one location to other • Goal Test: All locations visited, Agent at initial location • Path Cost: Distance between locations SHIWANI GUPTA 47
  • 41. VLSI layout problem • Problem Statement • States: Positions of components, wires on chip • Initial State: – Incremental – Complete State • Successor Function(Operators) – Incremental – Complete State • Goal Test: All components placed and connected as specified • Path Cost: distance, capacity, no. of connections per component SHIWANI GUPTA 48
  • 42. Robot Navigation • Problem Statement • States: Locations, Position of actuator • Initial State: Start pos • Successor Function(Operators): Movement, actions of actuators • Goal Test: Task Dependent • Path Cost: Distance, Energy consumption SHIWANI GUPTA 49
  • 43. Assembly Sequencing • Problem Statement • States: Location of components • Initial State: No components assembled • Successor Function(Operators): Place component • Goal Test: System fully assembled • Path Cost: Number of moves SHIWANI GUPTA 50
  • 44. Monkey Banana Problem • Problem Statement • States: • Initial State: Monkey on the floor without bananas • Successor Function(Operators) • Goal Test • Path Cost: The number of moves by monkey to get bananas SHIWANI GUPTA 51
  • 45. Search Problem • State space – each state is an abstract representation of the environment – the state space is discrete • Initial state • Successor function • Goal test • Path cost
  • 46. Search Problem • State space • Initial state: – usually the current state – sometimes one or several hypothetical states (“what if …”) • Successor function • Goal test • Path cost
  • 47. Search Problem • State space • Initial state • Successor function: – [state → subset of states] – an abstract representation of the possible actions • Goal test • Path cost
  • 48. Search Problem • State space • Initial state • Successor function • Goal test: – usually a condition – sometimes the description of a state • Path cost
  • 49. Search Problem • State space • Initial state • Successor function • Goal test • Path cost: – [path → positive number] – usually, path cost = sum of step costs – e.g., number of moves of the empty tile
  • 50. Assumptions in Basic Search • The environment is static • The environment is discretizable • The environment is observable • The actions are deterministic
  • 51. University Questions • Solve the following Crypt arithmetic problem: FORTY CROSS SEND BASE TEN EAT ROADS MORE BALL TEN THAT DANGER MONEY GAMES SIXTY APPLE • You are given 2 jugs of cap 4l and 3l each. Neither of the jugs have any measuring markers on them. There is a pump that can be used to fill jugs with water. How can u get exactly 2l of water in 4l jug? Formulate the problem in state space and draw complete diagram • Consider jugs of volumes 3 and 7 units are available. Show the trace to measure 2 and 5 units. • Solve Wolf Goat Cabbage problem.