small fixes

This commit is contained in:
Vitor Santos Costa 2011-05-20 23:56:12 +01:00
parent 6d4d2b5830
commit 55e2e6fe3a
7 changed files with 27 additions and 12 deletions

View File

@ -52,7 +52,7 @@ cpt_average(AllVars, Key, Els0, Tab, Vs, NewVs) :-
cpt_average(AllVars, Key, Els0, 1.0, Tab, Vs, NewVs). cpt_average(AllVars, Key, Els0, 1.0, Tab, Vs, NewVs).
% support variables with evidence from domain. This should make everyone's life easier. % support variables with evidence from domain. This should make everyone's life easier.
cpt_average([Ev|Vars], Key, Els0, Softness, p(Els0, CPT, NewParents), Vs, NewVs) :- cpt_average([Ev|Vars], Key, Els0, Softness, pf(Els0, MAT, NewParents), Vs, NewVs) :-
find_evidence(Vars, 0, TotEvidence, RVars), find_evidence(Vars, 0, TotEvidence, RVars),
build_avg_table(RVars, Vars, Els0, Key, TotEvidence, Softness, MAT0, NewParents0, Vs, IVs), build_avg_table(RVars, Vars, Els0, Key, TotEvidence, Softness, MAT0, NewParents0, Vs, IVs),
include_qevidence(Ev, MAT0, MAT, NewParents0, NewParents, Vs, IVs, NewVs). include_qevidence(Ev, MAT0, MAT, NewParents0, NewParents, Vs, IVs, NewVs).

View File

@ -93,7 +93,7 @@ vars2ids([V|QueryVars], [VarId|Ids]) :-
get_evidence(V, Ev) :- get_evidence(V, Ev) :-
clpbn:get_atts(V, [evidence(Ev)]), !. clpbn:get_atts(V, [evidence(Ev)]), !.
get_evidence(V, -1). % no evidence !!! get_evidence(_V, -1). % no evidence !!!
get_extra_vars_info([], []). get_extra_vars_info([], []).

View File

@ -22,7 +22,7 @@ output_var(Stream, V) :-
Parents = [_|_], !, Parents = [_|_], !,
format(Stream, ' ',[]), format(Stream, ' ',[]),
output_parents(Stream, Parents), output_parents(Stream, Parents),
format(' -> ',[]), format(Stream,' -> ',[]),
output_key(Stream,Key), output_key(Stream,Key),
nl(Stream). nl(Stream).
output_var(_, _). output_var(_, _).

View File

@ -96,7 +96,7 @@ clpbn_table(F/N,M) :-
Key =.. L1, Key =.. L1,
atom_concat(F, '___tabled', NF), atom_concat(F, '___tabled', NF),
L2 = [_|Args], L2 = [_|Args],
S1 =.. [NF|Args], _S1 =.. [NF|Args],
L0 = [_|OArgs], L0 = [_|OArgs],
S2 =.. [NF|OArgs], S2 =.. [NF|OArgs],
asserta(clpbn_table(S, M, S2)), asserta(clpbn_table(S, M, S2)),

View File

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

View File

@ -11,7 +11,7 @@
[clpbn_init_graph/1, [clpbn_init_graph/1,
clpbn_init_solver/5, clpbn_init_solver/5,
clpbn_run_solver/4, clpbn_run_solver/4,
clpbn_finalize_solver/4, clpbn_finalize_solver/1,
clpbn_flag/2]). clpbn_flag/2]).
:- use_module(library('clpbn/dists'), :- use_module(library('clpbn/dists'),
@ -92,7 +92,7 @@ init_em(Items, state( AllDists, AllDistInstances, MargVars, SolverVars)) :-
em_loop(Its, Likelihood0, State, MaxError, MaxIts, LikelihoodF, FTables) :- em_loop(Its, Likelihood0, State, MaxError, MaxIts, LikelihoodF, FTables) :-
estimate(State, LPs), estimate(State, LPs),
maximise(State, Tables, LPs, Likelihood), maximise(State, Tables, LPs, Likelihood),
writeln(Likelihood:Its:Likelihood0:Tables), % writeln(Likelihood:Its:Likelihood0:Tables),
( (
( (
abs((Likelihood - Likelihood0)/Likelihood) < MaxError abs((Likelihood - Likelihood0)/Likelihood) < MaxError
@ -207,7 +207,7 @@ compute_parameters([Id-Samples|Dists], [Id-NewTable|Tables], MDistTable, Lik0,
empty_dist(Id, Table0), empty_dist(Id, Table0),
add_samples(Samples, Table0, MDistTable), add_samples(Samples, Table0, MDistTable),
soften_sample(Table0, SoftenedTable), soften_sample(Table0, SoftenedTable),
matrix:matrix_sum(Table0,TotM), % matrix:matrix_sum(Table0,TotM),
normalise_counts(SoftenedTable, NewTable), normalise_counts(SoftenedTable, NewTable),
compute_likelihood(Table0, NewTable, DeltaLik), compute_likelihood(Table0, NewTable, DeltaLik),
dist_new_table(Id, NewTable), dist_new_table(Id, NewTable),

File diff suppressed because one or more lines are too long