SlideShare uma empresa Scribd logo
1 de 27
Informed Search
Hill Climbing
• Back – Tracking
• Use Enqued List
• Informed Search
• Very similar to DFS except instead of using
lexical order to break ties, it break ties
according to which node is closer to the goal.
• Hill Climbing: Front Sorted
Hill Climbing
• It starts with random (potentially poor)
solution, and iteratively makes small changes
to the solution, each time improving it a little.
When the algorithm cannot see any
improvement anymore, it terminates.
• Ideally, at that point the current solution is
close to optimal, but it is not guaranteed that
hill climbing will ever come close to the
optimal solution.
Hill Climbing
• Hill climbing can be applied to the travelling
salesman problem.
• It is easy to find a solution that visits all the
cities but will be very poor compared to the
optimal solution.
Hill Climbing
The hill climbing can be described as follows:
1. Start with current-state = initial state
2. Until current-state = goal-state OR there is no
change in current-state do:
– Get the successors of the current state and use the
evaluating function to assign a score to each
successor.
– If one of the successors has a better score than the
current-state then set the new current-state to be the
successor with the best score.
• Hill climbing terminates when there are no
successors of the current state which are better
than the current state itself.
Hill Climbing
• Hill climbing is depth-first search with a
heuristic measurement that orders choices as
nodes are expanded. It always selects the
most promising successor of the node last
expanded.
Hill Climbing
• For instance, consider that the most
promising successor of a node is the one
that has the shortest straight-line
distance to the goal node G.
• In figure below, the straight line
distances between each city and goal G
is indicated in square brackets, i.e. the
heuristic.
Hill Climbing
• Problems with Hill Climbing
– Gets stuck at local maxima when we reach a
position where there are no better neighbors, it is
not a guarantee that we have found the best
solution. Ridge is a sequence of local maxima.
– Another type of problem we may find with hill
climbing searches is finding a plateau. This is an
area where the search space is flat so that all
neighbors returns the same evaluation.
Hill Climbing
S
A
A
G
E
FB
88.5
8.5 6
6 3
D
The hill climbing search from S to G proceeds as
follows:
S
A
D
B
E
C
F
G
3
4 4
5 5
42
4
3
[8]
[8.5] [6]
[6] [3]
[3]
[10]
Hill Climbing
• Apply the hill climbing algorithm to find a path
from S to G, considering that the most promising
successor of a node is its closest neighbor.
S
A
D
B
E
C
F
G
3
4 4
5 5
42
4
3
Hill Climbing
•the best first search method selects for expansion the
most promising leaf node of the current search tree
•the hill climbing search method selects for expansion the most
promising successor of the node last expanded.
• In depth-first search: front of the queue (a stack).
• In breadth-first search: back of the queue.
• Now, in hill-climbing search, you sort[1] the current node's
children before adding them to the queue.
• In best-first search, you add the current node's children to
the queue in any order, then sort[1] the entire queue.
• [1]: sort according to some problem-specific evaluation of the
solution node, for example "distance from destination" in a
path-finding search
Hill Climbing
AI, Subash Chandra Pakhrin 12
S
G
D
E
B
A
C
5
4
4
6
3
5
7+
6
7+
S
A B
G
A C
D
7+ 6
5
7+
7+ 3
A and C are both equally far from goal, so now we are going to use
lexical order to break the tie
Beam Search
S
A B
B D
C G
A C
Beam width (w) = 2
Beam: Keep w Best
Annealing
• In metallurgy, annealing is the process used to
temper or harden metals and glass by heating
them to a high temperature and then
gradually cooling them, thus allowing material
to reach a low energy crystalline state.
• This can be applied to computer science
problems.
Simulated Annealing
• It is applied to solve problems like
– Travelling salesman problem
– Designing printed circuit boards
– Solving VLSI layout problems
– Factory scheduling
– Large-scale optimization task
– Planning of path for a robot
– Bioinformatics to design three dimension
structures of protein molecules.
Simulated Annealing
• A hill climbing algorithm that never makes “down
hill” moves towards states with lower value is
guaranteed to be incomplete, because it can get
stuck on a local maximum.
• In contrast, a purely random walk – that is,
moving to a successor chosen uniformly at
random from the set of successors- is complete
but extremely inefficient.
• Simulated Annealing = hill climbing + random
walk hence, it is efficient as well as completeness.
Simulated Annealing
• At the beginning you don’t care if you are
actually moving towards the good solution
and you accept bad moves as well, you accept
bad configurations as well but as you progress
towards the solution we become more careful
and we try to get closer to the solution by
selecting only the good moves.
Simulated Annealing
• Switch the perspective from hill climbing to gradient
descent.
• Imagine the task of getting a ping-pong ball into he
deepest crevice in a bumpy surface.
• If we just let the ball roll, it will get come to rest at a
local minimum.
• If we shake the surface, we can bounce the ball out of
local minimum.
• The trick is to shake just hard enough to bounce the
ball out of local minimum but not hard enough to
dislodge it from the global minimum.
• Simulated Annealing solution is to start by shaking hard
(i.e., at a high temperature) and then gradually reduce
the intensity of shaking (i.e., lower the temperature)
Simulated Annealing
• E = Energy of the system
• ΔE = Change in energy
• We need to have a mechanism to alter the
configuration
All possible configurations of a given system
E
n
e
r
g
y
C N
Move
Simulated Annealing
C = C init
for T = T max to T min
E c = E(C)
N = next (C)
EN = E(N)
ΔE = EN – EC
If (ΔE > 0)
C = N
else if (eΔE/T > rand (0, 1))
C = N
epoch
Simulated Annealing
• If the change in energy is negative, or in other
words if we are making bad move.
– In this case we compute probability
• If probability is very high then we accept the move
even if it is a bad move.
• If probability is very low then we have low probability
to accept the bad move.
• Probability depends upon two variables
change in energy ΔE and the temperature
factor T.
Simulated Annealing
• When temperature is very high then
probability for accepting bad move is very
high. In other words, at high temperature we
are exploring the solution space or we are
exploiting the configuration and we’re
accepting bad moves as well.
• When the temperature is low this probability
becomes very low and we have very low
probability to accept bad moves.
Simulated Annealing
• Case 1: T = 1000, ΔE = 10
ΔE/T = 0.01
eΔ E/T = 0.99004
A number that is close to one has a very high
(correlation) probability to become greater than a
random number between 0 and 1, which means
we get a very high probability, so when
temperature is very high we have high probability
to accept bad moves as well.
Simulated Annealing
ΔE influences probability
• ΔE is very high = a low probability to accept the
move
• ΔE is small = high probability to accept the move.
• We repeat the process for certain number of
times usually known as the number of epochs,
usually 100 to 200 times and for every value of
temperature we repeat the process and finally
expecting the solution to converge towards the
global minimum.
Simulated Annealing
• Now on either extremes are 2 other algorithms
1. Hill Climbing
2. Random Walk
• If we remove the probability factor or the
temperature factor and always accept the good
moves only then that’s hill climbing or it’s like a
greedy algorithm which always go towards a
better solution. Such, algorithms are prone to be
easily stuck in local minima.
Simulated Annealing
• Random walk: It doesn’t care about how good
a move we are making every time but we just
explore, continue to explore, the space. Such
algorithm never converge and will probably
never give you the best optimal solution.
Simulated Annealing
• Parameters T max to T min and number of epochs
are dependent on the problem that we are
solving, usually we start with high temperature
like few thousands, let’s say 5000 or 3000 and
then the minimum temperature is set to a small
value like 0 or 10 or something like that.
• Number of epoch is usually a hundred, or 200
depending on the problem
• If you run multiple times you will have an idea
whether you’re being stuck in the local minima or
global minimum

Mais conteúdo relacionado

Semelhante a Lec 6 bsc csit

Artificial Intelligence_Anjali_Kumari_26900122059.pptx
Artificial Intelligence_Anjali_Kumari_26900122059.pptxArtificial Intelligence_Anjali_Kumari_26900122059.pptx
Artificial Intelligence_Anjali_Kumari_26900122059.pptxCCBProduction
 
Chap 4 local_search
Chap 4 local_search Chap 4 local_search
Chap 4 local_search Rakhi Gupta
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptkarthikaparthasarath
 
BeyondClassicalSearch.ppt
BeyondClassicalSearch.pptBeyondClassicalSearch.ppt
BeyondClassicalSearch.pptGauravWani20
 
BeyondClassicalSearch.ppt
BeyondClassicalSearch.pptBeyondClassicalSearch.ppt
BeyondClassicalSearch.pptjpradha86
 
Informed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptxInformed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptxKirti Verma
 
Optimization
OptimizationOptimization
Optimizationyesheeka
 
Learning algorithm including gradient descent.pptx
Learning algorithm including gradient descent.pptxLearning algorithm including gradient descent.pptx
Learning algorithm including gradient descent.pptxamrita chaturvedi
 
Heuristic or informed search
Heuristic or informed searchHeuristic or informed search
Heuristic or informed searchHamzaJaved64
 
Gradient descent method
Gradient descent methodGradient descent method
Gradient descent methodSanghyuk Chun
 
Simulated annealing presentation
Simulated annealing presentation Simulated annealing presentation
Simulated annealing presentation AmarendraKrSaroj
 
Simulated annealing-global optimization algorithm
Simulated annealing-global optimization algorithmSimulated annealing-global optimization algorithm
Simulated annealing-global optimization algorithmAkhil Prabhakar
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithmMegha Sharma
 

Semelhante a Lec 6 bsc csit (20)

02LocalSearch.pdf
02LocalSearch.pdf02LocalSearch.pdf
02LocalSearch.pdf
 
Artificial Intelligence_Anjali_Kumari_26900122059.pptx
Artificial Intelligence_Anjali_Kumari_26900122059.pptxArtificial Intelligence_Anjali_Kumari_26900122059.pptx
Artificial Intelligence_Anjali_Kumari_26900122059.pptx
 
Chap 4 local_search
Chap 4 local_search Chap 4 local_search
Chap 4 local_search
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
 
BeyondClassicalSearch.ppt
BeyondClassicalSearch.pptBeyondClassicalSearch.ppt
BeyondClassicalSearch.ppt
 
BeyondClassicalSearch.ppt
BeyondClassicalSearch.pptBeyondClassicalSearch.ppt
BeyondClassicalSearch.ppt
 
Informed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptxInformed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptx
 
Optimization
OptimizationOptimization
Optimization
 
cs-171-05-LocalSearch.pptx
cs-171-05-LocalSearch.pptxcs-171-05-LocalSearch.pptx
cs-171-05-LocalSearch.pptx
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
Learning algorithm including gradient descent.pptx
Learning algorithm including gradient descent.pptxLearning algorithm including gradient descent.pptx
Learning algorithm including gradient descent.pptx
 
Heuristic or informed search
Heuristic or informed searchHeuristic or informed search
Heuristic or informed search
 
Gradient descent method
Gradient descent methodGradient descent method
Gradient descent method
 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
 
Informed search
Informed searchInformed search
Informed search
 
Secant method
Secant method Secant method
Secant method
 
Simulated annealing presentation
Simulated annealing presentation Simulated annealing presentation
Simulated annealing presentation
 
Simulated annealing-global optimization algorithm
Simulated annealing-global optimization algorithmSimulated annealing-global optimization algorithm
Simulated annealing-global optimization algorithm
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithm
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 

Mais de Subash Chandra Pakhrin

Torsion Angles, ASA Used for prediction of Non - Enzymatic PTM
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTMTorsion Angles, ASA Used for prediction of Non - Enzymatic PTM
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTMSubash Chandra Pakhrin
 
Characterization and identification of lysine succinylation sites based
Characterization and identification of lysine succinylation sites basedCharacterization and identification of lysine succinylation sites based
Characterization and identification of lysine succinylation sites basedSubash Chandra Pakhrin
 
Deep Learning or Convolutional Neural Network
Deep Learning or Convolutional Neural Network Deep Learning or Convolutional Neural Network
Deep Learning or Convolutional Neural Network Subash Chandra Pakhrin
 
Knnowledge representation and logic lec 11 to lec 15
Knnowledge representation and logic lec 11 to lec 15Knnowledge representation and logic lec 11 to lec 15
Knnowledge representation and logic lec 11 to lec 15Subash Chandra Pakhrin
 

Mais de Subash Chandra Pakhrin (20)

Prismoid
PrismoidPrismoid
Prismoid
 
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTM
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTMTorsion Angles, ASA Used for prediction of Non - Enzymatic PTM
Torsion Angles, ASA Used for prediction of Non - Enzymatic PTM
 
COVID 19
COVID 19 COVID 19
COVID 19
 
Lstm covid 19 prediction
Lstm covid 19 predictionLstm covid 19 prediction
Lstm covid 19 prediction
 
Rnn & Lstm
Rnn & LstmRnn & Lstm
Rnn & Lstm
 
Characterization and identification of lysine succinylation sites based
Characterization and identification of lysine succinylation sites basedCharacterization and identification of lysine succinylation sites based
Characterization and identification of lysine succinylation sites based
 
Cnn april 8 2020
Cnn april 8 2020Cnn april 8 2020
Cnn april 8 2020
 
Deep Learning or Convolutional Neural Network
Deep Learning or Convolutional Neural Network Deep Learning or Convolutional Neural Network
Deep Learning or Convolutional Neural Network
 
Ncit 1st ai lab
Ncit 1st ai labNcit 1st ai lab
Ncit 1st ai lab
 
Ai lab
Ai labAi lab
Ai lab
 
Constraint satisfaction problem
Constraint satisfaction problem Constraint satisfaction problem
Constraint satisfaction problem
 
Analysis
AnalysisAnalysis
Analysis
 
Planning
PlanningPlanning
Planning
 
Intelligent agents (bsc csit) lec 2
Intelligent agents (bsc csit) lec 2Intelligent agents (bsc csit) lec 2
Intelligent agents (bsc csit) lec 2
 
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
 
Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5
 
Two player games
Two player gamesTwo player games
Two player games
 
Knnowledge representation and logic lec 11 to lec 15
Knnowledge representation and logic lec 11 to lec 15Knnowledge representation and logic lec 11 to lec 15
Knnowledge representation and logic lec 11 to lec 15
 
Final slide (bsc csit) chapter 2
Final slide (bsc csit) chapter 2Final slide (bsc csit) chapter 2
Final slide (bsc csit) chapter 2
 
Final slide (bsc csit) chapter 3
Final slide (bsc csit) chapter 3Final slide (bsc csit) chapter 3
Final slide (bsc csit) chapter 3
 

Último

AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 

Último (20)

AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 

Lec 6 bsc csit

  • 2. Hill Climbing • Back – Tracking • Use Enqued List • Informed Search • Very similar to DFS except instead of using lexical order to break ties, it break ties according to which node is closer to the goal. • Hill Climbing: Front Sorted
  • 3. Hill Climbing • It starts with random (potentially poor) solution, and iteratively makes small changes to the solution, each time improving it a little. When the algorithm cannot see any improvement anymore, it terminates. • Ideally, at that point the current solution is close to optimal, but it is not guaranteed that hill climbing will ever come close to the optimal solution.
  • 4. Hill Climbing • Hill climbing can be applied to the travelling salesman problem. • It is easy to find a solution that visits all the cities but will be very poor compared to the optimal solution.
  • 5. Hill Climbing The hill climbing can be described as follows: 1. Start with current-state = initial state 2. Until current-state = goal-state OR there is no change in current-state do: – Get the successors of the current state and use the evaluating function to assign a score to each successor. – If one of the successors has a better score than the current-state then set the new current-state to be the successor with the best score. • Hill climbing terminates when there are no successors of the current state which are better than the current state itself.
  • 6. Hill Climbing • Hill climbing is depth-first search with a heuristic measurement that orders choices as nodes are expanded. It always selects the most promising successor of the node last expanded.
  • 7. Hill Climbing • For instance, consider that the most promising successor of a node is the one that has the shortest straight-line distance to the goal node G. • In figure below, the straight line distances between each city and goal G is indicated in square brackets, i.e. the heuristic.
  • 8. Hill Climbing • Problems with Hill Climbing – Gets stuck at local maxima when we reach a position where there are no better neighbors, it is not a guarantee that we have found the best solution. Ridge is a sequence of local maxima. – Another type of problem we may find with hill climbing searches is finding a plateau. This is an area where the search space is flat so that all neighbors returns the same evaluation.
  • 9. Hill Climbing S A A G E FB 88.5 8.5 6 6 3 D The hill climbing search from S to G proceeds as follows: S A D B E C F G 3 4 4 5 5 42 4 3 [8] [8.5] [6] [6] [3] [3] [10]
  • 10. Hill Climbing • Apply the hill climbing algorithm to find a path from S to G, considering that the most promising successor of a node is its closest neighbor. S A D B E C F G 3 4 4 5 5 42 4 3
  • 11. Hill Climbing •the best first search method selects for expansion the most promising leaf node of the current search tree •the hill climbing search method selects for expansion the most promising successor of the node last expanded. • In depth-first search: front of the queue (a stack). • In breadth-first search: back of the queue. • Now, in hill-climbing search, you sort[1] the current node's children before adding them to the queue. • In best-first search, you add the current node's children to the queue in any order, then sort[1] the entire queue. • [1]: sort according to some problem-specific evaluation of the solution node, for example "distance from destination" in a path-finding search
  • 12. Hill Climbing AI, Subash Chandra Pakhrin 12 S G D E B A C 5 4 4 6 3 5 7+ 6 7+ S A B G A C D 7+ 6 5 7+ 7+ 3 A and C are both equally far from goal, so now we are going to use lexical order to break the tie
  • 13. Beam Search S A B B D C G A C Beam width (w) = 2 Beam: Keep w Best
  • 14. Annealing • In metallurgy, annealing is the process used to temper or harden metals and glass by heating them to a high temperature and then gradually cooling them, thus allowing material to reach a low energy crystalline state. • This can be applied to computer science problems.
  • 15. Simulated Annealing • It is applied to solve problems like – Travelling salesman problem – Designing printed circuit boards – Solving VLSI layout problems – Factory scheduling – Large-scale optimization task – Planning of path for a robot – Bioinformatics to design three dimension structures of protein molecules.
  • 16. Simulated Annealing • A hill climbing algorithm that never makes “down hill” moves towards states with lower value is guaranteed to be incomplete, because it can get stuck on a local maximum. • In contrast, a purely random walk – that is, moving to a successor chosen uniformly at random from the set of successors- is complete but extremely inefficient. • Simulated Annealing = hill climbing + random walk hence, it is efficient as well as completeness.
  • 17. Simulated Annealing • At the beginning you don’t care if you are actually moving towards the good solution and you accept bad moves as well, you accept bad configurations as well but as you progress towards the solution we become more careful and we try to get closer to the solution by selecting only the good moves.
  • 18. Simulated Annealing • Switch the perspective from hill climbing to gradient descent. • Imagine the task of getting a ping-pong ball into he deepest crevice in a bumpy surface. • If we just let the ball roll, it will get come to rest at a local minimum. • If we shake the surface, we can bounce the ball out of local minimum. • The trick is to shake just hard enough to bounce the ball out of local minimum but not hard enough to dislodge it from the global minimum. • Simulated Annealing solution is to start by shaking hard (i.e., at a high temperature) and then gradually reduce the intensity of shaking (i.e., lower the temperature)
  • 19. Simulated Annealing • E = Energy of the system • ΔE = Change in energy • We need to have a mechanism to alter the configuration All possible configurations of a given system E n e r g y C N Move
  • 20. Simulated Annealing C = C init for T = T max to T min E c = E(C) N = next (C) EN = E(N) ΔE = EN – EC If (ΔE > 0) C = N else if (eΔE/T > rand (0, 1)) C = N epoch
  • 21. Simulated Annealing • If the change in energy is negative, or in other words if we are making bad move. – In this case we compute probability • If probability is very high then we accept the move even if it is a bad move. • If probability is very low then we have low probability to accept the bad move. • Probability depends upon two variables change in energy ΔE and the temperature factor T.
  • 22. Simulated Annealing • When temperature is very high then probability for accepting bad move is very high. In other words, at high temperature we are exploring the solution space or we are exploiting the configuration and we’re accepting bad moves as well. • When the temperature is low this probability becomes very low and we have very low probability to accept bad moves.
  • 23. Simulated Annealing • Case 1: T = 1000, ΔE = 10 ΔE/T = 0.01 eΔ E/T = 0.99004 A number that is close to one has a very high (correlation) probability to become greater than a random number between 0 and 1, which means we get a very high probability, so when temperature is very high we have high probability to accept bad moves as well.
  • 24. Simulated Annealing ΔE influences probability • ΔE is very high = a low probability to accept the move • ΔE is small = high probability to accept the move. • We repeat the process for certain number of times usually known as the number of epochs, usually 100 to 200 times and for every value of temperature we repeat the process and finally expecting the solution to converge towards the global minimum.
  • 25. Simulated Annealing • Now on either extremes are 2 other algorithms 1. Hill Climbing 2. Random Walk • If we remove the probability factor or the temperature factor and always accept the good moves only then that’s hill climbing or it’s like a greedy algorithm which always go towards a better solution. Such, algorithms are prone to be easily stuck in local minima.
  • 26. Simulated Annealing • Random walk: It doesn’t care about how good a move we are making every time but we just explore, continue to explore, the space. Such algorithm never converge and will probably never give you the best optimal solution.
  • 27. Simulated Annealing • Parameters T max to T min and number of epochs are dependent on the problem that we are solving, usually we start with high temperature like few thousands, let’s say 5000 or 3000 and then the minimum temperature is set to a small value like 0 or 10 or something like that. • Number of epoch is usually a hundred, or 200 depending on the problem • If you run multiple times you will have an idea whether you’re being stuck in the local minima or global minimum

Notas do Editor

  1. Energy Landscape
  2. Case 1: ΔE = -10000 keeping T constant e^(-10000) = 0 Case 2: : ΔE = -0.001 keeping T constant e^(-0.001) = 0.9999