wolffd@0: function CPD = tabular_decision_node(sz, CPT) wolffd@0: % TABULAR_DECISION_NODE Represent the randomized policy over a discrete decision/action node as a table wolffd@0: % CPD = tabular_decision_node(sz, CPT) wolffd@0: % wolffd@0: % sz(1:end-1) is the sizes of the parents, sz(end) is the size of this node wolffd@0: % By default, CPT is set to the uniform random policy wolffd@0: wolffd@0: if nargin==0 wolffd@0: % This occurs if we are trying to load an object from a file. wolffd@0: CPD = init_fields; wolffd@0: CPD = class(CPD, 'tabular_decision_node'); wolffd@0: return; wolffd@0: elseif isa(sz, 'tabular_decision_node') wolffd@0: % This might occur if we are copying an object. wolffd@0: CPD = sz; wolffd@0: return; wolffd@0: end wolffd@0: CPD = init_fields; wolffd@0: wolffd@0: if nargin < 2 wolffd@0: CPT = mk_stochastic(myones(sz)); wolffd@0: else wolffd@0: CPT = myreshape(CPT, sz); wolffd@0: end wolffd@0: wolffd@0: CPD.CPT = CPT; wolffd@0: CPD.size = sz; wolffd@0: wolffd@0: CPD = class(CPD, 'tabular_decision_node'); wolffd@0: wolffd@0: %%%%%%%%%%% wolffd@0: wolffd@0: function CPD = init_fields() wolffd@0: % This ensures we define the fields in the same order wolffd@0: % no matter whether we load an object from a file, wolffd@0: % or create it from scratch. (Matlab requires this.) wolffd@0: wolffd@0: CPD.CPT = []; wolffd@0: CPD.size = [];