Classical Algorithm Research Series: 8. heuristic search algorithms

Source: Internet
Author: User

ClassicAlgorithmStudy Series: 8. heuristic search algorithms


Author: July February 10, 2011
I. Wikipedia,
Ii. Artificial Intelligence-09 heuristic search,
Iii. Classic Algorithm Research Series in this blog: 1. A * Search Algorithm


A * search algorithms, as the beginning of the classical algorithm research seriesArticle, Which has been described in this blog.
However, to really understand the * search algorithm, you must first start with the heuristic search algorithm.

After all, a * search algorithm is also one of the heuristic algorithms. OK.

I. What is heuristic search?
A heuristic search algorithm is a bit like a breadth-first search. The difference is that it will first search for enlightening and specific information nodes.

These nodes may be the best path to the target.

We call this process best-first or heuristic search.

The basic idea is as follows:
1) assume that there is a heuristic (Evaluation) function effecf, which can help determine the next optimal node to be extended,
We adopt a convention, that is, the small value of limit F indicates that a good node is found.
This function is based on the information of the specified problem domain. It is an actual numeric function of state description.

2) The next node to be expanded n is the node with the smallest value of ipvf (N) (assuming that node expansion generates all
3) The process ends when the next node to be expanded is the target node.

We can often specify a good evaluation function for optimal search.
For example8. Digital Problems, You can use the number of numbers in the incorrect position as a measurement of the status description:
F (n) = number of numbers with incorrect positions (compared with the target)
When this heuristic function is used in the search process, the graph shown in Figure 9-1 is generated. The value of each node is

Figure 9-1 A possible result of a heuristic search process

The above example shows that in the search process, we need to favor searching back to the early paths (in order to avoid testing due to excessive optimization)
And fall into "Garden trails ").

Therefore, we add a "depth factor" to limit F: Limit F (n) = g lead (n) + H lead (N), g lead (N) is the "depth" Estimation of node N in the figure (that is
The shortest path length from the Start Node to N), H minus (n) is the inspiration or evaluation of node n.

As before, if G Branch (n) = searches for the depth of node N in the graph, H Branch (n) = the number of digits in the incorrect position (compared with the target ), we can see Figure 9-2.


In this figure, the values of G Branch (N) and H Branch (n) are written next to each node. In this case, we can see that the search is directly directed to

Label (except nodes marked with circles ).

These examples raise two important questions.
First, how do we determine the evaluation function for optimal search?
Second, what are the features of optimal search? Can it find a good path to the target node?

This article mainly discusses the representation of optimal search. As an example, the following describes a general graph search algorithm that includes the optimal search version.
(For more details about heuristic search, refer to the cited articles and the book [pearl 1984] written by Pearl.)

2. A general Graph Search Algorithm
To more accurately interpret the heuristic search process, a general graph search algorithm is proposed here, which allows various
User-preference for heuristic or blind customization. I call this algorithm graphsearch ).
The following is the definition of (first version.
1) generate a search tree tr that only contains the Start Node N0. Place N0 in an ordered list called open.
2) generate a list named closed with an empty initial value.
3) if open is empty, it fails and exits.
4) Select the first node in open, remove it from open, and put it into closed. This node is called N.
5) if n is the target node, trace back from N to N0 along the arc in TR and find a path to obtain the solution.
Output (the arc is generated in step 1 ).
6) Expand node n to generate n successor Node Set M. Create an arc for each member from N to m in tr to generate n successors.
7) sort the open list in any mode or heuristic mode.
8) return to step 3.

This algorithm can be used to perform optimal search, breadth-first search, or deep-first search.
In the breadth-first search, new nodes can be placed at the end of open (first-in-first-out, FIFO), and nodes do not need to be rearranged.
In the deep priority search, the new node is placed at the beginning of open (later, first-in, first-out, LIFO ).
In the optimal (also known as heuristic) search, open is rearranged according to the heuristic method of nodes.


III. A * Search Algorithm

Use the optimal search algorithm to describe graphsearch in detail.
Based on the added value of the function, the optimal search algorithm reassembles the section in open (in step 1 ).
Point, such as 8 digital problems. This algorithm of graphseach is called algorithm *.

As shown in the following figure, it is feasible to define a * to perform a wide search or search at the same cost. To determine the function family to use, you must first
Describes other symbols.

Set g (n) = the cost of a minimum cost path from the Start Node N0 to the node n.
Set H (n) = the actual cost of the minimum cost path between node N and the target node (covering all possible target nodes and all possible paths from N to them.

F (n) = g (n) + H (n) is the minimum cost path from N0 to the target node and passing through node n.
Note that F (N0) = H (N0) is the cost of a (unrestricted) minimum cost path from N0 to the target node.

For each node N, set G cost (N) (depth factor) to the minimum cost path from node n discovered by a *, and H cost (N) (heuristic factor) is an estimation of H (n.
In algorithm a *, we use branch F (n) = G Branch (n) + H Branch (n ).
Note: If the constant in algorithm A * is equal to 0, it will be searched at the same cost. Examples of these definitions are shown in figure 3.

Algorithm *:
1) generate a search graph G that only contains the Start Node N0, and place the N0 on an open list.
2) generate a list named closed. Its initial value is null.
3) if open is empty, it fails to exit.
4) Select the first node on open and move it from open to closed, which is called N.
5) if n is the target node, find a path from N to N0 in G, get the solution, and exit successfully.
(This pointer defines a search tree created in step 1 ).

6) Expand node n to generate its successor Node Set M. In G, N's ancestor cannot be in M. Placement of m in G
Members to make them the successor of N.
7) create a pointer to N from every non-g Member of M (for example, neither open nor
In closed ). Add members of m to open. For each
If the best path to M found so far passes through N, it points its pointer to n. Pair
Every member of M that is already in close, redirects it to every successor in g so that they follow the current
The best path found so far points to their ancestor.
8) Sort open by incremental value (the same minimum value can be solved based on the deepest node in the Search Tree ).
9) return step 1.

In step 2, if the search process finds that the cost of a path arriving at a node is lower than that of the existing path,
We need to redirect the pointer to this node. The redirection of the node descendant in closed saves the following
But it may require exponential computing costs. Therefore, step 1 is often not implemented. With search
And some pointers will be redirected.

For more information, see: Classic Algorithm Research Series: 1. A * search algorithm:


Iv. heuristic algorithm problems
4.1. heuristic algorithms and Shortest Path Problems
Heuristic algorithms are usually used to search information. For example, it is best to prioritize greedy algorithms.
Method and *.

It is best to prioritize greedy algorithms to select the lowest-cost node for heuristic functions;
A * selects the lowest cost node for G (n) + H (N). This G (n) is the exact cost of the path from the Start Node to the current node.
If H (n) is acceptable (admissible) meaning that H (n) has not paid more than the cost to reach the goal, a * will certainly find the optimal solution.

N-puzzle is the classic problem that best shows the benefits of heuristic algorithms. This algorithm is used when calculating the incorrect puzzle image, the sum of the distance between the two pieces of the puzzle and the distance between them and the target. Note that both of the preceding conditions must be within the acceptable range.

The distance from Manhattan is a simple version of N-puzzle, because we assume that we can move a square to the desired position independently without considering moving it to other blocks.
Give us a group of reasonable heuristic functions, such as H1 (N), H2 (N ),..., hi (N), while the function H (n) = max {H1 (N), H2 (N ),..., hi (n)} Is
Can predict the heuristic types of these types.

Absolver, a program written by a.e. prieditis in 1993, uses these technologies, which can automatically inspire problems.
Algorithm. The heuristic algorithm generated by absolver for 8-puzzle is better than any previous one! It also finds the first useful solution.
The heuristic program of the cube.

4.2 influence of heuristic algorithms on computing efficiency
In any search problem, each node has B choices and D depth to reach the target. A no-skill algorithm usually needs to search for BD
Node to find the answer.

Heuristic Algorithms reduce the branching factor by using a certain cutting mechanism to improve search efficiency, from B to B '. The branching rate can be used to define the partial order relationship of a heuristic algorithm. For example, if you are on a n-node search tree,
If the split rate of H1 (n) is lower than that of H2 (N), H1 (n) <H2 (n ).

Heuristic Algorithms provide a low split rate for each node in the search tree to solve specific problems, so they have a better computing capability.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.