fixes
diff --git a/sim.py b/sim.py
--- a/sim.py
+++ b/sim.py
@@ -457,7 +457,7 @@ def fold(net, num=100, strategy="jumphal
target = choice(nodes)
while target == start:
target = choice(nodes)
- if fullroute:
+ if fullroutes:
route = findroute(target, start, net, maxhtl=9999)
else:
route = findroute(target, start, net, maxhtl=maxhtl)
@@ -465,7 +465,7 @@ def fold(net, num=100, strategy="jumphal
# in case we break the route at maxhtl, we just add the
# HTL+1 to be able to do the simplistic success stats
# later.
- if not fullroute:
+ if not fullroutes:
routelengths.append(maxhtl+1)
continue
routelen = len(route)
@@ -496,7 +496,7 @@ def parse_args():
parser.add_argument("--maxhtl", help="The maximum length of routes to be successful.", default=20, type=int)
parser.add_argument("--steps", help="The maximum number of modelsteps.", default=60, type=int)
parser.add_argument("--perstep", help="The number of requests to run per step.", default=100, type=int)
- parser.add_argument("--nofullroutes", help="Don’t calculate full routes but break at maxhtl. This gives weaker statistics but is much faster for random networks with very long routes and very low success rate", action="store_true", default=False, type=bool)
+ parser.add_argument("--nofullroutes", help="Don’t calculate full routes but break at maxhtl. This gives weaker statistics but is much faster for random networks with very long routes and very low success rate", action="store_true")
parser.add_argument("-o", "--output", help="Filename of the pylab plot.", default="plot.png")
return parser.parse_args()
@@ -514,7 +514,7 @@ if __name__ == "__main__":
lensnapshots[(run,0)] = linklengths(net), [0]
print (np.mean(lensnapshots[(run,0)][0]))
print("===", run, "===")
- routelengths = fold(net, 20)
+ routelengths = fold(net, foldperstep, args.strategy, args.maxhtl, fullroutes=not args.nofullroutes)
linklens = linklengths(net)
print (np.mean(linklens), np.mean(routelengths), "±", np.std(routelengths), "succ", len([r for r in routelengths if r < args.maxhtl])/len(routelengths), min(routelengths), max(routelengths), sum(deviationfromsmallworld(linklens, numbins=10)))
for i in range(args.steps):
@@ -524,6 +524,7 @@ if __name__ == "__main__":
print (np.mean(linklens), np.mean(routelengths), "±", np.std(routelengths), "succ", len([r for r in routelengths if r < args.maxhtl])/len(routelengths),
min(routelengths), max(routelengths), sum(deviationfromsmallworld(linklens, numbins=10)))
+ print()
# now plot the data
import pylab as pl
pl.rcParams['font.size'] = 5