Heuristic search-in-artificial-intelligence

G

A Heuristic is a technique to solve a problem faster than classic methods, or to find an approximate solution when classic methods cannot. This is a kind of a shortcut as we often trade one of optimality, completeness, accuracy, or precision for speed. A Heuristic (or a heuristic function) takes a look at search algorithms. At each branching step, it evaluates the available information and makes a decision on which branch to follow.

What is Heuristic Search
- Techniques & Hill
Climibing in AI
Heuristic Search in Artificial Intelligence – Python
First, let’s revise the Artificial Intelligence Tutorial
What is a Heuristic Search?
A Heuristic is a technique to solve a problem faster than classic methods, or to find an
approximate solution when classic methods cannot. This is a kind of a shortcut as we
often trade one of optimality, completeness, accuracy, or precision for speed. A
Heuristic (or a heuristic function) takes a look at search algorithms. At each branching
step, it evaluates the available information and makes a decision on which branch to
follow. It does so by ranking alternatives. The Heuristic is any device that is often
effective but will not guarantee work in every case.
You must take a look at NLP Tutorial
So why do we need heuristics? One reason is to produce, in a reasonable amount of
time, a solution that is good enough for the problem in question. It doesn’t have to be
the best- an approximate solution will do since this is fast enough. Most problems are
exponential. Heuristic Search let us reduce this to a rather polynomial number. We
use this in AI because we can put it to use in situations where we can’t find known
algorithms.
We can say Heuristic Techniques are weak methods because they are vulnerable to
combinatorial explosion.
Heuristic Search Techniques in
Artificial Intelligence
Briefly, we can taxonomize such techniques of Heuristic into two categories:
Heuristic Search Techniques in Artificial Intelligence
a. Direct Heuristic Search Techniques in AI
Other names for these are Blind Search, Uninformed Search, and Blind Control
Strategy. These aren’t always possible since they demand much time or memory.
They search the entire state space for a solution and use an arbitrary ordering of
operations. Examples of these are Breadth First Search (BFS) and Depth First Search
(DFS).
Do you know about NLTK Python
b. Weak Heuristic Search Techniques in AI
Other names for these are Informed Search, Heuristic Search, and Heuristic Control
Strategy. These are effective if applied correctly to the right types of tasks and usually
demand domain-specific information. We need this extra information to compute
preference among child nodes to explore and expand. Each node has a heuristic
function associated with it. Examples are Best First Search (BFS) and A*.
Before we move on to describe certain techniques, let’s first take a look at the ones we
generally observe. Below, we name a few.
 Best-First Search
 A* Search
 Bidirectional Search
 Tabu Search
 Beam Search
 Simulated Annealing
 Hill Climbing
 Constraint Satisfaction Problems
Hill Climbing in Artifical Intelligence
First, let’s talk about Hill Climbing in Artifical Intelligence. This is a heuristic for
optimizing problems mathematically. We need to choose values from the input to
maximize or minimize a real function. It is okay if the solution isn’t the global optimal
maximum.
Heuristic Search Techniques – Hill Climbing
Let’s discuss Python Speech Recognition
One such example of Hill Climbing will be the widely discussed Travelling Salesman
Problem- one where we must minimize the distance he travels.
a. Features of Hill Climbing in AI
Let’s discuss some of the features of this algorithm (Hill Climbing):
 It is a variant of the generate-and-test algorithm
 It makes use of the greedy approach
This means it keeps generating possible solutions until it finds the expected solution,
and moves only in the direction which optimizes the cost function for it.
b. Types of Hill Climbing in AI
Heuristic Search – Types of Hill Climbing in Artifical Intelligence
 Simple Hill Climbing- This examines one neighboring node at a time and selects
the first one that optimizes the current cost to be the next node.
 Steepest Ascent Hill Climbing- This examines all neighboring nodes and selects
the one closest to the solution state.
 Stochastic Hill Climbing- This selects a neighboring node at random and decides
