annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_decision_node/tabular_decision_node.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function CPD = tabular_decision_node(bnet, self, CPT)
Daniel@0 2 % TABULAR_DECISION_NODE Represent a stochastic policy over a discrete decision/action node as a table
Daniel@0 3 % CPD = tabular_decision_node(bnet, self, CPT)
Daniel@0 4 %
Daniel@0 5 % node is the number of a node in this equivalence class.
Daniel@0 6 % CPT is an optional argument (see tabular_CPD for details); by default, it is the uniform policy.
Daniel@0 7
Daniel@0 8 if nargin==0
Daniel@0 9 % This occurs if we are trying to load an object from a file.
Daniel@0 10 CPD = init_fields;
Daniel@0 11 CPD = class(CPD, 'tabular_decision_node', discrete_CPD(1, []));
Daniel@0 12 return;
Daniel@0 13 elseif isa(bnet, 'tabular_decision_node')
Daniel@0 14 % This might occur if we are copying an object.
Daniel@0 15 CPD = bnet;
Daniel@0 16 return;
Daniel@0 17 end
Daniel@0 18 CPD = init_fields;
Daniel@0 19
Daniel@0 20 ns = bnet.node_sizes;
Daniel@0 21 fam = family(bnet.dag, self);
Daniel@0 22 ps = parents(bnet.dag, self);
Daniel@0 23 sz = ns(fam);
Daniel@0 24
Daniel@0 25 if nargin < 3
Daniel@0 26 CPT = mk_stochastic(myones(sz));
Daniel@0 27 else
Daniel@0 28 CPT = myreshape(CPT, sz);
Daniel@0 29 end
Daniel@0 30
Daniel@0 31 CPD.CPT = CPT;
Daniel@0 32 CPD.sizes = sz;
Daniel@0 33
Daniel@0 34 clamped = 1; % don't update using EM
Daniel@0 35 CPD = class(CPD, 'tabular_decision_node', discrete_CPD(clamped, ns([ps self])));
Daniel@0 36
Daniel@0 37 %%%%%%%%%%%
Daniel@0 38
Daniel@0 39 function CPD = init_fields()
Daniel@0 40 % This ensures we define the fields in the same order
Daniel@0 41 % no matter whether we load an object from a file,
Daniel@0 42 % or create it from scratch. (Matlab requires this.)
Daniel@0 43
Daniel@0 44 CPD.CPT = [];
Daniel@0 45 CPD.sizes = [];