Wuolah Free SINBlock1Chapter5
Wuolah Free SINBlock1Chapter5
Anónimo
Sistemas Inteligentes
Heuristic function: A rule of thumb, simplification, or educated guess that reduces or limits the search for
solutions in domains that are difficult and poorly understood
h(n) = estimated cost of the cheapest path from the state at node n to the goal state. If n is the goal state
then ℎ(𝑛) = 0
Greedy best-first search expands the node that appears to be closest to goal; it expands the closest node to
the goal, on the grounds that this is likely to lead to a solution quickly. Thus, it evaluates nodes by using
just the heuristic function: 𝑓(𝑛) = ℎ(𝑛)
a64b0469ff35958ef4ab887a898bd50bdfbbe91a-3906950
Features
• Complete
o NO, it can get stuck in loops, e.g. (consider the problem to go from Iasi to Fagaras):
Iasi → Neamt → Iasi → Neamt (dead end, infinite loop)
No se permite la explotación económica ni la transformación de esta obra. Queda permitida la impresión en su totalidad.
o Resembles depth-first search (it prefers to follow a single path to the goal)
o The GRAPH-SEARCH version is complete (check on repeated states in the CLOSED LIST)
• Optimal:
o No, at each step it tries to get as close to the goal state as it can; this is why it is called greedy!
No se permite la explotación económica ni la transformación de esta obra. Queda permitida la impresión en su totalidad.
The idea is to avoid paths that are already expensive. f(n) is the estimated total cost of the cheapest
solution through n. Algorithms that use an evaluation function of the form 𝑓(𝑛) = 𝑔(𝑛) + ℎ(𝑛) are called
A algorithms.
A* search uses an admissible heuristic function. A heuristic is admissible if it never overestimates the cost
to reach the goal, i.e., it is optimistic.
Formally:
• A heuristic h(n) is admissible if for every node n, ℎ(𝑛) ≤ ℎ∗ (𝑛), where h*(n) is the real cost
to reach the goal state from n.
• Because A* search uses an admissible heuristic, it returns the optimal solution.
• ℎ(𝑛) >= 0 so ℎ(𝐺) = 0 for any goal G
Iteration 2
Last iteration:
No se permite la explotación económica ni la transformación de esta obra. Queda permitida la impresión en su totalidad.
total cost (𝑓 − 𝑣𝑎𝑙𝑢𝑒 = 418) than the one in the OPEN LIST. We replace the Bucharest node in OPEN
with the new found instance.
Example (2)
TREE-SEARCH version without control of repeated states
• Heuristic knowledge:
o ℎ(𝑛) = 0, lack of knowledge
o ℎ(𝑛) = ℎ∗ (𝑛), maximal knowledge
For difficult problems, it is recommended to highly reduce the search space. In these cases, it is worth using
ℎ(𝑛) > ℎ∗ (𝑛) to eventually find a solution at a reasonable cost even though this is not the optimal solution.
For each problem, find a balance between the search cost and the cost of the solution path found.
a64b0469ff35958ef4ab887a898bd50bdfbbe91a-3906950
Optimality
The optimality of a TREE-SEARCH A* algorithm is guaranteed if h(n) is an admissible heuristic.
Admissibility:
No se permite la explotación económica ni la transformación de esta obra. Queda permitida la impresión en su totalidad.
o h(n) is admissible if it never overestimates the cost to reach the goal (∀𝑛, ℎ(𝑛) ≤ ℎ∗ (𝑛))
o Let G be a goal/objective node, and n a node on an optimal path to G. f(n) never overestimates
the true cost of a solution through n
o 𝑓(𝑛) = 𝑔(𝑛) + ℎ(𝑛) ≤ 𝑔(𝑛) + ℎ∗ (𝑛) = 𝑔(𝐺) = 𝑓(𝐺) ⇒ 𝑓(𝑛) ≤ 𝑔(𝐺) (1)
Proof that if h(n) is admissible, then A* is optimal
• Let Start be the initial state of a problem such that the optimal
solution from Start leads to a solution node 𝐺: 𝑓(𝐺) = 𝑔(𝐺)
• Let G2 be another solution node (𝑓(𝐺2) = 𝑔(𝐺2)) such that the
cost of G2 is higher than the cost of G: 𝑔(𝐺2) > 𝑔(𝐺) (2)
• Let n be a node on the optimal path to G
If we combine (1) and (3) we get 𝑓(𝐺2) ≤ 𝑓(𝑛) ≤ 𝑔(𝐺) ⇒ 𝑔(𝐺2) ≤ 𝑔(𝐺) that contradicts
(2) so n is chosen first for expansion. Therefore, the algorithm will return the optimal solution.
The optimality of a GRAPH-SEARCH A* algorithm where repeated states in CLOSED are re-expanded is
guaranteed if h(n) is an admissible heuristic.
In a GRAPH-SEARCH A* algorithm with no re-expansion of repeated states in CLOSED, the optimal
solution is guaranteed if we can ensure the first found path to any node is the best path to the node. This
occurs if h(n) is a consistent heuristic.
Consistency, also called monotonicity is a slightly stronger condition than admissibility:
h(n) is consistent if, for every node n and every successor n’ of n generated by any action a:
ℎ(𝑛) ≤ ℎ(𝑛’) + 𝑐(𝑛, 𝑎, 𝑛’)
Therefore, a GRAPH-SEARCH A* algorithm with no re-expansion of repeated states that uses a consistent
heuristic h(n) also returns the optimal solution:
• Because it is guaranteed that when a node n is expanded, we have found the optimal solution from
the initial state to n so it is not necessary to re-expand n in case of a repeated instance; i.e. the cost
of the first instance of n will never be improved by any repeated node (they will be at least as
expensive).
• A derivation of the consistency condition is that the sequence of expanded nodes by the GRAPH-
SEARCH version of A* is in non-decreasing order of f(n).
No se permite la explotación económica ni la transformación de esta obra. Queda permitida la impresión en su totalidad.
• Optimal
o YES, under consistency condition (for GRAPH-SEARCH version)
o There always exists at least a node n on the OPEN LIST that belongs to the optimal
solution path from the start node to a goal node
o If C* is the cost of the optimal solution:
▪ A* expands all nodes with 𝑓(𝑛) < 𝐶 ∗
▪ A* might expand some nodes with 𝑓(𝑛) = 𝐶 ∗
▪ A* expands no nodes with 𝑓(𝑛) > 𝐶 ∗
No se permite la explotación económica ni la transformación de esta obra. Queda permitida la impresión en su totalidad.
o Exhaustive search to depth 22: 322 ≈ 3.1 𝑥 1010 states.
o A good heuristic function can reduce the search process.
• Heuristic 1:
o ℎ1(𝑛): number of misplaced tiles
o ℎ1(𝑛) = 5 for the example
• Heuristic 2:
o ℎ2(𝑛): Manhattan distance (the sum of the
distances of the tiles from their goal positions)
o ℎ2(𝑛) = 1 + 2 + 4 + 1 + 1 = 9 for the example
Manhattan distance dominates misplaced tiles (ℎ2(𝑛) ≥ ℎ1(𝑛), ∀𝑛), so h2 is better for search.
𝑁 + 1 = 1 + 𝑏 ∗ + (𝑏 ∗ )2 + … + (𝑏 ∗ )𝑑
For example, if A* finds a solution at depth 5 using 52 nodes, 𝑏 ∗ = 1.92.
• A well-designed heuristic would have a value of b* close to 1, allowing fairly large problems to be solved.
• A value of b* near unity corresponds to a search that is highly focused towards the goal, with very little
branching in other directions.
• Experimental measurements of b* on a small set of problems can provide a good guidance to the
heuristic’s overall usefulness.
Example – Heuristics for the traveling salesman problem
• 6 cities: A,B,C,D,E,F
• States: sequences of cities starting in city A which
represent partial routes
• Start: A
• Final: sequences starting and ending in A which are made up of all cities
• Rules or operators: add at the end of each state one city which is not in the sequence already
• Operators cost: distance between the last city in the sequence and the recently added city (see table)
a64b0469ff35958ef4ab887a898bd50bdfbbe91a-3906950
𝒉(𝑨𝑩𝑬) → C, D, F, back to A
h2(n) = number of missing arcs multiplied by the arc of
minimal cost [ℎ2(𝐴𝐵𝐸) = 4 ∗ 5 = 20]
No se permite la explotación económica ni la transformación de esta obra. Queda permitida la impresión en su totalidad.
h3(n) = sum of the shortest p arcs if there are p missing arcs
(undirected graph) [ℎ3(𝐴𝐵𝐸) = 5 + 5 + 7 + 7 = 24]