comparison toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/mk_bat_dbn.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 [bnet, names] = mk_bat_dbn()
2 % MK_BAT_DBN Make the BAT DBN
3 % [bnet, names] = mk_bat_dbn()
4 % See
5 % - Forbes, Huang, Kanazawa and Russell, "The BATmobile: Towards a Bayesian Automated Taxi", IJCAI 95
6 % - Boyen and Koller, "Tractable Inference for Complex Stochastic Processes", UAI98.
7
8 names = {'LeftClr', 'RightClr', 'LatAct', 'Xdot', 'InLane', 'FwdAct', ...
9 'Ydot', 'Stopped', 'EngStatus', 'FBStatus', ...
10 'LeftClrSens', 'RightClrSens', 'TurnSignalSens', 'XdotSens', 'YdotSens', ...
11 'FYdotDiffSens', 'FclrSens', 'BXdotSens', 'BclrSens', 'BYdotDiffSens', ...
12 'SensorValid', 'FYdotDiff', 'FcloseSlow', 'Fclr', 'BXdot', 'BcloseFast', 'Bclr', 'BYdotDiff'};
13 ss = length(names);
14
15 intrac = {...
16 'LeftClr', 'LeftClrSens';
17 'RightClr', 'RightClrSens';
18 'LatAct', 'TurnSignalSens'; 'LatAct', 'Xdot';
19 'Xdot', 'XdotSens';
20 'FwdAct', 'Ydot';
21 'Ydot', 'YdotSens'; 'Ydot', 'Stopped';
22 'EngStatus', 'Ydot'; 'EngStatus', 'FYdotDiff'; 'EngStatus', 'Fclr'; 'EngStatus', 'BXdot';
23 'SensorValid', 'XdotSens'; 'SensorValid', 'YdotSens';
24 'FYdotDiff', 'FYdotDiffSens'; 'FYdotDiff', 'FcloseSlow';
25 'FcloseSlow', 'FBStatus';
26 'Fclr', 'FclrSens'; 'Fclr', 'FcloseSlow';
27 'BXdot', 'BXdotSens';
28 'Bclr', 'BclrSens'; 'Bclr', 'BXdot'; 'Bclr', 'BcloseFast';
29 'BcloseFast', 'FBStatus';
30 'BYdotDiff', 'BYdotDiffSens'; 'BYdotDiff', 'BcloseFast'};
31 [intra, names] = mk_adj_mat(intrac, names, 1);
32
33
34 interc = {...
35 'LeftClr', 'LeftClr'; 'LeftClr', 'LatAct';
36 'RightClr', 'RightClr'; 'RightClr', 'LatAct';
37 'LatAct', 'LatAct'; 'LatAct', 'FwdAct';
38 'Xdot', 'Xdot'; 'Xdot', 'InLane';
39 'InLane', 'InLane'; 'InLane', 'LatAct';
40 'FwdAct', 'FwdAct';
41 'Ydot', 'Ydot';
42 'Stopped', 'Stopped';
43 'EngStatus', 'EngStatus';
44 'FBStatus', 'FwdAct'; 'FBStatus', 'LatAct'};
45 inter = mk_adj_mat(interc, names, 0);
46
47 obs = {'LeftClrSens', 'RightClrSens', 'TurnSignalSens', 'XdotSens', 'YdotSens', 'FYdotDiffSens', ...
48 'FclrSens', 'BXdotSens', 'BclrSens', 'BYdotDiffSens'};
49
50 for i=1:length(obs)
51 onodes(i) = strmatch(obs{i}, names); %stringmatch(obs{i}, names);
52 end
53 onodes = sort(onodes);
54
55 dnodes = 1:ss;
56 ns = 2*ones(1,ss); % binary nodes
57 bnet = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'observed', onodes, 'eclass2', (1:ss)+ss);
58
59 % make rnd params
60 for i=1:2*ss
61 bnet.CPD{i} = tabular_CPD(bnet, i);
62 end
63