Hill Climbing Search Solved Example using Local and Global Heuristic Function by Dr. Mahesh Huddar

Mahesh Huddar
28 Jan 202209:33

Summary

TLDRThis video tutorial explains the Hill Climbing algorithm's application in transitioning from an initial state to a goal state using both local and global heuristic functions. It illustrates the process with a block-stacking example, highlighting the limitations of local heuristics leading to a local maximum and demonstrating how global heuristics can guide the algorithm to the optimal solution. The explanation clarifies the use of heuristic functions in overcoming local maxima and achieving the goal state.

Takeaways

  • 📚 The video discusses the application of the hill climbing algorithm using both local and global heuristic functions to transition from an initial state to a goal state.
  • 🔍 The example given involves moving blocks labeled A, B, C, and D to their correct positions on top of each other to reach the goal state.
  • 🤖 Local heuristic functions consider immediate consequences and reward blocks that are resting on the correct block with a +1, while incorrectly placed blocks receive a -1.
  • 🌐 Global heuristic functions take into account the overall support structure of each block, rewarding correct placements with +1 and penalizing incorrect ones with -1.
  • 🔢 The start state's value is calculated by assigning points based on the local heuristic function, resulting in a total value of 0 for the given example.
  • 🎯 The goal state's value is calculated as +4 using the local heuristic function, indicating all blocks are correctly placed.
  • 🚫 A disadvantage of using local heuristic functions is the potential to reach a local maximum, where no further improvement is possible, as demonstrated when moving block D.
  • 🔄 To overcome local maxima, the video switches to using a global heuristic function, which considers the entire structure of block placement.
  • 📉 The initial state's value using the global heuristic function is -6, indicating that none of the blocks are correctly placed.
  • 📈 By applying operators and moving blocks according to the global heuristic function, the algorithm successfully reaches the goal state with a value of +6.
  • 🛠 The video illustrates the process of using hill climbing with heuristic functions to find a solution path from the start state to the goal state in a block puzzle scenario.

Q & A

  • What is the Hill Climbing algorithm?

    -The Hill Climbing algorithm is a heuristic search algorithm that aims to find the peak of a cost function, which represents the solution to a problem. It iteratively moves to the best local solution until it reaches a peak, which may or may not be the global optimum.

  • What is the difference between a local and a global heuristic function?

    -A local heuristic function considers only the immediate consequences of a move to decide the next step, whereas a global heuristic function takes into account the overall state of the problem to guide the search towards the goal.

  • What is the initial state in the context of the given script?

    -The initial state is the starting configuration of the blocks where the goal is to rearrange them so that each block is on top of the block it should be, according to the problem's goal state.

  • What is the goal state in the described scenario?

    -The goal state is the final configuration where block A is on the ground, block B is on top of A, block C is on top of B, and block D is on top of C.

  • How does the local heuristic function assign rewards in the given example?

    -The local heuristic function assigns a plus one reward for each block that is resting on the block it is supposed to be on, and a minus one reward if it is not in the correct position.

  • What is the problem with using only a local heuristic function in the script's example?

    -The problem with using only a local heuristic function is that it can lead to a local maximum, where no further improvements can be made based on immediate consequences, thus potentially failing to reach the global optimum or goal state.

  • How does the global heuristic function differ in assigning rewards compared to the local heuristic?

    -The global heuristic function assigns rewards based on the correct support structure of each block. It gives a plus one reward for each block with the correct support and a minus one reward for each block with an incorrect support structure.

  • What is the advantage of using a global heuristic function over a local heuristic function?

    -The advantage of using a global heuristic function is that it considers the overall state of the problem, which can help avoid local maxima and provide a better chance of reaching the global optimum or the goal state.

  • What does the script illustrate about the process of moving from the initial state to the goal state using heuristic functions?

    -The script illustrates that by applying different heuristic functions—local and global—one can evaluate the current state and choose the best next move. It shows that sometimes a local heuristic might not be sufficient, and a global heuristic might be necessary to reach the goal state.

  • What is the final outcome of applying the global heuristic function in the script's example?

    -The final outcome is that the algorithm successfully moves from the initial state with a value of minus six to the goal state with a value of plus six, indicating that all blocks are in their correct positions.

