0% found this document useful (0 votes)
202 views24 pages

AI Problem Solving and Search Strategies

The document discusses the concepts of problems, problem spaces, and search techniques in artificial intelligence, emphasizing the importance of defining problems accurately and exploring possible states to find solutions. It explains state space search as a method for navigating through problem states and highlights the production system as a framework for developing AI applications through rules and a global database. Additionally, it outlines the characteristics, advantages, and disadvantages of production systems in AI.
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)
202 views24 pages

AI Problem Solving and Search Strategies

The document discusses the concepts of problems, problem spaces, and search techniques in artificial intelligence, emphasizing the importance of defining problems accurately and exploring possible states to find solutions. It explains state space search as a method for navigating through problem states and highlights the production system as a framework for developing AI applications through rules and a global database. Additionally, it outlines the characteristics, advantages, and disadvantages of production systems in AI.
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
You are on page 1/ 24

Artificial Intelligence | 1

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
UNIT -2
Index

Topics Page No.


Problems
Problems spaces and search
Define the problem as a state space search
Production system
Problem characteristics
Production system characteristic
Issues in design of search program
Search Techniques: DFS, BFS, Hill climbing

School of Computer Science 1


Artificial Intelligence | 2

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Problems, Problems spaces and search
Let’s explain the concepts of problem, problem space, and search in the context of artificial
intelligence:

1. Problem: A problem is a specific task or challenge that requires finding a solution or making a
decision. In artificial intelligence, problems can vary in complexity and scope, ranging from
simple tasks like arithmetic calculations to complex challenges such as image recognition,
natural language processing, game playing, and optimization. Each problem has a defined set of
initial states, possible actions or moves, and a goal state that needs to be reached or achieved.

For example, in a game of chess, the problem is to find a sequence of moves that lead to
checkmate, while in route planning, the problem is to find the shortest path between two
locations on a map.

2. Problem Space: The problem space is the set of all possible states, actions, and transitions
that can be encountered while attempting to solve a specific problem. It represents the entire
landscape of potential solutions and paths from the initial state to the goal state.

In other words, the problem space defines all the possible configurations or arrangements
of elements involved in the problem and the set of valid moves or actions that can be taken at
each state. Each state in the problem space represents a specific configuration, and each action
represents a possible move or step from one state to another.

For example, in the problem of route planning, the problem space includes all possible
locations on the map as states and all valid roads or paths between them as actions.

3. Search: Search is the process of exploring the problem space to find a sequence of actions or
moves that lead to the goal state or a satisfactory solution. In AI, search algorithms are used to
systematically navigate through the problem space and discover paths or solutions that satisfy
the problem’s constraints and objectives.

The search process involves starting from the initial state and exploring possible actions
to generate new states. These states are then evaluated based on certain criteria (e.g., distance
to the goal, cost, or utility) to determine the most promising states to explore further. The
process continues iteratively until the goal state is reached or a satisfactory solution is found.
There are various search algorithms used in AI, such as depth-first search, breadth-first search,
A* search, and heuristic search. Each algorithm has its strengths and weaknesses, and the
choice of search algorithm depends on the problem’s characteristics, size of the problem space,
and the resources available.

In summary, a problem is a task or challenge that requires a solution, the problem space
represents all possible configurations and actions related to the problem, and search involves
exploring the problem space to find a sequence of actions leading to the desired goal or solution.
Efficient search algorithms are essential in AI problem-solving to effectively navigate large and
complex problem spaces and find optimal or near-optimal solutions.

School of Computer Science 2


Artificial Intelligence | 3

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
To solve the problem of building a system you should take the following steps:

1. Define the problem accurately including detailed specifications and what constitutes a suitable
solution.
2. Scrutinize the problem carefully, for some features may have a central effect on the chosen
method of solution.
3. Segregate and represent the background knowledge needed in the solution of the problem.
4. Choose the best solving techniques for the problem to solve a solution

School of Computer Science 3


Artificial Intelligence | 4

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Define the problem as a state space search

Overview:- State space search is a problem-solving technique used in Artificial Intelligence (AI) to
find the solution path from the initial state to the goal state by exploring the various states. The state
space search approach searches through all possible states of a problem to find a solution. It is an
essential part of Artificial Intelligence and is used in various applications, from game-playing
algorithms to natural language processing.

