about summary refs log tree commit diff
diff options
context:
space:
mode:
authorziejd22018-03-14 23:19:16 -0500
committerziejd22018-03-14 23:19:16 -0500
commitc80226899f5cdd9f11c163817d59445213f5bef0 (patch)
treee0fd79d2e32fd2aedda2eadaed0f19af3514c520
parent324ebc8ddacab8e154047b8518afd5cbb5bb2fa4 (diff)
downloadBNW-c80226899f5cdd9f11c163817d59445213f5bef0.tar.gz
Separating Octave and php calculations
-rw-r--r--BNW_parameter_learning/Predictmultiple.m87
-rw-r--r--BNW_parameter_learning/Predictmultipleintrvention.m76
-rw-r--r--BNW_parameter_learning/drawFigure.m17
-rw-r--r--BNW_parameter_learning/drawFigureM.m60
-rw-r--r--BNW_parameter_learning/prepareInput.m281
-rw-r--r--BNW_parameter_learning/readInput.m9
-rw-r--r--BNW_parameter_learning/runBN_initial.m87
-rw-r--r--BNW_parameter_learning/standardizeData.m2
-rw-r--r--BNW_parameter_learning/writeParameters.m106
-rw-r--r--BNW_parameter_learning/writeParameters_ev.m151
-rw-r--r--BNW_parameter_learning/writeParameters_int.m186
-rw-r--r--home.php4
-rw-r--r--sourcecodes/BNW_workflow_net1.htm6
-rw-r--r--sourcecodes/add_evd.php10
-rw-r--r--sourcecodes/add_evd.php~204
-rw-r--r--sourcecodes/add_evd_example.php10
-rw-r--r--sourcecodes/add_evd_example.php~204
-rw-r--r--sourcecodes/add_inv.php12
-rw-r--r--sourcecodes/add_inv.php~262
-rw-r--r--sourcecodes/add_inv_example.php12
-rw-r--r--sourcecodes/add_inv_example.php~251
-rw-r--r--sourcecodes/bn_file_load_gom.php270
-rw-r--r--sourcecodes/execute_bn_gom.php~98
-rw-r--r--sourcecodes/graphviz_structure.php~97
-rw-r--r--sourcecodes/header_batchsearch.inc2
-rw-r--r--sourcecodes/input_check.php16
-rw-r--r--sourcecodes/layout.php3
-rw-r--r--sourcecodes/layout_example.php3
-rw-r--r--sourcecodes/my_new_style.css6
-rw-r--r--sourcecodes/network_layout_evd.php162
-rw-r--r--sourcecodes/network_layout_evd.php~667
-rw-r--r--sourcecodes/network_layout_evd_2.php110
-rw-r--r--sourcecodes/network_layout_evd_2_example.php40
-rw-r--r--sourcecodes/network_layout_evd_example.php56
-rw-r--r--sourcecodes/network_layout_inv.php118
-rw-r--r--sourcecodes/network_layout_inv_2.php51
-rw-r--r--sourcecodes/network_layout_inv_2_example.php37
-rw-r--r--sourcecodes/network_layout_inv_example.php31
-rw-r--r--sourcecodes/parameter_display.php16
-rw-r--r--sourcecodes/parameter_learning/Predictmultiple.m87
-rw-r--r--sourcecodes/parameter_learning/Predictmultipleintrvention.m76
-rw-r--r--sourcecodes/parameter_learning/drawFigure.m17
-rw-r--r--sourcecodes/parameter_learning/drawFigureM.m60
-rw-r--r--sourcecodes/parameter_learning/prepareInput.m281
-rw-r--r--sourcecodes/parameter_learning/readInput.m9
-rw-r--r--sourcecodes/parameter_learning/runBN_initial.m87
-rw-r--r--sourcecodes/parameter_learning/standardizeData.m2
-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-corebin247702 -> 0 bytes
-rw-r--r--sourcecodes/parameter_learning/writeParameters.m106
-rw-r--r--sourcecodes/parameter_learning/writeParameters_ev.m151
-rw-r--r--sourcecodes/parameter_learning/writeParameters_int.m186
-rw-r--r--sourcecodes/run_octave_inv~7
-rw-r--r--sourcecodes/run_octave~7
-rw-r--r--sourcecodes/run_prep_input (renamed from sourcecodes/run_octave_evd~)2
-rw-r--r--sourcecodes/runmat.sh7
-rw-r--r--sourcecodes/runmat.sh.bk7
-rw-r--r--sourcecodes/runmat_evd.sh4
-rw-r--r--sourcecodes/runmat_evd.sh.bk4
-rw-r--r--sourcecodes/runmat_inv.sh4
-rw-r--r--sourcecodes/runmat_inv.sh.bk4
67 files changed, 2034 insertions, 3892 deletions
diff --git a/BNW_parameter_learning/Predictmultiple.m b/BNW_parameter_learning/Predictmultiple.m
index c14b516c..781c64a4 100644
--- a/BNW_parameter_learning/Predictmultiple.m
+++ b/BNW_parameter_learning/Predictmultiple.m
@@ -1,57 +1,72 @@
 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');

-                            

+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');

 

+means_orig = cell(1,nnodes);

+stdevs_orig = cell(1,nnodes);

+labels_orig = cell(1,nnodes);

+%Read in original means and standard deviations

+mapfile = strcat(pre,'map.txt');

+fmap = fopen(mapfile,'r');

+for i=1:nnodes

+    buffer = fgetl(mapfile);

+    temp = cell(1,4);

+    for j=1:4

+        [next,buffer] = strtok(buffer);

+        temp{j} = next;

+    end

+    labels_orig{i} = temp{1};

+    means_orig{i} = str2num(temp{4});

+    stdevs_orig{i} = str2num(temp{3});

+end

+fclose(fmap);

+

+%Need to map the means and stdevs to the correct labels

+means = cell(1,nnodes);

+stdevs = cell(1,nnodes);

+%Read in labels in new order.

+labelsnew = cell(1,nnodes);

+mapdatafile = strcat(pre,'mapdata.txt');

+fmapdata = fopen(mapdatafile,'r');

+buffer = fgetl(fmapdata);

+for i = 1:nnodes

+    [next,buffer ] = strtok(buffer);

+    labelsnew{i} = next;

+end

+fclose(fmapdata);

+for i = 1:nnodes

+    for j = 1:nnodes

+       if strcmp(labelsnew{i},labels_orig{j})

+          means{i} = means_orig{j};

+          stdevs{i} = stdevs_orig{j};

+          break

+       end

+    end

+end

+

+

 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
+drawFigureM(nnodes,bnet,labels,filename,cases,stdevs,means,select_var_new,select_var_data_new);

+

+writeParameters_ev(pre,bnet,nnodes,labels,cases,stdevs,means,select_var_new,select_var_data_new);

+

+end

diff --git a/BNW_parameter_learning/Predictmultipleintrvention.m b/BNW_parameter_learning/Predictmultipleintrvention.m
index 4675b846..eaec60dc 100644
--- a/BNW_parameter_learning/Predictmultipleintrvention.m
+++ b/BNW_parameter_learning/Predictmultipleintrvention.m
@@ -11,17 +11,13 @@ 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);

 

+[bnet]=parameterLearning(bnet,cases);

 

 fvarfile=strcat(pre,'var.txt');

-fvar = fopen(fvarfile,'r');

-                            

+fvar = fopen(fvarfile,'r');                           

 select_var_new = fscanf(fvar,'%d');

 

 nm = numel(select_var_new);

@@ -48,26 +44,52 @@ fvard = fopen(fvardfile,'r');
 

 select_var_data_new = fscanf(fvard,'%f');

 

+means_orig = cell(1,nnodes);

+stdevs_orig = cell(1,nnodes);

+labels_orig = cell(1,nnodes);

+%Read in original means and standard deviations

+mapfile = strcat(pre,'map.txt');

+fmap = fopen(mapfile,'r');

+for i=1:nnodes

+    buffer = fgetl(mapfile);

+    temp = cell(1,4);

+    for j=1:4

+        [next,buffer] = strtok(buffer);

+        temp{j} = next;

+    end

+    labels_orig{i} = temp{1};

+    means_orig{i} = str2num(temp{4});

+    stdevs_orig{i} = str2num(temp{3});

+end

+fclose(fmap);

+

+%Need to map the means and stdevs to the correct labels

+means = cell(1,nnodes);

+stdevs = cell(1,nnodes);

+%Read in labels in new order.

+labelsnew = cell(1,nnodes);

+mapdatafile = strcat(pre,'mapdata.txt');

+fmapdata = fopen(mapdatafile,'r');

+buffer = fgetl(fmapdata);

+for i = 1:nnodes

+    [next,buffer ] = strtok(buffer);

+    labelsnew{i} = next;

+end

+fclose(fmapdata);

+for i = 1:nnodes

+    for j = 1:nnodes

+       if strcmp(labelsnew{i},labels_orig{j})

+          means{i} = means_orig{j};

+          stdevs{i} = stdevs_orig{j};

+          break

+       end

+    end

+end

+

 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
+drawFigureM(nnodes,bnet,labels,filename,cases,stdevs,means,select_var_new,select_var_data_new);

+

+writeParameters_int(pre,bnet,nnodes,labels,cases,stdevs,means,select_var_new,select_var_data_new);

+

+end

diff --git a/BNW_parameter_learning/drawFigure.m b/BNW_parameter_learning/drawFigure.m
index a5de0f2d..fa963a4b 100644
--- a/BNW_parameter_learning/drawFigure.m
+++ b/BNW_parameter_learning/drawFigure.m
@@ -1,18 +1,19 @@
-function [] = drawFigure(nnodes,bnet,labels,filename,cases,selectvar,selectdata)

+function [] = drawFigure(nnodes,bnet,labels,filename,cases,stdevs,means,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);

+

+if nargin < 8,

+    drawFigureNoEv(nnodes,bnet,labels,filename,cases,stdevs,means);

 else

-    drawFigureEv(nnodes,bnet,labels,filename,cases,selectvar,selectdata);

+    drawFigureEv(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata);

 end;

 

 end

 

 

 

-function [] = drawFigureEv(nnodes,bnet,labels,filename,cases,selectvar,selectdata)

+function [] = drawFigureEv(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata)

 %Function to use if there is no entered evidence. 

 %         

 %

@@ -152,6 +153,8 @@ for i = 1:nnodes,
         [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,

+            %%Undo standardization

+            xvals(j,1) = xvals(j,1)*stdevs{i}+means{i}

             fprintf(fileID,'%6.4f\t%6.4f\n',x_vals(j,1),y_vals(j,1));

         end;

       end;

@@ -172,7 +175,7 @@ end
 

 

 

-function [] = drawFigureNoEv(nnodes,bnet,labels,filename,cases)

+function [] = drawFigureNoEv(nnodes,bnet,labels,filename,cases,stdevs,means)

 %Function to use if there is no entered evidence. 

 %         

 %

@@ -302,6 +305,8 @@ for i = 1:nnodes,
         [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,

+            %%Undo standardization

+            x_vals(j,1) = x_vals(j,1)*stdevs{i}+means{i};

             fprintf(fileID,'%6.4f\t%6.4f\n',x_vals(j,1),y_vals(j,1));

         end;

     end;

diff --git a/BNW_parameter_learning/drawFigureM.m b/BNW_parameter_learning/drawFigureM.m
index bca223ce..9aa77d35 100644
--- a/BNW_parameter_learning/drawFigureM.m
+++ b/BNW_parameter_learning/drawFigureM.m
@@ -1,21 +1,6 @@
-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

+function [] = drawFigureM(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata)

+%drawFigureM writes the parameters and data that are needed to draw the

+%structure of a Bayesian network after added evidence or intervention

 

 fileID = fopen(filename,'w');

 

@@ -30,49 +15,35 @@ 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);   

-    

+%Need to standardized evidence for continuous nodes.

+    if bnet.node_sizes(di) == 1

+        ev_dat(di) = (ev_dat(di) - means{di}) / stdevs{di};

+    end

     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;

+fprintf(fileID,'\n');

 

 [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)

-

+fprintf(fileID,'%i\t%i\t\n',x_dim,y_dim);

 x = x*x_dim;

 y = y*y_dim;

 for i = 1:nnodes,

@@ -99,7 +70,6 @@ for i = 1:nnodes,
     end

 end

 

-

 for i = 1:nnodes,

     %%% The name and type of each node (1=continuous, the number of states

     %%% if it is discrete

@@ -162,23 +132,25 @@ for i = 1:nnodes,
             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,

+            %%Undo standardization

+            x_vals(j,1) = x_vals(j,1)*stdevs{i}+means{i};

             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);

+      if bnet.node_sizes(i) == 1,

+	fprintf(fileID,'%6.4f\t%6.4f\n',ev_dat(i)*stdevs{i}+means{i},1);

+      else

+	fprintf(fileID,'%6.4f\t%6.4f\n',ev_dat(i),1);

+      endif 

     end

     

 end

-%fprintf(fileID,'%s\t %\n',labels_temp{:});

-

 

 fclose(fileID);

-

 end

 

 

diff --git a/BNW_parameter_learning/prepareInput.m b/BNW_parameter_learning/prepareInput.m
new file mode 100644
index 00000000..28a06c15
--- /dev/null
+++ b/BNW_parameter_learning/prepareInput.m
@@ -0,0 +1,281 @@
+function  [ ] = prepareInput( pre )
+   %   
+   %  This function takes files that are uploaded to BNW and creates output
+   %    files that can be used for structure and parameter learning.
+   %  It replaces php code that was previously in bn_file_load_gom.php.
+   %    There are several improvements in performance and ease of use:
+   %     1) Loading files is significantly (~5x) faster for large input files.
+   %     2) The allowed values for discrete variables are more flexible. 
+   %           (e.g., A genotype variable be 'B' and 'D' instead of having
+   %               to replace to make them '1' and '2'.)
+   %     3) Continuous variables may be identified as continuous in some cases
+   %            even if there is not a period.
+   %     4) The states of discrete variables should be correctly ordered in
+   %            almost all cases.
+   %     5) An additional output file is written that will let users check if
+   %            the input file has been uploaded and parsed correctly.
+   %     6) Future updates to this code should be easier than updating the php.
+   %      
+   %
+   %  Input: ???continuous_input_orig.txt
+   %    This is the input file that is uploaded to BNW.
+   %    It is directly written out by the BNW php code with no modification.
+   %    The file format is a header line containing the variable names
+   %     followed by the data, with each case in a row.
+   %
+   %  Output: There are many output files.
+   %    1) The main output file is ???continuous_input.txt that can be
+   %       used by the structure learning code and parameter learning codes.
+   %       The first line is variable names, the second line is the node type
+   %          (continuous nodes should have 1, discrete nodes have the number
+   %           of states), and the rest is the data.
+   %    2) A new output file is ???input_desc.txt, a file that describes the
+   %        data so users can check that it has been parsed correctly.
+   %    3) ???nlevels.txt: The states of discrete variables.
+   %    4) ???name.txt: The names of the variables as uploaded.
+   %    5) ???type.txt: The number of states for each variables
+   %            (1 indicates a continuous variable.)
+   %    6/7) ???nnode.txt and ???nrows.txt: number of nodes and cases
+   %    8-12) ???ban.txt, ???white.txt, ???k.txt, ???thr.txt, and
+   %          ???parent.txt: Files with default values for structure learning. 
+   %
+
+%  open file for input, include error handling
+dfile=strcat(pre,'continuous_input_orig.txt');
+
+fin = fopen(dfile,'r');
+if fin < 0
+   error(['Could not open ',dfile,' for input']);
+end
+
+% Get the number of cases (the number of rows in the file excluding the header)
+ncases = fskipl(fin,Inf) - 1;
+
+frewind(fin);
+
+% Read in first line to get the number of nodes and the node labels.
+buffer = fgetl(fin);    %get header line as a string
+nnodes = numel(strfind(buffer,"\t")) + 1;
+labels = cell(1,nnodes);
+for j=1:nnodes
+    [next,buffer] = strtok(buffer);
+    labels{j} = next;
+end
+
+% Read in the data
+data = cell(ncases,nnodes);
+for i = 1:ncases
+    buffer = fgetl(fin);
+    for j = 1:nnodes
+         [next,buffer] = strtok(buffer);
+         data{i,j} = next;
+    end
+end
+
+% Determine whether or not the nodes are continuous or discrete.
+% First, treat them as all discrete and get the states and number of stats(levels).
+levels = cell(1,nnodes);
+states = [];
+for j = 1:nnodes
+   states{end+1} = unique(data(:,j));
+   levels{j} = size(states{j},1);
+end
+
+%Now do some checks to see if nodes are discrete or continuous
+for j = 1:nnodes
+    % If there are 3 or less unique values, I will assume that the node is discrete.
+    if levels{j} < 4;
+        continue
+    % If there are as many unique values as a third of the number of cases,
+    %      I will assume that the node is continuous.
+    elseif levels{j} > ncases/3;
+       levels{j} = 1;
+    % If there are more than twenty unique values,
+    %      I will assume that the node is continuous.
+    elseif levels{j} > 20;
+       levels{j} = 1;
+    % Otherwise, I will scan through the individual values.
+    % If any of the values contain a '.', I will assume it is continuous.
+    else
+       period_test = 0;
+       column = data(:,j);
+       k = 1;
+       while period_test == 0 
+           period_test = sum(cell2mat(strfind(column(k),".")));
+           if period_test != 0;
+              levels{j} = 1;
+           end
+           k++;
+           if k > ncases
+              break
+           end
+        end
+    end
+end
+
+%I need to check if any discrete nodes are listed after continuous nodes.
+%If so, I need to rearrange the columns.
+max_disc = 0;
+min_cont = nnodes + 1;
+for i = 1:nnodes
+    if levels{i} > 1
+       max_disc = i;
+    elseif min_cont == nnodes+1
+       min_cont = i;
+    end
+end
+%If max_disc > min_cont, you need to rearrange the nodes
+%  to put the discrete nodes first.
+if max_disc > min_cont
+  levels_old = levels;
+  labels_old = labels;
+  data_old = data;
+  states_old = states;
+  new_order = {};
+  for i=1:nnodes
+    if levels_old{i} > 1
+      new_order{end+1} = i;
+    end
+  end
+  for i=1:nnodes
+    if levels_old{i} == 1
+      new_order{end+1} = i;
+    end
+  end
+  labels = {};
+  levels = {};
+  states = {};
+  for i =1:nnodes
+    labels{i} = labels_old{new_order{i}};
+    levels{i} = levels_old{new_order{i}};
+    states{i} = states_old{new_order{i}};
+    for j=1:ncases
+      data{j,i} = data_old{j,new_order{i}};
+    end
+  end
+  
+endif
+
+
+%Write other files that are used by BNW for this key.
+%The first group of files establish default settings for structure learning.
+outfile = strcat(pre,'white.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'From\tTo\n');
+fclose(fout);
+
+outfile = strcat(pre,'ban.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'From\tTo\n');
+fclose(fout);
+
+outfile = strcat(pre,'k.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'1\n');
+fclose(fout);
+
+outfile = strcat(pre,'parent.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'4\n');
+fclose(fout);
+
+outfile = strcat(pre,'thr.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'0.5\n');
+fclose(fout);
+
+
+%The next group of files have information about the uploaded file.
+outfile = strcat(pre,'name.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%s\t',labels{1:end-1});
+fprintf(fout,'%s\n',labels{end});
+fclose(fout);
+
+outfile = strcat(pre,'nnode.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%i\n',nnodes);
+fclose(fout);
+
+outfile = strcat(pre,'nrows.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%i\n',ncases);
+fclose(fout);
+
+outfile = strcat(pre,'type.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%s\t',labels{1:end-1});
+fprintf(fout,'%s\n',labels{end});
+fprintf(fout,'%i\t',levels{1:end-1});
+fprintf(fout,'%i\n',levels{end});
+fclose(fout);
+
+%This output file contains the states for discrete nodes.
+% The unique matlab function already sorts the states.
+outfile = strcat(pre,'nlevels.txt');
+fout = fopen(outfile,'w');
+for i = 1:nnodes
+    if levels{i} > 1
+        fprintf(fout,'%s\t',labels{i},states{i}{1:end-1});
+        fprintf(fout,'%s\n',states{i}{end});
+    end
+end
+fclose(fout);
+
+
+%Print a file with a short description of the input.
+descfile = strcat(pre,'input_desc.txt');
+dout = fopen(descfile,'w');
+fprintf(dout,['As loaded, the input file had the following properties:\n\n']);
+dout = fopen(descfile,'a');
+fprintf(dout,'There are %i variables and %i cases(rows)\n',size(labels,2),ncases);
+fprintf(dout,'The variable names are:\n');
+fprintf(dout,'%s\t',labels{1:end-1});
+fprintf(dout,'%s\n\n',labels{end});
+for i=1:nnodes
+    if levels{i} == 1
+       fprintf(dout,'%s is a continuous variable\n',labels{i});
+       column = str2double(data(:,i));
+       colmean = mean(column);
+       colstd = std(column);
+       fprintf(dout,'It has a mean of %6.3f and a standard deviation of %6.3f\n\n',mean(column),std(column))
+    else 
+       fprintf(dout,'%s is a discrete variable with %i states\n',labels{i},levels{i});
+       fprintf(dout,'The states are: ');
+       fprintf(dout,'%s ',states{i}{1:end-1});
+       fprintf(dout,'%s\n\n',states{i}{end});
+    end
+end
+fclose(fout);
+
+outfile = strcat(pre,'continuous_input.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%s\t',labels{1:end-1});
+fprintf(fout,'%s\n',labels{end});
+fprintf(fout,'%i\t',levels{1:end-1});
+fprintf(fout,'%i\n',levels{end});
+%Need to replace states in discrete variables with integers for BNT
+for i = 1:nnodes
+    if levels{i} > 1
+	for j = 1:ncases
+            for k=1:size(states{i},1)
+	      if data{j,i} == states{i}{k}
+                 data{j,i} = sprintf('%i',num2cell(k){1});;
+                 break
+              end
+            end
+        end
+     end
+end
+for i = 1:ncases
+      fprintf(fout,'%s\t',data{i,1:end-1});
+      fprintf(fout,'%s\n',data{i,end});
+end
+fclose(fout);
+
+
+
+
+
+end
+%  end of prepareInput.m
\ No newline at end of file
diff --git a/BNW_parameter_learning/readInput.m b/BNW_parameter_learning/readInput.m
index c2c16331..2be0af29 100644
--- a/BNW_parameter_learning/readInput.m
+++ b/BNW_parameter_learning/readInput.m
@@ -25,19 +25,12 @@ end
 [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

@@ -67,4 +60,4 @@ end
         

 

 end

-%  end of readInput.m
\ No newline at end of file
+%  end of readInput.m

diff --git a/BNW_parameter_learning/runBN_initial.m b/BNW_parameter_learning/runBN_initial.m
index c3f2a34b..43caf402 100644
--- a/BNW_parameter_learning/runBN_initial.m
+++ b/BNW_parameter_learning/runBN_initial.m
@@ -15,84 +15,43 @@ 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);

+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');

+fclose(mapval);

+fclose(mapfile);

+

+%Need to rearrange the means and stdevs to match the new labeling.

+means = cell(1,nnodes);

+stdevs = cell(1,nnodes);

+for i = 1:nnodes

+    for j = 1:nnodes

+       if strcmp(labels{i},labelsold{j})

+          means{i} = m(j);

+          stdevs{i} = s(j);

+          break

+       end

+    end

+end

+

 

 [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
+

+drawFigure(nnodes,bnet,labels,filename,cases,stdevs,means);

+

+writeParameters(pre,nnodes,bnet,labels,cases,labelsold,s,m);

+

+end

diff --git a/BNW_parameter_learning/standardizeData.m b/BNW_parameter_learning/standardizeData.m
index ba4ef5dd..449aa440 100644
--- a/BNW_parameter_learning/standardizeData.m
+++ b/BNW_parameter_learning/standardizeData.m
@@ -1,7 +1,7 @@
 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);

 

diff --git a/BNW_parameter_learning/writeParameters.m b/BNW_parameter_learning/writeParameters.m
new file mode 100644
index 00000000..0790a8e2
--- /dev/null
+++ b/BNW_parameter_learning/writeParameters.m
@@ -0,0 +1,106 @@
+function [] = writeParameters(pre,nnodes,bnet,labels,cases,labelsold,s,m)
+%Writes a file that contains the parameters of the network with no evidence.
+
+
+%%Get the types of the nodes.
+typefile = strcat(pre,'type.txt');
+ftype = fopen(typefile,'r');
+types = cell(1,nnodes);
+buffer = fgetl(ftype);
+buffer = fgetl(ftype);
+for j = 1:nnodes
+    [next,buffer] = strtok(buffer);
+    types{j} = uint16(str2num(next));
+end
+
+max_states = 0;
+disc_nodes = 0;
+for j = 1:nnodes
+  if types{j} > max_states
+    max_states = types{j};
+  end
+  if types{j} > 1
+    disc_nodes = disc_nodes + 1;
+  end
+end
+
+%Add 1 to max_states to account for node name
+max_states = max_states + 1;
+
+%%Get mapping of discrete levels.
+levelfile = strcat(pre,'nlevels.txt');
+flevels = fopen(levelfile,'r');
+levels = cell(disc_nodes,max_states);
+ndisc_nodes = 0;
+for i=1:disc_nodes
+    ndisc_nodes = ndisc_nodes + 1;
+    buffer = fgetl(flevels);
+     for j = 1:max_states
+       [next,buffer] = strtok(buffer);
+       if j == 1
+          levels{i,j} = next;
+       else
+%          levels{i,j} = uint16(str2num(next));
+          levels{i,j} = next;
+       end        
+       if length(buffer) < 1
+        break
+       end
+     end
+end
+
+
+evidence = cell(1,nnodes);
+engine = jtree_inf_engine(bnet);
+[engine,loglik] = enter_evidence(engine,evidence);
+
+%Open output file.
+filename = strcat(pre,'parameters.txt');
+fileID = fopen(filename,'w');
+
+for i = 1:nnodes
+    for j = 1:nnodes
+	if strcmp(labelsold{i},labels{j});
+            nodeid = j;
+            break
+        end
+    end
+    predict = marginal_nodes(engine,nodeid);
+    %%%Print the name of the node
+    fprintf(fileID,'%s\n',labels{nodeid});
+    %%%Print the type of node
+    if bnet.node_sizes(nodeid) == 1;
+        line = 'Continuous node\n';
+        fprintf(fileID,line);
+        %%% 'i' in the line below is correct: m and s are had original node labeling
+        adj_mu = predict.mu*s(i)+m(i);
+        adj_sigma = s(i)*predict.Sigma;
+	fprintf(fileID,'%6.4f\t%6.4f\n\n',adj_mu,adj_sigma);
+    else
+        line = 'Discrete node with %i states\n';
+        fprintf(fileID,line,bnet.node_sizes(nodeid));
+        %line = 'Probability of each state\n';
+        %fprintf(fileID,line);
+        nodeid2 = 0;
+        for k = 1:ndisc_nodes,
+           if strcmp(levels{k,1},labels{nodeid}),
+	      nodeid2 = k;
+              break
+           end
+        end
+        for j = 1:bnet.node_sizes(nodeid),
+            %%%For discrete nodes, the state and the percent of that state
+%		  fprintf(fileID,'%i\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+		  fprintf(fileID,'%s\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+        end;
+        fprintf(fileID,'\n')
+
+    end
+end
+
+
+
+fclose(fileID);
+
+end
+
diff --git a/BNW_parameter_learning/writeParameters_ev.m b/BNW_parameter_learning/writeParameters_ev.m
new file mode 100644
index 00000000..fc24e2e5
--- /dev/null
+++ b/BNW_parameter_learning/writeParameters_ev.m
@@ -0,0 +1,151 @@
+function [] = writeParameters_ev(pre,bnet,nnodes,labels,cases,stdevs,means,selectvar,selectdata)
+%Writes a file that contains the parameters of the network after entering evidence.
+
+%Read in original node labels to get node IDs.
+infile = strcat(pre,'continuous_input.txt');
+fin = fopen(infile,'r');
+labelsold = cell(1,nnodes);
+buffer = fgetl(fin);
+for j = 1:nnodes
+    [next,buffer] = strtok(buffer);
+    labelsold{j} = next;
+end
+fclose(fin);
+
+
+evidence = cell(1,nnodes);
+engine = jtree_inf_engine(bnet);
+
+m = size(selectvar,1);
+
+%%Get the types of the nodes.
+typefile = strcat(pre,'type.txt');
+ftype = fopen(typefile,'r');
+types = cell(1,nnodes);
+buffer = fgetl(ftype);
+buffer = fgetl(ftype);
+for j = 1:nnodes
+   [next,buffer] = strtok(buffer);
+   types{j} = uint16(str2num(next));
+end
+
+max_states = 0;
+disc_nodes = 0;
+for j = 1:nnodes
+  if types{j} > max_states
+       max_states = types{j};
+  end
+  if types{j} > 1
+    disc_nodes = disc_nodes + 1;
+  end
+end
+
+%Add 1 to max_states to account for node name
+max_states = max_states + 1;
+
+%%Get mapping of discrete levels.
+levelfile = strcat(pre,'nlevels.txt');
+flevels = fopen(levelfile,'r');
+levels = cell(disc_nodes,max_states);
+ndisc_nodes = 0;
+for i=1:disc_nodes
+	ndisc_nodes = ndisc_nodes + 1;
+buffer = fgetl(flevels);
+for j = 1:max_states
+	  [next,buffer] = strtok(buffer);
+       if j == 1
+	 levels{i,j} = next;
+       else
+%	 levels{i,j} = uint16(str2num(next));
+	 levels{i,j} = next;
+       end
+       if length(buffer) < 1
+        break
+       end
+     end
+end
+
+
+ev_dat = zeros(1,nnodes);
+for i = 1:m,
+    di=selectvar(i,1);
+    ev_dat(di)=selectdata(i,1);
+%Need to standardize evidence for continuous nodes.
+    if bnet.node_sizes(di) == 1,
+        ev_dat(di) = (ev_dat(di) - means{di})/stdevs{di};
+    end
+    evidence{di} = ev_dat(di);
+end
+
+[engine,loglik]=enter_evidence(engine,evidence);
+
+%Open output file.
+filename = strcat(pre,'parameters_ev.txt');
+fileID = fopen(filename,'w');
+
+for i = 1:nnodes
+    for j = 1:nnodes
+	if strcmp(labelsold{i},labels{j});
+            nodeid = j;
+            break
+        end
+    end
+    %%%Print the name of the node
+    fprintf(fileID,'%s\n',labels{nodeid});
+    predict = marginal_nodes(engine,nodeid);
+    if isempty(evidence{nodeid})
+       %%%Print the type of node
+       if bnet.node_sizes(nodeid) == 1;
+           line = 'Continuous parameters considering evidence:\n';
+           fprintf(fileID,line);
+           %line = 'Mean and standard deviation of Gaussian distribution\n';
+           %fprintf(fileID,line);
+	     adj_mu = predict.mu*stdevs{nodeid}+means{nodeid};
+             adj_sigma = stdevs{nodeid}*predict.Sigma;
+             fprintf(fileID,'%6.4f\t%6.4f\n\n',adj_mu,adj_sigma);
+       else
+           line = 'Probability of states considering evidence:\n';
+           fprintf(fileID,line);
+           nodeid2 = 0;
+           for k = 1:ndisc_nodes,
+	     if strcmp(levels{k,1},labels{nodeid}),
+                nodeid2 = k;
+                break
+             end
+            end
+	    for j = 1:bnet.node_sizes(nodeid),
+		%%%For discrete nodes, the state and the percent of that state
+%		fprintf(fileID,'%i\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+		fprintf(fileID,'%s\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+           end;
+           fprintf(fileID,'\n')
+       end
+   else
+       if bnet.node_sizes(nodeid) == 1;
+          line = 'Evidence was observed for this node. The observed value was:\n';
+          fprintf(fileID,line);  
+          adj_mu = ev_dat(nodeid)*stdevs{nodeid}+means{nodeid};
+          fprintf(fileID,'%6.4f\n\n',adj_mu);
+       else
+          nodeid2 = 0;
+          for k = 1:ndisc_nodes,
+	    if strcmp(levels{k,1},labels{nodeid}),
+               nodeid2 = k;
+               break
+            end
+          end
+	 line = 'Evidence was observed for this node. The observed state was:\n';
+         fprintf(fileID,line);
+         state_ev =   uint16(ev_dat(nodeid));
+%         fprintf(fileID,'%i\n\n',levels{nodeid2,state_ev+1});
+         fprintf(fileID,'%s\n\n',levels{nodeid2,state_ev+1});
+       end
+   end
+end
+
+
+
+fclose(fileID);
+
+end
+
diff --git a/BNW_parameter_learning/writeParameters_int.m b/BNW_parameter_learning/writeParameters_int.m
new file mode 100644
index 00000000..ed92d593
--- /dev/null
+++ b/BNW_parameter_learning/writeParameters_int.m
@@ -0,0 +1,186 @@
+function [] = writeParameters_int(pre,bnet,nnodes,labels,cases,stdevs,means,selectvar,selectdata)
+%Writes a file that contains the parameters of the network after intervention.
+
+
+%First read input file to get node labels to get node IDs.
+infile = strcat(pre,'continuous_input.txt');
+fin = fopen(infile,'r');
+labelsold = cell(1,nnodes);
+buffer = fgetl(fin);
+for j = 1:nnodes
+    [next,buffer] = strtok(buffer);
+    labelsold{j} = next;
+end
+
+evidence = cell(1,nnodes);
+engine = jtree_inf_engine(bnet);
+
+m = size(selectvar,1);
+
+%%Get the types of the nodes.
+typefile = strcat(pre,'type.txt');
+ftype = fopen(typefile,'r');
+types = cell(1,nnodes);
+buffer = fgetl(ftype);
+buffer = fgetl(ftype);
+for j = 1:nnodes
+   [next,buffer] = strtok(buffer);
+   types{j} = uint16(str2num(next));
+end
+
+max_states = 0;
+disc_nodes = 0;
+for j = 1:nnodes
+  if types{j} > max_states
+       max_states = types{j};
+  end
+  if types{j} > 1
+    disc_nodes = disc_nodes + 1;
+  end
+end
+
+%Add 1 to max_states to account for node name
+max_states = max_states + 1;
+
+%%Get mapping of discrete levels.
+levelfile = strcat(pre,'nlevels.txt');
+flevels = fopen(levelfile,'r');
+levels = cell(disc_nodes,max_states);
+ndisc_nodes = 0;
+for i=1:disc_nodes
+	ndisc_nodes = ndisc_nodes + 1;
+buffer = fgetl(flevels);
+for j = 1:max_states
+	  [next,buffer] = strtok(buffer);
+       if j == 1
+	 levels{i,j} = next;
+       else
+%	 levels{i,j} = uint16(str2num(next));
+	 levels{i,j} = next;
+       end
+       if length(buffer) < 1
+        break
+       end
+     end
+end
+
+
+ev_dat = zeros(1,nnodes);
+for i = 1:m,
+    di=selectvar(i,1);
+    ev_dat(di)=selectdata(i,1);
+%Need to standardize evidence for continuous nodes.
+    if bnet.node_sizes(di) == 1,
+      ev_dat(di) = (ev_dat(di) - means{di})/stdevs{di};
+    end
+    evidence{di} = ev_dat(di);
+end
+
+[engine,loglik]=enter_evidence(engine,evidence);
+
+%Get list of nodes that are children, grandchildren, etc. of intervened nodes
+%int_nodes contains the list of these children nodes
+int_nodes = zeros(1,nnodes);
+%new_nodes is just a temporary array to know when to keep looking
+new_nodes = zeros(1,nnodes);
+for i = 1:nnodes
+    if !isempty(evidence{i});
+        new_nodes(i) = 1;
+        int_nodes(i) = 1;
+    end
+end
+while sum(new_nodes) != 0
+   new_nodes_old = new_nodes;
+   new_nodes = zeros(1,nnodes);
+   for i = 1:nnodes
+      if new_nodes_old(i) == 1
+           for j = 1:nnodes
+              if int_nodes(j) == 0
+	        if bnet.dag(i,j) == 1,
+		     new_nodes(j) = 1;
+                end
+              end
+           end
+       end
+   end
+   for i = 1:nnodes
+      if new_nodes(i) == 1;
+        int_nodes(i) = 1;
+      end
+   end               
+end
+
+
+%Open output file.
+filename = strcat(pre,'parameters_ev.txt');
+fileID = fopen(filename,'w');
+
+for i = 1:nnodes
+    for j = 1:nnodes
+	if strcmp(labelsold{i},labels{j});
+            nodeid = j;
+            break
+        end
+    end
+    %check to see if this is a node impacted by intervention
+    if int_nodes(nodeid) == 1
+    %%%Print the name of the node
+    fprintf(fileID,'%s\n',labels{nodeid});
+    predict = marginal_nodes(engine,nodeid);
+    if isempty(evidence{nodeid})
+       %%%Print the type of node
+       if bnet.node_sizes(nodeid) == 1;
+           line = 'Continuous parameters considering intervention:\n';
+           fprintf(fileID,line);
+           %line = 'Mean and standard deviation of Gaussian distribution\n';
+           %fprintf(fileID,line);
+	   adj_mu = predict.mu*stdevs{nodeid}+means{nodeid};
+           adj_sigma = stdevs{nodeid}*predict.Sigma;
+           fprintf(fileID,'%6.4f\t%6.4f\n\n',adj_mu,adj_sigma);
+       else
+           line = 'Probability of states considering intervention:\n';
+           fprintf(fileID,line);
+           nodeid2 = 0;
+           for k = 1:ndisc_nodes,
+	     if strcmp(levels{k,1},labels{nodeid}),
+                nodeid2 = k;
+                break
+             end
+            end
+	    for j = 1:bnet.node_sizes(nodeid),
+		%%%For discrete nodes, the state and the percent of that state
+%		fprintf(fileID,'%i\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+		fprintf(fileID,'%s\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+           end;
+           fprintf(fileID,'\n')
+       end
+   else
+       if bnet.node_sizes(nodeid) == 1;
+          line = 'Intervention on this node assigned the following value:\n';
+          fprintf(fileID,line);  
+          adj_mu = ev_dat(nodeid)*stdevs{nodeid}+means{nodeid};
+          fprintf(fileID,'%6.4f\n\n',adj_mu);
+       else
+          nodeid2 = 0;
+          for k = 1:ndisc_nodes,
+	    if strcmp(levels{k,1},labels{nodeid}),
+               nodeid2 = k;
+               break
+            end
+          end
+	 line = 'Intervention on this node assigned the following state:\n';
+         fprintf(fileID,line);
+         state_ev =   uint16(ev_dat(nodeid));
+%         fprintf(fileID,'%i\n\n',levels{nodeid2,state_ev+1});
+         fprintf(fileID,'%s\n\n',levels{nodeid2,state_ev+1});
+       end
+   end
+   end
+end
+
+
+
+fclose(fileID);
+
+end
+
diff --git a/home.php b/home.php
index e6c85c12..93348be2 100644
--- a/home.php
+++ b/home.php
@@ -13,7 +13,7 @@ if($str_arrmat[1]>70.0)
 
 ?>
 <script>
-window.open("http://bnw.genenetwork.org/BNW_1.02/sourcecodes/home.php",'_self',false);
+window.open("http://bnw.genenetwork.org/BNW_1.1/sourcecodes/home.php",'_self',false);
 </script>
 <?php
 }
@@ -21,7 +21,7 @@ else
 {
 ?>    
 <script>
-window.open("http://compbio.uthsc.edu/BNW_1.02/sourcecodes/home.php",'_self',false);
+window.open("http://compbio.uthsc.edu/BNW_1.1/sourcecodes/home.php",'_self',false);
 </script>
 
 <?php
diff --git a/sourcecodes/BNW_workflow_net1.htm b/sourcecodes/BNW_workflow_net1.htm
index ae00ad80..e82f1f41 100644
--- a/sourcecodes/BNW_workflow_net1.htm
+++ b/sourcecodes/BNW_workflow_net1.htm
@@ -292,7 +292,7 @@ ul
 
 <p class=MsoNormal style='margin-right:107.5pt'><span style='font-size:12.0pt;
 line-height:115%;font-family:"Arial","sans-serif"'>This tutorial provides
-an overview of using BNW to build a Bayesian network model from a dataset and use the network to make predictions. The dataset used in this tutorial is a synthetic example of a genetic dataset that has a total of 8 variables. Two of the variables are genotypes labeled Geno1 and Geno2, and the remaining 6 variables are gene expression levels or other quantitative traits that are labeled Trait1 to Trait6. The dataset is available <a href="example_datasets/example_data_8nodes.txt">here</a>.<br><br>The data file is formatted according to the guidelines on the <a href=http://compbio.uthsc.edu/BNW_1.02/sourcecodes/help.php#file_format>BNW help page</a>. The first row of the file contains the names of the variables and the remaining rows contain the data for each sample of the dataset. The genotypes (Geno1 and Geno2), which are the only discrete variables in the network, are the leftmost variables in the input file and are integer values (1 and 2) for all of the samples. The quantitative traits are continuous variables, and, therefore, all contain a "." in at least one of the samples.<o:p></o:p></span></p>
+an overview of using BNW to build a Bayesian network model from a dataset and use the network to make predictions. The dataset used in this tutorial is a synthetic example of a genetic dataset that has a total of 8 variables. Two of the variables are genotypes labeled Geno1 and Geno2, and the remaining 6 variables are gene expression levels or other quantitative traits that are labeled Trait1 to Trait6. The dataset is available <a href="example_datasets/example_data_8nodes.txt">here</a>.<br><br>The data file is formatted according to the guidelines on the <a href=http://compbio.uthsc.edu/BNW_1.1/sourcecodes/help.php#file_format>BNW help page</a>. The first row of the file contains the names of the variables and the remaining rows contain the data for each sample of the dataset. The genotypes (Geno1 and Geno2), which are the only discrete variables in the network, are the leftmost variables in the input file and are integer values (1 and 2) for all of the samples. The quantitative traits are continuous variables, and, therefore, all contain a "." in at least one of the samples.<o:p></o:p></span></p>
 
 <p class=MsoNormal style='margin-right:107.5pt'><b style='mso-bidi-font-weight:
 normal'><span style='font-size:14.0pt;line-height:115%;font-family:"Arial","sans-serif"'>1. Structure learning using default options<o:p></o:p></span></b></p>
@@ -322,7 +322,7 @@ normal'><span style='font-size:14.0pt;line-height:115%;font-family:"Arial","sans
 
 <p class=MsoNormal style='margin-top:0in;margin-right:107.5pt;margin-bottom:
 0in;margin-left:0in;margin-bottom:.0001pt'><span style='font-size:12.0pt;
-line-height:115%;font-family:"Arial","sans-serif";mso-no-proof:yes'>In order to test if edges present the single best scoring network are conserved across high scoring networks. We can modify the structure learning settings to get identify the structures of many high scoring networks and perform <a href=http://compbio.uthsc.edu/BNW_1.02/sourcecodes/help.php#learn_details>model averaging</a> over these structures. To do this, return to the BNW home page, select <u>Learn a network model from data</u>, and upload the datafile. Instead of using the default settings, select <u>Go to structure learning settings and the BNW structural constraint interface</u>. A more detailed overview of use of the structural constraint interface is provided in <a href=http://compbio.uthsc.edu/BNW_1.02/sourcecodes/BNW_workflow_2.htm>another tutorial</a>, but, here, we will investigate the impact of modifying some of the structure learning settings shown below:<br><o:p></o:p></span></p><br>
+line-height:115%;font-family:"Arial","sans-serif";mso-no-proof:yes'>In order to test if edges present the single best scoring network are conserved across high scoring networks. We can modify the structure learning settings to get identify the structures of many high scoring networks and perform <a href=http://compbio.uthsc.edu/BNW_1.1/sourcecodes/help.php#learn_details>model averaging</a> over these structures. To do this, return to the BNW home page, select <u>Learn a network model from data</u>, and upload the datafile. Instead of using the default settings, select <u>Go to structure learning settings and the BNW structural constraint interface</u>. A more detailed overview of use of the structural constraint interface is provided in <a href=http://compbio.uthsc.edu/BNW_1.1/sourcecodes/BNW_workflow_2.htm>another tutorial</a>, but, here, we will investigate the impact of modifying some of the structure learning settings shown below:<br><o:p></o:p></span></p><br>
 
 <p class=MsoNormal style='margin-right:107.5pt'><span style='font-size:12.0pt;
 line-height:115%;font-family:"Arial","sans-serif";mso-no-proof:yes'>
@@ -356,7 +356,7 @@ normal'><span style='font-size:14.0pt;line-height:115%;font-family:"Arial","sans
 
 <p class=MsoNormal style='margin-top:0in;margin-right:107.5pt;margin-bottom:
 0in;margin-left:0in;margin-bottom:.0001pt'><span style='font-size:12.0pt;
-line-height:115%;font-family:"Arial","sans-serif";mso-no-proof:yes'><br>To make predictions with the network, we will use the structure learned after model averaging of the top 100 highest scoring networks. First, we will use the model to compare the expected values for nodes in the network based on observed genotypes. For these predictions, we will keep the prediction in evidence mode. The difference between evidence and intervention modes is discussed in the <a href=http://compbio.uthsc.edu/BNW_1.02/sourcecodes/faq.php#evid_inter>BNW FAQ page</a>. To use the model to make predictions based on Geno1, click on one of the blue bars in the Geno1 node and enter 1 or 2 to indicate which genotype value should be used to predict the values of the other network nodes. In the figure below, Geno1 is outlined in red and state 2 has a 100% probability, indicating that the value of this node has been entered as evidence. The red lines in the figure show the predicted distributions of the nodes after this evidence is known and can be compared with the blue lines which show the distributions for variables using the original data.<o:p></o:p></span></p><br>
+line-height:115%;font-family:"Arial","sans-serif";mso-no-proof:yes'><br>To make predictions with the network, we will use the structure learned after model averaging of the top 100 highest scoring networks. First, we will use the model to compare the expected values for nodes in the network based on observed genotypes. For these predictions, we will keep the prediction in evidence mode. The difference between evidence and intervention modes is discussed in the <a href=http://compbio.uthsc.edu/BNW_1.1/sourcecodes/faq.php#evid_inter>BNW FAQ page</a>. To use the model to make predictions based on Geno1, click on one of the blue bars in the Geno1 node and enter 1 or 2 to indicate which genotype value should be used to predict the values of the other network nodes. In the figure below, Geno1 is outlined in red and state 2 has a 100% probability, indicating that the value of this node has been entered as evidence. The red lines in the figure show the predicted distributions of the nodes after this evidence is known and can be compared with the blue lines which show the distributions for variables using the original data.<o:p></o:p></span></p><br>
 
 <p class=MsoNormal style='margin-right:107.5pt'><span style='font-size:12.0pt;
 line-height:115%;font-family:"Arial","sans-serif";mso-no-proof:yes'>
diff --git a/sourcecodes/add_evd.php b/sourcecodes/add_evd.php
index cba58632..191dc244 100644
--- a/sourcecodes/add_evd.php
+++ b/sourcecodes/add_evd.php
@@ -105,12 +105,16 @@ for($j=0;$j<$nn;$j++)
 
 $dt=$type_d[$s];
  
-if($dt==1)
-   $textdata=reversemap($sym,$textdata,$keyval);
-else
+//if($dt==1)
+//  $textdata=reversemap($sym,$textdata,$keyval);
+//else
+//   $textdata=discretemap($textdata,$sym,$dmapdata);
+
+if($dt!=1)
    $textdata=discretemap($textdata,$sym,$dmapdata);
 
 
+
  $ft=$dir."$keyval"."var.txt"; 
  $f1=fopen("$ft","w");  
  $ft=$dir."$keyval"."vardata.txt";
diff --git a/sourcecodes/add_evd.php~ b/sourcecodes/add_evd.php~
deleted file mode 100644
index 5a5ad2ff..00000000
--- a/sourcecodes/add_evd.php~
+++ /dev/null
@@ -1,204 +0,0 @@
-<?php 
-
-$keyval=trim($_GET['My_key']);
-
-include("restructuremap.php");
-
-
-function discretemap($textdata,$sym,$dmapdata)
-{
-$textdata=trim($textdata);
-$leve_l=array();
-$leve_l=explode("\n",$dmapdata);
-$leve_d=array();
-
-foreach($leve_l as $l)
-{ 
-  $l=trim($l);
-  $leve_d=explode("\t",$l);
-  $inxname=trim($leve_d[0]);
-  $name=trim($sym);
-  if($inxname==$name)
-  {    $i=0;
-       foreach($leve_d as $d)
-       { 
-         $d=trim($d);
-         if($d==$textdata)
-             return $i;
-         $i++;
-       }
-  } 
-}
-
-}
-
-
-
-
-
-function mapid($name,$keyval)
-{
-
-$dir="./data/";
-$nm=$dir.$keyval."mapdata.txt";
-$namelist=file_get_contents("$nm");
-
-$str_arrname=array();
-$str_arrname=explode("\n",$namelist);
-$dataname=array();
-$dataname=explode("\t",$str_arrname[0]);
-$i=1;
-
- foreach($dataname as $cell)
- {
-   $cell=trim($cell);
-   if($cell==$name)
-   {
-    $val=$i;
-    break;      
-   }
-    $i++;
- }
-
-return $val;
-
-}
-
-
-$dir="./data/";
-
-$lfile=$dir.$keyval."nlevels.txt";
-$dmapdata=file_get_contents($lfile);   
-
-
-$sym=trim($_GET['name']);
-
-$textdata=$_GET['evidence'];
-$ft=$dir.$keyval."var.txt";
-$fpvar = file_get_contents("$ft");
-$ft=$dir.$keyval."vardata.txt";
-$fpdata  = file_get_contents("$ft");
-$ft=$dir.$keyval."varname.txt";
-$fpvarname  = file_get_contents("$ft");
-
-$vriable=mapid($sym,$keyval);
-
-$ft=$dir.$keyval."type.txt";
-$type = file_get_contents("$ft");
-$type_r=array();
-$type_r=explode("\n",$type);
-$type_n=array();
-$type_n=explode("\t",$type_r[0]);
-$type_d=array();
-$type_d=explode("\t",$type_r[1]);
-
-$nn=count($type_n);
-
-for($j=0;$j<$nn;$j++)
-{   
-   $dn=$type_n[$j];
-   $sym=trim($sym);
-   $dn=trim($dn); 
-   if($dn==$sym)
-     $s=$j;
-} 
-
-$dt=$type_d[$s];
- 
-if($dt==1)
-   $textdata=reversemap($sym,$textdata,$keyval);
-else
-   $textdata=discretemap($textdata,$sym,$dmapdata);
-
-
- $ft=$dir."$keyval"."var.txt"; 
- $f1=fopen("$ft","w");  
- $ft=$dir."$keyval"."vardata.txt";
- $f2=fopen("$ft","w");  
- $ft=$dir."$keyval"."varname.txt";
- $f3=fopen("$ft","w");
-
-
-$pos = strpos($fpvarname, $sym);
-
-if($fpvarname=="")
-{
-  fwrite($f1,$vriable);
-  fwrite($f2,$textdata);
-  fwrite($f3,$sym);
-
-}
-else 
-{
-  if ($pos === false)// append at buttom as new records 
-  {
-  
-     $fpvar=$fpvar."\t".$vriable;
-     fwrite($f1,$fpvar);
-
-     $fpdata=$fpdata."\t".$textdata;
-     fwrite($f2,$fpdata);
-
-     $fpvarname=$fpvarname."\t".$sym;
-     fwrite($f3,$fpvarname);
-
-  }
-  else 
-  {
-     $cld=explode("\t",$fpvarname);
-     $j=0;
-     $inx=0;
-     foreach($cld as $cc)
-     {
-        $cc=trim($cc);
-        if($cc==$sym)
-        {
-              $inx=$j;
-        } 
-        $j++;
-    
-     }
-
- 
-     fwrite($f1,$fpvar);
-     fwrite($f3,$fpvarname);
-
-     $cld1=explode("\t",$fpdata);
-     $j=0;
-     $dataw="";
-     foreach($cld1 as $cc)
-     {
-        $cc=trim($cc);
-        if($j==$inx)
-        {
-              $inx=$j;
-              fprintf($f2,"%s\t",$textdata);
-        }
-        else 
-        {          
-              fprintf($f2,"%s\t",$cc);
-        }
-        
-        $j++;
-    
-     }
-
-   }
-
-}
-
-
-//  $file1="./data/".$keyval."run_evidencemodified.sh";
-//  $initiallines=file_get_contents("./data/temp_evidence_file");
-//  $all_lines="$initiallines"."$keyval\nfi\nexit";
-   
-//  $fp = fopen($file1,"w"); 
-//  fwrite($fp, "$all_lines\n");
-//  fclose($fp);
-  //execute shell script for matlab
-  shell_exec('./run_octave_evd.sh '.$keyval);
-
-?>
-<script>
-window.open("network_layout_evd_2.php?My_key=<?php print($keyval);?>",'_self',false);
-</script>
diff --git a/sourcecodes/add_evd_example.php b/sourcecodes/add_evd_example.php
index af97c030..03846663 100644
--- a/sourcecodes/add_evd_example.php
+++ b/sourcecodes/add_evd_example.php
@@ -105,11 +105,13 @@ for($j=0;$j<$nn;$j++)
 
 $dt=$type_d[$s];
  
-if($dt==1)
-   $textdata=reversemap($sym,$textdata,$keyval);
-else
-   $textdata=discretemap($textdata,$sym,$dmapdata);
+//if($dt==1)
+//   $textdata=reversemap($sym,$textdata,$keyval);
+//else
+//   $textdata=discretemap($textdata,$sym,$dmapdata);
 
+if($dt!=1)
+   $textdata=discretemap($textdata,$sym,$dmapdata);
 
  $ft=$dir."$keyval"."var.txt"; 
  $f1=fopen("$ft","w");  
diff --git a/sourcecodes/add_evd_example.php~ b/sourcecodes/add_evd_example.php~
deleted file mode 100644
index e3daca1e..00000000
--- a/sourcecodes/add_evd_example.php~
+++ /dev/null
@@ -1,204 +0,0 @@
-<?php 
-
-$keyval=trim($_GET['My_key']);
-
-include("restructuremap.php");
-
-
-function discretemap($textdata,$sym,$dmapdata)
-{
-$textdata=trim($textdata);
-$leve_l=array();
-$leve_l=explode("\n",$dmapdata);
-$leve_d=array();
-
-foreach($leve_l as $l)
-{ 
-  $l=trim($l);
-  $leve_d=explode("\t",$l);
-  $inxname=trim($leve_d[0]);
-  $name=trim($sym);
-  if($inxname==$name)
-  {    $i=0;
-       foreach($leve_d as $d)
-       { 
-         $d=trim($d);
-         if($d==$textdata)
-             return $i;
-         $i++;
-       }
-  } 
-}
-
-}
-
-
-
-
-
-function mapid($name,$keyval)
-{
-
-$dir="./data/";
-$nm=$dir.$keyval."mapdata.txt";
-$namelist=file_get_contents("$nm");
-
-$str_arrname=array();
-$str_arrname=explode("\n",$namelist);
-$dataname=array();
-$dataname=explode("\t",$str_arrname[0]);
-$i=1;
-
- foreach($dataname as $cell)
- {
-   $cell=trim($cell);
-   if($cell==$name)
-   {
-    $val=$i;
-    break;      
-   }
-    $i++;
- }
-
-return $val;
-
-}
-
-
-$dir="./data/";
-
-$lfile=$dir.$keyval."nlevels.txt";
-$dmapdata=file_get_contents($lfile);   
-
-
-$sym=trim($_GET['name']);
-
-$textdata=$_GET['evidence'];
-$ft=$dir.$keyval."var.txt";
-$fpvar = file_get_contents("$ft");
-$ft=$dir.$keyval."vardata.txt";
-$fpdata  = file_get_contents("$ft");
-$ft=$dir.$keyval."varname.txt";
-$fpvarname  = file_get_contents("$ft");
-
-$vriable=mapid($sym,$keyval);
-
-$ft=$dir.$keyval."type.txt";
-$type = file_get_contents("$ft");
-$type_r=array();
-$type_r=explode("\n",$type);
-$type_n=array();
-$type_n=explode("\t",$type_r[0]);
-$type_d=array();
-$type_d=explode("\t",$type_r[1]);
-
-$nn=count($type_n);
-
-for($j=0;$j<$nn;$j++)
-{   
-   $dn=$type_n[$j];
-   $sym=trim($sym);
-   $dn=trim($dn); 
-   if($dn==$sym)
-     $s=$j;
-} 
-
-$dt=$type_d[$s];
- 
-if($dt==1)
-   $textdata=reversemap($sym,$textdata,$keyval);
-else
-   $textdata=discretemap($textdata,$sym,$dmapdata);
-
-
- $ft=$dir."$keyval"."var.txt"; 
- $f1=fopen("$ft","w");  
- $ft=$dir."$keyval"."vardata.txt";
- $f2=fopen("$ft","w");  
- $ft=$dir."$keyval"."varname.txt";
- $f3=fopen("$ft","w");
-
-
-$pos = strpos($fpvarname, $sym);
-
-if($fpvarname=="")
-{
-  fwrite($f1,$vriable);
-  fwrite($f2,$textdata);
-  fwrite($f3,$sym);
-
-}
-else 
-{
-  if ($pos === false)// append at buttom as new records 
-  {
-  
-     $fpvar=$fpvar."\t".$vriable;
-     fwrite($f1,$fpvar);
-
-     $fpdata=$fpdata."\t".$textdata;
-     fwrite($f2,$fpdata);
-
-     $fpvarname=$fpvarname."\t".$sym;
-     fwrite($f3,$fpvarname);
-
-  }
-  else 
-  {
-     $cld=explode("\t",$fpvarname);
-     $j=0;
-     $inx=0;
-     foreach($cld as $cc)
-     {
-        $cc=trim($cc);
-        if($cc==$sym)
-        {
-              $inx=$j;
-        } 
-        $j++;
-    
-     }
-
- 
-     fwrite($f1,$fpvar);
-     fwrite($f3,$fpvarname);
-
-     $cld1=explode("\t",$fpdata);
-     $j=0;
-     $dataw="";
-     foreach($cld1 as $cc)
-     {
-        $cc=trim($cc);
-        if($j==$inx)
-        {
-              $inx=$j;
-              fprintf($f2,"%s\t",$textdata);
-        }
-        else 
-        {          
-              fprintf($f2,"%s\t",$cc);
-        }
-        
-        $j++;
-    
-     }
-
-   }
-
-}
-
-
-//  $file1="./data/".$keyval."run_evidencemodified.sh";
-//  $initiallines=file_get_contents("./data/temp_evidence_file");
-//  $all_lines="$initiallines"."$keyval\nfi\nexit";
-   
-//  $fp = fopen($file1,"w"); 
-//  fwrite($fp, "$all_lines\n");
-//  fclose($fp);
-  //execute shell script for matlab
-  shell_exec('./run_octave_evd.sh '.$keyval);
-
-?>
-<script>
-window.open("network_layout_evd_2_example.php?My_key=<?php print($keyval);?>",'_self',false);
-</script>
diff --git a/sourcecodes/add_inv.php b/sourcecodes/add_inv.php
index 69dab328..d9ec7cbb 100644
--- a/sourcecodes/add_inv.php
+++ b/sourcecodes/add_inv.php
@@ -100,10 +100,14 @@ for($j=0;$j<$nn;$j++)
 
 $dt=$type_d[$s];
  
-if($dt==1)
-   $textdata=reversemap($sym,$textdata,$keyval);
-else
-   $textdata=discretemap($textdata,$sym,$dmapdata);
+//if($dt==1)
+//   $textdata=reversemap($sym,$textdata,$keyval);
+//else
+//   $textdata=discretemap($textdata,$sym,$dmapdata);
+
+if($dt!=1)
+  $textdata=discretemap($textdata,$sym,$dmapdata);
+
 
  $ft=$dir.$keyval."var.txt"; 
  $f1=fopen("$ft","w");  
diff --git a/sourcecodes/add_inv.php~ b/sourcecodes/add_inv.php~
deleted file mode 100644
index 877b4a9a..00000000
--- a/sourcecodes/add_inv.php~
+++ /dev/null
@@ -1,262 +0,0 @@
-<?php 
-include("restructuremap.php");
-$keyval=$_GET["My_key"];
-
-function discretemap($textdata,$sym,$dmapdata)
-{
-$textdata=trim($textdata);
-$leve_l=array();
-$leve_l=explode("\n",$dmapdata);
-$leve_d=array();
-
-foreach($leve_l as $l)
-{ 
-  $l=trim($l);
-  $leve_d=explode("\t",$l);
-  $inxname=trim($leve_d[0]);
-  $name=trim($sym);
-  if($inxname==$name)
-  {    $i=0;
-       foreach($leve_d as $d)
-       { 
-         $d=trim($d);
-         if($d==$textdata)
-             return $i;
-         $i++;
-       }
-  } 
-}
-
-}
-
-
-function mapid($name,$keyval)
-{
-
-$dir="./data/";
-
-$nm=$dir."$keyval"."mapdata.txt";
-$namelist=file_get_contents("$nm");
-
-$str_arrname=array();
-$str_arrname=explode("\n",$namelist);
-$dataname=array();
-$dataname=explode("\t",$str_arrname[0]);
-$i=1;
-
- foreach($dataname as $cell)
- {
-   $cell=trim($cell);
-   if($cell==$name)
-   {
-    $val=$i;
-    break;      
-   }
-    $i++;
- }
-
-return $val;
-
-}
-
-
-$dir="./data/";
-
-$lfile=$dir.$keyval."nlevels.txt";
-$dmapdata=file_get_contents($lfile);
-
-
-$sym=trim($_GET['name']);
-
-$textdata=$_GET['evidence'];
-$ft=$dir.$keyval."var.txt";
-$fpvar = file_get_contents("$ft");
-$ft=$dir.$keyval."vardata.txt";
-$fpdata  = file_get_contents("$ft");
-$ft=$dir.$keyval."varname.txt";
-$fpvarname  = file_get_contents("$ft");
-
-$vriable=mapid($sym,$keyval);
-$ft=$dir.$keyval."type.txt";
-$type = file_get_contents("$ft");
-
-$type_r=array();
-$type_r=explode("\n",$type);
-$type_n=array();
-$type_n=explode("\t",$type_r[0]);
-$type_d=array();
-$type_d=explode("\t",$type_r[1]);
-
-$nn=count($type_n);
-
-for($j=0;$j<$nn;$j++)
-{   
-   $dn=$type_n[$j];
-   $sym=trim($sym);
-   $dn=trim($dn); 
-   if($dn==$sym)
-     $s=$j;
-} 
-
-$dt=$type_d[$s];
- 
-if($dt==1)
-   $textdata=reversemap($sym,$textdata,$keyval);
-else
-   $textdata=discretemap($textdata,$sym,$dmapdata);
-
- $ft=$dir.$keyval."var.txt"; 
- $f1=fopen("$ft","w");  
- $ft=$dir.$keyval."vardata.txt";
- $f2=fopen("$ft","w");  
- $ft=$dir.$keyval."varname.txt";
- $f3=fopen("$ft","w");
-
-
-$pos = strpos($fpvarname, $sym);
-
-if($fpvarname=="")
-{
-  fwrite($f1,$vriable);
-  fwrite($f2,$textdata);
-  fwrite($f3,$sym);
-
-}
-else 
-{
-  if ($pos === false)// append at buttom as new records 
-  {
-  
-     $fpvar=$fpvar."\t".$vriable;
-     fwrite($f1,$fpvar);
-
-     $fpdata=$fpdata."\t".$textdata;
-     fwrite($f2,$fpdata);
-
-     $fpvarname=$fpvarname."\t".$sym;
-     fwrite($f3,$fpvarname);
-
-  }
-  else 
-  {
-     $cld=explode("\t",$fpvarname);
-     $j=0;
-     $inx=0;
-     foreach($cld as $cc)
-     {
-        $cc=trim($cc);
-        if($cc==$sym)
-        {
-              $inx=$j;
-        } 
-        $j++;
-    
-     }
-
- 
-     fwrite($f1,$fpvar);
-     fwrite($f3,$fpvarname);
-
-     $cld1=explode("\t",$fpdata);
-     $j=0;
-     $dataw="";
-     foreach($cld1 as $cc)
-     {
-        $cc=trim($cc);
-        if($j==$inx)
-        {
-              $inx=$j;
-              fprintf($f2,"%s\t",$textdata);
-        }
-        else 
-        {          
-              fprintf($f2,"%s\t",$cc);
-        }
-        
-        $j++;
-    
-     }
-
-   }
-
-}
-
-include("mat_structure.php");
-structure_change($keyval);
-
-
-
-
-
-//  $file1="./data/".$keyval."run_newintervention.sh";
-//  $initiallines=file_get_contents("./data/temp_intervention_file");
-//  $all_lines="$initiallines"."$keyval\nfi\nexit";
-
-//  $fp = fopen($file1,"w"); 
-//  fwrite($fp, "$all_lines\n");
-//  fclose($fp);
-  //execute shell script for matlab
- // $cmd="./runmat_inv.sh $keyval";
-//  system($cmd);
-shell_exec('./run_ocatve_inv '.$keyval);
-
-
-
-
-$matfile=$dir.$keyval."structure_input_new.txt";
-
-$fout=fopen($dir.$keyval."graphviz_new.txt","w");
-$matrix1=file_get_contents("$matfile");           
-$str_arrmat=array();
-$str_arrmat=explode("\n",$matrix1);
-$datamat=array();
-$data_cell=array(); 
-
-$dataname=array();
-$dataname=explode("\t",$str_arrmat[0]);
-$n=count($dataname);
-
-$initialstring="digraph G {\n"."size=\"10,10\";  ratio = fill;\n"."node [shape=square,width=1.5];\n";
-$endstring="}";
-fwrite($fout,"$initialstring");
-
-
-$g_file_name="./data/".$keyval."grviz_name_file_new.txt";
-$grviz_name_file=fopen($g_file_name,"w");
-
-for($i=0;$i<$n;$i++)
-{
-      $row_name=trim($dataname[$i]);  
-      fwrite($grviz_name_file,"$row_name\n");
-}
-
-
-for($i=1;$i<=$n;$i++)
-{
-         $ii=$i-1; 
-         $row_name=trim($dataname[$ii]);  
-
- 
-         $col_arr=explode("\t",$str_arrmat[$i]);
-        
-        
-	   for($j=0;$j<$n;$j++)
-	   {
-               $col_val=trim($col_arr[$j]);
-               if($col_val==1)
-               { 
-                  $col_name=trim($dataname[$j]);
-                  fprintf($fout,"%s -> %s;\n",$ii,$j);  
-
-                 
-	        }
-          }
-          
-     
-} 
-fwrite($fout,"$endstring");   
-
-?>
-<script>
-window.open("network_layout_inv_2.php?My_key=<?php print($keyval);?>",'_self',false);
-</script>
diff --git a/sourcecodes/add_inv_example.php b/sourcecodes/add_inv_example.php
index c3514122..a66e069c 100644
--- a/sourcecodes/add_inv_example.php
+++ b/sourcecodes/add_inv_example.php
@@ -100,11 +100,17 @@ for($j=0;$j<$nn;$j++)
 
 $dt=$type_d[$s];
  
-if($dt==1)
-   $textdata=reversemap($sym,$textdata,$keyval);
-else
+//if($dt==1)
+//   $textdata=reversemap($sym,$textdata,$keyval);
+//else
+//   $textdata=discretemap($textdata,$sym,$dmapdata);
+
+if($dt!=1)
    $textdata=discretemap($textdata,$sym,$dmapdata);
 
+
+
+
  $ft=$dir.$keyval."var.txt"; 
  $f1=fopen("$ft","w");  
  $ft=$dir.$keyval."vardata.txt";
diff --git a/sourcecodes/add_inv_example.php~ b/sourcecodes/add_inv_example.php~
deleted file mode 100644
index 93c70c8d..00000000
--- a/sourcecodes/add_inv_example.php~
+++ /dev/null
@@ -1,251 +0,0 @@
-<?php 
-include("restructuremap.php");
-$keyval=$_GET["My_key"];
-
-function discretemap($textdata,$sym,$dmapdata)
-{
-$textdata=trim($textdata);
-$leve_l=array();
-$leve_l=explode("\n",$dmapdata);
-$leve_d=array();
-
-foreach($leve_l as $l)
-{ 
-  $l=trim($l);
-  $leve_d=explode("\t",$l);
-  $inxname=trim($leve_d[0]);
-  $name=trim($sym);
-  if($inxname==$name)
-  {    $i=0;
-       foreach($leve_d as $d)
-       { 
-         $d=trim($d);
-         if($d==$textdata)
-             return $i;
-         $i++;
-       }
-  } 
-}
-
-}
-
-
-function mapid($name,$keyval)
-{
-
-$dir="./data/";
-
-$nm=$dir."$keyval"."mapdata.txt";
-$namelist=file_get_contents("$nm");
-
-$str_arrname=array();
-$str_arrname=explode("\n",$namelist);
-$dataname=array();
-$dataname=explode("\t",$str_arrname[0]);
-$i=1;
-
- foreach($dataname as $cell)
- {
-   $cell=trim($cell);
-   if($cell==$name)
-   {
-    $val=$i;
-    break;      
-   }
-    $i++;
- }
-
-return $val;
-
-}
-
-
-$dir="./data/";
-
-$lfile=$dir.$keyval."nlevels.txt";
-$dmapdata=file_get_contents($lfile);
-
-
-$sym=trim($_GET['name']);
-
-$textdata=$_GET['evidence'];
-$ft=$dir.$keyval."var.txt";
-$fpvar = file_get_contents("$ft");
-$ft=$dir.$keyval."vardata.txt";
-$fpdata  = file_get_contents("$ft");
-$ft=$dir.$keyval."varname.txt";
-$fpvarname  = file_get_contents("$ft");
-
-$vriable=mapid($sym,$keyval);
-$ft=$dir.$keyval."type.txt";
-$type = file_get_contents("$ft");
-
-$type_r=array();
-$type_r=explode("\n",$type);
-$type_n=array();
-$type_n=explode("\t",$type_r[0]);
-$type_d=array();
-$type_d=explode("\t",$type_r[1]);
-
-$nn=count($type_n);
-
-for($j=0;$j<$nn;$j++)
-{   
-   $dn=$type_n[$j];
-   $sym=trim($sym);
-   $dn=trim($dn); 
-   if($dn==$sym)
-     $s=$j;
-} 
-
-$dt=$type_d[$s];
- 
-if($dt==1)
-   $textdata=reversemap($sym,$textdata,$keyval);
-else
-   $textdata=discretemap($textdata,$sym,$dmapdata);
-
- $ft=$dir.$keyval."var.txt"; 
- $f1=fopen("$ft","w");  
- $ft=$dir.$keyval."vardata.txt";
- $f2=fopen("$ft","w");  
- $ft=$dir.$keyval."varname.txt";
- $f3=fopen("$ft","w");
-
-
-$pos = strpos($fpvarname, $sym);
-
-if($fpvarname=="")
-{
-  fwrite($f1,$vriable);
-  fwrite($f2,$textdata);
-  fwrite($f3,$sym);
-
-}
-else 
-{
-  if ($pos === false)// append at buttom as new records 
-  {
-  
-     $fpvar=$fpvar."\t".$vriable;
-     fwrite($f1,$fpvar);
-
-     $fpdata=$fpdata."\t".$textdata;
-     fwrite($f2,$fpdata);
-
-     $fpvarname=$fpvarname."\t".$sym;
-     fwrite($f3,$fpvarname);
-
-  }
-  else 
-  {
-     $cld=explode("\t",$fpvarname);
-     $j=0;
-     $inx=0;
-     foreach($cld as $cc)
-     {
-        $cc=trim($cc);
-        if($cc==$sym)
-        {
-              $inx=$j;
-        } 
-        $j++;
-    
-     }
-
- 
-     fwrite($f1,$fpvar);
-     fwrite($f3,$fpvarname);
-
-     $cld1=explode("\t",$fpdata);
-     $j=0;
-     $dataw="";
-     foreach($cld1 as $cc)
-     {
-        $cc=trim($cc);
-        if($j==$inx)
-        {
-              $inx=$j;
-              fprintf($f2,"%s\t",$textdata);
-        }
-        else 
-        {          
-              fprintf($f2,"%s\t",$cc);
-        }
-        
-        $j++;
-    
-     }
-
-   }
-
-}
-
-include("mat_structure.php");
-structure_change($keyval);
-
-
-
-
-
-  $file1="./data/".$keyval."run_newintervention.sh";
-  $initiallines=file_get_contents("./data/temp_intervention_file");
-  $all_lines="$initiallines"."$keyval\nfi\nexit";
-
-  $fp = fopen($file1,"w"); 
-  fwrite($fp, "$all_lines\n");
-  fclose($fp);
-  //execute shell script for matlab
- // $cmd="./runmat_inv.sh $keyval";
-//  system($cmd);
-shell_exec('./runmat_inv.sh '.$keyval);
-
-
-
-
-$matfile=$dir.$keyval."structure_input_new.txt";
-
-$fout=fopen($dir.$keyval."graphviz_new.txt","w");
-$matrix1=file_get_contents("$matfile");           
-$str_arrmat=array();
-$str_arrmat=explode("\n",$matrix1);
-$datamat=array();
-$data_cell=array(); 
-
-$dataname=array();
-$dataname=explode("\t",$str_arrmat[0]);
-$n=count($dataname);
-
-$initialstring="digraph G {\n"."size=\"10,10\";  ratio = fill;\n"."node [shape=square,width=1.5];\n";
-$endstring="}";
-fwrite($fout,"$initialstring");
-
-for($i=1;$i<=$n;$i++)
-{
-         $ii=$i-1; 
-         $row_name=trim($dataname[$ii]);  
-
- 
-         $col_arr=explode("\t",$str_arrmat[$i]);
-        
-        
-	   for($j=0;$j<$n;$j++)
-	   {
-               $col_val=trim($col_arr[$j]);
-               if($col_val==1)
-               { 
-                  $col_name=trim($dataname[$j]);
-                  fprintf($fout,"%s -> %s;\n",$row_name,$col_name);  
-
-                 
-	        }
-          }
-          
-     
-} 
-fwrite($fout,"$endstring");   
-
-?>
-<script>
-window.open("network_layout_inv_2_example.php?My_key=<?php print($keyval);?>",'_self',false);
-</script>
diff --git a/sourcecodes/bn_file_load_gom.php b/sourcecodes/bn_file_load_gom.php
index 342afe02..8f14aa7a 100644
--- a/sourcecodes/bn_file_load_gom.php
+++ b/sourcecodes/bn_file_load_gom.php
@@ -1,5 +1,7 @@
 <?php
-////////////////This code load a data file and creates input file for continuous global optimal search (our modification). execute_bn_gom.php link is for execution of structure learning and create_tiers_gom.php is for adding restrictions///////////////////////////////////
+  //Going to modify this so it just writes the uploaded data to a file.
+  //Standardization and determining other factors will be performed in
+  //  a Matlab/Octave script.
 
 include("header_new.inc");
 include("header_batchsearch.inc");
@@ -8,6 +10,7 @@ $searchID="";
 $UploadValue="NO";
 $TextFile=$HTTP_POST_FILES["MyFile"]["name"];
 
+
 /////////////Generate a random key/////////////////////
 $alphas=array();
 $alphas = array_merge(range('A', 'Z'), range('a', 'z'));
@@ -24,39 +27,11 @@ if($_POST["My_key"]!="")
   $keyval=$_POST["My_key"];
 
 
-////////////////////max parent/////////////////////////
-
-
-$type_n=array();
-
-//Get number of parent data and key value for changes in number of parent
-$type_n=explode("|",$_POST["nm_parent"]);
-if($keyval=="")
-   $keyval=$type_n[0];
-
 $sid=$keyval."continuous_input";
 $dir="./data/";
 
-$TextinFileFinal=$dir.$sid.".txt";
-$TextinFile=$dir.$sid."_temp.txt";
-$TextinFilenamelist=$dir.$keyval."name.txt";
-
-//print default number of parents
-$parent_number=4;
-$pfile=$dir.$keyval."parent.txt";
-$parentf=fopen($pfile,"w");
-fwrite($parentf,"$parent_number\n");
+$TextinFile=$dir.$sid."_orig.txt";
 
-//print default number of k for model averaging
-$k_number=1;
-$kfile=$dir.$keyval."k.txt";
-$kf=fopen($kfile,"w");
-fwrite($kf,"$k_number\n");
-
-//print default threshold for model averaging
-$thrfile=$dir.$keyval."thr.txt";
-$kf=fopen($thrfile,"w");
-fwrite($kf,"0.5\n");
 
 if(isset($HTTP_POST_VARS["searchkey"]))
 {
@@ -69,10 +44,6 @@ if($searchID!="")
 ?>
 
 <!-- Site navigation menu -->
-<ul class="navbar2">
-  <li><a href="executionprogress.php?My_key=<?php print($keyval);?>">Perform Bayesian network modeling using default settings</a>
-  <li><a href="create_tiers_gom.php?My_key=<?php print($keyval);?>">Go to structure learning settings and the BNW structural constraint interface</a>  
-</ul>
 <ul class="navbar">
   <li><a href="help.php#file_format" target="_blank">Data formatting guidelines</a> 
   <li><a href="help.php" target="_blank">Help</a>
@@ -111,7 +82,7 @@ if(isset($HTTP_POST_VARS["MyUpload"]))
             else
             {
                 $searchID=file_get_contents("$TextinFile");
-		  unlink($TextinFile);
+		//unlink($TextinFile);
 
             }
 
@@ -140,7 +111,7 @@ if(isset($HTTP_POST_VARS["MyUpload"]))
 </tr>
 <tr>
 <td align="left"><font color=#33339f><br>Content of uploaded data file:</font><br>
-          <textarea name="searchkey" rows="10" cols="100"><?PHP print($searchID)?> </textarea>
+          <textarea name="searchkey" rows="8" cols="100"><?PHP print($searchID)?> </textarea>
 </td>
 </tr>
 <tr>
@@ -176,220 +147,41 @@ if(isset($HTTP_POST_VARS["MyUpload"]))
 </table>
 </FORM>
 </div>
-<?php
-//////////////////Format data for Structure learning "C" code////////
-
-  $str_arr=array();
-  $searchID=trim($searchID);
-  $str_arr=explode("\n",$searchID);
-  $data=array();
-
-   
-  $fph = fopen($TextinFilenamelist,"w");
-  $fpmain = fopen($TextinFileFinal,"w");
-
-  $cont_arr=array();
-  $cont_arr_tmp=array();
-
-
-  $data_type=array();
-  $level_arr=array();
-
-//Who is discrete? Who is continuous?
-  $i=0;
-  $lc=0;
-  foreach($str_arr as $line)
-  {
-    $line=trim($line); 
-    if($lc==0)
-      {
-       fwrite($fph, "$line\n");
-	fprintf($fpmain, "$line\n");
-       $name_t=$line;
-
-	fclose($fph); 
-       $data=explode("\t",$line);
-	$j=0;
-       foreach($data as $d_c)
-	  {
-           $d_c=trim($d_c);
-           $level_arr[$j][0]=$d_c;  //variable name y for 
-            
-	    $data_type[$j]=0;
-            $j++;
-          }
-          $lcc=$j;  //$lcc=number of column in the input file 
-      }        
-    else
-      { 
-        
-        $strline=""; 
-        $data=explode("\t",$line);
-	 $j=0;
-        foreach($data as $d_c) 
-        {
-            $d_c=trim($d_c);
-	     $cont_arr[$i][$j]=$d_c; 
-            $cont_arr_tmp[$i][$j]=$d_c; 
-
-            $mystring = $d_c;
-	     $findme   = '.';
-	     $pos = strpos($mystring, $findme);
-            $strline.="1\t";
-  
-            if ($pos != false)
-            {
-                $data_type[$j]=1;
-            }
-            $j++;
-         }
-	 $i++; 
-    
-      }
-     $lc++;
-     
-  }
-$lc--; //$lc=number of rows in the input file
-//Now count number of labels for discrete variables and populate the $data_type[$j] 
-$data_count=0;
-$l_type="";
-for($j=0;$j<$lcc;$j++)
-{
-
-       if($data_type[$j]!=1)
-	{
-	  $data_count=0;
-	  for($i=0;$i<$lc;$i++)
-	  {
-              $vi=$i+1;
-	       for($ii=$vi;$ii<$lc;$ii++)
-	       {
-                 if($cont_arr[$i][$j]==$cont_arr[$ii][$j] && $cont_arr[$i][$j]!=-9999)
-		   {
-		       $cont_arr[$ii][$j]=-9999; 
-               
-		   } 
-	       }
-               
-              
-         }
-	  for($i=0;$i<$lc;$i++)
-	     {
-	       if($cont_arr[$i][$j]!=-9999 && $cont_arr[$i][$j]!="")
-		{
-                  // $data_count_l=$data_count+2;
-                  $data_count++;
-                  $level_arr[$j][$data_count]=$cont_arr[$i][$j];
-              }
-	     }
-	  $data_type[$j]=$data_count;
-	    
-	   
-	}
-       if($j==0)
-         $l_type.=$data_type[$j];
-       else
-	 $l_type.="\t".$data_type[$j];  
-      
-    }
-
-///////////////////Write data to files/////////////////
-$fptype = fopen($dir.$keyval."type.txt","w");
-$fpnode= fopen($dir.$keyval."nnode.txt","w");
-fwrite($fpnode,"$lcc\n");
-$fprows = fopen($dir.$keyval."nrows.txt","w");
-fwrite($fprows,"$lc\n");
-$flevel = fopen($dir.$keyval."nlevels.txt","w");
-
-//print in level mapping file for discrete variables
-for($j=0;$j<$lcc;$j++)
-{
-  if($data_type[$j]>1)
-  {  
-      fprintf($flevel,"%s",$level_arr[$j][0]);
-      $m=$data_type[$j];
-      for($jj=1;$jj<=$m;$jj++)
-      {
-         fprintf($flevel,"\t%s",$level_arr[$j][$jj]);
-      }
-
-      fprintf($flevel,"\n");  
-  }   
-}
-
-
-fwrite($fptype,"$name_t\n");
-for($j=0;$j<$lcc;$j++)
-{
-  fprintf($fptype,"$data_type[$j]\t");
-}
-fwrite($fptype,"\n");
-
-  
-fwrite($fpmain, "$l_type\n");
-$l_c=0;
-
-//perform discrete level replacement 
-for($m=0;$m<$lcc;$m++)  //column
-{
-  if($data_type[$m]>1)
-  {
-     $r=$data_type[$m];
-     for($j=1;$j<=$r;$j++)
-     {  
-         $search=$level_arr[$m][$j];
-         $replace=$j."#";
-         for($n=0;$n<$lc;$n++)  //row
-         { 
-           $val=$cont_arr_tmp[$n][$m];
-           if($val==$search)
-               $cont_arr_tmp[$n][$m]=$replace;  //alter levels 
-         }
-     }
-     for($n=0;$n<$lc;$n++)  //row
-          $cont_arr_tmp[$n][$m]=str_replace('#','',$cont_arr_tmp[$n][$m]);
-  }
-}
-
-//write data to output file
-for($j=0;$j<$lc;$j++)
-{
-  fprintf($fpmain,"%s",$cont_arr_tmp[$j][0]);
-  for($jj=1;$jj<$lcc;$jj++)
-    fprintf($fpmain,"\t%s",$cont_arr_tmp[$j][$jj]);
-  fprintf($fpmain, "\n");
-}
-
-fclose($fpmain);
-
-////////////////empty ban and white list/////////////////////////////
-
-$sid1=$keyval."ban";
-$sid2=$keyval."white";
-$wdir="./data/"; 
 
-$Textban=$wdir.$sid1.".txt";
-$Textwhite=$wdir.$sid2.".txt";
-
-$fpb = fopen($Textban,"w");
-$fpw = fopen($Textwhite,"w");
-
-$datpost="From\tTo\n";
+<?php
 
-fwrite($fpb,"$datpost");
-fwrite($fpw,"$datpost");
 if($searchID!="")
 {
-
-$runtime=exe_time($keyval,$parent_number,$k_number);
+  if ($UploadValue=="NO")
+  {
+      $fpdata = fopen($dir.$keyval."continuous_input_orig.txt","w");
+      fwrite($fpdata,$searchID);
+  }  
+  shell_exec('./run_prep_input '.$keyval);
+  $parent_number=4;
+  $k_number=1;
+  $runtime=exe_time($keyval,$parent_number,$k_number);
 ?>
+<ul class="navbar2">
+  <li><a href="javascript:void(0);"
+NAME="InputCheck" title="InputCheck"
+    onClick=window.open("input_check.php?My_key=<?php print($keyval);?>","Rat//ting","width=950,height=270,0,status=0,");>View uploaded variables and data</a>
+  <li><a href="executionprogress.php?My_key=<?php print($keyval);?>">Perform Bayesian network modeling using default settings</a>
+  <li><a href="create_tiers_gom.php?My_key=<?php print($keyval);?>">Go to structure learning settings and the BNW structural constraint interface</a>  
+</ul>
 <div id="outernew">
 <p><h3><?php 
 print("Estimated run time for current dataset using default settings: $runtime seconds");
 ?>
-<br><br></h3>
+<br><br><br><br></h3>
 </p>
 <br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
 </div>
 <?php
 }
diff --git a/sourcecodes/execute_bn_gom.php~ b/sourcecodes/execute_bn_gom.php~
deleted file mode 100644
index f7c234d1..00000000
--- a/sourcecodes/execute_bn_gom.php~
+++ /dev/null
@@ -1,98 +0,0 @@
-
-<?php 
-$keyval=$_GET["My_key"];
-
-//////////////execute c codes for local score///////////////////
-$dir="./data/";
-
-$pfile="./data/".$keyval."parent.txt";
-$parentf=file_get_contents("$pfile");
-$maxp=trim($parentf);
-
-
-$kfile="./data/".$keyval."k.txt";
-$kf=file_get_contents("$kfile");
-$maxk=trim($kf);
-
-
-
-$thrfile="./data/".$keyval."thr.txt";
-$thr=file_get_contents("$thrfile");
-$thr=trim($thr);
-
-
-//$cmd="./run.sh $keyval $maxp $maxk";
-//system($cmd);
-shell_exec('./run.sh '.$keyval.' '.$maxp.' '.$maxk.' '.$thr);
-
-/////////////////////////////////structure matrix//////////////////////////////////////////////////////////
-
-$matfile=$dir.$keyval."structure_input.txt";
-
-$fout=fopen($dir.$keyval."graphviz.txt","w");
-
-$matrix1=file_get_contents("$matfile");           
-$str_arrmat=array();
-$str_arrmat=explode("\n",$matrix1);
-$datamat=array();
-$data_cell=array(); 
-
-$dataname=array();
-$dataname=explode("\t",$str_arrmat[0]);
-$n=count($dataname);
-
-$initialstring="digraph G {\n"."size=\"10,10\";  ratio = fill;\n"."node [shape=square,width=1.5];\n";
-$endstring="}";
-fwrite($fout,"$initialstring");
-
-$g_file_name="./data/".$keyval."grviz_name_file.txt";
-$grviz_name_file=fopen($g_file_name,"w");
-
-for($i=0;$i<$n;$i++)
-{
-      $row_name=trim($dataname[$i]);  
-      fwrite($grviz_name_file,"$row_name\n");
-}
-
-for($i=1;$i<=$n;$i++)
-{
-         $ii=$i-1; 
-         $row_name=trim($dataname[$ii]);  
-
-         $col_arr=explode("\t",$str_arrmat[$i]);
-        
-        
-	   for($j=0;$j<$n;$j++)
-	   {
-               $col_val=trim($col_arr[$j]);
-               if($col_val==1)
-               { 
-                  $col_name=trim($dataname[$j]);
-                  fprintf($fout,"%s -> %s;\n",$ii,$j);  
-                  //fprintf($fouttemp,"%s -> %s;\n",$row_name,$col_name);
-                 
-	        }
-          }
-          
-     
-} 
-fwrite($fout,"$endstring");   
-fclose($fout);
-
-$file1="./data/".$keyval."run_initialstructure.sh";
-$initiallines=file_get_contents("./data/temp_shell_file_initial_structure");
-$all_lines="$initiallines"."$keyval\nfi\nexit";
-$fp = fopen($file1,"w"); 
-fwrite($fp, "$all_lines\n");
-fclose($fp);
-//prepare and execute shell script for matlab with a write lock
-//$cmd="./runmat.sh $keyval";
-//system($cmd);
-
-shell_exec('./run_octave '.$keyval);
-
-?>
-<script>
-window.open("layout.php?My_key=<?php print($keyval);?>",'_self',false);
-</script>
-
diff --git a/sourcecodes/graphviz_structure.php~ b/sourcecodes/graphviz_structure.php~
deleted file mode 100644
index 251c7557..00000000
--- a/sourcecodes/graphviz_structure.php~
+++ /dev/null
@@ -1,97 +0,0 @@
-<script language="JavaScript">
-<!--
-function calcHeight()
-{
-  //find the height of the internal page
-  var the_height=
-    document.getElementById('the_iframe').contentWindow.
-      document.body.scrollHeight;
-
-  //change the height of the iframe
-  document.getElementById('the_iframe').height=
-      the_height;
-}
-//-->
-</script>
-
-
-<?php 
-include("header_new.inc");
-$keyval=$_GET["My_key"];
-
-/////////////////////////////////structure matrix//////////////////////////////////////////////////////////
-
-
-$matfile="./data/".$keyval."structure_input.txt";
-$fout=fopen("./data/".$keyval."graphviz.txt","w");
-
-$matrix1=file_get_contents("$matfile");           
-$str_arrmat=array();
-$str_arrmat=explode("\n",$matrix1);
-$datamat=array();
-$data_cell=array(); 
-
-$dataname=array();
-$dataname=explode("\t",$str_arrmat[0]);
-$n=count($dataname);
-
-$initialstring="digraph G {\n"."size=\"10,10\";  ratio = fill;\n"."node [shape=square,width=1.5];\n";
-$endstring="}";
-fwrite($fout,"$initialstring");
-//fwrite($fouttemp,"$initialstring_temp");
-
-
-$g_file_name="./data/".$keyval."grviz_name_file.txt";
-$grviz_name_file=fopen($g_file_name,"w");
-
-for($i=0;$i<$n;$i++)
-{
-      $row_name=trim($dataname[$i]);  
-      fwrite($grviz_name_file,"$row_name\n");
-}
-
-for($i=1;$i<=$n;$i++)
-{
-         $ii=$i-1; 
-         $row_name=trim($dataname[$ii]);  
-
- 
-         $col_arr=explode("\t",$str_arrmat[$i]);
-        
-        
-	   for($j=0;$j<$n;$j++)
-	   {
-               $col_val=trim($col_arr[$j]);
-               if($col_val==1)
-               { 
-                  $col_name=trim($dataname[$j]);
-                  fprintf($fout,"%s -> %s;\n",$ii,$j);  
-                  //fprintf($fouttemp,"%s -> %s;\n",$row_name,$col_name);
-                 
-	        }
-          }
-          
-     
-} 
-fwrite($fout,"$endstring");   
-//fwrite($fouttemp,"$endstring");
- 
-//shell_exec('/usr/bin/dot -Tpng -o /var/www/html/compbio/BNW/graphviz.jpg /var/www/html/compbio/BNW/graphviztemp.txt');
-
-$file1="./data/".$keyval."run_initialstructure.sh";
-$initiallines=file_get_contents("./data/temp_shell_file_initial_structure");
-$all_lines="$initiallines"."$keyval\nfi\nexit";
-$fp = fopen($file1,"w"); 
-fwrite($fp, "$all_lines\n");
-fclose($fp);
-//prepare and execute shell script for matlab with a write lock
-//$cmd="./runmat.sh $keyval";
-//system($cmd);
-shell_exec('./runmat.sh '.$keyval);
-?>
-<script>
-window.open("layout.php?My_key=<?php print($keyval);?>",'_self',false);
-</script>
-
-
-
diff --git a/sourcecodes/header_batchsearch.inc b/sourcecodes/header_batchsearch.inc
index 9cf50178..95ff5687 100644
--- a/sourcecodes/header_batchsearch.inc
+++ b/sourcecodes/header_batchsearch.inc
@@ -65,7 +65,7 @@ function demochl()
   with(window.document.key_search)
   {
 
-searchkey.value="Ctrq3\tMAS\tNeutrophil\tLoad\tWeight\n2\t0.969230769\t3\t3.252367514\t1\n2\t0.925170068\t1.6\t2.46322088\t1.033472803\n1\t0.427272727\t33.8\t4.206610024\t0.831372549\n2\t0.877835951\t8.3\t3.764250875\t0.967153285\n2\t0.914862915\t4.4\t3.691700208\t1.046025105\n2\t0.560334528\t4.9\t2.604550033\t0.98046875\n1\t0.383073497\t13.1\t4.273556814\t0.812316716\n1\t0.101010101\t18.6\t5.089640217\t0.771929825\n1\t0.106719368\t18.9\t4.915125346\t0.80994152\n2\t0.894736842\t2.5\t2.691700208\t0.995515695\n1\t0.067226891\t19.8\t4.878194228\t0.846153846\n2\t0.921022067\t2.9\t4.127428778\t1.03875969\n2\t0.938701923\t0.7\t4.366310867\t0.984732824\n1\t0.658008658\t15.7\t4.531121115\t0.884210526\n2\t0.9\t4.8\t2.604550033\t0.913194444\n2\t0.790923825\t10.4\t2.390670213\t0.892857143\n1\t0.295539033\t8.6\t4.24137213\t0.85840708\n2\t0.317757009\t12.2\t4.449648073\t0.889830508\n1\t0.032418953\t20.2\t5.053428044\t0.811320755\n1\t0.603960396\t23.4\t4.283775979\t0.805460751\n2\t0.939351199\t3.6\t2.349277527\t0.952380952\n1\t0.978448276\t0.4\t3.495405563\t0.8875\n1\t0.1\t23.2\t4.675613388\t0.766101695\n1\t0.036363636\t32.6\t4.938109253\t0.828125\n1\t0.660247593\t9.2\t3.826398782\t0.921052632\n1\t0.078651685\t35.8\t4.513630383\t0.852112676\n1\t0.186915888\t20.7\t5.048247532\t0.779761905\n1\t0.071578947\t35.6\t4.574586809\t0.797356828\n1\t0.239520958\t15.4\t4.331548761\t0.941176471\n1\t0.205741627\t24.5\t5.058547488\t0.774193548\n1\t0.062300319\t13.4\t4.594790195\t0.832236842\n2\t0.599675851\t5\t4.18178644\t0.969348659\n1\t0.324246772\t13.5\t4.252367514\t0.858585859\n1\t0.87628866\t14.2\t2.929061124\t0.869863014\n1\t0.146103896\t15.6\t4.579726449\t0.9\n1\t0.257383966\t22.5\t5.210214148\t0.75\n1\t0.033333333\t31.1\t4.632578756\t0.718644068\n1\t0.29739777\t36.1\t3.880756445\t0.798353909\n2\t0.872979215\t4.2\t4.097465554\t0.856756757\n2\t0.909221902\t4.3\t3.650307523\t0.976\n1\t0.10041841\t28.3\t4.46322088\t0.757462687";
+searchkey.value="Ctrq3\tMAS\tNeutrophil\tLoad\tWeight\n2\t0.969230769\t3\t3.252367514\t1\n2\t0.925170068\t1.6\t2.46322088\t1.033472803\n1\t0.427272727\t33.8\t4.206610024\t0.831372549\n2\t0.877835951\t8.3\t3.764250875\t0.967153285\n2\t0.914862915\t4.4\t3.691700208\t1.046025105\n2\t0.560334528\t4.9\t2.604550033\t0.98046875\n1\t0.383073497\t13.1\t4.273556814\t0.812316716\n1\t0.101010101\t18.6\t5.089640217\t0.771929825\n1\t0.106719368\t18.9\t4.915125346\t0.80994152\n2\t0.894736842\t2.5\t2.691700208\t0.995515695\n1\t0.067226891\t19.8\t4.878194228\t0.846153846\n2\t0.921022067\t2.9\t4.127428778\t1.03875969\n2\t0.938701923\t0.7\t4.366310867\t0.984732824\n1\t0.658008658\t15.7\t4.531121115\t0.884210526\n2\t0.9\t4.8\t2.604550033\t0.913194444\n2\t0.790923825\t10.4\t2.390670213\t0.892857143\n1\t0.295539033\t8.6\t4.24137213\t0.85840708\n2\t0.317757009\t12.2\t4.449648073\t0.889830508\n1\t0.032418953\t20.2\t5.053428044\t0.811320755\n1\t0.603960396\t23.4\t4.283775979\t0.805460751\n2\t0.939351199\t3.6\t2.349277527\t0.952380952\n1\t0.978448276\t0.4\t3.495405563\t0.8875\n1\t0.1\t23.2\t4.675613388\t0.766101695\n1\t0.036363636\t32.6\t4.938109253\t0.828125\n1\t0.660247593\t9.2\t3.826398782\t0.921052632\n1\t0.078651685\t35.8\t4.513630383\t0.852112676\n1\t0.186915888\t20.7\t5.048247532\t0.779761905\n1\t0.071578947\t35.6\t4.574586809\t0.797356828\n1\t0.239520958\t15.4\t4.331548761\t0.941176471\n1\t0.205741627\t24.5\t5.058547488\t0.774193548\n1\t0.062300319\t13.4\t4.594790195\t0.832236842\n2\t0.599675851\t5\t4.18178644\t0.969348659\n1\t0.324246772\t13.5\t4.252367514\t0.858585859\n1\t0.87628866\t14.2\t2.929061124\t0.869863014\n1\t0.146103896\t15.6\t4.579726449\t0.9\n1\t0.257383966\t22.5\t5.210214148\t0.75\n1\t0.033333333\t31.1\t4.632578756\t0.718644068\n1\t0.29739777\t36.1\t3.880756445\t0.798353909\n2\t0.872979215\t4.2\t4.097465554\t0.856756757\n2\t0.909221902\t4.3\t3.650307523\t0.976\n1\t0.10041841\t28.3\t4.46322088\t0.757462687\n";
    }
 }
 
diff --git a/sourcecodes/input_check.php b/sourcecodes/input_check.php
new file mode 100644
index 00000000..b3c0a421
--- /dev/null
+++ b/sourcecodes/input_check.php
@@ -0,0 +1,16 @@
+<?php $keyval=$_GET["My_key"]; ?>
+
+<h3> <a href=<?php $d="./data/".$keyval."input_desc.txt"; print($d);?>>View variable descriptions</a></h3>
+<br>
+
+<br>
+
+<?php
+$filename="./data/".$keyval."continuous_input_orig.txt";
+if(file_exists($filename)) 
+{?>
+<h3> <a href=<?php $d="./data/".$keyval."continuous_input_orig.txt"; print($d);?>>View uploaded data file</a></h3>
+<br>
+<?php
+}
+?>
diff --git a/sourcecodes/layout.php b/sourcecodes/layout.php
index 85d089b5..e5f4c6b1 100644
--- a/sourcecodes/layout.php
+++ b/sourcecodes/layout.php
@@ -84,6 +84,9 @@ function calcHeight()
   <li><a href="javascript:void(0);"
 NAME="Model Averaging Matrix" title="Model Averaging Matrix"
 onClick=window.open("matrix.php?My_key=<?php print($keyval);?>","Ratting","width=950,height=270,0,status=0,");>Display structure matrix</a>  
+  <li><a href="javascript:void(0);"
+NAME="Parameters" title="Parameters"
+onClick=window.open("parameter_display.php?My_key=<?php print($keyval);?>","Ratting","width=950,height=270,0,status=0,");>View parameters</a>  
  <li><a href="help.php" target='_blank'>Help</a> 
  <li><a href="../home.php">Home</a>
 </ul>
diff --git a/sourcecodes/layout_example.php b/sourcecodes/layout_example.php
index b5f53a6b..130b8b7c 100644
--- a/sourcecodes/layout_example.php
+++ b/sourcecodes/layout_example.php
@@ -84,6 +84,9 @@ function calcHeight()
   <li><a href="javascript:void(0);"
 NAME="Model Averaging Matrix" title="Model Averaging Matrix"
 onClick=window.open("matrix.php?My_key=<?php print($keyval);?>","Ratting","width=950,height=270,0,status=0,");>Display structure matrix</a>  
+  <li><a href="javascript:void(0);"
+NAME="Parameters" title="Parameters"
+onClick=window.open("parameter_display.php?My_key=<?php print($keyval);?>","Ratting","width=950,height=270,0,status=0,");>View parameters</a>  
  <li><a href="help.php" target='_blank'>Help</a> 
  <li><a href="home.php">Home</a>
 </ul>
diff --git a/sourcecodes/my_new_style.css b/sourcecodes/my_new_style.css
index 20db184f..8e88862f 100644
--- a/sourcecodes/my_new_style.css
+++ b/sourcecodes/my_new_style.css
@@ -44,7 +44,7 @@ body {
   text-align:left;
   background:white;
   min-width:50%;
-  min-hieght:50%;
+  min-height:50%;
   max-width:70%;
 
 }
@@ -58,7 +58,7 @@ body {
   text-align:left;
   background:white;
   min-width:50%;
-  min-hieght:50%;
+  min-height:50%;
   max-width:60%;
 
 }
@@ -72,7 +72,7 @@ body {
   text-align:left;
   background:white;
   min-width:50%;
-  min-hieght:50%;
+  min-height:50%;
   max-width:60%;
 
 }
diff --git a/sourcecodes/network_layout_evd.php b/sourcecodes/network_layout_evd.php
index 4efd35da..09554624 100644
--- a/sourcecodes/network_layout_evd.php
+++ b/sourcecodes/network_layout_evd.php
@@ -1,6 +1,9 @@
 <?php 
 include("structuremap.php");
 
+//This function is used to transfer between the integral
+//  levels for discrete nodes that required by BNT and
+//  the actual states of the levels that are in the input file.
 function levelmap($inx,$name,$mapdata)
 {
 
@@ -21,7 +24,8 @@ foreach($leve_l as $l)
 }
 
 
-////////////////////////////////////Read data from net_figure file///////////////////////Graphp Display/////////////////////////////////////////////
+/////////////Read data from net_figure file/////////////
+
 $dir="./data/";
 
 
@@ -44,7 +48,7 @@ $str_arrmat=explode("\n",$matrix1);
 if($str_arrmat[2]=="" || $matrix1=="")
 {
 ?>
-  <h1><font color=blue>Error: Unable to display your network structure 1.</font></h1>
+  <h1><font color=blue>Error: Unable to display your network structure.</font></h1>
 <?php
 exit;
 }
@@ -53,36 +57,10 @@ $datamat=array();
 $data_read=array();
  
 $node=trim($str_arrmat[0]);
-/*
-if($node<=5)
-{
-  $width=200;
-  $hieght=150;
-  $font=14;
-}
-else if($node>5 && $node<=7)
-{
-  $width=150;
-  $hieght=120;
-  $font=12;
 
-}
-else if($node>7 && $node<=10)
-{
-  $width=110;
-  $hieght=85;
-  $font=10;
-}
-else 
-{
-  $width=80;
-  $hieght=60;
-  $font=8;
-}
-*/
-  $width=150;
-  $hieght=150;
-  $font=12;
+$width=150;
+$height=150;
+$font=12;
 
 $r_index=$node+2;
 
@@ -93,26 +71,21 @@ $data_read[$i][0]=trim($datamat[0]);  //name
 $data_read[$i][1]=trim($datamat[1]);  //datatype
 $col_in=2;
 $r_index+=4;
-	if($datamat[1]==1)  //type=coninuous
+	if($datamat[1]==1)  //type=continuous
 	{
          for($j=1;$j<=101;$j++)
          {
            $datamat=explode("\t",$str_arrmat[$r_index]);
            $data_read[$i][$col_in]=trim($datamat[0]);  //x data
-         //  echo $data_read[$i][$col_in];
-          // echo '&nbsp';
 
            $col_in++;
            $data_read[$i][$col_in]=trim($datamat[1]);  //y data
-          // echo $data_read[$i][$col_in];
-	   // echo '&nbsp';
 
            $col_in++;
            $r_index++; // increment to point next data
-           // echo "<br />"; 
          } 
 	}
-	if($datamat[1]>1)  //type=descrete
+	if($datamat[1]>1)  //type=discrete
 	{
          $iter=$datamat[1];
          for($j=1;$j<=$iter;$j++)
@@ -120,46 +93,28 @@ $r_index+=4;
            $datamat=explode("\t",$str_arrmat[$r_index]);
            $data_read[$i][$col_in]=trim($datamat[0]);  //x data
            //use level mapping
-           $data_read[$i][$col_in]=levelmap($data_read[$i][$col_in],$data_read[$i][0],$levelmap);
+	   $data_read[$i][$col_in]=levelmap($data_read[$i][$col_in],$data_read[$i][0],$levelmap);
  
            $col_in++;
            $data_read[$i][$col_in]=trim($datamat[1]);  //y data
          
            $col_in++;
            $r_index++; // increment to point next data
-           //echo "<br />"; 
          } 
 	}
 
 }
 
 
-
-
-////////////////////////////////////////////////Graphviz data read////////////////////////////////////////////////////////////////////////////////
+/////////Graphviz data read////////////////
 
 $grv=$dir.$keyval."graphviz.txt";
 $line=shell_exec('/usr/bin/dot -Tplain -y '.$grv);
-
-
 $grviz_name_list=array();
 $g_file_name="./data/".$keyval."grviz_name_file.txt";
 $grviz_name=file_get_contents("$g_file_name");
 $grviz_name_list=explode("\n",$grviz_name);
 
-
-
-//$foutnew=fopen("contentofgraphviz.txt","w");
-//fwrite($foutnew,"$line");
-
-
-//$grfilename=$keyval."graphviz.txt";
-//$cmd="/usr/bin/dot -Tplain -y  $grfilename";
-//$line=system($cmd);
-
-
-
-
 $str_arrname=array();
 $str_arrname=explode("\n",$line);
 $data=array();
@@ -171,42 +126,29 @@ foreach($str_arrname as $row)
   $i++;
   if($i>1)
   {
-       
-  	$data=explode(" ",$row);
+       $data=explode(" ",$row);
        $j=0;
        $k=0;
        $flag=0;
   	foreach($data as $cell)
 	{
-             
              $j++;
-             
              $cell=trim($cell);
-             //echo $cell;
-             //echo '&nbsp';
              if($j==1 && $cell=="node")
              {
                 $flag=1;
              }  
-               
              if($j>1 && $j<5 && $flag==1)
              {
-    		  //echo $cell;
-   		  //echo '&nbsp';
                 if($j==2)
                 {
-                    
                    $ID_data[$ii][$k]=$grviz_name_list[$cell];
                 } 
                 else
                    $ID_data[$ii][$k]=round($cell/10*900);
-               // echo $ID_data[$ii][$k];
-                //echo '&nbsp';
-
                 $k++; 
              }
        } 
-  
        if($flag==1)
        {
           $ID_data[$ii][3]=$ID_data[$ii][1]+100;
@@ -214,10 +156,7 @@ foreach($str_arrname as $row)
           $ID_data[$ii][5]=$ID_data[$ii][1]+100;
           $ID_data[$ii][6]=$ID_data[$ii][2]; 
           $ii++;
-          //echo "<br />"; 
        } 
-     // echo "<br />"; 
-	
   }
 }
 
@@ -232,10 +171,8 @@ foreach($str_arrname as $row)
   $i++;
   if($i>1)
   {
-       
-  	$data=explode(" ",$row);
+       $data=explode(" ",$row);
        $j=0;
-       
        $flag=0;
        $number_of_point=0;
        $index=0; 
@@ -243,15 +180,12 @@ foreach($str_arrname as $row)
 	{
              $j++;
              $cell=trim($cell);
-         
              if($j==1 && $cell=="edge")
              {
                 $flag=1;
              }  
-               
              if($j==2 && $flag==1)
              {
-                
                 for($k=0;$k<$nnode;$k++)
                 {     
                       $cell=$grviz_name_list[$cell];
@@ -260,9 +194,7 @@ foreach($str_arrname as $row)
                           $edge_data[$ii][0]=$ID_data[$k][3];
                           $edge_data[$ii][1]=$ID_data[$k][4];
                       }                     
-
                 }
-               
              }
              else if($j==3 && $flag==1)
              {
@@ -273,9 +205,7 @@ foreach($str_arrname as $row)
                           $edge_data[$ii][2]=$ID_data[$k][5];
                           $edge_data[$ii][3]=$ID_data[$k][6];
                       }                     
-
                 }
-
              }
              else if($j==4 && $flag==1)
              {
@@ -286,27 +216,19 @@ foreach($str_arrname as $row)
              else if($j>4 && $number_of_point>0 && $flag==1)
              {
                 if(($j%2)!=0)
-                  $edge_data[$ii][$index]=round($cell/10*900)+60;//+30+30;
+                  $edge_data[$ii][$index]=round($cell/10*900)+60;
                 else
-                  $edge_data[$ii][$index]=round($cell/10*900)+48;//+18+30;
-
+                  $edge_data[$ii][$index]=round($cell/10*900)+48;
                 $number_of_point--;
                 $index++;
              }
-
-
-             
        } 
        if($flag==1)
        {
           $ii++;
-          //echo "<br />"; 
        } 
- 	
   }
 }
-
-
 $nedges=$ii;
 
 ?>
@@ -316,9 +238,9 @@ $nedges=$ii;
 <head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
- <script type="text/javascript">
-  google.load('visualization', '1', {packages: ['corechart']});
- </script>
+<script type="text/javascript">
+google.load('visualization', '1', {packages: ['corechart']});
+</script>
  
 
 <?php 
@@ -412,9 +334,9 @@ for($i=0;$i<$nnode;$i++)
         } 
          chart.draw(data,
                  {title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                    vAxis: {textStyle: {fontSize:<?php print($font);?>}},
+		    hAxis: {minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
                   backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
         google.visualization.events.addListener(chart, 'select', selectHandler);  
@@ -428,13 +350,13 @@ for($i=0;$i<$nnode;$i++)
   function <?php print($fname);?> {
   // Create and populate the data table.
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', ''],
+						    [{label:'<?php print($name);?>',type:'number'}, {label:''}],
   <?php
   $c_i=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //       $val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -448,7 +370,7 @@ for($i=0;$i<$nnode;$i++)
   if($j==100)
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //       $val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -479,10 +401,11 @@ for($i=0;$i<$nnode;$i++)
             chart.draw(data, {curveType: "function",
                   title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
 			legend: {position: 'none'},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
-                  backgroundColor: {stroke: 'black', strokeWidth: 5}}
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                  vAxis: {minValue: 0, maxValue: 1, viewWindow: {min:0}, gridlines: {count: 5}, textStyle: {fontSize: 9}},
+		    hAxis: {gridlines: {count: 4}, textStyle: {fontSize: 9},viewWindowMode: 'maximized'},
+		    chartArea:{left:30,top:25,right:8,bottom:25},
+                    backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
            google.visualization.events.addListener(chart, 'select', selectHandler); 
        }
@@ -496,9 +419,9 @@ for($i=0;$i<$nnode;$i++)
 }
 
 ///////////////////////////////////write data to file///////////////////////////////////////////////////////////
-$fl=$dir.$keyval."structure_old.txt";
-$fp = fopen("$fl","w");
-fwrite($fp,"$data_val");
+//$fl=$dir.$keyval."structure_old.txt";
+//$fp = fopen("$fl","w");
+//fwrite($fp,"$data_val");
 ?>
 
 
@@ -540,22 +463,10 @@ function canvas_arrow_draw(n, polypts,context){
 
 //Create jsGraphics object
 var headlen = 10;
-/*
-var hexno=new String;
-arr=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
-var n1=Math.round(Math.random()*15);
-var n2=Math.round(Math.random()*15);
-var n3=Math.round(Math.random()*15);
-var n4=Math.round(Math.random()*15);
-var n5=Math.round(Math.random()*15);
-var n6=Math.round(Math.random()*15);
-hexno="#"+arr[n1]+""+arr[n2]+""+arr[n3]+""+arr[n4]+""+arr[n5]+""+arr[n6];
-*/
 hexno="black";
 var polypoints = new Array();
 var n2=n*2;
 
-
 var sx=polypts[0];
 var sy=polypts[1];
  
@@ -624,8 +535,7 @@ $data=$edge_data[$i][$inx];
 
 ?>
 	polypoints[j] = "<?php print($data);?>";
-
-       j++;
+        j++;
 <?php
 }
 ?>
@@ -651,7 +561,7 @@ for($i=0;$i<$nnode;$i++)
 <script type="text/javascript">
    google.setOnLoadCallback(draw_<?php print($name)?>);
 </script>
-<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($hieght);?>; position: absolute"></div>
+<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($height);?>; position: absolute"></div>
 
 <?php 
 }
diff --git a/sourcecodes/network_layout_evd.php~ b/sourcecodes/network_layout_evd.php~
deleted file mode 100644
index a5909436..00000000
--- a/sourcecodes/network_layout_evd.php~
+++ /dev/null
@@ -1,667 +0,0 @@
-<?php 
-include("structuremap.php");
-
-function levelmap($inx,$name,$mapdata)
-{
-
-$leve_l=array();
-$leve_l=explode("\n",$mapdata);
-$leve_d=array();
-
-foreach($leve_l as $l)
-{ 
-  $l=trim($l);
-  $leve_d=explode("\t",$l);
-  $inxname=trim($leve_d[0]);
-  $name=trim($name);
-  if($inxname==$name)
-    return $leve_d[$inx];
-}
-           
-}
-
-
-////////////////////////////////////Read data from net_figure file///////////////////////Graphp Display/////////////////////////////////////////////
-$dir="./data/";
-
-
-$keyval=$_GET["My_key"];
-
-$matfile=$dir."$keyval"."net_figure.txt";
-
-$data_val="";
-
-$matrix=file("$matfile");
-$matrix1=file_get_contents("$matfile");   
-
-$lfile=$dir.$keyval."nlevels.txt";
-$levelmap=file_get_contents($lfile);   
-
-
-$str_arrmat=array();
-$str_arrmat=explode("\n",$matrix1);
-
-if($str_arrmat[2]=="" || $matrix1=="")
-{
-?>
-<h1><font color=blue>Error: Unable to display your network structure.</font></h1>
-<?php
-exit;
-}
-
-$datamat=array();
-$data_read=array();
- 
-$node=trim($str_arrmat[0]);
-/*
-if($node<=5)
-{
-  $width=200;
-  $hieght=150;
-  $font=14;
-}
-else if($node>5 && $node<=7)
-{
-  $width=150;
-  $hieght=120;
-  $font=12;
-
-}
-else if($node>7 && $node<=10)
-{
-  $width=110;
-  $hieght=85;
-  $font=10;
-}
-else 
-{
-  $width=80;
-  $hieght=60;
-  $font=8;
-}
-*/
-  $width=150;
-  $hieght=150;
-  $font=12;
-
-$r_index=$node+2;
-
-for($i=0;$i<$node;$i++)
-{
-$datamat=explode("\t",$str_arrmat[$r_index]);
-$data_read[$i][0]=trim($datamat[0]);  //name
-$data_read[$i][1]=trim($datamat[1]);  //datatype
-$col_in=2;
-$r_index+=4;
-	if($datamat[1]==1)  //type=coninuous
-	{
-         for($j=1;$j<=101;$j++)
-         {
-           $datamat=explode("\t",$str_arrmat[$r_index]);
-           $data_read[$i][$col_in]=trim($datamat[0]);  //x data
-         //  echo $data_read[$i][$col_in];
-          // echo '&nbsp';
-
-           $col_in++;
-           $data_read[$i][$col_in]=trim($datamat[1]);  //y data
-          // echo $data_read[$i][$col_in];
-	   // echo '&nbsp';
-
-           $col_in++;
-           $r_index++; // increment to point next data
-           // echo "<br />"; 
-         } 
-	}
-	if($datamat[1]>1)  //type=descrete
-	{
-         $iter=$datamat[1];
-         for($j=1;$j<=$iter;$j++)
-         {
-           $datamat=explode("\t",$str_arrmat[$r_index]);
-           $data_read[$i][$col_in]=trim($datamat[0]);  //x data
-           //use level mapping
-           $data_read[$i][$col_in]=levelmap($data_read[$i][$col_in],$data_read[$i][0],$levelmap);
- 
-           $col_in++;
-           $data_read[$i][$col_in]=trim($datamat[1]);  //y data
-         
-           $col_in++;
-           $r_index++; // increment to point next data
-           //echo "<br />"; 
-         } 
-	}
-
-}
-
-
-
-
-////////////////////////////////////////////////Graphviz data read////////////////////////////////////////////////////////////////////////////////
-
-$grv=$dir.$keyval."graphviz.txt";
-$line=shell_exec('/usr/bin/dot -Tplain -y '.$grv);
-
-
-$grviz_name_list=array();
-$g_file_name="./data/".$keyval."grviz_name_file.txt";
-$grviz_name=file_get_contents("$g_file_name");
-$grviz_name_list=explode("\n",$grviz_name);
-
-
-
-//$foutnew=fopen("contentofgraphviz.txt","w");
-//fwrite($foutnew,"$line");
-
-
-//$grfilename=$keyval."graphviz.txt";
-//$cmd="/usr/bin/dot -Tplain -y  $grfilename";
-//$line=system($cmd);
-
-
-
-
-$str_arrname=array();
-$str_arrname=explode("\n",$line);
-$data=array();
-$ID_data=array();
-$i=0;
-$ii=0;
-foreach($str_arrname as $row)
-{
-  $i++;
-  if($i>1)
-  {
-       
-  	$data=explode(" ",$row);
-       $j=0;
-       $k=0;
-       $flag=0;
-  	foreach($data as $cell)
-	{
-             
-             $j++;
-             
-             $cell=trim($cell);
-             //echo $cell;
-             //echo '&nbsp';
-             if($j==1 && $cell=="node")
-             {
-                $flag=1;
-             }  
-               
-             if($j>1 && $j<5 && $flag==1)
-             {
-    		  //echo $cell;
-   		  //echo '&nbsp';
-                if($j==2)
-                {
-                    
-                   $ID_data[$ii][$k]=$grviz_name_list[$cell];
-                } 
-                else
-                   $ID_data[$ii][$k]=round($cell/10*900);
-               // echo $ID_data[$ii][$k];
-                //echo '&nbsp';
-
-                $k++; 
-             }
-       } 
-  
-       if($flag==1)
-       {
-          $ID_data[$ii][3]=$ID_data[$ii][1]+100;
-          $ID_data[$ii][4]=$ID_data[$ii][2]+150; 
-          $ID_data[$ii][5]=$ID_data[$ii][1]+100;
-          $ID_data[$ii][6]=$ID_data[$ii][2]; 
-          $ii++;
-          //echo "<br />"; 
-       } 
-     // echo "<br />"; 
-	
-  }
-}
-
-$nnode=$ii;
-$edge_data=array();
-
-$i=0;
-$ii=0;
-
-foreach($str_arrname as $row)
-{
-  $i++;
-  if($i>1)
-  {
-       
-  	$data=explode(" ",$row);
-       $j=0;
-       
-       $flag=0;
-       $number_of_point=0;
-       $index=0; 
-  	foreach($data as $cell)
-	{
-             $j++;
-             $cell=trim($cell);
-         
-             if($j==1 && $cell=="edge")
-             {
-                $flag=1;
-             }  
-               
-             if($j==2 && $flag==1)
-             {
-                
-                for($k=0;$k<$nnode;$k++)
-                {     
-                      $cell=$grviz_name_list[$cell];
-                      if($cell==$ID_data[$k][0])
-                      {
-                          $edge_data[$ii][0]=$ID_data[$k][3];
-                          $edge_data[$ii][1]=$ID_data[$k][4];
-                      }                     
-
-                }
-               
-             }
-             else if($j==3 && $flag==1)
-             {
-               for($k=0;$k<$nnode;$k++)
-                {
-                      if($cell==$ID_data[$k][0])
-                      {
-                          $edge_data[$ii][2]=$ID_data[$k][5];
-                          $edge_data[$ii][3]=$ID_data[$k][6];
-                      }                     
-
-                }
-
-             }
-             else if($j==4 && $flag==1)
-             {
-                  $edge_data[$ii][4]=$cell;
-                  $number_of_point=$cell*2;
-                  $index=5;
-             }
-             else if($j>4 && $number_of_point>0 && $flag==1)
-             {
-                if(($j%2)!=0)
-                  $edge_data[$ii][$index]=round($cell/10*900)+60;//+30+30;
-                else
-                  $edge_data[$ii][$index]=round($cell/10*900)+48;//+18+30;
-
-                $number_of_point--;
-                $index++;
-             }
-
-
-             
-       } 
-       if($flag==1)
-       {
-          $ii++;
-          //echo "<br />"; 
-       } 
- 	
-  }
-}
-
-
-$nedges=$ii;
-
-?>
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
-<script type="text/javascript" src="http://www.google.com/jsapi"></script>
- <script type="text/javascript">
-  google.load('visualization', '1', {packages: ['corechart']});
- </script>
- 
-
-<?php 
-$data_val="";
-
-for($i=0;$i<$nnode;$i++)
- {
-////////////////////////////select node //////////////////////////////////////
- $name=$ID_data[$i][0];
- $fname="draw_".$name."()";
- $data_val.=$name;
- for($j=0;$j<$node;$j++)
- {
-    if($data_read[$j][0]==$name)
-    {
-       $s_i=$j;
-       break;
-    } 
- }
- 
-/////////////////////////////////Display nodes//////////////////////////////////////////////////////////
-?>    
- <script type="text/javascript">
-
-
-<?php
-  $node_type=$data_read[$s_i][1];
-  if($node_type>1) //discrete node
-  { 
-?>
-  
- 
-  function <?php print($fname);?> {
-  // Create and populate the data table.
- 
-  var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', ''],
-  <?php
-  $c_i=2; 
-
-  for($j=0;$j<$node_type-1;$j++) 
-  {     
-       $val1=trim($data_read[$s_i][$c_i]);
-
-
-       $c_i++;
-       $val2=trim($data_read[$s_i][$c_i]);
-       $c_i++;
-       $data_val.="\t".$val2;
-        
-  ?>
-   ['<?php print($val1);?>', <?php print($val2);?>],
-
-  <?php
-  }
-  if($j==$node_type-1)
-  {
-        $val1=trim($data_read[$s_i][$c_i]);
-
-
-       $c_i++;
-       $val2=trim($data_read[$s_i][$c_i]);
-       $c_i++;
-       $data_val.="\t".$val2."\n";
-  ?> 
-    ['<?php print($val1);?>', <?php print($val2);?>]
-<?php
-  }
-?>
-  ]);
-      
-        // Create and draw the visualization.
-      
-      var cnode="<?php print($name); ?>";
-      var keyv="<?php print($keyval);?>";  
-
-        var chart = new google.visualization.BarChart(document.getElementById('<?php print($name);?>'));
-        function selectHandler() {
-          var selectedItem = chart.getSelection()[0];
-          if (selectedItem) {
-            var topping = data.getValue(selectedItem.row, 0);
-            
-            var s = window.prompt('Selected evidence ' + topping + ' for ' + cnode + '. Enter new evidence ', topping );
-           
-            window.location.href = "add_evd.php?name=" + cnode + "&evidence=" + s + "&My_key="  + keyv;
-           
-
-  
-              //alert('The user selected ' + topping + topname);
-          }
-        } 
-         chart.draw(data,
-                 {title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
-                  backgroundColor: {stroke: 'black', strokeWidth: 5}}
-            );
-        google.visualization.events.addListener(chart, 'select', selectHandler);  
-
-  }
-<?php
- }
- else //continuous node
- {
-?>
-  function <?php print($fname);?> {
-  // Create and populate the data table.
-  var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', ''],
-  <?php
-  $c_i=2;
-  for($j=0;$j<100;$j++) 
-  {
-       $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
-
-       $c_i++;
-       $val2=trim($data_read[$s_i][$c_i]);
-       $c_i++;         
-       $data_val.="\t".$val2;
-  ?>
-   ['<?php print($val1);?>', <?php print($val2);?>],
-
-  <?php
-  }
-  if($j==100)
-  {
-       $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
-
-       $c_i++;
-       $val2=trim($data_read[$s_i][$c_i]);
-       $c_i++;
-       $data_val.="\t".$val2."\n";
-  ?> 
-    ['<?php print($val1);?>', <?php print($val2);?>]
-<?php
-  }
-?>
-  ]);
-      
-        // Create and draw the visualization.
-      var cnode="<?php print($name); ?>";
-      var keyv="<?php print($keyval);?>";  
-        var chart = new google.visualization.LineChart(document.getElementById('<?php print($name);?>'));
-
-        function selectHandler() {
-          var selectedItem = chart.getSelection()[0];
-          if (selectedItem) {
-           
-            var topping = data.getValue(selectedItem.row, 0);
-            var s = window.prompt('Selected evidence ' + topping + ' for ' + cnode + '. Enter new evidence ', topping );
-            window.location.href = "add_evd.php?name=" + cnode + "&evidence=" + s + "&My_key=" + keyv;  
-
-          }
-        }
-            chart.draw(data, {curveType: "function",
-                  title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-			legend: {position: 'none'},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
-                  backgroundColor: {stroke: 'black', strokeWidth: 5}}
-            );
-           google.visualization.events.addListener(chart, 'select', selectHandler); 
-       }
-
-<?php
- }
-?>
-</script>
-<?php
-///////////////////////////end of display nodes////////////////////////////////////////////////
-}
-
-///////////////////////////////////write data to file///////////////////////////////////////////////////////////
-$fl=$dir.$keyval."structure_old.txt";
-$fp = fopen("$fl","w");
-fwrite($fp,"$data_val");
-?>
-
-
-
-<script type="text/javascript">
-function canvas_arrow(context, fromx, fromy, tox, toy){
-    var headlen = 15;
-    var dx = tox-fromx;
-    var dy = toy-fromy;
-    var angle = Math.atan2(dy,dx);
-    context.moveTo(fromx,fromy);
-    context.lineTo(tox,toy);
-    context.lineTo(tox-headlen*Math.cos(angle-Math.PI/6),toy-headlen*Math.sin(angle-Math.PI/6));
-    context.moveTo(tox,toy);
-    context.lineTo(tox-headlen*Math.cos(angle+Math.PI/6),toy-headlen*Math.sin(angle+Math.PI/6));
-}
-</script>
-
-<script type="text/javascript">
-function canvas_arrow_head(context, fromx, fromy, tox, toy){
-    var headlen = 15;
-    var dx = tox-fromx;
-    var dy = toy-fromy;
-    var angle = Math.atan2(dy,dx);
-    context.moveTo(tox,toy);
-    context.lineTo(tox-headlen*Math.cos(angle-Math.PI/6),toy-headlen*Math.sin(angle-Math.PI/6));
-    context.moveTo(tox,toy);
-    context.lineTo(tox-headlen*Math.cos(angle+Math.PI/6),toy-headlen*Math.sin(angle+Math.PI/6));
-}
-</script>
-
-
-</head>
-
-<body>
-<canvas id="test" width="3000" height="3000" style="position:absolute">
-<script>
-function canvas_arrow_draw(n, polypts,context){
-
-//Create jsGraphics object
-var headlen = 10;
-/*
-var hexno=new String;
-arr=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
-var n1=Math.round(Math.random()*15);
-var n2=Math.round(Math.random()*15);
-var n3=Math.round(Math.random()*15);
-var n4=Math.round(Math.random()*15);
-var n5=Math.round(Math.random()*15);
-var n6=Math.round(Math.random()*15);
-hexno="#"+arr[n1]+""+arr[n2]+""+arr[n3]+""+arr[n4]+""+arr[n5]+""+arr[n6];
-*/
-hexno="black";
-var polypoints = new Array();
-var n2=n*2;
-
-
-var sx=polypts[0];
-var sy=polypts[1];
- 
-var sx1=polypts[n2-4];
-var sy1=polypts[n2-3];
-var ex1=polypts[n2-2];
-var ey1=polypts[n2-1];
-
-context.beginPath();
-canvas_arrow_head(context,sx1,sy1,ex1,ey1);
-
-context.moveTo(polypts[0],polypts[1]);
-nm=n%3;
-ni=(n-nm)/3;
-
-for(i=0;i<ni;i++)
-{
-  i11=i*6+2;
-  i12=i*6+3;
-  i21=i*6+4;
-  i22=i*6+5;
-  i31=i*6+6;
-  i32=i*6+7;
-
-  context.bezierCurveTo(polypts[i11],polypts[i12],polypts[i21],polypts[i22],polypts[i31],polypts[i32]);
-  context.moveTo(polypts[i31],polypts[i32]);
-
- // polypoints[i] = new jxPoint(polypts[i1], polypts[i2]);
-}
-
-
-if(nm==2)
-{
-  context.moveTo(polypts[i21],polypts[i22]);
-  context.bezierCurveTo(polypts[i31],polypts[i32],sx1,sy1,ex1,ey1);
-  context.moveTo(ex1,ey1);
-
-}
-
- context.strokeStyle = hexno;
- context.stroke();
-
-}
-
-
-var canvas=document.getElementById("test");
-var context = canvas.getContext("2d");
-context.lineWidth = 3;
-
-<?php
-for($i=0;$i<$nedges;$i++)
-{
-
-   $n=$edge_data[$i][4]; 
-   $n2=$n*2;
-   
-?>
-var polypoints = new Array();
-var j=0;
-var n="<?php print($n);?>";
-<?php
-for($j=0;$j<$n2;$j++)
-{
-$inx=$j+5;
-$data=$edge_data[$i][$inx];
-
-?>
-	polypoints[j] = "<?php print($data);?>";
-
-       j++;
-<?php
-}
-?>
-canvas_arrow_draw(n,polypoints,context);
-<?php
-}
-?>
-
-
-
-</script>
-</canvas>
-
-
-<?php 
-for($i=0;$i<$nnode;$i++)
-{
-  $x=$ID_data[$i][1]-8; $y=$ID_data[$i][2]-20; 
-
-  $name=$ID_data[$i][0];
-?>
-
-<script type="text/javascript">
-   google.setOnLoadCallback(draw_<?php print($name)?>);
-</script>
-<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($hieght);?>; position: absolute"></div>
-
-<?php 
-}
-?>
-
-
-</body>
-
-
-
-</html>
-
-
diff --git a/sourcecodes/network_layout_evd_2.php b/sourcecodes/network_layout_evd_2.php
index c89cb465..0daf9df9 100644
--- a/sourcecodes/network_layout_evd_2.php
+++ b/sourcecodes/network_layout_evd_2.php
@@ -108,35 +108,8 @@ if($str_arrmat[2]=="" || $matrix1=="")
 <?php
 exit;
 }
-/*
-if($node<=5)
-{
-  $width=200;
-  $hieght=150;
-  $font=11;
-}
-else if($node>5 && $node<=7)
-{
-  $width=150;
-  $hieght=120;
-  $font=10;
-
-}
-else if($node>7 && $node<=10)
-{
-  $width=110;
-  $hieght=85;
-  $font=8;
-}
-else 
-{
-  $width=80;
-  $hieght=60;
-  $font=7;
-}
-*/
   $width=150;
-  $hieght=150;
+  $height=150;
   $font=12;
 
 
@@ -193,7 +166,7 @@ for($i=0;$i<$node;$i++)
         
         		 } 
 		}
-		if($nodetype>1)  //type=descrete
+		if($nodetype>1)  //type=discrete
 		{
          		$iter=$datamat[1];
          		for($j=1;$j<=$iter;$j++)
@@ -205,7 +178,6 @@ for($i=0;$i<$node;$i++)
            			$data_read[$i][$col_in]=trim($datamat[1]);  //y data
            			$col_in++;
            			$r_index++; // increment to point next data
-           //echo "<br />"; 
          		} 
 		}
 
@@ -234,7 +206,7 @@ for($i=0;$i<$node_old;$i++)
 	$data_read_old[$i][1]=trim($datamat_old[1]);  //datatype
 	$col_in_old=2;
 	$r_index_old+=4;
