From 96825e484149a44d17e2f2330c8fe2ee4563259c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 13 Aug 2015 11:04:31 +0200 Subject: Implement random generation of configurations Configuration are generated with random assumptions. This should generate different configuration for every SAT solver execution. --- scripts/configurations.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/configurations.py b/scripts/configurations.py index 097f501..0b73a53 100644 --- a/scripts/configurations.py +++ b/scripts/configurations.py @@ -149,13 +149,14 @@ def __register_conf__(con, conf_num, generator): if os.path.isfile(filen): if compare(filen, wfile): print("I: Generated existing configuration.") - return + return False else: print("W: Generated configuration with collision hash.") # TODO this might have to be tweaked raise Exception() shutil.move(wfile, filen) dtb.add_configuration(hsh, hshf, generator) + return True def __generate_single__(var_num, conf_num): measure_list = set() @@ -184,15 +185,15 @@ def __generate_single__(var_num, conf_num): return True def __generate_random__(var_num, conf_num): - # TODO - #tfile = __buildtempcnf__(var_num, (sf(conf.rules_file), sf(conf.fixed_file)), ()) - #try: - #confs = __exec_sat__(tfile, []) - #for con in confs: - #__register_conf__(con, conf_num) - #finally: - #os.remove(tfile) - return False + tfile = __buildtempcnf__(var_num, (sf(conf.rules_file), sf(conf.fixed_file)), ()) + try: + confs = __exec_sat__(tfile, ['-i', '3']) + for con in confs: + if not __register_conf__(con, conf_num, 'random-sat'): + __generate_random__(var_num, conf_num) + finally: + os.remove(tfile) + return True def generate(): """Collect boolean equations from files rules and required -- cgit v1.2.3