Introduction:- A state space is a way to mathematically represent a problem by defining all the
possible states in which the problem can be. This is used in search algorithms to represent the
initial state, goal state, and current state of the problem. Each state in the state space is
represented using a set of variables.

The efficiency of the search algorithm greatly depends on the size of the state space, and it
is important to choose an appropriate representation and search strategy to search the state space
efficiently.

One of the most well-known state space search algorithms is the A algorithm. Other
commonly used state space search algorithms include breadth-first search (BFS), depth-first
search (DFS), hill climbing, simulated annealing, and genetic algorithms.

Features of State Space Search:- State space search has several features that make it an
effective problem-solving technique in Artificial Intelligence. These features include:

 Exhaustiveness:
State space search explores all possible states of a problem to find a solution.
 Completeness:
If a solution exists, state space search will find it.
 Optimality:
Searching through a state space results in an optimal solution.
 Uninformed and Informed Search:
State space search in artificial intelligence can be classified as uninformed if it provides
additional information about the problem.

In contrast, informed search uses additional information, such as heuristics, to guide the
search process.

Steps in State Space Search

The steps involved in state space search are as follows:

School of Computer Science 4


Artificial Intelligence | 5

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403

 To begin the search process, we set the current state to the initial state.
 We then check if the current state is the goal state. If it is, we terminate the algorithm and
return the result.
 If the current state is not the goal state, we generate the set of possible successor states
that can be reached from the current state.
 For each successor state, we check if it has already been visited. If it has, we skip it, else we
add it to the queue of states to be visited.
 Next, we set the next state in the queue as the current state and check if it's the goal state. If
it is, we return the result. If not, we repeat the previous step until we find the goal state or
explore all the states.
 If all possible states have been explored and the goal state still needs to be found, we return
with no solution.

State Space Representation

State space Representation involves defining an INITIAL STATE and a GOAL STATE and then
determining a sequence of actions, called states, to follow.

 State: A state can be an Initial State, a Goal State, or any other possible state that can be
generated by applying rules between them.
 Space: In an AI problem, space refers to the exhaustive collection of all conceivable states.
 Search: This technique moves from the beginning state to the desired state by applying
good rules while traversing the space of all possible states.
 Search Tree: To visualize the search issue, a search tree is used, which is a tree-like
structure that represents the problem. The initial state is represented by the root node of
the search tree, which is the starting point of the tree.
 Transition Model: This describes what each action does, while Path Cost assigns a cost
value to each path, an activity sequence that connects the beginning node to the end node.
The optimal option has the lowest cost among all alternatives.
School of Computer Science 5
Artificial Intelligence | 6

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Example of State Space Search

The 8-puzzle problem is a commonly used example of a state space search. It is a sliding puzzle
game consisting of 8 numbered tiles arranged in a 3x3 grid and one blank space. The game aims to
rearrange the tiles from their initial state to a final goal state by sliding them into the blank space.

To represent the state space in this problem, we use the nine tiles in the puzzle and their
respective positions in the grid. Each state in the state space is represented by a 3x3 array with
values ranging from 1 to 8, and the blank space is represented as an empty tile.

The initial state of the puzzle represents the starting configuration of the tiles, while the goal state
represents the desired configuration. Search algorithms utilize the state space to find a sequence
of moves that will transform the initial state into the goal state.

The

The States of 8 tile puzzle are the different permutation of the tiles within frame.

Lets do a standard formulation of this problem now.

States: It specifies the location of each of the 8 tiles and the blank in one of the nice square.

Initial state: Any State can be designated as the initial state.

Goal: Many goal configurations are possible one such is shown in the figure.

Legal moves (or States): They generate legal states that result from typing the four actions-
Blank move left
Blank move right
Blank move up
Blank move down

Path cost: Each step cost 1, so the path cost is the number of steps in the path.

The tree diagram showing the Search space is shown in figure


,

School of Computer Science 6


Artificial Intelligence | 7

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403

Applications of State Space Search

 State space search algorithms are used in various fields, such as robotics, game playing,
