scyther/gui/Protocols/multi-NSL/test-heuristics.py

70 lines
1.4 KiB
Python
Raw Normal View History

2006-11-21 13:40:50 +00:00
#!/usr/bin/python
#
#
# Idea:
#
# We test all options for the heuristics [0..31] to compare,
# and sincerely hope on gives a complete proof.
# we slowly refine the tests.
#
2020-10-27 21:09:03 +00:00
import subprocess
2006-11-21 13:40:50 +00:00
def startset():
mainlist = [11, 15]
2020-10-27 21:09:03 +00:00
print("Starting with", mainlist)
2006-11-21 13:40:50 +00:00
return mainlist
def tuplingchoice(heur,variant,P,runs,latupling):
# variant is in range [0..64>,
# where we use the highest bid to signify the
# associativity of the tupling.
extraflags = ""
if latupling:
extraflags += " --la-tupling"
# Choose heuristics
extraflags += " --goal-select=%i" % (heur)
# Time limit
extraflags += " --timer=20"
s = "./multinsl-generator.py"
s += " %i %i" % (P,variant)
s += " | scyther -a -r%i -m2 --summary %s" % (runs, extraflags)
## Old stuff
#s += " | scyther -a -r%i --summary" % runs
# Show what we're doing
2020-10-27 21:09:03 +00:00
print(s)
2006-11-21 13:40:50 +00:00
#s += " | grep \"complete\""
2020-10-27 21:09:03 +00:00
out = subprocess.getoutput(s)
2006-11-21 13:40:50 +00:00
if out == "":
#print "Okay"
return False
else:
2020-10-27 21:09:03 +00:00
print(out)
2006-11-21 13:40:50 +00:00
return True
def testvariant(h,v,p,r):
if tuplingchoice (h,v,p,r, False):
return True
else:
return tuplingchoice (h,v,p,r, True)
def scan(testlist, P, runs):
2020-10-27 21:09:03 +00:00
print("Testing using P %i and %i runs." % (P,runs))
2006-11-21 13:40:50 +00:00
for i in testlist:
2020-10-27 21:09:03 +00:00
print("Testing protocol %i." % (i))
2006-11-21 13:40:50 +00:00
for h in range (0,32):
2020-10-27 21:09:03 +00:00
print("Heuristic %i:" % (h))
2006-11-21 13:40:50 +00:00
testvariant (h,i,P,runs)
def main():
candidates = startset()
scan(candidates,3,5)
main()