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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
dynare
Commits
aa66949a
Commit
aa66949a
authored
6 years ago
by
Sumudu Kankanamge
Browse files
Options
Downloads
Patches
Plain Diff
read JSON for stochastic simulations from GUI
parent
2dc988b6
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1650
read JSON for stochastic simulations from GUI
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/+gui/+stochastic-simulation/read.m
+79
-0
79 additions, 0 deletions
matlab/+gui/+stochastic-simulation/read.m
with
79 additions
and
0 deletions
matlab/+gui/+stochastic-simulation/read.m
0 → 100644
+
79
−
0
View file @
aa66949a
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
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment