make EM work with PFL and BP.

This commit is contained in:
Costa Vitor
2012-08-15 16:01:45 -05:00
parent 020692635b
commit a76f4f34d5
8 changed files with 170 additions and 85 deletions

View File

@@ -16,20 +16,21 @@
% with \phi defined by abi_table(X) and whose domain and constraints
% is obtained from professor/1.
%
bayes abi(K)::[h,m,l] ; abi_table ; [professor(K)].
bayes pop(K)::[h,m,l], abi(K) ; pop_table ; [professor(K)].
bayes grade(C,S)::[a,b,c,d], int(S), diff(C) ; grade_table ; [registration(_,C,S)].
bayes sat(C,S,P)::[h,m,l], abi(P), grade(C,S) ; sat_table ; [reg_sat(C,S,P)].
bayes rat(C) :: [h,m,l], avg(Sats) ; avg ; [course_rating(C, Sats)].
bayes diff(C) :: [h,m,l] ; diff_table ; [course(C,_)].
bayes int(S) :: [h,m,l] ; int_table ; [student(S)].
bayes grade(C,S)::[a,b,c,d], int(S), diff(C) ; grade_table ; [registration(_,C,S)].
bayes satisfaction(C,S)::[h,m,l], abi(P), grade(C,S) ; sat_table ; [reg_satisfaction(C,S,P)].
bayes rat(C) :: [h,m,l], avg(Sats) ; avg ; [course_rating(C, Sats)].
bayes rank(S) :: [a,b,c,d], avg(Grades) ; avg ; [student_ranking(S,Grades)].
@@ -37,14 +38,14 @@ grade(Key, Grade) :-
registration(Key, CKey, SKey),
grade(CKey, SKey, Grade).
reg_sat(CKey, SKey, PKey) :-
reg_satisfaction(CKey, SKey, PKey) :-
registration(_Key, CKey, SKey),
course(CKey, PKey).
course_rating(CKey, Sats) :-
course(CKey, _),
setof(sat(CKey,SKey,PKey),
reg_sat(CKey, SKey, PKey),
setof(satisfaction(CKey,SKey,PKey),
reg_satisfaction(CKey, SKey, PKey),
Sats).
student_ranking(SKey, Grades) :-
@@ -53,13 +54,31 @@ student_ranking(SKey, Grades) :-
:- ensure_loaded(tables).
% convert to longer names
professor_ability(P,A) :- abi(P, A).
professor_popularity(P,A) :- pop(P, A).
registration_grade(R,A) :-
registration(R,C,S),
grade(C,S,A).
registration_satisfaction(R,A) :-
registration(R,C,S),
satisfaction(C,S,A).
student_intelligence(P,A) :- int(P, A).
course_difficulty(P,A) :- diff(P, A).
%
% evidence
%
abi(p0, h).
%abi(p0, h).
pop(p1, m).
pop(p2, h).
%pop(p1, m).
%pop(p2, h).
% Query
% ?- abi(p0, X).

View File

@@ -7,7 +7,7 @@ total_students(256).
*/
:- use_module(library(clpbn)).
:- use_module(library(pfl)).
:- source.
@@ -17,7 +17,7 @@ total_students(256).
:- yap_flag(write_strings,on).
:- ensure_loaded(schema).
:- ensure_loaded(parschema).
:- ensure_loaded(school32_data).

View File

@@ -12,16 +12,17 @@ abi_table([0.3,0.3,0.4]).
pop_table([0.3,0.3,0.4,0.3,0.3,0.4,0.3,0.3,0.4]).
goal_list([abi(p0,h),
goal_list([/*abi(p0,h),
abi(p1,m),
abi(p2,m),
abi(p3,m),
abi(p3,m),*/
abi(p4,l),
pop(p5,h),
abi(p5,_),
abi(p6,_),
pop(p7,_)]).
professor(p0).
professor(p1).
professor(p2).
professor(p3).