computer networks, operations research, bioinformatics, cryptography, and supply chain
management. In artificial intelligence, state space search algorithms can solve problems
like pathfinding, planning, and scheduling.
 They are also useful in planning robot motion and finding the best sequence of actions to
achieve a goal. In games, state space search algorithms can help determine the best move
for a player given a particular game state.
 State space search algorithms can optimize routing and resource allocation in computer
networks and operations research.
 In Bioinformatics, state space search algorithms can help find patterns in biological data
and predict protein structures.
 In Cryptography, state space search algorithms are used to break codes and find
cryptographic keys.

Conclusion

 State Space Search is a problem-solving technique used in AI to find a solution to a


problem by exploring all possible states of the problem.
 It is an exhaustive, complete, and optimal search process that can be classified as
uninformed or informed.
 State Space Representation is a crucial step in the state space search process as it
determines the efficiency of the search algorithm.
 State space search in artificial intelligence has several applications, including game-playing
algorithms, natural language processing, robotics, planning, scheduling, and computer
vision.

School of Computer Science 7


Artificial Intelligence | 8

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Production system
What is a Production System in AI?

A production system in AI is a framework that assists in developing computer programs to


automate a wide range of tasks. It significantly impacts the creation of AI-based systems like
computer software, mobile applications, and manufacturing tools. By establishing rules, a
production system empowers machines to demonstrate particular behaviors and adapt to their
surroundings.

In Artificial Intelligence, a production system serves as a cognitive architecture. It


encompasses rules representing declarative knowledge, allowing machines to make decisions and
act based on different conditions. Many expert systems and automation methodologies rely on the
rules defined in production systems to guide their behavior.

A production system’s architecture consists of rules structured as left-hand side (LHS) and
right-hand side (RHS) equations. The LHS specifies the condition to be evaluated, while the RHS
determines the output or action resulting from the estimated condition. This rule-based approach
forms the foundation of production systems in AI, enabling machines to process information and
respond accordingly.

The representation of knowledge in AI comprises various components used for making


intelligent machines. In the next section, we will discuss the important components of a
production system in Artificial Intelligence.

Components of a Production System in AI

For making an AI-based intelligent system that performs specific tasks, we need an
architecture. The architecture of a production system in Artificial Intelligence consists of
production rules, a database, and the control system.

School of Computer Science 8


Artificial Intelligence | 9

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Let us discuss each one of them in detail.

 Global Database -A global database consists of the architecture used as a central data
structure. A database contains all the necessary data and information required for the
successful completion of a task. It can be divided into two parts as permanent and temporary.
The permanent part of the database consists of fixed actions, whereas the temporary part
alters according to circumstances.
 Production Rules- Production rules in AI are the set of rules that operate on the data fetched
from the global database. Also, these production rules are bound with precondition and
postcondition that gets checked by the database. If a condition is passed through a production
rule and gets satisfied by the global database, then the rule is successfully applied. The rules
are of the form A®B, where the right-hand side represents an outcome corresponding to the
problem state represented by the left-hand side.
 Control System- The control system checks the applicability of a rule. It helps decide which
rule should be applied and terminates the process when the system gives the correct output. It
also resolves the conflict of multiple conditions arriving at the same time. The strategy of the
control system specifies the sequence of rules that compares the condition from the global
database to reach the correct result.

Characteristics of a Production System


There are mainly four characteristics of the production system in AI that is simplicity,
modifiability, modularity, and knowledge-intensive.

Simplicity - The production rule in AI is in the form of an ‘IF-THEN’ statement. Every rule in the
production system has a unique structure. It helps represent knowledge and reasoning in the
simplest way possible to solve real-world problems. Also, it helps improve the readability and
understanding of the production rules.

Modularity - The modularity of a production rule helps in its incremental improvement as the
production rule can be in discrete parts. The production rule is made from a collection of
information and facts that may not have dependencies unless there is a rule connecting them
together. The addition or deletion of single information will not have a major effect on the output.
Modularity helps enhance the performance of the production system by adjusting the parameters
of the rules.

Modifiability -The feature of modifiability helps alter the rules as per requirements. Initially, the

School of Computer Science 9


Artificial Intelligence | 10

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
skeletal form of the production system is created. We then gather the requirements and make
changes in the raw structure of the production system. This helps in the iterative improvement of
the production system.

