To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / _FullBNT / BNT / CPDs / @tabular_decision_node / Old / tabular_decision_node.m @ 8:b5b38998ef3b

History | View | Annotate | Download (1005 Bytes)

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 = [];