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