0% found this document useful (0 votes)
40 views61 pages

Problem Formulation in AI Search Methods

Abstraction is crucial in problem formulation as it simplifies complex real-world issues, allowing for effective algorithm design and faster solutions. The document outlines the components of problem formulation for scenarios like online food delivery and movie ticket booking, emphasizing the importance of initial state, actions, transition model, goal state, and path cost. Additionally, it discusses various search algorithms in AI, categorizing them into uninformed and informed searches, and highlights the role of heuristic functions in optimizing search efficiency.

Uploaded by

thasneem671
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views61 pages

Problem Formulation in AI Search Methods

Abstraction is crucial in problem formulation as it simplifies complex real-world issues, allowing for effective algorithm design and faster solutions. The document outlines the components of problem formulation for scenarios like online food delivery and movie ticket booking, emphasizing the importance of initial state, actions, transition model, goal state, and path cost. Additionally, it discusses various search algorithms in AI, categorizing them into uninformed and informed searches, and highlights the role of heuristic functions in optimizing search efficiency.

Uploaded by

thasneem671
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Solving Problems by Searching

Why is abstraction necessary in problem formulation?


Abstraction is necessary in problem formulation because it helps us focus only
on the relevant details of a problem while ignoring unnecessary complexities.
Without abstraction, real-world problems become too large and complicated to
represent or solve using computational models. For example, while planning a
bus route, it is not necessary to include the color of the buses or the design of the
seats; instead, we only consider stops, distances, timings, and traffic. By
simplifying the problem in this way, abstraction allows us to represent it in a
manageable form, design effective algorithms, and reach the solution faster. In
short, abstraction ensures that a problem is solvable, efficient, and practical to
handle.
Study 8-puzzle and 8-Queens problem from textbook.
Formulate the Online Food Delivery Problem into the 5 components of problem
formulation.

The task of delivering food from restaurants to customers can be expressed using
the five components of problem formulation:
1. Initial State
• The delivery agent is at the restaurant with the food ready for pickup.
2. Actions
• Move from one location to another (roads, lanes, shortcuts).
• Pick up food from the restaurant.
• Deliver food to the customer’s location.
3. Transition Model
• Specifies what happens when an action is taken.
• If the agent chooses a particular road, it determines the next location
considering traffic conditions.
• For example, taking the highway might reduce distance but increase time
if traffic is heavy.
4. Goal State
• The food is successfully delivered to the customer’s address within the
expected time.
5. Path Cost
• The total cost of the delivery, which may include:
• Distance traveled.
• Time taken (delays due to traffic).
• Fuel consumption or delivery charges.
Formulate the Online Movie Ticket Booking Problem into the components
of problem formulation.
1. Initial State
The user is logged into the movie booking application without any booked ticket.
2. Actions
• Search for movies.
• Select theatre and showtime.
• Choose seats.
• Make payment.
3. Transition Model
Each action changes the state of the system:
• Selecting a show updates available seats.
• Making payment transitions from “seat selected” to “ticket confirmed.”
4. Goal State
The user has a confirmed movie ticket (with seat number and showtime).
5. Path Cost
Includes the ticket price, booking charges, and possibly convenience factors like
seat preference.

Searching for solutions

Search algorithms form the backbone of problem-solving in AI. Whether it’s navigating a
maze, planning a robot’s movement, or strategizing in a game, AI systems often need to explore
various possibilities to reach a goal. This exploration is enabled by search algorithms.
These algorithms simulate intelligent behaviour by systematically examining sequences of
decisions or actions. From simple blind searches to sophisticated heuristic-guided methods,
they help AI systems find optimal or feasible solutions in complex environments.

Understanding the Role of Search in AI


In artificial intelligence, a search problem involves navigating from an initial state to a goal
state through a series of valid actions. It’s a structured way of representing decision-making
tasks where an agent must explore different paths to find a solution.
A well-defined search problem consists of:
• Initial State: Where the agent begins.
• Actions: All possible moves or decisions from each state.
• Goal State: The desired outcome or target.
• Path Cost: A numerical value representing the cost or effort required to reach a goal.
Search algorithms use these components to construct a search space, typically represented as
a search tree or a search graph:
• Search Tree: A branching structure generated from the initial state without revisiting
past states.
• Search Graph: A more efficient structure that accounts for repeated states and shared
paths, reducing redundancy.
Understanding this structure is key to selecting the right algorithm.
Key Terminologies in AI Search Algorithms
To understand how search algorithms function in AI, it’s essential to grasp a few core terms:
• State Space: The complete set of all possible states the agent can reach.
• Nodes: Represent states in the search tree, including metadata like parent node, path
cost, and depth.
• Frontier: Also known as the open list; it’s a queue of nodes waiting to be explored.
• Explored Set: The set of already visited nodes, used to avoid redundancy and loops.
Cost Functions play a key role in evaluating and guiding searches:
• g(n): Cost from the start node to node n.
• h(n): Heuristic estimate of the cost from n to the goal.
• f(n) = g(n) + h(n): Estimated total cost (used in A* and similar algorithms).
Other important properties:
• Optimality: Whether the algorithm finds the best solution.
• Completeness: Whether it guarantees finding a solution if one exists.
• Time and Space Complexity: Resources needed for computation and memory.
Tree and Graph Search Algorithms
Classification: Types of Search Algorithms
Search algorithms in AI are broadly classified into two main categories:
• Uninformed Search (Blind Search): These algorithms have no additional
information about goal location other than the problem definition. They
explore the search space systematically. Examples include Breadth-First
Search (BFS), Depth-First Search (DFS), and Uniform Cost Search.
• Informed Search (Heuristic Search): These use heuristic functions to
estimate the cost to reach the goal, allowing more efficient exploration.
Examples include Greedy Best-First Search and A*.
Other forms include Online Search, where the environment is partially known,
and Adversarial Search, used in games with opponents.
Uninformed Search Algorithms
Uninformed search also called blind search explores the search space without any
domain specific knowledge or heuristics. It treats all nodes equally and chooses
which path to explore next based solely on general rules like node depth or path
cost.
[Link]-First Search(BFS)
BFS explores nodes level by level, starting from the initial state and expanding
all neighboring nodes before moving to the next depth level. It uses a FIFO
(queue) data structure.
BFS is ideal for finding the shortest path in unweighted graphs and is complete
and optimal when all actions have equal cost. However, it consumes a lot of
memory, especially for large or deep search spaces, making it less practical for
complex problems.
• Guarantees optimal solution, simple to implement
• High space complexity, slow on deep trees
2. Uniform Cost Search
• Uniform Cost Search is similar to BFS but takes the cost of each move into
account. It always expands the node with the lowest cumulative path cost
from the start.
• This makes UCS optimal and complete and useful when actions have
different costs such as in navigation systems.
• It uses a priority queue to manage the frontier and ensures the cheapest path
is always chosen next.

Uniform Cost Search (UCS) expands the least-cost node first using a priority
queue. It behaves like BFS when all costs are equal but outperforms it when costs
vary.

UCS is complete and optimal, making it suitable for pathfinding problems


involving variable edge costs (e.g., GPS routing). However, like BFS, it can be
slow and memory-intensive for large graphs. In above tree it is at first going to
G.
• Always finds the lowest-cost path
• Slow in large spaces, requires cost function and priority queue
3. Depth First Search
• Depth First Search explores paths by going as deep as possible along one
direction before backtracking. It uses a stack or recursion to keep track of
the path.
• DFS is memory efficient compared to BFS since it doesn’t need to store all
siblings at each level.
• However it is not guaranteed to find the shortest path and may get stuck in
an infinite loop if the search tree is deep or contains cycles unless depth
limits or visited checks are applied.
DFS explores as deep as possible along each branch before backtracking. It uses
a LIFO (stack) structure or recursion, making it space-efficient.