Knowledge-intensive -Production systems contain knowledge in the form of a human spoken


language, i.e., English. It is not built using any programming languages. The knowledge is
represented in plain English sentences. Production rules help make productive conclusions from
these sentences.

Disadvantages of a Production System

We discussed various features of a production system in the previous section. However, many
disadvantages are also there in a production system in Artificial Intelligence, and they are as given
below:

 Opacity- Communication between the rule interpreter and the production rules creates
difficulty for the understanding of the control system and its strategies. This condition arises
due to the impact of the combined operation of the control program. There exist difficulties in
understanding the hierarchy of operations.
 Inefficiency - There are various rules that we employ for solving a problem. The rules can be
effective in different ways. There are conditions where multiple rules get activated during
execution. All the individual rules apply exhaustive searches in each cycle that reduces the
efficiency of the production system.
 Inability to Learn - A simple production system based on certain rules is not capable of
learning through experience, unlike advanced AI systems. They are simply bound to specific
rules for actions. We can understand the rules and break them.
 Conflict Resolution - To satisfy a condition, various production rules are employed. The
condition may arise when there is a triggering of more than one rule. In that condition, the
control system has to determine the best possible rule from the set of conflicting rules. This
may reduce the efficiency of the production system.

Classes of a Production System

There are four types of production systems that help in categorizing methodologies for solving
different varieties of problems. Let us have a look at each one of them.

 Monotonic Production System -In this type of a production system, the rules can be applied
simultaneously as the use of one rule does not prevent the involvement of another rule that is
School of Computer Science 10
Artificial Intelligence | 11

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
selected at the same time.
 Partially Commutative Production System- This class helps create a production system that
can give the results even by interchanging the states of rules. If using a set of rules transforms
State A into State B, then multiple combinations of those rules will be capable to convert State
A into State B.
 Non-monotonic Production System- This type of a production system increases efficiency in
solving problems. The implementation of these systems does not require backtracking to
correct the previous incorrect moves. The non-monotonic production systems are necessary
from the implementation point of view to find an efficient solution.
 Commutative System -Commutative systems are helpful where the order of an operation is
not important. Also, problems where the changes are reversible use commutative systems. On
the other hand, partially commutative production systems help in working on problems, where
the changes are irreversible such as a chemical process. When dealing with partially
commutative systems, the order of processes is important to get the correct results.

School of Computer Science 11


Artificial Intelligence | 12

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Problem characteristics
 The Essence of AI Challenges -AI problems are unique beasts. They often involve a level of
complexity and unpredictability that's not commonly found in traditional programming.
Understanding these characteristics is key to developing effective AI solutions.
 Complexity-AI problems are typically more complex than standard computational tasks. This
complexity arises from the vast data sets AI systems must process and the intricate algorithms
they employ.
 Uncertainty- Unlike traditional algorithms, AI often deals with uncertain and incomplete
information. This uncertainty requires AI systems to make predictions and decisions based on
probabilistic reasoning.
 Adaptability- AI systems must adapt to new data and evolving environments. This dynamic
nature challenges programmers to create flexible algorithms that can learn and adjust over
time.
 Goal-oriented Design- AI algorithms are designed to achieve specific goals. These goals can
range from simple tasks like sorting data to more complex objectives like facial recognition or
language translation.
 Problem Characteristics Steps- Navigating the complexity of AI problems requires a
systematic approach. Here's a step-by-step guide to understanding and solving these
challenges:
 Defining the Problem- The first step is to clearly define the problem. What exactly are you
trying to solve? This might involve processing large datasets, recognizing patterns, or making
predictions. A well-defined problem is easier to tackle.
 Data Collection & Preparation -AI thrives on data. Collect relevant data and prepare it for
analysis. This involves cleaning the data, handling missing values, and possibly transforming
the data into a format suitable for AI algorithms.
 Choosing the Right Algorithm -Different problems require different AI approaches. For
example, neural networks might be great for image recognition, while decision trees could be
better for classification tasks. Selecting the appropriate algorithm is crucial.
 Training the Model- This involves feeding the algorithm data and allowing it to learn from it.
The training process is iterative and requires constant adjustment and fine-tuning.
 Evaluation & Optimization - After training, evaluate the model's performance. Use metrics
