Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

UNIT 2

PROBLEM SOLVING METHOD

Problem solving in artificial intelligence (AI) involves using techniques such as:

 Efficient algorithms
 Heuristics
 Root cause analysis
 Searching algorithms
The goal of AI is to solve problems in the same way that humans do.
Here are some problem solving methods in AI:
 Heuristic search
Uses a rule of thumb to increase the chances of success
 Heuristic approach
Focuses on experimentation and test procedures to understand a problem and create a
solution
 State space search
Involves defining the search space, deciding start and goal states, and then finding the path
from start state to goal state through search space
 Constraint satisfaction problems
Mathematical questions defined as a set of objects whose state must satisfy a number of
constraints or limitations.
Other problem solving methods in AI include:
 Uninformed vs Informed Search

 Local Search
 Stochastic Hill Climbing
 Simulated Annealing
 Tabu Search
SEARCH STRATEGIES

In artificial intelligence (AI), search strategies are techniques and algorithms used to explore
and navigate a problem space in order to find a solution to a given problem. Search strategies
are commonly employed in tasks like pathfinding, puzzle-solving, game playing, and
optimization. There are various search algorithms, each with its own characteristics and
applications. Here are some of the commonly used search strategies in AI:

1. Depth-First Search (DFS): DFS explores a tree or graph by following one branch as deeply
as possible before backtracking. It is implemented using a stack data structure and is often
used in games and puzzle-solving.
2. Breadth-First Search (BFS): BFS explores a tree or graph level by level, visiting all nodes
at the current level before moving on to the next level. It is implemented using a queue data
structure and is commonly used in finding the shortest path in unweighted graphs.
3. Uniform Cost Search (UCS): UCS is a variant of BFS that takes into account the cost
associated with each path. It expands the path with the lowest accumulated cost first and is
used for finding the shortest path in weighted graphs.
4. A Search:* A* combines the advantages of both BFS and UCS by using a heuristic function
to estimate the cost of reaching the goal from a given state. It selects the path with the lowest
estimated total cost, making it efficient for pathfinding and optimization problems.
5. Greedy Best-First Search: Greedy Best-First Search selects the path that appears to be
closest to the goal according to a heuristic, without considering the actual path cost. It can be
very efficient but may not always find the optimal solution.
6. Dijkstra's Algorithm: Dijkstra's algorithm is used to find the shortest path in a weighted
graph. It explores paths in order of their actual costs and is guaranteed to find the shortest
path in a non-negative weighted graph.
7. Bidirectional Search: Bidirectional search starts from both the initial and goal states and
searches simultaneously until the two searches meet in the middle. It can be more efficient
than traditional searches, especially in large search spaces.
8. Depth-Limited Search: Depth-Limited Search is a modified version of DFS that sets a
maximum depth limit. It helps avoid infinite loops in cases where a solution may not exist
within a reasonable depth.
9. Iterative Deepening Depth-First Search (IDDFS): IDDFS combines the advantages of
DFS and BFS by repeatedly applying DFS with increasing depth limits until a solution is
found. It ensures optimality and is suitable for large state spaces.
10. Beam Search: Beam search is a variant of BFS that only keeps a fixed number of the best
nodes at each level, discarding the rest. It is used in game playing and optimization problems.
11. Simulated Annealing: Simulated annealing is a probabilistic search algorithm inspired by
the annealing process in metallurgy. It is used for optimization problems and aims to find the
global optimum through random exploration and probabilistic acceptance of worse solutions.
12. Genetic Algorithms: Genetic algorithms are inspired by the process of natural selection.
They use populations of solutions and evolve them over generations by applying genetic
operators like mutation and crossover. Genetic algorithms are used in optimization and
machine learning.
These search strategies can be adapted and combined to suit the specific requirements and
characteristics of the problem at hand. The choice of a particular search strategy depends on
factors such as the problem space, search space, available computational resources, and
desired solution quality.