DFS is effective in scenarios where solutions are located deep in the search tree
or when exploring all possible paths. However, it’s neither complete nor optimal
in infinite or cyclic spaces without additional checks.
• Low memory usage, faster in deep trees
• Can get stuck in loops, doesn’t guarantee shortest path
4. Depth Limited Search
Depth-Limited Search (DLS) is a DFS with a fixed depth limit to prevent infinite
recursion. It’s useful when the maximum depth of the solution is known in
advance.
Advantages of Depth-Limited SearchConclusions
1. Memory Efficient: Like DFS, it uses linear memory O(d) where d is the
depth limit.
2. Prevents Infinite Loops: Especially helpful in infinite or cyclic graphs.
3. Simpler Than Other Methods: Easy to implement recursively.
4. Useful in Iterative Deepening: DLS is used repeatedly with increasing
depth in Iterative Deepening Search (IDS).
Limitations of Depth-Limited Search
1. Incomplete: If the depth limit is too shallow, the goal won’t be found.
2. Not Optimal: It does not guarantee the shortest path if multiple goal
states exist.
3. Requires Guessing the Right Depth: Choosing the correct depth limit is
not always easy.
4. Performance Drops if Goal is Far: If the goal lies just beyond the limit,
DLS won’t find it and will return a cutoff.
5. Iterative Deepening Search
Iterative Deepening DFS (IDDFS) combines the space-efficiency of DFS
with the completeness of BFS by repeatedly running DLS with increasing
depth limits. It’s often used in applications like game tree exploration.
• Memory-efficient, complete like BFS
• Repeats work in earlier iterations, may be slow
Iterative deepening search may seem wasteful because states are generated
multiple times. It turns out this is not too costly. The reason is that in a
search tree with the same (or nearly the same) branching factor at each level,
most of the nodes are in the bottom level, so it does not matter much that the
upper levels are generated multiple times. In an iterative deepening search,
the nodes on the bottom level (depth d) are generated once, those on the
6. Bidirectional Search
Informed Search Algorithms (Heuristic Search)
Informed search uses domain knowledge in the form of heuristics to make
smarter decisions during the search process. These heuristics estimate how close
a state is to the goal guiding the search more efficiently.
Informed search algorithms use heuristic knowledge about the problem domain
to guide the search process more efficiently. They evaluate each node using a
heuristic function to estimate how close it is to the goal, helping prioritize
promising paths.
1. Greedy Best-First Search
Greedy Best-First Search uses a heuristic function h(n) to expand the node that
appears closest to the goal, ignoring the path cost g(n). It selects the node with
the lowest h(n) at each step.
While it can be very fast, especially in large state spaces, it does not guarantee
finding the shortest or even a correct solution if h(n) is not well-designed.
• Fast, memory-efficient, good for approximate solutions
• Not optimal or complete; can get stuck in local minima
2. A* Search
A* is one of the most widely used informed search algorithms. It uses a combined
evaluation function:
Where:

• g(n) = cost to reach node n


• h(n) = estimated cost from n to the goal
A* expands nodes with the lowest f(n) value, balancing actual cost and heuristic
estimate.
If the heuristic h(n) is:
• Admissible (never overestimates),
• Consistent (monotonic),
Then A* is both complete and optimal.
In graph search, A* avoids revisiting nodes and uses an explored set to prevent
loops—improving efficiency over tree-based implementations.
• Optimal, efficient with good heuristics
• Can consume high memory; performance depends on heuristic quality
Tree and Graph Search
• A* tree search also uses the f(n) = g(n) + h(n) evaluation but treats the
search space as a tree which means it doesn’t track already visited nodes.
Every path is explored independently even if it leads to the same state.
• This can result in duplicate work and a larger search space, especially in
graphs with cycles.
• Although it’s simpler to implement A* tree search may be less efficient and
is typically used when the search structure is naturally a tree or when
memory constraints prevent maintaining a closed list.

• A* graph search is an informed algorithm that finds the shortest path in a


graph by considering both the cost to reach a node (g(n)) and the estimated
cost to the goal (h(n)).
• It keeps track of visited nodes using a closed list to avoid revisiting them
which makes it efficient and prevents cycles or redundant paths.
• This approach ensures optimality and completeness if the heuristic is
admissible.
• It’s suitable for complex environments like road maps or game levels
where paths may loop or intersect.
because f is nondecreasing along any path, n would have lower f-cost than n and
would have been selected first.
expanded in Romania Map Problem example even though it is a child of the root.
We say that the subtree below
3 Memory-bounded heuristic search

reexpanding the subtree at some later time.


