Lecture 6: Search in Artificial Intelligence

Author

Your Name

Published

February 10, 2025

Introduction

Announcements: Impresa Magistrale Initiative

The lecture begins with an announcement regarding the Impresa Magistrale initiative at the university. This program is designed to enhance the collaboration between the university and the business sector, offering master’s level students paid internship opportunities. Specifically, the initiative provides scholarships of €5,000 over two years for internships with companies affiliated with the Village, the university’s industry-connected laboratories, or with companies that have long-standing partnerships with the university.

The application process involves submitting an application which will be evaluated based on the applicant’s curriculum and other relevant criteria. For our degree programs, there are six available positions. Successful candidates will receive funding and participate in discussions to align their interests with the available company projects, leading to a structured internship. This internship can be validated for academic credit, specifically as equivalent to two advanced laboratory courses. The internship entails 500 hours of work, offering a more extended and compensated practical experience compared to standard internships. The scholarship is disbursed in two installments: €2,500 initially, followed by another €2,500 upon positive evaluation after the first year. The application deadline is March 31st. Students interested in applying or seeking further information are encouraged to contact Professor Serra directly at Giuseppe.serra@unido.it.

Lecture 6: Overview of Search in AI

This lecture, Lecture 6, continues our exploration of search algorithms within the field of Artificial Intelligence. Originally planned to conclude within two sessions, the depth of the material necessitates a slightly extended coverage. Today’s lecture aims to provide a more comprehensive understanding of search methodologies, building upon the foundational concepts established in our previous discussions. We will transition from basic search algorithms to more advanced techniques, addressing limitations and expanding the scope of problem-solving strategies in AI.

Fundamentals of Search Problems

In our preceding lectures, we laid the groundwork by defining the fundamental elements of search problems. We introduced the concept of problem-solving agents, which are intelligent entities designed to find solutions to problems formulated as searches. These search problems can be formally defined using a sextuple, which encapsulates all necessary components:

  • State Space: This is the set encompassing all possible configurations or situations that the problem can be in. Each element in the state space represents a unique state of the problem.

  • Initial State: Within the state space, the initial state is the starting point from which the agent begins its search for a solution. It is the problem’s given starting configuration.

  • Actions: For each state, there is a set of possible actions that the agent can take to transition to another state. These actions define the possible moves or operations within the problem domain.

  • Result: The result function specifies the outcome of performing an action in a given state. In a deterministic environment, each action from a state leads to a single, predictable resulting state.

  • Goal Test: This is a criterion or condition that determines whether a given state is a goal state. A goal state represents a desired solution to the problem. The goal test is a function that can be applied to any state to check if it satisfies the goal condition.

  • Cost Function: The cost function assigns a numerical cost to each action, representing the ‘expense’ of moving from one state to another. This cost can be in terms of time, resources, or any other relevant metric that needs to be minimized or optimized.

To simplify our initial exploration of search algorithms, we have, thus far, operated under a set of simplifying assumptions regarding the nature of the task environment:

  • Discrete Environment: The state space is discrete, meaning that the number of possible states and actions is finite or countably infinite. This allows for clear and distinct steps in problem-solving.

  • Fully Observable Environment: The agent has complete access to the current state of the environment. There is no hidden information, and the agent’s sensors provide a full picture of the environment’s condition.

  • Deterministic Actions: The outcome of each action is predictable and unique. When an agent performs an action in a state, the result is always the same, with no uncertainty about the next state.

  • Known Environment: The environment is known to the agent, implying that the agent has complete knowledge of the environment’s dynamics, including the state space, the available actions in each state, the transition model (how actions change states), the goal test, and the cost function.

Furthermore, we introduced the concept of a state space graph as a natural and intuitive way to represent search problems. In this graph, nodes correspond to states, and edges represent transitions between states caused by actions. For the purpose of systematic search, this state space graph is often transformed into a search tree. Rooted at the initial state, the search tree expands possible sequences of actions, allowing us to visualize and explore paths towards a goal state. The fundamental objective of search algorithms is to identify a sequence of actions that leads from the initial state to a goal state while minimizing the cumulative cost incurred along the path. The optimal solution is defined as the action sequence that achieves a goal state with the minimum total cost.

Review of Uninformed Search Methods

Characteristics of Task Environments

In our initial discussions, we have focused on simplified task environments to understand the basic principles of search. These environments are characterized by several key properties that make the search problem more tractable:

  • Discrete: The environment is discrete, meaning that the number of possible states and actions is finite or countably infinite. This allows for clear and distinct steps in problem-solving.

  • Fully Observable: The agent has complete information about the current state of the environment. There are no hidden aspects, and the agent’s perception provides a full representation of the environment’s condition.

  • Deterministic: Actions in the environment are deterministic, meaning that each action taken in a state results in a single, uniquely determined next state. There is no randomness or uncertainty in the outcomes of actions.

  • Known: The environment is known to the agent, implying that the agent has complete knowledge of the state space, the available actions in each state, the transition model (how actions change states), the goal test, and the cost function.

These simplifying assumptions allow us to concentrate on the core mechanics of search algorithms without the complexities introduced by uncertainty, incomplete information, or continuous state spaces. By starting with these idealized conditions, we can build a solid foundation for understanding more complex search scenarios later.

State Space Graphs and Trees

The state space of a problem can be naturally represented as a graph, known as a state space graph. In this representation, each node in the graph corresponds to a unique state of the problem. The edges in the graph represent the transitions between states, which are brought about by the application of actions. To perform a systematic search, it is often useful to transform this state space graph into a search tree. The search tree is rooted at the initial state, and each path from the root to a node in the tree represents a sequence of actions. This tree structure facilitates the visualization and exploration of possible action sequences starting from the initial state, allowing search algorithms to methodically navigate through the problem space.

Search Frontier and Exploration

The search frontier is a crucial concept in search algorithms. It is defined as the set of states that the algorithm has generated but not yet expanded. In other words, these are the states that are known to exist but whose successors have not yet been explored. The frontier marks the boundary between the explored and the unexplored regions of the state space.

Exploration is the process of systematically examining the states within the state space to find a path to a goal state. Search algorithms operate by iteratively selecting a state from the frontier and expanding it. Expanding a state involves generating its successor states (the states reachable by applying available actions), evaluating them, and adding them to the frontier if they have not been explored yet. By managing the frontier and systematically exploring states, search algorithms can discover paths from the initial state to a goal state.

Detailed Uninformed Search Algorithms

Uninformed search algorithms, also known as blind search algorithms, are search strategies that do not use any domain-specific knowledge beyond the problem definition itself. These algorithms explore the state space based only on the information available in the problem definition, such as the initial state, actions, and goal test. We have examined several fundamental uninformed search algorithms, each with its own approach to exploration and characteristics.

Depth-First Search (DFS)

Concept: Depth-First Search (DFS) is an algorithm that explores the state space by going as deep as possible along each branch before backtracking. It starts at the root node (initial state) and explores one branch of the search tree to its fullest extent before moving to the next branch.

Initialize frontier as a stack with the initial state of problem Initialize explored as an empty set node \(\leftarrow\) POP(frontier) node Add node to explored PUSH(child, frontier) failure

Complexity Analysis of DFS:

  • Time Complexity: In the worst case, DFS may explore the entire search tree, leading to a time complexity of \(O(b^m)\), where \(b\) is the branching factor and \(m\) is the maximum depth of the search tree. In the case of infinite depth search spaces, \(m\) can be infinity, and DFS may not terminate.

  • Space Complexity: DFS has a space complexity of \(O(bm)\), as it only needs to store the nodes on the current path from the root to the current node, along with the unexplored siblings for each node on the path. This is significantly less than BFS.

Pros:

  • Minimal Memory Requirement: DFS is memory-efficient because it only needs to store the path from the root to the current node, making its space complexity linear with respect to the depth of the search tree.

Cons:

  • Incompleteness: DFS is not complete in infinite state spaces. It can get trapped in an infinite path and fail to find a goal even if one exists in another part of the state space.

  • Suboptimal Solutions: DFS is not guaranteed to find the optimal solution. The first solution it finds might be on a deeper path and thus have a higher cost than a solution on a shallower path.

Breadth-First Search (BFS)

Concept: Breadth-First Search (BFS) explores the state space level by level. It starts at the root node and explores all neighbors at the present depth level before moving on to nodes at the next depth level. This ensures that BFS finds the shortest path in terms of the number of edges.

Initialize frontier as a queue with the initial state of problem Initialize explored as an empty set node \(\leftarrow\) POP(frontier) node Add node to explored ENQUEUE(child, frontier) failure

Complexity Analysis of BFS:

  • Time Complexity: BFS has a time complexity of \(O(b^d)\), where \(b\) is the branching factor and \(d\) is the depth of the shallowest goal node. In the worst case, it explores all nodes at depths up to \(d\).

  • Space Complexity: BFS has a space complexity of \(O(b^d)\) because it stores all nodes at the current level in the frontier to explore their children in the next level. This can be a significant limitation as memory usage grows exponentially with depth.

Pros:

  • Completeness: BFS is complete, meaning if a solution exists at a finite depth, BFS is guaranteed to find it.

  • Optimality for Unit Step Costs: If all step costs are equal (or unit cost), BFS is optimal, as it always finds the shallowest goal state, which corresponds to the least number of steps from the initial state.

Cons:

  • High Memory Requirement: BFS requires significant memory to store all nodes at each level of the search tree. This can become a major issue for problems with large branching factors or deep solution depths, often leading to memory exhaustion.

Uniform-Cost Search (UCS)

Concept: Uniform-Cost Search (UCS) is a variation of Dijkstra’s algorithm applied to state space search. It expands nodes in order of their path cost from the start node. UCS prioritizes exploring paths that have the lowest cumulative cost, ensuring that it finds the least-cost path to a goal.

Initialize frontier as a priority queue ordered by path cost \(g\), with the initial state of problem Initialize explored as an empty set node \(\leftarrow\) POP_MIN(frontier) node Add node to explored Add child to frontier with path cost \(g(\textit{child})\) Replace child in frontier with lower path cost failure

Complexity Analysis of UCS:

  • Time Complexity: The time complexity of UCS is \(O(b^{C^*/\epsilon})\), where \(C^*\) is the cost of the optimal solution and \(\epsilon\) is the minimum action cost. This is because UCS may explore all nodes with a path cost less than \(C^*\).

  • Space Complexity: Similarly, the space complexity is also \(O(b^{C^*/\epsilon})\) as UCS needs to store all nodes in the frontier, which can be substantial if the optimal path cost is high and action costs are small.

Pros:

  • Completeness: UCS is complete, guaranteed to find a solution if one exists.

  • Optimality for General Step Costs: UCS is optimal for any step cost function. It always finds the path with the minimum total cost from the start node to a goal node.

Cons:

  • Potential Inefficiency: UCS can explore a large number of nodes, especially if there are many paths with path costs close to the optimal path cost. It may explore paths that are only slightly cheaper than the optimal path but ultimately lead to suboptimal or longer solutions in terms of depth.

Iterative Deepening Depth-First Search (IDDFS)

Concept: Iterative Deepening Depth-First Search (IDDFS) combines the space efficiency of DFS with the completeness and optimality (for unit costs) of BFS. IDDFS performs a series of Depth-First Searches, each with a gradually increasing depth limit. It starts with a depth limit of 0, then 1, then 2, and so on, until a goal is found.

result \(\leftarrow\) result

Initialize frontier as a stack with the initial state of problem Initialize cutoff_occurred \(\leftarrow\) false node \(\leftarrow\) POP(frontier) node cutoff_occurred \(\leftarrow\) true PUSH(child, frontier) cutoff failure

Complexity Analysis of IDDFS:

  • Time Complexity: IDDFS has a time complexity of \(O(b^d)\), similar to BFS. Although it repeats searches at shallower depths, the number of repeated nodes is relatively small compared to the nodes at the deepest level, especially for larger branching factors.

  • Space Complexity: IDDFS has a space complexity of \(O(bd)\), similar to DFS, because at any depth limit, it performs a DFS which only requires memory proportional to the depth limit.

Pros:

  • Completeness: IDDFS is complete, like BFS, and will find a solution if one exists.

  • Optimality for Unit Step Costs: IDDFS is optimal if all step costs are uniform, as it explores in increasing depth order, similar to BFS.

  • Low Memory Requirement: IDDFS has a linear space complexity, similar to DFS, making it much more memory-efficient than BFS, especially for deep search spaces.

Cons:

  • Repeated States: IDDFS regenerates states multiple times in each iteration, which might seem inefficient. However, this redundancy is often acceptable because the majority of nodes are in the deepest level explored, and the overhead from shallower levels is not prohibitively large.

Search in Historical and Computer Science Context

The field of Artificial Intelligence has made profound and lasting contributions to Computer Science. Many concepts and algorithms that are now considered fundamental to Computer Science were initially pioneered and developed within the AI research community. Early AI researchers, in their quest to create intelligent systems, invented tools and techniques that proved to be broadly applicable across computer science. For example, LISP and Scheme, influential programming languages, were created by John McCarthy, a founding figure of AI. Similarly, the paradigm of Object-Oriented Programming (OOP), which revolutionized software development, owes some of its conceptual origins to AI research.

Notably, search algorithms, which are central to AI problem-solving, have transitioned into core computer science. The very algorithms we discuss for AI search problems, developedand refined in the 1950s and 1960s, are now standard topics in computer science curricula. Thanks to the work of figures like Donald Knuth, these algorithms have been rigorously analyzed, optimized, and integrated into the theoretical foundations of computer science. Today, search algorithms are taught in introductory courses on algorithms and data structures, forming part of the essential knowledge for computer scientists, not exclusively confined to the domain of Artificial Intelligence. This evolution is encapsulated in John McCarthy’s famous observation: "As soon as it works, no one calls it AI anymore," highlighting how AI’s successful innovations often become absorbed into the broader field of computer science.

AI’s Role as the Search Frontier

Artificial Intelligence can be metaphorically viewed as the frontier of problem-solving in the digital and computational world. AI research is inherently focused on tackling problems that currently lie at the edge of our computational capabilities and theoretical understanding—problems that we do not yet know how to solve effectively. The process in AI often involves exploring uncharted territories of problem-solving, developing new algorithms and techniques to address previously intractable challenges.

As AI research progresses and solutions are discovered and refined for these frontier problems, these solutions gradually become well-understood and routine. They transition from being cutting-edge AI to becoming part of the "expanded set" of established computer science knowledge and engineering practices. This expansion effectively shifts the AI frontier forward, as researchers then turn their attention to even more complex and unsolved problems.

In this context, search, particularly in the mid-20th century, was undoubtedly at the forefront of the AI frontier. The development of effective search algorithms was crucial for enabling AI systems to solve complex problems. While search remains a vital area within AI, it has also become a mature and well-understood domain, arguably now more within the "expanded set" than at the bleeding edge. However, it is important to note that research in search continues to evolve, with ongoing advancements in areas such as heuristic design, search in complex and dynamic environments, and integration with machine learning. These ongoing efforts ensure that search remains a vibrant and relevant field within AI, continually pushing the boundaries of what is computationally solvable.

Informed Search Techniques

Introduction to Informed Search and Heuristics

Building upon our understanding of uninformed search methods, we now turn our attention to informed search techniques. Unlike uninformed search, which explores the state space without any knowledge of how close a state is to the goal, informed search algorithms leverage heuristic functions to guide their exploration. These heuristics provide an estimate of the cost from the current state to the nearest goal, enabling the search to focus on more promising paths.

Definition 1 (Heuristic Function).

A heuristic function, denoted as \(h(n)\), is a function that estimates the cost of the cheapest path from a given state \(n\) to a goal state. It is domain-specific and provides an informed guess about the distance to the goal.

The primary goal of informed search is to enhance the efficiency of the search process. By using heuristic functions, these algorithms aim to reduce the search space, thereby finding solutions more quickly and with fewer resources compared to uninformed methods. The effectiveness of informed search heavily depends on the quality of the heuristic function used.

Greedy Best-First Search: A Heuristic Approach

Definition 2 (Greedy Best-First Search).

Greedy Best-First Search is an informed search algorithm that expands the node that is estimated to be closest to the goal. It operates by evaluating nodes based solely on the heuristic function \(h(n)\), effectively choosing to explore the path that appears to be most promising at each step.

The term "greedy" in Greedy Best-First Search reflects its strategy of always trying to move towards the goal as quickly as possible, without considering the cost of the path taken so far. It is akin to a hiker who always chooses the path that seems to directly lead to the summit, regardless of the terrain already covered.

Example 1 (Romania Travel using Greedy Best-First Search).

Consider our Romania travel problem. Starting in Arad, Greedy Best-First Search evaluates the heuristic values for the directly reachable cities: Sibiu (\(h(\text{Sibiu}) = 253\)), Timisoara (\(h(\text{Timisoara}) = 329\)), and Zerind (\(h(\text{Zerind}) = 374\)). Since Sibiu has the lowest heuristic value, Greedy Best-First Search selects Sibiu as the next city to expand. This process repeats: from Sibiu, it considers Fagaras (\(h(\text{Fagaras}) = 176\)), Rimnicu Vilcea (\(h(\text{Rimnicu Vilcea}) = 193\)), and Craiova (\(h(\text{Craiova}) = 242\)). Fagaras is chosen due to its minimal heuristic value. Continuing this greedy approach leads to the path Arad \(\rightarrow\) Sibiu \(\rightarrow\) Fagaras \(\rightarrow\) Bucharest.

