Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
SysBiOThe
/
CRA-Matlab
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit d1cfd128
authored
2019-03-31 21:28:39 +0200
by
Chiara Antonini
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Upload new file
1 parent
894cb883
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
CRA_Updated_Version/CRA_Toolbox_GUI/start_simulation.m
CRA_Updated_Version/CRA_Toolbox_GUI/start_simulation.m
0 → 100644
View file @
d1cfd12
%Function executed when the button START SIMULATION in the main GUI is
%pushed. It takes in input the handles of the main GUI.
function
start_simulation
(
handles
,
hObject
)
%tic
%cell array where the measured variables for all independent realizations
%are saved
AllResults
=
cell
(
handles
.
Nr
,
length
(
handles
.
Model
.
Species
));
AllPerturbations
=
cell
(
handles
.
Nr
,
1
);
%retrieve parameters and observables of the model
handles
.
num_param
=
length
(
handles
.
Model
.
Parameters
);
handles
.
param_name
=
get
(
handles
.
Model
.
Parameters
,
'Name'
);
handles
.
nominal_p
=
cell2mat
(
get
(
handles
.
Model
.
Parameters
,
'value'
))
'
;
obs_name
=
get
(
handles
.
Model
.
Species
,
'Name'
);
handles
.
time_results
=
[
0
:
handles
.
step_size
:
handles
.
csObj
.
StopTime
]
'
;
set
(
handles
.
text14
,
'string'
,
''
);
h
=
waitbar
(
0
,
'Please wait...'
);
%for each independent realization k
for
k
=
1
:
handles
.
Nr
waitbar
(
k
/
handles
.
Nr
,
h
,[
'Realization number '
,
num2str
(
k
)]);
%Latin Hypercube generation for perturbing the parameter space
hypercube
=
LatinHypercube
(
handles
.
LBpi
,
handles
.
UBpi
,
handles
.
Nsample
);
handles
.
perturbation
=
hypercube
.
generate_sample
(
handles
.
num_param
);
perturbed_p
=
repmat
(
handles
.
nominal_p
,
length
(
handles
.
perturbation
),
1
)
.*
handles
.
perturbation
;
AllPerturbations
{
k
,
1
}
=
handles
.
perturbation
;
disp
(
strcat
(
'Generated a Latin Hypercube of size'
,{
' '
},
sprintf
(
'%.0f'
,
size
(
handles
.
perturbation
,
1
)),
'x'
,
sprintf
(
'%.0f'
,
size
(
handles
.
perturbation
,
2
))));
%creation of a SimFunction object for performing model simulations
modelsim
=
createSimFunction
(
handles
.
Model
,
handles
.
param_name
,
obs_name
,[],
'UseParallel'
,
true
);
[
tsim_all
,
psim_all
]
=
modelsim
(
perturbed_p
,[],[],
handles
.
time_results
);
%ArrayResults is a cell array for saving measured variables of each
%single realization. Then, these results are all saved in the cell
%array AllResults
ArrayResults
=
cell
(
handles
.
Nsample
,
length
(
handles
.
Model
.
Species
));
for
i
=
1
:
handles
.
Nsample
for
j
=
1
:
length
(
handles
.
Model
.
Species
)
ArrayResults
{
i
,
j
}
=
psim_all
{
i
,
1
}(:,
j
);
end
end
for
j
=
1
:
length
(
handles
.
Model
.
Species
)
AllResults
{
k
,
j
}
=
ArrayResults
(:,
j
);
end
disp
(
strcat
(
'Completed one realization. The array of results has size'
,{
' '
},
sprintf
(
'%.0f'
,
size
(
psim_all
,
1
)),
'x'
,
sprintf
(
'%.0f'
,
size
(
psim_all
,
2
))));
end
handles
.
AllResults
=
AllResults
;
handles
.
AllPerturbations
=
AllPerturbations
;
delete
(
gcp
)
%save(fullfile(handles.folder,'measuresPeng2016.mat'),'-v7.3');
close
(
h
)
%close the waitbar
%handles.elapsedtime=toc;
%set(handles.text14,'string',strcat('All done!Time employed for model simulation is',handles.elapsedtime));
%drawnow;
guidata
(
hObject
,
handles
);
end
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment