city example.
This commit is contained in:
parent
49b3f4e7b6
commit
21050891ee
25
packages/CLPBN/examples/City/db_128.yap
Normal file
25
packages/CLPBN/examples/City/db_128.yap
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
%conservative_city(nyc, t).
|
||||
|
||||
hair_color(joe, t).
|
||||
|
||||
car_color(joe, t).
|
||||
|
||||
shoe_size(joe, f).
|
||||
|
||||
/* Steps:
|
||||
|
||||
1. generate N facts lives(I, nyc), 0 <= I < N.
|
||||
|
||||
2. generate evidence on descn for N people, *** except for 1 ***
|
||||
|
||||
3. Run query ?- guilty(joe, Guilty), witness(joe, t), descn(2,t), descn(3, f), descn(4, f).
|
||||
|
||||
query(Guilty) :-
|
||||
guilty(joe, Guilty),
|
||||
witness(joe, t),
|
||||
descn(2,t),
|
||||
descn(3,f),
|
||||
descn(4,f), ....
|
||||
|
||||
*/
|
60
packages/CLPBN/examples/City/schema.yap
Normal file
60
packages/CLPBN/examples/City/schema.yap
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
/* base file for school database. Supposed to be called from school_*.yap */
|
||||
|
||||
conservative_city(City, Cons) :-
|
||||
cons_table(City, ConsDist),
|
||||
{ Cons = cons(City) with p([y,n], ConsDist) }.
|
||||
|
||||
gender(X, Gender) :-
|
||||
gender_table(City, GenderDist),
|
||||
{ Gender = gender(City) with p([m,f], GenderDist) }.
|
||||
|
||||
hair_color(X, Color) :-
|
||||
lives(X, City),
|
||||
conservative_city(City, Cons),
|
||||
gender(X, Gender),
|
||||
color_table(X,ColorTable),
|
||||
{ Color = color(X) with
|
||||
p([t,f], ColorTable,[Gender,Cons]) }.
|
||||
|
||||
car_color(X, Color) :-
|
||||
hair_color(City, HColor),
|
||||
ccolor_table(X,CColorTable),
|
||||
{ Color = ccolor(X) with
|
||||
p([t,f], CColorTable,[HColor]) }.
|
||||
|
||||
height(X, Height) :-
|
||||
gender(X, Gender),
|
||||
height_table(X,HeightTable),
|
||||
{ Height = height(X) with
|
||||
p([t,f], HeightTable,[Gender]) }.
|
||||
|
||||
shoe_size(X, Shoesize) :-
|
||||
height(X, Height),
|
||||
shoe_size_table(X,ShoesizeTable),
|
||||
{ Shoesize = shoe_size(X) with
|
||||
p([t,f], ShoesizeTable,[Height]) }.
|
||||
|
||||
guilty(X, Guilt) :-
|
||||
guilt_table(X, GuiltDist),
|
||||
{ Guilt = guilt(X) with p([y,n], GuiltDist) }.
|
||||
|
||||
|
||||
descn(X, Descn) :-
|
||||
car_color(X, Car),
|
||||
hair_color(X, Hair),
|
||||
height(X, Height),
|
||||
guilty(X, Guilt),
|
||||
descn_table(X, DescTable),
|
||||
{ Descn = descn(X) with
|
||||
p([t,f], DescTable,[Car,Hair,Height,Guilt]) }.
|
||||
|
||||
witness(City, Witness) :-
|
||||
descn(joe, DescnJ),
|
||||
descn(1, Descn1),
|
||||
wit_table(WitTable),
|
||||
{ Witness = wit(City) with
|
||||
p([t,f], WitTable,[DescnJ, Descn1]) }.
|
||||
|
||||
|
||||
|
35
packages/CLPBN/examples/City/tables.yap
Normal file
35
packages/CLPBN/examples/City/tables.yap
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
cons_table(amsterdam,[0.2,
|
||||
0.8]) :- !.
|
||||
cons_table(_, [0.8,
|
||||
0.2]).
|
||||
|
||||
color_table(_,
|
||||
/* tm tf fm ff */
|
||||
[ 0.05, 0.1, 0.3, 0.5 ,
|
||||
0.95, 0.9, 0.7, 0.5 ]).
|
||||
|
||||
ccolor_table(_,
|
||||
/* t f */
|
||||
[ 0.9, 0.2 ,
|
||||
0.1, 0.8 ]).
|
||||
|
||||
height_table(_,
|
||||
/* m f */
|
||||
[ 0.6, 0.4 ,
|
||||
0.4, 0.6 ]).
|
||||
|
||||
shoe_size_table(_,
|
||||
/* t f */
|
||||
[ 0.9, 0.1 ,
|
||||
0.1, 0.9 ]).
|
||||
|
||||
A: professor's ability;
|
||||
B: student's grade (for course registration).
|
||||
*/
|
||||
descn_table(_,
|
||||
/* color, hair, height, guilt */
|
||||
/* ttttt tttf ttft ttff tfttt tftf tfft tfff ttttt fttf ftft ftff ffttt fftf ffft ffff */
|
||||
/*t*/ [0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99, 0.99,
|
||||
/*f*/ 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01 ]).
|
||||
|
Reference in New Issue
Block a user