Classical Algorithm Research Series: 8. heuristic search algorithms

Source: Internet
Author: User

Author: July February 10, 2011
Reference:
I. Wikipedia,
II. Artificial Intelligence-09 heuristic search,
III. Classic Algorithm Research Series in this BLOG: 1. A * Search Algorithm
----------------------------

 

Introduction:
A * search algorithms, as the first article in the classical algorithm research series, have 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 example, you can use the number of numbers in the incorrect position as a metric to describe the status:
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
Value.

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.
GRAPHSEACH:
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: html "target = _ blank> classical 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)

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.

.

Related Article

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: info-contact@alibabacloud.com 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.