From ceaf8af95db6c32333d35a95381d604a93dec71c Mon Sep 17 00:00:00 2001 From: rzf Date: Mon, 18 Feb 2008 16:42:04 +0000 Subject: [PATCH] added binary flag suppress_attribute_display to clpbn to suppress the dislpaying of attributes fixed a bug in bnt.yap: the index of the value of the evidence variable start from 1 rather than from 0 added the possibility of computing the marginal of more than one variable in bnt.yap git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2103 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- CLPBN/clpbn.yap | 19 ++++++++++++++++++- CLPBN/clpbn/bnt.yap | 5 ++++- CLPBN/clpbn/display.yap | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CLPBN/clpbn.yap b/CLPBN/clpbn.yap index c56354aa2..e0cf8b9fc 100644 --- a/CLPBN/clpbn.yap +++ b/CLPBN/clpbn.yap @@ -68,13 +68,14 @@ sort_vars_by_key/3 ]). -:- dynamic solver/1,output/1,use/1. +:- dynamic solver/1,output/1,use/1,suppress_attribute_display/1. solver(jt). %output(xbif(user_error)). %output(gviz(user_error)). output(no). +suppress_attribute_display(false). clpbn_flag(Flag,Option) :- clpbn_flag(Flag, Option, Option). @@ -97,6 +98,10 @@ clpbn_flag(bnt_path,Before,After) :- clpbn_flag(bnt_model,Before,After) :- retract(bnt:bnt_model(Before)), assert(bnt:bnt_model(After)). +clpbn_flag(suppress_attribute_display,Before,After) :- + retract(suppress_attribute_display(Before)), + assert(suppress_attribute_display(After)). + {Var = Key with Dist} :- put_atts(El,[key(Key),dist(DistInfo,Parents)]), @@ -135,6 +140,7 @@ clpbn_marginalise(V, Dist) :- % or by call_residue/2 % project_attributes(GVars, AVars) :- + suppress_attribute_display(false), AVars = [_|_], solver(Solver), ( GVars = [_|_] ; Solver = graphs), !, @@ -144,6 +150,17 @@ project_attributes(GVars, AVars) :- write_out(Solver,CLPBNGVars, AllVars, DiffVars). project_attributes(_, _). +call_solver(GVars, AVars) :- + AVars = [_|_], + solver(Solver), + ( GVars = [_|_] ; Solver = graphs), !, + clpbn_vars(AVars, DiffVars, AllVars), + get_clpbn_vars(GVars,CLPBNGVars0), + simplify_query_vars(CLPBNGVars0, CLPBNGVars), + write_out(Solver,CLPBNGVars, AllVars, DiffVars). + + + clpbn_vars(AVars, DiffVars, AllVars) :- sort_vars_by_key(AVars,SortedAVars,DiffVars), incorporate_evidence(SortedAVars, AllVars). diff --git a/CLPBN/clpbn/bnt.yap b/CLPBN/clpbn/bnt.yap index f35441904..828b2933f 100644 --- a/CLPBN/clpbn/bnt.yap +++ b/CLPBN/clpbn/bnt.yap @@ -107,16 +107,19 @@ create_bnt_graph(AllVars, Representatives, SortedVertices, NumberedVertices, Siz % make sure MATLAB works. + init_matlab :- bnt(on), !. init_matlab :- start_matlab, bnt_path(Path), - atom_concat('cd ', Path, Command), + append("cd ",Path,Command), +% atom_concat('cd ', Path, Command), matlab_eval_string(Command), matlab_eval_string('addpath(genpathKPM(pwd))',_), assert(bnt(on)). + start_matlab :- matlab_on, !. start_matlab :- diff --git a/CLPBN/clpbn/display.yap b/CLPBN/clpbn/display.yap index 921c3e13d..48050a753 100644 --- a/CLPBN/clpbn/display.yap +++ b/CLPBN/clpbn/display.yap @@ -15,6 +15,7 @@ % what is actually output % attribute_goal(V, G) :- + clpbn:suppress_attribute_display(false), get_atts(V, [posterior(Vs,Vals,Ps,AllDiffs)]), massage_out(Vs, Vals, Ps, G, AllDiffs, V).