update examples
This commit is contained in:
parent
d22b5a97fd
commit
dacf6b4e57
@ -1,37 +0,0 @@
|
|||||||
#!/home/tiago/bin/yap -L --
|
|
||||||
|
|
||||||
|
|
||||||
:- initialization(main).
|
|
||||||
|
|
||||||
|
|
||||||
main :-
|
|
||||||
unix(argv([H])),
|
|
||||||
generate_town(H).
|
|
||||||
|
|
||||||
|
|
||||||
generate_town(N) :-
|
|
||||||
atomic_concat(['city_', N, '.yap'], FileName),
|
|
||||||
open(FileName, 'write', S),
|
|
||||||
atom_number(N, N2),
|
|
||||||
generate_people(S, N2, 4),
|
|
||||||
write(S, '\n'),
|
|
||||||
generate_query(S, N2, 4),
|
|
||||||
write(S, '\n'),
|
|
||||||
close(S).
|
|
||||||
|
|
||||||
|
|
||||||
generate_people(S, N, Counting) :-
|
|
||||||
Counting > N, !.
|
|
||||||
generate_people(S, N, Counting) :-
|
|
||||||
format(S, 'people(p~w, nyc).~n', [Counting]),
|
|
||||||
Counting1 is Counting + 1,
|
|
||||||
generate_people(S, N, Counting1).
|
|
||||||
|
|
||||||
|
|
||||||
generate_query(S, N, Counting) :-
|
|
||||||
Counting > N, !.
|
|
||||||
generate_query(S, N, Counting) :- !,
|
|
||||||
format(S, 'ev(descn(p~w, t)).~n', [Counting]),
|
|
||||||
Counting1 is Counting + 1,
|
|
||||||
generate_query(S, N, Counting1).
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
|||||||
#!/home/tgomes/bin/yap -L --
|
|
||||||
|
|
||||||
|
|
||||||
:- initialization(main).
|
|
||||||
|
|
||||||
|
|
||||||
main :-
|
|
||||||
unix(argv([H])),
|
|
||||||
generate_town(H).
|
|
||||||
|
|
||||||
|
|
||||||
generate_town(N) :-
|
|
||||||
atomic_concat(['pop_', N, '.yap'], FileName),
|
|
||||||
open(FileName, 'write', S),
|
|
||||||
atom_number(N, N2),
|
|
||||||
generate_people(S, N2, 4),
|
|
||||||
write(S, '\n'),
|
|
||||||
close(S).
|
|
||||||
|
|
||||||
|
|
||||||
generate_people(S, N, Counting) :-
|
|
||||||
Counting > N, !.
|
|
||||||
generate_people(S, N, Counting) :-
|
|
||||||
format(S, 'people(p~w).~n', [Counting]),
|
|
||||||
Counting1 is Counting + 1,
|
|
||||||
generate_people(S, N, Counting1).
|
|
||||||
|
|
@ -2,19 +2,24 @@
|
|||||||
|
|
||||||
:- clpbn_horus:set_solver(fove).
|
:- clpbn_horus:set_solver(fove).
|
||||||
%:- clpbn_horus:set_solver(hve).
|
%:- clpbn_horus:set_solver(hve).
|
||||||
:- clpbn_horus:set_solver(bp).
|
%:- clpbn_horus:set_solver(bp).
|
||||||
%:- clpbn_horus:set_solver(cbp).
|
%:- clpbn_horus:set_solver(cbp).
|
||||||
|
|
||||||
|
:- multifile people/2.
|
||||||
|
:- multifile ev/1.
|
||||||
|
|
||||||
|
|
||||||
people(joe,nyc).
|
people(joe,nyc).
|
||||||
people(p2, nyc).
|
people(p2, nyc).
|
||||||
people(p3, nyc).
|
people(p3, nyc).
|
||||||
|
people(p4, nyc).
|
||||||
|
people(p5, nyc).
|
||||||
|
|
||||||
|
%ev(descn(p2, t)).
|
||||||
ev(descn(p2, t)).
|
|
||||||
ev(descn(p3, t)).
|
ev(descn(p3, t)).
|
||||||
|
ev(descn(p4, t)).
|
||||||
|
ev(descn(p5, t)).
|
||||||
|
|
||||||
% :- [city_7].
|
|
||||||
|
|
||||||
bayes city_conservativeness(C)::[y,n] ; cons_table(C) ; [people(_,C)].
|
bayes city_conservativeness(C)::[y,n] ; cons_table(C) ; [people(_,C)].
|
||||||
|
|
||||||
@ -34,12 +39,12 @@ bayes descn(P)::[t,f], car_color(P), hair_color(P), height(P), guilty(P) ; descn
|
|||||||
|
|
||||||
bayes witness(C)::[t,f], descn(Joe), descn(P2) ; wit_table ; [people(_,C), Joe=joe, P2=p2].
|
bayes witness(C)::[t,f], descn(Joe), descn(P2) ; wit_table ; [people(_,C), Joe=joe, P2=p2].
|
||||||
|
|
||||||
|
% FIXME
|
||||||
cons_table(amsterdam, [0.2, 0.8]) :- !.
|
%cons_table(amsterdam, [0.2, 0.8]) :- !.
|
||||||
cons_table(_, [0.8, 0.2]).
|
cons_table(_, [0.8, 0.2]).
|
||||||
|
|
||||||
|
|
||||||
gender_table(_, [0.55, 0.44]).
|
gender_table(_, [0.55, 0.45]).
|
||||||
|
|
||||||
|
|
||||||
hair_color_table(_,
|
hair_color_table(_,
|
||||||
@ -73,8 +78,8 @@ guilty_table(_, [0.23, 0.77]).
|
|||||||
descn_table(_,
|
descn_table(_,
|
||||||
/* color, hair, height, guilt */
|
/* color, hair, height, guilt */
|
||||||
/* ttttt tttf ttft ttff tfttt tftf tfft tfff ttttt fttf ftft ftff ffttt fftf ffft ffff */
|
/* ttttt tttf ttft ttff tfttt tftf tfft tfff ttttt fttf ftft ftff ffttt fftf ffft ffff */
|
||||||
[ 0.99, 0.5, 0.23, 0.88, 0.41, 0.3, 0.76, 0.87, 0.44, 0.43, 0.29, 0.72, 0.33, 0.91, 0.95, 0.92,
|
[ 0.99, 0.5, 0.23, 0.88, 0.41, 0.3, 0.76, 0.87, 0.44, 0.43, 0.29, 0.72, 0.23, 0.91, 0.95, 0.92,
|
||||||
0.01, 0.5, 0.77, 0.12, 0.59, 0.7, 0.24, 0.13, 0.56, 0.57, 0.61, 0.28, 0.77, 0.09, 0.05, 0.08]).
|
0.01, 0.5, 0.77, 0.12, 0.59, 0.7, 0.24, 0.13, 0.56, 0.57, 0.71, 0.28, 0.77, 0.09, 0.05, 0.08]).
|
||||||
|
|
||||||
|
|
||||||
wit_table([0.2, 0.45, 0.24, 0.34,
|
wit_table([0.2, 0.45, 0.24, 0.34,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
friends(P1, P2) :-
|
friends(P1, P2) :-
|
||||||
people(P1),
|
people(P1),
|
||||||
people(P2),
|
people(P2),
|
||||||
P1 \= P2.
|
P1 @< P2.
|
||||||
|
|
||||||
people @ 3.
|
people @ 3.
|
||||||
|
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
:- use_module(library(pfl)).
|
:- use_module(library(pfl)).
|
||||||
|
|
||||||
%:- clpbn_horus:set_solver(fove).
|
:- clpbn_horus:set_solver(fove).
|
||||||
%:- clpbn_horus:set_solver(hve).
|
%:- clpbn_horus:set_solver(hve).
|
||||||
:- clpbn_horus:set_solver(bp).
|
%:- clpbn_horus:set_solver(bp).
|
||||||
%:- clpbn_horus:set_solver(cbp).
|
%:- clpbn_horus:set_solver(cbp).
|
||||||
|
|
||||||
:- yap_flag(write_strings, off).
|
:- yap_flag(write_strings, off).
|
||||||
|
|
||||||
people @ 3.
|
people @ 5.
|
||||||
|
|
||||||
markov attends(P)::[t,f], attr1::[t,f] ; [0.11, 0.2, 0.3, 0.4] ; [people(P)].
|
markov attends(P)::[t,f], attr1::[t,f] ; [0.7, 0.3, 0.3, 0.3] ; [people(P)].
|
||||||
|
|
||||||
markov attends(P)::[t,f], attr2::[t,f] ; [0.1, 0.22, 0.3, 0.4] ; [people(P)].
|
markov attends(P)::[t,f], attr2::[t,f] ; [0.7, 0.3, 0.3, 0.3] ; [people(P)].
|
||||||
|
|
||||||
markov attends(P)::[t,f], attr3::[t,f] ; [0.1, 0.2, 0.33, 0.4] ; [people(P)].
|
markov attends(P)::[t,f], attr3::[t,f] ; [0.7, 0.3, 0.3, 0.3] ; [people(P)].
|
||||||
|
|
||||||
markov attends(P)::[t,f], attr4::[t,f] ; [0.1, 0.2, 0.3, 0.44] ; [people(P)].
|
markov attends(P)::[t,f], attr4::[t,f] ; [0.7, 0.3, 0.3, 0.3] ; [people(P)].
|
||||||
|
|
||||||
markov attends(P)::[t,f], attr5::[t,f] ; [0.1, 0.2, 0.3, 0.45] ; [people(P)].
|
markov attends(P)::[t,f], attr5::[t,f] ; [0.7, 0.3, 0.3, 0.3] ; [people(P)].
|
||||||
|
|
||||||
markov attends(P)::[t,f], attr6::[t,f] ; [0.1, 0.2, 0.3, 0.46] ; [people(P)].
|
markov attends(P)::[t,f], attr6::[t,f] ; [0.7, 0.3, 0.3, 0.3] ; [people(P)].
|
||||||
|
|
||||||
markov attends(P)::[t,f], series::[t,f] ; [0.5, 0.6, 0.7, 0.87] ; [people(P)].
|
markov attends(P)::[t,f], series::[t,f] ; [0.501, 0.499, 0.499, 0.499] ; [people(P)].
|
||||||
|
|
||||||
% ?- series(X).
|
% ?- series(X).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user