- Added some new heuristics testing.

This commit is contained in:
ccremers 2006-02-23 09:39:02 +00:00
parent 8f896432d1
commit 0a74c87934

View File

@ -48,7 +48,7 @@ def parse(scout):
return (ra,rb,rp,nc,st)
def test_goal_selector(goalselector, options):
def test_goal_selector(goalselector, options,branchbound):
"""Test with a given goal selector
in:
@ -86,6 +86,9 @@ def test_goal_selector(goalselector, options):
claims = claims + nc
states = states + st
if (bounds * states) > branchbound:
return (-1,0,0,0,0,0)
return (attacks,bounds,proofs,claims,np,states)
# Max
@ -106,8 +109,15 @@ class maxor:
self.dir = dir
self.min = mymin
self.max = mymax
if dir & 1:
self.data = mymax
else:
self.data = mymin
def reg(self,data):
def get(self):
return self.data
def reg(self,d):
"""Store a new data element
in:
@ -117,20 +127,22 @@ class maxor:
notifications according to initial settings.
"""
self.data = d
res = ""
if self.min >= data:
self.min = data
if self.min >= d:
if (self.dir & 2):
res = res + "-"
if self.max <= data:
self.max = data
self.min = d
if self.max <= d:
if (self.dir & 1):
res = res + "+"
self.max = d
if res == "":
return res
else:
return "[" + res + "]"
# Main code
def main():
parser = OptionParser()
@ -150,27 +162,31 @@ def main():
boundstatesmax = maxor(2)
for g in range(1,63):
if (g & 8) == 0 and (g & 4) == 0 :
(ra,rb,rp,nc,np,st) = test_goal_selector(g, options)
# Scores: bounds are negative
score1 = ra + rp - rb
score2 = ra + (3 * rp) - (2 * rb)
boundstates = rb * st
(ra,rb,rp,nc,np,st) = test_goal_selector(g, options,
boundstatesmax.get())
res = str(g)
if ra < 0:
# Error: not well bounded
res += "\tWent over bound, stopped investigation."
else:
# Scores: bounds are negative
score1 = ra + rp - rb
score2 = ra + (3 * rp) - (2 * rb)
boundstates = rb * st
def shows (res, mx, data):
return res + "\t" + str(data) + mx.reg(data)
res = shows (res, ramax, ra)
res = shows (res, rbmax, rb)
res = shows (res, rpmax, rp)
res = res + "\t" + str(nc)
res = shows (res, score1max, score1)
res = shows (res, score2max, score2)
res = shows (res, statesmax, st)
res = shows (res, boundstatesmax, boundstates)
def shows (res, mx, data):
return res + "\t" + str(data) + mx.reg(data)
res = shows (res, ramax, ra)
res = shows (res, rbmax, rb)
res = shows (res, rpmax, rp)
res = res + "\t" + str(nc)
res = shows (res, score1max, score1)
res = shows (res, score2max, score2)
res = shows (res, statesmax, st)
res = shows (res, boundstatesmax, boundstates)
print res
print