import os
import exp_module.build as bld
import exp_module.statistics as stats
import exp_module.io as io

files = ["../datasets/mod_instance5_0.75-1050"]

for i in range(len(files)):
    io.init_exp()
    try:
        for filename in os.listdir(files[i]):
            file_path = files[i] + "/" + filename
            if (file_path[-3:] == "cnf"):
                (G, n, m, c, Q, s) = bld.make_graph_from_levy_file(file_path)
                data = stats.check_graph(G, file_path, n, m, c, Q, s)
                io.write_output(data)
                io.print_stats(data)
    except KeyboardInterrupt:
        import sys
        io.close_exp()
        sys.exit()
    io.close_exp()


            
import os
import exp_module.build as bld
import exp_module.statistics as stats
import exp_module.io as io

files = ["easy_synth"]

for i in range(len(files)):
    io.init_exp()
    try:
        for filename in os.listdir(files[i]):
            file_path = files[i] + "/" + filename
            (G, n, m) = bld.make_graph_from_file(file_path)
            data = stats.check_graph(G, file_path, n, m, None, None, None)
            io.write_output(data)
            io.print_stats(data)
    except KeyboardInterrupt:
        import sys
        io.close_exp()
        sys.exit()
    io.close_exp()


            
import os
import exp_module.build as bld
import exp_module.statistics as stats
import exp_module.io as io

files = ["easy_synth"]

for i in range(len(files)):
    io.init_exp()
    try:
        for filename in os.listdir(files[i]):
            file_path = files[i] + "/" + filename
            (G, n, m) = bld.make_graph_from_file(file_path)
            data = stats.check_graph(G, filename, n, m, None, None)
            io.write_output(data)
            io.print_stats(data)
    except KeyboardInterrupt:
        import sys
        io.close_exp()
        sys.exit()
    io.close_exp()


            
#desired approximate Q-value
APPROX_Q = 0.95

#----------------------------------------------------------------------------#
#                                                                            #
#    Main Functions                                                          #
#                                                                            #
#----------------------------------------------------------------------------#

io.init_exp()
try:
    for vrs in range(*VARS_DATA):
        clas = int(vrs * CTV_RATIO)
        for i in range(NUM_PER_ITER):
            (G, CNF) = bld.make_graph(vrs, clas, 1, 0)
            rand = stats.check_graph(G, CNF, vrs, clas, 1, 0)
            io.write_output(rand)
            io.print_stats(rand)
except KeyboardInterrupt:
    import sys
    io.close_exp()
    sys.exit()
io.close_exp()

for grp in range(*GRP_DATA):
    io.init_exp()
    try:
        for vrs1 in range(*VARS_DATA):
            vrs = vrs1 * grp
            clas = int(vrs * CTV_RATIO)
            for i in range(NUM_PER_ITER):