22import subprocess as sp
33parser = argparse .ArgumentParser ()
44parser .add_argument ('-i' ,'--i' , help = 'input CNF file' , required = True )
5+ parser .add_argument ('-thresh' ,'--thresh' , help = 'threshold cut size' , default = 25 , required = False )
56args = parser .parse_args ()
67file_name = args .i
78
@@ -26,6 +27,9 @@ def run(cmd, timeout, ttl = 3, silent = False):
2627 os .system ("cp {0} {1}" .format (args .i , temp_file ))
2728 input_file = os .path .basename (temp_file )
2829
30+ if os .path .exists (f"IS_dlp_{ input_file } " ):
31+ os .remove (f"IS_dlp_{ input_file } " )
32+
2933cmd = 'python compute_dlp.py -i {0}' .format (input_file )
3034out = run (cmd , 100 )
3135# print(" === Computing a cut === ")
@@ -36,7 +40,7 @@ def run(cmd, timeout, ttl = 3, silent = False):
3640# out = run(cmd, 100)
3741
3842cut_size = None
39- threshold = 50
43+ threshold = int ( args . thresh )
4044cut_string = ""
4145for line in out .splitlines ():
4246 if line .startswith ("c the size of cut:" ):
@@ -70,12 +74,13 @@ def run(cmd, timeout, ttl = 3, silent = False):
7074 if cnt is None :
7175 print ("No estimate found in the projenum." )
7276
73- os .system (f'rm -f { input_file } cut_{ input_file } minimal_{ input_file } ' )
77+ os .system (f'rm -f { input_file } cut_{ input_file } dlp_ { input_file } minimal_{ input_file } ' )
7478else :
75- # we can run Hashcount
76- # print(" === Computing independent suport === ")
77- cmd = 'python compute_independent_support.py -i dlp_{0}' .format (input_file )
78- out = run (cmd , 250 )
79+ # we run Hashcount
80+ if not os .path .exists (f"IS_dlp_{ input_file } " ):
81+ # print(" === Computing independent suport === ")
82+ cmd = 'python compute_independent_support.py -i dlp_{0}' .format (input_file )
83+ out = run (cmd , 250 )
7984 # print(" === Running HashCount === ")
8085 cmd = './hashcount --useind IS_dlp_{0} --asp dlp_{0}' .format (input_file )
8186 out = run (cmd , 5000 )
@@ -90,4 +95,4 @@ def run(cmd, timeout, ttl = 3, silent = False):
9095 if cnt is None :
9196 print ("No estimate found in the hashcount." )
9297
93- os .system (f'rm -f { input_file } dlp_{ input_file } IS_dlp_{ input_file } ' )
98+ os .system (f'rm -f { input_file } dlp_{ input_file } IS_dlp_{ input_file } minimal_ { input_file } { new_input_file } ' )
0 commit comments