Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
dynare
Merge requests
!1650
read JSON for stochastic simulations from GUI
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
read JSON for stochastic simulations from GUI
SumuduK/dynare:master
into
master
Overview
0
Commits
1
Pipelines
1
Changes
1
Merged
read JSON for stochastic simulations from GUI
Sumudu Kankanamge
requested to merge
SumuduK/dynare:master
into
master
Apr 12, 2019
Overview
0
Commits
1
Pipelines
1
Changes
1
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
aa66949a
1 commit,
Apr 12, 2019
1 file
+
79
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
matlab/+gui/+stochastic-simulation/read.m
0 → 100644
+
79
−
0
View file @ aa66949a
Edit in single-file editor
Open in Web IDE
function
run
(
json
)
% function varargout = run(json)
% Read JSON and run perfect foresight solver. Potentially return output as
% JSON
%
% INPUTS
% json [string] JSON string representing options to run perfect
% foresight solver
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2019 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global
M_
options_
oo_
%loading JSON
jm
=
loadjson
(
json
,
'SimplifyCell'
,
1
);
runflag
=
1
;
data2json
=
struct
();
M_
.
exo_det_length
=
0
;
for
nshocks
=
1
:
length
(
jm
.
stochasticshocksdescription
)
covartype
=
jm
.
stochasticshocksdescription
{
nshocks
}
.
shockattributevalue
;
thisshock
=
(
jm
.
stochasticshocksdescription
{
nshocks
}
.
shockindex
)
+
1
;
assoshock
=
(
jm
.
stochasticshocksdescription
{
nshocks
}
.
assoshockindex
)
+
1
;
switch
covartype
case
1
M_
.
Sigma_e
(
thisshock
,
thisshock
)
=
(
jm
.
stochasticshocksdescription
{
nshocks
}
.
shockvalue
)
^
2
;
case
2
M_
.
Sigma_e
(
thisshock
,
thisshock
)
=
jm
.
stochasticshocksdescription
{
nshocks
}
.
shockvalue
;
case
3
M_
.
Sigma_e
(
thisshock
,
assoshock
)
=
jm
.
stochasticshocksdescription
{
nshocks
}
.
shockvalue
;
M_
.
Sigma_e
(
assoshock
,
thisshock
)
=
M_
.
Sigma_e
(
thisshock
,
assoshock
);
M_
.
sigma_e_is_diagonal
=
0
;
case
4
M_
.
Sigma_e
(
thisshock
,
assoshock
)
=
2
*
sqrt
(
M_
.
Sigma_e
(
thisshock
,
thisshock
)
*
M_
.
Sigma_e
(
assoshock
,
assoshock
));
M_
.
Sigma_e
(
assoshock
,
thisshock
)
=
M_
.
Sigma_e
(
thisshock
,
assoshock
);
M_
.
Correlation_matrix
(
thisshock
,
assoshock
)
=
jm
.
stochasticshocksdescription
{
nshocks
}
.
shockvalue
;
M_
.
Correlation_matrix
(
assoshock
,
thisshock
)
=
M_
.
Correlation_matrix
(
thisshock
,
assoshock
);
M_
.
sigma_e_is_diagonal
=
0
;
end
end
options_
.
irf
=
jm
.
irfperiods
;
options_
.
nograph
=
1
;
options_
.
order
=
jm
.
taylororder
;
% if jm.taylororder==3
% options_.k_order_solver = 3;
% end
var_list_
=
char
();
info
=
stoch_simul
(
var_list_
);
irfnames
=
fieldnames
(
oo_
.
irfs
);
for
jj
=
1
:
numel
(
fieldnames
(
oo_
.
irfs
))
data2json
.
irfs
.
(
strtrim
(
char
(
irfnames
(
jj
))))
=
oo_
.
irfs
.
(
irfnames
{
jj
});
end
savejson
(
''
,
data2json
,
'stochsimout.JSON'
);
return
;
Loading