# Heuristic techniques

In this article, we are going to discuss Heuristic techniques along with some examples that will help you to understand the Heuristic techniques more clearly.

## What is Heuristics?

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

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

## History

Psychologists Daniel Kahneman and Amos Tversky have developed the study of Heuristics in human decision-making in the 1970s and 1980s. However, this concept was first introduced by the Nobel Laureate Herbert A. Simon, whose primary object of research was problem-solving.

## Why do we need heuristics?

Heuristics are used in situations in which there is the requirement of a short-term solution. On facing complex situations with limited resources and time, Heuristics can help the companies to make quick decisions by shortcuts and approximated calculations. Most of the heuristic methods involve mental shortcuts to make decisions on past experiences.

The heuristic method might not always provide us the finest solution, but it is assured that it helps us find a good solution in a reasonable time.

Based on context, there can be different heuristic methods that correlate with the problem's scope. The most common heuristic methods are - trial and error, guesswork, the process of elimination, historical data analysis. These methods involve simply available information that is not particular to the problem but is most appropriate. They can include representative, affect, and availability heuristics.

## Heuristic search techniques in AI (Artificial Intelligence)

We can perform the Heuristic techniques into two categories:

### Direct Heuristic Search techniques in AI

It includes Blind Search, Uninformed Search, and Blind control strategy. These search techniques are not always possible as they require much memory and time. These techniques search the complete space for a solution and use the arbitrary ordering of operations.

The examples of Direct Heuristic search techniques include Breadth-First Search (BFS) and Depth First Search (DFS).

### Weak Heuristic Search techniques in AI

It includes Informed Search, Heuristic Search, and Heuristic control strategy. These techniques are helpful when they are applied properly to the right types of tasks. They usually require domain-specific information.

The examples of Weak Heuristic search techniques include Best First Search (BFS) and A*.

Before describing certain heuristic techniques, let's see some of the techniques listed below:

• Bidirectional Search
• A* search
• Simulated Annealing
• Hill Climbing
• Best First search
• Beam search

First, let's talk about the Hill climbing in Artificial intelligence.

### Hill Climbing Algorithm

It is a technique for optimizing the mathematical problems. Hill Climbing is widely used when a good heuristic is available.

It is a local search algorithm that continuously moves in the direction of increasing elevation/value to find the mountain's peak or the best solution to the problem. It terminates when it reaches a peak value where no neighbor has a higher value. Traveling-salesman Problem is one of the widely discussed examples of the Hill climbing algorithm, 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. The steps of a simple hill-climbing algorithm are listed below:

Step 1: Evaluate the initial state. If it is the 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 a goal state, then return to success and quit.

Else if it is better than the current state, then assign a new state as a current state.

Else if not better than the current state, then return to step2.

Step 5: Exit.

### Best first search (BFS)

This algorithm always chooses the path which appears best at that moment. It is the combination of depth-first search and breadth-first search algorithms. It lets us to take the benefit of both algorithms. It uses the heuristic function and search. With the help of the best-first search, at each step, we can choose the most promising node.

Best first search algorithm:

Step 1: Place the starting node into the OPEN list.

Step 2: If the OPEN list is empty, Stop and return failure.

Step 3: Remove the node n from the OPEN list, which has the lowest value of h(n), and places it in the CLOSED list.

Step 4: Expand the node n, and generate the successors of node n.

Step 5: Check each successor of node n, and find whether any node is a goal node or not. If any successor node is the goal node, then return success and stop the search, else continue to next step.

Step 6: For each successor node, the algorithm checks for evaluation function f(n) and then check if the node has been in either OPEN or CLOSED list. If the node has not been in both lists, then add it to the OPEN list.

### A* Search Algorithm

A* search is the most commonly known form of best-first search. It uses the heuristic function h(n) and cost to reach the node n from the start state g(n). It has combined features of UCS and greedy best-first search, by which it solve the problem efficiently.

It finds the shortest path through the search space using the heuristic function. This search algorithm expands fewer search tree and gives optimal results faster.

