CLP(BN) is dead. Long live the PFL

This commit is contained in:
Tiago Gomes 2012-12-13 17:04:14 +00:00
parent d78baa48a1
commit 6b8301d9c4
7 changed files with 10 additions and 126 deletions

View File

@ -77,10 +77,8 @@ CLPBN_LEARNING_PROGRAMS= \
CLPBN_SCHOOL_EXAMPLES= \
$(CLPBN_EXDIR)/School/README \
$(CLPBN_EXDIR)/School/evidence_128.yap \
$(CLPBN_EXDIR)/School/schema.yap \
$(CLPBN_EXDIR)/School/parschema.pfl \
$(CLPBN_EXDIR)/School/school_128.yap \
$(CLPBN_EXDIR)/School/school_32.yap \
$(CLPBN_EXDIR)/School/sch32.yap \
$(CLPBN_EXDIR)/School/school32_data.yap \
$(CLPBN_EXDIR)/School/school_64.yap \

View File

@ -5,14 +5,11 @@ There are four main files:
school_128.yap: a school with 128 professors, 256 courses and 4096 students.
school_64.yap: medium size school
school_32.yap: small school (CLP(BN))
sch32.yap: small school (PFL)
parschema.pfl: the PFL schema
schema.yap: the CLP(BN) schema
tables: CPTs
=============================================================================

View File

@ -1,68 +0,0 @@
/* Base file for school database. Supposed to be called from school_*.yap */
professor_key(Key) :-
professor(Key).
professor_ability(Key,Abi) :-
abi_table(Key, AbiDist),
{ Abi = ability(Key) with p([h,m,l], AbiDist) }.
professor_popularity(Key, Pop) :-
professor_ability(Key, Abi),
pop_table(Key,PopTable),
{ Pop = popularity(Key) with
p([h,m,l], PopTable,[Abi]) }.
registration_key(Key) :-
registration(Key, _, _).
registration_course(Key, CKey) :-
registration(Key, CKey, _).
registration_student(Key, SKey) :-
registration(Key, _, SKey).
registration_grade(Key, Grade) :-
registration(Key, CKey, SKey),
course_difficulty(CKey, Dif),
student_intelligence(SKey, Int),
grade_table(Int, Dif, Table),
{ Grade = grade(Key) with Table }.
% registration_satisfaction(r0, h) :- {}.
registration_satisfaction(Key, Sat) :-
registration_course(Key, CKey),
course_professor(CKey, PKey),
professor_ability(PKey, Abi),
registration_grade(Key, Grade),
satisfaction_table(Abi, Grade, Table),
{ Sat = satisfaction(Key) with Table }.
course_key(Key) :-
course(Key,_).
course_professor(Key, PKey) :-
course(Key, PKey).
course_rating(CKey, Rat) :-
setof(Sat, RKey^(registration_course(RKey,CKey), registration_satisfaction(RKey,Sat)), Sats),
{ Rat = rating(CKey) with avg([h,m,l],Sats) }.
course_difficulty(Key, Dif) :-
dif_table(Key, Dist),
{ Dif = difficulty(Key) with p([h,m,l], Dist) }.
student_key(Key) :-
student(Key).
student_intelligence(Key, Int) :-
int_table(Key, IDist, Domain),
{ Int = intelligence(Key) with p(Domain, IDist) }.
student_ranking(Key, Rank) :-
setof(Grade, CKey^(registration_student(CKey,Key),
registration_grade(CKey, Grade)), Grades),
{ Rank = ranking(Key) with avg([a,b,c,d],Grades) }.
:- ensure_loaded(tables).

View File

@ -7,6 +7,8 @@ total_students(4096).
*/
:- use_module(library(pfl)).
:- source.
:- style_check(all).
@ -15,9 +17,9 @@ total_students(4096).
:- yap_flag(write_strings,on).
:- use_module(library(clpbn)).
:- ensure_loaded('parschema.pfl').
:- [-schema].
:- set_solver(hve).
professor(p0).
professor(p1).

View File

@ -1,23 +0,0 @@
/*
total_professors(32).
total_courses(64).
total_students(256).
*/
:- source.
:- style_check(all).
:- yap_flag(unknown,error).
:- yap_flag(write_strings,on).
:- use_module(library(clpbn)).
:- [-schema].
:- ensure_loaded(school32_data).

View File

@ -7,6 +7,9 @@ total_students(1024).
*/
:- use_module(library(pfl)).
:- source.
:- style_check(all).
@ -15,9 +18,9 @@ total_students(1024).
:- yap_flag(write_strings,on).
:- use_module(library(clpbn)).
:- ensure_loaded('parschema.pfl').
:- [-schema].
:- set_solver(hve).
professor(p0).
professor(p1).

View File

@ -1,33 +1,26 @@
/* CTPs for school database. */
abi_table(
/* h */ [ 0.50,
/* m */ 0.40,
/* l */ 0.10 ]).
abi_table(_, T) :- abi_table(T).
pop_table(
/* h m l */
/* h */ [ 0.9, 0.2, 0.01,
/* m */ 0.09, 0.6, 0.09,
/* l */ 0.01, 0.2, 0.9 ]).
pop_table(_, T) :- pop_table(T).
diff_table(
/* h */ [ 0.25,
/* m */ 0.50,
/* l */ 0.25 ]).
dif_table(_, T) :- diff_table(T).
int_table(
/* h */ [ 0.5,
/* m */ 0.4,
/* l */ 0.1 ]).
int_table(_,T ,[h,m,l]) :- int_table(T).
grade_table(
/* h h h m h l m h m m m l l h l m l l */
/* a */ [ 0.2, 0.7, 0.85, 0.1, 0.2, 0.5, 0.01, 0.05, 0.1,
@ -35,27 +28,9 @@ grade_table(
/* c */ 0.15, 0.04, 0.02, 0.4, 0.15, 0.12, 0.5, 0.6, 0.4,
/* d */ 0.05, 0.01, 0.01, 0.2, 0.05, 0.03, 0.45, 0.2, 0.1 ]).
grade_table(I, D,
p([a,b,c,d], T, [I,D])) :- grade_table(T).
sat_table(
/* h a h b h c h d m a m b m c m d l a l b l c l d */
/* h */ [ 0.98, 0.9, 0.8 , 0.6, 0.9, 0.4, 0.2, 0.01, 0.5, 0.2, 0.01, 0.01,
/* m */ 0.01, 0.09, 0.15, 0.3, 0.05, 0.4, 0.3, 0.04, 0.35, 0.3, 0.09, 0.01,
/* l */ 0.01, 0.01, 0.05, 0.1, 0.05, 0.2, 0.5, 0.95, 0.15, 0.5, 0.9, 0.98 ]).
satisfaction_table(A, G, p([h,m,l], T, [A,G])) :- sat_table(T).
% The idea is quite simple:
% hs = h -> r = ( 0.9, 0.1, 0)
% hs = m -> r = ( 0.2, 0.6, 0.2)
% hs = l -> r = ( 0, 0.1, 0.9)
%
% add all and divide on the number of elements on the table!
%
rating_prob_table(
[ 0.9, 0.05, 0.01,
0.09, 0.9, 0.09,
0.01, 0.05, 0.9 ]).