whether to move to it or examine another.
Let’s revise Python Unit testing
Let’s take a look at the algorithm for simple hill climbing.
1. Evaluate initial state- if goal state, stop and return success. Else, make initial state
current.
2. Loop until the solution reached or until no new operators left to apply to current
state:
a. Select new operator to apply to the current producing new state.
b. Evaluate new state:
 If a goal state, stop and return success.
 If better than the current state, make it current state, proceed.
 Even if not better than the current state, continue until the solution reached.
3. Exit.
c. Problems with Hill Climbing in AI
We usually run into one of three issues-
 Local Maximum- All neighboring states have values worse than the current. The
greedy approach means we won’t be moving to a worse state. This terminates the
process even though there may have been a better solution. As a workaround, we
use backtracking.
 Plateau- All neighbors to it have the same value. This makes it impossible to
choose a direction. To avoid this, we randomly make a big jump.
 Ridge- At a ridge, movement in all possible directions is downward. This makes
it look like a peak and terminates the process. To avoid this, we may use two or
more rules before testing.
Do you know about Python Assert Statements
Constraint Satisfaction Problems
(CSP)
A constraint is nothing but a limitation or a restriction. Working with AI, we may
need to satisfy some constraints to solve problems. Let’s try solving a problem this
way, shall we?
Let’s talk of a magic square. This is a sequence of numbers- usually integers-
arranged in a square grid. The numbers in each row, each column, and each diagonal
all add up to a constant which we call the Magic Constant. Let’s implement this with
Python.
1. def magic_square(matrix):
2. size=len(matrix[0])
3. sum_list=[]
4. for col in range(size): #Vertical sum
5. sum_list.append(sum(row[col] for row in matrix))
6. sum_list.extend([sum(lines) for lines in matrix])#Horizontal sum
7. result1=0
8. for i in range(0,size):
9. result1+=matrix[i][i]
10. sum_list.append(result1)
11. result2=0
12. for i in range(size-1,-1,-1):
13. result2+=matrix[i][i]
14. sum_list.append(result2)
15. if len(set(sum_list))>1:
16. return False
17. return True
Now let’s run this code.
1. >>> magic_square([[1,2,3],[4,5,6],[7,8,9]])
False
This is not a magic square. The numbers in the rows/columns/diagonals do not add up
to the same value. Let’s try another list of lists.
Have a look at AI Neural Networks
1. >>> magic_square([[2,7,6],[9,5,1],[4,3,8]])
True
Heuristic Search – Magic
Since the values add up to the constant 15 in all directions, surely, this is a magic
square!
Simulated Annealing Heuristic Search
In metallurgy, when we slow-cool metals to pull them down to a state of low energy
gives them exemplary amounts of strength. We call this annealing. While high
temperatures observe much random movement, low temperatures notice little
randomness.
In AI, we take a cue from this to produce something called simulated annealing. This
is a way of optimization where we begin with a random search at a high temperature
and reduce the temperature slowly. Eventually, as the temperature approaches zero,
the search becomes pure greedy descent. At each step, this processes randomly selects
a variable and a value. It accepts the assignment only when it is an improvement or
doesn’t lead to more conflict. If not, it checks if the temperature is much worse than
the current assignment to accept the assignment with some probability.
Do you know about Python ternary Operators
An annealing schedule defines how the temperature drops as the search progress. A
very common schedule is geometric cooling. If we begin with a temperature of 10 and
multiply by 0.97 after every step, then after 100 steps, we’re left with a temperature of
0.48.
Best-First Search (BFS) Heuristic
Search
Often dubbed BFS, Best First Search is an informed search that uses an evaluation
function to decide which adjacent is the most promising before it can continue to
explore. Breadth- and Depth- First Searches blindly explore paths without keeping a
cost function in mind. Things aren’t the same with BFS, though. Here, we use a
priority queue to store node costs. Let’s understand BFS Heuristic Search through
pseudocode.
1. Define list OPEN with single node s– the start node.
2. IF list is empty, return failure.
3. Remove node n (node with best score) from list, move it to list CLOSED.
4. Expand node n.
5. IF any successor to n is the goal node, return success and trace path from goal
node to s to return the solution.
6. FOR each successor node:
 Apply evaluation function f.
 IF the node isn’t in either list, add it to list OPEN.
