annotate _FullBNT/BNT/CPDs/@tabular_decision_node/tabular_decision_node.m @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
rev   line source
matthiasm@8 1 function CPD = tabular_decision_node(bnet, self, CPT)
matthiasm@8 2 % TABULAR_DECISION_NODE Represent a stochastic policy over a discrete decision/action node as a table
matthiasm@8 3 % CPD = tabular_decision_node(bnet, self, CPT)
matthiasm@8 4 %
matthiasm@8 5 % node is the number of a node in this equivalence class.
matthiasm@8 6 % CPT is an optional argument (see tabular_CPD for details); by default, it is the uniform policy.
matthiasm@8 7
matthiasm@8 8 if nargin==0
matthiasm@8 9 % This occurs if we are trying to load an object from a file.
matthiasm@8 10 CPD = init_fields;
matthiasm@8 11 CPD = class(CPD, 'tabular_decision_node', discrete_CPD(1, []));
matthiasm@8 12 return;
matthiasm@8 13 elseif isa(bnet, 'tabular_decision_node')
matthiasm@8 14 % This might occur if we are copying an object.
matthiasm@8 15 CPD = bnet;
matthiasm@8 16 return;
matthiasm@8 17 end
matthiasm@8 18 CPD = init_fields;
matthiasm@8 19
matthiasm@8 20 ns = bnet.node_sizes;
matthiasm@8 21 fam = family(bnet.dag, self);
matthiasm@8 22 ps = parents(bnet.dag, self);
matthiasm@8 23 sz = ns(fam);
matthiasm@8 24
matthiasm@8 25 if nargin < 3
matthiasm@8 26 CPT = mk_stochastic(myones(sz));
matthiasm@8 27 else
matthiasm@8 28 CPT = myreshape(CPT, sz);
matthiasm@8 29 end
matthiasm@8 30
matthiasm@8 31 CPD.CPT = CPT;
matthiasm@8 32 CPD.sizes = sz;
matthiasm@8 33
matthiasm@8 34 clamped = 1; % don't update using EM
matthiasm@8 35 CPD = class(CPD, 'tabular_decision_node', discrete_CPD(clamped, ns([ps self])));
matthiasm@8 36
matthiasm@8 37 %%%%%%%%%%%
matthiasm@8 38
matthiasm@8 39 function CPD = init_fields()
matthiasm@8 40 % This ensures we define the fields in the same order
matthiasm@8 41 % no matter whether we load an object from a file,
matthiasm@8 42 % or create it from scratch. (Matlab requires this.)
matthiasm@8 43
matthiasm@8 44 CPD.CPT = [];
matthiasm@8 45 CPD.sizes = [];