comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_decision_node/tabular_decision_node.m @ 0:e9a9cd732c1e tip

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