7. Loop to step 2.
Let’s learn about Python Slice
So, this was all in Heuristic Search Techniques in AI. Hope you like our
explanation.
Conclusion – Heuristic Search
Techniques
Hence, in this Python AI tutorial, we discussed the Heuristic Search in AI. While we
named a few techniques that fall under that, we also discussed, in brief, those like
BFS, Hill Climbing, Simulated Annealing, and CSP. We also implemented CSP in
Python. Still, if you have any query in Heuristic Search Techniques, feel free to ask in
the comment tab.

Recomendados

Informed search (heuristics) por
Informed search (heuristics)Informed search (heuristics)
Informed search (heuristics)Bablu Shofi
962 visualizações31 slides
AI: AI & Problem Solving por
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem SolvingDataminingTools Inc
36.4K visualizações17 slides
AI Lecture 3 (solving problems by searching) por
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)Tajim Md. Niamat Ullah Akhund
4K visualizações71 slides
Artificial Intelligence Searching Techniques por
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesDr. C.V. Suresh Babu
3.2K visualizações38 slides
Heuristic Search Techniques {Artificial Intelligence} por
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}FellowBuddy.com
32.6K visualizações22 slides
I.BEST FIRST SEARCH IN AI por
I.BEST FIRST SEARCH IN AII.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AIvikas dhakane
2.2K visualizações7 slides

Mais conteúdo relacionado

Mais procurados

Informed search por
Informed searchInformed search
Informed searchAmit Rathi
1.4K visualizações84 slides
Solving problems by searching por
Solving problems by searchingSolving problems by searching
Solving problems by searchingLuigi Ceccaroni
12.8K visualizações48 slides
I. Hill climbing algorithm II. Steepest hill climbing algorithm por
I. Hill climbing algorithm II. Steepest hill climbing algorithmI. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithmvikas dhakane
972 visualizações14 slides
Informed and Uninformed search Strategies por
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search StrategiesAmey Kerkar
49.4K visualizações76 slides
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE por
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCEIntelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCEKhushboo Pal
9.9K visualizações29 slides
Ai 03 solving_problems_by_searching por
Ai 03 solving_problems_by_searchingAi 03 solving_problems_by_searching
Ai 03 solving_problems_by_searchingMohammed Romi
3.1K visualizações32 slides

Mais procurados(20)

Informed search por Amit Rathi
Informed searchInformed search
Informed search
Amit Rathi1.4K visualizações
Solving problems by searching por Luigi Ceccaroni
Solving problems by searchingSolving problems by searching
Solving problems by searching
Luigi Ceccaroni12.8K visualizações
I. Hill climbing algorithm II. Steepest hill climbing algorithm por vikas dhakane
I. Hill climbing algorithm II. Steepest hill climbing algorithmI. Hill climbing algorithm II. Steepest hill climbing algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithm
vikas dhakane972 visualizações
Informed and Uninformed search Strategies por Amey Kerkar
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search Strategies
Amey Kerkar49.4K visualizações
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE por Khushboo Pal
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCEIntelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Khushboo Pal9.9K visualizações
Ai 03 solving_problems_by_searching por Mohammed Romi
Ai 03 solving_problems_by_searchingAi 03 solving_problems_by_searching
Ai 03 solving_problems_by_searching
Mohammed Romi3.1K visualizações
AI_Session 7 Greedy Best first search algorithm.pptx por Asst.Prof. M.Gokilavani
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptx
Asst.Prof. M.Gokilavani454 visualizações
Hill climbing por Mohammad Faizan
Hill climbingHill climbing
Hill climbing
Mohammad Faizan67.9K visualizações
Unit3:Informed and Uninformed search por Tekendra Nath Yogi
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
Tekendra Nath Yogi1.1K visualizações
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf por JenishaR1
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdfUNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
UNIT - I PROBLEM SOLVING AGENTS and EXAMPLES.pptx.pdf
JenishaR1494 visualizações
Artificial Intelligence -- Search Algorithms por Syed Ahmed
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms
Syed Ahmed4.3K visualizações
Agents in Artificial intelligence por Lalit Birla
Agents in Artificial intelligence Agents in Artificial intelligence
Agents in Artificial intelligence
Lalit Birla2.4K visualizações
Problem solving agents por Megha Sharma
Problem solving agentsProblem solving agents
Problem solving agents
Megha Sharma4.2K visualizações
Local search algorithm por Megha Sharma
Local search algorithmLocal search algorithm
Local search algorithm
Megha Sharma2.5K visualizações
Heuristc Search Techniques por Jismy .K.Jose
Heuristc Search TechniquesHeuristc Search Techniques
Heuristc Search Techniques
Jismy .K.Jose9.9K visualizações
Hill climbing algorithm in artificial intelligence por sandeep54552
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligence
sandeep545525.7K visualizações
Heuristic Search Techniques Unit -II.ppt por karthikaparthasarath
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
karthikaparthasarath1.1K visualizações
Lecture 11 Informed Search por Hema Kashyap
Lecture 11 Informed SearchLecture 11 Informed Search
Lecture 11 Informed Search
Hema Kashyap1.2K visualizações
State space search por chauhankapil
State space searchState space search
State space search
chauhankapil693 visualizações

