wolffd@0
|
1 function bnet = mk_water_dbn(discrete_obs, obs_leaves)
|
wolffd@0
|
2 % MK_WATER_DBN
|
wolffd@0
|
3 % bnet = mk_water_dbn(discrete_obs, obs_leaves)
|
wolffd@0
|
4 %
|
wolffd@0
|
5 % If discrete_obs = 1 (default), the leaves are binary, else scalar Gaussians
|
wolffd@0
|
6 % If obs_leaves = 1, all the leaves are observed, otherwise rnd nodes are observed
|
wolffd@0
|
7 %
|
wolffd@0
|
8 % This is a model of the biological processes of a water purification plant, developed
|
wolffd@0
|
9 % by Finn V. Jensen, Uffe Kjærulff, Kristian G. Olesen, and Jan Pedersen.
|
wolffd@0
|
10 % See http://www-nt.cs.berkeley.edu/home/nir/public_html/Repository/water.htm
|
wolffd@0
|
11 % See also Boyen and Koller, "Tractable Inference for Complex Stochastic Processes", UAI98
|
wolffd@0
|
12
|
wolffd@0
|
13 if nargin < 1, discrete_obs = 1; end
|
wolffd@0
|
14 if nargin < 1, obs_leaves = 1; end
|
wolffd@0
|
15
|
wolffd@0
|
16 ss = 12;
|
wolffd@0
|
17 intra = zeros(ss);
|
wolffd@0
|
18 intra(1,9) = 1;
|
wolffd@0
|
19 intra(3,10) = 1;
|
wolffd@0
|
20 intra(4,11) = 1;
|
wolffd@0
|
21 intra(8,12) = 1;
|
wolffd@0
|
22
|
wolffd@0
|
23 inter = zeros(ss);
|
wolffd@0
|
24 inter(1, [1 3]) = 1;
|
wolffd@0
|
25 inter(2, [2 3 7]) = 1;
|
wolffd@0
|
26 inter(3, [3 4 5]) = 1;
|
wolffd@0
|
27 inter(4, [3 4 6]) = 1;
|
wolffd@0
|
28 inter(5, [3 5 6]) = 1;
|
wolffd@0
|
29 inter(6, [4 5 6]) = 1;
|
wolffd@0
|
30 inter(7, [7 8]) = 1;
|
wolffd@0
|
31 inter(8, [6 7 8]) = 1;
|
wolffd@0
|
32
|
wolffd@0
|
33 if obs_leaves
|
wolffd@0
|
34 onodes = 9:12; % leaves
|
wolffd@0
|
35 else
|
wolffd@0
|
36 onodes = [1 5 9:12]; % throw in some other nodes
|
wolffd@0
|
37 end
|
wolffd@0
|
38 hnodes = 1:8;
|
wolffd@0
|
39 if discrete_obs
|
wolffd@0
|
40 ns = 2*ones(1 ,ss);
|
wolffd@0
|
41 dnodes = 1:ss;
|
wolffd@0
|
42 else
|
wolffd@0
|
43 ns = [2*ones(1,length(hnodes)) 1*ones(length(onodes))];
|
wolffd@0
|
44 dnodes = hnodes;
|
wolffd@0
|
45 end
|
wolffd@0
|
46
|
wolffd@0
|
47 eclass1 = 1:12;
|
wolffd@0
|
48 eclass2 = [13:20 9:12];
|
wolffd@0
|
49 bnet = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'eclass1', eclass1, 'eclass2', eclass2, ...
|
wolffd@0
|
50 'observed', onodes);
|
wolffd@0
|
51 if discrete_obs
|
wolffd@0
|
52 for i=1:max(eclass2)
|
wolffd@0
|
53 bnet.CPD{i} = tabular_CPD(bnet, i);
|
wolffd@0
|
54 end
|
wolffd@0
|
55 else
|
wolffd@0
|
56 for i=hnodes(:)'
|
wolffd@0
|
57 bnet.CPD{i} = tabular_CPD(bnet, i);
|
wolffd@0
|
58 end
|
wolffd@0
|
59 for i=onodes(:)'
|
wolffd@0
|
60 bnet.CPD{i} = gaussian_CPD(bnet, i);
|
wolffd@0
|
61 end
|
wolffd@0
|
62 for i=hnodes(:)'+ss
|
wolffd@0
|
63 bnet.CPD{i} = tabular_CPD(bnet, i);
|
wolffd@0
|
64 end
|
wolffd@0
|
65 end
|
wolffd@0
|
66
|
wolffd@0
|
67
|
wolffd@0
|
68
|