-	if($datamat_old[1]==1)  //type=coninuous
+	if($datamat_old[1]==1)  //type=continuous
 	{
          for($j=1;$j<=101;$j++)
          {
@@ -249,7 +221,7 @@ for($i=0;$i<$node_old;$i++)
 
          } 
 	}
-	if($datamat_old[1]>1)  //type=descrete
+	if($datamat_old[1]>1)  //type=discrete
 	{
          $iter=$datamat_old[1];
          for($j=1;$j<=$iter;$j++)
@@ -279,15 +251,6 @@ $g_file_name="./data/".$keyval."grviz_name_file.txt";
 $grviz_name=file_get_contents("$g_file_name");
 $grviz_name_list=explode("\n",$grviz_name);
 
-
-
-//$grfilename=$keyval."graphviz.txt";
-//$cmd="/usr/bin/dot -Tplain -y  $grfilename";
-//$line=system($cmd);
-
-
-
-//shell_exec('/usr/bin/dot -Tpng -o /var/www/html/compbio/BNW/graphviz.png /var/www/html/compbio/BNW/graphviz.txt');
 $str_arrname=array();
 $str_arrname=explode("\n",$line);
 $data=array();
@@ -299,35 +262,24 @@ foreach($str_arrname as $row)
   $i++;
   if($i>1)
   {
-       
-  	$data=explode(" ",$row);
+       $data=explode(" ",$row);
        $j=0;
        $k=0;
        $flag=0;
   	foreach($data as $cell)
 	{
-             
              $j++;
-             
              $cell=trim($cell);
-             //echo $cell;
-             //echo '&nbsp';
              if($j==1 && $cell=="node")
              {
                 $flag=1;
              }  
-               
              if($j>1 && $j<5 && $flag==1)
              {
-    		  //echo $cell;
-   		  //echo '&nbsp';
                 if($j==2)
                    $ID_data[$ii][$k]=$grviz_name_list[$cell];
                 else
                    $ID_data[$ii][$k]=round($cell/10*900);
-               // echo $ID_data[$ii][$k];
-                //echo '&nbsp';
-
                 $k++; 
              }
        } 
@@ -339,10 +291,7 @@ foreach($str_arrname as $row)
           $ID_data[$ii][5]=$ID_data[$ii][1]+100;
           $ID_data[$ii][6]=$ID_data[$ii][2]; 
           $ii++;
-          //echo "<br />"; 
        } 
-     // echo "<br />"; 
-	
   }
 }
 
@@ -357,10 +306,8 @@ foreach($str_arrname as $row)
   $i++;
   if($i>1)
   {
-       
   	$data=explode(" ",$row);
        $j=0;
-       
        $flag=0;
        $number_of_point=0;
        $index=0; 
@@ -368,12 +315,10 @@ foreach($str_arrname as $row)
 	{
              $j++;
              $cell=trim($cell);
-         
              if($j==1 && $cell=="edge")
              {
                 $flag=1;
              }  
-               
              if($j==2 && $flag==1)
              {
                 
@@ -385,9 +330,7 @@ foreach($str_arrname as $row)
                           $edge_data[$ii][0]=$ID_data[$k][3];
                           $edge_data[$ii][1]=$ID_data[$k][4];
                       }                     
-
                 }
-               
              }
              else if($j==3 && $flag==1)
              {
@@ -398,9 +341,7 @@ foreach($str_arrname as $row)
                           $edge_data[$ii][2]=$ID_data[$k][5];
                           $edge_data[$ii][3]=$ID_data[$k][6];
                       }                     
-
                 }
-
              }
              else if($j==4 && $flag==1)
              {
@@ -411,29 +352,21 @@ foreach($str_arrname as $row)
              else if($j>4 && $number_of_point>0 && $flag==1)
              {
                 if(($j%2)!=0)
-                  $edge_data[$ii][$index]=round($cell/10*900)+60;//+30+30;
+                  $edge_data[$ii][$index]=round($cell/10*900)+60;
                 else
-                  $edge_data[$ii][$index]=round($cell/10*900)+48;//+18+30;
-
+                  $edge_data[$ii][$index]=round($cell/10*900)+48;
                 $number_of_point--;
                 $index++;
              }
-
-
-             
        } 
        if($flag==1)
        {
           $ii++;
-          //echo "<br />"; 
        } 
