Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/inference/static/@jtree_limid_inf_engine/Old/marginal_nodes_SS.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [pot, MEU] = marginal_nodes(engine, d) | |
2 | |
3 C = length(cliques); | |
4 %clpot = init_clpot(limid, cliques, d, clq_ass_to_node); | |
5 clpot = init_clpot(limid, cliques, [], clq_ass_to_node); | |
6 | |
7 % collect to root | |
8 if 1 | |
9 % HUGIN | |
10 seppot = cell(C, C); % separators are implicitely initialized to 1s | |
11 for n=postorder{di}(1:end-1) | |
12 for p=parents(rooted_jtree{di}, n) | |
13 %clpot{p} = divide_by_pot(clpot{n}, seppot{p,n}); % dividing by 1 is redundant | |
14 seppot{p,n} = marginalize_pot(clpot{n}, separator{p,n}); | |
15 clpot{p} = multiply_by_pot(clpot{p}, seppot{p,n}); | |
16 end | |
17 end | |
18 else | |
19 % Shafer-Shenoy | |
20 msg = cell(C,C); | |
21 for n=postorder{di}(1:end-1) | |
22 for c=children(rooted_jtree{di}, n) | |
23 clpot{n} = multiply_by_pot(clpot{n}, msg{c,n}); | |
24 end | |
25 p = parents(rooted_jtree{di}, n); | |
26 %msg{n,p} = marginalize_pot(clpot{n}, cliques{p}); | |
27 msg{n,p} = marginalize_pot(clpot{n}, separator{n,p}); | |
28 end | |
29 root = clq_ass_to_node(d); | |
30 n=postorder{di}(end); | |
31 assert(n == root); | |
32 for c=children(rooted_jtree{di}, n) | |
33 clpot{n} = multiply_by_pot(clpot{n}, msg{c,n}); | |
34 end | |
35 end | |
36 | |
37 fam = family(limid.dag, d); | |
38 pot = marginalize_pot(clpot{root}, fam); | |
39 | |
40 %%%%%%% | |
41 jpot = compute_joint_pot_limid(limid); | |
42 pot2 = marginalize_pot(jpot, fam); | |
43 assert(approxeq_pot(pot, pot2)) | |
44 %%%%%% | |
45 | |
46 [policy, score] = extract_policy(pot); | |
47 | |
48 e = limid.equiv_class(d); | |
49 limid.CPD{e} = set_params(limid.CPD{e}, 'policy', policy); | |
50 | |
51 | |
52 |