Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
matlab-gui
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
matlab-gui
Commits
6d540dec
Verified
Commit
6d540dec
authored
5 years ago
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
update epilogue tab for changes in epilogue block
parent
6d0e4722
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/gui_epilogue.m
+42
-19
42 additions, 19 deletions
src/gui_epilogue.m
with
42 additions
and
19 deletions
src/gui_epilogue.m
+
42
−
19
View file @
6d540dec
...
@@ -11,7 +11,7 @@ function gui_epilogue(tabId)
...
@@ -11,7 +11,7 @@ function gui_epilogue(tabId)
% SPECIAL REQUIREMENTS
% SPECIAL REQUIREMENTS
% none
% none
% Copyright (C) 2019 Dynare Team
% Copyright (C) 2019
-2020
Dynare Team
%
%
% This file is part of Dynare.
% This file is part of Dynare.
%
%
...
@@ -28,7 +28,7 @@ function gui_epilogue(tabId)
...
@@ -28,7 +28,7 @@ function gui_epilogue(tabId)
% You should have received a copy of the GNU General Public License
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global
project_info
dynare_gui_
options_
model_settings
oo_
M_
global
M_
bg_color
=
char
(
getappdata
(
0
,
'bg_color'
));
bg_color
=
char
(
getappdata
(
0
,
'bg_color'
));
special_color
=
char
(
getappdata
(
0
,
'special_color'
));
special_color
=
char
(
getappdata
(
0
,
'special_color'
));
...
@@ -68,12 +68,12 @@ handles.equations = uicontrol( ...
...
@@ -68,12 +68,12 @@ handles.equations = uicontrol( ...
'Max'
,
3
,
...
'Max'
,
3
,
...
'Min'
,
1
);
'Min'
,
1
);
if
exist
([
'+'
M_
.
fname
filesep
'epilogue.m'
],
'file'
)
==
2
if
exist
([
'+'
M_
.
fname
filesep
'epilogue
_dynamic
.m'
],
'file'
)
==
2
% If the epilogue file already exists, parse it and set the edit box
% If the epilogue file already exists, parse it and set the edit box
% string equal to the equations in the file
% string equal to the equations in the file
eqs
=
regexp
(
fileread
([
'+'
M_
.
fname
filesep
'epilogue.m'
]),
'from.*'
,
'match'
,
'dotexceptnewline'
);
eqs
=
regexp
(
fileread
([
'+'
M_
.
fname
filesep
'epilogue
_dynamic
.m'
]),
'from.*'
,
'match'
,
'dotexceptnewline'
);
eqs
=
strrep
(
eqs
,
'from simul_begin_date to simul_end_date do ds
eries__
.'
,
''
);
eqs
=
strrep
(
eqs
,
'from simul_begin_date to simul_end_date do ds.'
,
''
);
eqs
=
strrep
(
eqs
,
'ds
eries__
.'
,
''
);
eqs
=
strrep
(
eqs
,
'ds.'
,
''
);
eqs
=
regexprep
(
eqs
,
'\s'
,
''
);
eqs
=
regexprep
(
eqs
,
'\s'
,
''
);
eqs
=
regexprep
(
eqs
,
[
'\<('
strjoin
(
M_
.
endo_names
,
'|'
)
')\(t\)'
],
'$1'
);
eqs
=
regexprep
(
eqs
,
[
'\<('
strjoin
(
M_
.
endo_names
,
'|'
)
')\(t\)'
],
'$1'
);
eqs
=
regexprep
(
eqs
,
'\(t\)='
,
'='
);
eqs
=
regexprep
(
eqs
,
'\(t\)='
,
'='
);
...
@@ -116,25 +116,48 @@ handles.pushbuttonEpilogue = uicontrol( ...
...
@@ -116,25 +116,48 @@ handles.pushbuttonEpilogue = uicontrol( ...
max_lag
(
i
)
=
abs
(
min
(
cellfun
(
@
str2num
,
max_lag_eqs
{
i
})));
max_lag
(
i
)
=
abs
(
min
(
cellfun
(
@
str2num
,
max_lag_eqs
{
i
})));
end
end
end
end
equations
=
regexprep
(
equations
,
'(\w*)='
,
'ds
eries__
.$1(t)='
);
equations
=
regexprep
(
equations
,
'(\w*)='
,
'ds.$1(t)='
);
equations
=
regexprep
(
equations
,
[
'\<('
strjoin
([
M_
.
endo_names
;
M_
.
exo_names
],
'|'
)
')(?!\()\>'
],
'ds
eries__
.$1(t)'
);
equations
=
regexprep
(
equations
,
[
'\<('
strjoin
([
M_
.
endo_names
;
M_
.
exo_names
],
'|'
)
')(?!\()\>'
],
'ds.$1(t)'
);
equations
=
regexprep
(
equations
,
[
'\<('
strjoin
([
M_
.
endo_names
;
M_
.
exo_names
],
'|'
)
')\>\(\-'
],
'ds
eries__
.$1(t-'
);
equations
=
regexprep
(
equations
,
[
'\<('
strjoin
([
M_
.
endo_names
;
M_
.
exo_names
],
'|'
)
')\>\(\-'
],
'ds.$1(t-'
);
equations
=
regexprep
(
equations
,
[
'\<('
strjoin
(
M_
.
param_names
,
'|'
)
')\>'
],
'${[
''
params(
''
num2str(find(not(cellfun(
''
isempty
''
,strfind(M_.param_names,$1)))))
''
)
''
]}'
);
equations
=
regexprep
(
equations
,
[
'\<('
strjoin
(
M_
.
param_names
,
'|'
)
')\>'
],
'${[
''
params(
''
num2str(find(not(cellfun(
''
isempty
''
,strfind(M_.param_names,$1)))))
''
)
''
]}'
);
fidw
=
fopen
([
'+'
M_
.
fname
filesep
'epilogue.m'
],
'w'
);
fidw
=
fopen
([
'+'
M_
.
fname
filesep
'epilogue
_dynamic
.m'
],
'w'
);
if
fidw
<
0
if
fidw
<
0
gui_tools
.
show_warning
([
'Couldn
''
t open +'
M_
.
fname
filesep
'epilogue.m for writing'
]);
gui_tools
.
show_warning
([
'Couldn
''
t open +'
M_
.
fname
filesep
'epilogue
_dynamic
.m for writing'
]);
return
return
end
end
fprintf
(
fidw
,
'function ds
eries__
= epilogue(params, ds
eries__
)\n'
);
fprintf
(
fidw
,
'function ds = epilogue
_dynamic
(params, ds)\n'
);
fprintf
(
fidw
,
'%s\n'
,
'% function ds
eries__
= epilogue(params, ds
eries__
)'
);
fprintf
(
fidw
,
'%s\n'
,
'% function ds = epilogue
_dynamic
(params, ds)'
);
fprintf
(
fidw
,
'%s\n'
,
'% Epilogue file generated by Dynare GUI'
);
fprintf
(
fidw
,
'%s\n
\n
'
,
'% Epilogue file generated by Dynare GUI'
);
fprintf
(
fidw
,
'simul_end_date = lastdate(ds
eries__
);\n\n'
);
fprintf
(
fidw
,
'simul_end_date = lastdate(ds);\n\n'
);
for
i
=
1
:
length
(
equations
)
for
i
=
1
:
length
(
equations
)
fprintf
(
fidw
,
'simul_begin_date = firstobservedperiod(dseries__{
''
%s
''
}) + %d + 1;\n'
,
strjoin
(
rhs
{
i
},
'
''
,
''
'
),
max_lag
(
i
));
fprintf
(
fidw
,
'if ~ds.exist(
''
%s
''
)\n'
,
lhs
{
i
});
fprintf
(
fidw
,
'if ~dseries__.exist(
''
%s
''
)\n'
,
lhs
{
i
});
fprintf
(
fidw
,
' ds = [ds dseries(NaN(ds.nobs,1), ds.firstdate,
''
%s
''
)];\n'
,
lhs
{
i
});
fprintf
(
fidw
,
' dseries__ = [dseries__ dseries(NaN(dseries__.nobs,1), dseries__.firstdate,
''
%s
''
)];\n'
,
lhs
{
i
});
fprintf
(
fidw
,
'end\n'
);
fprintf
(
fidw
,
'end\n'
);
fprintf
(
fidw
,
'try\n'
);
fprintf
(
fidw
,
' simul_begin_date = firstobservedperiod(ds{
''
%s
''
}) + %d;\n'
,
strjoin
(
rhs
{
i
},
'
''
,
''
'
),
max_lag
(
i
));
fprintf
(
fidw
,
' from simul_begin_date to simul_end_date do %s;\n\n'
,
equations
{
i
});
fprintf
(
fidw
,
' from simul_begin_date to simul_end_date do %s;\n\n'
,
equations
{
i
});
fprintf
(
fidw
,
'catch\n'
);
fprintf
(
fidw
,
'end\n'
);
end
fprintf
(
fidw
,
'end\n'
);
fclose
(
fidw
);
fidw
=
fopen
([
'+'
M_
.
fname
filesep
'epilogue_static.m'
],
'w'
);
if
fidw
<
0
gui_tools
.
show_warning
([
'Couldn
''
t open +'
M_
.
fname
filesep
'epilogue_static.m for writing'
]);
return
end
fprintf
(
fidw
,
'function ds = epilogue_static(params, ds)\n'
);
fprintf
(
fidw
,
'%s\n'
,
'% function ds = epilogue_static(params, ds)'
);
fprintf
(
fidw
,
'%s\n\n'
,
'% Epilogue file generated by Dynare GUI'
);
equations
=
regexprep
(
equations
,
'.*='
,
''
);
equations
=
regexprep
(
equations
,
'\(t((-\d)|(+d))?\)'
,
''
);
for
i
=
1
:
length
(
equations
)
fprintf
(
fidw
,
'epilogue_static_tmp_term = %s;\n'
,
equations
{
i
});
fprintf
(
fidw
,
'if isdseries(epilogue_static_tmp_term)\n'
);
fprintf
(
fidw
,
' ds.%s = epilogue_static_tmp_term;\n'
,
lhs
{
i
});
fprintf
(
fidw
,
'else\n'
);
fprintf
(
fidw
,
' ds.%s = dseries(ones(ds.nobs,1)*epilogue_static_tmp_term, ds.firstdate,
''
%s
''
);\n'
,
lhs
{
i
},
lhs
{
i
});
fprintf
(
fidw
,
'end\n'
);
end
end
fprintf
(
fidw
,
'end\n'
);
fprintf
(
fidw
,
'end\n'
);
fclose
(
fidw
);
fclose
(
fidw
);
...
...
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