- 	
   }
 }
 
-
 $nedges=$ii;
-//echo $nedges;
 
 ?>
 
@@ -625,9 +558,9 @@ else
         } 
          chart.draw(data,
                  {title:"<?php print($named);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                  vAxis: {textStyle: {fontSize:<?php print($font);?>}},
+		    hAxis: {minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
                   backgroundColor: {stroke: '<?php print($bcolor);?>', strokeWidth: 5}}
             );
         google.visualization.events.addListener(chart, 'select', selectHandler);  
@@ -654,14 +587,14 @@ if($evd==-9999)
 {
 ?>
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', 'Old', 'New'],
+						    [{label: '<?php print($name);?>', type: 'number'}, {label:'Old'},{label:'New'}],
 <?php
   $c_i=2;
   $c_i_old=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //       $val1=map($name,$val1,$keyval);
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
        $c_i++;         
@@ -678,7 +611,7 @@ if($evd==-9999)
   if($j==100)
   {
         $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+	//       $val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -695,11 +628,11 @@ if($evd==-9999)
 }
 else
 {
-    $evd=map($name,$evd,$keyval);
+  //    $evd=map($name,$evd,$keyval);
     $evduse=$evd;
 ?>
   var data = google.visualization.arrayToDataTable([
-    ['<?php print($name);?>', 'Old', 'New'],
+						    [{label: '<?php print($name);?>', type: 'number'}, {label:'Old'},{label:'New'}],
 
 <?php
  
@@ -707,7 +640,7 @@ else
   for($j=0;$j<100;$j++) 
   {     
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+       //       $val1_old=map($name,$val1_old,$keyval);
 
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
@@ -730,7 +663,7 @@ else
   if($j==100)
   {
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+       //       $val1_old=map($name,$val1_old,$keyval);
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
        $c_i_old++;
@@ -777,9 +710,10 @@ else
             chart.draw(data, {curveType: "function",
                   title:"<?php print($named);?>", titleTextStyle: {fontSize: <?php print($font);?>},
 			legend: {position: 'none'},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+		     hAxis: {gridlines: {count: 4}, textStyle: {fontSize: 9},viewWindowMode: 'maximized'},
+		    vAxis: {maxValue: 1, minValue: 0,viewWindow: {min:0}, gridlines: {count:5}, textStyle: {fontSize: 9}},
+		    chartArea:{left:30,top:25,right:8,bottom:25},
                   backgroundColor: {stroke: '<?php print($bcolor);?>', strokeWidth: 5}}
             );
            google.visualization.events.addListener(chart, 'select', selectHandler); 
@@ -946,7 +880,7 @@ for($i=0;$i<$nnode;$i++)
 <script type="text/javascript">
    google.setOnLoadCallback(draw_<?php print($name)?>);
 </script>
-<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($hieght);?>; position: absolute"></div>
+<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($height);?>; position: absolute"></div>
 
 <?php 
 }
diff --git a/sourcecodes/network_layout_evd_2_example.php b/sourcecodes/network_layout_evd_2_example.php
index 055216e3..030d2c3a 100644
--- a/sourcecodes/network_layout_evd_2_example.php
+++ b/sourcecodes/network_layout_evd_2_example.php
@@ -112,31 +112,31 @@ exit;
 if($node<=5)
 {
   $width=200;
-  $hieght=150;
+  $height=150;
   $font=11;
 }
 else if($node>5 && $node<=7)
 {
   $width=150;
-  $hieght=120;
+  $height=120;
   $font=10;
 
 }
 else if($node>7 && $node<=10)
 {
   $width=110;
-  $hieght=85;
+  $height=85;
   $font=8;
 }
 else 
 {
   $width=80;
-  $hieght=60;
+  $height=60;
   $font=7;
 }
 */
   $width=150;
-  $hieght=150;
+  $height=150;
   $font=12;
 
 
@@ -617,9 +617,9 @@ else
         } 
          chart.draw(data,
                  {title:"<?php print($named);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                  vAxis: {textStyle: {fontSize:<?php print($font);?>}},
+		    hAxis: {minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
                   backgroundColor: {stroke: '<?php print($bcolor);?>', strokeWidth: 5}}
             );
         google.visualization.events.addListener(chart, 'select', selectHandler);  
@@ -646,14 +646,14 @@ if($evd==-9999)
 {
 ?>
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', 'Old', 'New'],
+						    [{label:'<?php print($name);?>',type:'number'}, {label:'Old'},{label:'New'}],
 <?php
   $c_i=2;
   $c_i_old=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //$val1=map($name,$val1,$keyval);
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
        $c_i++;         
@@ -670,7 +670,7 @@ if($evd==-9999)
   if($j==100)
   {
         $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+	//$val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -687,11 +687,12 @@ if($evd==-9999)
 }
 else
 {
-    $evd=map($name,$evd,$keyval);
+  //$evd=map($name,$evd,$keyval);
     $evduse=$evd;
 ?>
   var data = google.visualization.arrayToDataTable([
-    ['<?php print($name);?>', 'Old', 'New'],
+						    [{label:'<?php print($name);?>',type:'number'}, {label:'Old'},{label:'New'}], 
+//   ['<?php print($name);?>', 'Old', 'New'],
 
 <?php
  
@@ -699,7 +700,7 @@ else
   for($j=0;$j<100;$j++) 
   {     
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+       //$val1_old=map($name,$val1_old,$keyval);
 
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
@@ -722,7 +723,7 @@ else
   if($j==100)
   {
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+       //$val1_old=map($name,$val1_old,$keyval);
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
        $c_i_old++;
@@ -769,9 +770,10 @@ else
             chart.draw(data, {curveType: "function",
                   title:"<?php print($named);?>", titleTextStyle: {fontSize: <?php print($font);?>},
 			legend: {position: 'none'},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+		  hAxis: {gridlines: {count: 4}, textStyle: {fontSize: 9}, viewWindowMode: 'maximized'},
+		    vAxis: {maxValue: 1, minValue: 0,viewWindow: {min:0}, gridlines: {count:5}, textStyle: {fontSize: 9}},
+		    chartArea:{left:30,top:25,right:8,bottom:25},
                   backgroundColor: {stroke: '<?php print($bcolor);?>', strokeWidth: 5}}
             );
            google.visualization.events.addListener(chart, 'select', selectHandler); 
@@ -938,7 +940,7 @@ for($i=0;$i<$nnode;$i++)
 <script type="text/javascript">
    google.setOnLoadCallback(draw_<?php print($name)?>);
 </script>
-<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($hieght);?>; position: absolute"></div>
+<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($height);?>; position: absolute"></div>
 
 <?php 
 }
diff --git a/sourcecodes/network_layout_evd_example.php b/sourcecodes/network_layout_evd_example.php
index 4cec1f2f..8cc4bd00 100644
--- a/sourcecodes/network_layout_evd_example.php
+++ b/sourcecodes/network_layout_evd_example.php
@@ -53,35 +53,8 @@ $datamat=array();
 $data_read=array();
  
 $node=trim($str_arrmat[0]);
-/*
-if($node<=5)
-{
-  $width=200;
-  $hieght=150;
-  $font=14;
-}
-else if($node>5 && $node<=7)
-{
-  $width=150;
-  $hieght=120;
-  $font=12;
-
-}
-else if($node>7 && $node<=10)
-{
-  $width=110;
-  $hieght=85;
-  $font=10;
-}
-else 
-{
-  $width=80;
-  $hieght=60;
-  $font=8;
-}
-*/
   $width=150;
-  $hieght=150;
+  $height=150;
   $font=12;
 
 $r_index=$node+2;
@@ -396,9 +369,9 @@ for($i=0;$i<$nnode;$i++)
         } 
          chart.draw(data,
                  {title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                  vAxis: {textStyle: {fontSize:<?php print($font);?>}},
+		    hAxis: {minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
                   backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
         google.visualization.events.addListener(chart, 'select', selectHandler);  
@@ -412,27 +385,27 @@ for($i=0;$i<$nnode;$i++)
   function <?php print($fname);?> {
   // Create and populate the data table.
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', ''],
+						    [ {label: '<?php print($name);?>', type: 'number'}, {label:''}],
   <?php
   $c_i=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //$val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
        $c_i++;         
        $data_val.="\t".$val2;
   ?>
-   ['<?php print($val1);?>', <?php print($val2);?>],
+   ['<?php print(floatval($val1));?>', <?php print($val2);?>],
 
   <?php
   }
   if($j==100)
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //$val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -462,11 +435,12 @@ for($i=0;$i<$nnode;$i++)
         }
             chart.draw(data, {curveType: "function",
                   title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-			legend: {position: 'none'},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
-                  backgroundColor: {stroke: 'black', strokeWidth: 5}}
+		  legend: {position: 'none'},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+						  vAxis: {minValue: 0, maxValue: 1, viewWindow: {min:0}, gridlines: {count: 5}, textStyle: {fontSize: 9}},
+                  hAxis: {gridlines: {count: 4}, textStyle: {fontSize: 9},viewWindowMode: 'maximized'},
+                  chartArea:{left:30,top:25,right:8,bottom:25},
+		    backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
            google.visualization.events.addListener(chart, 'select', selectHandler); 
        }
@@ -635,7 +609,7 @@ for($i=0;$i<$nnode;$i++)
 <script type="text/javascript">
    google.setOnLoadCallback(draw_<?php print($name)?>);
 </script>
-<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($hieght);?>; position: absolute"></div>
+<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($height);?>; position: absolute"></div>
 
 <?php 
 }
diff --git a/sourcecodes/network_layout_inv.php b/sourcecodes/network_layout_inv.php
index c11fc774..df5f1cd9 100644
--- a/sourcecodes/network_layout_inv.php
+++ b/sourcecodes/network_layout_inv.php
@@ -3,7 +3,6 @@ include("structuremap.php");
 
 function levelmap($inx,$name,$mapdata)
 {
-
 $leve_l=array();
 $leve_l=explode("\n",$mapdata);
 $leve_d=array();
@@ -17,7 +16,6 @@ foreach($leve_l as $l)
   if($inxname==$name)
     return $leve_d[$inx];
 }
-           
 }
 
 ////////////////////////////////////Read data from net_figure file///////////////////////Graphp Display/////////////////////////////////////////////
@@ -28,16 +26,12 @@ $dir="./data/";
 $lfile=$dir.$keyval."nlevels.txt";
 $levelmap=file_get_contents($lfile);   
 
-
-
-
 $matfile=$dir."$keyval"."net_figure.txt";
 
-
 $data_val="";
 
 $matrix=file("$matfile");
-$matrix1=file_get_contents("$matfile");              //file("$matfile");
+$matrix1=file_get_contents("$matfile");
 
 $str_arrmat=array();
 $str_arrmat=explode("\n",$matrix1);
@@ -56,36 +50,9 @@ $datamat=array();
 $data_read=array();
  
 $node=trim($str_arrmat[0]);
-/*
-if($node<=5)
-{
-  $width=200;
-  $hieght=150;
-  $font=14;
-}
-else if($node>5 && $node<=7)
-{
-  $width=150;
-  $hieght=120;
-  $font=12;
-
-}
-else if($node>7 && $node<=10)
-{
-  $width=110;
-  $hieght=85;
-  $font=10;
-}
-else 
-{
-  $width=80;
-  $hieght=60;
-  $font=8;
-}
-*/
-  $width=150;
-  $hieght=150;
-  $font=12;
+$width=150;
+$height=150;
+$font=12;
 
 $r_index=$node+2;
 
@@ -96,26 +63,21 @@ $data_read[$i][0]=trim($datamat[0]);  //name
 $data_read[$i][1]=trim($datamat[1]);  //datatype
 $col_in=2;
 $r_index+=4;
-	if($datamat[1]==1)  //type=coninuous
+	if($datamat[1]==1)  //type=continuous
 	{
          for($j=1;$j<=101;$j++)
          {
            $datamat=explode("\t",$str_arrmat[$r_index]);
            $data_read[$i][$col_in]=trim($datamat[0]);  //x data
-         //  echo $data_read[$i][$col_in];
-          // echo '&nbsp';
 
            $col_in++;
            $data_read[$i][$col_in]=trim($datamat[1]);  //y data
-          // echo $data_read[$i][$col_in];
-	   // echo '&nbsp';
 
            $col_in++;
            $r_index++; // increment to point next data
-           // echo "<br />"; 
          } 
 	}
-	if($datamat[1]>1)  //type=descrete
+	if($datamat[1]>1)  //type=discrete
 	{
          $iter=$datamat[1];
          for($j=1;$j<=$iter;$j++)
@@ -123,43 +85,25 @@ $r_index+=4;
            $datamat=explode("\t",$str_arrmat[$r_index]);
            $data_read[$i][$col_in]=trim($datamat[0]);  //x data
            $data_read[$i][$col_in]=levelmap($data_read[$i][$col_in],$data_read[$i][0],$levelmap);
-
-         //  echo $data_read[$i][$col_in];
-          // echo '&nbsp';
   
            $col_in++;
            $data_read[$i][$col_in]=trim($datamat[1]);  //y data
-          // echo $data_read[$i][$col_in];
-           //echo '&nbsp';
 
            $col_in++;
            $r_index++; // increment to point next data
-           //echo "<br />"; 
          } 
 	}
-
 }
 
-
-
-
 ////////////////////////////////////////////////Graphviz data read////////////////////////////////////////////////////////////////////////////////
 $grv=$dir.$keyval."graphviz.txt";
 $line=shell_exec('/usr/bin/dot -Tplain -y '.$grv);
 
-
 $grviz_name_list=array();
 $g_file_name="./data/".$keyval."grviz_name_file.txt";
 $grviz_name=file_get_contents("$g_file_name");
 $grviz_name_list=explode("\n",$grviz_name);
 
-
-//$grfilename=$keyval."graphviz.txt";
-//$cmd="/usr/bin/dot -Tplain -y  $grfilename";
-//$line=system($cmd);
-
-
-//shell_exec('/usr/bin/dot -Tpng -o /var/www/html/compbio/BNW/graphviz.png /var/www/html/compbio/BNW/graphviz.txt');
 $str_arrname=array();
 $str_arrname=explode("\n",$line);
 $data=array();
@@ -171,35 +115,24 @@ foreach($str_arrname as $row)
   $i++;
   if($i>1)
   {
-       
-  	$data=explode(" ",$row);
+       $data=explode(" ",$row);
        $j=0;
        $k=0;
        $flag=0;
   	foreach($data as $cell)
 	{
-             
              $j++;
-             
              $cell=trim($cell);
-             //echo $cell;
-             //echo '&nbsp';
              if($j==1 && $cell=="node")
              {
                 $flag=1;
              }  
-               
              if($j>1 && $j<5 && $flag==1)
              {
-    		  //echo $cell;
-   		  //echo '&nbsp';
                 if($j==2)
                    $ID_data[$ii][$k]=$grviz_name_list[$cell];
                 else
                    $ID_data[$ii][$k]=round($cell/10*900);
-               // echo $ID_data[$ii][$k];
-                //echo '&nbsp';
-
                 $k++; 
              }
        } 
@@ -211,10 +144,7 @@ foreach($str_arrname as $row)
           $ID_data[$ii][5]=$ID_data[$ii][1]+100;
           $ID_data[$ii][6]=$ID_data[$ii][2]; 
           $ii++;
-          //echo "<br />"; 
        } 
-     // echo "<br />"; 
-	
   }
 }
 
@@ -229,7 +159,6 @@ foreach($str_arrname as $row)
   $i++;
   if($i>1)
   {
-       
   	$data=explode(" ",$row);
        $j=0;
        
@@ -240,15 +169,12 @@ foreach($str_arrname as $row)
 	{
              $j++;
              $cell=trim($cell);
-         
              if($j==1 && $cell=="edge")
              {
                 $flag=1;
              }  
-               
              if($j==2 && $flag==1)
              {
-                
                 for($k=0;$k<$nnode;$k++)
                 {
                       $cell=$grviz_name_list[$cell];
@@ -257,9 +183,7 @@ foreach($str_arrname as $row)
                           $edge_data[$ii][0]=$ID_data[$k][3];
                           $edge_data[$ii][1]=$ID_data[$k][4];
                       }                     
-
                 }
-               
              }
              else if($j==3 && $flag==1)
              {
@@ -270,9 +194,7 @@ foreach($str_arrname as $row)
                           $edge_data[$ii][2]=$ID_data[$k][5];
                           $edge_data[$ii][3]=$ID_data[$k][6];
                       }                     
-
                 }
-
              }
              else if($j==4 && $flag==1)
              {
@@ -290,16 +212,11 @@ foreach($str_arrname as $row)
                 $number_of_point--;
                 $index++;
              }
-
-
-             
        } 
        if($flag==1)
        {
           $ii++;
-          //echo "<br />"; 
        } 
- 	
   }
 }
 
@@ -408,9 +325,9 @@ for($i=0;$i<$nnode;$i++)
         } 
          chart.draw(data,
                  {title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                  vAxis: {textStyle: {fontSize:<?php print($font);?>}},
+		    hAxis: {minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
                   backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
         google.visualization.events.addListener(chart, 'select', selectHandler);  
@@ -424,13 +341,13 @@ for($i=0;$i<$nnode;$i++)
   function <?php print($fname);?> {
   // Create and populate the data table.
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', ''],
+						    [{label:'<?php print($name);?>',type:'number'},{label: ''}],
   <?php
   $c_i=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //       $val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -444,7 +361,7 @@ for($i=0;$i<$nnode;$i++)
   if($j==100)
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //       $val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -476,9 +393,10 @@ for($i=0;$i<$nnode;$i++)
             chart.draw(data, {curveType: "function",
                   title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
 			legend: {position: 'none'},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+		  hAxis: {gridlines: {count: 4}, textStyle: {fontSize: 9}, viewWindowMode: 'maximized'},
+                    vAxis: {maxValue: 1, minValue: 0,viewWindow: {min:0}, gridlines: {count:5}, textStyle: {fontSize: 9}},
+                    chartArea:{left:30,top:25,right:8,bottom:25},
                   backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
            google.visualization.events.addListener(chart, 'select', selectHandler); 
@@ -648,7 +566,7 @@ for($i=0;$i<$nnode;$i++)
 <script type="text/javascript">
    google.setOnLoadCallback(draw_<?php print($name)?>);
 </script>
-<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($hieght);?>; position: absolute"></div>
+<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($height);?>; position: absolute"></div>
 
 <?php 
 }
diff --git a/sourcecodes/network_layout_inv_2.php b/sourcecodes/network_layout_inv_2.php
index 4a1471a5..858de277 100644
--- a/sourcecodes/network_layout_inv_2.php
+++ b/sourcecodes/network_layout_inv_2.php
@@ -198,31 +198,31 @@ $node=trim($str_arrmat[1]);
 if($node<=5)
 {
   $width=200;
-  $hieght=150;
+  $height=150;
   $font=14;
 }
 else if($node>5 && $node<=7)
 {
   $width=150;
-  $hieght=120;
+  $height=120;
   $font=12;
 
 }
 else if($node>7 && $node<=10)
 {
   $width=110;
-  $hieght=85;
+  $height=85;
   $font=10;
 }
 else 
 {
   $width=80;
-  $hieght=60;
+  $height=60;
   $font=8;
 }
 */
   $width=150;
-  $hieght=150;
+  $height=150;
   $font=12;
 
 
@@ -771,9 +771,9 @@ else
         } 
          chart.draw(data,
                  {title:"<?php print($named);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                  vAxis: {textStyle: {fontSize:<?php print($font);?>}},
+		    hAxis: {minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
                   backgroundColor: {stroke: '<?php print($bcolor);?>', strokeWidth: 5}}
             );
         google.visualization.events.addListener(chart, 'select', selectHandler);  
@@ -806,21 +806,21 @@ if($evd==-9999)
     {
 ?>
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', 'Old'],
+						    [{label:'<?php print($name);?>',type:'number'},{label: 'Old'}],
 <?php
   $c_i=2;
   $c_i_old=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //       $val1=map($name,$val1,$keyval);
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
        $c_i++;         
 
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
-
+       //$val1_old=map($name,$val1_old,$keyval);
+       
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
        $c_i_old++; 
@@ -832,14 +832,14 @@ if($evd==-9999)
   if($j==100)
   {
         $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+	//$val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
        $c_i++;
 
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+	//$val1_old=map($name,$val1_old,$keyval);
   
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
@@ -856,14 +856,14 @@ if($evd==-9999)
 
 ?>
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', 'Old', 'New'],
+						    [{label:'<?php print($name);?>',type:'number'},{label: 'Old'},{label: 'New'}],
 <?php
   $c_i=2;
   $c_i_old=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //$val1=map($name,$val1,$keyval);
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
        $c_i++;         
@@ -880,7 +880,7 @@ if($evd==-9999)
   if($j==100)
   {
         $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+	//$val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -898,11 +898,11 @@ if($evd==-9999)
 }
 else
 {
-    $evd=map($name,$evd,$keyval);
+  //$evd=map($name,$evd,$keyval);
     $evduse=$evd;
 ?>
   var data = google.visualization.arrayToDataTable([
-    ['<?php print($name);?>', 'Old', 'New'],
+						    [{label:'<?php print($name);?>',type:'number'},{label: 'Old'},{label: 'New'}],
 
 <?php
  
@@ -910,7 +910,7 @@ else
   for($j=0;$j<100;$j++) 
   {     
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+       //$val1_old=map($name,$val1_old,$keyval);
 
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
@@ -933,7 +933,7 @@ else
   if($j==100)
   {
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+       //$val1_old=map($name,$val1_old,$keyval);
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
        $c_i_old++;
@@ -978,9 +978,10 @@ else
             chart.draw(data, {curveType: "function",
                   title:"<?php print($named);?>", titleTextStyle: {fontSize: <?php print($font);?>},
 			legend: {position: 'none'},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+		  hAxis: {gridlines: {count: 4}, textStyle: {fontSize: 9}, viewWindowMode: 'maximized'},
+                    vAxis: {maxValue: 1, minValue: 0,viewWindow: {min:0}, gridlines: {count:5}, textStyle: {fontSize: 9}},
+                    chartArea:{left:30,top:25,right:8,bottom:25},
                   backgroundColor: {stroke: '<?php print($bcolor);?>', strokeWidth: 5}}
             );
            google.visualization.events.addListener(chart, 'select', selectHandler); 
@@ -1145,7 +1146,7 @@ for($i=0;$i<$nnode;$i++)
 <script type="text/javascript">
    google.setOnLoadCallback(draw_<?php print($name)?>);
 </script>
-<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($hieght);?>; position: absolute"></div>
+<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($height);?>; position: absolute"></div>
 
 <?php 
 }
diff --git a/sourcecodes/network_layout_inv_2_example.php b/sourcecodes/network_layout_inv_2_example.php
index 3ec0d84c..7835ec0d 100644
--- a/sourcecodes/network_layout_inv_2_example.php
+++ b/sourcecodes/network_layout_inv_2_example.php
@@ -573,7 +573,7 @@ $flag=0; //evidence flag
      if($ev_arr[$ii]==$name)
      {
         $evd=$evdata_arr[$ii]; 
-        $evd=levelmap($evd,$name,$levelmap);
+        //$evd=levelmap($evd,$name,$levelmap);
         $flag=1;
         break;
      }
@@ -766,8 +766,8 @@ else
          chart.draw(data,
                  {title:"<?php print($named);?>", titleTextStyle: {fontSize: <?php print($font);?>},
                   width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
+                  vAxis: {textStyle: {fontSize:<?php print($font);?>}},
+		    hAxis: {minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
                   backgroundColor: {stroke: '<?php print($bcolor);?>', strokeWidth: 5}}
             );
         google.visualization.events.addListener(chart, 'select', selectHandler);  
@@ -800,20 +800,20 @@ if($evd==-9999)
     {
 ?>
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', 'Old'],
+	[{label:'<?php print($name);?>',type:'number'},{label:'Old'}],
 <?php
   $c_i=2;
   $c_i_old=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //$val1=map($name,$val1,$keyval);
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
        $c_i++;         
 
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+       //$val1_old=map($name,$val1_old,$keyval);
 
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
@@ -826,14 +826,14 @@ if($evd==-9999)
   if($j==100)
   {
         $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+	//$val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
        $c_i++;
 
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+	//$val1_old=map($name,$val1_old,$keyval);
   
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
@@ -850,14 +850,14 @@ if($evd==-9999)
 
 ?>
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', 'Old', 'New'],
+	[{label:'<?php print($name);?>',type:'number'},{label:'Old'},{label:'New'}],
 <?php
   $c_i=2;
   $c_i_old=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //$val1=map($name,$val1,$keyval);
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
        $c_i++;         
@@ -874,7 +874,7 @@ if($evd==-9999)
   if($j==100)
   {
         $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+	//$val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -892,11 +892,11 @@ if($evd==-9999)
 }
 else
 {
-    $evd=map($name,$evd,$keyval);
+  //$evd=map($name,$evd,$keyval);
     $evduse=$evd;
 ?>
   var data = google.visualization.arrayToDataTable([
-    ['<?php print($name);?>', 'Old', 'New'],
+	[{label:'<?php print($name);?>',type:'number'},{label: 'Old'},{label: 'New'}],
 
 <?php
  
@@ -904,7 +904,7 @@ else
   for($j=0;$j<100;$j++) 
   {     
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+       //$val1_old=map($name,$val1_old,$keyval);
 
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
@@ -927,7 +927,7 @@ else
   if($j==100)
   {
        $val1_old=trim($data_read_old[$s_i_old][$c_i_old]);
-       $val1_old=map($name,$val1_old,$keyval);
+       //$val1_old=map($name,$val1_old,$keyval);
        $c_i_old++;
        $val2_old=trim($data_read_old[$s_i_old][$c_i_old]);
        $c_i_old++;
@@ -973,9 +973,10 @@ else
                   title:"<?php print($named);?>", titleTextStyle: {fontSize: <?php print($font);?>},
 			legend: {position: 'none'},
                   width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
-                  backgroundColor: {stroke: '<?php print($bcolor);?>', strokeWidth: 5}}
+		  hAxis: {gridlines: {count: 4}, textStyle: {fontSize: 9}, viewWindowMode: 'maximized'},
+                   vAxis: {maxValue: 1, minValue: 0,viewWindow: {min:0}, gridlines: {count:5}, textStyle: {fontSize: 9}},
+                   chartArea:{left:30,top:25,right:8,bottom:25},
+                   backgroundColor: {stroke: '<?php print($bcolor);?>', strokeWidth: 5}}
             );
            google.visualization.events.addListener(chart, 'select', selectHandler); 
        }
diff --git a/sourcecodes/network_layout_inv_example.php b/sourcecodes/network_layout_inv_example.php
index 1e5cd51b..04543523 100644
--- a/sourcecodes/network_layout_inv_example.php
+++ b/sourcecodes/network_layout_inv_example.php
@@ -60,31 +60,31 @@ $node=trim($str_arrmat[0]);
 if($node<=5)
 {
   $width=200;
-  $hieght=150;
+  $height=150;
   $font=14;
 }
 else if($node>5 && $node<=7)
 {
   $width=150;
-  $hieght=120;
+  $height=120;
   $font=12;
 
 }
 else if($node>7 && $node<=10)
 {
   $width=110;
-  $hieght=85;
+  $height=85;
   $font=10;
 }
 else 
 {
   $width=80;
-  $hieght=60;
+  $height=60;
   $font=8;
 }
 */
   $width=150;
-  $hieght=150;
+  $height=150;
   $font=12;
 
 $r_index=$node+2;
@@ -401,9 +401,9 @@ for($i=0;$i<$nnode;$i++)
         } 
          chart.draw(data,
                  {title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                  vAxis: {textStyle: {fontSize:<?php print($font);?>}},
+		    hAxis: {minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
                   backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
         google.visualization.events.addListener(chart, 'select', selectHandler);  
@@ -417,13 +417,13 @@ for($i=0;$i<$nnode;$i++)
   function <?php print($fname);?> {
   // Create and populate the data table.
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', ''],
+						    [{label:'<?php print($name);?>', type: 'number'},{label: ''}],
   <?php
   $c_i=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //$val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -437,7 +437,7 @@ for($i=0;$i<$nnode;$i++)
   if($j==100)
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //$val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -469,9 +469,10 @@ for($i=0;$i<$nnode;$i++)
             chart.draw(data, {curveType: "function",
                   title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
 			legend: {position: 'none'},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+		  hAxis: {gridlines: {count: 4}, textStyle: {fontSize: 9}, viewWindowMode: 'maximized'},
+                    vAxis: {maxValue: 1, minValue: 0,viewWindow: {min:0}, gridlines: {count:5}, textStyle: {fontSize: 9}},
+                    chartArea:{left:30,top:25,right:8,bottom:25},
                   backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
            google.visualization.events.addListener(chart, 'select', selectHandler); 
@@ -641,7 +642,7 @@ for($i=0;$i<$nnode;$i++)
 <script type="text/javascript">
    google.setOnLoadCallback(draw_<?php print($name)?>);
 </script>
-<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($hieght);?>; position: absolute"></div>
+<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($height);?>; position: absolute"></div>
 
 <?php 
 }
diff --git a/sourcecodes/parameter_display.php b/sourcecodes/parameter_display.php
new file mode 100644
index 00000000..7df6d282
--- /dev/null
+++ b/sourcecodes/parameter_display.php
@@ -0,0 +1,16 @@
+<?php $keyval=$_GET["My_key"]; ?>
+
+<h3> <a href=<?php $d="./data/".$keyval."parameters.txt"; print($d);?>>View original parameters</a></h3>
+<br>
+
+<br>
+
+<?php
+$filename="./data/".$keyval."parameters_ev.txt";
+if(file_exists($filename)) 
+{?>
+<h3> <a href=<?php $d="./data/".$keyval."parameters_ev.txt"; print($d);?>>View parameters after added evidence or intervention</a></h3>
+<br>
+<?php
+}
+?>
diff --git a/sourcecodes/parameter_learning/Predictmultiple.m b/sourcecodes/parameter_learning/Predictmultiple.m
index 692c6b24..f03568ef 100644
--- a/sourcecodes/parameter_learning/Predictmultiple.m
+++ b/sourcecodes/parameter_learning/Predictmultiple.m
@@ -1,57 +1,72 @@
 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');
-                            
+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');
 
+means_orig = cell(1,nnodes);
+stdevs_orig = cell(1,nnodes);
+labels_orig = cell(1,nnodes);
+%Read in original means and standard deviations
+mapfile = strcat(pre,'map.txt');
+fmap = fopen(mapfile,'r');
+for i=1:nnodes
+    buffer = fgetl(mapfile);
+    temp = cell(1,4);
+    for j=1:4
+        [next,buffer] = strtok(buffer);
+        temp{j} = next;
+    end
+    labels_orig{i} = temp{1};
+    means_orig{i} = str2num(temp{4});
+    stdevs_orig{i} = str2num(temp{3});
+end
+fclose(fmap);
+
+%Need to map the means and stdevs to the correct labels
+means = cell(1,nnodes);
+stdevs = cell(1,nnodes);
+%Read in labels in new order.
+labelsnew = cell(1,nnodes);
+mapdatafile = strcat(pre,'mapdata.txt');
+fmapdata = fopen(mapdatafile,'r');
+buffer = fgetl(fmapdata);
+for i = 1:nnodes
+    [next,buffer ] = strtok(buffer);
+    labelsnew{i} = next;
+end
+fclose(fmapdata);
+for i = 1:nnodes
+    for j = 1:nnodes
+       if strcmp(labelsnew{i},labels_orig{j})
+          means{i} = means_orig{j};
+          stdevs{i} = stdevs_orig{j};
+          break
+       end
+    end
+end
+
+
 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
+drawFigureM(nnodes,bnet,labels,filename,cases,stdevs,means,select_var_new,select_var_data_new);
+
+writeParameters_ev(pre,bnet,nnodes,labels,cases,stdevs,means,select_var_new,select_var_data_new);
+
+end
diff --git a/sourcecodes/parameter_learning/Predictmultipleintrvention.m b/sourcecodes/parameter_learning/Predictmultipleintrvention.m
index d3d509cb..1b9fa2f4 100644
--- a/sourcecodes/parameter_learning/Predictmultipleintrvention.m
+++ b/sourcecodes/parameter_learning/Predictmultipleintrvention.m
@@ -11,17 +11,13 @@ 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);
 
+[bnet]=parameterLearning(bnet,cases);
 
 fvarfile=strcat(pre,'var.txt');
-fvar = fopen(fvarfile,'r');
-                            
+fvar = fopen(fvarfile,'r');                           
 select_var_new = fscanf(fvar,'%d');
 
 nm = numel(select_var_new);
@@ -48,26 +44,52 @@ fvard = fopen(fvardfile,'r');
 
 select_var_data_new = fscanf(fvard,'%f');
 
+means_orig = cell(1,nnodes);
+stdevs_orig = cell(1,nnodes);
+labels_orig = cell(1,nnodes);
+%Read in original means and standard deviations
+mapfile = strcat(pre,'map.txt');
+fmap = fopen(mapfile,'r');
+for i=1:nnodes
+    buffer = fgetl(mapfile);
+    temp = cell(1,4);
+    for j=1:4
+        [next,buffer] = strtok(buffer);
+        temp{j} = next;
+    end
+    labels_orig{i} = temp{1};
+    means_orig{i} = str2num(temp{4});
+    stdevs_orig{i} = str2num(temp{3});
+end
+fclose(fmap);
+
+%Need to map the means and stdevs to the correct labels
+means = cell(1,nnodes);
+stdevs = cell(1,nnodes);
+%Read in labels in new order.
+labelsnew = cell(1,nnodes);
+mapdatafile = strcat(pre,'mapdata.txt');
+fmapdata = fopen(mapdatafile,'r');
+buffer = fgetl(fmapdata);
+for i = 1:nnodes
+    [next,buffer ] = strtok(buffer);
+    labelsnew{i} = next;
+end
+fclose(fmapdata);
+for i = 1:nnodes
+    for j = 1:nnodes
+       if strcmp(labelsnew{i},labels_orig{j})
+          means{i} = means_orig{j};
+          stdevs{i} = stdevs_orig{j};
+          break
+       end
+    end
+end
+
 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
+drawFigureM(nnodes,bnet,labels,filename,cases,stdevs,means,select_var_new,select_var_data_new);
+
+writeParameters_int(pre,bnet,nnodes,labels,cases,stdevs,means,select_var_new,select_var_data_new);
+
+end
diff --git a/sourcecodes/parameter_learning/drawFigure.m b/sourcecodes/parameter_learning/drawFigure.m
index 76979b3e..404a65f7 100644
--- a/sourcecodes/parameter_learning/drawFigure.m
+++ b/sourcecodes/parameter_learning/drawFigure.m
@@ -1,18 +1,19 @@
-function [] = drawFigure(nnodes,bnet,labels,filename,cases,selectvar,selectdata)
+function [] = drawFigure(nnodes,bnet,labels,filename,cases,stdevs,means,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);
+
+if nargin < 8,
+    drawFigureNoEv(nnodes,bnet,labels,filename,cases,stdevs,means);
 else
-    drawFigureEv(nnodes,bnet,labels,filename,cases,selectvar,selectdata);
+    drawFigureEv(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata);
 end;
 
 end
 
 
 
-function [] = drawFigureEv(nnodes,bnet,labels,filename,cases,selectvar,selectdata)
+function [] = drawFigureEv(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata)
 %Function to use if there is no entered evidence. 
 %         
 %
@@ -152,6 +153,8 @@ for i = 1:nnodes,
         [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,
+            %%Undo standardization
+            xvals(j,1) = xvals(j,1)*stdevs{i}+means{i}
             fprintf(fileID,'%6.4f\t%6.4f\n',x_vals(j,1),y_vals(j,1));
         end;
       end;
@@ -172,7 +175,7 @@ end
 
 
 
-function [] = drawFigureNoEv(nnodes,bnet,labels,filename,cases)
+function [] = drawFigureNoEv(nnodes,bnet,labels,filename,cases,stdevs,means)
 %Function to use if there is no entered evidence. 
 %         
 %
@@ -302,6 +305,8 @@ for i = 1:nnodes,
         [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,
+            %%Undo standardization
+            x_vals(j,1) = x_vals(j,1)*stdevs{i}+means{i};
             fprintf(fileID,'%6.4f\t%6.4f\n',x_vals(j,1),y_vals(j,1));
         end;
     end;
diff --git a/sourcecodes/parameter_learning/drawFigureM.m b/sourcecodes/parameter_learning/drawFigureM.m
index 95a27634..91b8698f 100644
--- a/sourcecodes/parameter_learning/drawFigureM.m
+++ b/sourcecodes/parameter_learning/drawFigureM.m
@@ -1,21 +1,6 @@
-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
+function [] = drawFigureM(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata)
+%drawFigureM writes the parameters and data that are needed to draw the
+%structure of a Bayesian network after added evidence or intervention
 
 fileID = fopen(filename,'w');
 
@@ -30,49 +15,35 @@ 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);   
-    
+%Need to standardized evidence for continuous nodes.
+    if bnet.node_sizes(di) == 1
+        ev_dat(di) = (ev_dat(di) - means{di}) / stdevs{di};
+    end
     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;
+fprintf(fileID,'\n');
 
 [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)
-
+fprintf(fileID,'%i\t%i\t\n',x_dim,y_dim);
 x = x*x_dim;
 y = y*y_dim;
 for i = 1:nnodes,
@@ -99,7 +70,6 @@ for i = 1:nnodes,
     end
 end
 
-
 for i = 1:nnodes,
     %%% The name and type of each node (1=continuous, the number of states
     %%% if it is discrete
@@ -162,23 +132,25 @@ for i = 1:nnodes,
             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,
+            %%Undo standardization
+            x_vals(j,1) = x_vals(j,1)*stdevs{i}+means{i};
             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);
+      if bnet.node_sizes(i) == 1,
+	fprintf(fileID,'%6.4f\t%6.4f\n',ev_dat(i)*stdevs{i}+means{i},1);
+      else
+	fprintf(fileID,'%6.4f\t%6.4f\n',ev_dat(i),1);
+      endif 
     end
     
 end
-%fprintf(fileID,'%s\t %\n',labels_temp{:});
-
 
 fclose(fileID);
-
 end
 
 
diff --git a/sourcecodes/parameter_learning/prepareInput.m b/sourcecodes/parameter_learning/prepareInput.m
new file mode 100644
index 00000000..28a06c15
--- /dev/null
+++ b/sourcecodes/parameter_learning/prepareInput.m
@@ -0,0 +1,281 @@
+function  [ ] = prepareInput( pre )
+   %   
+   %  This function takes files that are uploaded to BNW and creates output
+   %    files that can be used for structure and parameter learning.
+   %  It replaces php code that was previously in bn_file_load_gom.php.
+   %    There are several improvements in performance and ease of use:
+   %     1) Loading files is significantly (~5x) faster for large input files.
+   %     2) The allowed values for discrete variables are more flexible. 
+   %           (e.g., A genotype variable be 'B' and 'D' instead of having
+   %               to replace to make them '1' and '2'.)
+   %     3) Continuous variables may be identified as continuous in some cases
+   %            even if there is not a period.
+   %     4) The states of discrete variables should be correctly ordered in
+   %            almost all cases.
+   %     5) An additional output file is written that will let users check if
+   %            the input file has been uploaded and parsed correctly.
+   %     6) Future updates to this code should be easier than updating the php.
+   %      
+   %
+   %  Input: ???continuous_input_orig.txt
+   %    This is the input file that is uploaded to BNW.
+   %    It is directly written out by the BNW php code with no modification.
+   %    The file format is a header line containing the variable names
+   %     followed by the data, with each case in a row.
+   %
+   %  Output: There are many output files.
+   %    1) The main output file is ???continuous_input.txt that can be
+   %       used by the structure learning code and parameter learning codes.
+   %       The first line is variable names, the second line is the node type
+   %          (continuous nodes should have 1, discrete nodes have the number
+   %           of states), and the rest is the data.
+   %    2) A new output file is ???input_desc.txt, a file that describes the
+   %        data so users can check that it has been parsed correctly.
+   %    3) ???nlevels.txt: The states of discrete variables.
+   %    4) ???name.txt: The names of the variables as uploaded.
+   %    5) ???type.txt: The number of states for each variables
+   %            (1 indicates a continuous variable.)
+   %    6/7) ???nnode.txt and ???nrows.txt: number of nodes and cases
+   %    8-12) ???ban.txt, ???white.txt, ???k.txt, ???thr.txt, and
+   %          ???parent.txt: Files with default values for structure learning. 
+   %
+
+%  open file for input, include error handling
+dfile=strcat(pre,'continuous_input_orig.txt');
+
+fin = fopen(dfile,'r');
+if fin < 0
+   error(['Could not open ',dfile,' for input']);
+end
+
+% Get the number of cases (the number of rows in the file excluding the header)
+ncases = fskipl(fin,Inf) - 1;
+
+frewind(fin);
+
+% Read in first line to get the number of nodes and the node labels.
+buffer = fgetl(fin);    %get header line as a string
+nnodes = numel(strfind(buffer,"\t")) + 1;
+labels = cell(1,nnodes);
+for j=1:nnodes
+    [next,buffer] = strtok(buffer);
+    labels{j} = next;
+end
+
+% Read in the data
+data = cell(ncases,nnodes);
+for i = 1:ncases
+    buffer = fgetl(fin);
+    for j = 1:nnodes
+         [next,buffer] = strtok(buffer);
+         data{i,j} = next;
+    end
+end
+
+% Determine whether or not the nodes are continuous or discrete.
+% First, treat them as all discrete and get the states and number of stats(levels).
+levels = cell(1,nnodes);
+states = [];
+for j = 1:nnodes
+   states{end+1} = unique(data(:,j));
+   levels{j} = size(states{j},1);
+end
+
+%Now do some checks to see if nodes are discrete or continuous
+for j = 1:nnodes
+    % If there are 3 or less unique values, I will assume that the node is discrete.
+    if levels{j} < 4;
+        continue
+    % If there are as many unique values as a third of the number of cases,
+    %      I will assume that the node is continuous.
+    elseif levels{j} > ncases/3;
+       levels{j} = 1;
+    % If there are more than twenty unique values,
+    %      I will assume that the node is continuous.
+    elseif levels{j} > 20;
+       levels{j} = 1;
+    % Otherwise, I will scan through the individual values.
+    % If any of the values contain a '.', I will assume it is continuous.
+    else
+       period_test = 0;
+       column = data(:,j);
+       k = 1;
+       while period_test == 0 
+           period_test = sum(cell2mat(strfind(column(k),".")));
+           if period_test != 0;
+              levels{j} = 1;
+           end
+           k++;
+           if k > ncases
+              break
+           end
+        end
+    end
+end
+
+%I need to check if any discrete nodes are listed after continuous nodes.
+%If so, I need to rearrange the columns.
+max_disc = 0;
+min_cont = nnodes + 1;
+for i = 1:nnodes
+    if levels{i} > 1
+       max_disc = i;
+    elseif min_cont == nnodes+1
+       min_cont = i;
+    end
+end
+%If max_disc > min_cont, you need to rearrange the nodes
+%  to put the discrete nodes first.
+if max_disc > min_cont
+  levels_old = levels;
+  labels_old = labels;
+  data_old = data;
+  states_old = states;
+  new_order = {};
+  for i=1:nnodes
+    if levels_old{i} > 1
+      new_order{end+1} = i;
+    end
+  end
+  for i=1:nnodes
+    if levels_old{i} == 1
+      new_order{end+1} = i;
+    end
+  end
+  labels = {};
+  levels = {};
+  states = {};
+  for i =1:nnodes
+    labels{i} = labels_old{new_order{i}};
+    levels{i} = levels_old{new_order{i}};
+    states{i} = states_old{new_order{i}};
+    for j=1:ncases
+      data{j,i} = data_old{j,new_order{i}};
+    end
+  end
+  
+endif
+
+
+%Write other files that are used by BNW for this key.
+%The first group of files establish default settings for structure learning.
+outfile = strcat(pre,'white.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'From\tTo\n');
+fclose(fout);
+
+outfile = strcat(pre,'ban.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'From\tTo\n');
+fclose(fout);
+
+outfile = strcat(pre,'k.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'1\n');
+fclose(fout);
+
+outfile = strcat(pre,'parent.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'4\n');
+fclose(fout);
+
+outfile = strcat(pre,'thr.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'0.5\n');
+fclose(fout);
+
+
+%The next group of files have information about the uploaded file.
+outfile = strcat(pre,'name.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%s\t',labels{1:end-1});
+fprintf(fout,'%s\n',labels{end});
+fclose(fout);
+
+outfile = strcat(pre,'nnode.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%i\n',nnodes);
+fclose(fout);
+
+outfile = strcat(pre,'nrows.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%i\n',ncases);
+fclose(fout);
+
+outfile = strcat(pre,'type.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%s\t',labels{1:end-1});
+fprintf(fout,'%s\n',labels{end});
+fprintf(fout,'%i\t',levels{1:end-1});
+fprintf(fout,'%i\n',levels{end});
+fclose(fout);
+
+%This output file contains the states for discrete nodes.
+% The unique matlab function already sorts the states.
+outfile = strcat(pre,'nlevels.txt');
+fout = fopen(outfile,'w');
+for i = 1:nnodes
+    if levels{i} > 1
+        fprintf(fout,'%s\t',labels{i},states{i}{1:end-1});
+        fprintf(fout,'%s\n',states{i}{end});
+    end
+end
+fclose(fout);
+
+
+%Print a file with a short description of the input.
+descfile = strcat(pre,'input_desc.txt');
+dout = fopen(descfile,'w');
+fprintf(dout,['As loaded, the input file had the following properties:\n\n']);
+dout = fopen(descfile,'a');
+fprintf(dout,'There are %i variables and %i cases(rows)\n',size(labels,2),ncases);
+fprintf(dout,'The variable names are:\n');
+fprintf(dout,'%s\t',labels{1:end-1});
+fprintf(dout,'%s\n\n',labels{end});
+for i=1:nnodes
+    if levels{i} == 1
+       fprintf(dout,'%s is a continuous variable\n',labels{i});
+       column = str2double(data(:,i));
+       colmean = mean(column);
+       colstd = std(column);
+       fprintf(dout,'It has a mean of %6.3f and a standard deviation of %6.3f\n\n',mean(column),std(column))
+    else 
+       fprintf(dout,'%s is a discrete variable with %i states\n',labels{i},levels{i});
+       fprintf(dout,'The states are: ');
+       fprintf(dout,'%s ',states{i}{1:end-1});
+       fprintf(dout,'%s\n\n',states{i}{end});
+    end
+end
+fclose(fout);
+
+outfile = strcat(pre,'continuous_input.txt');
+fout = fopen(outfile,'w');
+fprintf(fout,'%s\t',labels{1:end-1});
+fprintf(fout,'%s\n',labels{end});
+fprintf(fout,'%i\t',levels{1:end-1});
+fprintf(fout,'%i\n',levels{end});
+%Need to replace states in discrete variables with integers for BNT
+for i = 1:nnodes
+    if levels{i} > 1
+	for j = 1:ncases
+            for k=1:size(states{i},1)
+	      if data{j,i} == states{i}{k}
+                 data{j,i} = sprintf('%i',num2cell(k){1});;
+                 break
+              end
+            end
+        end
+     end
+end
+for i = 1:ncases
+      fprintf(fout,'%s\t',data{i,1:end-1});
+      fprintf(fout,'%s\n',data{i,end});
+end
+fclose(fout);
+
+
+
+
+
+end
+%  end of prepareInput.m
\ No newline at end of file
diff --git a/sourcecodes/parameter_learning/readInput.m b/sourcecodes/parameter_learning/readInput.m
index 9d4959b8..891d7f36 100644
--- a/sourcecodes/parameter_learning/readInput.m
+++ b/sourcecodes/parameter_learning/readInput.m
@@ -25,19 +25,12 @@ end
 [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
@@ -67,4 +60,4 @@ end
         
 
 end
-%  end of readInput.m
\ No newline at end of file
+%  end of readInput.m
diff --git a/sourcecodes/parameter_learning/runBN_initial.m b/sourcecodes/parameter_learning/runBN_initial.m
index 789b4260..c2dec164 100644
--- a/sourcecodes/parameter_learning/runBN_initial.m
+++ b/sourcecodes/parameter_learning/runBN_initial.m
@@ -15,84 +15,43 @@ 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);
+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');
+fclose(mapval);
+fclose(mapfile);
+
+%Need to rearrange the means and stdevs to match the new labeling.
+means = cell(1,nnodes);
+stdevs = cell(1,nnodes);
+for i = 1:nnodes
+    for j = 1:nnodes
+       if strcmp(labels{i},labelsold{j})
+          means{i} = m(j);
+          stdevs{i} = s(j);
+          break
+       end
+    end
+end
+
 
 [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
+
+drawFigure(nnodes,bnet,labels,filename,cases,stdevs,means);
+
+writeParameters(pre,nnodes,bnet,labels,cases,labelsold,s,m);
+
+end
diff --git a/sourcecodes/parameter_learning/standardizeData.m b/sourcecodes/parameter_learning/standardizeData.m
index 61ea280e..db5e04c7 100644
--- a/sourcecodes/parameter_learning/standardizeData.m
+++ b/sourcecodes/parameter_learning/standardizeData.m
@@ -1,7 +1,7 @@
 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);
 
diff --git a/sourcecodes/parameter_learning/test/Agbcontinuous_input.txt b/sourcecodes/parameter_learning/test/Agbcontinuous_input.txt
deleted file mode 100644
index bcd9b88c..00000000
--- a/sourcecodes/parameter_learning/test/Agbcontinuous_input.txt
+++ /dev/null
@@ -1,103 +0,0 @@
-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
deleted file mode 100644
index bb1dd64f..00000000
--- a/sourcecodes/parameter_learning/test/Agbmap.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-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
deleted file mode 100644
index fa8be0bd..00000000
--- a/sourcecodes/parameter_learning/test/Agbmapdata.txt
+++ /dev/null
@@ -1 +0,0 @@
-GenotypeB	Gene3	GenotypeA	Gene2	Gene4	Gene1
diff --git a/sourcecodes/parameter_learning/test/Agbnet_figure.txt b/sourcecodes/parameter_learning/test/Agbnet_figure.txt
deleted file mode 100644
index 8243b7d9..00000000
--- a/sourcecodes/parameter_learning/test/Agbnet_figure.txt
+++ /dev/null
@@ -1,440 +0,0 @@
-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
deleted file mode 100644
index 8243b7d9..00000000
--- a/sourcecodes/parameter_learning/test/Agbnet_figure.txt.bk
+++ /dev/null
@@ -1,440 +0,0 @@
-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
deleted file mode 100644
index 1e8b3149..00000000
--- a/sourcecodes/parameter_learning/test/Agbnnode.txt
+++ /dev/null
@@ -1 +0,0 @@
-6
diff --git a/sourcecodes/parameter_learning/test/Agbstructure_input.txt b/sourcecodes/parameter_learning/test/Agbstructure_input.txt
deleted file mode 100644
index 10766f0c..00000000
--- a/sourcecodes/parameter_learning/test/Agbstructure_input.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-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
deleted file mode 100644
index 678fda92..00000000
--- a/sourcecodes/parameter_learning/test/octave-core
+++ /dev/null
Binary files differdiff --git a/sourcecodes/parameter_learning/writeParameters.m b/sourcecodes/parameter_learning/writeParameters.m
new file mode 100644
index 00000000..0790a8e2
--- /dev/null
+++ b/sourcecodes/parameter_learning/writeParameters.m
@@ -0,0 +1,106 @@
+function [] = writeParameters(pre,nnodes,bnet,labels,cases,labelsold,s,m)
+%Writes a file that contains the parameters of the network with no evidence.
+
+
+%%Get the types of the nodes.
+typefile = strcat(pre,'type.txt');
+ftype = fopen(typefile,'r');
+types = cell(1,nnodes);
+buffer = fgetl(ftype);
+buffer = fgetl(ftype);
+for j = 1:nnodes
+    [next,buffer] = strtok(buffer);
+    types{j} = uint16(str2num(next));
+end
+
+max_states = 0;
+disc_nodes = 0;
+for j = 1:nnodes
+  if types{j} > max_states
+    max_states = types{j};
+  end
+  if types{j} > 1
+    disc_nodes = disc_nodes + 1;
+  end
+end
+
+%Add 1 to max_states to account for node name
+max_states = max_states + 1;
+
+%%Get mapping of discrete levels.
+levelfile = strcat(pre,'nlevels.txt');
+flevels = fopen(levelfile,'r');
+levels = cell(disc_nodes,max_states);
+ndisc_nodes = 0;
+for i=1:disc_nodes
+    ndisc_nodes = ndisc_nodes + 1;
+    buffer = fgetl(flevels);
+     for j = 1:max_states
+       [next,buffer] = strtok(buffer);
+       if j == 1
+          levels{i,j} = next;
+       else
+%          levels{i,j} = uint16(str2num(next));
+          levels{i,j} = next;
+       end        
+       if length(buffer) < 1
+        break
+       end
+     end
+end
+
+
+evidence = cell(1,nnodes);
+engine = jtree_inf_engine(bnet);
+[engine,loglik] = enter_evidence(engine,evidence);
+
+%Open output file.
+filename = strcat(pre,'parameters.txt');
+fileID = fopen(filename,'w');
+
+for i = 1:nnodes
+    for j = 1:nnodes
+	if strcmp(labelsold{i},labels{j});
+            nodeid = j;
+            break
+        end
+    end
+    predict = marginal_nodes(engine,nodeid);
+    %%%Print the name of the node
+    fprintf(fileID,'%s\n',labels{nodeid});
+    %%%Print the type of node
+    if bnet.node_sizes(nodeid) == 1;
+        line = 'Continuous node\n';
+        fprintf(fileID,line);
+        %%% 'i' in the line below is correct: m and s are had original node labeling
+        adj_mu = predict.mu*s(i)+m(i);
+        adj_sigma = s(i)*predict.Sigma;
+	fprintf(fileID,'%6.4f\t%6.4f\n\n',adj_mu,adj_sigma);
+    else
+        line = 'Discrete node with %i states\n';
+        fprintf(fileID,line,bnet.node_sizes(nodeid));
+        %line = 'Probability of each state\n';
+        %fprintf(fileID,line);
+        nodeid2 = 0;
+        for k = 1:ndisc_nodes,
+           if strcmp(levels{k,1},labels{nodeid}),
+	      nodeid2 = k;
+              break
+           end
+        end
+        for j = 1:bnet.node_sizes(nodeid),
+            %%%For discrete nodes, the state and the percent of that state
+%		  fprintf(fileID,'%i\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+		  fprintf(fileID,'%s\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+        end;
+        fprintf(fileID,'\n')
+
+    end
+end
+
+
+
+fclose(fileID);
+
+end
+
diff --git a/sourcecodes/parameter_learning/writeParameters_ev.m b/sourcecodes/parameter_learning/writeParameters_ev.m
new file mode 100644
index 00000000..fc24e2e5
--- /dev/null
+++ b/sourcecodes/parameter_learning/writeParameters_ev.m
@@ -0,0 +1,151 @@
+function [] = writeParameters_ev(pre,bnet,nnodes,labels,cases,stdevs,means,selectvar,selectdata)
+%Writes a file that contains the parameters of the network after entering evidence.
+
+%Read in original node labels to get node IDs.
+infile = strcat(pre,'continuous_input.txt');
+fin = fopen(infile,'r');
+labelsold = cell(1,nnodes);
+buffer = fgetl(fin);
+for j = 1:nnodes
+    [next,buffer] = strtok(buffer);
+    labelsold{j} = next;
+end
+fclose(fin);
+
+
+evidence = cell(1,nnodes);
+engine = jtree_inf_engine(bnet);
+
+m = size(selectvar,1);
+
+%%Get the types of the nodes.
+typefile = strcat(pre,'type.txt');
+ftype = fopen(typefile,'r');
+types = cell(1,nnodes);
+buffer = fgetl(ftype);
+buffer = fgetl(ftype);
+for j = 1:nnodes
+   [next,buffer] = strtok(buffer);
+   types{j} = uint16(str2num(next));
+end
+
+max_states = 0;
+disc_nodes = 0;
+for j = 1:nnodes
+  if types{j} > max_states
+       max_states = types{j};
+  end
+  if types{j} > 1
+    disc_nodes = disc_nodes + 1;
+  end
+end
+
+%Add 1 to max_states to account for node name
+max_states = max_states + 1;
+
+%%Get mapping of discrete levels.
+levelfile = strcat(pre,'nlevels.txt');
+flevels = fopen(levelfile,'r');
+levels = cell(disc_nodes,max_states);
+ndisc_nodes = 0;
+for i=1:disc_nodes
+	ndisc_nodes = ndisc_nodes + 1;
+buffer = fgetl(flevels);
+for j = 1:max_states
+	  [next,buffer] = strtok(buffer);
+       if j == 1
+	 levels{i,j} = next;
+       else
+%	 levels{i,j} = uint16(str2num(next));
+	 levels{i,j} = next;
+       end
+       if length(buffer) < 1
+        break
+       end
+     end
+end
+
+
+ev_dat = zeros(1,nnodes);
+for i = 1:m,
+    di=selectvar(i,1);
+    ev_dat(di)=selectdata(i,1);
+%Need to standardize evidence for continuous nodes.
+    if bnet.node_sizes(di) == 1,
+        ev_dat(di) = (ev_dat(di) - means{di})/stdevs{di};
+    end
+    evidence{di} = ev_dat(di);
+end
+
+[engine,loglik]=enter_evidence(engine,evidence);
+
+%Open output file.
+filename = strcat(pre,'parameters_ev.txt');
+fileID = fopen(filename,'w');
+
+for i = 1:nnodes
+    for j = 1:nnodes
+	if strcmp(labelsold{i},labels{j});
+            nodeid = j;
+            break
+        end
+    end
+    %%%Print the name of the node
+    fprintf(fileID,'%s\n',labels{nodeid});
+    predict = marginal_nodes(engine,nodeid);
+    if isempty(evidence{nodeid})
+       %%%Print the type of node
+       if bnet.node_sizes(nodeid) == 1;
+           line = 'Continuous parameters considering evidence:\n';
+           fprintf(fileID,line);
+           %line = 'Mean and standard deviation of Gaussian distribution\n';
+           %fprintf(fileID,line);
+	     adj_mu = predict.mu*stdevs{nodeid}+means{nodeid};
+             adj_sigma = stdevs{nodeid}*predict.Sigma;
+             fprintf(fileID,'%6.4f\t%6.4f\n\n',adj_mu,adj_sigma);
+       else
+           line = 'Probability of states considering evidence:\n';
+           fprintf(fileID,line);
+           nodeid2 = 0;
+           for k = 1:ndisc_nodes,
+	     if strcmp(levels{k,1},labels{nodeid}),
+                nodeid2 = k;
+                break
+             end
+            end
+	    for j = 1:bnet.node_sizes(nodeid),
+		%%%For discrete nodes, the state and the percent of that state
+%		fprintf(fileID,'%i\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+		fprintf(fileID,'%s\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+           end;
+           fprintf(fileID,'\n')
+       end
+   else
+       if bnet.node_sizes(nodeid) == 1;
+          line = 'Evidence was observed for this node. The observed value was:\n';
+          fprintf(fileID,line);  
+          adj_mu = ev_dat(nodeid)*stdevs{nodeid}+means{nodeid};
+          fprintf(fileID,'%6.4f\n\n',adj_mu);
+       else
+          nodeid2 = 0;
+          for k = 1:ndisc_nodes,
+	    if strcmp(levels{k,1},labels{nodeid}),
+               nodeid2 = k;
+               break
+            end
+          end
+	 line = 'Evidence was observed for this node. The observed state was:\n';
+         fprintf(fileID,line);
+         state_ev =   uint16(ev_dat(nodeid));
+%         fprintf(fileID,'%i\n\n',levels{nodeid2,state_ev+1});
+         fprintf(fileID,'%s\n\n',levels{nodeid2,state_ev+1});
+       end
+   end
+end
+
+
+
+fclose(fileID);
+
+end
+
diff --git a/sourcecodes/parameter_learning/writeParameters_int.m b/sourcecodes/parameter_learning/writeParameters_int.m
new file mode 100644
index 00000000..ed92d593
--- /dev/null
+++ b/sourcecodes/parameter_learning/writeParameters_int.m
@@ -0,0 +1,186 @@
+function [] = writeParameters_int(pre,bnet,nnodes,labels,cases,stdevs,means,selectvar,selectdata)
+%Writes a file that contains the parameters of the network after intervention.
+
+
+%First read input file to get node labels to get node IDs.
+infile = strcat(pre,'continuous_input.txt');
+fin = fopen(infile,'r');
+labelsold = cell(1,nnodes);
+buffer = fgetl(fin);
+for j = 1:nnodes
+    [next,buffer] = strtok(buffer);
+    labelsold{j} = next;
+end
+
+evidence = cell(1,nnodes);
+engine = jtree_inf_engine(bnet);
+
+m = size(selectvar,1);
+
+%%Get the types of the nodes.
+typefile = strcat(pre,'type.txt');
+ftype = fopen(typefile,'r');
+types = cell(1,nnodes);
+buffer = fgetl(ftype);
+buffer = fgetl(ftype);
+for j = 1:nnodes
+   [next,buffer] = strtok(buffer);
+   types{j} = uint16(str2num(next));
+end
+
+max_states = 0;
+disc_nodes = 0;
+for j = 1:nnodes
+  if types{j} > max_states
+       max_states = types{j};
+  end
+  if types{j} > 1
+    disc_nodes = disc_nodes + 1;
+  end
+end
+
+%Add 1 to max_states to account for node name
+max_states = max_states + 1;
+
+%%Get mapping of discrete levels.
+levelfile = strcat(pre,'nlevels.txt');
+flevels = fopen(levelfile,'r');
+levels = cell(disc_nodes,max_states);
+ndisc_nodes = 0;
+for i=1:disc_nodes
+	ndisc_nodes = ndisc_nodes + 1;
+buffer = fgetl(flevels);
+for j = 1:max_states
+	  [next,buffer] = strtok(buffer);
+       if j == 1
+	 levels{i,j} = next;
+       else
+%	 levels{i,j} = uint16(str2num(next));
+	 levels{i,j} = next;
+       end
+       if length(buffer) < 1
+        break
+       end
+     end
+end
+
+
+ev_dat = zeros(1,nnodes);
+for i = 1:m,
+    di=selectvar(i,1);
+    ev_dat(di)=selectdata(i,1);
+%Need to standardize evidence for continuous nodes.
+    if bnet.node_sizes(di) == 1,
+      ev_dat(di) = (ev_dat(di) - means{di})/stdevs{di};
+    end
+    evidence{di} = ev_dat(di);
+end
+
+[engine,loglik]=enter_evidence(engine,evidence);
+
+%Get list of nodes that are children, grandchildren, etc. of intervened nodes
+%int_nodes contains the list of these children nodes
+int_nodes = zeros(1,nnodes);
+%new_nodes is just a temporary array to know when to keep looking
+new_nodes = zeros(1,nnodes);
+for i = 1:nnodes
+    if !isempty(evidence{i});
+        new_nodes(i) = 1;
+        int_nodes(i) = 1;
+    end
+end
+while sum(new_nodes) != 0
+   new_nodes_old = new_nodes;
+   new_nodes = zeros(1,nnodes);
+   for i = 1:nnodes
+      if new_nodes_old(i) == 1
+           for j = 1:nnodes
+              if int_nodes(j) == 0
+	        if bnet.dag(i,j) == 1,
+		     new_nodes(j) = 1;
+                end
+              end
+           end
+       end
+   end
+   for i = 1:nnodes
+      if new_nodes(i) == 1;
+        int_nodes(i) = 1;
+      end
+   end               
+end
+
+
+%Open output file.
+filename = strcat(pre,'parameters_ev.txt');
+fileID = fopen(filename,'w');
+
+for i = 1:nnodes
+    for j = 1:nnodes
+	if strcmp(labelsold{i},labels{j});
+            nodeid = j;
+            break
+        end
+    end
+    %check to see if this is a node impacted by intervention
+    if int_nodes(nodeid) == 1
+    %%%Print the name of the node
+    fprintf(fileID,'%s\n',labels{nodeid});
+    predict = marginal_nodes(engine,nodeid);
+    if isempty(evidence{nodeid})
+       %%%Print the type of node
+       if bnet.node_sizes(nodeid) == 1;
+           line = 'Continuous parameters considering intervention:\n';
+           fprintf(fileID,line);
+           %line = 'Mean and standard deviation of Gaussian distribution\n';
+           %fprintf(fileID,line);
+	   adj_mu = predict.mu*stdevs{nodeid}+means{nodeid};
+           adj_sigma = stdevs{nodeid}*predict.Sigma;
+           fprintf(fileID,'%6.4f\t%6.4f\n\n',adj_mu,adj_sigma);
+       else
+           line = 'Probability of states considering intervention:\n';
+           fprintf(fileID,line);
+           nodeid2 = 0;
+           for k = 1:ndisc_nodes,
+	     if strcmp(levels{k,1},labels{nodeid}),
+                nodeid2 = k;
+                break
+             end
+            end
+	    for j = 1:bnet.node_sizes(nodeid),
+		%%%For discrete nodes, the state and the percent of that state
+%		fprintf(fileID,'%i\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+		fprintf(fileID,'%s\t%6.4f\n',levels{nodeid2,j+1},predict.T(j));
+           end;
+           fprintf(fileID,'\n')
+       end
+   else
+       if bnet.node_sizes(nodeid) == 1;
+          line = 'Intervention on this node assigned the following value:\n';
+          fprintf(fileID,line);  
+          adj_mu = ev_dat(nodeid)*stdevs{nodeid}+means{nodeid};
+          fprintf(fileID,'%6.4f\n\n',adj_mu);
+       else
+          nodeid2 = 0;
+          for k = 1:ndisc_nodes,
+	    if strcmp(levels{k,1},labels{nodeid}),
+               nodeid2 = k;
+               break
+            end
+          end
+	 line = 'Intervention on this node assigned the following state:\n';
+         fprintf(fileID,line);
+         state_ev =   uint16(ev_dat(nodeid));
+%         fprintf(fileID,'%i\n\n',levels{nodeid2,state_ev+1});
+         fprintf(fileID,'%s\n\n',levels{nodeid2,state_ev+1});
+       end
+   end
+   end
+end
+
+
+
+fclose(fileID);
+
+end
+
diff --git a/sourcecodes/run_octave_inv~ b/sourcecodes/run_octave_inv~
deleted file mode 100644
index f9e568e3..00000000
--- a/sourcecodes/run_octave_inv~
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/octave -qf
-cd ./data
-arg_list = argv(); 
-addpath("../bnt-master");
-addpath(genpathKPM("../bnt-master"));
-addpath("../parameter_learning");
-Predictmultipleintervention(arg_list{1});
diff --git a/sourcecodes/run_octave~ b/sourcecodes/run_octave~
deleted file mode 100644
index fe29d0d1..00000000
--- a/sourcecodes/run_octave~
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/octave -qf
-cd ./data
-arg_list = argv(); 
-addpath("/var/www/html/compbio/BNW_1.02/sourcecodes/bnt-master");
-addpath(genpathKPM("/var/www/html/compbio/BNW_1.02/sourcecodes/bnt-master"));
-addpath("/var/www/html/compbio/BNW_1.02/sourcecodes/parameter_learning");
-runBN_initial(arg_list{1});
diff --git a/sourcecodes/run_octave_evd~ b/sourcecodes/run_prep_input
index 3879280e..4611d880 100644
--- a/sourcecodes/run_octave_evd~
+++ b/sourcecodes/run_prep_input
@@ -4,4 +4,4 @@ arg_list = argv();
 addpath("../bnt-master");
 addpath(genpathKPM("../bnt-master"));
 addpath("../parameter_learning");
-runBN_initial(arg_list{1});
+prepareInput(arg_list{1});
diff --git a/sourcecodes/runmat.sh b/sourcecodes/runmat.sh
deleted file mode 100644
index 948bdac3..00000000
--- a/sourcecodes/runmat.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-cd ./data/
-
-chmod 0774 $1run_initialstructure.sh
-
-./$1run_initialstructure.sh /usr/local/MATLAB/R2012a/
\ No newline at end of file
diff --git a/sourcecodes/runmat.sh.bk b/sourcecodes/runmat.sh.bk
deleted file mode 100644
index 948bdac3..00000000
--- a/sourcecodes/runmat.sh.bk
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-cd ./data/
-
-chmod 0774 $1run_initialstructure.sh
-
-./$1run_initialstructure.sh /usr/local/MATLAB/R2012a/
\ No newline at end of file
diff --git a/sourcecodes/runmat_evd.sh b/sourcecodes/runmat_evd.sh
deleted file mode 100644
index 68f30ca5..00000000
--- a/sourcecodes/runmat_evd.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-cd ./data/
-chmod 0774 $1run_evidencemodified.sh
-./$1run_evidencemodified.sh /usr/local/MATLAB/R2012a/
\ No newline at end of file
diff --git a/sourcecodes/runmat_evd.sh.bk b/sourcecodes/runmat_evd.sh.bk
deleted file mode 100644
index 68f30ca5..00000000
--- a/sourcecodes/runmat_evd.sh.bk
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-cd ./data/
-chmod 0774 $1run_evidencemodified.sh
-./$1run_evidencemodified.sh /usr/local/MATLAB/R2012a/
\ No newline at end of file
diff --git a/sourcecodes/runmat_inv.sh b/sourcecodes/runmat_inv.sh
deleted file mode 100644
index 1368b423..00000000
--- a/sourcecodes/runmat_inv.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-cd ./data/
-chmod 0774 $1run_newintervention.sh
-./$1run_newintervention.sh /usr/local/MATLAB/R2012a/
\ No newline at end of file
diff --git a/sourcecodes/runmat_inv.sh.bk b/sourcecodes/runmat_inv.sh.bk
deleted file mode 100644
index 1368b423..00000000
--- a/sourcecodes/runmat_inv.sh.bk
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-cd ./data/
-chmod 0774 $1run_newintervention.sh
-./$1run_newintervention.sh /usr/local/MATLAB/R2012a/
\ No newline at end of file