Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/inference/online/@jtree_2TBN_inf_engine/jtree_2TBN_inf_engine.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 engine = jtree_2TBN_inf_engine(bnet, varargin) | |
2 % JTREE_ONLINE_INF_ENGINE Online Junction tree inference algorithm for DBNs. | |
3 % engine = jtree_online_inf_engine(bnet, ...) | |
4 % | |
5 % The following optional arguments can be specified in the form of name/value pairs: | |
6 % [default value in brackets] | |
7 % | |
8 % clusters - specifies variables that must be grouped in the 1.5 slice DBN | |
9 % | |
10 % The same nodes must be observed in every slice. | |
11 % | |
12 % This uses the forwards interface of slice t-1 plus all of slice t. | |
13 % By contrast, jtree_dbn uses all of slice t-1 plus the backwards interface of slice t. | |
14 % See my thesis for details. | |
15 | |
16 | |
17 clusters = {}; | |
18 | |
19 args = varargin; | |
20 nargs = length(args); | |
21 for i=1:2:length(args) | |
22 switch args{i}, | |
23 case 'clusters', clusters = args{i+1}; | |
24 otherwise, error(['unrecognized argument ' args{i}]) | |
25 end | |
26 end | |
27 | |
28 engine.maximize = 0; | |
29 engine.evidence = []; | |
30 engine.node_sizes = []; | |
31 | |
32 int = compute_fwd_interface(bnet.intra, bnet.inter); | |
33 engine.interface = int; | |
34 ss = length(bnet.intra); | |
35 engine.nonint = mysetdiff(1:ss, int); | |
36 onodes = bnet.observed; | |
37 | |
38 bnet15 = mk_slice_and_half_dbn(bnet, int); | |
39 | |
40 % use unconstrained elimination, | |
41 % but force there to be a clique containing both interfaces | |
42 clusters(end+1:end+2) = {int, int+ss}; | |
43 engine.jtree_engine = jtree_inf_engine(bnet15, 'clusters', clusters, 'root', int+ss); | |
44 jtree_engine = struct(engine.jtree_engine); % violate object privacy | |
45 | |
46 engine.in_clq = clq_containing_nodes(engine.jtree_engine, int); | |
47 engine.out_clq = clq_containing_nodes(engine.jtree_engine, int+ss); | |
48 engine.clq_ass_to_node = jtree_engine.clq_ass_to_node; | |
49 engine.root = jtree_engine.root_clq; | |
50 | |
51 % Also create an engine just for slice 1 | |
52 bnet1 = mk_bnet(bnet.intra1, bnet.node_sizes_slice, 'discrete', myintersect(bnet.dnodes,1:ss), ... | |
53 'equiv_class', bnet.equiv_class(:,1), 'observed', onodes); | |
54 for i=1:max(bnet1.equiv_class) | |
55 bnet1.CPD{i} = bnet.CPD{i}; | |
56 end | |
57 engine.jtree_engine1 = jtree_inf_engine(bnet1, 'clusters', {int}, 'root', int); | |
58 jtree_engine1 = struct(engine.jtree_engine1); % violate object privacy | |
59 engine.int_clq1 = clq_containing_nodes(engine.jtree_engine1, int); | |
60 engine.clq_ass_to_node1 = jtree_engine1.clq_ass_to_node; | |
61 engine.root1 = jtree_engine1.root_clq; | |
62 | |
63 engine.observed = [onodes onodes+ss]; | |
64 engine.observed1 = onodes; | |
65 engine.pot_type = determine_pot_type(bnet, onodes); | |
66 engine.slice_size = bnet.nnodes_per_slice; | |
67 | |
68 engine = class(engine, 'jtree_2TBN_inf_engine', inf_engine(bnet)); | |
69 |