]> rtime.felk.cvut.cz Git - linux-conf-perf.git/commitdiff
Implement random generation of configurations
authorKarel Kočí <cynerd@email.cz>
Thu, 13 Aug 2015 09:04:31 +0000 (11:04 +0200)
committerKarel Kočí <cynerd@email.cz>
Thu, 13 Aug 2015 09:08:00 +0000 (11:08 +0200)
Configuration are generated with random assumptions. This should
generate different configuration for every SAT solver execution.

scripts/configurations.py

index 097f501169fb2d6b8d12ae59c77a40feb9fc5ec5..0b73a5343a0a44f8090b205d459541930b0a53bb 100644 (file)
@@ -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