like accuracy, precision, and recall to gauge how well your AI is performing. Based on these
evaluations, optimize the model for better performance.
 Deployment & Monitoring -Once optimized, the AI solution is deployed into a real-world
environment. Continuous monitoring is essential to ensure it adapts to new data and
conditions.

School of Computer Science 12


Artificial Intelligence | 13

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Issues in design of search program
Issues in the Design of Search Problem
Design is a signature of human intelligence. It was more difficult and big challenge for AI. Designs
shaped early ideas on automated problem solving and reasoning. It provided ever since, task for
AI which are as follows:
i. Studying, explaining and modeling the faculties underlying intelligent behaviour.
ii. Engineering systems that are capable of exhibiting for a such behavior.

Issues in Engineering Design


• When basically increasing integration on one hand and distribution work on the other hand are
the trends that determine the present and even more the future of engineering design. This type of
situation is by no means a paradox. When result of various engineering differ, different activities
should be put together. When product is complete and launched in the market, it should be
efficient and quality.

• Collaborative design transforms a chaining process into a parallel one with the aim of avoding
iteration and utilizing resources, more efficiently, (Gadh-1996). Concurrent engineering has an
even broader focus. Acknowledgeing that, engineering design must take into account the intrinsic
requirement and properties of the process that bring to life, create, maintain and re-cycle artifacts.
It embraces all main life-cycle activities such as marketing, design, manufacturing, distribution,
sales, operation, maintenance, disposal and re-cycling. The expectations are greater, fewer
modifications, shorter time-to market, more efficient resource utilization, better process and
product quality (Sohlenius, 1992) though reliable (Alting and Legarth 1995; Jansen and Krause,
1996).

1. Design Synthesis
a) Automated search

The search problems in design have been addressed mainly by the application of greedy numerical
optimization algorithm, random re-start hill-climbing, stochastic local and global search methods.
The technique is best if a design problem can be coined as a combinatorial optimization problem.
They are account neither for the cost nor for the bounded resources of best for computations.

Tangible result in economic rationally lies in the center of intelligent behaviour (Doyle etal, 1996;
Russel, 1997)

b) Model based and functional reasoning, constraint satisfaction

• Knowledge about artifacts enables reasoning about them, even if they are only partially defined.
Can constrain the design process by evaluating partial design solution can be very complex
problem (McGuinness and wright, 1998).
School of Computer Science 13
Artificial Intelligence | 14

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
• The design process is not self automanted, rather alternatives are generated deriving the
implications of the user provided data.

• The consistency of data could be preserved in the whole interactive design process. Functional
models, the traditional decomposition of function subfunction can even better direct the design
process through they cannot work on multiple levels of abstraction and without human
interaction (Umeda and Ismiled Tomiyama, 1997).

c) Case based approach to design

Lack of sufficient understanding of design synthesis and the resistance of expertise to


formalization attempts on one hand, where the surprising complexity of automated problem
solving process on the other hand led AI practitioners back to tranditional design. Practice to the
re-use of previous solution. In case based design (Maher and Garza, 1997) cases are episodic
descriptions of problem together with their associated solution and trace of the solution process.
Reasoning goes through the steps of adapting such stored cases that are particulary relevant to a
new problem. Side-stepping the main line of reasoning, new cases be added to the case-base, CBR
solve any problem to essay.

School of Computer Science 14


Artificial Intelligence | 15

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Search Techniques: DFS, BFS, Hill climbing
Problem-solving agents:
In Artificial Intelligence, Search techniques are universal problem-solving methods. Rational
agents or Problem-solving agents in AI mostly used these search strategies or algorithms to
solve a specific problem and provide the best result. Problem-solving agents are the goal-based
agents and use atomic representation. In this topic, we will learn various problem-solving search
algorithms.

Search Algorithm Terminologies:


o Search: Searchingis a step by step procedure to solve a search-problem in a given search
space. A search problem can have three main factors:
a. Search Space: Search space represents a set of possible solutions, which a system may
have.
b. Start State: It is a state from where agent begins the search.
c. Goal test: It is a function which observe the current state and returns whether the goal
state is achieved or not.
o Search tree: A tree representation of search problem is called Search tree. The root of the
search tree is the root node which is corresponding to the initial state.
o Actions: It gives the description of all the available actions to the agent.
o Transition model: A description of what each action do, can be represented as a transition
model.
o Path Cost: It is a function which assigns a numeric cost to each path.
o Solution: It is an action sequence which leads from the start node to the goal node.
o Optimal Solution: If a solution has the lowest cost among all solutions.

Properties of Search Algorithms:


Following are the four essential properties of search algorithms to compare the efficiency of these
algorithms:

 Completeness: A search algorithm is said to be complete if it guarantees to return a solution


if at least any solution exists for any random input.
 Optimality: If a solution found for an algorithm is guaranteed to be the best solution (lowest
path cost) among all other solutions, then such a solution for is said to be an optimal solution.
 Time Complexity: Time complexity is a measure of time for an algorithm to complete its
task.
 Space Complexity: It is the maximum storage space required at any point during the search,
as the complexity of the problem.

School of Computer Science 15


Artificial Intelligence | 16

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Types of search algorithms
Based on the search problems we can classify the search algorithms into uninformed (Blind search)
search and informed search (Heuristic search) algorithms.

1. Breadth-first Search:
o Breadth-first search is the most common search strategy for traversing a tree or graph. This
algorithm searches breadth wise in a tree or graph, so it is called breadth-first search.
o BFS algorithm starts searching from the root node of the tree and expands all successor node at the
current level before moving to nodes of next level.
o The breadth-first search algorithm is an example of a general-graph search algorithm.
o Breadth-first search implemented using FIFO queue data structure.

Advantages:
o BFS will provide a solution if any solution exists.
o If there is more than one solution for a given problem, then BFS will provide the minimal solution
which requires the least number of steps.

Disadvantages:
o It requires lots of memory since each level of the tree must be saved into memory to expand the
next level.
o BFS needs lots of time if the solution is far away from the root node.

School of Computer Science 16


Artificial Intelligence | 17

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Example: In the below tree structure, we have shown the traversing of the tree using BFS algorithm
from the root node S to goal node K. BFS search algorithm traverse in layers, so it will follow the path which
is shown by the dotted arrow, and the traversed path will be:

1. S---> A--->B---->C--->D---->G--->H--->E---->F---->I---->K

1. Uniformed search technique


2. FIFO (Queue)
3. Shallowest Node
4. Complete
5. Optimal
6. Time Complexity

S
AB
BCD
CDGH
DGHEF
GHEF
HEFI
EFI
FIK
IK
K

Time Complexity: Time Complexity of BFS algorithm can be obtained by the number of nodes traversed in
BFS until the shallowest Node. Where the d= depth of shallowest solution and b is a node at every
state(Branch Factor).
T (b) = 1+b2+b3+.......+ bd= O (bd)

Space Complexity: Space complexity of BFS algorithm is given by the Memory size of frontier which is
O(bd).

Completeness: BFS is complete, which means if the shallowest goal node is at some finite depth, then BFS
will find a solution.

Optimality: BFS is optimal if path cost is a non-decreasing function of the depth of the node.

School of Computer Science 17


Artificial Intelligence | 18

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
2. Depth-first Search
o Depth-first search is a recursive algorithm for traversing a tree or graph data structure.
o It is called the depth-first search because it starts from the root node and follows each path to its
greatest depth node before moving to the next path.
o DFS uses a stack data structure for its implementation.
o The process of the DFS algorithm is similar to the BFS algorithm.

Advantage:
o DFS requires very less memory as it only needs to store a stack of the nodes on the path from root
node to the current node.
o It takes less time to reach to the goal node than BFS algorithm (if it traverses in the right path).

Disadvantage:
o There is the possibility that many states keep re-occurring, and there is no guarantee of finding the
solution.
o DFS algorithm goes for deep down searching and sometime it may go to the infinite loop.

Example:
In the below search tree, we have shown the flow of depth-first search, and it will follow the order as:
Root node--->Left node ----> right node.
It will start searching from root node S, and traverse A, then B, then D and E, after traversing E, it will
backtrack the tree as E has no other successor and still goal node is not found. After backtracking it will
traverse node C and then G, and here it will terminate as it found goal node.

