Skip to content

Commit 0e93ebf

Browse files
committed
add reasoning test
1 parent 01a5247 commit 0e93ebf

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

mln/alarm.db

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
livesIn(James,Yorkshire)
2+
livesIn(Stefan,Freiburg)
3+
burglary(James)
4+
tornado(Freiburg)
5+
neighborhood(James,Average)
6+
neighborhood(Stefan,Bad)

mln/alarm.mln

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// domain declarations
2+
domNeighborhood = {Good, Bad, Average}
3+
person = {James,Stefan}
4+
place = {Freiburg,Yorkshire,Austin}
5+
6+
7+
8+
// predicate declarations
9+
alarm(person)
10+
burglary(person)
11+
livesIn(person,place!)
12+
neighborhood(person,domNeighborhood!)
13+
tornado(place)
14+
15+
// formulas
16+
2.200000 burglary(x) => alarm(x)
17+
2.200000 (livesIn(x,y) ^ tornado(y)) => alarm(x)
18+
0.400000 neighborhood(x,Bad) => burglary(x)
19+
-0.400000 neighborhood(x,Average) => burglary(x)
20+
-0.800000 neighborhood(x,Good) => burglary(x)

mln/demo_pracmln.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,12 @@ def test_db():
3333
db.write()
3434
return (mln, db)
3535

36+
def test_reasoning():
37+
mln = MLN.load(files='./mln/alarm.mln')
38+
db = Database.load(mln, './mln/alarm.db')
39+
result = MLNQuery(mln=mln, db=db).run()
40+
result.write()
41+
3642
if __name__ == "__main__":
37-
test_db()
43+
test_db()
44+
test_reasoning()

0 commit comments

Comments
 (0)