⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oil1.m

📁 贝叶斯网络matlab源程序,可用于分类,欢迎大家下载测试
💻 M
字号:
% oil wildcatter influence diagram in Cowell et al p172T = 1; UT = 2; O = 3; R = 4; D = 5; UD = 6;N = 6;dag = zeros(N);dag(T, [UT R D]) = 1;dag(O, [R UD]) = 1;dag(R, D) = 1;dag(D, UD) = 1;ns = zeros(1,N);ns(O) = 3; ns(R) = 4; ns(T) = 2; ns(D) = 2; ns(UT) = 1; ns(UD) = 1;limid = mk_limid(dag, ns, 'chance', [O R], 'decision', [T D], 'utility', [UT UD]);limid.CPD{O} = tabular_CPD(limid, O, [0.5 0.3 0.2]);tbl = [0.6 0 0.3 0 0.1 0  0.3 0 0.4 0 0.4 0  0.1 0 0.3 0 0.5 0  0 1 0 1 0 1];limid.CPD{R} = tabular_CPD(limid, R, tbl);limid.CPD{UT} = tabular_utility_node(limid, UT,  [-10 0]);limid.CPD{UD} = tabular_utility_node(limid, UD, [-70 50 200  0 0 0]);if 1  % start with uniform policies  limid.CPD{T} = tabular_decision_node(limid, T);  limid.CPD{D} = tabular_decision_node(limid, D);else  % hard code optimal policies  limid.CPD{T} = tabular_decision_node(limid, T, [1.0 0.0]);          a = 0.5; b = 1-a; % arbitrary value  tbl = myreshape([0 a 1 a 1 a a a  1 b 0 b 0 b b b], ns([T R D]));  limid.CPD{D} = tabular_decision_node(limid, D,  tbl);endfname = '/home/cs/murphyk/matlab/Misc/loopybel.txt';engines = {};engines{end+1} = global_joint_inf_engine(limid);engines{end+1} = jtree_limid_inf_engine(limid);%engines{end+1} = belprop_inf_engine(limid, 'max_iter', 3*N, 'filename', fname);exact = [1 2];%approx = 3;approx = [];E = length(engines);strategy = cell(1, E);MEU = zeros(1, E);for e=1:E  [strategy{e}, MEU(e)] = solve_limid(engines{e});  MEUendMEUfor e=exact(:)'  assert(approxeq(MEU(e), 22.5))  assert(argmax(strategy{e}{T} == 1)); % test = yes  t = 1; % test = yes  for r=[2 3] % OpS, ClS    assert(argmax(squeeze(strategy{e}{D}(t,r,:))) == 1); % drill = yes  end  r = 1; % noS  assert(argmax(squeeze(strategy{e}{D}(t,r,:))) == 2); % drill = noendfor e=approx(:)'  approxeq(strategy{exact(1)}{T}, strategy{e}{T})  approxeq(strategy{exact(1)}{D}, strategy{e}{D})end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -