使用最佳优先搜索查找路线

问题描述 投票:0回答:1

我必须在Prolog中做一些我不太熟悉的工作。我需要找到伦敦地铁从一个车站到另一个车站的路径,所需的旅行时间以分钟为单位。我需要应用“最佳优先搜索”以实现目标。我需要一个开端,因为我从未在Prolog中做过任何工作。我已经开始了一点,但不知道如何进一步。任何帮助将不胜感激。这是我的入门者:

adjacent(waterloo,westminster,jubilee,2).
adjacent(westminster,green_park,jubilee,2).
adjacent(green_park,bond_street,jubilee,2).
adjacent(bond_street,baker_street,jubilee,2).

adjacent(waterloo,embankment,northern,2).
adjacent(embankment,charing_cross,northern,1).
adjacent(charing_cross,leicester_square,northern,1).
adjacent(leicester_square,tottenham_court_road,northern,2).
adjacent(tottenham_court_road,goodge_street,northern,1).
adjacent(goodge_street,warren_street,northern,2).
adjacent(warren_street,euston,northern,1).

adjacent(waterloo,embankment,bakerloo,2).
adjacent(embankment,charing_cross,bakerloo,1).
adjacent(charing_cross,piccadilly_circus,bakerloo,2).
adjacent(piccadilly_circus,oxford_circus,bakerloo,2).
adjacent(oxford_circus,regents_park,bakerloo,2).
adjacent(regents_park,baker_street,bakerloo,2).
prolog breadth-first-search
1个回答
0
投票

迭代式加深可让您以不会陷入循环的方式做到最佳第一。https://www.swi-prolog.org/pldoc/man?predicate=call_with_depth_limit/3

© www.soinside.com 2019 - 2024. All rights reserved.