Skip to content

Commit

Permalink
Fixed path lengths output only showing the paths found in the last trial
Browse files Browse the repository at this point in the history
  • Loading branch information
ChadFulton committed Feb 20, 2013
1 parent 6b24b83 commit 14d8859
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ def main():
"""Function called by running simulate.py on the command line"""
t0 = time.time()

path_lengths = {}
p = []
for i in range(settings.trials):
world = simulate(settings.n, settings.T, graph=settings.double_bridge, source_node = settings.NEST, terminal_node = settings.FOOD);
pheromones = world.memo_history[-1]
p.append(float(pheromones[settings.NEST | settings.FOOD])**settings.alpha / (float(pheromones[settings.NEST | settings.FOOD])**settings.alpha + float(pheromones[settings.LONG_BRANCH | settings.NEST])**settings.alpha))
for path_length, n in world.path_lengths.iteritems():
if path_length not in path_lengths:
path_lengths[path_length] = 0
path_lengths[path_length] += n
fail = [i for i in p if i <= 0.5]
success = [i for i in p if i >= 0.5]

Expand All @@ -46,7 +51,7 @@ def main():
print '|'
print '| Convergence to long path: %d%%' % (float(len(fail)) / float(len(p))*100)
print '| (in %.1f seconds)' % (t1-t0)
print '| Number of paths found: ', world.path_lengths
print '| Number of paths found: ', path_lengths
print '==========================================='
print ''

Expand Down

0 comments on commit 14d8859

Please sign in to comment.