UNINFORMED SEARCH

Uninformed search, also known as blind search, is a category of search algorithms in artificial
intelligence (AI) that explore a problem space without any knowledge of the location of the
goal or the structure of the problem. Uninformed search algorithms rely on systematic
exploration, visiting states or nodes in the search space based on simple rules, often without
any heuristic information.
Here are some commonly used uninformed search algorithms in AI:
1. Breadth-First Search (BFS): BFS explores a search tree or graph by systematically
expanding all the nodes at the current level before moving on to the next level. It is
complete, meaning it will find a solution if one exists, and it is guaranteed to find the
shortest path in an unweighted graph.
2. Depth-First Search (DFS): DFS explores a search tree or graph by visiting a node
and then recursively visiting its children as deeply as possible before backtracking.
DFS is often implemented using a stack data structure and is memory-efficient
compared to BFS, but it may not find the optimal solution.
3. Depth-Limited Search (DLS): DLS is a modification of DFS where a depth limit is
imposed. It is useful for preventing infinite loops and for limiting the depth of
exploration. DLS is often used in conjunction with iterative deepening to ensure
completeness and optimality.
4. Iterative Deepening Depth-First Search (IDDFS): IDDFS is a combination of DLS
and DFS. It repeatedly applies DLS with increasing depth limits until a solution is
found. IDDFS is both complete (guaranteed to find a solution) and optimal
(guaranteed to find the shortest path in unweighted graphs).
5. Uniform Cost Search (UCS): UCS is a variant of BFS that considers the actual cost
of reaching a state. It explores paths in order of their accumulated cost, making it
useful for finding the shortest path in weighted graphs.
6. Bidirectional Search: Bidirectional search starts from both the initial and goal states
and searches simultaneously until the two searches meet in the middle. It can be more
efficient than traditional searches in large search spaces.
Uninformed search algorithms are used in situations where little or no information about the
problem space is available. While these algorithms are guaranteed to find a solution
(completeness), they may not always be the most efficient, especially in complex search
spaces. In cases where additional information is available, heuristic search algorithms, such
as A* search, are often preferred because they can make more informed decisions about
which paths to explore. Uninformed search is valuable for baseline exploration and as a basis
for developing more advanced search strategies in AI.

INFORMED SEARCH
Informed search in artificial intelligence (AI) is a search algorithm that uses problem-
specific knowledge to make search more directed and efficient. Informed search provides
the AI with guidance on how and where to look for the solution to the problem.
Informed search uses heuristics to evaluate which nodes or states to expand next during
search. A heuristic is a function that finds the most promising path. It takes the current state
of the agent as its input and produces an estimation of how close the agent is from the goal.
Informed search algorithms, like A* Search, use heuristics to estimate the cost to reach the
goal, potentially speeding up the search and finding more efficient solutions.
An example of informed search in AI is searching a place you want to visit on Google
maps. The current location and the destination place are given to the search algorithm for
calculating the accurate distance, time taken, and real-time traffic updates on that particular
route.
HEURISTIC SEARCH
Heuristic search is a simple searching technique in artificial intelligence (AI) that looks
for a reasonable solution to a problem. It ranks every opportunity at each search branch
and then chooses the best one from the options provided.
Heuristic search is also known as informed search or heuristic control strategy. It uses the
idea of heuristic, which is a function that finds the most promising path.
Heuristic search is useful in situations where known algorithms can't be found. It can also be
used in large search spaces.

Here are some examples of heuristic search in AI:

 Hill climbing: A simple optimization algorithm used to find the best possible solution for a
given problem
 Breadth First Search (BFS): An example of uninformed search
 Depth First Search (DFS): An algorithm that explores as far as possible along each branch
before backtracking

LOCAL SEARCH ALGORITHM


A local search algorithm in artificial intelligence (AI) starts with an initial solution and
then makes small adjustments to it in the hopes of finding a better one. The algorithm
iterates, assessing the current solution and creating a new solution with a small modification.
Local search is used in most AI models to search for the optimal solution according to the
cost function of that model. It is used in linear regression, neural networks, and clustering
models.
Some local search algorithms include: Hill climbing, Simulated annealing, Tabu search.
Local searches are widely used for optimization tasks since they often require fewer
computational resources than global searches, making them more efficient and cost
effective. They are also a memory-efficient strategy.
The hill climbing algorithm continually moves "uphill" in state-space landscape, and
terminates when it reaches a "peak", or where there is no neighbor with higher value.

OPTIMIZATION PROBLEM
An optimization problem in artificial intelligence (AI) is finding a set of inputs to an
objective function that results in a maximum or minimum function evaluation. It is a
challenging problem that underlies many machine learning algorithms, such as fitting logistic
regression models and training artificial neural networks.
Optimization problems can be classified according to the nature of the constraints, such as
linear, nonlinear, or convex.
Some optimization algorithms include:
 Ant colony optimization
Based on the ideas of ant foraging by pheromone communication to form paths
 Genetic algorithm
A conventional evolutionary algorithm motivated by Darwinian evolutionary ideas
 Nature-inspired search algorithms
Such as the runner-root algorithm (RRA), which is inspired by the function of runners and
roots of plants in nature
When identifying AI optimization problems and objectives, you should also consider the
ethical, social, and environmental implications of the problem and the solutions. For example,
if you are optimizing an AI system for facial recognition, you should be aware of the
potential biases, privacy issues, and legal regulations involved.

SEARCHING WITH PARTIAL OBSERVATIONS


Searching with partial observations, also known as "Partially Observable Search" or
"Partially Observable Markov Decision Processes (POMDPs)," is a challenging problem in
artificial intelligence. In such scenarios, an agent has limited or incomplete information about
its environment and must make decisions based on the information it has. This differs from
traditional search problems, where the agent has complete knowledge of the environment.
Here are the key components and techniques used in searching with partial observations in
AI:
1. Partially Observable Environments: In partially observable environments, the agent
doesn't have access to the full state of the world. Instead, it typically receives
observations, which are partial and sometimes noisy information about the state.
2. State Estimation: To address partial observability, the agent needs to maintain a
belief state or probability distribution over possible states of the environment. This
belief state is updated with new observations and used to make informed decisions.
3. Partially Observable Markov Decision Processes (POMDPs): POMDPs are a
formal framework for modeling decision-making in partially observable
environments. They extend Markov Decision Processes (MDPs) to handle
uncertainty. A POMDP is defined by a tuple (S, A, O, T, R, Z), where S is the set of
states, A is the set of actions, O is the set of observations, T is the transition function,
R is the reward function, and Z is the observation function.
4. Belief State Update: The belief state is updated using a Bayesian filter, such as the
Kalman filter, particle filter, or more advanced techniques like the Bayesian recursive
filtering. These filters combine prior beliefs with new observations to estimate the
current state.
5. Policy Search: The agent seeks to find a policy that maximizes expected cumulative
rewards, considering the belief state. This involves finding an optimal policy or a
stochastic policy that can adapt to the uncertainty of the environment.
6. Value Iteration and Policy Iteration: Traditional reinforcement learning algorithms
like value iteration and policy iteration can be adapted for POMDPs by working with
the belief state. These methods aim to find the optimal policy.
7. Partially Observable Heuristic Search: Heuristic search algorithms, such as A* or
its variants, can be extended to POMDPs. They use heuristics to guide the search
process, considering the belief state.
8. Monte Carlo Methods: Monte Carlo methods, such as Monte Carlo Tree Search
(MCTS), are used to address partial observability in environments, especially in
domains like game playing, where an agent has limited information about the
opponent's actions.
9. Learning and Adaptation: Learning techniques, including reinforcement learning
and online learning, can be used in partially observable environments to adapt to the
uncertainty and improve decision-making over time.
10. Sensory Models: Accurate sensory models that describe the relationship between the
agent's actions and the observations it receives are essential in POMDPs.
Searching with partial observations is especially relevant in robotics, autonomous systems,
and real-world applications where agents must make decisions based on sensor data, which
may not provide complete and precise information about the environment. Solving POMDPs
efficiently often involves a trade-off between computational complexity and decision quality,
and various approximation techniques and heuristics are used to tackle these challenges.

