-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpgel_sat.py
41 lines (29 loc) · 974 Bytes
/
pgel_sat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys
from pgel_sat import ProbabilisticKnowledgeBase, solve
import argparse
def str_lp(lp):
return f'''lp solution:
x: {lp.x}
y: {lp.y}
cost: {lp.cost}'''
def main():
parser = init_argparse()
args = parser.parse_args()
filename = args.file[0]
kb = ProbabilisticKnowledgeBase.from_file(filename)
result = solve(kb)
print('is satisfiable:', result['satisfiable'])
print(str_lp(result['lp']))
def init_argparse():
parser = argparse.ArgumentParser(
description='Computes the Probabilistic SAT algorithm' \
'in a Probabilistic Graphic EL knowledge base.'
)
parser.add_argument(
'file', nargs=1, type=str,
help='path of the OWL file with the Probabilistic Graphic EL ontology')
parser.add_argument('-v', '--verbose', action='store_true',
help='prints the problem and solution')
return parser
if __name__ == '__main__':
main()