From 8070dc963753142bb86c4ed698d91fd623ed28e7 Mon Sep 17 00:00:00 2001 From: ziejd2 Date: Thu, 28 Sep 2017 15:04:40 -0500 Subject: BNW using Octave instead of Matlab. This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02 --- .../BNT/CPDs/@tabular_decision_node/CPD_to_CPT.m | 5 +++ .../BNT/CPDs/@tabular_decision_node/CVS/Entries | 6 +++ .../CPDs/@tabular_decision_node/CVS/Entries.Log | 1 + .../BNT/CPDs/@tabular_decision_node/CVS/Repository | 1 + .../BNT/CPDs/@tabular_decision_node/CVS/Root | 1 + .../CPDs/@tabular_decision_node/Old/CVS/Entries | 2 + .../CPDs/@tabular_decision_node/Old/CVS/Repository | 1 + .../BNT/CPDs/@tabular_decision_node/Old/CVS/Root | 1 + .../Old/tabular_decision_node.m | 39 +++++++++++++++++++ .../BNT/CPDs/@tabular_decision_node/display.m | 4 ++ .../BNT/CPDs/@tabular_decision_node/get_field.m | 19 +++++++++ .../BNT/CPDs/@tabular_decision_node/set_fields.m | 19 +++++++++ .../@tabular_decision_node/tabular_decision_node.m | 45 ++++++++++++++++++++++ 13 files changed, 144 insertions(+) create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CPD_to_CPT.m create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Entries create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Entries.Log create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Repository create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Root create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Entries create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Repository create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Root create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/tabular_decision_node.m create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/display.m create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/get_field.m create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/set_fields.m create mode 100644 sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/tabular_decision_node.m (limited to 'sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node') diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CPD_to_CPT.m b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CPD_to_CPT.m new file mode 100644 index 00000000..f3509acf --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CPD_to_CPT.m @@ -0,0 +1,5 @@ +function CPT = CPD_to_CPT(CPD) +% CPD_TO_CPT Convert the tabular_decision_node to a CPT +% CPT = CPD_to_CPT(CPD) + +CPT = CPD.CPT; diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Entries b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Entries new file mode 100644 index 00000000..70a7b527 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Entries @@ -0,0 +1,6 @@ +/CPD_to_CPT.m/1.1.1.1/Wed May 29 15:59:54 2002// +/display.m/1.1.1.1/Wed May 29 15:59:54 2002// +/get_field.m/1.1.1.1/Wed May 29 15:59:54 2002// +/set_fields.m/1.1.1.1/Wed May 29 15:59:54 2002// +/tabular_decision_node.m/1.1.1.1/Wed May 29 15:59:54 2002// +D diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Entries.Log b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Entries.Log new file mode 100644 index 00000000..24f16336 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Entries.Log @@ -0,0 +1 @@ +A D/Old//// diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Repository b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Repository new file mode 100644 index 00000000..df9f8a23 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Repository @@ -0,0 +1 @@ +FullBNT/BNT/CPDs/@tabular_decision_node diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Root b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Root new file mode 100644 index 00000000..f3bd14a6 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/CVS/Root @@ -0,0 +1 @@ +:ext:nsaunier@bnt.cvs.sourceforge.net:/cvsroot/bnt diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Entries b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Entries new file mode 100644 index 00000000..f11d0269 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Entries @@ -0,0 +1,2 @@ +/tabular_decision_node.m/1.1.1.1/Wed May 29 15:59:54 2002// +D diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Repository b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Repository new file mode 100644 index 00000000..c14a3f7d --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Repository @@ -0,0 +1 @@ +FullBNT/BNT/CPDs/@tabular_decision_node/Old diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Root b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Root new file mode 100644 index 00000000..f3bd14a6 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/CVS/Root @@ -0,0 +1 @@ +:ext:nsaunier@bnt.cvs.sourceforge.net:/cvsroot/bnt diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/tabular_decision_node.m b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/tabular_decision_node.m new file mode 100644 index 00000000..7c4c26d5 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/Old/tabular_decision_node.m @@ -0,0 +1,39 @@ +function CPD = tabular_decision_node(sz, CPT) +% TABULAR_DECISION_NODE Represent the randomized policy over a discrete decision/action node as a table +% CPD = tabular_decision_node(sz, CPT) +% +% sz(1:end-1) is the sizes of the parents, sz(end) is the size of this node +% By default, CPT is set to the uniform random policy + +if nargin==0 + % This occurs if we are trying to load an object from a file. + CPD = init_fields; + CPD = class(CPD, 'tabular_decision_node'); + return; +elseif isa(sz, 'tabular_decision_node') + % This might occur if we are copying an object. + CPD = sz; + return; +end +CPD = init_fields; + +if nargin < 2 + CPT = mk_stochastic(myones(sz)); +else + CPT = myreshape(CPT, sz); +end + +CPD.CPT = CPT; +CPD.size = sz; + +CPD = class(CPD, 'tabular_decision_node'); + +%%%%%%%%%%% + +function CPD = init_fields() +% This ensures we define the fields in the same order +% no matter whether we load an object from a file, +% or create it from scratch. (Matlab requires this.) + +CPD.CPT = []; +CPD.size = []; diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/display.m b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/display.m new file mode 100644 index 00000000..a029e5d6 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/display.m @@ -0,0 +1,4 @@ +function display(CPD) + +disp('tabular decision node object'); +disp(struct(CPD)); diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/get_field.m b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/get_field.m new file mode 100644 index 00000000..24c2cedc --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/get_field.m @@ -0,0 +1,19 @@ +function vals = get_field(CPD, name) +% GET_PARAMS Get the parameters (fields) for a tabular_decision_node object +% vals = get_params(CPD, name) +% +% The following fields can be accessed +% +% policy - the table containing the policy +% +% e.g., policy = get_params(CPD, 'policy') + +args = varargin; +nargs = length(args); +for i=1:2:nargs + switch args{i}, + case 'policy', vals = CPD.CPT; + otherwise, + error(['invalid argument name ' args{i}]); + end +end diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/set_fields.m b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/set_fields.m new file mode 100644 index 00000000..4fe62292 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/set_fields.m @@ -0,0 +1,19 @@ +function CPD = set_params(CPD, varargin) +% SET_PARAMS Set the parameters (fields) for a tabular_decision_node object +% CPD = set_params(CPD, name/value pairs) +% +% The following optional arguments can be specified in the form of name/value pairs: +% +% policy - the table containing the policy +% +% e.g., CPD = set_params(CPD, 'policy', T) + +args = varargin; +nargs = length(args); +for i=1:2:nargs + switch args{i}, + case 'policy', CPD.CPT = args{i+1}; + otherwise, + error(['invalid argument name ' args{i}]); + end +end diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/tabular_decision_node.m b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/tabular_decision_node.m new file mode 100644 index 00000000..75ca5780 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_decision_node/tabular_decision_node.m @@ -0,0 +1,45 @@ +function CPD = tabular_decision_node(bnet, self, CPT) +% TABULAR_DECISION_NODE Represent a stochastic policy over a discrete decision/action node as a table +% CPD = tabular_decision_node(bnet, self, CPT) +% +% node is the number of a node in this equivalence class. +% CPT is an optional argument (see tabular_CPD for details); by default, it is the uniform policy. + +if nargin==0 + % This occurs if we are trying to load an object from a file. + CPD = init_fields; + CPD = class(CPD, 'tabular_decision_node', discrete_CPD(1, [])); + return; +elseif isa(bnet, 'tabular_decision_node') + % This might occur if we are copying an object. + CPD = bnet; + return; +end +CPD = init_fields; + +ns = bnet.node_sizes; +fam = family(bnet.dag, self); +ps = parents(bnet.dag, self); +sz = ns(fam); + +if nargin < 3 + CPT = mk_stochastic(myones(sz)); +else + CPT = myreshape(CPT, sz); +end + +CPD.CPT = CPT; +CPD.sizes = sz; + +clamped = 1; % don't update using EM +CPD = class(CPD, 'tabular_decision_node', discrete_CPD(clamped, ns([ps self]))); + +%%%%%%%%%%% + +function CPD = init_fields() +% This ensures we define the fields in the same order +% no matter whether we load an object from a file, +% or create it from scratch. (Matlab requires this.) + +CPD.CPT = []; +CPD.sizes = []; -- cgit 1.4.1