wolffd@0: function bnet = mk_water_dbn(discrete_obs, obs_leaves) wolffd@0: % MK_WATER_DBN wolffd@0: % bnet = mk_water_dbn(discrete_obs, obs_leaves) wolffd@0: % wolffd@0: % If discrete_obs = 1 (default), the leaves are binary, else scalar Gaussians wolffd@0: % If obs_leaves = 1, all the leaves are observed, otherwise rnd nodes are observed wolffd@0: % wolffd@0: % This is a model of the biological processes of a water purification plant, developed wolffd@0: % by Finn V. Jensen, Uffe Kjærulff, Kristian G. Olesen, and Jan Pedersen. wolffd@0: % See http://www-nt.cs.berkeley.edu/home/nir/public_html/Repository/water.htm wolffd@0: % See also Boyen and Koller, "Tractable Inference for Complex Stochastic Processes", UAI98 wolffd@0: wolffd@0: if nargin < 1, discrete_obs = 1; end wolffd@0: if nargin < 1, obs_leaves = 1; end wolffd@0: wolffd@0: ss = 12; wolffd@0: intra = zeros(ss); wolffd@0: intra(1,9) = 1; wolffd@0: intra(3,10) = 1; wolffd@0: intra(4,11) = 1; wolffd@0: intra(8,12) = 1; wolffd@0: wolffd@0: inter = zeros(ss); wolffd@0: inter(1, [1 3]) = 1; wolffd@0: inter(2, [2 3 7]) = 1; wolffd@0: inter(3, [3 4 5]) = 1; wolffd@0: inter(4, [3 4 6]) = 1; wolffd@0: inter(5, [3 5 6]) = 1; wolffd@0: inter(6, [4 5 6]) = 1; wolffd@0: inter(7, [7 8]) = 1; wolffd@0: inter(8, [6 7 8]) = 1; wolffd@0: wolffd@0: if obs_leaves wolffd@0: onodes = 9:12; % leaves wolffd@0: else wolffd@0: onodes = [1 5 9:12]; % throw in some other nodes wolffd@0: end wolffd@0: hnodes = 1:8; wolffd@0: if discrete_obs wolffd@0: ns = 2*ones(1 ,ss); wolffd@0: dnodes = 1:ss; wolffd@0: else wolffd@0: ns = [2*ones(1,length(hnodes)) 1*ones(length(onodes))]; wolffd@0: dnodes = hnodes; wolffd@0: end wolffd@0: wolffd@0: eclass1 = 1:12; wolffd@0: eclass2 = [13:20 9:12]; wolffd@0: bnet = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'eclass1', eclass1, 'eclass2', eclass2, ... wolffd@0: 'observed', onodes); wolffd@0: if discrete_obs wolffd@0: for i=1:max(eclass2) wolffd@0: bnet.CPD{i} = tabular_CPD(bnet, i); wolffd@0: end wolffd@0: else wolffd@0: for i=hnodes(:)' wolffd@0: bnet.CPD{i} = tabular_CPD(bnet, i); wolffd@0: end wolffd@0: for i=onodes(:)' wolffd@0: bnet.CPD{i} = gaussian_CPD(bnet, i); wolffd@0: end wolffd@0: for i=hnodes(:)'+ss wolffd@0: bnet.CPD{i} = tabular_CPD(bnet, i); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: wolffd@0: