minor changes to CLP(BN).

This commit is contained in:
Vitor Santos Costa 2009-10-21 00:05:23 +01:00
parent 54465b08f1
commit b2eb437625
6 changed files with 25 additions and 13 deletions

View File

@ -476,7 +476,7 @@ clean_up :-
fail.
clean_up.
gibbs_params(5,1000,10000).
gibbs_params(5,100,1000).
cvt2problist([], []).
cvt2problist([[[_|E]]|Est0], [Ps|Probs]) :-

View File

@ -63,6 +63,8 @@ clpbn_reset_tables(Sz) :-
myf(Key, Size, Index) :-
instantiated_term_hash(Key, -1, Size, Index).
myc(A, B) :-
ground(A), !, B == A.
myc(A, B) :-
variant(A,B),
term_variables(A,L1),

View File

@ -97,7 +97,7 @@ run_vel_solver(LVs, LPs, LNVs) :-
findall(Ps, solve_vel(LVs, LNVs, Ps), LPs).
solve_vel([LVs|_], [NVs0|_], Ps) :-
length(NVs0, L), (L > 64 -> clpbn_gviz:clpbn2gviz(user_error,sort,NVs0,LVs) ; true ),
% length(NVs0, L), (L > 64 -> clpbn_gviz:clpbn2gviz(user_error,sort,NVs0,LVs) ; true ),
find_all_clpbn_vars(NVs0, NVs0, LV0, LVi, Tables0),
sort(LV0, LV),
% construct the graph

View File

@ -227,11 +227,10 @@ run_sample([C|Cases], [P|Ps], Table) :-
run_sample(Cases, Ps, Table).
call_run_all(Mod:Items) :-
clpbn_flag(em_solver, pcg),
clpbn_flag(em_solver, pcg), !,
backtrack_run_all(Items, Mod).
call_run_all(Items) :-
clpbn_flag(em_solver, pcg),
run_all(Items).
call_run_all(Mod:Items) :-
run_all(Mod:Items).
backtrack_run_all([Item|_], Mod) :-
call(Mod:Item),

View File

@ -4,9 +4,20 @@
:- [pos:train].
:- ['~/Yap/work/CLPBN/clpbn/examples/School/school_32'].
:- ['~/Yap/work/packages/CLPBN/clpbn/examples/School/school_32'].
:- ['~/Yap/work/CLPBN/learning/em'].
:- ['~/Yap/work/packages/CLPBN/learning/em'].
%:- clpbn:set_clpbn_flag(em_solver,gibbs).
:- clpbn:set_clpbn_flag(em_solver,jt).
%:- clpbn:set_clpbn_flag(em_solver,vel).
timed_main :-
statistics(runtime, _),
findall(X,goal(X),L),
em(L,0.01,10,_,Lik),
statistics(runtime, [T,_]),
format('Took ~d msec and Lik ~3f~n',[T,Lik]).
main :-
findall(X,goal(X),L),
@ -14,9 +25,9 @@ main :-
writeln(Lik:CPTs).
%
% change to 0.05, 0.1, 0.2 to make things simpler/harder
% change to 0.0, 0.1, 0.2 to make things simpler/harder
%
missing(0.3).
missing(0.50).
% miss 30% of the examples.
goal(professor_ability(P,V)) :-

View File

@ -30,15 +30,15 @@
run_all([]).
run_all([G|Gs]) :-
call(G),
run_all(Gs).
run_all(user:[G:Gs]).
run_all(M:Gs) :-
clpbn_reset_tables,
run_all(Gs,M).
run_all([],_).
run_all([G|Gs],M) :-
( call(M:G) -> true ; writeln(bad:M:G), break),
% (G = _:ge(ybr136w,t8,23,-1) -> nb_getval(clpbn_tables, Tab), writeln(Tab) ; true ),
( call(M:G) -> true ; writeln(bad:M:G), start_low_level_trace, M:G ; halt ),
run_all(Gs,M).
clpbn_vars(Vs,BVars) :-