From b3bd547f5503707e1052f282e68b9ed84a74fe12 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 21 May 2011 00:27:25 +0100 Subject: [PATCH] vel -> ve --- packages/CLPBN/Makefile.in | 2 +- packages/CLPBN/clpbn.yap | 34 +++++++------- packages/CLPBN/clpbn/{vel.yap => ve.yap} | 46 +++++++++---------- .../CLPBN/learning/example/school_params.yap | 2 +- packages/CLPBN/learning/learn_utils.yap | 2 +- 5 files changed, 43 insertions(+), 43 deletions(-) rename packages/CLPBN/clpbn/{vel.yap => ve.yap} (90%) diff --git a/packages/CLPBN/Makefile.in b/packages/CLPBN/Makefile.in index 6eae7152b..c3cc626e7 100644 --- a/packages/CLPBN/Makefile.in +++ b/packages/CLPBN/Makefile.in @@ -51,7 +51,7 @@ CLPBN_PROGRAMS= \ $(CLPBN_SRCDIR)/table.yap \ $(CLPBN_SRCDIR)/topsort.yap \ $(CLPBN_SRCDIR)/utils.yap \ - $(CLPBN_SRCDIR)/vel.yap \ + $(CLPBN_SRCDIR)/ve.yap \ $(CLPBN_SRCDIR)/viterbi.yap \ $(CLPBN_SRCDIR)/xbif.yap diff --git a/packages/CLPBN/clpbn.yap b/packages/CLPBN/clpbn.yap index 2883569b8..11e57eb45 100644 --- a/packages/CLPBN/clpbn.yap +++ b/packages/CLPBN/clpbn.yap @@ -29,11 +29,11 @@ :- attribute key/1, dist/2, evidence/1, starter/0. -:- use_module('clpbn/vel', - [vel/3, - check_if_vel_done/1, - init_vel_solver/4, - run_vel_solver/3 +:- use_module('clpbn/ve', + [ve/3, + check_if_ve_done/1, + init_ve_solver/4, + run_ve_solver/3 ]). :- use_module('clpbn/bp', @@ -110,8 +110,8 @@ :- dynamic solver/1,output/1,use/1,suppress_attribute_display/1, parameter_softening/1, em_solver/1. -solver(vel). -em_solver(vel). +solver(ve). +em_solver(ve). %output(xbif(user_error)). %output(gviz(user_error)). @@ -215,7 +215,7 @@ project_attributes(GVars, AVars) :- clpbn_vars(AVars, DiffVars, AllVars), get_clpbn_vars(GVars,CLPBNGVars0), simplify_query_vars(CLPBNGVars0, CLPBNGVars), - (output(xbif(XBifStream)) -> clpbn2xbif(XBifStream,vel,AllVars) ; true), + (output(xbif(XBifStream)) -> clpbn2xbif(XBifStream,ve,AllVars) ; true), (output(gviz(XBifStream)) -> clpbn2gviz(XBifStream,sort,AllVars,GVars) ; true), ( Solver = graphs @@ -257,8 +257,8 @@ get_rid_of_ev_vars([V|LVs0],[V|LVs]) :- % do nothing if we don't have query variables to compute. write_out(graphs, _, AVars, _) :- clpbn2graph(AVars). -write_out(vel, GVars, AVars, DiffVars) :- - vel(GVars, AVars, DiffVars). +write_out(ve, GVars, AVars, DiffVars) :- + ve(GVars, AVars, DiffVars). write_out(jt, GVars, AVars, DiffVars) :- jt(GVars, AVars, DiffVars). write_out(bp, GVars, AVars, DiffVars) :- @@ -349,14 +349,14 @@ bind_clpbn(_, Var, _, _, _, _, []) :- use(bnt), check_if_bnt_done(Var), !. bind_clpbn(_, Var, _, _, _, _, []) :- - use(vel), - check_if_vel_done(Var), !. + use(ve), + check_if_ve_done(Var), !. bind_clpbn(_, Var, _, _, _, _, []) :- use(bp), check_if_bp_done(Var), !. bind_clpbn(_, Var, _, _, _, _, []) :- use(jt), - check_if_vel_done(Var), !. + check_if_ve_done(Var), !. bind_clpbn(T, Var, Key0, _, _, _, []) :- get_atts(Var, [key(Key)]), !, ( @@ -421,8 +421,8 @@ clpbn_init_solver(LVs, Vs0, VarsWithUnboundKeys, State) :- clpbn_init_solver(gibbs, LVs, Vs0, VarsWithUnboundKeys, State) :- init_gibbs_solver(LVs, Vs0, VarsWithUnboundKeys, State). -clpbn_init_solver(vel, LVs, Vs0, VarsWithUnboundKeys, State) :- - init_vel_solver(LVs, Vs0, VarsWithUnboundKeys, State). +clpbn_init_solver(ve, LVs, Vs0, VarsWithUnboundKeys, State) :- + init_ve_solver(LVs, Vs0, VarsWithUnboundKeys, State). clpbn_init_solver(bp, LVs, Vs0, VarsWithUnboundKeys, State) :- init_bp_solver(LVs, Vs0, VarsWithUnboundKeys, State). clpbn_init_solver(jt, LVs, Vs0, VarsWithUnboundKeys, State) :- @@ -444,8 +444,8 @@ clpbn_run_solver(LVs, LPs, State) :- clpbn_run_solver(gibbs, LVs, LPs, State) :- run_gibbs_solver(LVs, LPs, State). -clpbn_run_solver(vel, LVs, LPs, State) :- - run_vel_solver(LVs, LPs, State). +clpbn_run_solver(ve, LVs, LPs, State) :- + run_ve_solver(LVs, LPs, State). clpbn_run_solver(bp, LVs, LPs, State) :- run_bp_solver(LVs, LPs, State). diff --git a/packages/CLPBN/clpbn/vel.yap b/packages/CLPBN/clpbn/ve.yap similarity index 90% rename from packages/CLPBN/clpbn/vel.yap rename to packages/CLPBN/clpbn/ve.yap index 93acbd6e0..be2696bd1 100644 --- a/packages/CLPBN/clpbn/vel.yap +++ b/packages/CLPBN/clpbn/ve.yap @@ -14,10 +14,10 @@ *********************************/ -:- module(clpbn_vel, [vel/3, - check_if_vel_done/1, - init_vel_solver/4, - run_vel_solver/3]). +:- module(clpbn_ve, [ve/3, + check_if_ve_done/1, + init_ve_solver/4, + run_ve_solver/3]). :- attribute size/1, all_diffs/1. @@ -64,39 +64,39 @@ [check_for_agg_vars/2]). -check_if_vel_done(Var) :- +check_if_ve_done(Var) :- get_atts(Var, [size(_)]), !. % % implementation of the well known variable elimination algorithm % -vel([[]],_,_) :- !. -vel([LVs],Vs0,AllDiffs) :- - init_vel_solver([LVs], Vs0, AllDiffs, State), +ve([[]],_,_) :- !. +ve([LVs],Vs0,AllDiffs) :- + init_ve_solver([LVs], Vs0, AllDiffs, State), % variable elimination proper - run_vel_solver([LVs], [LPs], State), + run_ve_solver([LVs], [LPs], State), % bind Probs back to variables so that they can be output. clpbn_bind_vals([LVs],[LPs],AllDiffs). -init_vel_solver(Qs, Vs0, _, LVis) :- +init_ve_solver(Qs, Vs0, _, LVis) :- check_for_agg_vars(Vs0, Vs1), % LVi will have a list of CLPBN variables % Tables0 will have the full data on each variable init_influences(Vs1, G, RG), - init_vel_solver_for_questions(Qs, G, RG, _, LVis). + init_ve_solver_for_questions(Qs, G, RG, _, LVis). -init_vel_solver_for_questions([], _, _, [], []). -init_vel_solver_for_questions([Vs|MVs], G, RG, [NVs|MNVs0], [NVs|LVis]) :- +init_ve_solver_for_questions([], _, _, [], []). +init_ve_solver_for_questions([Vs|MVs], G, RG, [NVs|MNVs0], [NVs|LVis]) :- influences(Vs, _, NVs0, G, RG), sort(NVs0, NVs), %clpbn_gviz:clpbn2gviz(user_error, test, NVs, Vs), - init_vel_solver_for_questions(MVs, G, RG, MNVs0, LVis). + init_ve_solver_for_questions(MVs, G, RG, MNVs0, LVis). % use a findall to recover space without needing for GC -run_vel_solver(LVs, LPs, LNVs) :- - findall(Ps, solve_vel(LVs, LNVs, Ps), LPs). +run_ve_solver(LVs, LPs, LNVs) :- + findall(Ps, solve_ve(LVs, LNVs, Ps), LPs). -solve_vel([LVs|_], [NVs0|_], Ps) :- +solve_ve([LVs|_], [NVs0|_], Ps) :- % 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), @@ -109,8 +109,8 @@ solve_vel([LVs|_], [NVs0|_], Ps) :- % move from potentials back to probabilities normalise_CPT(Dist,MPs), list_from_CPT(MPs, Ps). -solve_vel([_|MoreLVs], [_|MoreLVis], Ps) :- - solve_vel(MoreLVs, MoreLVis, Ps). +solve_ve([_|MoreLVs], [_|MoreLVis], Ps) :- + solve_ve(MoreLVs, MoreLVis, Ps). exps([],[]). exps([L|LD],[O|LDE]) :- @@ -134,7 +134,7 @@ find_all_clpbn_vars([V|Vs], NVs0, [Var|LV], ProcessedVars, [table(I,Table,Parent % variables with evidence should not be processed. (var(Ev) -> Var = var(V,I,Sz,Vals,Parents,Ev,_,_), - vel_get_dist_size(V,Sz), + ve_get_dist_size(V,Sz), ProcessedVars = [Var|ProcessedVars0] ; ProcessedVars = ProcessedVars0 @@ -192,7 +192,7 @@ compute_size([tab(_,Vs,_)|Tabs],Vs0,K) :- multiply_sizes([],K,K). multiply_sizes([V|Vs],K0,K) :- - vel_get_dist_size(V, Sz), + ve_get_dist_size(V, Sz), KI is K0*Sz, multiply_sizes(Vs,KI,K). @@ -281,9 +281,9 @@ update_tables([tab(Tab0,Vs,Sz)|Tabs],[tab(Tab0,Vs,Sz)|NTabs],Table,V) :- update_tables([_|Tabs],NTabs,Table,V) :- update_tables(Tabs,NTabs,Table,V). -vel_get_dist_size(V,Sz) :- +ve_get_dist_size(V,Sz) :- get_atts(V, [size(Sz)]), !. -vel_get_dist_size(V,Sz) :- +ve_get_dist_size(V,Sz) :- clpbn:get_atts(V,dist(Id,_)), !, get_dist_domain_size(Id,Sz), put_atts(V, [size(Sz)]). diff --git a/packages/CLPBN/learning/example/school_params.yap b/packages/CLPBN/learning/example/school_params.yap index 0f45ad190..199e4534f 100644 --- a/packages/CLPBN/learning/example/school_params.yap +++ b/packages/CLPBN/learning/example/school_params.yap @@ -10,7 +10,7 @@ %:- clpbn:set_clpbn_flag(em_solver,gibbs). %:- clpbn:set_clpbn_flag(em_solver,jt). -:- clpbn:set_clpbn_flag(em_solver,vel). +:- clpbn:set_clpbn_flag(em_solver,ve). %:- clpbn:set_clpbn_flag(em_solver,bp). timed_main :- diff --git a/packages/CLPBN/learning/learn_utils.yap b/packages/CLPBN/learning/learn_utils.yap index 9d0523dd9..713f19da4 100644 --- a/packages/CLPBN/learning/learn_utils.yap +++ b/packages/CLPBN/learning/learn_utils.yap @@ -38,7 +38,7 @@ run_all(M:Gs) :- run_all([],_). run_all([G|Gs],M) :- % (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 ), + ( call(M:G) -> true ; throw(bad_call(M:G)) ), run_all(Gs,M). clpbn_vars(Vs,BVars) :-