Elevate Developer Efficiency & build GenAI Application with Amazon Q
Problems problem spaces and search
1. Mr. Amey D. S. Kerkar,
Asst. Professor ,
Computer Engineering Department,
Don Bosco College of Engineering,
Fatorda-Goa.
2. Terminologies:
State – Configuration of the game at any Point
1. State Space
- Description of all possible states reachable from initial
state.
Forms a graph.
Nodes = States
Arcs= actions
2. Initial State
3. Goal State
4. Path Cost
3. 5. Production Rules:
Rules/actions/operators applied to the current state. Results into
the next state.
rule: XY
Where, LHS represents current state in problem space
RHS is the resultant state.
6. Production System
- AI system developed for the solution of any problem.
Components of Production System:
1. Production Rules
2. Knowledge Base(KB)
3. Control Strategy- Order in which rule is applied compared to
Database/Knowledge base rules
4. Rule applier- checks current state with LHS of rules in KB and
finds appropriate rule to apply.
4. Example 1: 8-Puzzle Problem
7 4 2
1 5
6 3 8
Initial State
1 2 3
8 4
7 6 5
Initial State
Rules /Operators/Actions: 1. Move blank tile UP
2. Move blank tile DOWN
3. Move blank tile LEFT
4. Move blank tile RIGHT
Control Strategy= Search Technique.
Types of Search Techniques:
1. Uninformed/ Blind Search
2. Informed Search
5. Problem Formulation for 8 puzzle:
- Data Structure: 3 x 3 vector used for board
- Blank Tile is represented with ‘B’
- Numbered tiles are represented with corresponding
tile number
- Ex: 7 4 2
1 5
6 3 8
Is represented as:
7 4 2
1 𝑩 5
6 3 8
7. Search Process contains:
1. Expanding a node
2. Generating a node
3. Comparing
4. Tracking the path and path cost
Terminologies: 1.Generated node
2. Explored node
8. Example 2: TIC-TAC-TOE Problem
Initial state
X X X
X X X
X X X
X
X
X
X
X
X
5 POSSIBLE GOAL STATES FOR PLAYER 1
Player 1 will mark X
Player 2 will mark O
9. Problem Formulation for TIC-TAC-TOE:
- Data Structure: 3 x 3 vector used for board
- Blank Cell is represented with ‘0’
- Cell with ‘X’ marking represented with ‘1’
- Cell with ‘O’ marking represented with ‘2’
- Ex: Initial state 0 0 0
0 𝟎 0
0 0 0
0 0 X
X 0
X 0
- One of the
Goal State :
2 2 1
0 𝟏 2
1 2 0
10. Problem Formulation:
Each state= ordered pair {X,Y}
Where,
X= amount of water contained in Jar 1 (4 gallon capacity)
at any time.
Y=amount of water contained in Jar 2 (3 gallon capacity)
at any time.
Initial state: {0,0}
Final state: { P, 2}, Where P is any amount of water.
Example 3: Water Jug Problem
11. Production Rules:
RULE 1: (X,Y)(4,Y) [fill 4 gallon jug. Applicable if X<4]
RULE 2: (X,Y)(X,3) [fill 3 gallon jug. Applicable if Y<3]
RULE 3: (X,Y)(X-X1,Y) [pour some water out of 4 gallons jar]
RULE 4: (X,Y)(X,Y-X1) [pour some water out of 3 gallons jar]
RULE 5: (X,Y)(0,Y) [Empty 4 gallon jar]
RULE 6: (X,Y)(X,0) [Empty 3 gallon jar]
RULE 7: (X,Y)(4,Y-(4-X)) [Fill 4 gallon jar by pouring some water
from 3 gallon jar]
RULE 8: (X,Y)(X-(3-Y),3) [Fill 3 gallon jar by pouring some water
from 4 gallon jar]
RULE 9: (X,Y)(X+Y,0) [Empty 3 gallon jar by pouring all its water
into 4 gallon jar]
RULE 10: (X,Y)(0,X+Y) [Empty 4 gallon jar by pouring all its water
into 3 gallon jar]
RULE 11: (0,2)(2,0) [Pour 2 gallon from 3 gallon jar into 4 gallon]
12. RULE 12: (2,y)(0,y) [empty the 2 gallons in 3 gallon
jar on the ground]
One solution :
Water in 4-gallon
jar (X)
Water in 3-gallon
jar (Y)
Rule applied
0 0
0 3 Rule 2
3 0 Rule 9
3 3 Rule 2
4 2 Rule 7
0 2 Rule 5 or 12
13. Water in 4-gallon
jar (X)
Water in 3-gallon
jar (Y)
Rule applied
0 0
4 0 Rule 1
1 3 Rule 8
1 0 Rule 6
0 1 Rule 10
4 1 Rule 1
2 3 Rule 8
Another Solution :
15. Missionaries and cannibels
Travelling Salesperson
8 Queens
Combinatorial explosition- in travelling salesperson
problem –
number of routes α (no of cities -1)!
If it takes 1 hour of cpu time to solve for 30 cities
30 hours for 31 cities and
330 hours for 32 cities!!!!
16. Control strategies
Helps us decide which rule to apply next.
What to do when there are more than 1 matching
rules?
Good control strategy should:
1. cause motion
2.Systematic
17. Control strategies are classified as:
1. Uninformed/blind search control strategy
Do not have additional info about states beyond problem def.
Total search space is looked for solution
No info is used to determine preference of one child over
other.
Example: 1. Breadth First Search(BFS), Depth First
Search(DFS), Depth Limited Search (DLS).
2. Informed/Directed Search Control Strategy
Some info about problem space(heuristic) is used to compute
preference among the children for exploration and
expansion.
Examples: 1. Best First Search, 2. Problem Decomposition,
A*, Mean end Analysis