本文整理汇总了Python中solver.Solver.dfs方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.dfs方法的具体用法?Python Solver.dfs怎么用?Python Solver.dfs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solver.Solver
的用法示例。
在下文中一共展示了Solver.dfs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dfs
# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import dfs [as 别名]
def dfs():
solver = Solver(3)
result = []
for i in range(11):
t = []
# Gets 100 samples
for j in range(100):
start = time.clock()
v = solver.dfs(math.pow(2, i))
t.append(time.clock() - start)
# Calculates the median time
result.append(np.median(t))
# Returns a list of medians
return result
示例2: dfs_bfs
# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import dfs [as 别名]
def dfs_bfs():
solver = Solver(3)
result = [[], []] # Keeps the execution time + path length
bfs_target = rubiks_cube()
for i in range(4):
print '# i = ', i
t = []
l = []
for j in range(100):
print'### j = ', j
start = time.clock()
v = solver.dfs(math.pow(2, i))
u = solver.bfs(v, bfs_target)
p = solver.calculate_shortest_path(u) # Path from v to cube's initial state
total_time = time.clock() - start
if total_time < 180:
print "### time %d length %d" % (total_time, len(p))
t.append(total_time)
l.append(len(p))
result_full.append(len(p))
result[0].append(np.median(t))
result[1].append(np.median(l))
return result