Outlines

00:00

🤖 Introduction to Hill Climbing Algorithm with Heuristics

This paragraph introduces the concept of the hill climbing algorithm in the context of a block stacking problem. The speaker explains the goal of transitioning from an initial state to a goal state using heuristic functions. Two types of heuristics are discussed: local and global. The local heuristic function rewards each block that is correctly positioned with a +1, while incorrectly positioned blocks receive a -1. The global heuristic function considers the overall structure and assigns rewards or penalties based on the correctness of the entire stack beneath each block. The speaker uses an example with four blocks (A, B, C, D) to illustrate the process, starting with an initial configuration and aiming for a goal configuration where each block is correctly stacked.

05:01

🔍 Overcoming Local Maxima with Global Heuristics

In this paragraph, the speaker delves into the limitations of using only local heuristic functions, which can lead to local maxima where the algorithm gets stuck and cannot reach the goal state. To overcome this, the speaker introduces the use of global heuristic functions. The global heuristic function assigns a score based on the correctness of the entire support structure beneath each block. The speaker demonstrates how applying global heuristics can lead to a series of moves that successfully transition from the initial state to the goal state. The example shows a step-by-step application of different operators to improve the state's value, ultimately achieving the goal state with a positive value, highlighting the effectiveness of global heuristics in the hill climbing algorithm.

Mindmap

Keywords

💡Hill Climbing Algorithm

The Hill Climbing Algorithm is a heuristic search algorithm used to find an approximate solution to optimization problems. In the context of the video, it is applied to navigate from an initial state to a goal state in a problem-solving scenario, such as moving blocks to their correct positions. The algorithm iteratively selects the best option based on a heuristic function, aiming to 'climb' towards the optimal solution.

💡Heuristic Function

A Heuristic Function is a method used to estimate the cost or value of reaching a goal from a given state. In the video, two types of heuristic functions are discussed: local and global. The local heuristic function considers immediate consequences, while the global heuristic function takes into account the overall state to estimate the distance to the goal.

💡Local Heuristic Function

A Local Heuristic Function evaluates the desirability of a state based on its immediate surroundings or the next step. In the video, it is used to give a plus one reward for blocks that are resting on the correct block or the ground, and a minus one for incorrect placements, guiding the algorithm to make the next best move based on the current state.

💡Global Heuristic Function

A Global Heuristic Function assesses the overall state by considering the entire problem space, not just the immediate next step. In the script, it is used to evaluate the correctness of the support structure of each block, giving a minus one for incorrect placements and a plus one for correct ones, which helps in avoiding local maxima and finding a path to the goal state.

💡Initial State

The Initial State refers to the starting point of the problem in the video, where the blocks are not in their correct positions. It is the state from which the Hill Climbing Algorithm begins its search for the optimal solution.

💡Goal State

The Goal State is the desired end state of the problem-solving process, where all blocks are in their correct positions as per the problem's requirements. The video discusses using heuristic functions to guide the algorithm towards reaching this state.

💡Local Maximum

A Local Maximum is a point in the search space where all immediate neighbors have lower values, making it seem like the best option based on local information. However, it may not be the global optimum. In the video, the concept is illustrated when the algorithm, using only local heuristics, reaches a state from which it cannot progress towards the goal state.

💡Operator

An Operator in the context of the video refers to the actions that can be applied to change the state, such as moving one block to another position. The choice of operator is guided by the heuristic function to move towards the goal state.

💡Support Structure

Support Structure in the video refers to the arrangement of blocks beneath a particular block. The heuristic function evaluates the correctness of this structure, influencing the decision-making process in the Hill Climbing Algorithm.

💡Optimization Problem

An Optimization Problem is a type of problem where the goal is to find the best solution according to certain criteria. In the video, the optimization problem is to arrange blocks in a specific order, and the Hill Climbing Algorithm is used to find an efficient solution to this problem.

💡Reward

In the video, a Reward is a value assigned by the heuristic function to indicate how close a state is to the desired goal. A plus one reward is given for correct placements, while a minus one indicates incorrect positions, guiding the algorithm to make moves that increase the reward value.

Highlights

Introduction to hill climbing algorithm and its application in transitioning from an initial state to a goal state using heuristic functions.

Explanation of the example involving four blocks (A, B, C, D) and the goal state configuration.

Differentiation between local and global heuristic functions in decision-making processes.

Description of the local heuristic function rewarding blocks resting on their correct positions.

Calculation of the start state's value using the local heuristic function resulting in zero.

Goal state's value calculation with all blocks correctly positioned yielding a positive value.

Demonstration of applying operators to move from the start state towards the goal state.

Encountering a local maximum where further progress with the local heuristic function is not possible.

Introduction of the global heuristic function considering the entire structure for evaluation.

Calculation of the start state's value using the global heuristic function resulting in a negative value.

Goal state's value calculation with the global heuristic function showing a positive outcome.

Step-by-step application of the global heuristic function to overcome the local maximum and progress towards the goal state.

Illustration of moving block A to the ground and recalculating the state's value with the global heuristic function.

Exploration of moving block D to different positions and evaluating the outcomes.

Use of the global heuristic function to successfully transition from the initial state to the goal state.

Conclusion on the effectiveness of using both local and global heuristic functions in the hill climbing algorithm.

Encouragement for viewers to like, share, subscribe, and turn on notifications for more content.

Transcripts

play00:00

hi

play00:01

welcome back in this video i will

play00:03

discuss how to apply hill claiming

play00:04

search algorithm to go from initial

play00:07

state to gold state

play00:08

using local and global heuristic

play00:11

function

play00:15

we take this example where we have four

play00:17

blocks abcd

play00:19

we want to go from this particular

play00:21

initial state or a start state to this

play00:23

particular goal state

play00:25

where we are expecting

play00:26

a should be present on the ground on the

play00:28

top of a b should be present on the top

play00:31

of b we should have c on the top of c we

play00:34

should have d in this case so this is

play00:36

what is expected

play00:38

now if you want to go from this

play00:39

particular start state to gold state

play00:42

we have to use one heuristic function

play00:45

we have to use either the local

play00:46

heuristic function where we will

play00:48

consider only the immediate consequences

play00:52

so that we can decide what to do next

play00:55

or we have to consider the global

play00:57

heuristic function

play00:58

where we will consider the global

play01:01

information or we can say that what will

play01:03

happen

play01:04

in future

play01:06

based on that we will select the

play01:08

operator

play01:10

where we can go from start state to gold

play01:13

state here

play01:15

so first we will consider the local

play01:17

heuristic function

play01:18

uh in this local heresy function we will

play01:20

give plus one reward for each block that

play01:23

is resting on a thing it is supposed to

play01:26

be resting on

play01:27

that is for example we are expecting b

play01:30

should rest on a a should rest on ground

play01:33

similarly c should rest on b

play01:35

d should rest on c if it is the case we

play01:38

will give plus one if anything else is

play01:40

there for example

play01:41

in this particular start state only

play01:44

b is present on a ground but what we are

play01:46

expecting a should be present on the

play01:48

ground so it will be given as a minus

play01:49

one

play01:50

ah we are expecting

play01:52

c should be present on b yes it is

play01:53

present so it will be given as a plus

play01:55

one and so on so that is what the local

play01:56

uh uh information or a local heuristic

play01:59

function here

play02:00

so we will try to calculate what is the

play02:01

value for the start state

play02:04

the start state is it will be minus one

play02:06

because it is not present at the correct

play02:08

position here

play02:10

for c c is expected to be present on b

play02:13

and it is present so it will be plus 1

play02:16

this is also plus 1 but this is minus 1

play02:18

so the total value of this particular

play02:21

start state is 0 here

play02:23

now when it comes to goal state all of

play02:25

them are present on the current position

play02:28

of course they are present on the

play02:29

correct position so everything will be

play02:30

given as

play02:32

you can say that plus 1 over here

play02:34

so the answer or the value of this

play02:36

particular function is you can say that

play02:39

the plus 4 here

play02:41

now

play02:42

using this particular local information

play02:44

we have to go from start state to gold

play02:46

state over here

play02:48

now we have to apply some different

play02:50

operators at the start state so that we

play02:52

can go to the goal state here

play02:54

so first operator is i will bring this

play02:56

particular a to the ground so that is

play02:58

the only option what we have here

play03:00

now

play03:01

b is present on the ground that is

play03:03

incorrect position so it will be -1

play03:06

c is present at the correct position d

play03:08

is present at the correct position so

play03:10

this will be given as a plus one here

play03:14

is present at what we can say that the

play03:16

correct position so it will be given as

play03:19

the plus one now if i add everything i

play03:21

will get the plus two as the answer in

play03:23

this case

play03:24

now uh there are two possibilities are

play03:26

there either i can move this particular

play03:28

d to this on the top of a or i can move

play03:31

this particular d to this particular

play03:33

ground

play03:34

now if i do this particular operator if

play03:37

i if i apply this particular operator

play03:38

what will happen we will try to see

play03:41

if i move this particular d on the top

play03:43

of a

play03:44

i will get the value as 0

play03:47

and if i move this particular d to the

play03:49

ground i am getting the value of 0

play03:51

why because

play03:53

b is incorrectly placed d is incorrectly

play03:56

placed

play03:56

a and c are correctly placed here so the

play04:00

value is 0 similarly c is correctly

play04:03

placed here k is correctly placed

play04:06

b and d are incorrectly placed so

play04:08

because of that we are getting 0 here

play04:11

because we are getting 0 0 in both the

play04:13

cases we have i ended up with something

play04:15

called as

play04:16

the local

play04:18

maximum

play04:19

or can say that a local optimum

play04:22

okay so because of this we cannot go

play04:25

ahead from here onwards

play04:26

this is the disadvantage of using a

play04:28

local elastic function or a local

play04:30

information

play04:32

i am not able to reach what you can say

play04:33

that the goal state using this function

play04:36

so what i do is i will use a global

play04:39

information or a global heuristic

play04:41

function

play04:42

we will try to see whether i will be

play04:44

able to go from

play04:46

the start state to goal state or not

play04:49

so in this case again the start state

play04:52

and the goal states are same but the

play04:53

heuristic function is something like

play04:55

this for each block that has the correct

play04:58

support structure the plus one will be

play05:00

given as a reward for each one

play05:03

for every block you can say

play05:06

for each block that has a wrong support

play05:08

structure a minus one will be given

play05:10

support structure in the sense uh the

play05:12

blocks which are present below the

play05:13

current block if if all of them are

play05:16

correctly placed uh one will be given

play05:19

for every block actually

play05:21

if they are not correctly placed minus 1

play05:23

will be given for every block again okay

play05:26

so you can see here

play05:28

below b we don't have anything so it

play05:29

will be 0

play05:31

but below c b is present whether b is

play05:33

present the correct position no so it

play05:35

will be -1

play05:37

below d

play05:38

c and b are there both of them are

play05:41

correctly placed no they are not

play05:42

correctly placed so it will be minus 2

play05:45

below a

play05:46

b c d are there all of them are not

play05:48

correctly placed with respect to the

play05:51

gold state so it will be minus 3

play05:53

so the total value of this particular

play05:55

state is -6

play05:57

now coming back to this goal state

play06:00

of course all of them

play06:02

are present at the correct position so

play06:04

below a we don't have anything so it is

play06:06

0

play06:07

below b we have one node so it will be 1

play06:10

here

play06:12

for this one it will be 2

play06:13

for this one it will be

play06:16

3 here because below d 3 nodes are there

play06:18

or the three

play06:20

blocks are there all of them are

play06:21

correctly placed here so it is plus six

play06:24

so the intention is to go from start

play06:25

state to gold state that is minus six

play06:27

two plus six here by applying different

play06:29

operators

play06:30

so what i do here is first i will move

play06:32

this particular a to this particular

play06:34

ground

play06:35

now if i move this particular a to the

play06:37

ground

play06:38

b below b we don't have anything so it

play06:40

is 0 below c b is present it is

play06:43

incorrectly placed

play06:44

below d we have c and b

play06:47

both of them are incorrectly placed

play06:49

below a we don't have anything so it is

play06:51

0 so the total value of this state is -3

play06:56

now there are two possibilities are

play06:57

there either i can move d on the ground

play06:59

or d on the top of a

play07:02

and now i will move this particular d on

play07:04

the ground i will see what will happen

play07:06

uh now if i move d on the ground

play07:09

this one will be zero below c we have

play07:12

one block that is incorrectly placed

play07:14

below a we don't have anything so it is

play07:16

0 below d we don't have anything hence

play07:18

it is 0 so the total value of this

play07:20

particular state is minus 1 so it is

play07:23

better than the previous one so we will

play07:24

consider it

play07:26

now i will move c on the ground it will

play07:29

look something like this

play07:30

all of them

play07:31

are not correctly placed but be below

play07:34

this particular thing the support

play07:35

structure is not present so all of them

play07:37

are having 0 0 as the value

play07:40

so the value of this particular state is

play07:41

0. again it is better than the previous

play07:43

one so i will continue from here onwards

play07:46

now i will put

play07:48

b on the top of a here so if i put b on

play07:51

the top of a

play07:53

for a it is 0 because below a we don't

play07:55

have anything below b we have one

play07:58

we can say that the block

play08:00

which is correctly placed since it is

play08:02

plus one

play08:04

and then uh for d it is zero for c it is

play08:07

zero so the total value of this state is

play08:09

one year

play08:10

now i will move c on the top of b

play08:14

uh below a we don't have anything that's

play08:16

the reason it is zero

play08:18

below b we have one

play08:21

block and it is correctly placed so it

play08:22

is one below c we have two blocks a and

play08:25

b both of them are correctly placed it

play08:27

is two

play08:28

below d we don't have anything so it is

play08:29

zero so the total value of this

play08:31

particular state is three in this case

play08:34

now coming back to the last one that is

play08:36

mo d on the top of c

play08:39

all of them are correctly placed

play08:41

for a it is 0 for b it is 1 because 1

play08:45

correctly block is present below b

play08:48

below c we have 2 blocks both of them

play08:50

are correctly placed below d we have 3

play08:52

blocks all three blocks are correctly

play08:54

placed here so the total value of this

play08:56

particular state is equivalent to plus

play08:58

six

play08:59

so we started with minus six we ended up

play09:02

with plus six using this particular

play09:04

global heuristic function in this case

play09:08

so this is how actually we can use

play09:09

either local or global heuristic

play09:11

function

play09:12

to go from initial state to gold state

play09:15

using hill claiming algorithm

play09:18

i hope this particular concept is clear

play09:20

if you like the video do like and share

play09:22

with your friends press the subscribe

play09:24

button for more videos press the bell

play09:26

icon for regular updates thank you for

play09:28

watching

Rate This

5.0 / 5 (0 votes)

相关标签
Hill ClimbingAlgorithmsHeuristicsProblem SolvingLocal SearchGlobal SearchAI TechniquesOptimizationMachine LearningProgramming
您是否需要英文摘要?