CONSTRAINT SATISFACTION PROBLEM (CSP)


A constraint satisfaction problem (CSP) in artificial intelligence (AI) is a type of issue that
involves finding a solution that meets a set of constraints. The goal is to find a value for
each variable such that all the constraints are satisfied.

A CSP is described by:

 A set of variables
 A domain for each variable
 A set of constraints that outline the possible combinations of values for these variables
Many combinatorial problems in operational research, such as scheduling and timetabling,
can be formulated as CSPs.

Here are some examples of CSPs:


 Australia map coloring problem
Color each region of Australia using three colors so that no neighboring territory has the
same color
 4-queens problem
Place the 4 queens on a 4x4 chessboard such that no two queens can attack each other
CONSTRAINT PROPAGATION
Constraint propagation is a form of reasoning in artificial intelligence (AI) that uses
constraints to reduce the domain of possible values for each variable. It can also infer
new constraints from existing ones.

Constraint propagation works by:

1. Communicating the domain reduction of a decision variable to all of the constraints that are
stated over this variable
2. Using the constraints to reduce the domain of possible values for each variable
3. Inferring new constraints from the existing ones
4. Applying filtering to the constraints in the CSP instance at hand
5. Explicitly forbidding values or combinations of values for some variables of a problem
because a given subset of its constraints cannot be satisfied otherwise
A constraint satisfaction problem (CSP) in AI consists of three components:

 X: A set of variables, {X1, …, Xn}


 D: A set of domains, {D1, …, Dn}, one for each variable
 Each domain Di: Consists of a set of allowable values, {v1, …, vk} for variable Xi
Forward checking is a type of constraint propagation that propagates information from
assigned to unassigned variables. It can detect inconsistency earlier than simple backtracking,
which allows branches of the search tree that will lead to failure to be pruned earlier.

BACKTRACKING IS A SEARCH ALGORITHM


Backtracking is a search algorithm used in artificial intelligence and computer science to find
solutions to problems, particularly in scenarios where an exhaustive search is required. It is a
depth-first search algorithm that explores a search space by incrementally building a solution
and backtracking (undoing) when it determines that the current path cannot lead to a valid
solution. Backtracking is commonly used in constraint satisfaction problems, puzzles, and
optimization tasks. Here's how the backtracking search algorithm works:
1. Initialization: Start with an empty solution or partial solution and initialize a variable
to track the current state. The current state represents the position in the search space.
2. Exploration: In each step, the algorithm selects a possible choice or option to extend
the current solution. This can involve making decisions, setting variables, or choosing
values.
3. Constraint Checking: After making a choice, the algorithm checks if the choice
violates any constraints or criteria that must be satisfied for the solution to be valid. If
the choice leads to a constraint violation, the algorithm backtracks.
4. Recursion: Backtracking involves undoing the previous choice and returning to the
previous state. This can be accomplished by reverting the choice and variables to their
previous values. The algorithm then continues to explore other choices from the
previous state.
5. Termination: The algorithm continues this process until it finds a valid solution or
exhaustively explores all possible choices. If no valid solution is found, it terminates.
6. Optimization: Depending on the problem and the desired optimization criteria,
backtracking can be enhanced with heuristics and pruning techniques to reduce the
search space and improve efficiency.
Common applications of backtracking include:
 Solving puzzles such as the Eight Queens puzzle, Sudoku, and the N-Queens
