標準的な方法は次のとおりです。AI: 最新のアプローチ
function UNIFORM-COST-SEARCH
node <- INITIAL-STATE
frontier <- priority queue ordered by PATH-COST, with node as the only element
explored <- an empty set
loop do
if frontier is empty then return failure
node <- POP frontier /* chooses the lowest-cost node in frontier */
if GOAL-TEST(node) then return SOLUTION(node)
add node to explored
for each action in ACTIONS(node) do
child <- CHILD-NODE(problem, node, action)
if child is not in explored or frontier then
frontier.INSERT(child)
else if child is in frontier with higher PATH-COST then
replace that frontier node with child
ここで、この手順を実行するのは複雑です。通常の優先度キューでは、特定の要素の優先度を効率的に更新できません。
else if child is in frontier with higher PATH-COST then
replace that frontier node with child
アルゴリズムを次のように変更することを考えています。
function UNIFORM-COST-SEARCH-Modified
node <- INITIAL-STATE
frontier <- priority queue ordered by PATH-COST, with node as the only element
explored <- an empty set
loop do
if frontier is empty then return failure
node <- POP frontier /* chooses the lowest-cost node in frontier */
> if node is in explored then continue
if GOAL-TEST(node) then return SOLUTION(node)
add node to explored
for each action in ACTIONS(node) do
child <- CHILD-NODE(problem, node, action)
> if child is not in explored then
frontier.INSERT(child)
したがって、フロンティアに繰り返し状態が含まれているかどうかは気にしません。フロンティアで繰り返される最初の状態のみを展開します。パスコストはconsistent
であり、フロンティアは を使用して実装されてpriority queue
いるため、より高いコストを持つ他の繰り返される状態を無視しても害はありません。
それは合理的ですか?
アップデート
申し訳ありませんが、一貫したヒューリスティックなケースに特に興味があることを忘れていました。