Skip to content

Commit 22974df

Browse files
committed
some cleanup
1 parent 6c4f447 commit 22974df

2 files changed

Lines changed: 49 additions & 48 deletions

File tree

.github/workflows/build.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ jobs:
4040
cd scripts
4141
python run_hashcount_on_itemmining.py -i vote.cnf
4242
43+
- name: Sample ProjEnum Run
44+
run: |
45+
cd scripts
46+
python run_projenum_on_itemmining.py -i vote.cnf
47+
4348
- name: Sample ProjEnum Run
4449
run: |
4550
cd scripts
@@ -48,4 +53,9 @@ jobs:
4853
- name: Sample MinLB Run
4954
run: |
5055
cd scripts
51-
python run_minlb_on_modelcounting.py -i mccmc2021_track1_058.cnf
56+
python run_minlb_on_modelcounting.py -i mccmc2021_track1_058.cnf
57+
58+
- name: Sample MinLB Run
59+
run: |
60+
cd scripts
61+
python run_minlb_on_itemmining.py -i vote.cnf

scripts/compute_dlp.py

Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,11 @@ def compute_disjunctive_program(file_name):
6666
output_file_pointer.close()
6767

6868
file_name = args.i
69-
# first we are computing the cautious reasoning
70-
output_file = "lp_" + file_name
71-
# doing the preprocessing first
72-
# using the cautious reasoning computed from wasp
7369
# do preprocessing
7470
compute_disjunctive_program(file_name)
7571
preprocess = True
7672
original_set_var = None
7773
original_set_clause = None
78-
cautious = False # set to True to turn on cautious reasoning
7974
if preprocess:
8075
file_pointer = open(file_name, 'r')
8176
for line in file_pointer:
@@ -95,14 +90,10 @@ def compute_disjunctive_program(file_name):
9590
# check whether the preprocessing failed or not
9691
final_input_filename = "prep_" + file_name
9792
file_pointer = open(final_input_filename, 'r')
98-
output_file_pointer = open(output_file, 'w')
93+
# output_file_pointer = open(output_file, 'w')
9994
# grph = nx.Graph()
100-
varset = set()
95+
# varset = set()
10196
minimal_file_pointer = open("minimal_" + file_name , 'w')
102-
o_line = "o "
103-
for _ in range(1, original_set_var + 1):
104-
o_line = o_line + (str(_) + " ")
105-
o_line = o_line + ("0")
10697
for line in file_pointer:
10798
if line.startswith("c"):
10899
if line.startswith("c Number of clauses:"):
@@ -111,56 +102,56 @@ def compute_disjunctive_program(file_name):
111102
continue
112103
elif line.startswith("p cnf"):
113104
l = line.split()
114-
output_file_pointer.write("%rule size: {0}\n".format(int(l[-1])))
105+
# output_file_pointer.write("%rule size: {0}\n".format(int(l[-1])))
115106
minimal_file_pointer.write(line)
116107
minimal_file_pointer.write("c opt {0}\n".format(original_set_var))
117108
print("The number of literals: {0} and clauses: {1}".format(l[-2], l[-1]))
118109
else:
119-
l = line.split()
110+
# l = line.split()
120111
minimal_file_pointer.write(line)
121-
lit_list = []
122-
for lit in l:
123-
var = int(lit)
124-
if var != 0:
125-
lit_list.append(var)
112+
# lit_list = []
113+
# for lit in l:
114+
# var = int(lit)
115+
# if var != 0:
116+
# lit_list.append(var)
126117

127-
rule_string = ""
128-
rule_str = ":- "
129-
node_lit = []
130-
for index, lit in enumerate(lit_list):
131-
if lit < 0:
132-
if abs(lit) <= original_set_var:
133-
rule_str = rule_str + " v({0}),".format(abs(lit))
134-
else:
135-
rule_str = rule_str + " a({0}),".format(abs(lit))
136-
else:
137-
if abs(lit) not in varset:
138-
varset.add(abs(lit))
139-
if abs(lit) <= original_set_var:
140-
rule_str = rule_str + " not v({0}),".format(abs(lit))
141-
else:
142-
rule_str = rule_str + " not a({0}),".format(abs(lit))
118+
# rule_str = ":- "
119+
# node_lit = []
120+
# for index, lit in enumerate(lit_list):
121+
# if lit < 0:
122+
# if abs(lit) <= original_set_var:
123+
# rule_str = rule_str + " v({0}),".format(abs(lit))
124+
# else:
125+
# rule_str = rule_str + " a({0}),".format(abs(lit))
126+
# else:
127+
# if abs(lit) not in varset:
128+
# varset.add(abs(lit))
129+
# if abs(lit) <= original_set_var:
130+
# rule_str = rule_str + " not v({0}),".format(abs(lit))
131+
# else:
132+
# rule_str = rule_str + " not a({0}),".format(abs(lit))
143133

144-
rule_str = rule_str[:-1] + "." # end of rule
134+
# rule_str = rule_str[:-1] + "." # end of rule
145135

146136

147137
# writing the rule
148-
output_file_pointer.write(rule_str + "\n")
138+
# output_file_pointer.write(rule_str + "\n")
149139

140+
os.remove("prep_" + file_name)
150141
# writing choice rules
151-
rule_str = "{"
152-
for index, atom in enumerate(list(varset)):
153-
if atom <= original_set_var:
154-
rule_str = rule_str + " v({0}) ;".format(atom)
155-
else:
156-
rule_str = rule_str + " a({0}) ;".format(atom)
142+
# rule_str = "{"
143+
# for index, atom in enumerate(list(varset)):
144+
# if atom <= original_set_var:
145+
# rule_str = rule_str + " v({0}) ;".format(atom)
146+
# else:
147+
# rule_str = rule_str + " a({0}) ;".format(atom)
157148

158-
rule_str = rule_str[:-1] + "}." # end of rule
159-
output_file_pointer.write(rule_str + "\n")
160-
output_file_pointer.write("#heuristic v(X). [1, false]" + "\n")
161-
output_file_pointer.write("#show v/1. \n")
149+
# rule_str = rule_str[:-1] + "}." # end of rule
150+
# output_file_pointer.write(rule_str + "\n")
151+
# output_file_pointer.write("#heuristic v(X). [1, false]" + "\n")
152+
# output_file_pointer.write("#show v/1. \n")
162153

163154
file_pointer.close()
164155
minimal_file_pointer.close()
165-
output_file_pointer.close()
156+
# output_file_pointer.close()
166157

0 commit comments

Comments
 (0)