- Added more scoring levels to the comparative heuristics.

- Added option to override cache.
This commit is contained in:
ccremers 2005-03-11 16:07:31 +00:00
parent b831c755f3
commit 46974091dc
3 changed files with 43 additions and 17 deletions

View File

@ -30,7 +30,7 @@ def parse(scout):
# Test with a goal selector
def test_goal_selector(goalselector):
def test_goal_selector(goalselector, options):
import protocollist
scythertest.set_extra_parameters("--goal-select=" + str(goalselector))
@ -43,7 +43,9 @@ def test_goal_selector(goalselector):
proofs = 0
claims = 0
for p in plist:
(status,scout) = scythertest.default_test([p],0,0)
(status,scout) = scythertest.default_test([p], \
int(options.match), \
int(options.bounds))
(ra,rb,rp,nc) = parse(scout)
attacks = attacks + ra
bounds = bounds + rb
@ -60,18 +62,29 @@ def main():
(options, args) = parser.parse_args()
scythertest.process_default_options(options)
print "G-sel\tAttack\tBound\tProof\tClaims\tScore"
print "G-sel\tAttack\tBound\tProof\tClaims\tScore1\tScore2"
print
for g in range(1,31):
(ra,rb,rp,nc,np) = test_goal_selector(g)
score1max = 0
score2max = 0
# Score: bounds are negative
score = ra + rp - rb
for g in range(1,31):
(ra,rb,rp,nc,np) = test_goal_selector(g, options)
# Scores: bounds are negative
score1 = ra + rp - rb
score2 = ra + rp - (2 * rb)
res = str(g)
res = res + "\t" + str(ra) + "\t" + str(rb)
res = res + "\t" + str(rp) + "\t" + str(nc)
res = res + "\t" + str(score)
res = res + "\t" + str(score1)
if score1 >= score1max:
score1max = score1
res = res + "*"
res = res + "\t" + str(score2)
if score2 >= score2max:
score2max = score2
res = res + "*"
print res
print
print "Goal selector scan completed."

View File

@ -22,6 +22,7 @@ from tempfile import NamedTemporaryFile, gettempdir
# Minimum duration for a test to get into the cache (in seconds)
CacheTimer = 0.1
ScytherProgram = "scyther"
RetrieveFromCache = True
#----------------------------------------------------------------------------
# How to override Scyther program setting
@ -35,6 +36,11 @@ def scytheroverride (newprg):
print "Cannot find any file at", ScytherProgram, " and it cannot be used as a Scyther executable."
sys.exit()
def cacheoverride ():
global RetrieveFromCache
RetrieveFromCache = False
#----------------------------------------------------------------------------
# How to call Scyther
#----------------------------------------------------------------------------
@ -138,7 +144,7 @@ def evaluate (argumentstring, inputstring):
# Determine the unique filename for this test
cachefile = cachefilename(cacheid())
if os.path.exists(cachefile):
if os.path.exists(cachefile) and RetrieveFromCache:
return retrieve_from_cache(cachefile)
else:
return compute_and_cache(cachefile)

View File

@ -6,7 +6,7 @@
#
import sys
from optparse import OptionParser
from scythercache import evaluate, scytheroverride
from scythercache import evaluate, scytheroverride, cacheoverride
#----------------------------------------------------------------------------
@ -151,6 +151,10 @@ def default_options(parser):
parser.add_option("-P","--program", dest="program",
default = "",
help = "define alternative scyther executable")
parser.add_option("-N","--no-cache", dest="nocache",
default = False,
action = "store_true",
help = "do not use cache mechanism")
# Process the default options
def process_default_options(options):
@ -160,7 +164,10 @@ def process_default_options(options):
if options.extra != "":
add_extra_parameters(options.extra)
print "Added extra options, now:", get_extra_parameters(options.extra)
if options.nocache:
# Do not use cache
print "Warning: Disabling cache"
cacheoverride ()
#----------------------------------------------------------------------------
@ -261,15 +268,15 @@ def main():
parser = OptionParser()
default_options(parser)
parser.add_option("-e","--errors", dest="errors",
default = "False",
default = False,
action = "store_true",
help = "detect compilation errors for all protocols [in list_all]")
parser.add_option("-r","--results", dest="results",
default = "False",
default = False,
action = "store_true",
help = "scan for results for all protocols [in list_all]")
parser.add_option("-t","--timeouts", dest="timeouts",
default = "False",
default = False,
action = "store_true",
help = "scan for timeout errors for all protocols [in list_all]")
(options, args) = parser.parse_args()
@ -278,11 +285,11 @@ def main():
process_default_options(options)
# Subcases
if options.errors != "False":
if options.errors:
scan_for_errors(options,args)
elif options.results != "False":
elif options.results:
scan_for_results(options,args)
elif options.timeouts != "False":
elif options.timeouts:
scan_for_timeouts(options,args)
else:
# Not any other switch: just test the list then