1. Uniformed search technique


2. LiFo (Stack)
3. Deepest Node
4. Incomplete
5. Non Optimal
6. Time Complexity

A B
H C D
H E
C
H

Completeness: DFS search algorithm is complete within finite state space as it will expand every node
within a limited search tree.

Time Complexity: Time complexity of DFS will be equivalent to the node traversed by the algorithm. It is
given by:
T(n)= 1+ n2+ n3 +.........+ nm=O(nm) or O(bd)

School of Computer Science 18


Artificial Intelligence | 19

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Where, m= maximum depth of any node and this can be much larger than d (Shallowest solution
depth)

Space Complexity: DFS algorithm needs to store only single path from the root node, hence space
complexity of DFS is equivalent to the size of the fringe set, which is O(bm).

Optimal: DFS search algorithm is non-optimal, as it may generate a large number of steps or high cost to
reach to the goal node.

School of Computer Science 19


Artificial Intelligence | 20

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Heuristic techniques

What is Heuristics?

A heuristic is a technique that is used to solve a problem faster than the classic methods. These
techniques are used to find the approximate solution of a problem when classical methods do not.
Heuristics are said to be the problem-solving techniques that result in practical and quick
solutions.

Heuristics are strategies that are derived from past experience with similar problems.
Heuristics use practical methods and shortcuts used to produce the solutions that may or may not
be optimal, but those solutions are sufficient in a given limited timeframe

Why do we need heuristics?

 Heuristics are used in situations in which there is the requirement of a short-term solution. On
facing complex situations with limited resources and time, Heuristics can help the companies
to make quick decisions by shortcuts and approximated calculations. Most of the heuristic
methods involve mental shortcuts to make decisions on past experiences.
 The heuristic method might not always provide us the finest solution, but it is assured that it
helps us find a good solution in a reasonable time.
 Based on context, there can be different heuristic methods that correlate with the problem's
scope. The most common heuristic methods are - trial and error, guesswork, the process of
elimination, historical data analysis. These methods involve simply available information that
is not particular to the problem but is most appropriate. They can include representative,
affect, and availability heuristics.

School of Computer Science 20


Artificial Intelligence | 21

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Hill Climbing Algorithm in Artificial Intelligence
o Hill climbing algorithm is a local search algorithm which continuously moves in the direction of
increasing elevation/value to find the peak of the mountain or best solution to the problem. It
terminates when it reaches a peak value where no neighbor has a higher value.
o Hill climbing algorithm is a technique which is used for optimizing the mathematical problems. One
of the widely discussed examples of Hill climbing algorithm is Traveling-salesman Problem in
which we need to minimize the distance traveled by the salesman.
o It is also called greedy local search as it only looks to its good immediate neighbor state and not
beyond that.
o A node of hill climbing algorithm has two components which are state and value.
o Hill Climbing is mostly used when a good heuristic is available.
o In this algorithm, we don't need to maintain and handle the search tree or graph as it only keeps a
single current state.

Features of Hill Climbing:


Following are some main features of Hill Climbing Algorithm:
o Generate and Test variant: Hill Climbing is the variant of Generate and Test method. The Generate
and Test method produce feedback which helps to decide which direction to move in the search
space.
o Greedy approach: Hill-climbing algorithm search moves in the direction which optimizes the cost.
o No backtracking: It does not backtrack the search space, as it does not remember the previous
states.

State-space Diagram for Hill Climbing:


The state-space landscape is a graphical representation of the hill-climbing algorithm which is showing a
graph between various states of algorithm and Objective function/Cost.

On Y-axis we have taken the function which can be an objective function or cost function, and state-space
on the x-axis. If the function on Y-axis is cost then, the goal of search is to find the global minimum and local
minimum. If the function of Y-axis is Objective function, then the goal of the search is to find the global
maximum and local maximum.

School of Computer Science 21


Artificial Intelligence | 22

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Different regions in the state space landscape:
Local Maximum: Local maximum is a state which is better than its neighbor states, but there is also
another state which is higher than it.

Global Maximum: Global maximum is the best possible state of state space landscape. It has the highest
value of objective function.

Current state: It is a state in a landscape diagram where an agent is currently present.

Flat local maximum: It is a flat space in the landscape where all the neighbor states of current states have
the same value.

Shoulder: It is a plateau region which has an uphill edge.

Types of Hill Climbing Algorithm:


o Simple hill Climbing:
o Steepest-Ascent hill-climbing:
o Stochastic hill Climbing:

1. Simple Hill Climbing:

Simple hill climbing is the simplest way to implement a hill climbing algorithm. It only evaluates the
neighbor node state at a time and selects the first one which optimizes current cost and set it as a
current state. It only checks it's one successor state, and if it finds better than the current state, then move
else be in the same state. This algorithm has the following features:

o Less time consuming


o Less optimal solution and the solution is not guaranteed

Algorithm for Simple Hill Climbing:


o Step 1: Evaluate the initial state, if it is goal state then return success and Stop.
o Step 2: Loop Until a solution is found or there is no new operator left to apply.
o Step 3: Select and apply an operator to the current state.
o Step 4: Check new state:
a. If it is goal state, then return success and quit.
b. Else if it is better than the current state then assign new state as a current state.
c. Else if not better than the current state, then return to step2.
Step 5: Exit.

2. Steepest-Ascent hill climbing:

The steepest-Ascent algorithm is a variation of simple hill climbing algorithm. This algorithm examines all
the neighboring nodes of the current state and selects one neighbor node which is closest to the goal state.
This algorithm consumes more time as it searches for multiple neighbors

School of Computer Science 22


Artificial Intelligence | 23

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403
Algorithm for Steepest-Ascent hill climbing:
o Step 1: Evaluate the initial state, if it is goal state then return success and stop, else make current
state as initial state.
o Step 2: Loop until a solution is found or the current state does not change.
a. Let SUCC be a state such that any successor of the current state will be better than it.
b. For each operator that applies to the current state:
a. Apply the new operator and generate a new state.
b. Evaluate the new state.
c. If it is goal state, then return it and quit, else compare it to the SUCC.
d. If it is better than SUCC, then set new state as SUCC.
e. If the SUCC is better than the current state, then set current state to SUCC.
Step 5: Exit.

3. Stochastic hill climbing:

Stochastic hill climbing does not examine for all its neighbor before moving. Rather, this search algorithm
selects one neighbor node at random and decides whether to choose it as a current state or examine
another state.

Problems in Hill Climbing Algorithm:


1. Local Maximum: A local maximum is a peak state in the landscape which is better than each of its
neighboring states, but there is another state also present which is higher than the local maximum.

Solution: Backtracking technique can be a solution of the local maximum in state space landscape. Create a
list of the promising path so that the algorithm can backtrack the search space and explore other paths as
well.

2. Plateau: A plateau is the flat area of the search space in which all the neighbor states of the current state
contains the same value, because of this algorithm does not find any best direction to move. A hill-climbing
search might be lost in the plateau area.

Solution: The solution for the plateau is to take big steps or very little steps while searching, to solve the
problem. Randomly select a state which is far away from the current state so it is possible that the
algorithm could find non-plateau region.

School of Computer Science 23


Artificial Intelligence | 24

RENAISSANCE UNIVERSITY, INDORE


SCHOOL OF COMPUTER SCIENCE
Artificial Intelligence BCA-403

3. Ridges: A ridge is a special form of the local maximum. It has an area which is higher than its
surrounding areas, but itself has a slope, and cannot be reached in a single move.

Solution: With the use of bidirectional search, or by moving in different directions, we can improve this
problem.

ADVERTISEMENT

Simulated Annealing:
A hill-climbing algorithm which never makes a move towards a lower value guaranteed to be incomplete
because it can get stuck on a local maximum. And if algorithm applies a random walk, by moving a
successor, then it may complete but not efficient. Simulated Annealing is an algorithm which yields both
efficiency and completeness.

In mechanical term Annealing is a process of hardening a metal or glass to a high temperature then cooling
gradually, so this allows the metal to reach a low-energy crystalline state. The same process is used in
simulated annealing in which the algorithm picks a random move, instead of picking the best move. If the
random move improves the state, then it follows the same path. Otherwise, the algorithm follows the path
which has a probability of less than 1 or it moves downhill and chooses another path.

School of Computer Science 24

You might also like