0% found this document useful (0 votes)
20 views

Hill Climbing ALgorithm

Uploaded by

Vikash Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Hill Climbing ALgorithm

Uploaded by

Vikash Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Breadth First Search Algorithm

• Start with the source node.


• Add that node at the front of the queue to the
visited list.
• Make a list of the nodes as visited that are close to
that vertex.
• And dequeue the nodes once they are visited.
• Repeat the actions until the queue is empty.
The time complexity of the breadth-first search
algorithm can be stated as O(|V|+|E|) because, in the
worst case, it will explore every vertex and edge.
Depth First Search Algorithm
• Step 1: Create a stack with the total number of vertices in
the graph as the size.
• Step 2: Choose any vertex as the traversal's beginning point.
Push a visit to that vertex and add it to the stack.
• Step 3 - Push any non-visited adjacent vertices of a vertex at
the top of the stack to the top of the stack.
• Step 4 - Repeat steps 3 and 4 until there are no more
vertices to visit from the vertex at the top of the stack.
• Step 5 - If there are no new vertices to visit, go back and pop
one from the stack using backtracking.
• Step 6 - Continue using steps 3, 4, and 5 until the stack is
empty.
• Step 7 - When the stack is entirely unoccupied, create the
final spanning tree by deleting the graph's unused edges.
• Generate-and-Test
– Generate-and-test search algorithm is a very simple algorithm that
guarantees to find a solution if done systematically and there exists a
solution.
• Algorithm:
• Generate a possible solution. For some problems, this means
generating a particular point in the problem space. For others
it means generating a path from a start stat.
• Test to see if this is actually a solution by comparing the chosen
point or the endpoint of the chosen path to the set of
acceptable goal states.
• If a solution has been found, quit, Otherwise return to step 1.
– It is a depth first search procedure since complete solutions must be
generated before they can be tested.
– In its most systematic form, it is simply an exhaustive search of the
problem space.
Hill Climbing Algorithm
• Hill climbing algorithm is a local search algorithm which
continuously moves in the direction of increasing elevation/value
to find the peak of the mountain or best solution to the problem. It
terminates when it reaches a peak value where no neighbor has a
higher value.
• Hill climbing algorithm is a technique which is used for optimizing
the mathematical problems. One of the widely discussed examples
of Hill climbing algorithm is Traveling-salesman Problem in which
we need to minimize the distance traveled by the salesman.
• It is also called greedy local search as it only looks to its good
immediate neighbor state and not beyond that.
• A node of hill climbing algorithm has two components which are
state and value.
• Hill Climbing is mostly used when a good heuristic is available.
• In this algorithm, we don't need to maintain and handle the search
Features of Hill Climbing:
Following are some main features of Hill Climbing Algorithm:

• Generate and Test variant: Hill Climbing is the