Algorithm of A* search:

Step 1: Place the starting node in the OPEN list.

Step 2: Check if the OPEN list is empty or not. If the list is empty, then return failure and stops.

Step 3: Select the node from the OPEN list which has the smallest value of the evaluation function (g+h). If node n is the goal node, then return success and stop, otherwise.

Step 4: Expand node n and generate all of its successors, and put n into the closed list. For each successor n', check whether n' is already in the OPEN or CLOSED list. If not, then compute the evaluation function for n' and place it into the Open list.

Step 5: Else, if node n' is already in OPEN and CLOSED, then it should be attached to the back pointer which reflects the lowest g(n') value.

## Examples of heuristics in everyday life

Some of the real-life examples of heuristics that people use as a way to solve a problem:

• Common sense: It is a heuristic that is used to solve a problem based on the observation of an individual.
• Rule of thumb: In heuristics, we also use a term rule of thumb. This heuristic allows an individual to make an approximation without doing an exhaustive search.
• Working backward: It lets an individual solve a problem by assuming that the problem is already being solved by them and working backward in their minds to see how much a solution has been reached.
• Availability heuristic: It allows a person to judge a situation based on the examples of similar situations that come to mind.
• Familiarity heuristic: It allows a person to approach a problem on the fact that an individual is familiar with the same situation, so one should act similarly as he/she acted in the same situation before.
• Educated guess: It allows a person to reach a conclusion without doing an exhaustive search. Using it, a person considers what they have observed in the past and applies that history to the situation where there is not any definite answer has decided yet.

## Types of heuristics

There are various types of heuristics, including the availability heuristic, affect heuristic and representative heuristic. Each heuristic type plays a role in decision-making. Let's discuss about the Availability heuristic, affect heuristic, and Representative heuristic.

### Availability heuristic

Availability heuristic is said to be the judgment that people make regarding the likelihood of an event based on information that quickly comes into mind. On making decisions, people typically rely on the past knowledge or experience of an event. It allows a person to judge a situation based on the examples of similar situations that come to mind.

### Representative heuristic

It occurs when we evaluate an event's probability on the basis of its similarity with another event.

Example: We can understand the representative heuristic by the example of product packaging, as consumers tend to associate the products quality with the external packaging of a product. If a company packages its products that remind you of a high quality and well-known product, then consumers will relate that product as having the same quality as the branded product.

So, instead of evaluating the product based on its quality, customers correlate the products quality based on the similarity in packaging.

### Affect heuristic

It is based on the negative and positive feelings that are linked with a certain stimulus. It includes quick feelings that are based on past beliefs. Its theory is one's emotional response to a stimulus that can affect the decisions taken by an individual.

When people take a little time to evaluate a situation carefully, they might base their decisions based on their emotional response.

Example: The affect heuristic can be understood by the example of advertisements. Advertisements can influence the emotions of consumers, so it affects the purchasing decision of a consumer. The most common examples of advertisements are the ads of fast food. When fast-food companies run the advertisement, they hope to obtain a positive emotional response that pushes you to positively view their products.

If someone carefully analyzes the benefits and risks of consuming fast food, they might decide that fast food is unhealthy. But people rarely take time to evaluate everything they see and generally make decisions based on their automatic emotional response. So, Fast food companies present advertisements that rely on such type of Affect heuristic for generating a positive emotional response which results in sales.

### Limitation of heuristics

Along with the benefits, heuristic also has some limitations.

• Although heuristics speed up our decision-making process and also help us to solve problems, they can also introduce errors just because something has worked accurately in the past, so it does not mean that it will work again.
• It will hard to find alternative solutions or ideas if we always rely on the existing solutions or heuristics.

## Conclusion

That's all about the article. Hence, in this article, we have discussed the heuristic techniques that are the problem-solving techniques that result in a quick and practical solution. We have also discussed some algorithms and examples, as well as the limitation of heuristics.

Next TopicWhat is RECTANGLE