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