problem.
 Solving cryptarithmetic problems where letters represent digits (e.g., SEND + MORE
= MONEY).
 Solving constraint satisfaction problems (CSPs) like scheduling, timetabling, and
resource allocation.
 Generating permutations, combinations, or subsets of elements.
 Solving optimization problems like the Traveling Salesman Problem (TSP) using the
branch and bound technique.
Backtracking can be a powerful and flexible approach to solving complex problems, but its
performance heavily depends on the nature of the problem and the effectiveness of constraint
propagation and pruning techniques. In some cases, more advanced search algorithms, such
as constraint propagation or informed search, may be used in conjunction with backtracking
to improve efficiency.

GAME PLAYING IN ARTIFICIAL INTELLIGENCE

Game playing in artificial intelligence (AI) is one of the first tasks undertaken in AI. There
are two main approaches to game playing in AI:

 Rule-based systems: Use a set of fixed rules to play the game


 Machine learning-based systems: Use algorithms to learn from experience and make
decisions based on that experience
The Mini-Max algorithm is mostly used for game playing in AI. This algorithm computes
the minimax decision for the current state. In this algorithm, two players play the game, one
is called MAX and other is called MIN.
General game playing (GGP) is the design of artificial intelligence programs to be able to
play more than one game successfully. For many games like chess, computers are
programmed to play these games using a specially designed algorithm, which cannot be
transferred to another context.
AI in gaming refers to responsive and adaptive video game experiences. These AI-powered
interactive experiences are usually generated via non-player characters, or NPCs, that act
intelligently or creatively, as if controlled by a human game-player.
OPTIMAL DECISION MAKING IN GAMES

In AI, optimal decision making in games is making the best decision possible in a given
situation, while considering various factors. These factors include:

 Game mechanics
 Resources available
 Potential risks and rewards
 Other players' activities
The optimal strategy in a game can be determined from the minimax value of each node
in a game tree. In the minimax algorithm, MAX prefers to move to a state of maximum
value, while MIN prefers a state of minimum value.
The optimal solution becomes a contingent strategy when it specifies MAX's move in the
initial state, then Max moves to the states resulting for every possible response by MIN.

Some factors that can make a more formal approach to decision making necessary include:

 The decision is important enough to justify the time it takes to analyze it


 The decision is too complex to solve with more simple intuitive approaches
Decision theory is the study of an agent's rational choices. It supports progress in technology
such as work on machine learning and artificial intelligence.
ALPHA-BETA PRUNING
Alpha-beta pruning is an optimization technique used in artificial intelligence to speed up the
Minimax algorithm, which is commonly used for game playing and decision-making in two-
player, zero-sum games. Alpha-beta pruning reduces the number of nodes evaluated in the
game tree, allowing the algorithm to explore the most promising branches and discard
unproductive ones. Here's an explanation of alpha-beta pruning with an example:
Alpha-Beta Pruning Example: Tic-Tac-Toe
Consider a simple game of Tic-Tac-Toe, where two players, X and O, take turns placing their
marks on a 3x3 grid. The goal is to get three of their marks in a row, either horizontally,
vertically, or diagonally. Let's see how alpha-beta pruning works in this context:
1. Game Tree Representation: We create a game tree to represent the possible moves
and states in the game. Each node in the tree represents a game state, and the edges
represent possible moves (e.g., placing an X or O in a cell). The root of the tree
represents the initial state of the game, and the leaves represent terminal states (win,
lose, or draw).
2. Minimax Algorithm: We apply the Minimax algorithm to evaluate each node in the
game tree. In Minimax, X maximizes its score (tries to win), while O minimizes its
score (tries to prevent X from winning).
3. Alpha and Beta Values: During the search, we keep track of two values, alpha and
beta, for each node. Alpha represents the best score X can achieve so far, and beta
represents the best score O can achieve so far. Initially, alpha is set to negative
infinity, and beta is set to positive infinity.
4. Pruning Condition: At each node, we check if the current node's score can never be
better than the alpha or beta value of its parent node, depending on whether it's X's or
O's turn. If this condition is met, it means we can prune the rest of the branches below
that node because the parent node's best move has already been found.
Let's illustrate alpha-beta pruning with an example game tree:

X
/\
O -
/ \ /|\
X OX-X
/ / |
O - X
/|\ /\
XOX OX
/ /
- -
In this example:
 X is the root node, and it is X's turn to play.
 X explores its first child, O, and assigns an alpha value of -∞ to X.
 O explores its first child, X, and assigns a beta value of ∞ to O.
 X evaluates its second child, which is a terminal state with a score of 0 (draw).
 O determines that X's second child is not better than its first child (X's alpha value), so
it prunes the remaining branches below O.
 This process continues, and pruning occurs when O's beta value becomes less than or
equal to X's alpha value at nodes with dashes (-).
The result of alpha-beta pruning in this example is that many branches of the game tree are
pruned, significantly reducing the number of nodes that need to be evaluated. Alpha-beta
pruning ensures that the Minimax algorithm explores the most promising branches and
discards unproductive ones while maintaining the same optimal result as a full Minimax
search.
STOCHASTIC GAMES
Stochastic games, also known as stochastic dynamic games or sequential games of chance,
are a class of games in the field of game theory and artificial intelligence where uncertainty,
randomness, and sequential decision-making play a significant role. Unlike deterministic
games, where the outcome of each move is known with certainty, stochastic games involve a
level of randomness or uncertainty in the decision-making process. Stochastic games are used
to model a wide range of situations, from economics to biology to AI.
Here are some key concepts related to stochastic games:
1. Players: Stochastic games involve two or more players, each making decisions in a
sequential manner. Players may have different objectives or preferences.
2. States: The game progresses through a sequence of states. Each state represents a
snapshot of the game at a specific point in time. The transition from one state to
another depends on the players' actions and the random elements in the game.
3. Actions: In each state, players have a set of possible actions they can take. These
actions influence the game's progression.
4. Transitions: The game transitions from one state to another based on the actions of
the players and the probabilistic elements, such as random events or chance outcomes.
5. Rewards or Payoffs: At each state, players receive rewards or payoffs based on the
actions they have taken. The rewards can be deterministic or stochastic, depending on
the game's design.
6. Discount Factor: A discount factor is often used to model time preferences or
uncertainties about the future. It determines the relative importance of immediate
rewards versus future rewards.
7. Objective Function: Players typically have an objective function that defines their
goals or preferences. The goal can be to maximize expected rewards, minimize
expected costs, or achieve other specific objectives.
8. Strategies: Players choose strategies to maximize their objectives. Strategies are
plans or policies that specify the actions to take in different states or situations.
9. Equilibria: Stochastic games can have various equilibria, including Nash equilibria,
subgame perfect equilibria, and Markov perfect equilibria. These represent stable
points where no player can unilaterally improve their situation.
Examples of stochastic games include:
 Repeated Games: Games played over multiple rounds where the outcomes of
previous rounds can influence future rounds. For example, repeated prisoner's
dilemma games.
 Stochastic Control Problems: Problems where a player must make sequential
decisions under uncertainty. Examples include financial portfolio optimization and
inventory management.
 Game-Theoretic Models in Economics: Stochastic games are used to model
economic interactions involving strategic decision-making under uncertainty.
 Reinforcement Learning: In reinforcement learning, agents learn to make sequential
decisions in stochastic environments, where they receive rewards that are subject to
uncertainty.
Stochastic games provide a powerful framework for modeling complex, dynamic systems
where uncertainty is a central feature. Analyzing and solving stochastic games often involves
advanced mathematical techniques, including dynamic programming, Markov decision
processes, and game-theoretic concepts. These games are essential in understanding decision-
making under uncertainty and have applications in various fields, including economics,
operations research, and AI.

You might also like