Skip to content
Snippets Groups Projects
Verified Commit b9399974 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

simul: add possibility to use smoother/steady state vals as initial values

parent 73ec2b6e
Branches
Tags
No related merge requests found
...@@ -39,43 +39,53 @@ gui_size = gui_tools.get_gui_elements_size(tabId); ...@@ -39,43 +39,53 @@ gui_size = gui_tools.get_gui_elements_size(tabId);
% --- PANELS ------------------------------------- % --- PANELS -------------------------------------
handles.uipanelShocks = uipanel( ... handles.uipanelShocks = uipanel( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'uipanelShocks','BackgroundColor', special_color,... 'Tag', 'uipanelShocks', ...
'Units', 'normalized', 'Position', [0.01 0.18 0.6 0.73],... 'BackgroundColor', special_color, ...
'Units', 'normalized', ...
'Position', [0.01 0.18 0.6 0.73], ...
'Title', '', ... 'Title', '', ...
'BorderType', 'none'); 'BorderType', 'none');
uipanelShocks_CreateFcn; uipanelShocks_CreateFcn;
handles.uipanelVars = uipanel( ... handles.uipanelVars = uipanel( ...
'Parent', tabId, 'Tag', 'uipanelVars', ... 'Parent', tabId, ...
'UserData', zeros(1,0), 'BackgroundColor', special_color,... 'Tag', 'uipanelVars', ...
'Units', 'normalized', 'Position', [0.62 0.18 0.37 0.73], ... 'UserData', zeros(1,0), ...
'Title', '', 'BorderType', 'none'); 'BackgroundColor', special_color, ...
'Units', 'normalized', ...
'Position', [0.62 0.18 0.37 0.70], ...
'Title', '', ...
'BorderType', 'none');
handles = gui_tabs.create_endo_vars(handles, 'perfect_foresight'); handles = gui_tabs.create_endo_vars(handles, 'perfect_foresight');
handles.uipanelComm = uipanel( ... handles.uipanelComm = uipanel( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'uipanelCommOptions', ... 'Tag', 'uipanelCommOptions', ...
'UserData', zeros(1,0), 'BackgroundColor', bg_color, ... 'UserData', zeros(1,0), ...
'Units', 'normalized', 'Position', [0.01 0.09 0.98 0.09], ... 'BackgroundColor', bg_color, ...
'Units', 'normalized', ...
'Position', [0.01 0.09 0.98 0.09], ...
'Title', 'Current command options:'); 'Title', 'Current command options:');
% --- STATIC TEXT ------------------------------------- % --- STATIC TEXT -------------------------------------
handles.text7 = uicontrol( ... uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'text7', ... 'Style', 'text', ...
'Style', 'text', 'BackgroundColor', bg_color,... 'BackgroundColor', bg_color, ...
'Units','normalized','Position',[0.62 0.92 0.48 0.05],... 'Units', 'normalized', ...
'Position', [0.62 0.92 0.48 0.05], ...
'FontWeight', 'bold', ... 'FontWeight', 'bold', ...
'String', 'Select variables for which to plot simulated trajectory:', ... 'String', 'Select variables for which to plot simulated trajectory:', ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
handles.text8 = uicontrol( ... uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'text8', ... 'Style', 'text', ...
'Style', 'text', 'BackgroundColor', bg_color,... 'BackgroundColor', bg_color, ...
'Units','normalized','Position',[0.01 0.92 0.48 0.05],... 'Units', 'normalized', ...
'Position', [0.01 0.92 0.48 0.05], ...
'FontWeight', 'bold', ... 'FontWeight', 'bold', ...
'String', 'Define shocks on exogenous variables:', ... 'String', 'Define shocks on exogenous variables:', ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
...@@ -95,6 +105,43 @@ handles.simul = uicontrol( ... ...@@ -95,6 +105,43 @@ handles.simul = uicontrol( ...
'TooltipString', comm_str, ... 'TooltipString', comm_str, ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
% --- Check Boxes -------------------------------------
uicontrol( ...
'Parent', tabId, ...
'Style', 'text', ...
'BackgroundColor', bg_color, ...
'Units', 'normalized', ...
'Position', [0.62 0.88 0.48 0.05], ...
'FontWeight', 'bold', ...
'String', 'Use initial values from...', ...
'HorizontalAlignment', 'left');
handles.steadystate = uicontrol( ...
'Parent', tabId, ...
'Style', 'checkbox', ...
'String', 'steady state', ...
'Units', 'normalized', ...
'Position', [0.72 0.89 0.48 0.05], ...
'Value', 0, ...
'Callback', @steady_state_init_val);
handles.smoother = uicontrol( ...
'Parent', tabId, ...
'Style', 'checkbox', ...
'String', 'smoother', ...
'Units', 'normalized', ...
'Position', [0.79 0.89 0.48 0.05], ...
'Value', 0, ...
'Callback', @smoother_init_val);
handles.zero = uicontrol( ...
'Parent', tabId, ...
'Style', 'checkbox', ...
'String', 'zero', ...
'Units', 'normalized', ...
'Position', [0.85 0.89 0.48 0.05], ...
'Value', 0, ...
'Callback', @zero_init_val);
% --- PUSHBUTTONS ------------------------------------- % --- PUSHBUTTONS -------------------------------------
handles.pushbuttonSimulation = uicontrol( ... handles.pushbuttonSimulation = uicontrol( ...
...@@ -502,4 +549,41 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -502,4 +549,41 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
% return as JSON string % return as JSON string
json = savejson('', json, 'ParseLogical', 1, 'FileName', '', 'ArrayIndent', 0); json = savejson('', json, 'ParseLogical', 1, 'FileName', '', 'ArrayIndent', 0);
end end
function steady_state_init_val(~, evt)
if ~evt.Source.Value
return
end
if ~isfield(oo_, 'steady_state')
gui_tools.show_warning('Must first calculate the steady state')
evt.Source.Value = 0;
return
end
handles.endoTable.Data(:,3) = num2cell(oo_.steady_state);
handles.zero.Value = 0;
handles.smoother.Value = 0;
end
function smoother_init_val(~, evt)
if ~evt.Source.Value
return
end
if ~isfield(oo_, 'SmoothedVariables')
gui_tools.show_warning('Must first run smoother')
evt.Source.Value = 0;
return
end
handles.endoTable.Data(:,3) = num2cell(oo_.SmoothedVariables);
handles.zero.Value = 0;
handles.steadystate.Value = 0;
end
function zero_init_val(~, evt)
if ~evt.Source.Value
return
end
handles.endoTable.Data(:,3) = num2cell(zeros(M_.orig_endo_nbr, 1));
handles.smoother.Value = 0;
handles.steadystate.Value = 0;
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment