# AI heuristic algorithm (a,a*)

Source: Internet
Author: User

Heuristic algorithm is a kind of search strategy, which is different from blind search algorithm. The main characteristic is that we can use some characteristic information (heuristic information) to guide the process of searching, which can narrow the search scope and improve the search efficiency.

In fact, the heuristic algorithm also represents the "Thumb Code" (which in most cases is successful, but does not guarantee a certain success of the guidelines).

Heuristic algorithm can not be separated from heuristic information, and heuristic information is reflected in evaluation function.

The evaluation function f (x) is defined as: starting from the initial node S0, constrains the estimated value of the minimum path cost in all the paths of node x to the target node sg.

Its general form is F (x) =g (x) +h (x), g (x) represents the actual cost from the initial node S0 to node X, and H (x) represents the estimated cost of the optimal path from X to the target node sg. But the actual form should be determined according to the problem characteristics.

A search algorithm

We use a eight digital example to explain the A-search algorithm.

(Problem description and illustrations reproduced from http://www.cnblogs.com/guanghe/p/5485816.html)

Problem Description:

? 3x3 Nine chess board, placing a digital 1-8 of the 8 chess cards, leaving a space, only through the move of chess cards to the space to change the layout of the board.

Requirements: According to the given initial layout (that is, the initial state) and the target layout (that is, the target State), how to move the chess card from the initial layout to reach the target layout, to find a legitimate walking sequence.

Question discussion:

How does a search algorithm solve eight digital problems? Remember that the heuristic algorithm is inseparable from the valuation function (f (x) =g (x) +h (x)), then for the eight digital problem we give the value function, g (x) is currently examined and expanded node n in the search graph node depth, h (x) is the node x compared to the target State SG, Number of cards not in the target position (no spaces).

So the initial state of F (x) =0+4=4.

In the process of solving, we also need to use open table, close table.

The open table holds nodes that have not yet been expanded, and the close table holds the expanded nodes.

Problem Solving Process:

1, load the initial node into the open table

2, if the open table is empty, fails, exits; otherwise, the first node in the Open table is removed and added to the close table.

3, if the node is the target node, it succeeds and exits.

4, if the node can be extended, the node's extension node is added to the open table, and the open table is arranged from small to large according to the valuation function;

Otherwise jump 2nd step.

A * search algorithm

We also use eight digital questions to explain a * algorithm.

The definition of the valuation function in a * algorithm: g (x) is the node depth of the currently examined and expanded node n in the search graph, and H (x) is the sum of the number of moves required to move to the corresponding position of the target State (without spaces), when the node x is compared to the target State SG.

A * algorithm is more efficient than a algorithm.

AI heuristic algorithm (a,a*)

Related Keywords:

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.