about summary refs log tree commit diff
path: root/sourcecodes/parameter_learning
diff options
context:
space:
mode:
Diffstat (limited to 'sourcecodes/parameter_learning')
-rw-r--r--sourcecodes/parameter_learning/Predictmultiple.m57
-rw-r--r--sourcecodes/parameter_learning/Predictmultipleintrvention.m73
-rw-r--r--sourcecodes/parameter_learning/checkDiscreteNodes.m37
-rw-r--r--sourcecodes/parameter_learning/checkStructure.m78
-rw-r--r--sourcecodes/parameter_learning/drawFigure.m383
-rw-r--r--sourcecodes/parameter_learning/drawFigureM.m258
-rw-r--r--sourcecodes/parameter_learning/getParams.m22
-rw-r--r--sourcecodes/parameter_learning/parameterLearning.m17
-rw-r--r--sourcecodes/parameter_learning/readInput.m70
-rw-r--r--sourcecodes/parameter_learning/readInputData.m75
-rw-r--r--sourcecodes/parameter_learning/readInputStructure.m72
-rw-r--r--sourcecodes/parameter_learning/runBN_initial.m98
-rw-r--r--sourcecodes/parameter_learning/standardizeData.m25
-rw-r--r--sourcecodes/parameter_learning/test/Agbcontinuous_input.txt103
-rw-r--r--sourcecodes/parameter_learning/test/Agbmap.txt6
-rw-r--r--sourcecodes/parameter_learning/test/Agbmapdata.txt1
-rw-r--r--sourcecodes/parameter_learning/test/Agbnet_figure.txt440
-rw-r--r--sourcecodes/parameter_learning/test/Agbnet_figure.txt.bk440
-rw-r--r--sourcecodes/parameter_learning/test/Agbnnode.txt1
-rw-r--r--sourcecodes/parameter_learning/test/Agbstructure_input.txt7
-rw-r--r--sourcecodes/parameter_learning/test/octave-corebin0 -> 247702 bytes
21 files changed, 2263 insertions, 0 deletions
diff --git a/sourcecodes/parameter_learning/Predictmultiple.m b/sourcecodes/parameter_learning/Predictmultiple.m
new file mode 100644
index 00000000..692c6b24
--- /dev/null
+++ b/sourcecodes/parameter_learning/Predictmultiple.m
@@ -0,0 +1,57 @@
+function Predictmultiple(pre)
+
+dfile=strcat(pre,'structure_input.txt');
+sfile=dfile;
+dfile=strcat(pre,'continuous_input.txt');
+nnodefile=strcat(pre,'nnode.txt');
+fnnode = fopen(nnodefile,'r');
+nnodes = fscanf(fnnode,'%d');
+
+
+
+%nnodes=5;
+Std_flag=true;
+[labels,cases,bnet]=readInput(dfile,sfile,nnodes,Std_flag);
+
+
+%name
+%labels
+%map
+
+[bnet]=parameterLearning(bnet,cases);
+%[predict_mean,predict_sd,q_sq]=looCrossValid(bnet,cases);
+fvarfile=strcat(pre,'var.txt');
+
+fvar = fopen(fvarfile,'r');
+                            
+select_var_new = fscanf(fvar,'%d');
+
+fvardfile=strcat(pre,'vardata.txt');
+
+fvard = fopen(fvardfile,'r');
+
+select_var_data_new = fscanf(fvard,'%f');
+
+filename=strcat(pre,'net_figure_new.txt');
+
+drawFigureM(nnodes,bnet,labels,filename,cases,select_var_new,select_var_data_new);
+
+%quit force;
+%marginal_nodes(engine,2)
+%marginal_nodes(engine,3)
+%marginal_nodes(engine,4)
+%marginal_nodes(engine,5)
+%evidence{1}=2;
+%[engine,loglik]=enter_evidence(engine,evidence)
+%marginal_nodes(engine,1)
+%marginal_nodes(engine,2)
+%marginal_nodes(engine,3)
+%marginal_nodes(engine,4)
+%marginal_nodes(engine,5)
+%evidence{2}=0.6;
+%evidence{1}=[];
+%[engine,loglik]=enter_evidence(engine,evidence);
+%marginal_nodes(engine,3);
+%marginal_nodes(engine,4);
+%marginal_nodes(engine,5);
+end
\ No newline at end of file
diff --git a/sourcecodes/parameter_learning/Predictmultipleintrvention.m b/sourcecodes/parameter_learning/Predictmultipleintrvention.m
new file mode 100644
index 00000000..d3d509cb
--- /dev/null
+++ b/sourcecodes/parameter_learning/Predictmultipleintrvention.m
@@ -0,0 +1,73 @@
+function Predictmultipleintrvention(pre)
+dfile=strcat(pre,'structure_input.txt');
+sfile=dfile;
+dfile=strcat(pre,'continuous_input.txt');
+nnodefile=strcat(pre,'nnode.txt');
+
+fnnode = fopen(nnodefile,'r');
+nnodes = fscanf(fnnode,'%d');
+
+fvarnamefile=strcat(pre,'varname.txt');
+
+varfile = fopen(fvarnamefile,'r');
+
+%nnodes=5;
+Std_flag=true;
+[labels,cases,bnet]=readInput(dfile,sfile,nnodes,Std_flag);
+[bnet]=parameterLearning(bnet,cases);
+
+%[predict_mean,predict_sd,q_sq]=looCrossValid(bnet,cases);
+
+
+fvarfile=strcat(pre,'var.txt');
+fvar = fopen(fvarfile,'r');
+                            
+select_var_new = fscanf(fvar,'%d');
+
+nm = numel(select_var_new);
+
+varlabels = cell(1,nm);
+varbuffer = fgetl(varfile);    %get header line as a string
+for j=1:nm
+    [varnext,varbuffer] = strtok(varbuffer);
+    varlabels{j} = varnext;
+    for i=1:nnodes    
+        if strcmp(varlabels{j},labels{i})
+            select_var_new(j)=i;
+        end
+     end    
+    
+end
+
+
+
+
+fvardfile=strcat(pre,'vardata.txt');
+
+fvard = fopen(fvardfile,'r');
+
+select_var_data_new = fscanf(fvard,'%f');
+
+filename=strcat(pre,'net_figure_new.txt');
+
+drawFigureM(nnodes,bnet,labels,filename,cases,select_var_new,select_var_data_new);
+
+%quit force;
+%marginal_nodes(engine,2)
+%marginal_nodes(engine,3)
+%marginal_nodes(engine,4)
+%marginal_nodes(engine,5)
+%evidence{1}=2;
+%[engine,loglik]=enter_evidence(engine,evidence)
+%marginal_nodes(engine,1)
+%marginal_nodes(engine,2)
+%marginal_nodes(engine,3)
+%marginal_nodes(engine,4)
+%marginal_nodes(engine,5)
+%evidence{2}=0.6;
+%evidence{1}=[];
+%[engine,loglik]=enter_evidence(engine,evidence);
+%marginal_nodes(engine,3);
+%marginal_nodes(engine,4);
+%marginal_nodes(engine,5);
+end
\ No newline at end of file
diff --git a/sourcecodes/parameter_learning/checkDiscreteNodes.m b/sourcecodes/parameter_learning/checkDiscreteNodes.m
new file mode 100644
index 00000000..c9d0692c
--- /dev/null
+++ b/sourcecodes/parameter_learning/checkDiscreteNodes.m
@@ -0,0 +1,37 @@
+function [ ] = checkDiscreteNodes( bnet, cases)
+    %checkDiscreteNodes Checks if states of discrete nodes are be integers from 1 to M
+    %   where M is the number of states of the node.  (M should be the same as
+    %   node_sizes in the bnet).
+    % 
+    %Input:
+    %   bnet: BNT bnet
+    %   cases: cell array of data
+    %
+%
+node_sizes = bnet.node_sizes;
+dnodes = bnet.dnodes;
+ndisc = size(dnodes,2);
+ncases = size(cases,2);
+
+%check to see that all data for discrete nodes are integers
+for i = 1:ndisc
+    inode = dnodes(i);
+    data = cases(inode,:);
+    isize = node_sizes(inode);
+    states = zeros(1,isize);
+    for j = 1:isize
+        states(j) = j;
+    end
+    for j = 1:ncases
+        k = int64(data{j});
+        if ~any(k==states)
+            error(['Discrete nodes must be integers from 1 to the number of states']);
+        end
+    end
+end
+
+    
+end
+
+
+
diff --git a/sourcecodes/parameter_learning/checkStructure.m b/sourcecodes/parameter_learning/checkStructure.m
new file mode 100644
index 00000000..5931c187
--- /dev/null
+++ b/sourcecodes/parameter_learning/checkStructure.m
@@ -0,0 +1,78 @@
+function [ labels, cases, dag, node_sizes, ord_flag ] = checkStructure(labels, cases, dag, node_sizes)
+    %checkStructure Check to see if nodes are sorted correctly.  They must be
+    %   in topological order (i.e., parents before children) before parameter
+    %   learning can take place.
+    %
+    %Input and output have the same meaning.  The output has just been
+    %topologically ordered.
+    %   labels = cell array with the names of the nodes.
+    %   cases = cell array with the data.
+    %   dag = matrix with the strucutre of the network.
+    %   node_sizes = vector with the size of each node.
+
+%make connections array
+%count how big you need the connections array to be
+nnodes = size(dag,1);
+narcs = 0;
+for i = 1:nnodes
+    for j = 1:nnodes
+        if dag(i,j) == 1
+            narcs = narcs + 1;
+        end
+    end
+end
+%fill connections array with label names
+connections = cell(narcs,2);
+ncount = 0;
+for i = 1:nnodes
+    for j = 1:nnodes
+        if dag(i,j) == 1
+            ncount = ncount + 1;
+            connections{ncount,1} = labels{i};
+            connections{ncount,2} = labels{j};
+        end
+    end
+end
+
+%get topologically sorted dag and labels
+[new_dag, new_labels] = mk_adj_mat(connections, labels, 1);
+
+%check to see if order changed
+ord_flag = 0;
+for i = 1:nnodes
+    if ~strcmp(new_labels{i},labels{i})
+        ord_flag = 1;
+    end
+end
+
+if ord_flag
+    %get new ordering of nodes
+    order = cell(1,nnodes);
+    for i = 1:nnodes
+        for j = 1:nnodes
+            if strcmp(new_labels{j},labels{i})
+                order{i} = j;
+            end
+        end
+    end
+
+    %reorder cases and node_sizes
+    new_cases = cell(size(cases));
+    for i = 1:nnodes
+        new_cases(order{i},:) = cases(i,:);
+    end
+    new_node_sizes = zeros(1,nnodes);
+    for i = 1:nnodes
+        new_node_sizes(order{i}) = node_sizes(i);
+    end
+
+
+    dag = new_dag;
+    cases = new_cases;
+    node_sizes = new_node_sizes;
+    labels = new_labels;    
+end
+
+end
+%end checkStructure.m
+
diff --git a/sourcecodes/parameter_learning/drawFigure.m b/sourcecodes/parameter_learning/drawFigure.m
new file mode 100644
index 00000000..76979b3e
--- /dev/null
+++ b/sourcecodes/parameter_learning/drawFigure.m
@@ -0,0 +1,383 @@
+function [] = drawFigure(nnodes,bnet,labels,filename,cases,selectvar,selectdata)
+%drawFigure writes the parameters and data that are needed to draw the
+%structure of a Bayesian network.
+
+if nargin < 6,
+    drawFigureNoEv(nnodes,bnet,labels,filename,cases);
+else
+    drawFigureEv(nnodes,bnet,labels,filename,cases,selectvar,selectdata);
+end;
+
+end
+
+
+
+function [] = drawFigureEv(nnodes,bnet,labels,filename,cases,selectvar,selectdata)
+%Function to use if there is no entered evidence. 
+%         
+%
+%Before each printed line, I will have a line that starts with %%%
+% that describes what will be on that line
+
+%Create an empty evidence cell array.
+
+%val=cases;
+%for i = 1:nnodes
+% val(i,1)=val(i,2);
+
+%end
+
+A=cell2mat(cases');
+Amax=max(A);
+Amin=min(A);
+
+
+evidence = cell(1,nnodes);
+engine = jtree_inf_engine(bnet);
+
+evidence{selectvar}=selectdata;
+
+[engine,loglik]=enter_evidence(engine,evidence);
+
+%Open the file, and write the nodes to a file.
+fileID = fopen(filename,'w');
+
+%%%%Evidence node
+fprintf(fileID,'%i\n',selectvar);
+%%% The number of nodes
+fprintf(fileID,'%i\n',nnodes);
+%Get canvas size
+labels_temp = cellstr(labels);
+[x,y] = make_layout(bnet.dag);
+
+x = x - min(x);
+y = 1 - y;
+y = y - min(y);
+
+[x_dim,y_dim] = canvasSize(nnodes,x,y);
+
+%%% The dimensions of the canvas for the javascript code
+fprintf(fileID,'%i\t%i\t\n',x_dim,y_dim)
+
+x = x*x_dim;
+y = y*y_dim;
+for i = 1:nnodes,
+%%% The name and X- and Y-positions of each node
+    fprintf(fileID,'%s\t%i\t%i\n',labels{i},round(x(i)),round(y(i)));
+end
+
+%Get the number of parents and children for each node.
+num_par = zeros(1,nnodes);
+%For parents, sum down columns
+for i = 1:nnodes,
+    for j = 1:nnodes,
+        if bnet.dag(j,i) == 1,
+            num_par(i) = num_par(i) + 1;
+        end
+    end
+end
+num_child = zeros(1,nnodes);
+for i = 1:nnodes,
+    for j = 1:nnodes,
+        if bnet.dag(i,j) == 1,
+            num_child(i) = num_child(i) + 1;
+        end
+    end
+end
+
+
+for i = 1:nnodes,
+    %%% The name and type of each node (1=continuous, the number of states
+    %%% if it is discrete
+    fprintf(fileID,'%s\t%i\n',labels{i},bnet.node_sizes(i));
+    %%% The size of the node, I am going to keep them 
+    %%% 250(width) by 150(height) for now
+    %Could modify this to change the width based on the length of the node
+    %name
+    fprintf(fileID,'%i\t%i\n',250,150);
+    %%% The number of parents of the node, and the parents
+    if num_par(i) == 0;
+        %%% If no parents:
+        fprintf(fileID,'%i\n',num_par(i));
+    else
+        parents = zeros(1,num_par(i));
+        k = 1;
+        for j = 1:nnodes,
+           if bnet.dag(j,i) == 1,
+             parents(1,k) = j;
+             k = k + 1;
+           end
+        end
+        format = '%i\t';
+        for j = 1:num_par(i)-1,
+            format = strcat(format,'%i\t');
+        end
+        format = strcat(format,'%i\n');
+        %%%If there are parents:
+        fprintf(fileID,format,num_par(i),parents(1,:));
+    end
+    
+    
+    %%% The number of children of the node, and the children
+    if num_child(i) == 0;
+        %%% If no children:
+        fprintf(fileID,'%i\n',num_child(i));
+    else
+        children = zeros(1,num_child(i));
+        k = 1;
+        for j = 1:nnodes,
+           if bnet.dag(i,j) == 1,
+             children(1,k) = j;
+             k = k + 1;
+           end
+        end
+        format = '%i\t';
+        for j = 1:num_child(i)-1,
+            format = strcat(format,'%i\t');
+        end
+        format = strcat(format,'%i\n');
+        %%%If there are parents:
+        fprintf(fileID,format,num_child(i),children(1,:));
+    end
+    
+    predict = marginal_nodes(engine,i);
+    if isempty(evidence{i})
+      if bnet.node_sizes(i) ~= 1,
+        for j = 1:bnet.node_sizes(i),
+            %%%For discrete nodes, the state and the percent of that state
+            fprintf(fileID,'%i\t%6.4f\n',j,predict.T(j));
+        end;
+      else
+
+        [x_vals,y_vals] = calcGaussian(predict.mu,predict.Sigma,Amax(i),Amin(i));
+        %%%For continuous nodes, print x and the pdf of a normal curve.
+        for j = 1:101,
+            fprintf(fileID,'%6.4f\t%6.4f\n',x_vals(j,1),y_vals(j,1));
+        end;
+      end;
+    else
+      fprintf(fileID,'%6.4f\t%6.4f\n',selectdata,1);
+    end
+    
+end
+%fprintf(fileID,'%s\t %\n',labels_temp{:});
+
+
+fclose(fileID);
+
+end
+
+
+
+
+
+
+function [] = drawFigureNoEv(nnodes,bnet,labels,filename,cases)
+%Function to use if there is no entered evidence. 
+%         
+%
+%Before each printed line, I will have a line that starts with %%%
+% that describes what will be on that line
+A=cell2mat(cases');
+Amax=max(A);
+Amin=min(A);
+
+%Create an empty evidence cell array.
+evidence = cell(1,nnodes);
+engine = jtree_inf_engine(bnet);
+[engine,loglik] = enter_evidence(engine,evidence);
+
+%Open the file, and write the nodes to a file.
+fileID = fopen(filename,'w');
+%%% The number of nodes
+fprintf(fileID,'%i\n',nnodes);
+
+%Get canvas size
+
+labels_temp = cellstr(labels);
+[x,y] = make_layout(bnet.dag);
+%[x,y] = layout_dag(bnet.dag);
+
+
+x = x - min(x);
+y = 1 - y;
+y = y - min(y);
+
+[x_dim,y_dim] = canvasSize(nnodes,x,y);
+
+%%% The dimensions of the canvas for the javascript code
+fprintf(fileID,'%i\t%i\t\n',x_dim,y_dim)
+
+x = x*x_dim;
+y = y*y_dim;
+for i = 1:nnodes,
+%%% The name and X- and Y-positions of each node
+    fprintf(fileID,'%s\t%i\t%i\n',labels{i},round(x(i)),round(y(i)));
+end
+
+%Get the number of parents and children for each node.
+num_par = zeros(1,nnodes);
+%For parents, sum down columns
+for i = 1:nnodes,
+    for j = 1:nnodes,
+        if bnet.dag(j,i) == 1,
+            num_par(i) = num_par(i) + 1;
+        end
+    end
+end
+num_child = zeros(1,nnodes);
+for i = 1:nnodes,
+    for j = 1:nnodes,
+        if bnet.dag(i,j) == 1,
+            num_child(i) = num_child(i) + 1;
+        end
+    end
+end
+
+
+for i = 1:nnodes,
+    %%% The name and type of each node (1=continuous, the number of states
+    %%% if it is discrete
+    fprintf(fileID,'%s\t%i\n',labels{i},bnet.node_sizes(i));
+    %%% The size of the node, I am going to keep them 
+    %%% 250(width) by 150(height) for now
+    %Could modify this to change the width based on the length of the node
+    %name
+    fprintf(fileID,'%i\t%i\n',250,150);
+    %%% The number of parents of the node, and the parents
+    if num_par(i) == 0;
+        %%% If no parents:
+        fprintf(fileID,'%i\n',num_par(i));
+    else
+        parents = zeros(1,num_par(i));
+        k = 1;
+        for j = 1:nnodes,
+           if bnet.dag(j,i) == 1,
+             parents(1,k) = j;
+             k = k + 1;
+           end
+        end
+        format = '%i\t';
+        for j = 1:num_par(i)-1,
+            format = strcat(format,'%i\t');
+        end
+        format = strcat(format,'%i\n');
+        %%%If there are parents:
+        fprintf(fileID,format,num_par(i),parents(1,:));
+    end
+    
+    
+    %%% The number of children of the node, and the children
+    if num_child(i) == 0;
+        %%% If no children:
+        fprintf(fileID,'%i\n',num_child(i));
+    else
+        children = zeros(1,num_child(i));
+        k = 1;
+        for j = 1:nnodes,
+           if bnet.dag(i,j) == 1,
+             children(1,k) = j;
+             k = k + 1;
+           end
+        end
+        format = '%i\t';
+        for j = 1:num_child(i)-1,
+            format = strcat(format,'%i\t');
+        end
+        format = strcat(format,'%i\n');
+        %%%If there are parents:
+        fprintf(fileID,format,num_child(i),children(1,:));
+    end
+    
+    predict = marginal_nodes(engine,i);
+    if bnet.node_sizes(i) ~= 1,
+        for j = 1:bnet.node_sizes(i),
+            %%%For discrete nodes, the state and the percent of that state
+            fprintf(fileID,'%i\t%6.4f\n',j,predict.T(j));
+        end;
+    else
+        %cases(i)
+       % MAX(cases(i))
+       % MIN(cases(i))
+        [x_vals,y_vals] = calcGaussian(predict.mu,predict.Sigma,Amax(i),Amin(i));
+        %%%For continuous nodes, print x and the pdf of a normal curve.
+        for j = 1:101,
+            fprintf(fileID,'%6.4f\t%6.4f\n',x_vals(j,1),y_vals(j,1));
+        end;
+    end;
+end
+%fprintf(fileID,'%s\t %\n',labels_temp{:});
+
+
+fclose(fileID);
+
+end
+
+
+function [x_dim, y_dim] = canvasSize(nnodes,x,y)
+%canvasSize Function to calculate the size of the canvas to
+%           build the network structure
+
+
+%I am going to assume that the node size will be
+% height = 150, width = 250
+% so there will be a node spacing of 
+% 200 (in y-dim) and 300 (in x-dim).
+y_space = 200;
+x_space = 300;
+
+%Set default minimum x and y dimensions
+x_dim = 1200;
+y_dim = 1200;
+
+%get unique y values
+y_unique = unique(y);
+size_y = size(y_unique,2);
+y_dim_temp = size_y*y_space;
+
+%get the maximum nodes in any layer
+size_x = zeros(1,size_y);
+for i = 1:size_y,
+    for j = 1:nnodes,
+        if y_unique(i) == y(j),
+            size_x(1,i) = size_x(1,i) + 1;
+        end;
+    end;
+end;
+size_x = max(size_x);
+x_dim_temp = size_x*x_space;
+
+if x_dim_temp > x_dim,
+    x_dim = x_dim_temp;
+end;
+
+if y_dim_temp > y_dim,
+    y_dim = y_dim_temp;
+end;
+end
+
+function [x_vals,y_vals] = calcGaussian(mu,Sigma,maxval,minval)
+%Function to calculate 101 points of Gaussian function to use in plotting
+% Gets the probability density of the mean value and 50 evenly spaced
+% points up to 3Sigma below the mean and 50 evenly space points up to
+% 3Sigma above the mean.
+%maxval
+%minval
+x_vals = zeros(101,1);
+y_vals = zeros(101,1);
+
+%x_vals(1,1) = mu - 3*Sigma;
+x_vals(1,1) = minval - 1;
+gap=((maxval+1)-(minval - 1))/100;
+%x_vals(1,1) = 0;%mu - 3*Sigma;
+for i = 1:100,
+   % x_vals(i+1,1) = x_vals(1,1) + i*6*Sigma/100;
+    x_vals(i+1,1) = x_vals(i,1) + gap;
+ %x_vals(i+1,1) = x_vals(i,1) + 1/100;
+end
+
+for i = 1:101,
+    y_vals(i,1) = normpdf(x_vals(i,1),mu,Sigma);
+end
+
+end
diff --git a/sourcecodes/parameter_learning/drawFigureM.m b/sourcecodes/parameter_learning/drawFigureM.m
new file mode 100644
index 00000000..95a27634
--- /dev/null
+++ b/sourcecodes/parameter_learning/drawFigureM.m
@@ -0,0 +1,258 @@
+function [] = drawFigureM(nnodes,bnet,labels,filename,cases,selectvar,selectdata)
+%drawFigure writes the parameters and data that are needed to draw the
+%structure of a Bayesian network.
+
+
+%Function to use if there is no entered evidence. 
+%         
+%
+%Before each printed line, I will have a line that starts with %%%
+% that describes what will be on that line
+
+%Create an empty evidence cell array.
+
+%val=cases;
+%for i = 1:nnodes
+% val(i,1)=val(i,2);
+
+%end
+
+fileID = fopen(filename,'w');
+
+
+A=cell2mat(cases');
+Amax=max(A);
+Amin=min(A);
+
+
+evidence = cell(1,nnodes);
+engine = jtree_inf_engine(bnet);
+
+m = size(selectvar,1);
+
+
+ev_dat = zeros(1,nnodes);
+%For parents, sum down columns
+for i = 1:m,
+    di=selectvar(i,1);
+    ev_dat(di)=selectdata(i,1);   
+    
+    evidence{di}=ev_dat(di);
+    fprintf(fileID,'%i\t',di);
+end
+fprintf(fileID,'\n');
+
+%ev_dat
+
+% select_var = selectvar(1,1)
+% 
+% select_var_data = selectdata(1,1)
+% 
+% 
+% evidence{select_var}=select_var_data;
+
+[engine,loglik]=enter_evidence(engine,evidence);
+
+%Open the file, and write the nodes to a file.
+
+
+%%%%Evidence node
+
+%%% The number of nodes
+fprintf(fileID,'%i\n',nnodes);
+%Get canvas size
+labels_temp = cellstr(labels);
+[x,y] = make_layout(bnet.dag);
+
+x = x - min(x);
+y = 1 - y;
+y = y - min(y);
+
+[x_dim,y_dim] = canvasSize(nnodes,x,y);
+
+%%% The dimensions of the canvas for the javascript code
+fprintf(fileID,'%i\t%i\t\n',x_dim,y_dim)
+
+x = x*x_dim;
+y = y*y_dim;
+for i = 1:nnodes,
+%%% The name and X- and Y-positions of each node
+    fprintf(fileID,'%s\t%i\t%i\n',labels{i},round(x(i)),round(y(i)));
+end
+
+%Get the number of parents and children for each node.
+num_par = zeros(1,nnodes);
+%For parents, sum down columns
+for i = 1:nnodes,
+    for j = 1:nnodes,
+        if bnet.dag(j,i) == 1,
+            num_par(i) = num_par(i) + 1;
+        end
+    end
+end
+num_child = zeros(1,nnodes);
+for i = 1:nnodes,
+    for j = 1:nnodes,
+        if bnet.dag(i,j) == 1,
+            num_child(i) = num_child(i) + 1;
+        end
+    end
+end
+
+
+for i = 1:nnodes,
+    %%% The name and type of each node (1=continuous, the number of states
+    %%% if it is discrete
+    fprintf(fileID,'%s\t%i\n',labels{i},bnet.node_sizes(i));
+    %%% The size of the node, I am going to keep them 
+    %%% 250(width) by 150(height) for now
+    %Could modify this to change the width based on the length of the node
+    %name
+    fprintf(fileID,'%i\t%i\n',250,150);
+    %%% The number of parents of the node, and the parents
+    if num_par(i) == 0;
+        %%% If no parents:
+        fprintf(fileID,'%i\n',num_par(i));
+    else
+        parents = zeros(1,num_par(i));
+        k = 1;
+        for j = 1:nnodes,
+           if bnet.dag(j,i) == 1,
+             parents(1,k) = j;
+             k = k + 1;
+           end
+        end
+        format = '%i\t';
+        for j = 1:num_par(i)-1,
+            format = strcat(format,'%i\t');
+        end
+        format = strcat(format,'%i\n');
+        %%%If there are parents:
+        fprintf(fileID,format,num_par(i),parents(1,:));
+    end
+    
+    
+    %%% The number of children of the node, and the children
+    if num_child(i) == 0;
+        %%% If no children:
+        fprintf(fileID,'%i\n',num_child(i));
+    else
+        children = zeros(1,num_child(i));
+        k = 1;
+        for j = 1:nnodes,
+           if bnet.dag(i,j) == 1,
+             children(1,k) = j;
+             k = k + 1;
+           end
+        end
+        format = '%i\t';
+        for j = 1:num_child(i)-1,
+            format = strcat(format,'%i\t');
+        end
+        format = strcat(format,'%i\n');
+        %%%If there are parents:
+        fprintf(fileID,format,num_child(i),children(1,:));
+    end
+    
+    predict = marginal_nodes(engine,i);
+    if isempty(evidence{i})
+      if bnet.node_sizes(i) ~= 1,
+        for j = 1:bnet.node_sizes(i),
+            %%%For discrete nodes, the state and the percent of that state
+            fprintf(fileID,'%i\t%6.4f\n',j,predict.T(j));
+        end;
+      else
+
+        [x_vals,y_vals] = calcGaussian(predict.mu,predict.Sigma,Amax(i),Amin(i));
+        %%%For continuous nodes, print x and the pdf of a normal curve.
+        for j = 1:101,
+            fprintf(fileID,'%6.4f\t%6.4f\n',x_vals(j,1),y_vals(j,1));
+        end;
+      end;
+    else
+      fprintf(fileID,'%6.4f\t%6.4f\n',ev_dat(i),1);
+    end
+    
+end
+%fprintf(fileID,'%s\t %\n',labels_temp{:});
+
+
+fclose(fileID);
+
+end
+
+
+
+
+
+
+
+
+
+function [x_dim, y_dim] = canvasSize(nnodes,x,y)
+%canvasSize Function to calculate the size of the canvas to
+%           build the network structure
+
+
+%I am going to assume that the node size will be
+% height = 150, width = 250
+% so there will be a node spacing of 
+% 200 (in y-dim) and 300 (in x-dim).
+y_space = 200;
+x_space = 300;
+
+%Set default minimum x and y dimensions
+x_dim = 1200;
+y_dim = 1200;
+
+%get unique y values
+y_unique = unique(y);
+size_y = size(y_unique,2);
+y_dim_temp = size_y*y_space;
+
+%get the maximum nodes in any layer
+size_x = zeros(1,size_y);
+for i = 1:size_y,
+    for j = 1:nnodes,
+        if y_unique(i) == y(j),
+            size_x(1,i) = size_x(1,i) + 1;
+        end;
+    end;
+end;
+size_x = max(size_x);
+x_dim_temp = size_x*x_space;
+
+if x_dim_temp > x_dim,
+    x_dim = x_dim_temp;
+end;
+
+if y_dim_temp > y_dim,
+    y_dim = y_dim_temp;
+end;
+end
+
+function [x_vals,y_vals] = calcGaussian(mu,Sigma,maxval,minval)
+%Function to calculate 101 points of Gaussian function to use in plotting
+% Gets the probability density of the mean value and 50 evenly spaced
+% points up to 3Sigma below the mean and 50 evenly space points up to
+% 3Sigma above the mean.
+%maxval
+%minval
+x_vals = zeros(101,1);
+y_vals = zeros(101,1);
+
+%x_vals(1,1) = mu - 3*Sigma;
+x_vals(1,1) = minval - 1;
+gap=((maxval+1)-(minval - 1))/100;
+%x_vals(1,1) = 0;%mu - 3*Sigma;
+for i = 1:100,
+   % x_vals(i+1,1) = x_vals(1,1) + i*6*Sigma/100;
+    x_vals(i+1,1) = x_vals(i,1) + gap;
+ %x_vals(i+1,1) = x_vals(i,1) + 1/100;
+end
+
+for i = 1:101,
+    y_vals(i,1) = normpdf(x_vals(i,1),mu,Sigma);
+end
+
+end
diff --git a/sourcecodes/parameter_learning/getParams.m b/sourcecodes/parameter_learning/getParams.m
new file mode 100644
index 00000000..31f84ffb
--- /dev/null
+++ b/sourcecodes/parameter_learning/getParams.m
@@ -0,0 +1,22 @@
+function [ bnet ] = getParams( bnet, cases )
+%getParams Code to initialize CPT and do parameter learning.
+%This will be very basic for now.  I can add more options later.
+
+dnodes = bnet.dnodes;
+cnodes = bnet.cnodes;
+nnodes = size(dnodes,2)+size(cnodes,2);
+
+%make dnodes tabular_CPT
+for i = 1:size(dnodes,2)
+    bnet.CPD{dnodes(i)} = tabular_CPD(bnet,dnodes(i));
+end
+
+for i = 1:size(cnodes,2)
+    bnet.CPD{cnodes(i)} = gaussian_CPD(bnet,cnodes(i));
+end
+
+bnet = learn_params(bnet,cases);
+
+
+end
+
diff --git a/sourcecodes/parameter_learning/parameterLearning.m b/sourcecodes/parameter_learning/parameterLearning.m
new file mode 100644
index 00000000..872e94b1
--- /dev/null
+++ b/sourcecodes/parameter_learning/parameterLearning.m
@@ -0,0 +1,17 @@
+function [ bnet ] = parameterLearning( bnet,cases,engine_name )
+%parameterLearning Do parameter learning and inference
+
+%engine is an optional argument
+if nargin < 3
+    engine_name = 'jtree_inf_engine';
+end
+
+
+%First do parameter learning with all the data
+[bnet] = getParams(bnet,cases);
+
+
+
+
+end
+
diff --git a/sourcecodes/parameter_learning/readInput.m b/sourcecodes/parameter_learning/readInput.m
new file mode 100644
index 00000000..9d4959b8
--- /dev/null
+++ b/sourcecodes/parameter_learning/readInput.m
@@ -0,0 +1,70 @@
+function [ labels, cases, bnet, node_sizes, data,labelsold] = readInput( dfile, sfile, nnodes, std_flag )
+    %readInput is to be used when reading in a network with a known structure
+    %   
+    %Input:
+	%   dfile  = name of the file containing the data (required)
+    %   sfile = name of the file containing the structure (required)
+    %   nnodes = number of nodes in the network (required)
+    %   std_flag = flag for whether or not to standardize the data.
+    %   (optional-- Default is FALSE)
+    %
+    %   See readInputData.m and readInputStructure.m for description of the
+    %       format of the dfile and sfile, respectively. 
+    %
+    %Output:
+    %   labels = cell array with the names of the nodes.
+    %   cases = cell array with the data.
+    %   bnet = BNT bayesian network with the input structure.
+
+if nargin < 4
+    std_flag = false(1);
+end
+
+    
+% read in the file with the data
+[labelsold,node_sizes,cases, data] = readInputData(dfile,nnodes);
+
+
+
+
+% read in the file with the structure
+[dag] = readInputStructure(sfile,labelsold);
+
+
+% check the ordering of the nodes and reorder if necessary
+[labels,cases,dag,node_sizes,ord_flag] = checkStructure(labelsold,cases,dag,node_sizes);
+%draw_graph(dag,labels);
+%if ord_flag == 1
+%    fprintf(['Order of nodes was changed to agree with topological order\n'])
+%end
+%fprintf(['The structure of the network should be correctly displayed in a figure\n'])
+
+dcount = 0;
+for i = 1:nnodes
+    if node_sizes(i) ~= 1
+        dcount = dcount + 1;
+    end
+end
+discrete = zeros(1,dcount);
+dcount = 0;
+for i = 1:nnodes
+    if node_sizes(i) ~= 1
+        dcount = dcount + 1;
+        discrete(dcount) = i;
+    end
+end
+
+bnet = mk_bnet(dag,node_sizes,'discrete',discrete,'names',labels);
+
+%bnet.dag
+
+checkDiscreteNodes(bnet,cases);
+
+% standardize continuous data to have a mean = 0 and std = 1
+if (std_flag)
+    [cases] = standardizeData(labels,node_sizes,cases);
+end
+        
+
+end
+%  end of readInput.m
\ No newline at end of file
diff --git a/sourcecodes/parameter_learning/readInputData.m b/sourcecodes/parameter_learning/readInputData.m
new file mode 100644
index 00000000..706e2751
--- /dev/null
+++ b/sourcecodes/parameter_learning/readInputData.m
@@ -0,0 +1,75 @@
+function  [ labels , node_sizes, cases, data] = readInputData( dfile , nnodes )
+	%  readColData  reads data from a file containing data in columns
+	%               that have text titles, and possibly other header text
+	%   
+	%  Input:
+	%     dfile  = name of the file containing the data.(required)
+	%     nnodes  = number of columns in the data file.  (required)
+    %
+    %   Function assumes the following format for the input file:
+    %       1) First line has labels for each of the nodes.  There cannot
+    %              be spaces in any node label.
+    %       2) The next line is the "node_sizes" of the nodes.  If the 
+    %           nodes are discrete, this number will be equal to the number
+    %           of states.  If the nodes are continuous, they should be 
+    %           equal to 1.  The function assumes that any nodes with
+    %           node_size = 1 is continuous.
+    %       3) The rest of the file is numeric data.  The data in the input
+    %               data has the number of columns equal to the number of 
+    %               nodes in the network and the number of rows equal to
+    %               the number of samples.
+    %
+    %
+	%  Output:
+	%     labels = cell array with node (column) labels.
+    %     node_sizes  =  vector with the size of each node
+    %     cases = cell array with the data.  The cases array is transposed
+    %       in comparison with the input data to agree with the format of
+    %       cell data used in BNT.
+
+%  open file for input, include error handling
+fin = fopen(dfile,'r');
+if fin < 0
+   error(['Could not open ',dfile,' for input']);
+end
+
+% Read in first line to get the node labels.
+labels = cell(1,nnodes);
+buffer = fgetl(fin);    %get header line as a string
+for j=1:nnodes
+    [next,buffer] = strtok(buffer);
+    labels{j} = next;
+end
+
+%  Read in the data.  Use the vetorized fscanf function to load all
+%  numerical values into one vector.  Then reshape this vector into a
+%  matrix.
+
+data = fscanf(fin,'%f');  %  Load the numerical values into one long vector
+
+
+
+
+nd = length(data);        %  total number of data points
+nr = nd/nnodes;            %  number of rows; check (next statement) to make sure
+if nr ~= round(nd/nnodes)
+   fprintf(1,'\ndata: nrow = %f\tncol = %d\n',nr,nnodes);
+   fprintf(1,'number of data points = %d does not equal nrow*ncol\n',nd);
+   error('data is not rectangular')
+end
+
+data = reshape(data,nnodes,nr)';   %  have to transpose the reshaped array
+
+
+node_sizes = zeros(1,nnodes);
+for j = 1:nnodes
+    node_sizes(j) = data(1,j);
+end
+
+nr = nr - 1;
+data(1,:) = [];
+cases = cell(nnodes,nr);
+cases(:,:) = num2cell(data');
+
+end
+%  end of readInputData.m
\ No newline at end of file
diff --git a/sourcecodes/parameter_learning/readInputStructure.m b/sourcecodes/parameter_learning/readInputStructure.m
new file mode 100644
index 00000000..6b3cbece
--- /dev/null
+++ b/sourcecodes/parameter_learning/readInputStructure.m
@@ -0,0 +1,72 @@
+function [ dag ] = readInputStructure( sfile, labels )
+%readInputStructure Read in file with structure information
+    %   
+    %Input:
+	%     sfile  = name of the file containing the data (required)
+	%     labels = cell array with node labels. (required)
+    %     nnodes  = number of columns in the data file. (required)  
+    %
+    %   Function assumes the following format for the structure input file:
+    %       1) The first line has node labels.  These must be the same as 
+    %           in the input data file.  They cannot contain spaces.
+    %       2) The remainder of the file contains the structure of the dag.
+    %           The structure of a graph is a N-by-N matrix, where N is the
+    %           number of nodes.  There are 1's in the matrix representing
+    %           parent-child relationships.  For each 1, the row indicates
+    %           the parent and the column indicates the child.  For
+    %           example, a 1 in the (2,3) position of the matrix indicates
+    %           that there is an arc pointing from node 2 to node 3.
+    %        
+    %
+	%  Output:
+    %     dag = matrix with the structure.
+%
+%   Read in first line of the structure file
+%  open file for input, include error handling
+fin = fopen(sfile,'r');
+if fin < 0
+   error(['Could not open ',sfile,' for input']);
+end
+
+nnodes = size(labels,2);
+% Read in first line to get the node labels.
+labels_test = cell(1,nnodes);
+buffer = fgetl(fin);    %get header line as a string
+for j=1:nnodes
+    [next,buffer] = strtok(buffer);
+    labels_test{j} = next;  
+end
+    
+for j=1:nnodes
+    if labels_test{j} ~= labels{j}
+        fprintf(['Label of node ',j,' is not consistent in input and structure files'])
+    end
+end
+
+data = fscanf(fin,'%f');
+  
+nd = length(data);        %  total number of data points
+nr = nd/nnodes;            %  number of rows; check (next statement) to make sure
+if nr ~= round(nd/nnodes)
+   fprintf(1,'\ndata: nrow = %f\tncol = %d\n',nr,nnodes);
+   fprintf(1,'number of data points = %d does not equal nrow*ncol\n',nd);
+   error('Structure file does not have the correct dimensions (1)')
+end
+% check to make sure that structure is square
+if nr ~= nnodes
+    error('Structure file does not have the correct dimensions (2)')
+end
+
+data = reshape(data,nnodes,nr)';   %  have to transpose the reshaped array
+
+
+dag = zeros(nnodes,nnodes);
+for i = 1:size(data,1)
+    for j = 1:size(data,2)
+        dag(i,j) = data(i,j);
+    end
+end
+
+
+end
+%  end of readInputStructure.m
diff --git a/sourcecodes/parameter_learning/runBN_initial.m b/sourcecodes/parameter_learning/runBN_initial.m
new file mode 100644
index 00000000..789b4260
--- /dev/null
+++ b/sourcecodes/parameter_learning/runBN_initial.m
@@ -0,0 +1,98 @@
+function runBN_initial(pre)
+sfile=strcat(pre,'structure_input.txt');
+dfile=strcat(pre,'continuous_input.txt');
+
+nnodefile=strcat(pre,'nnode.txt');
+fnnode = fopen(nnodefile,'r');
+nnodes = fscanf(fnnode,'%d');
+
+
+mapfilename=strcat(pre,'mapdata.txt');
+mapvalfilename=strcat(pre,'map.txt');
+
+mapfile = fopen(mapfilename,'w');
+
+mapval = fopen(mapvalfilename,'w');
+
+
+%nnodes=5;
+Std_flag=true;
+[labels,cases,bnet,node_sizes,data,labelsold]=readInput(dfile,sfile,nnodes,Std_flag);
+s = std(data,0,1);
+m=mean(data);
+
+
+for i=1:nnodes
+  fprintf(mapval,'%s\t%d\t%f\t%f\n',labelsold{i},node_sizes(i),s(i),m(i));
+end
+
+
+% for j=1:nnodes
+%     [next,buffer] = strtok(buffer);
+%     name{j}=next;
+%     for i=1:nnodes    
+%         if strcmp(name{j},labels{i})
+%             map{j}=i;
+%             fprintf(mapfile,'%d\t',i);
+%         end
+%      end
+% end
+%name
+%labels
+%map
+fprintf(mapfile,'%s',labels{1});
+for i=2:nnodes
+  fprintf(mapfile,'\t%s',labels{i});
+end
+fprintf(mapfile,'\n');
+
+[bnet]=parameterLearning(bnet,cases);
+%[predict_mean,predict_sd,q_sq]=looCrossValid(bnet,cases);
+%engine=jtree_inf_engine(bnet);
+%evidence=cell(1,nnodes);
+
+%varfile='var.txt';
+%fvar = fopen(varfile,'r');
+%select_var = fscanf(fvar,'%d');
+%select_var=map{select_var};
+%varfiled='vardata.txt';
+%fvard = fopen(varfiled,'r');
+%select_var_data = fscanf(fvard,'%f');
+
+%evidence{select_var}=select_var_data;
+%[engine,loglik]=enter_evidence(engine,evidence);
+
+%outdata='prediction.txt';
+%fout = fopen(outdata,'w');
+
+%for ii = 1:nnodes 
+ % i=map{ii};
+ % data=marginal_nodes(engine,i);
+ % fprintf(fout,'%d\t%d\t%f\t%f\t%f\n',ii,data.domain,data.T,data.mu,data.Sigma);
+  %fprintf(1,'%d\n',i);
+% end
+
+filename=strcat(pre,'net_figure.txt');
+drawFigure(nnodes,bnet,labels,filename,cases);
+
+%quit force;
+%marginal_nodes(engine,2)
+%marginal_nodes(engine,3)
+%marginal_nodes(engine,4)
+%marginal_nodes(engine,5)
+%evidence{1}=2;
+%[engine,loglik]=enter_evidence(engine,evidence)
+%marginal_nodes(engine,1)
+%marginal_nodes(engine,2)
+%marginal_nodes(engine,3)
+%marginal_nodes(engine,4)
+%marginal_nodes(engine,5)
+%evidence{2}=0.6;
+%evidence{1}=[];
+%[engine,loglik]=enter_evidence(engine,evidence);
+%marginal_nodes(engine,3);
+%marginal_nodes(engine,4);
+%marginal_nodes(engine,5);
+fclose(mapval);
+fclose(mapfile);
+end
\ No newline at end of file
diff --git a/sourcecodes/parameter_learning/standardizeData.m b/sourcecodes/parameter_learning/standardizeData.m
new file mode 100644
index 00000000..61ea280e
--- /dev/null
+++ b/sourcecodes/parameter_learning/standardizeData.m
@@ -0,0 +1,25 @@
+function [ cases ] = standardizeData( labels, node_sizes, cases )
+%standardizeData standardizes continuous nodes so they have a mean = 0
+%   and standard deviation = 1
+%   Detailed explanation goes here
+
+nnodes = size(labels,2);
+
+%fprintf(['Standardizing data for continuous nodes\n'])
+for i = 1:nnodes
+    if node_sizes(i) == 1
+        temp = cell2num(cases(i,:));
+        [temp] = standardize(temp);
+        cases(i,:) = num2cell(temp);
+    end
+end
+
+%write standardized data to file
+%fprintf(['Standardized data is written to file standardized_data.txt\n'])
+%fout = 'standardized_data.txt';
+%txt = sprintf([repmat('%s\t',1,size(labels,2))],labels{:});
+%dlmwrite(fout,txt,'');
+%dlmwrite(fout,cell2num(cases'),'-append','delimiter','\t');
+
+end
+
diff --git a/sourcecodes/parameter_learning/test/Agbcontinuous_input.txt b/sourcecodes/parameter_learning/test/Agbcontinuous_input.txt
new file mode 100644
index 00000000..bcd9b88c
--- /dev/null
+++ b/sourcecodes/parameter_learning/test/Agbcontinuous_input.txt
@@ -0,0 +1,103 @@
+GenotypeA	GenotypeB	Gene1	Gene2	Gene3	Gene4
+2	2	1	1	1	1
+1	1	0.0735451012188	0.807744827105	-0.141557122166	0.871977046116
+2	1	0.0783291492541	0.784023461068	0.501395957396	1.20598627055
+2	1	0.786243065384	0.978600201012	1.10615045137	0.91427570527
+2	1	-0.133165253244	1.09368397217	0.943147613583	1.28625182746
+2	1	0.849732696834	0.701697179341	1.1597647359	1.10898527576
+2	1	0.117358779641	1.27641582521	1.07600246132	0.837957699405
+1	2	0.260845541489	0.126507267356	0.134953769296	1.05166904426
+2	1	0.277734881926	1.07193390309	0.282304188176	1.11305323003
+1	2	0.23482774261	1.22992089679	0.0929753295409	1.16341704702
+1	2	0.948183366714	0.133267523413	-0.218162396333	0.906540379337
+2	1	-0.116613369121	1.14203606435	0.109901766308	0.729527128692
+1	1	-0.179825551391	0.10619275827	0.937787825497	1.03567603615
+2	1	0.293022973091	1.08721255661	-0.175473007708	0.887010836361
+2	1	-0.0489346771642	0.968137836317	0.107834185199	0.896061918536
+1	2	0.236140871956	-0.0428030926592	-0.318492104268	0.570552965391
+2	2	-0.0800211950407	0.69984329873	0.188143588172	1.31042305844
+1	1	-0.0036838396465	0.115049518621	1.23342471413	-0.0310668924648
+1	2	0.821596343182	-0.206883091797	-0.176745465075	1.00503814188
+2	1	0.968136985881	0.17393492998	1.10355204542	1.50730341194
+1	1	-0.2529273487	1.15825296446	-0.296758267158	0.334353609539
+2	2	0.996924729837	0.79867304131	-0.0654588195254	1.14114632703
+1	1	1.11517699739	1.04475472944	1.01515337419	-0.114835981744
+1	1	1.13306628335	0.212806963119	-0.331850695159	1.3262481351
+2	1	-0.202717212277	1.16180466017	0.698481134231	0.837229654056
+2	1	1.09703628172	0.988374730515	0.632905281073	0.871944778559
+1	1	0.0877178138353	0.92193353301	0.0882061186606	-0.109998053824
+2	2	-0.0465657805556	1.0562741142	0.203076906226	0.947081854544
+1	1	0.253626344342	0.774666759107	0.160237735682	0.137119974017
+2	2	0.958504778114	0.696202219462	0.837104986151	1.22862239026
+2	1	0.0190762231091	1.07363361357	0.836517352782	1.13138357074
+1	2	1.04546343625	1.22248653304	-0.177641501681	0.938273372293
+1	1	-0.356538939133	0.926691569307	-0.0141334158342	-0.333256032191
+2	2	-0.271616290794	1.02237907773	-0.0893323176884	1.13812703435
+1	1	0.112310230451	0.96903715979	0.735229019751	0.0718376819618
+2	2	-0.0541760888203	0.910562906664	0.237421737724	1.12792106072
+2	1	0.140510085427	1.14598129626	0.684754216604	1.37711161908
+1	2	0.673132921769	1.16156481777	0.828299174842	1.23484148864
+1	1	-0.36576911038	1.22402806897	0.985794473424	0.371258195776
+2	1	1.30745593323	-0.305709792671	1.18778090128	0.773246386727
+2	2	-0.530650832006	1.12852174836	-0.242830565653	0.83833485032
+1	1	-0.291997112416	-0.0207658889693	0.172776752193	0.36694855027
+1	2	-0.161225357475	1.16418585274	0.00727443800449	1.1352882361
+2	2	1.30343435031	0.732902323978	-0.172844997755	0.874662524376
+2	2	0.85539635481	1.29119106621	0.016024964511	1.13160810191
+1	2	0.839799562146	-0.0698184772979	0.064736024742	0.888230930115
+1	2	0.95789577351	-0.0042439536723	0.0555580748795	1.07993651996
+1	1	1.32802494815	-0.214047314771	0.329813058688	0.728172901439
+1	1	-0.200890919169	1.1000313421	1.04401630691	0.0521627161216
+2	2	0.937448394951	1.08384634906	-0.0899239635102	1.07443211017
+2	1	-0.0666111295973	0.607978461697	0.178977027858	0.996958995079
+2	1	0.98988279173	0.936124382141	1.16162098	0.953396718798
+1	1	0.783923131778	-0.185782423384	0.234091790401	1.05701020406
+1	1	0.761503655241	1.10820714005	0.784532435857	-0.125970126396
+2	1	-0.0961115621732	0.992263342859	0.660910916217	0.963055169574
+2	2	-0.154764213109	0.730891518005	-0.109545565909	1.12272967655
+2	2	0.0479283751395	0.928564948748	0.0947967021058	0.98105799191
+2	2	1.39168552274	0.128331277089	0.10146975109	1.24231428304
+1	1	0.976982771784	-0.146928630221	-0.0608841220423	0.972841874016
+2	1	1.15485099166	0.935197552788	0.965011443377	1.34264634759
+1	2	-0.166427006522	0.213464027262	-0.031343375005	0.8119490745
+2	1	0.602325327176	1.47360525321	1.40368030116	0.887287145417
+1	2	1.12050355207	1.18852964108	0.0704081979976	1.19584630693
+2	1	0.702485774332	1.15988608636	0.294782678413	0.751491248655
+1	2	0.155516690813	0.251086517248	0.975388704705	0.688269967741
+1	2	0.038035346805	0.682904829816	0.0951645619842	0.665389726903
+1	1	0.339450864189	0.116879724658	-0.170951058396	-0.370117675216
+2	2	-0.108372250446	0.696218715139	-0.00428297700477	0.961335352653
+2	2	0.0146712646232	1.12798531635	0.778687243129	1.27150673153
+1	2	0.704617012215	1.08526662881	0.799187464816	1.13063944956
+1	1	1.10224639633	1.09684843311	1.13580106237	0.186395861041
+1	1	1.13687210336	0.592984795387	0.20048850526	-0.0553656796539
+1	2	0.0632700472019	0.864610771614	-0.242802029698	0.848811159682
+2	1	0.0451786925492	1.33573290418	0.92973441898	-0.344011193096
+1	2	1.26061879295	1.09499325896	0.0222202420765	0.847629840625
+1	2	0.91681254794	0.290800393334	-0.0719474399104	0.926496648214
+2	1	1.2172426262	0.951648627857	1.25202262128	0.233889527648
+1	2	1.05048646769	0.172566561404	0.0550162349302	0.750079764855
+1	2	0.675366500637	-0.0673050997098	0.1645804156	0.781063579107
+2	1	0.204088201674	0.886512802356	1.05795947541	0.185790058971
+2	1	-0.100901351663	0.714436170991	-0.505529978858	0.647306701065
+1	2	0.907207625417	1.16174653049	-0.155199134127	0.747382222584
+1	2	0.0672106257479	0.603637849323	-0.140625204522	1.08080017243
+2	1	1.2385313097	1.0695347389	-0.176990709153	0.848256839162
+1	2	0.186923583294	0.119157644078	0.0349289573077	0.744803259527
+1	2	1.09352177593	0.194715059877	0.0236391004662	0.499673191061
+2	1	-0.376369481804	0.985546924317	0.0945527339598	0.948918281956
+1	1	1.18474855816	-0.115831486698	0.283152200427	0.970403352935
+2	2	1.15179008534	1.11293520284	0.221811798026	0.999871011204
+1	2	-0.270193067228	1.1546656712	-0.244378116913	0.671654326382
+2	2	0.439331185377	1.12197569445	0.258362973013	1.11146143747
+2	2	1.01095806207	0.745930460781	-0.0409015639874	1.14791250376
+2	1	-0.26402775558	1.0189980863	0.0142629520115	0.959203836932
+1	1	1.1622683144	-0.0120889455187	1.07714267283	-0.177584275215
+1	1	0.942340790264	0.254818931717	0.0587741977709	0.980453538135
+2	2	0.106324819492	0.79161883369	-0.16526611256	0.916230483749
+2	1	1.19278065887	0.913551161988	-0.0956615348665	1.05953140511
+1	1	0.99020996204	-0.0516709802571	0.785783698942	1.47690006823
+2	1	1.1566705292	1.05878794929	0.0968404106402	0.827720917511
+1	2	0.05207115921	-0.252341077617	-0.0848699551554	1.19139462554
+2	2	0.991086851115	-0.301180892331	-0.00253197995383	1.46608138294
+
diff --git a/sourcecodes/parameter_learning/test/Agbmap.txt b/sourcecodes/parameter_learning/test/Agbmap.txt
new file mode 100644
index 00000000..bb1dd64f
--- /dev/null
+++ b/sourcecodes/parameter_learning/test/Agbmap.txt
@@ -0,0 +1,6 @@
+GenotypeA	2	0.502519	1.500000
+GenotypeB	1	0.500908	1.460000
+Gene1	2	0.553536	0.475371
+Gene2	1	0.485907	0.701417
+Gene3	1	0.485352	0.313494
+Gene4	1	0.435265	0.819489
diff --git a/sourcecodes/parameter_learning/test/Agbmapdata.txt b/sourcecodes/parameter_learning/test/Agbmapdata.txt
new file mode 100644
index 00000000..fa8be0bd
--- /dev/null
+++ b/sourcecodes/parameter_learning/test/Agbmapdata.txt
@@ -0,0 +1 @@
+GenotypeB	Gene3	GenotypeA	Gene2	Gene4	Gene1
diff --git a/sourcecodes/parameter_learning/test/Agbnet_figure.txt b/sourcecodes/parameter_learning/test/Agbnet_figure.txt
new file mode 100644
index 00000000..8243b7d9
--- /dev/null
+++ b/sourcecodes/parameter_learning/test/Agbnet_figure.txt
@@ -0,0 +1,440 @@
+6
+1200	1200	
+GenotypeB	0	0
+Gene3	120	300
+GenotypeA	400	0
+Gene2	520	300
+Gene4	0	600
+Gene1	400	600
+GenotypeB	2
+250	150
+0
+2	2	5
+1	0.5400
+2	0.4600
+Gene3	1
+250	150
+1	1
+0
+-2.6875	0.0108
+-2.6281	0.0126
+-2.5688	0.0147
+-2.5095	0.0171
+-2.4501	0.0198
+-2.3908	0.0229
+-2.3315	0.0263
+-2.2721	0.0302
+-2.2128	0.0345
+-2.1535	0.0393
+-2.0941	0.0445
+-2.0348	0.0503
+-1.9754	0.0567
+-1.9161	0.0636
+-1.8568	0.0712
+-1.7974	0.0793
+-1.7381	0.0881
+-1.6788	0.0975
+-1.6194	0.1075
+-1.5601	0.1181
+-1.5008	0.1294
+-1.4414	0.1412
+-1.3821	0.1535
+-1.3227	0.1663
+-1.2634	0.1796
+-1.2041	0.1932
+-1.1447	0.2072
+-1.0854	0.2214
+-1.0261	0.2357
+-0.9667	0.2500
+-0.9074	0.2643
+-0.8480	0.2784
+-0.7887	0.2923
+-0.7294	0.3058
+-0.6700	0.3187
+-0.6107	0.3311
+-0.5514	0.3427
+-0.4920	0.3535
+-0.4327	0.3633
+-0.3734	0.3721
+-0.3140	0.3797
+-0.2547	0.3862
+-0.1953	0.3914
+-0.1360	0.3953
+-0.0767	0.3978
+-0.0173	0.3989
+0.0420	0.3986
+0.1013	0.3969
+0.1607	0.3938
+0.2200	0.3894
+0.2793	0.3837
+0.3387	0.3767
+0.3980	0.3686
+0.4574	0.3593
+0.5167	0.3491
+0.5760	0.3380
+0.6354	0.3260
+0.6947	0.3134
+0.7540	0.3002
+0.8134	0.2866
+0.8727	0.2726
+0.9320	0.2584
+0.9914	0.2441
+1.0507	0.2297
+1.1101	0.2154
+1.1694	0.2014
+1.2287	0.1875
+1.2881	0.1740
+1.3474	0.1609
+1.4067	0.1483
+1.4661	0.1362
+1.5254	0.1246
+1.5848	0.1136
+1.6441	0.1033
+1.7034	0.0935
+1.7628	0.0844
+1.8221	0.0759
+1.8814	0.0680
+1.9408	0.0607
+2.0001	0.0540
+2.0594	0.0479
+2.1188	0.0423
+2.1781	0.0372
+2.2375	0.0326
+2.2968	0.0285
+2.3561	0.0249
+2.4155	0.0216
+2.4748	0.0187
+2.5341	0.0161
+2.5935	0.0138
+2.6528	0.0118
+2.7121	0.0101
+2.7715	0.0086
+2.8308	0.0073
+2.8902	0.0061
+2.9495	0.0052
+3.0088	0.0043
+3.0682	0.0036
+3.1275	0.0030
+3.1868	0.0025
+3.2462	0.0021
+GenotypeA	2
+250	150
+0
+2	4	5
+1	0.5000
+2	0.5000
+Gene2	1
+250	150
+1	3
+2	5	6
+-3.0727	0.0036
+-3.0161	0.0042
+-2.9594	0.0050
+-2.9028	0.0059
+-2.8462	0.0069
+-2.7896	0.0081
+-2.7330	0.0095
+-2.6763	0.0111
+-2.6197	0.0129
+-2.5631	0.0149
+-2.5065	0.0172
+-2.4499	0.0198
+-2.3933	0.0228
+-2.3366	0.0260
+-2.2800	0.0297
+-2.2234	0.0337
+-2.1668	0.0381
+-2.1102	0.0431
+-2.0535	0.0484
+-1.9969	0.0543
+-1.9403	0.0607
+-1.8837	0.0677
+-1.8271	0.0752
+-1.7705	0.0832
+-1.7138	0.0919
+-1.6572	0.1011
+-1.6006	0.1108
+-1.5440	0.1211
+-1.4874	0.1320
+-1.4307	0.1434
+-1.3741	0.1552
+-1.3175	0.1675
+-1.2609	0.1802
+-1.2043	0.1932
+-1.1476	0.2065
+-1.0910	0.2200
+-1.0344	0.2336
+-0.9778	0.2473
+-0.9212	0.2610
+-0.8646	0.2745
+-0.8079	0.2878
+-0.7513	0.3008
+-0.6947	0.3134
+-0.6381	0.3255
+-0.5815	0.3369
+-0.5248	0.3476
+-0.4682	0.3575
+-0.4116	0.3665
+-0.3550	0.3746
+-0.2984	0.3816
+-0.2418	0.3875
+-0.1851	0.3922
+-0.1285	0.3957
+-0.0719	0.3979
+-0.0153	0.3989
+0.0413	0.3986
+0.0980	0.3970
+0.1546	0.3942
+0.2112	0.3901
+0.2678	0.3849
+0.3244	0.3785
+0.3810	0.3710
+0.4377	0.3625
+0.4943	0.3531
+0.5509	0.3428
+0.6075	0.3317
+0.6641	0.3200
+0.7208	0.3077
+0.7774	0.2949
+0.8340	0.2818
+0.8906	0.2683
+0.9472	0.2547
+1.0039	0.2410
+1.0605	0.2274
+1.1171	0.2138
+1.1737	0.2003
+1.2303	0.1872
+1.2869	0.1743
+1.3436	0.1618
+1.4002	0.1497
+1.4568	0.1381
+1.5134	0.1269
+1.5700	0.1163
+1.6267	0.1063
+1.6833	0.0967
+1.7399	0.0878
+1.7965	0.0794
+1.8531	0.0716
+1.9097	0.0644
+1.9664	0.0577
+2.0230	0.0516
+2.0796	0.0459
+2.1362	0.0407
+2.1928	0.0360
+2.2495	0.0318
+2.3061	0.0279
+2.3627	0.0245
+2.4193	0.0214
+2.4759	0.0186
+2.5326	0.0161
+2.5892	0.0140
+Gene4	1
+250	150
+3	1	3	4
+0
+-3.7331	0.0009
+-3.6699	0.0011
+-3.6068	0.0014
+-3.5437	0.0016
+-3.4805	0.0020
+-3.4174	0.0024
+-3.3543	0.0029
+-3.2911	0.0035
+-3.2280	0.0042
+-3.1649	0.0050
+-3.1017	0.0059
+-3.0386	0.0070
+-2.9755	0.0083
+-2.9123	0.0097
+-2.8492	0.0114
+-2.7861	0.0133
+-2.7229	0.0154
+-2.6598	0.0179
+-2.5967	0.0206
+-2.5335	0.0238
+-2.4704	0.0273
+-2.4073	0.0312
+-2.3441	0.0355
+-2.2810	0.0403
+-2.2179	0.0455
+-2.1547	0.0513
+-2.0916	0.0577
+-2.0285	0.0645
+-1.9653	0.0720
+-1.9022	0.0800
+-1.8391	0.0886
+-1.7759	0.0978
+-1.7128	0.1075
+-1.6497	0.1178
+-1.5865	0.1287
+-1.5234	0.1401
+-1.4603	0.1519
+-1.3971	0.1642
+-1.3340	0.1768
+-1.2709	0.1897
+-1.2077	0.2029
+-1.1446	0.2162
+-1.0815	0.2296
+-1.0183	0.2430
+-0.9552	0.2563
+-0.8921	0.2693
+-0.8290	0.2820
+-0.7658	0.2943
+-0.7027	0.3061
+-0.6396	0.3172
+-0.5764	0.3275
+-0.5133	0.3371
+-0.4502	0.3456
+-0.3870	0.3532
+-0.3239	0.3597
+-0.2608	0.3650
+-0.1976	0.3691
+-0.1345	0.3719
+-0.0714	0.3735
+-0.0082	0.3737
+0.0549	0.3727
+0.1180	0.3703
+0.1812	0.3667
+0.2443	0.3618
+0.3074	0.3558
+0.3706	0.3486
+0.4337	0.3404
+0.4968	0.3312
+0.5600	0.3212
+0.6231	0.3103
+0.6862	0.2988
+0.7494	0.2867
+0.8125	0.2741
+0.8756	0.2612
+0.9388	0.2480
+1.0019	0.2347
+1.0650	0.2213
+1.1282	0.2079
+1.1913	0.1947
+1.2544	0.1816
+1.3176	0.1689
+1.3807	0.1565
+1.4438	0.1445
+1.5070	0.1329
+1.5701	0.1219
+1.6332	0.1113
+1.6964	0.1014
+1.7595	0.0920
+1.8226	0.0831
+1.8858	0.0749
+1.9489	0.0673
+2.0120	0.0602
+2.0752	0.0536
+2.1383	0.0477
+2.2014	0.0422
+2.2646	0.0372
+2.3277	0.0327
+2.3908	0.0287
+2.4540	0.0250
+2.5171	0.0218
+2.5802	0.0189
+Gene1	1
+250	150
+1	4
+0
+-2.8174	0.0076
+-2.7627	0.0088
+-2.7080	0.0102
+-2.6533	0.0119
+-2.5985	0.0137
+-2.5438	0.0158
+-2.4891	0.0181
+-2.4343	0.0207
+-2.3796	0.0236
+-2.3249	0.0268
+-2.2702	0.0304
+-2.2154	0.0344
+-2.1607	0.0387
+-2.1060	0.0435
+-2.0512	0.0488
+-1.9965	0.0545
+-1.9418	0.0607
+-1.8871	0.0674
+-1.8323	0.0746
+-1.7776	0.0823
+-1.7229	0.0906
+-1.6682	0.0994
+-1.6134	0.1087
+-1.5587	0.1185
+-1.5040	0.1289
+-1.4492	0.1397
+-1.3945	0.1510
+-1.3398	0.1627
+-1.2851	0.1748
+-1.2303	0.1872
+-1.1756	0.2000
+-1.1209	0.2129
+-1.0661	0.2260
+-1.0114	0.2392
+-0.9567	0.2524
+-0.9020	0.2656
+-0.8472	0.2786
+-0.7925	0.2914
+-0.7378	0.3038
+-0.6830	0.3158
+-0.6283	0.3273
+-0.5736	0.3383
+-0.5189	0.3485
+-0.4641	0.3580
+-0.4094	0.3667
+-0.3547	0.3744
+-0.2999	0.3811
+-0.2452	0.3869
+-0.1905	0.3915
+-0.1358	0.3950
+-0.0810	0.3974
+-0.0263	0.3985
+0.0284	0.3985
+0.0832	0.3973
+0.1379	0.3949
+0.1926	0.3913
+0.2473	0.3867
+0.3021	0.3809
+0.3568	0.3741
+0.4115	0.3663
+0.4663	0.3577
+0.5210	0.3481
+0.5757	0.3379
+0.6304	0.3269
+0.6852	0.3154
+0.7399	0.3033
+0.7946	0.2909
+0.8493	0.2781
+0.9041	0.2651
+0.9588	0.2519
+1.0135	0.2387
+1.0683	0.2255
+1.1230	0.2124
+1.1777	0.1995
+1.2324	0.1867
+1.2872	0.1743
+1.3419	0.1622
+1.3966	0.1505
+1.4514	0.1393
+1.5061	0.1285
+1.5608	0.1181
+1.6155	0.1083
+1.6703	0.0990
+1.7250	0.0902
+1.7797	0.0820
+1.8345	0.0743
+1.8892	0.0671
+1.9439	0.0604
+1.9986	0.0543
+2.0534	0.0486
+2.1081	0.0433
+2.1628	0.0386
+2.2176	0.0342
+2.2723	0.0303
+2.3270	0.0267
+2.3817	0.0235
+2.4365	0.0206
+2.4912	0.0180
+2.5459	0.0157
+2.6007	0.0136
+2.6554	0.0118
diff --git a/sourcecodes/parameter_learning/test/Agbnet_figure.txt.bk b/sourcecodes/parameter_learning/test/Agbnet_figure.txt.bk
new file mode 100644
index 00000000..8243b7d9
--- /dev/null
+++ b/sourcecodes/parameter_learning/test/Agbnet_figure.txt.bk
@@ -0,0 +1,440 @@
+6
+1200	1200	
+GenotypeB	0	0
+Gene3	120	300
+GenotypeA	400	0
+Gene2	520	300
+Gene4	0	600
+Gene1	400	600
+GenotypeB	2
+250	150
+0
+2	2	5
+1	0.5400
+2	0.4600
+Gene3	1
+250	150
+1	1
+0
+-2.6875	0.0108
+-2.6281	0.0126
+-2.5688	0.0147
+-2.5095	0.0171
+-2.4501	0.0198
+-2.3908	0.0229
+-2.3315	0.0263
+-2.2721	0.0302
+-2.2128	0.0345
+-2.1535	0.0393
+-2.0941	0.0445
+-2.0348	0.0503
+-1.9754	0.0567
+-1.9161	0.0636
+-1.8568	0.0712
+-1.7974	0.0793
+-1.7381	0.0881
+-1.6788	0.0975
+-1.6194	0.1075
+-1.5601	0.1181
+-1.5008	0.1294
+-1.4414	0.1412
+-1.3821	0.1535
+-1.3227	0.1663
+-1.2634	0.1796
+-1.2041	0.1932
+-1.1447	0.2072
+-1.0854	0.2214
+-1.0261	0.2357
+-0.9667	0.2500
+-0.9074	0.2643
+-0.8480	0.2784
+-0.7887	0.2923
+-0.7294	0.3058
+-0.6700	0.3187
+-0.6107	0.3311
+-0.5514	0.3427
+-0.4920	0.3535
+-0.4327	0.3633
+-0.3734	0.3721
+-0.3140	0.3797
+-0.2547	0.3862
+-0.1953	0.3914
+-0.1360	0.3953
+-0.0767	0.3978
+-0.0173	0.3989
+0.0420	0.3986
+0.1013	0.3969
+0.1607	0.3938
+0.2200	0.3894
+0.2793	0.3837
+0.3387	0.3767
+0.3980	0.3686
+0.4574	0.3593
+0.5167	0.3491
+0.5760	0.3380
+0.6354	0.3260
+0.6947	0.3134
+0.7540	0.3002
+0.8134	0.2866
+0.8727	0.2726
+0.9320	0.2584
+0.9914	0.2441
+1.0507	0.2297
+1.1101	0.2154
+1.1694	0.2014
+1.2287	0.1875
+1.2881	0.1740
+1.3474	0.1609
+1.4067	0.1483
+1.4661	0.1362
+1.5254	0.1246
+1.5848	0.1136
+1.6441	0.1033
+1.7034	0.0935
+1.7628	0.0844
+1.8221	0.0759
+1.8814	0.0680
+1.9408	0.0607
+2.0001	0.0540
+2.0594	0.0479
+2.1188	0.0423
+2.1781	0.0372
+2.2375	0.0326
+2.2968	0.0285
+2.3561	0.0249
+2.4155	0.0216
+2.4748	0.0187
+2.5341	0.0161
+2.5935	0.0138
+2.6528	0.0118
+2.7121	0.0101
+2.7715	0.0086
+2.8308	0.0073
+2.8902	0.0061
+2.9495	0.0052
+3.0088	0.0043
+3.0682	0.0036
+3.1275	0.0030
+3.1868	0.0025
+3.2462	0.0021
+GenotypeA	2
+250	150
+0
+2	4	5
+1	0.5000
+2	0.5000
+Gene2	1
+250	150
+1	3
+2	5	6
+-3.0727	0.0036
+-3.0161	0.0042
+-2.9594	0.0050
+-2.9028	0.0059
+-2.8462	0.0069
+-2.7896	0.0081
+-2.7330	0.0095
+-2.6763	0.0111
+-2.6197	0.0129
+-2.5631	0.0149
+-2.5065	0.0172
+-2.4499	0.0198
+-2.3933	0.0228
+-2.3366	0.0260
+-2.2800	0.0297
+-2.2234	0.0337
+-2.1668	0.0381
+-2.1102	0.0431
+-2.0535	0.0484
+-1.9969	0.0543
+-1.9403	0.0607
+-1.8837	0.0677
+-1.8271	0.0752
+-1.7705	0.0832
+-1.7138	0.0919
+-1.6572	0.1011
+-1.6006	0.1108
+-1.5440	0.1211
+-1.4874	0.1320
+-1.4307	0.1434
+-1.3741	0.1552
+-1.3175	0.1675
+-1.2609	0.1802
+-1.2043	0.1932
+-1.1476	0.2065
+-1.0910	0.2200
+-1.0344	0.2336
+-0.9778	0.2473
+-0.9212	0.2610
+-0.8646	0.2745
+-0.8079	0.2878
+-0.7513	0.3008
+-0.6947	0.3134
+-0.6381	0.3255
+-0.5815	0.3369
+-0.5248	0.3476
+-0.4682	0.3575
+-0.4116	0.3665
+-0.3550	0.3746
+-0.2984	0.3816
+-0.2418	0.3875
+-0.1851	0.3922
+-0.1285	0.3957
+-0.0719	0.3979
+-0.0153	0.3989
+0.0413	0.3986
+0.0980	0.3970
+0.1546	0.3942
+0.2112	0.3901
+0.2678	0.3849
+0.3244	0.3785
+0.3810	0.3710
+0.4377	0.3625
+0.4943	0.3531
+0.5509	0.3428
+0.6075	0.3317
+0.6641	0.3200
+0.7208	0.3077
+0.7774	0.2949
+0.8340	0.2818
+0.8906	0.2683
+0.9472	0.2547
+1.0039	0.2410
+1.0605	0.2274
+1.1171	0.2138
+1.1737	0.2003
+1.2303	0.1872
+1.2869	0.1743
+1.3436	0.1618
+1.4002	0.1497
+1.4568	0.1381
+1.5134	0.1269
+1.5700	0.1163
+1.6267	0.1063
+1.6833	0.0967
+1.7399	0.0878
+1.7965	0.0794
+1.8531	0.0716
+1.9097	0.0644
+1.9664	0.0577
+2.0230	0.0516
+2.0796	0.0459
+2.1362	0.0407
+2.1928	0.0360
+2.2495	0.0318
+2.3061	0.0279
+2.3627	0.0245
+2.4193	0.0214
+2.4759	0.0186
+2.5326	0.0161
+2.5892	0.0140
+Gene4	1
+250	150
+3	1	3	4
+0
+-3.7331	0.0009
+-3.6699	0.0011
+-3.6068	0.0014
+-3.5437	0.0016
+-3.4805	0.0020
+-3.4174	0.0024
+-3.3543	0.0029
+-3.2911	0.0035
+-3.2280	0.0042
+-3.1649	0.0050
+-3.1017	0.0059
+-3.0386	0.0070
+-2.9755	0.0083
+-2.9123	0.0097
+-2.8492	0.0114
+-2.7861	0.0133
+-2.7229	0.0154
+-2.6598	0.0179
+-2.5967	0.0206
+-2.5335	0.0238
+-2.4704	0.0273
+-2.4073	0.0312
+-2.3441	0.0355
+-2.2810	0.0403
+-2.2179	0.0455
+-2.1547	0.0513
+-2.0916	0.0577
+-2.0285	0.0645
+-1.9653	0.0720
+-1.9022	0.0800
+-1.8391	0.0886
+-1.7759	0.0978
+-1.7128	0.1075
+-1.6497	0.1178
+-1.5865	0.1287
+-1.5234	0.1401
+-1.4603	0.1519
+-1.3971	0.1642
+-1.3340	0.1768
+-1.2709	0.1897
+-1.2077	0.2029
+-1.1446	0.2162
+-1.0815	0.2296
+-1.0183	0.2430
+-0.9552	0.2563
+-0.8921	0.2693
+-0.8290	0.2820
+-0.7658	0.2943
+-0.7027	0.3061
+-0.6396	0.3172
+-0.5764	0.3275
+-0.5133	0.3371
+-0.4502	0.3456
+-0.3870	0.3532
+-0.3239	0.3597
+-0.2608	0.3650
+-0.1976	0.3691
+-0.1345	0.3719
+-0.0714	0.3735
+-0.0082	0.3737
+0.0549	0.3727
+0.1180	0.3703
+0.1812	0.3667
+0.2443	0.3618
+0.3074	0.3558
+0.3706	0.3486
+0.4337	0.3404
+0.4968	0.3312
+0.5600	0.3212
+0.6231	0.3103
+0.6862	0.2988
+0.7494	0.2867
+0.8125	0.2741
+0.8756	0.2612
+0.9388	0.2480
+1.0019	0.2347
+1.0650	0.2213
+1.1282	0.2079
+1.1913	0.1947
+1.2544	0.1816
+1.3176	0.1689
+1.3807	0.1565
+1.4438	0.1445
+1.5070	0.1329
+1.5701	0.1219
+1.6332	0.1113
+1.6964	0.1014
+1.7595	0.0920
+1.8226	0.0831
+1.8858	0.0749
+1.9489	0.0673
+2.0120	0.0602
+2.0752	0.0536
+2.1383	0.0477
+2.2014	0.0422
+2.2646	0.0372
+2.3277	0.0327
+2.3908	0.0287
+2.4540	0.0250
+2.5171	0.0218
+2.5802	0.0189
+Gene1	1
+250	150
+1	4
+0
+-2.8174	0.0076
+-2.7627	0.0088
+-2.7080	0.0102
+-2.6533	0.0119
+-2.5985	0.0137
+-2.5438	0.0158
+-2.4891	0.0181
+-2.4343	0.0207
+-2.3796	0.0236
+-2.3249	0.0268
+-2.2702	0.0304
+-2.2154	0.0344
+-2.1607	0.0387
+-2.1060	0.0435
+-2.0512	0.0488
+-1.9965	0.0545
+-1.9418	0.0607
+-1.8871	0.0674
+-1.8323	0.0746
+-1.7776	0.0823
+-1.7229	0.0906
+-1.6682	0.0994
+-1.6134	0.1087
+-1.5587	0.1185
+-1.5040	0.1289
+-1.4492	0.1397
+-1.3945	0.1510
+-1.3398	0.1627
+-1.2851	0.1748
+-1.2303	0.1872
+-1.1756	0.2000
+-1.1209	0.2129
+-1.0661	0.2260
+-1.0114	0.2392
+-0.9567	0.2524
+-0.9020	0.2656
+-0.8472	0.2786
+-0.7925	0.2914
+-0.7378	0.3038
+-0.6830	0.3158
+-0.6283	0.3273
+-0.5736	0.3383
+-0.5189	0.3485
+-0.4641	0.3580
+-0.4094	0.3667
+-0.3547	0.3744
+-0.2999	0.3811
+-0.2452	0.3869
+-0.1905	0.3915
+-0.1358	0.3950
+-0.0810	0.3974
+-0.0263	0.3985
+0.0284	0.3985
+0.0832	0.3973
+0.1379	0.3949
+0.1926	0.3913
+0.2473	0.3867
+0.3021	0.3809
+0.3568	0.3741
+0.4115	0.3663
+0.4663	0.3577
+0.5210	0.3481
+0.5757	0.3379
+0.6304	0.3269
+0.6852	0.3154
+0.7399	0.3033
+0.7946	0.2909
+0.8493	0.2781
+0.9041	0.2651
+0.9588	0.2519
+1.0135	0.2387
+1.0683	0.2255
+1.1230	0.2124
+1.1777	0.1995
+1.2324	0.1867
+1.2872	0.1743
+1.3419	0.1622
+1.3966	0.1505
+1.4514	0.1393
+1.5061	0.1285
+1.5608	0.1181
+1.6155	0.1083
+1.6703	0.0990
+1.7250	0.0902
+1.7797	0.0820
+1.8345	0.0743
+1.8892	0.0671
+1.9439	0.0604
+1.9986	0.0543
+2.0534	0.0486
+2.1081	0.0433
+2.1628	0.0386
+2.2176	0.0342
+2.2723	0.0303
+2.3270	0.0267
+2.3817	0.0235
+2.4365	0.0206
+2.4912	0.0180
+2.5459	0.0157
+2.6007	0.0136
+2.6554	0.0118
diff --git a/sourcecodes/parameter_learning/test/Agbnnode.txt b/sourcecodes/parameter_learning/test/Agbnnode.txt
new file mode 100644
index 00000000..1e8b3149
--- /dev/null
+++ b/sourcecodes/parameter_learning/test/Agbnnode.txt
@@ -0,0 +1 @@
+6
diff --git a/sourcecodes/parameter_learning/test/Agbstructure_input.txt b/sourcecodes/parameter_learning/test/Agbstructure_input.txt
new file mode 100644
index 00000000..10766f0c
--- /dev/null
+++ b/sourcecodes/parameter_learning/test/Agbstructure_input.txt
@@ -0,0 +1,7 @@
+GenotypeA	GenotypeB	Gene1	Gene2	Gene3	Gene4	
+0	0	0	1	0	1	
+0	0	0	0	1	1	
+0	0	0	0	0	0	
+0	0	1	0	0	1	
+0	0	0	0	0	0	
+0	0	0	0	0	0	
diff --git a/sourcecodes/parameter_learning/test/octave-core b/sourcecodes/parameter_learning/test/octave-core
new file mode 100644
index 00000000..678fda92
--- /dev/null
+++ b/sourcecodes/parameter_learning/test/octave-core
Binary files differ