Similar a Heuristic search-in-artificial-intelligence

A* Algorithm por
A* AlgorithmA* Algorithm
A* AlgorithmDr. C.V. Suresh Babu
3.1K visualizações15 slides
CSA 2001 (Module-2).pptx por
CSA 2001 (Module-2).pptxCSA 2001 (Module-2).pptx
CSA 2001 (Module-2).pptxPranjalKhare13
18 visualizações123 slides
Ai planning with evolutionary computing por
Ai planning with evolutionary computingAi planning with evolutionary computing
Ai planning with evolutionary computingpinozz
410 visualizações15 slides
Types of Algorithms.ppt por
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.pptALIZAIB KHAN
9 visualizações36 slides
Artificial Intelligence por
Artificial IntelligenceArtificial Intelligence
Artificial IntelligenceJay Nagar
1K visualizações19 slides
DAA UNIT 3 por
DAA UNIT 3DAA UNIT 3
DAA UNIT 3SURBHI SAROHA
203 visualizações14 slides

Similar a Heuristic search-in-artificial-intelligence(20)

CSA 2001 (Module-2).pptx por PranjalKhare13
CSA 2001 (Module-2).pptxCSA 2001 (Module-2).pptx
CSA 2001 (Module-2).pptx
PranjalKhare1318 visualizações
Ai planning with evolutionary computing por pinozz
Ai planning with evolutionary computingAi planning with evolutionary computing
Ai planning with evolutionary computing
pinozz410 visualizações
Types of Algorithms.ppt por ALIZAIB KHAN
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.ppt
ALIZAIB KHAN9 visualizações
Artificial Intelligence por Jay Nagar
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
Jay Nagar1K visualizações
DAA UNIT 3 por SURBHI SAROHA
DAA UNIT 3DAA UNIT 3
DAA UNIT 3
SURBHI SAROHA203 visualizações
AI_Lecture2.pptx por saadurrehman35
AI_Lecture2.pptxAI_Lecture2.pptx
AI_Lecture2.pptx
saadurrehman3534 visualizações
daa unit 1.pptx por LakshayYadav46
daa unit 1.pptxdaa unit 1.pptx
daa unit 1.pptx
LakshayYadav4618 visualizações
Comparative study of different algorithms por ijfcstjournal
Comparative study of different algorithmsComparative study of different algorithms
Comparative study of different algorithms
ijfcstjournal307 visualizações
hill climbing algorithm.pptx por MghooolMasier
hill climbing algorithm.pptxhill climbing algorithm.pptx
hill climbing algorithm.pptx
MghooolMasier117 visualizações
Heuristis search por sajidktk96
Heuristis searchHeuristis search
Heuristis search
sajidktk9633 visualizações
Introduction to Algorithms por Mohamed Essam
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
Mohamed Essam94 visualizações
CPP12 - Algorithms por Michael Heron
CPP12 - AlgorithmsCPP12 - Algorithms
CPP12 - Algorithms
Michael Heron295 visualizações
Ic lecture6 architecture and algo por AttaullahRahimoon
Ic lecture6 architecture and algoIc lecture6 architecture and algo
Ic lecture6 architecture and algo
AttaullahRahimoon16 visualizações
Algorithm analysis (All in one) por jehan1987
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
jehan19873.7K visualizações
02 problem solving_search_control por Praveen Kumar
02 problem solving_search_control02 problem solving_search_control
02 problem solving_search_control
Praveen Kumar2.7K visualizações
RAJAT PROJECT.pptx por SayedMohdAsim2
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
SayedMohdAsim26 visualizações
Architecture Algorithm Definition por Gaditek
Architecture Algorithm DefinitionArchitecture Algorithm Definition
Architecture Algorithm Definition
Gaditek1.9K visualizações

