annotate toolboxes/FullBNT-1.0.7/bnt/inference/static/@belprop_inf_engine/Old/belprop_inf_engine_nostr.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 engine = belprop_inf_engine(fg, max_iter, momentum, tol, maximize)
wolffd@0 2
wolffd@0 3 if nargin < 2, max_iter = length(fg.G); end
wolffd@0 4 if nargin < 3, momentum = 0; end
wolffd@0 5 if nargin < 4, tol = 1e-3; end
wolffd@0 6 if nargin < 5, maximize = 0; end
wolffd@0 7
wolffd@0 8 engine.fgraph = fg;
wolffd@0 9 engine.max_iter = max_iter;
wolffd@0 10 engine.momentum = momentum;
wolffd@0 11 engine.tol = tol;
wolffd@0 12 engine.maximize = maximize;
wolffd@0 13
wolffd@0 14 % store results computed by enter_evidence here
wolffd@0 15 ndoms = length(fg.doms);
wolffd@0 16 nvars = length(fg.vars);
wolffd@0 17 engine.marginal_domains = cell(1, ndoms);
wolffd@0 18
wolffd@0 19 % to compute the marginal on each variable, we need to know which domain to marginalize
wolffd@0 20 % so we represent each domain as a bit vector, and compute its (pre-evidence) weight
wolffd@0 21 engine.dom_weight = [];
wolffd@0 22
wolffd@0 23 % engine.dom_bitv = sparse(ndoms, nvars);
wolffd@0 24 % ns = fg.node_sizes;
wolffd@0 25 % for i=1:ndoms
wolffd@0 26 % engine.dom_bitv(i, fg.doms{i}) = 1;
wolffd@0 27 % engine.dom_weight(i) = prod(ns(fg.doms{i}));
wolffd@0 28 % end
wolffd@0 29
wolffd@0 30
wolffd@0 31 engine = class(engine, 'belprop_inf_engine');