comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_decision_node/Old/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(sz, CPT)
2 % TABULAR_DECISION_NODE Represent the randomized policy over a discrete decision/action node as a table
3 % CPD = tabular_decision_node(sz, CPT)
4 %
5 % sz(1:end-1) is the sizes of the parents, sz(end) is the size of this node
6 % By default, CPT is set to the uniform random 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');
12 return;
13 elseif isa(sz, 'tabular_decision_node')
14 % This might occur if we are copying an object.
15 CPD = sz;
16 return;
17 end
18 CPD = init_fields;
19
20 if nargin < 2
21 CPT = mk_stochastic(myones(sz));
22 else
23 CPT = myreshape(CPT, sz);
24 end
25
26 CPD.CPT = CPT;
27 CPD.size = sz;
28
29 CPD = class(CPD, 'tabular_decision_node');
30
31 %%%%%%%%%%%
32
33 function CPD = init_fields()
34 % This ensures we define the fields in the same order
35 % no matter whether we load an object from a file,
36 % or create it from scratch. (Matlab requires this.)
37
38 CPD.CPT = [];
39 CPD.size = [];