Greedy Best-First Search Path in Romania Map (Red Path)

However, despite its efficiency in this example, Greedy Best-First Search is not optimal. It may not find the shortest path because it solely focuses on minimizing the estimated cost to the goal (\(h(n)\)) and completely disregards the cost already incurred to reach the current state (\(g(n)\)). In the Romania example, a more optimal path exists that passes through Rimnicu Vilcea and Pitesti, which Greedy Best-First Search overlooks by greedily choosing Fagaras from Sibiu. This illustrates a key limitation: prioritizing immediate heuristic gain can lead to suboptimal overall paths.

A* Search: Combining Cost and Heuristics

To overcome the limitations of Greedy Best-First Search and ensure optimality, the A* search algorithm was developed. A* Search enhances the evaluation function by incorporating both the cost to reach the current state and the estimated cost to the goal.

Definition 3 (A* Search).

A* Search is an informed search algorithm that combines the path cost, \(g(n)\), which is the cost from the start node to node \(n\), and the heuristic cost, \(h(n)\), which estimates the cost from node \(n\) to the goal. It expands nodes based on the evaluation function \(f(n) = g(n) + h(n)\).

A* Search aims to minimize the estimated total path cost from the start node to a goal node, passing through the current node \(n\). By considering both past path costs and future path estimates, A* balances exploration efficiency with optimality guarantees, provided that an admissible heuristic is used.

The F(n) Evaluation Function: g(n) + h(n)

The evaluation function \(f(n)\) in A* search is defined as the sum of two components: \[f(n) = g(n) + h(n)\] where:

  • \(g(n)\): This is the path cost, representing the actual cost incurred to reach the state \(n\) from the initial state. It is calculated as the sum of the costs of all actions taken to get to \(n\).

  • \(h(n)\): This is the heuristic cost, an admissible heuristic estimate of the cost of the cheapest path from state \(n\) to a goal state. It provides an informed guess about the remaining cost to reach the goal.

  • \(f(n)\): The total estimated cost of the cheapest path from the start node to a goal node, constrained to go through node \(n\). A* selects the node with the lowest \(f(n)\) from the frontier for expansion.

A* Search Example: Romania Travel Scenario

Example 2 (Romania Travel using A* Search).

Let’s revisit the Romania travel scenario, now applying A* search. Starting from Arad, A* calculates the \(f(n)\) for each reachable city. For Sibiu, \(f(\text{Sibiu}) = g(\text{Arad, Sibiu}) + h(\text{Sibiu}) = 140 + 253 = 393\). Similarly, for Timisoara, \(f(\text{Timisoara}) = g(\text{Arad, Timisoara}) + h(\text{Timisoara}) = 118 + 329 = 447\), and for Zerind, \(f(\text{Zerind}) = g(\text{Arad, Zerind}) + h(\text{Zerind}) = 75 + 374 = 449\). A* expands Sibiu first because it has the lowest \(f\) value (393).

Continuing from Sibiu, A* considers its neighbors. For Rimnicu Vilcea, \(f(\text{Rimnicu Vilcea}) = g(\text{Arad} \rightarrow \text{Sibiu} \rightarrow \text{Rimnicu Vilcea}) + h(\text{Rimnicu Vilcea}) = (140 + 80) + 193 = 413\). For Fagaras, \(f(\text{Fagaras}) = g(\text{Arad} \rightarrow \text{Sibiu} \rightarrow \text{Fagaras}) + h(\text{Fagaras}) = (140 + 99) + 176 = 415\). Despite Fagaras having a lower heuristic value than Rimnicu Vilcea, Rimnicu Vilcea is expanded next because its \(f\) value (413) is slightly lower than Fagaras’s (415) when considering the path cost \(g(n)\).

A* Search Path in Romania Map (Red Path)

By considering both \(g(n)\) and \(h(n)\), A* search effectively balances moving towards the goal (guided by \(h(n)\)) with ensuring the path taken so far is cost-effective (guided by \(g(n)\)). In the Romania example, A* correctly identifies the optimal path to Bucharest: Arad \(\rightarrow\) Sibiu \(\rightarrow\) Rimnicu Vilcea \(\rightarrow\) Pitesti \(\rightarrow\) Bucharest, which is different from the path found by Greedy Best-First Search and is indeed the optimal route in terms of total cost.

Optimality and Admissibility of A*

A crucial property that ensures A*’s optimality is the admissibility of the heuristic function.

Definition 4 (Admissible Heuristic).

A heuristic function \(h(n)\) is considered admissible if it never overestimates the actual cost to reach a goal state from any state \(n\). Formally, for every state \(n\), \(h(n) \leq h^*(n)\), where \(h^*(n)\) is the true cost of the optimal path from \(n\) to the nearest goal state. Additionally, an admissible heuristic must be non-negative for all states (\(h(n) \geq 0\)) and must be zero at goal states (\(h(\text{goal}) = 0\)).

Admissibility is a critical condition for A* to guarantee finding the optimal solution. If a heuristic is admissible, A* is guaranteed to find a minimum-cost path to a goal.

Proof of A* Optimality with Admissible Heuristics

Theorem 1 (Optimality of A*).

Description: This theorem states the fundamental property of the A* search algorithm: when using an admissible heuristic, A* is guaranteed to find the optimal (least-cost) path to a goal state, if such a path exists. If A* search uses an admissible heuristic \(h(n)\), then it is guaranteed to be optimal, meaning it will always find a least-cost path to a goal state if one exists.

Proof. Proof. Let us prove this by contradiction. Assume A* terminates and returns a suboptimal goal node \(B\), while there exists an optimal goal node \(A\) with a path cost \(g(A) < g(B)\). Let \(n\) be a node that is on an optimal path to \(A\) and is in the frontier when A* selects \(B\) for expansion. Since \(B\) is selected for expansion before \(n\), it must be the case that: \[f(B) \leq f(n)\] Since \(B\) is a goal node, its heuristic cost is zero, i.e., \(h(B) = 0\). Thus, \(f(B) = g(B) + h(B) = g(B)\). For node \(n\), the evaluation function is \(f(n) = g(n) + h(n)\). Substituting these into the inequality, we get: \[g(B) \leq g(n) + h(n)\] Because \(h(n)\) is admissible, we know that it never overestimates the true cost, so \(h(n) \leq h^*(n)\), where \(h^*(n)\) is the true optimal cost from \(n\) to a goal. Therefore, we can replace \(h(n)\) with \(h^*(n)\) to obtain an inequality that still holds or becomes tighter: \[g(B) \leq g(n) + h^*(n)\] Now, consider that \(n\) is on an optimal path to the goal \(A\). By definition, the sum of the cost to reach \(n\) and the optimal cost from \(n\) to \(A\) is equal to the optimal cost to reach \(A\). That is, \(g(A) = g(n) + h^*(n)\). Substituting \(g(A)\) for \(g(n) + h^*(n)\) in the inequality, we get: \[g(B) \leq g(A)\] This result, \(g(B) \leq g(A)\), contradicts our initial assumption that \(B\) is suboptimal and \(A\) is optimal, which implies \(g(A) < g(B)\). The only way to resolve this contradiction is if our assumption that A* would expand a suboptimal goal \(B\) before finding an optimal path is false. Therefore, A* must expand nodes in such an order that it will always find an optimal path to a goal before it could possibly terminate with a suboptimal goal, provided that an admissible heuristic is used. This proves that A* search is optimal with an admissible heuristic. ◻

Designing Effective Heuristics

The effectiveness of A* search is heavily reliant on the quality of the heuristic function \(h(n)\). Designing a good heuristic involves finding a balance between accuracy and computational cost. A common and effective approach to designing admissible heuristics is through the concept of relaxed problems.

Definition 5 (Relaxed Problem).

A relaxed problem is derived from the original problem by removing one or more constraints. This simplification makes the problem easier to solve, and the optimal solution cost of this relaxed problem can provide a useful heuristic for the original, more constrained problem.

The key idea is that by removing constraints, we effectively increase the set of possible actions, making it "easier" to reach a goal state. Consequently, the optimal path cost in the relaxed problem will always be less than or equal to the optimal path cost in the original problem. This property ensures that the heuristic derived from a relaxed problem is admissible, as it never overestimates the true cost.

Example: Heuristics for the 8-Puzzle

Example 3 (8-Puzzle Heuristics).

Consider the 8-puzzle problem. We can derive admissible heuristics by relaxing the problem constraints. In the 8-puzzle, tiles can only be moved to the adjacent empty space. Let’s consider two common heuristics derived from relaxed versions of this puzzle:

  • h1: Number of misplaced tiles. This heuristic simply counts the number of tiles that are not in their goal positions. To relax the 8-puzzle to justify this heuristic, we consider a problem where a tile can be moved from its current position to its goal position in a single step, regardless of other tiles. In this relaxed problem, each misplaced tile can be corrected in just one move. Thus, the number of misplaced tiles is a lower bound on the number of moves required in the original 8-puzzle, making \(h_1\) an admissible heuristic.

  • h2: Manhattan distance. The Manhattan distance heuristic calculates the sum of the horizontal and vertical distances of each tile from its goal position. For each tile, we sum up the number of horizontal and vertical steps needed to reach its correct position, ignoring any intervening tiles. The relaxed problem here allows tiles to move horizontally and vertically to their correct positions, even if other tiles are in the way. In the original 8-puzzle, any valid move reduces the Manhattan distance by at most 1. Therefore, the total Manhattan distance is a lower bound on the number of moves needed, making \(h_2\) also an admissible heuristic.

Both \(h_1\) and \(h_2\) are admissible heuristics for the 8-puzzle problem. Empirically, \(h_2\) (Manhattan distance) is generally a more effective heuristic than \(h_1\) (misplaced tiles) because it provides a more informed and closer estimate of the actual distance to the goal. In most cases, \(h_2(n) \geq h_1(n)\) for any state \(n\), and a heuristic \(h_2\) is considered to dominate* \(h_1\) if \(h_2(n) \geq h_1(n)\) for all \(n\) and \(h_2\) is still admissible. Heuristics that dominate others typically lead to more efficient search because they prune more of the search space.*

Practical Limitations of A*: Memory Usage

While A* search significantly reduces the number of nodes expanded compared to uninformed search methods, it still faces practical limitations, primarily related to memory usage. A* is a best-first search algorithm, which means it must keep track of all generated nodes in the frontier (or open list) to always select the node with the lowest \(f\) value for expansion. In the worst-case scenario, A* can explore a large portion of the search space, and the frontier can grow exponentially with the depth of the search.

For problems with very large state spaces, especially those requiring deep searches to find a solution, the memory required to store the frontier can become prohibitively large. This is often referred to as the space complexity bottleneck of A*. In practice, for many complex problems, A* may run out of memory long before it finds a solution, even if the number of nodes expanded is theoretically much smaller than that of uninformed search methods. As Russell and Norvig aptly put it, with A*, "you will probably run out of memory long before you get bored waiting for the solution."

Advanced A* Algorithms (Brief Overview)

To mitigate the memory limitations of standard A* search, several advanced variations have been developed. These algorithms aim to reduce the memory footprint while retaining the optimality and efficiency benefits of A*. Two notable examples are:

Iterative Deepening A* (IDA*)

Remark. Remark 1 (Iterative Deepening A* (IDA*)).

Iterative Deepening A* (IDA*) is a memory-bounded search algorithm that combines the iterative deepening strategy from IDDFS with the \(f\) evaluation function of A*. IDA* performs a series of depth-first searches, each with a cost bound. In each iteration, IDA* explores all paths in depth-first manner up to a given \(f\) limit. If no solution is found within the current limit, the limit is increased to the minimum \(f\) value that exceeded the current limit in the previous search, and the process repeats.

IDA* significantly reduces memory usage because, like DFS, it only needs to store the current path being explored. However, it may repeat node expansions across iterations, which can increase the computation time compared to standard A* if many iterations are needed. Despite this, IDA* is often more practical for problems where memory is a critical constraint.

Recursive Best-First Search (RBFS)

Remark. Remark 2 (Recursive Best-First Search (RBFS)).

Recursive Best-First Search (RBFS) is another memory-bounded algorithm that attempts to mimic the operation of standard best-first search but using only linear space. RBFS is a recursive algorithm that keeps track of the \(f\) value of the best alternative path available from any ancestor of the current node. If the current path’s \(f\) exceeds this alternative path’s \(f\), RBFS backtracks and explores the alternative path.

RBFS is more memory-efficient than A* and often IDA*, as it only stores the current path and the best alternative path. However, RBFS can be less efficient in terms of time complexity in some cases due to repeated node expansions when it switches between paths. Despite potential re-expansions, RBFS remains valuable for problems with stringent memory limitations, offering a good balance between memory usage and search efficiency.

Extending Search: Non-Deterministic Environments

Introduction to Non-Deterministic Scenarios

Up to this point, we have primarily focused on search problems within deterministic environments, where the outcome of each action is uniquely and predictably determined. However, the real world often presents situations where actions do not have single, certain outcomes. In non-deterministic environments, an action taken in a particular state can result in one of several possible states. This uncertainty introduces a significant layer of complexity to problem-solving and necessitates different search strategies compared to those used in deterministic settings.

The Erratic Vacuum World Problem

To illustrate the concept of non-determinism, let’s consider a modification of the simple vacuum world problem, which we will call the Erratic Vacuum World. In this modified scenario, we introduce non-deterministic behavior to the "Suck" action of a vacuum agent operating in a two-location environment (Location 1 and Location 2).

In the deterministic vacuum world, the "Suck" action reliably cleans dirt in the current location. However, in the Erratic Vacuum World, the "Suck" action behaves unpredictably:

  • If the current location is dirty: When the agent performs "Suck" in a dirty location, it will always clean the dirt in the current location. However, there are two possible secondary outcomes:

    1. Normal Operation: It only cleans the current location, behaving as expected in a deterministic setting.

    2. Enhanced Operation: It cleans the current location and, due to its erratic nature, also cleans the dirt in the adjacent location, if there is any.

  • If the current location is clean: If the agent performs "Suck" in a clean location, it might, unexpectedly:

    1. No Effect: Perform no action, remaining in the clean state.

    2. Deposit Dirt: Erratic behavior causes it to deposit dirt back into the current location, making it dirty again.

This erratic behavior of the "Suck" action transforms the vacuum world into a non-deterministic environment. For an agent trying to solve the vacuum world problem in such an environment, simply planning a fixed sequence of actions is no longer sufficient. The agent must be prepared for multiple possible outcomes after each action and adjust its strategy accordingly. This necessitates the use of contingency planning.

Contingency Planning inNon-Deterministic Settings

In deterministic environments, finding a solution typically involves determining a linear sequence of actions that leads from the initial state to a goal state. However, in non-deterministic environments, a simple sequence of actions is inadequate because the outcome of each action is uncertain. Instead, we need contingency plans, also known as conditional plans.

Definition 6 (Contingency Plan).

A contingency plan is a strategy that specifies what action to take based on the outcome observed after each step. It is not a fixed sequence of actions but rather a branching plan that accounts for various possible environmental responses.

Contingency plans are essential for agents operating in non-deterministic environments because they allow the agent to react appropriately to different situations as they unfold. For the Erratic Vacuum World, a contingency plan might look like: "Start at Location 1. Suck. If Location 1 is now clean, move to Location 2 and Suck. If after the first ‘Suck’ action, Location 1 is still dirty, Suck again." This plan is conditional; the subsequent actions depend on the observed state of Location 1 after the initial "Suck" action.

And-Or Search Trees

To represent and find solutions in non-deterministic environments, we use And-Or search trees. These trees are an extension of the standard search trees we’ve seen in deterministic search. And-Or trees explicitly represent the branching possibilities introduced by non-deterministic actions. They incorporate two types of nodes to differentiate between agent choices and environmental contingencies: Or nodes and And nodes.

Understanding Or Nodes

Definition 7 (Or Node).

In an And-Or search tree, an Or node represents a state in the environment where the agent must choose an action. It is a decision point for the agent. From an Or node, the agent can take one of* the available actions to transition to a subsequent state.*

Or nodes are analogous to the nodes in standard search trees used in deterministic environments. They signify points where the agent has control and can choose among several actions. Each branch emanating from an Or node represents a different action the agent can choose to perform. The agent needs to find at least one action that leads to a solution, regardless of the subsequent environmental responses.

Understanding And Nodes

Definition 8 (And Node).

In an And-Or search tree, an And node represents a state resulting from a non-deterministic action, where the environment or some external factor determines the outcome. From an And node, all possible outcomes must be considered. To achieve success from an And node, the agent must have a plan that works for every possible outcome.

And nodes are unique to And-Or search trees and are used to model the contingencies introduced by non-deterministic actions. When an action leads to an And node, it signifies that there are multiple possible next states, and the environment will choose one of them. For a plan to be successful from an And node, it must account for and handle all possible outcomes. Graphically, And nodes are often represented differently from Or nodes, sometimes as squares or with an arc connecting the edges leading to their children, to visually distinguish them in the search tree.

Defining Solutions in And-Or Trees

Definition 9 (Solution Subtree in And-Or Tree).

In the context of And-Or search trees, a solution is not simply a path, as in deterministic search, but rather a solution subtree. This subtree represents a conditional plan that guarantees reaching a goal state, no matter which outcomes occur at the And nodes. A solution subtree must satisfy the following conditions:

  • Action Choice at Or Nodes: For every Or node within the solution subtree, exactly one action must be selected. This chosen action leads to a child node that is also part of the solution subtree. This represents the agent making a specific choice of action at each decision point.

  • Consideration of All Outcomes at And Nodes: For every And node within the solution subtree, all* possible outcomes (all child nodes resulting from the non-deterministic action) must be included in the solution subtree. This ensures that the plan accounts for every contingency that might arise from a non-deterministic action.*

  • Goal Achievement at Leaves: Every leaf node in the solution subtree must be a goal node. This condition ensures that every branch of the conditional plan eventually leads to a successful goal state, regardless of the sequence of non-deterministic outcomes encountered along the way.

A valid solution subtree in an And-Or search tree effectively represents a robust contingency plan. It is a plan that is guaranteed to reach a goal state, handling all possible environmental responses modeled by the And nodes and making specific action choices at the Or nodes. Finding such a solution subtree is the objective of search algorithms designed for non-deterministic environments.

Adversarial Search and Game Playing

Game Theory and AI: An Introduction

Game theory is a mathematical framework designed to study strategic interactions among rational agents in situations where the outcome of an agent’s actions depends on the actions of other agents. It provides a rich set of concepts and tools for analyzing decision-making processes in competitive environments. In Artificial Intelligence, game playing represents a significant and historically important area of research. It serves as a challenging domain for developing intelligent algorithms that can compete with or even surpass human-level performance. The study of game playing in AI is not just about creating programs that win games; it is also about understanding and modeling intelligent behavior in competitive and adversarial situations. Games provide well-defined, yet complex, environments that are ideal for testing and developing search algorithms, decision-making strategies, and learning techniques that can be generalized to broader AI applications in multi-agent systems, robotics, and economic modeling.

Categorizing Games in Artificial Intelligence

Games in AI can be broadly categorized based on several key properties that significantly influence the design of game-playing algorithms. These categories help in understanding the nature of the game and in selecting or developing appropriate AI techniques.

Deterministic vs. Stochastic Games

  • Deterministic Games: In deterministic games, the outcome of each move is entirely predictable. Given a game state and a player’s action, the next state is uniquely determined. There is no element of chance or randomness involved. Examples of deterministic games include Chess, Checkers, Go, and Tic-Tac-Toe. In these games, the current state and the rules of the game are the only factors determining what happens next. Algorithms for deterministic games often focus on search and strategy, as the challenge lies in exploring the vast game tree to find optimal moves.

  • Stochastic Games: Stochastic games, on the other hand, incorporate elements of chance or randomness. The outcome of a player’s action may not be uniquely determined but rather depends on some probabilistic event, such as dice rolls, card shuffling, or random environmental factors. Examples of stochastic games include Backgammon, Monopoly, and card games like Poker and Bridge. In stochastic games, AI algorithms must not only consider strategic moves but also reason about probabilities and expected outcomes. Techniques for stochastic games often involve integrating probability theory with search algorithms to handle uncertainty.

Games with Perfect vs. Imperfect Information

  • Perfect Information Games: Perfect information games are characterized by the property that all players have complete knowledge of the game state at every point in time. All relevant information is visible to all players, and there are no hidden elements. Examples of perfect information games are Chess, Go, and Checkers. In these games, players know the entire history of moves and the current configuration of the game board. The challenge in perfect information games is managing the complexity of the state space and devising strategies to outmaneuver the opponent through strategic planning and search

  • Imperfect Information Games: In contrast, imperfect information games involve situations where players do not have complete knowledge of the game state. Some information is hidden from one or more players. This hidden information could be the cards held by other players in Poker, the distribution of units in Starcraft with fog of war, or hidden units in board games. Examples of imperfect information games include Poker, Bridge, and most real-time strategy video games. Dealing with imperfect information requires AI algorithms to reason about beliefs, probabilities, and deception. Strategies in these games often involve bluffing, inferring hidden information, and making decisions under uncertainty.

Two-Player vs. Multi-Player Games

  • Two-Player Games: Two-player games involve exactly two participants who are typically in direct competition with each other. Classic examples of two-player games include Chess, Checkers, Go, and Tic-Tac-Toe. The focus in two-player games is often on adversarial search, where each player tries to optimize their outcome while simultaneously trying to undermine the opponent’s goals. Algorithms like Minimax and Alpha-Beta pruning are specifically designed for two-player zero-sum games.

  • Multi-Player Games: Multi-player games involve more than two players, leading to more complex interactions and strategic considerations. Examples of multi-player games include Poker, Diplomacy, Risk, and many board games and video games designed for more than two participants. In multi-player games, players may form alliances, compete against multiple opponents, or engage in more complex forms of strategic interaction. AI in multi-player games needs to consider coalition formation, negotiation, and strategies that work in environments with multiple competing agents. The dynamics of multi-player games are often richer and more varied than those of two-player games.

Zero-Sum Game Dynamics

Definition 10 (Zero-Sum Game).

A zero-sum game is a specific type of game in game theory where the total sum of payoffs to all players for every possible outcome is zero. In a two-player zero-sum game, this means that one player’s gain is directly equivalent to the other player’s loss. In other words, the interests of the players are diametrically opposed; if one player wins, the other player necessarily loses by an equivalent amount.

Examples of zero-sum games include Chess, Checkers, Go, and many other classic board games where there is a clear winner and loser, and no possibility of mutual gain. In zero-sum games, the utility function is such that if player 1’s utility for an outcome is \(U\), then player 2’s utility for the same outcome is \(-U\). This competitive dynamic simplifies the analysis in some respects because the goal of each player is clearly to maximize their own utility, which is equivalent to minimizing the opponent’s utility. The Minimax algorithm, which we will discuss shortly, is particularly suited for solving two-player zero-sum games with perfect information.

