Daniel@0: function partial_order = determine_elim_constraints(bnet, onodes) Daniel@0: % DETERMINE_ELIM_CONSTRAINTS Determine what the constraints are (if any) on the elimination ordering. Daniel@0: % partial_order = determine_elim_constraints(bnet, onodes) Daniel@0: % Daniel@0: % A graph with different kinds of nodes (e.g., discrete and cts, or decision and rnd) is called marked. Daniel@0: % A strong root is guaranteed to exist if the marked graph is triangulated and does not have any paths of Daniel@0: % the form discrete -> cts -> discrete. In general we need to add extra edges to Daniel@0: % the moral graph to ensure this (see example in Lauritzen (1992) fig 3b). Daniel@0: % However, a simpler sufficient condition is to eliminate all the cts nodes before the discrete ones, Daniel@0: % because then, as we move from the leaves to the root, the cts nodes get marginalized away Daniel@0: % and we are left with purely discrete cliques. Daniel@0: % Daniel@0: % partial_order(i,j)=1 if we must marginalize j *before* i Daniel@0: % (so i will be nearer the strong root). Daniel@0: % If the hidden nodes are either all discrete or all cts, we set partial_order = []. Daniel@0: % Daniel@0: % For details, see Daniel@0: % - Jensen, Jensen and Dittmer, "From influence diagrams to junction trees", UAI 94. Daniel@0: % - Lauritzen, "Propgation of probabilities, means, and variances in mixed graphical Daniel@0: % association models", JASA 87(420):1098--1108, 1992. Daniel@0: % - K. Olesen, "Causal probabilistic networks with both discrete and continuous variables", Daniel@0: % IEEE Pami 15(3), 1993 Daniel@0: Daniel@0: Daniel@0: n = length(bnet.dag); Daniel@0: pot_type = determine_pot_type(bnet, onodes); Daniel@0: if (pot_type == 'd') | (pot_type == 'g') Daniel@0: partial_order = []; Daniel@0: return; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: partial_order = sparse(n,n); Daniel@0: partial_order(bnet.dnodes, bnet.cnodes) = 1; Daniel@0: Daniel@0: % Integrate out cts nodes before their discrete parents - see Olesen (1993) p9 Daniel@0: % This method gives the wrong results on cg1.m! Daniel@0: if 0 Daniel@0: for i=bnet.cnodes(:)' Daniel@0: dps = myintersect(parents(bnet.dag, i), bnet.dnodes); Daniel@0: partial_order(dps, i)=1; Daniel@0: end Daniel@0: end