%-------NOTE------
%PLEASE CHANGE THE save_net PATH AT LINE NUMBER 300.
clear all
clear screen
close all
clc
load('Rdata')
Rdata=Rdata';
input=[Rdata(:,1:4)]';
target=[Rdata(:,5)]';
%%%To store the results of one complete simulation in one.mat file.
%%%The purpose is to get best results to run the whole programme z times
%%%and store whole results in a file after each simulation.
z_TF_OL_Checking=[];
% %%%Overall
z_TF_OL_O_out_k=[];
%%%Training
z_TF_OL_Tr_target_k=[];
z_TF_OL_Tr_out_k=[];
%%%%Testing
z_TF_OL_Ts_target_k=[];
z_TF_OL_Ts_out_k=[];
%%%Validation
z_TF_OL_V_target_k=[];
z_TF_OL_V_out_k=[];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for z=1%:30
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Prefix'F' means final of each
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% property
%%%%To store thing which run during whole simulation process%%%
TF_OL_Checking=[];
% %%%Overall
TF_OL_O_out_k=[];
%%%Training
TF_OL_Tr_target_k=[];
TF_OL_Tr_out_k=[];
%%%%Testing
TF_OL_Ts_target_k=[];
TF_OL_Ts_out_k=[];
%%%Validation
TF_OL_V_target_k=[];
TF_OL_V_out_k=[];
%%FF means function final output
FBest_Solution=[];
FBest_output=[];
FBest_Result_Ts_target=[];
FBest_Result_Ts_output=[];
FBest_Result_Tr_target=[];
FBest_Result_Tr_output=[];
FBest_Result_V_target=[];
FBest_Result_V_output=[];
% % %%%Description about coulumns of Cross validation solution
% % %%%Corresponding to Min RMSE of Trainig, BestLayers_Combination=(:,1);
%
% %%%%Corresponding to Min RMSE of Training, training regression=(:,2)
% % %%%Corresponding to Min RMSE of Taining, training RMSE=(:,3);
% % %%%Corresponding to Min RMSE of Taining, training MAE=(:,4);
%
% % %%%Corresponding to Min RMSE of Training, testing regression=(:,5)
% % %%%Corresponding to Min RMSE of Training, testing RMSE=(:,6);
% % %%%Corresponding to Min RMSE of Training, testing MAE=(:,7);
%
%
% % %%%Corresponding to Min RMSE of Training, validation regression=(:,8)
% % %%%Corresponding to Min RMSE of Training, validation RMSE=(:,9);
% % %%%Corresponding to Min RMSE of Training, validation MAE=(:,10);
%
%
% % %%%Corresponding to Min RMSE of Training, over all regression=(:,11);
% % %%%Corresponding to Min RMSE of Training, Over all RMSE=(:,12);
% % %%%Corresponding to Min RMSE of Training, Over all MAE=(:,13);
%%% EXECUSION OF PROGRAMME WITH DIFFERENT TRANSFER FUNCTION IN
%%%HIDDEN LAYER OUTPUTLAYER
%%%LOGSIG PURELIN =(1,;)
%%%TANSIG PURELIN =(2,;)
%%%RADBAS PURELIN =(3,;)
%%%LOGSIG LOGSIG =(4,;)
%%%LOGSIG TANSIG =(5,;)
%%%TANSIG LOGSIG =(6,;)
%%%TANSIG TANSIG =(7,;)
%%% TRANSFER FUNCTION OF TANSIG =(2,;)
%%% TRANSFER FUNCTION OF RADBAS =(3,;)
%%%Loop to test and run the network with different transfer and training
%%%functions. total transfer function are 7.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for TF=1%:7; %[1 2 3 5 7] [1 2 3 5 7];
OL_Checking=[];
%%%Overall
OL_O_out_k=[];
%%%Training
OL_Tr_target_k=[];
OL_Tr_out_k=[];
%%%%Testing
OL_Ts_target_k=[];
OL_Ts_out_k=[];
%%%Validation
OL_V_target_k=[];
OL_V_out_k=[];
FBestLayers_Combination=[];
%%%Overall%%%%
F_O_RMSE=[];
F_O_MAE=[];
FOverallRegression=[];
Foutput=[];
%%%%Testing%%%%
F_Ts_RMSE=[];
F_Ts_MAE=[];
FTesting_Regression=[];
F_Ts_target=[];
F_Ts_output=[];
%%%Training%%%%
F_Tr_RMSE=[];
F_Tr_MAE=[];
FTraining_Regression=[];
F_Tr_target=[];
F_Tr_output=[];
%%%%%Validation%%%%
F_V_RMSE=[];
F_V_MAE=[];
FValidation_Regression=[];
F_V_target=[];
F_V_output=[];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%ANNRT means ANN Running Time, i mean how much time i run it, 2 times or 3
%%time or more times
%%%to accumulate each output for determination of rmse
kk=0;
for ANNRT=1:1
foutput=[]; %%%to sotre(save) all value of output during the iteration
%%%%%% OL means after one whole loop run than cumulation values stored
%%%%%%%%%%%%first letter loop or cumulative, second letter type of
%%%%%%%%%%%%function and third letter name of function
%%%%R meaning regression
%%%%Overall%%%%
OL_O_RMSE=[];
OL_O_MAE=[];
OL_O_R=[];
%%%Testing%%
OL_Ts_RMSE=[];
OL_Ts_MAE=[];
OL_Ts_R=[];
OL_Ts_target=[];
OL_Ts_output=[];
%%%%Training%%%%
OL_Tr_RMSE=[];
OL_Tr_MAE=[];
OL_Tr_R=[];
OL_Tr_target=[];
OL_Tr_output=[];
%%%%%Validation%%%%
OL_V_RMSE=[];
OL_V_MAE=[];
OL_V_R=[];
OL_V_target=[];
OL_V_output=[];
[Input_m,Input_n] = size(input);
ppsc=2* round((Input_m)^.5) +1;
fpsc=2*Input_m + 1;
for neuron =ppsc:fpsc%%%ppsc:fpsc
kk=kk+1;
%%
%%the value inbetween two this '%%' lines is just for checking and
%%cross validation purpose of programme (written code), k denote that
%%parameter belong to counter cheking operation
hidden_neuron(kk)=neuron; %%%number of neurons in hidden layer%%this is only for checking and validation
TF_Used(kk,:)=[TF]; %%tansfer function used.
%%
%%%%% use following training functions in loop
%%trainlm
%%trainbfg
%%trainrp
% net = feedforwardnet([neuron]);
net = feedforwardnet([neuron]);
%%with different transfer functions
if TF==1
net.layers{1}.transferFcn='logsig';
net.layers{2}.transferFcn='purelin';
end
if TF==2
net.layers{1}.transferFcn='tansig';
net.layers{2}.transferFcn='purelin';
end
if TF==3
net.layers{1}.transferFcn='radbas';
net.layers{2}.transferFcn='purelin';
end
if TF==4
net.layers{1}.transferFcn='logsig';
net.layers{2}.transferFcn='logsig';
end
if TF==5
net.layers{1}.transferFcn='logsig';
net.layers{2}.transferFcn='tansig';
end
if TF==6
net.layers{1}.transferFcn='tansig';
net.layers{2}.transferFcn='logsig';
end
if TF==7
net.layers{1}.transferFcn='tansig';
net.layers{2}.transferFcn='tansig';
end
% net.trainParam.showWindow = 0;
% %