Game Playing Terminology

To formalize game playing within the framework of search problems, we adapt terminology that is similar to what we use for general search but is tailored to the context of games. This specialized terminology helps in clearly defining the components of a game and in designing algorithms to play games.

Game States and Initial State

A game state represents a specific configuration of the game at any point in time. It includes all the information necessary to determine the future course of the game, such as the position of pieces on a board, the score, and whose turn it is to play. The initial state is the starting configuration of the game at the very beginning, from which the game play commences. For example, in chess, the initial state is the standard arrangement of all chess pieces on the board at the start of a game.

Players and the Player Function

Players are the participants in the game, typically denoted as Player 1 (often referred to as MAX, representing the maximizing player) and Player 2 (often referred to as MIN, representing the minimizing player in zero-sum games). The player function is a function that, given a game state, determines which player’s turn it is to make a move. This function is crucial for alternating turns between players and for keeping track of the game’s progression. For instance, in chess, the player function would indicate whether it is currently White’s turn or Black’s turn to move.

Actions and Transition Model

Actions in game playing are the possible moves that a player can make from a given game state. In chess, actions are all legal moves according to chess rules, such as moving a pawn, knight, or queen. The transition model, also known as the result function, defines the outcome of taking an action in a given state. It specifies how the game state changes when a particular action is performed. For example, in chess, the transition model would describe how the board configuration changes after a player moves a piece from one square to another.

Terminal States and Terminal Test

Terminal states are the end states of a game, representing conditions under which the game concludes. These states are also known as game over states. Examples of terminal states include checkmate in chess, reaching a certain score in a card game, or filling all spaces in Tic-Tac-Toe. The terminal test is a function that determines whether a given game state is a terminal state. When a terminal state is reached, the game ends, and the outcome is determined based on the game rules.

Utility Function in Games

Definition 11 (Utility Function).

In game theory, a utility function* (or payoff function) assigns a numerical value to each terminal state of the game. This value represents the final outcome or payoff for a player when the game ends in that state. In zero-sum games, the utility function is often defined from the perspective of one player (e.g., Player 1 or MAX), and the utility for the other player (Player 2 or MIN) is the negation of this value.*

For example, in chess, a common utility function could assign values as follows: +1 for a win for Player 1 (checkmate of Player 2), -1 for a loss for Player 1 (checkmate by Player 2), and 0 for a draw. These utility values quantify the desirability of each terminal state for the players and are used by game-playing algorithms to make optimal decisions. The utility function is crucial for evaluating the outcomes of game scenarios and for guiding search algorithms in finding moves that maximize a player’s expected utility.

Minimax Algorithm: An Introduction (Preview)

Remark. Remark 3 (Minimax Algorithm Introduction).

The Minimax algorithm* is a foundational decision-making algorithm in game theory and AI, particularly for two-player, deterministic, zero-sum games with perfect information. It is designed to determine the optimal move for a player, assuming that the opponent is also playing optimally to minimize the first player’s utility (and maximize their own). The core idea of the Minimax algorithm is to minimize the possible loss for a worst-case scenario. It explores the game tree by alternating between maximizing and minimizing levels, representing the moves of the two opposing players. The algorithm computes the minimax value of each state, which is the best utility that the MAX player can guarantee in a zero-sum game if the MIN player also plays optimally. We will delve into the details of the Minimax algorithm, its mechanics, and its applications in the next lecture, along with enhancements like alpha-beta pruning to improve its efficiency.*

Conclusion

This lecture has broadened our understanding of search techniques in Artificial Intelligence, transitioning from the foundational concepts of uninformed search to more sophisticated methods designed for complex environments. We began by exploring informed search methods, focusing on the A* search algorithm. A* leverages heuristic functions to guide the search process, achieving greater efficiency and optimality in deterministic environments. We rigorously examined the conditions for A*’s optimality, particularly the admissibility of heuristic functions, and discussed practical techniques for designing effective heuristics using the concept of relaxed problems.

Moving beyond deterministic scenarios, we addressed the challenges of non-deterministic environments and introduced And-Or trees as a framework for contingency planning. And-Or trees allow agents to reason and plan in situations where actions can have multiple possible outcomes, enabling the creation of conditional plans that account for environmental uncertainty.

Finally, we initiated a discussion on adversarial search and game playing, shifting our focus to competitive environments involving multiple agents with conflicting goals. We categorized games based on properties such as determinism, information availability, number of players, and game dynamics, laying the groundwork for understanding how AI can be applied to strategic game playing. This introduction sets the stage for the Minimax algorithm, a cornerstone technique for decision-making in competitive, zero-sum games.

Key Takeaways:

  • Informed Search with A*: We learned how A* search combines path cost and heuristic estimates to efficiently find optimal solutions in deterministic environments, provided an admissible heuristic is used. The effectiveness of A* hinges on the design of accurate and admissible heuristics, often derived from relaxed problem formulations.

  • Planning in Non-Deterministic Environments with And-Or Trees: We extended our search methodologies to handle non-deterministic environments by introducing And-Or trees. These structures enable the representation of contingency plans, allowing agents to make decisions and plan actions in environments where outcomes are uncertain, ensuring robustness across various possible scenarios.

  • Introduction to Adversarial Search and Game Playing: We transitioned into the domain of game theory and adversarial search, categorizing games based on their properties and setting the stage for algorithms designed for competitive environments. This introduction highlighted the shift from single-agent problem-solving to multi-agent interactions, where strategic decision-making in the face of an opponent is paramount.

In our next lecture, we will delve deeply into the Minimax algorithm, exploring its mechanics and application in two-player, zero-sum games. We will also examine alpha-beta pruning, a crucial optimization technique that significantly enhances the efficiency of the Minimax algorithm by reducing the search space without affecting the optimality of the decisions, making it possible to tackle more complex game-playing scenarios.