Commit 49ca2a58 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

wta: Add ability to bisect transition count

parent aca7bf3a
......@@ -258,6 +258,60 @@ def bisect_states(args):
print("First bad state count: %d" % bad)
def test_trans(args, transitions):
print("Trying %d..." % transitions)
args.transitions = str(transitions)
generate(args)
for i in range(0, samples):
try:
run_one_simple(args, i)
except subprocess.CalledProcessError:
return False
return True
def find_bad_trans(args, good):
transitions = good*2
if test_trans(args, transitions):
return find_bad(args, transitions)
else:
return (good, transitions)
def bisect_trans(args):
# Hacks and hacks and hacks
args.zero_frequency = None
args.out_degree = None
transitions = args.start_transitions
good = args.good or 0
bad = args.bad
if bad is None:
if good and transitions < good:
transitions = good+1
if test_trans(args, transitions):
(good, bad) = find_bad_trans(args, transitions)
else:
bad = transitions
while good+1 < bad:
transitions = good + (bad-good)//2
if test_trans(args, transitions):
good = transitions
else:
bad = transitions
print("First bad transition count: %d" % bad)
def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(required=True)
......@@ -304,6 +358,18 @@ def main():
bisect_parser.set_defaults(func=bisect_states)
bisect_trans_parser = subparsers.add_parser('bisect-trans')
bisect_trans_parser.add_argument('generator')
bisect_trans_parser.add_argument('copar')
bisect_trans_parser.add_argument('--monoid', required=True)
bisect_trans_parser.add_argument('--symbols', required=True)
bisect_trans_parser.add_argument('--different-values')
bisect_trans_parser.add_argument('--states', required=True)
bisect_trans_parser.add_argument('--start-transitions', type=int, default=100)
bisect_trans_parser.add_argument('--good', type=int)
bisect_trans_parser.add_argument('--bad', type=int)
bisect_trans_parser.set_defaults(func=bisect_trans)
args = parser.parse_args()
args.func(args)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment