wolffd@0: function CPD = tabular_decision_node(bnet, self, CPT) wolffd@0: % TABULAR_DECISION_NODE Represent a stochastic policy over a discrete decision/action node as a table wolffd@0: % CPD = tabular_decision_node(bnet, self, CPT) wolffd@0: % wolffd@0: % node is the number of a node in this equivalence class. wolffd@0: % CPT is an optional argument (see tabular_CPD for details); by default, it is the uniform policy. wolffd@0: wolffd@0: if nargin==0 wolffd@0: % This occurs if we are trying to load an object from a file. wolffd@0: CPD = init_fields; wolffd@0: CPD = class(CPD, 'tabular_decision_node', discrete_CPD(1, [])); wolffd@0: return; wolffd@0: elseif isa(bnet, 'tabular_decision_node') wolffd@0: % This might occur if we are copying an object. wolffd@0: CPD = bnet; wolffd@0: return; wolffd@0: end wolffd@0: CPD = init_fields; wolffd@0: wolffd@0: ns = bnet.node_sizes; wolffd@0: fam = family(bnet.dag, self); wolffd@0: ps = parents(bnet.dag, self); wolffd@0: sz = ns(fam); wolffd@0: wolffd@0: if nargin < 3 wolffd@0: CPT = mk_stochastic(myones(sz)); wolffd@0: else wolffd@0: CPT = myreshape(CPT, sz); wolffd@0: end wolffd@0: wolffd@0: CPD.CPT = CPT; wolffd@0: CPD.sizes = sz; wolffd@0: wolffd@0: clamped = 1; % don't update using EM wolffd@0: CPD = class(CPD, 'tabular_decision_node', discrete_CPD(clamped, ns([ps self]))); wolffd@0: wolffd@0: %%%%%%%%%%% wolffd@0: wolffd@0: function CPD = init_fields() wolffd@0: % This ensures we define the fields in the same order wolffd@0: % no matter whether we load an object from a file, wolffd@0: % or create it from scratch. (Matlab requires this.) wolffd@0: wolffd@0: CPD.CPT = []; wolffd@0: CPD.sizes = [];