Mais de grinu

Artificial neural network for machine learning por
Artificial neural network for machine learningArtificial neural network for machine learning
Artificial neural network for machine learninggrinu
572 visualizações7 slides
Why should I learn python por
Why should I learn pythonWhy should I learn python
Why should I learn pythongrinu
96 visualizações5 slides
Python standard library & list of important libraries por
Python standard library & list of important librariesPython standard library & list of important libraries
Python standard library & list of important librariesgrinu
333 visualizações18 slides
Data mining tutorial por
Data mining tutorialData mining tutorial
Data mining tutorialgrinu
91 visualizações17 slides
Python Machine Learning Tutorial por
Python Machine Learning TutorialPython Machine Learning Tutorial
Python Machine Learning Tutorialgrinu
111 visualizações16 slides
Machine Learning Tutorial for Beginners por
Machine Learning Tutorial for BeginnersMachine Learning Tutorial for Beginners
Machine Learning Tutorial for Beginnersgrinu
134 visualizações9 slides

Mais de grinu(8)

Artificial neural network for machine learning por grinu
Artificial neural network for machine learningArtificial neural network for machine learning
Artificial neural network for machine learning
grinu572 visualizações
Why should I learn python por grinu
Why should I learn pythonWhy should I learn python
Why should I learn python
grinu96 visualizações
Python standard library & list of important libraries por grinu
Python standard library & list of important librariesPython standard library & list of important libraries
Python standard library & list of important libraries
grinu333 visualizações
Data mining tutorial por grinu
Data mining tutorialData mining tutorial
Data mining tutorial
grinu91 visualizações
Python Machine Learning Tutorial por grinu
Python Machine Learning TutorialPython Machine Learning Tutorial
Python Machine Learning Tutorial
grinu111 visualizações
Machine Learning Tutorial for Beginners por grinu
Machine Learning Tutorial for BeginnersMachine Learning Tutorial for Beginners
Machine Learning Tutorial for Beginners
grinu134 visualizações
20 interesting-applications-of-deep-learning-with-python por grinu
20 interesting-applications-of-deep-learning-with-python20 interesting-applications-of-deep-learning-with-python
20 interesting-applications-of-deep-learning-with-python
grinu40 visualizações
Python AI tutorial por grinu
Python AI tutorialPython AI tutorial
Python AI tutorial
grinu174 visualizações

Último

Choosing the Right Flutter App Development Company por
Choosing the Right Flutter App Development CompanyChoosing the Right Flutter App Development Company
Choosing the Right Flutter App Development CompanyFicode Technologies
13 visualizações9 slides
Generative AI: Shifting the AI Landscape por
Generative AI: Shifting the AI LandscapeGenerative AI: Shifting the AI Landscape
Generative AI: Shifting the AI LandscapeDeakin University
67 visualizações55 slides
Innovation & Entrepreneurship strategies in Dairy Industry por
Innovation & Entrepreneurship strategies in Dairy IndustryInnovation & Entrepreneurship strategies in Dairy Industry
Innovation & Entrepreneurship strategies in Dairy IndustryPervaizDar1
35 visualizações26 slides
LLMs in Production: Tooling, Process, and Team Structure por
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team StructureAggregage
57 visualizações77 slides
AIM102-S_Cognizant_CognizantCognitive por
AIM102-S_Cognizant_CognizantCognitiveAIM102-S_Cognizant_CognizantCognitive
AIM102-S_Cognizant_CognizantCognitivePhilipBasford
21 visualizações36 slides
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023 por
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023BookNet Canada
44 visualizações19 slides

Último(20)

Choosing the Right Flutter App Development Company por Ficode Technologies
Choosing the Right Flutter App Development CompanyChoosing the Right Flutter App Development Company
Choosing the Right Flutter App Development Company
Ficode Technologies13 visualizações
Generative AI: Shifting the AI Landscape por Deakin University
Generative AI: Shifting the AI LandscapeGenerative AI: Shifting the AI Landscape
Generative AI: Shifting the AI Landscape
Deakin University67 visualizações
Innovation & Entrepreneurship strategies in Dairy Industry por PervaizDar1
Innovation & Entrepreneurship strategies in Dairy IndustryInnovation & Entrepreneurship strategies in Dairy Industry
Innovation & Entrepreneurship strategies in Dairy Industry
PervaizDar135 visualizações
LLMs in Production: Tooling, Process, and Team Structure por Aggregage
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team Structure
Aggregage57 visualizações
AIM102-S_Cognizant_CognizantCognitive por PhilipBasford
AIM102-S_Cognizant_CognizantCognitiveAIM102-S_Cognizant_CognizantCognitive
AIM102-S_Cognizant_CognizantCognitive
PhilipBasford21 visualizações
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023 por BookNet Canada
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
BookNet Canada44 visualizações
Digital Personal Data Protection (DPDP) Practical Approach For CISOs por Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash162 visualizações
Optimizing Communication to Optimize Human Behavior - LCBM por Yaman Kumar
Optimizing Communication to Optimize Human Behavior - LCBMOptimizing Communication to Optimize Human Behavior - LCBM
Optimizing Communication to Optimize Human Behavior - LCBM
Yaman Kumar38 visualizações
"Package management in monorepos", Zoltan Kochan por Fwdays
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan Kochan
Fwdays34 visualizações
Measuring User on the web with the core web vitals - by @theafolayan.pptx por Oluwaseun Raphael Afolayan
Measuring User on the web with the core web vitals - by @theafolayan.pptxMeasuring User on the web with the core web vitals - by @theafolayan.pptx
Measuring User on the web with the core web vitals - by @theafolayan.pptx
Oluwaseun Raphael Afolayan14 visualizações
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... por BookNet Canada
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
BookNet Canada41 visualizações
Business Analyst Series 2023 - Week 4 Session 7 por DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10146 visualizações
Cocktail of Environments. How to Mix Test and Development Environments and St... por Aleksandr Tarasov
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
Aleksandr Tarasov23 visualizações
"Running students' code in isolation. The hard way", Yurii Holiuk por Fwdays
"Running students' code in isolation. The hard way", Yurii Holiuk "Running students' code in isolation. The hard way", Yurii Holiuk
"Running students' code in isolation. The hard way", Yurii Holiuk
Fwdays36 visualizações
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」 por PC Cluster Consortium
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」
PC Cluster Consortium25 visualizações
The Role of Patterns in the Era of Large Language Models por Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li91 visualizações
Inawisdom IDP por PhilipBasford
Inawisdom IDPInawisdom IDP
Inawisdom IDP
PhilipBasford15 visualizações
This talk was not generated with ChatGPT: how AI is changing science por Elena Simperl
This talk was not generated with ChatGPT: how AI is changing scienceThis talk was not generated with ChatGPT: how AI is changing science
This talk was not generated with ChatGPT: how AI is changing science
Elena Simperl32 visualizações
GDSC GLAU Info Session.pptx por gauriverrma4
GDSC GLAU Info Session.pptxGDSC GLAU Info Session.pptx
GDSC GLAU Info Session.pptx
gauriverrma415 visualizações
Qualifying SaaS, IaaS.pptx por Sachin Bhandari
Qualifying SaaS, IaaS.pptxQualifying SaaS, IaaS.pptx
Qualifying SaaS, IaaS.pptx
Sachin Bhandari1.1K visualizações

Heuristic search-in-artificial-intelligence

  • 1. What is Heuristic Search - Techniques & Hill Climibing in AI
  • 2. Heuristic Search in Artificial Intelligence – Python First, let’s revise the Artificial Intelligence Tutorial What is a Heuristic Search? A Heuristic is a technique to solve a problem faster than classic methods, or to find an approximate solution when classic methods cannot. This is a kind of a shortcut as we often trade one of optimality, completeness, accuracy, or precision for speed. A Heuristic (or a heuristic function) takes a look at search algorithms. At each branching step, it evaluates the available information and makes a decision on which branch to follow. It does so by ranking alternatives. The Heuristic is any device that is often effective but will not guarantee work in every case. You must take a look at NLP Tutorial So why do we need heuristics? One reason is to produce, in a reasonable amount of time, a solution that is good enough for the problem in question. It doesn’t have to be the best- an approximate solution will do since this is fast enough. Most problems are exponential. Heuristic Search let us reduce this to a rather polynomial number. We use this in AI because we can put it to use in situations where we can’t find known algorithms. We can say Heuristic Techniques are weak methods because they are vulnerable to combinatorial explosion.
  • 3. Heuristic Search Techniques in Artificial Intelligence Briefly, we can taxonomize such techniques of Heuristic into two categories: Heuristic Search Techniques in Artificial Intelligence a. Direct Heuristic Search Techniques in AI Other names for these are Blind Search, Uninformed Search, and Blind Control Strategy. These aren’t always possible since they demand much time or memory. They search the entire state space for a solution and use an arbitrary ordering of operations. Examples of these are Breadth First Search (BFS) and Depth First Search (DFS). Do you know about NLTK Python b. Weak Heuristic Search Techniques in AI Other names for these are Informed Search, Heuristic Search, and Heuristic Control Strategy. These are effective if applied correctly to the right types of tasks and usually demand domain-specific information. We need this extra information to compute preference among child nodes to explore and expand. Each node has a heuristic
  • 4. function associated with it. Examples are Best First Search (BFS) and A*. Before we move on to describe certain techniques, let’s first take a look at the ones we generally observe. Below, we name a few.  Best-First Search  A* Search  Bidirectional Search  Tabu Search  Beam Search  Simulated Annealing  Hill Climbing  Constraint Satisfaction Problems Hill Climbing in Artifical Intelligence First, let’s talk about Hill Climbing in Artifical Intelligence. This is a heuristic for optimizing problems mathematically. We need to choose values from the input to maximize or minimize a real function. It is okay if the solution isn’t the global optimal maximum. Heuristic Search Techniques – Hill Climbing Let’s discuss Python Speech Recognition One such example of Hill Climbing will be the widely discussed Travelling Salesman Problem- one where we must minimize the distance he travels.
  • 5. a. Features of Hill Climbing in AI Let’s discuss some of the features of this algorithm (Hill Climbing):  It is a variant of the generate-and-test algorithm  It makes use of the greedy approach This means it keeps generating possible solutions until it finds the expected solution, and moves only in the direction which optimizes the cost function for it. b. Types of Hill Climbing in AI Heuristic Search – Types of Hill Climbing in Artifical Intelligence  Simple Hill Climbing- This examines one neighboring node at a time and selects the first one that optimizes the current cost to be the next node.  Steepest Ascent Hill Climbing- This examines all neighboring nodes and selects the one closest to the solution state.  Stochastic Hill Climbing- This selects a neighboring node at random and decides whether to move to it or examine another. Let’s revise Python Unit testing Let’s take a look at the algorithm for simple hill climbing. 1. Evaluate initial state- if goal state, stop and return success. Else, make initial state current.
  • 6. 2. Loop until the solution reached or until no new operators left to apply to current state: a. Select new operator to apply to the current producing new state. b. Evaluate new state:  If a goal state, stop and return success.  If better than the current state, make it current state, proceed.  Even if not better than the current state, continue until the solution reached. 3. Exit. c. Problems with Hill Climbing in AI We usually run into one of three issues-  Local Maximum- All neighboring states have values worse than the current. The greedy approach means we won’t be moving to a worse state. This terminates the process even though there may have been a better solution. As a workaround, we use backtracking.  Plateau- All neighbors to it have the same value. This makes it impossible to choose a direction. To avoid this, we randomly make a big jump.  Ridge- At a ridge, movement in all possible directions is downward. This makes it look like a peak and terminates the process. To avoid this, we may use two or more rules before testing. Do you know about Python Assert Statements Constraint Satisfaction Problems (CSP) A constraint is nothing but a limitation or a restriction. Working with AI, we may need to satisfy some constraints to solve problems. Let’s try solving a problem this way, shall we? Let’s talk of a magic square. This is a sequence of numbers- usually integers- arranged in a square grid. The numbers in each row, each column, and each diagonal all add up to a constant which we call the Magic Constant. Let’s implement this with Python. 1. def magic_square(matrix): 2. size=len(matrix[0]) 3. sum_list=[] 4. for col in range(size): #Vertical sum 5. sum_list.append(sum(row[col] for row in matrix)) 6. sum_list.extend([sum(lines) for lines in matrix])#Horizontal sum
  • 7. 7. result1=0 8. for i in range(0,size): 9. result1+=matrix[i][i] 10. sum_list.append(result1) 11. result2=0 12. for i in range(size-1,-1,-1): 13. result2+=matrix[i][i] 14. sum_list.append(result2) 15. if len(set(sum_list))>1: 16. return False 17. return True Now let’s run this code. 1. >>> magic_square([[1,2,3],[4,5,6],[7,8,9]]) False This is not a magic square. The numbers in the rows/columns/diagonals do not add up to the same value. Let’s try another list of lists. Have a look at AI Neural Networks 1. >>> magic_square([[2,7,6],[9,5,1],[4,3,8]]) True
  • 8. Heuristic Search – Magic Since the values add up to the constant 15 in all directions, surely, this is a magic square! Simulated Annealing Heuristic Search In metallurgy, when we slow-cool metals to pull them down to a state of low energy gives them exemplary amounts of strength. We call this annealing. While high temperatures observe much random movement, low temperatures notice little randomness. In AI, we take a cue from this to produce something called simulated annealing. This is a way of optimization where we begin with a random search at a high temperature and reduce the temperature slowly. Eventually, as the temperature approaches zero, the search becomes pure greedy descent. At each step, this processes randomly selects a variable and a value. It accepts the assignment only when it is an improvement or
  • 9. doesn’t lead to more conflict. If not, it checks if the temperature is much worse than the current assignment to accept the assignment with some probability. Do you know about Python ternary Operators An annealing schedule defines how the temperature drops as the search progress. A very common schedule is geometric cooling. If we begin with a temperature of 10 and multiply by 0.97 after every step, then after 100 steps, we’re left with a temperature of 0.48. Best-First Search (BFS) Heuristic Search Often dubbed BFS, Best First Search is an informed search that uses an evaluation function to decide which adjacent is the most promising before it can continue to explore. Breadth- and Depth- First Searches blindly explore paths without keeping a cost function in mind. Things aren’t the same with BFS, though. Here, we use a priority queue to store node costs. Let’s understand BFS Heuristic Search through pseudocode. 1. Define list OPEN with single node s– the start node. 2. IF list is empty, return failure. 3. Remove node n (node with best score) from list, move it to list CLOSED. 4. Expand node n. 5. IF any successor to n is the goal node, return success and trace path from goal node to s to return the solution. 6. FOR each successor node:  Apply evaluation function f.  IF the node isn’t in either list, add it to list OPEN. 7. Loop to step 2. Let’s learn about Python Slice So, this was all in Heuristic Search Techniques in AI. Hope you like our explanation. Conclusion – Heuristic Search Techniques
  • 10. Hence, in this Python AI tutorial, we discussed the Heuristic Search in AI. While we named a few techniques that fall under that, we also discussed, in brief, those like BFS, Hill Climbing, Simulated Annealing, and CSP. We also implemented CSP in Python. Still, if you have any query in Heuristic Search Techniques, feel free to ask in the comment tab.