variant of Generate and Test method. The Generate
and Test method produce feedback which helps to
decide which direction to move in the search space.
• Greedy approach: Hill-climbing algorithm search
moves in the direction which optimizes the cost.
• No backtracking: It does not backtrack the search
space, as it does not remember the previous states.
Problems in Hill Climbing Algorithm:
1. Local Maximum: A local maximum is a peak state in the landscape which is better
than each of its neighboring states, but there is another state also present which is
higher than the local maximum.
• Solution: Backtracking technique can be a solution of the local maximum in state
space landscape. Create a list of the promising path so that the algorithm can
backtrack the search space and explore other paths as well.
2. Plateau: A plateau is the flat area of the search space in which all the neighbor
states of the current state contains the same value, because of this algorithm does
not find any best direction to move. A hill-climbing search might be lost in the
plateau area.
• Solution: The solution for the plateau is to take big steps or very little steps while
searching, to solve the problem. Randomly select a state which is far away from
the current state so it is possible that the algorithm could find non-plateau region.
3. Ridges: A ridge is a special form of the local maximum. It has an area which is
higher than its surrounding areas, but itself has a slope, and cannot be reached in a
single move.
• Solution: With the use of bidirectional search, or by moving in different
directions, we can improve this problem.
1. Simple Hill Climbing:
Simple hill climbing is the simplest way to implement a hill climbing algorithm. It
only evaluates the neighbor node state at a time and selects the first one which
optimizes current cost and set it as a current state. It only checks it's one
successor state, and if it finds better than the current state, then move else be in
the same state. This algorithm has the following features:
• Less time consuming
• Less optimal solution and the solution is not guaranteed
• Algorithm for Simple Hill Climbing:
• Step 1: Evaluate the initial state, if it is goal state then return success and Stop.
• Step 2: Loop Until a solution is found or there is no new operator left to apply.
• Step 3: Select and apply an operator to the current state.
• Step 4: Check new state:
– If it is goal state, then return success and quit.
– Else if it is better than the current state then assign new state as a current state.
– Else if not better than the current state, then return to step2.
• Step 5: Exit.
2. Steepest-Ascent hill climbing:
The steepest-Ascent algorithm is a variation of simple
hill climbing algorithm. This algorithm examines all
the neighboring nodes of the current state and selects
one neighbor node which is closest to the goal state.
This algorithm consumes more time as it searches for
multiple neighbors
• Algorithm for Steepest-Ascent hill climbing:
• Step 1: Evaluate the initial state, if it is goal state
then return success and stop, else make current
state as initial state.
• Step 2: Loop until a solution is found or the current
state does not change.
– Let SUCC be a state such that any successor of the current state
will be better than it.
– For each operator that applies to the current state:
• Apply the new operator and generate a new state.
• Evaluate the new state.
• If it is goal state, then return it and quit, else compare it to the SUCC.
• If it is better than SUCC, then set new state as SUCC.
• If the SUCC is better than the current state, then set current state to
SUCC.
• Step 5: Exit.

3. Stochastic hill climbing:

Stochastic hill climbing does not examine for all its neighbor
before moving. Rather, this search algorithm selects one
neighbor node at random and decides whether to choose it as
• Problem Reduction
AND-OR graphs
• AND-OR graph (or tree) is useful for representing the solution of problems
that can be solved by decomposing them into a set of smaller problems, all
of which must then be solved.
• This decomposition or reduction generates arcs that we call AND arcs.
• One AND arc may point to any numbers of successor nodes. All of which
must then be solved in order for the arc to point solution.
• In order to find solution in an AND-OR graph we need an algorithm similar
to best –first search but with the ability to handle the AND arcs
appropriately.
• We define FUTILITY, if the estimated cost of solution becomes greater than
the value of FUTILITY then we abandon the search, FUTILITY should be
chosen to correspond to a threshold.
• In following figure AND arcs are indicated with a line connecting all the
components.
AO* algorithm

The AO* method divides any given difficult problem into a smaller
group of problems that are then resolved using the AND-OR graph
concept. AND OR graphs are specialized graphs that are used in
problems that can be divided into smaller problems. The AND side of
the graph represents a set of tasks that must be completed to achieve
the main goal, while the OR side of the graph represents different
methods for accomplishing the same main goal.
• Working of AO* algorithm:
• The evaluation function in AO* looks like this:
f(n) = g(n) + h(n)
f(n) = Actual cost + Estimated cost
here,
f(n) = The actual cost of traversal.
g(n) = the cost from the initial node to the current node.
h(n) = estimated cost from the current node to the goal
state.
Constraint Satisfaction
• Constraint satisfaction is a search procedure that operates in a space of constraint sets. The initial
state contains the constraints that are originally given in the problem description.
– A goal state is any state that has been constrained “enough” where “enough” must be
defined for each problem.
– For example, in cryptarithmetic problems, enough means that each letter has been assigned
a unique numeric value.
– Constraint Satisfaction problems in AI have goal of discovering some problem state that
satisfies a given set of constraints.
– Design tasks can be viewed as constraint satisfaction problems in which a design must be
created within fixed limits on time, cost, and materials.
– Constraint Satisfaction is a two-step process:
• First constraints are discovered and propagated as far as possible throughout the system.
• Then if there is still not a solution, search begins. A guess about something is made and added as
a new constraint.
• Example: Cryptarithmetic Problem
• Constraints:
• No two letters have the same value
• The sums of the digits must be as shown in the problem Goal State:
– All letters have been assigned a digit in such a way that all the initial constraints
are satisfied
• Input State Solution:
• Reasoning:
The reasoning is the mental process of deriving logical
conclusion and making predictions from available knowledge,
facts, and beliefs. Or we can say, "Reasoning is a way to infer
facts from existing data." It is a general process of thinking
rationally, to find valid conclusions.
Types of Reasoning
In artificial intelligence, reasoning can be divided into the
following categories:
• Deductive reasoning
• Inductive reasoning
• Abductive reasoning
• Common Sense Reasoning
• Monotonic Reasoning
Deductive Reasoning:
• Deductive reasoning is deducing new information from logically
related known information. It is the form of valid reasoning, which
means the argument's conclusion must be true when the premises
are true.
• Deductive reasoning is a type of propositional logic in AI, and it
requires various rules and facts. It is sometimes referred to as top-
down reasoning, and contradictory to inductive reasoning.
• In deductive reasoning, the truth of the premises guarantees the
truth of the conclusion.
• Deductive reasoning mostly starts from the general premises to the
specific conclusion, which can be explained as below example.

Example:
• Premise-1: All the human eats veggies
• Premise-2: Suresh is human.
• Conclusion: Suresh eats veggies.
Inductive Reasoning:
• Inductive reasoning is a form of reasoning to arrive at a conclusion
using limited sets of facts by the process of generalization. It starts
with the series of specific facts or data and reaches to a general
statement or conclusion.
• Inductive reasoning is a type of propositional logic, which is also
known as cause-effect reasoning or bottom-up reasoning.
• In inductive reasoning, we use historical data or various premises
to generate a generic rule, for which premises support the
conclusion.
• In inductive reasoning, premises provide probable supports to the
conclusion, so the truth of premises does not guarantee the truth
of the conclusion.

Example:
• Premise: All of the pigeons we have seen in the zoo are white.
Abductive reasoning:
• Abductive reasoning is a form of logical reasoning
which starts with single or multiple observations
then seeks to find the most likely explanation or
conclusion for the observation.
• Abductive reasoning is an extension of deductive
reasoning, but in abductive reasoning, the premises
do not guarantee the conclusion.
• Example:
• Implication: Cricket ground is wet if it is raining
• Axiom: Cricket ground is wet.
• Conclusion It is raining.
Common Sense Reasoning
• Common sense reasoning is an informal form of
reasoning, which can be gained through experiences.
• Common Sense reasoning simulates the human
ability to make presumptions about events which
occurs on every day.
• It relies on good judgment rather than exact logic and
operates on heuristic knowledge and heuristic rules.
• Example:
• One person can be at one place at a time.
• If I put my hand in a fire, then it will burn.
Monotonic Reasoning:
• In monotonic reasoning, once the conclusion is taken, then it will
remain the same even if we add some other information to existing
information in our knowledge base. In monotonic reasoning, adding
knowledge does not decrease the set of prepositions that can be
derived.
• To solve monotonic problems, we can derive the valid conclusion
from the available facts only, and it will not be affected by new facts.
• Monotonic reasoning is not useful for the real-time systems, as in
real time, facts get changed, so we cannot use monotonic reasoning.
• Monotonic reasoning is used in conventional reasoning systems, and
a logic-based system is monotonic.
Example: Earth revolves around the Sun.
It is a true fact, and it cannot be changed even if we add another
sentence in knowledge base like, "The moon revolves around the earth"
Or "Earth is not round," etc.
Non-monotonic Reasoning
• In Non-monotonic reasoning, some conclusions may be invalidated if
we add some more information to our knowledge base.
• Logic will be said as non-monotonic if some conclusions can be
invalidated by adding more knowledge into our knowledge base.
• Non-monotonic reasoning deals with incomplete and uncertain models.
• Human perceptions for various things in daily life, "is a general example
of non-monotonic reasoning.
• Example: Let suppose the knowledge base contains the following
knowledge:
• Birds can fly
• Penguins cannot fly
• Pitty is a bird
• So from the above sentences, we can conclude that Pitty can fly.
• However, if we add one another sentence into knowledge base "Pitty is
a penguin", which concludes "Pitty cannot fly", so it invalidates the
above conclusion.

You might also like