本文整理汇总了Python中ai.AI.perfroming_AI方法的典型用法代码示例。如果您正苦于以下问题:Python AI.perfroming_AI方法的具体用法?Python AI.perfroming_AI怎么用?Python AI.perfroming_AI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ai.AI
的用法示例。
在下文中一共展示了AI.perfroming_AI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_instance
# 需要导入模块: from ai import AI [as 别名]
# 或者: from ai.AI import perfroming_AI [as 别名]
def run_instance(instance_num):
#change the number after randTSP to switch to different number of cities graph
fo = open("randTSP/15/instance_%s.txt"%instance_num, "rw+")
# fo = open("randTSP/problem36.txt", "rw+")
number_of_city = int(fo.readline())
cities = []
#prepare data for a star algorithm
for line in fo:
city_info = line.split()
cities.append(City(city_info[0], city_info[1], city_info[2]))
fo.close()
# performing A* Search Algorithm, starting from the first node -- city A
astar = AI(cities)
result = astar.perfroming_AI()
#plot the result
fig, ax = plt.subplots()
x = []
y = []
names = []
for r in result:
print r.name
x.append(r.x)
y.append(r.y)
names.append(r.name)
ttl = str(AI.node_expand) + " nodes have expended"
print "result is ----------> ",AI.node_expand, "<----------"
plt.title(ttl)
plt.plot(x, y)
for i, txt in enumerate(names):
ax.annotate(txt, (x[i], y[i]))
plt.show()