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