RBFS is somewhat more efficient than IDA∗, but still suffers from excessive node
regeneration. In the example in Figure 3.27, RBFS follows the path via Rimnicu
Vilcea, then “changes its mind” and tries Fagaras, and then changes its mind back
again. These mind changes occur because every time the current best path is
extended, its f-value is likely to increase—h is usually less optimistic for nodes
closer to the goal. When this happens, the second-best path might become the best
path, so the search has to backtrack to follow it. Each mind change corresponds
to an iteration of IDA∗ and could require many reexpansions of forgotten nodes
to recreate the best path and extend it one more node. gotten nodes to recreate the
best path and extend it one more node. Like A∗ tree search, RBFS is an optimal
algorithm if the heuristic function h(n) is admissible. Its space complexity is
linear in the depth of the deepest optimal solution, but its time complexity is rather
difficult to characterize: it depends both on the accuracy of the heuristic function
and on how often the best path changes as nodes are expanded. IDA∗ and RBFS
suffer from using too little memory. Between iterations, IDA∗ retains only a
single number: the current f-cost limit. RBFS retains more information in
memory, but it uses only linear space: even if more memory were available, RBFS
has no way to make use of it. Because they forget most of what they have done,
both algorithms may end up reexpanding the same states many times over.
Furthermore, they suffer the potentially exponential increase in complexity
associated with redundant paths in graphs.
Heuristic Function in AI
In artificial intelligence (AI), solving problems efficiently is a crucial goal.
Heuristic function in AI plays a significant role in achieving this by guiding
search algorithms to make better decisions. They estimate the cost of reaching a
goal from a given state, helping algorithms prioritize paths and reduce
computational effort. Heuristic functions are essential for solving complex
problems in areas like robotics, game development, and natural language
processing.
What are Heuristic Functions?
A heuristic function is a mathematical function used in artificial intelligence to
estimate the cost of reaching a goal from a given state. It provides a “best guess”
to guide search algorithms, making them more efficient by focusing on the most
promising paths.
Key Characteristics:
• Admissibility: A heuristic is admissible if it never overestimates the actual
cost to reach the goal. This ensures the algorithm finds the optimal solution.
• Consistency (or Monotonicity): A heuristic is consistent if it satisfies the
triangle inequality, meaning the estimated cost between two states is less
than or equal to the actual cost.
Example:
Consider a GPS navigation system. The straight-line distance between two points
acts as a heuristic, estimating the travel cost while ignoring obstacles like traffic
or road closures.
Heuristic functions are the backbone of informed search strategies, enabling
faster and more effective problem-solving in AI.

Read the 8-puzzle problem from the book


Role of Heuristic Function in AI
Heuristic functions play a vital role in improving the efficiency of AI search
algorithms by guiding them toward optimal solutions. They act as a decision-
making tool, helping algorithms prioritize promising paths and reduce
computational overhead.
Key Contributions:
1. Guiding Search Processes:
Heuristic functions rank paths based on their likelihood of success,
enabling algorithms to focus on the most promising options first.
2. Improving Efficiency:
By estimating the cost to reach the goal, heuristics help eliminate
unnecessary exploration of less viable paths, saving time and resources.
Example:
In a pathfinding problem, such as navigating a maze, a heuristic like the straight-
line distance to the goal allows the algorithm to quickly discard unhelpful routes
and concentrate on paths closer to the destination.
Heuristics make complex problems, like route planning, game strategy, and
scheduling, more manageable by reducing the search space significantly.
Common Problem Types for Heuristic Functions
Heuristic functions are versatile tools applied across various problem types. Their
ability to estimate costs and prioritize paths makes them essential for solving
complex challenges efficiently.
1. Pathfinding Problems
• Applications: Navigation systems, autonomous robots, and network
routing.
• Example: A GPS calculates the shortest route using heuristics like the
straight-line distance to the destination.
2. Constraint Satisfaction Problems
• Applications: Scheduling tasks, resource allocation, and solving puzzles
like Sudoku.
• Example: Assigning tasks to employees to maximize efficiency while
adhering to deadlines.
3. Optimization Problems
• Applications: Route planning, logistics, and game strategies.
• Example: Planning delivery routes for a logistics company while
considering factors like time, fuel consumption, and traffic.
4. Game Playing
• Applications: Strategic games like chess, tic-tac-toe, or Go.
• Example: Evaluating moves using heuristics to decide the best next step
to maximize winning chances.
5. Robotics and Autonomous Systems
• Applications: Path navigation, obstacle avoidance, and task execution.
• Example: Robots use heuristic-based algorithms to navigate warehouses
or avoid collisions.
6. Natural Language Processing (NLP)
• Applications: Parsing, machine translation, and text summarization.
• Example: Using heuristics to determine the best translation for a phrase
based on context and grammar rules.
7. Image and Pattern Recognition
• Applications: Facial recognition, object detection, and medical imaging.
• Example: Identifying patterns in images to detect objects or classify
images.
8. Artificial Life and Simulations
• Applications: Simulating biological systems, traffic flow, and crowd
behavior.
• Example: Modeling traffic systems to optimize signal timings using
heuristic estimates.
9. Machine Learning Model Training
• Applications: Hyperparameter tuning and model optimization.
• Example: Using heuristic-based algorithms to select the best
hyperparameters for maximizing model accuracy.
10. Data Clustering
• Applications: Grouping data in market segmentation, image
segmentation, and anomaly detection.
• Example: Heuristics guide clustering algorithms like k-means to initialize
centroids effectively for better results.
11. Financial Forecasting
• Applications: Predicting stock prices, risk assessment, and portfolio
optimization.
• Example: Heuristics help in estimating future trends based on past data
patterns.
12. Internet Search Engines
• Applications: Optimizing search results and ranking pages.
• Example: Search engines use heuristics to rank web pages by relevance
and quality for user queries.
13. Supply Chain Management
• Applications: Inventory management, demand forecasting, and
warehouse optimization.
• Example: Heuristic methods predict demand and optimize inventory
levels to reduce costs.
Pathfinding with Heuristic Functions
Pathfinding is one of the most common applications of heuristic functions in AI.
By guiding search algorithms, heuristics help identify the shortest or most
efficient paths in complex environments.
Step 1: Define the A* Algorithm
A* is a widely used pathfinding algorithm that combines:
• g(n): The actual cost from the start node to the current node.
• h(n): The heuristic estimate from the current node to the goal.
• f(n): The total estimated cost, calculated as f(n)=g(n)+h(n)f(n) = g(n) +
h(n)f(n)=g(n)+h(n).
Step 2: Define the Visualization Function
Visualizing the search process can help in understanding how the algorithm
explores different paths. Common techniques include:
• Grid Representations: Visual grids where each cell represents a node.
• Color Coding: Highlighting explored, unvisited, and optimal paths for
clarity.
Step 3: Define the Grid and Start/Goal Positions
Set up a grid-based environment where:
• Each cell represents a possible state.
• Start and goal positions are clearly defined.
• Obstacles are marked to simulate real-world challenges.
Step 4: Run the A* Algorithm and Visualize the Path
Execute the algorithm step by step:
1. Initialize the open list with the start node.
2. Explore neighboring nodes and calculate their f(n)f(n)f(n) values.
3. Select the node with the lowest f(n)f(n)f(n) and repeat until the goal is
reached.
Applications of Heuristic Function in AI
Heuristic functions are integral to AI systems across various domains. Their
ability to prioritize and streamline problem-solving processes makes them
invaluable in real-world applications.
1. Game Playing
• Applications: Chess, tic-tac-toe, and Go.
• Role: Heuristics evaluate game states to determine the best possible
moves, improving decision-making and strategy formulation.
2. Robotics
• Applications: Autonomous navigation and obstacle avoidance.
• Role: Robots use heuristics to calculate efficient paths, ensuring smooth
operation in dynamic environments.
3. Natural Language Processing (NLP)
• Applications: Parsing, machine translation, and text summarization.
• Role: Heuristics help prioritize sentence structures or translations to
generate coherent and contextually relevant outputs.
4. Logistics and Supply Chain Management
• Applications: Route planning and inventory optimization.
• Role: Heuristics guide decisions in transportation and inventory
management to reduce costs and improve efficiency.
5. Healthcare
• Applications: Disease diagnosis and treatment planning.
• Role: Heuristics assist in analyzing symptoms and medical histories to
suggest potential diagnoses or treatment options.
6. E-commerce
• Applications: Product recommendations and search optimization.
• Role: Heuristics enhance user experiences by tailoring search results and
recommendations based on user preferences.
7. Environmental Modeling
• Applications: Climate modeling and disaster management.
• Role: Heuristics streamline simulations to predict outcomes like weather
patterns or the impact of natural disasters.
Heuristic functions are a cornerstone of artificial intelligence, enabling efficient
and intelligent decision-making across diverse applications. By estimating the
cost to reach a goal, they guide search algorithms to explore the most promising
paths, significantly reducing computational effort. From game playing and
robotics to natural language processing and logistics, heuristic functions
enhance AI’s ability to solve complex problems in real-world scenarios. Their
properties, such as admissibility and consistency, ensure optimal solutions
while maintaining efficiency.

Overall choosing a good heuristic function is of utmost importance. You can see
in the below the example difference in outcome with different heuristic function.

You might also like