preprocessor: only create *set_auxiliary_variables.m file if there will be something in it. Closes #1384
parent
bd81ebc55d
commit
718ff3d61c
|
@ -235,7 +235,9 @@ else
|
||||||
% which files have to be copied to run remotely
|
% which files have to be copied to run remotely
|
||||||
NamFileInput(1,:) = {'',[M_.fname '_static.m']};
|
NamFileInput(1,:) = {'',[M_.fname '_static.m']};
|
||||||
NamFileInput(2,:) = {'',[M_.fname '_dynamic.m']};
|
NamFileInput(2,:) = {'',[M_.fname '_dynamic.m']};
|
||||||
NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
|
if M_.set_auxiliary_variables
|
||||||
|
NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
|
||||||
|
end
|
||||||
if options_.steadystate_flag
|
if options_.steadystate_flag
|
||||||
if options_.steadystate_flag == 1
|
if options_.steadystate_flag == 1
|
||||||
NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']};
|
NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']};
|
||||||
|
|
|
@ -136,11 +136,15 @@ xx(1:M.orig_endo_nbr) = x(1:M.orig_endo_nbr); %set values of original endogenous
|
||||||
% setting steady state of auxiliary variables that depends on original endogenous variables
|
% setting steady state of auxiliary variables that depends on original endogenous variables
|
||||||
if any([M.aux_vars.type] ~= 6) %auxiliary variables other than multipliers
|
if any([M.aux_vars.type] ~= 6) %auxiliary variables other than multipliers
|
||||||
needs_set_auxiliary_variables = 1;
|
needs_set_auxiliary_variables = 1;
|
||||||
fh = str2func([M.fname '_set_auxiliary_variables']);
|
if M.set_auxiliary_variables
|
||||||
s_a_v_func = @(z) fh(z,...
|
fh = str2func([M.fname '_set_auxiliary_variables']);
|
||||||
[oo.exo_steady_state,...
|
s_a_v_func = @(z) fh(z,...
|
||||||
oo.exo_det_steady_state],...
|
[oo.exo_steady_state,...
|
||||||
params);
|
oo.exo_det_steady_state],...
|
||||||
|
params);
|
||||||
|
else
|
||||||
|
s_a_v_func = z;
|
||||||
|
end
|
||||||
xx = s_a_v_func(xx);
|
xx = s_a_v_func(xx);
|
||||||
else
|
else
|
||||||
needs_set_auxiliary_variables = 0;
|
needs_set_auxiliary_variables = 0;
|
||||||
|
|
|
@ -48,7 +48,9 @@ exo_ss = [oo.exo_steady_state; oo.exo_det_steady_state];
|
||||||
|
|
||||||
if length(M.aux_vars) > 0 && ~steadystate_flag
|
if length(M.aux_vars) > 0 && ~steadystate_flag
|
||||||
h_set_auxiliary_variables = str2func([M.fname '_set_auxiliary_variables']);
|
h_set_auxiliary_variables = str2func([M.fname '_set_auxiliary_variables']);
|
||||||
ys_init = h_set_auxiliary_variables(ys_init,exo_ss,M.params);
|
if M.set_auxiliary_variables
|
||||||
|
ys_init = h_set_auxiliary_variables(ys_init,exo_ss,M.params);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if options.ramsey_policy
|
if options.ramsey_policy
|
||||||
|
@ -288,7 +290,9 @@ if check
|
||||||
info(1)= 20;
|
info(1)= 20;
|
||||||
%make sure ys contains auxiliary variables in case of problem with dynare_solve
|
%make sure ys contains auxiliary variables in case of problem with dynare_solve
|
||||||
if length(M.aux_vars) > 0 && ~steadystate_flag
|
if length(M.aux_vars) > 0 && ~steadystate_flag
|
||||||
ys = h_set_auxiliary_variables(ys,exo_ss,M.params);
|
if M.set_auxiliary_variables
|
||||||
|
ys = h_set_auxiliary_variables(ys,exo_ss,M.params);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
resid = evaluate_static_model(ys,exo_ss,params,M,options);
|
resid = evaluate_static_model(ys,exo_ss,params,M,options);
|
||||||
info(2) = resid'*resid ;
|
info(2) = resid'*resid ;
|
||||||
|
|
|
@ -74,14 +74,18 @@ h_set_auxiliary_variables = str2func([M.fname '_set_auxiliary_variables']);
|
||||||
if isnan(updated_params_flag) || (updated_params_flag && any(isnan(params(~isnan(params))-params1(~isnan(params))))) %checks if new NaNs were added
|
if isnan(updated_params_flag) || (updated_params_flag && any(isnan(params(~isnan(params))-params1(~isnan(params))))) %checks if new NaNs were added
|
||||||
info(1) = 24;
|
info(1) = 24;
|
||||||
info(2) = NaN;
|
info(2) = NaN;
|
||||||
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
if M.set_auxiliary_variables
|
||||||
|
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if updated_params_flag && ~isreal(params1)
|
if updated_params_flag && ~isreal(params1)
|
||||||
info(1) = 23;
|
info(1) = 23;
|
||||||
info(2) = sum(imag(params).^2);
|
info(2) = sum(imag(params).^2);
|
||||||
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
if M.set_auxiliary_variables
|
||||||
|
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -94,16 +98,22 @@ if length(M.aux_vars) > 0 && ~options.ramsey_policy
|
||||||
if debug
|
if debug
|
||||||
ys0 = ys;
|
ys0 = ys;
|
||||||
end
|
end
|
||||||
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
if M.set_auxiliary_variables
|
||||||
|
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
||||||
|
end
|
||||||
if debug
|
if debug
|
||||||
ys1 = ys;
|
ys1 = ys;
|
||||||
end
|
end
|
||||||
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
if M.set_auxiliary_variables
|
||||||
|
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
||||||
|
end
|
||||||
if debug
|
if debug
|
||||||
ys2 = ys;
|
ys2 = ys;
|
||||||
end
|
end
|
||||||
if debug
|
if debug
|
||||||
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
if M.set_auxiliary_variables
|
||||||
|
ys = h_set_auxiliary_variables(ys,exo_ss,params);
|
||||||
|
end
|
||||||
ys3 = ys;
|
ys3 = ys;
|
||||||
idx = find(abs(ys0-ys1)>0);
|
idx = find(abs(ys0-ys1)>0);
|
||||||
if ~isempty(idx)
|
if ~isempty(idx)
|
||||||
|
|
|
@ -127,7 +127,9 @@ else
|
||||||
% which files have to be copied to run remotely
|
% which files have to be copied to run remotely
|
||||||
NamFileInput(1,:) = {'',[ModelName '_static.m']};
|
NamFileInput(1,:) = {'',[ModelName '_static.m']};
|
||||||
NamFileInput(2,:) = {'',[ModelName '_dynamic.m']};
|
NamFileInput(2,:) = {'',[ModelName '_dynamic.m']};
|
||||||
NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
|
if M.set_auxiliary_variables
|
||||||
|
NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
|
||||||
|
end
|
||||||
if options_.steadystate_flag
|
if options_.steadystate_flag
|
||||||
if options_.steadystate_flag == 1
|
if options_.steadystate_flag == 1
|
||||||
NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']};
|
NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']};
|
||||||
|
|
|
@ -294,7 +294,9 @@ else
|
||||||
% which files have to be copied to run remotely
|
% which files have to be copied to run remotely
|
||||||
NamFileInput(1,:) = {'',[M_.fname '_static.m']};
|
NamFileInput(1,:) = {'',[M_.fname '_static.m']};
|
||||||
NamFileInput(2,:) = {'',[M_.fname '_dynamic.m']};
|
NamFileInput(2,:) = {'',[M_.fname '_dynamic.m']};
|
||||||
NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
|
if M.set_auxiliary_variables
|
||||||
|
NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
|
||||||
|
end
|
||||||
if options_.steadystate_flag
|
if options_.steadystate_flag
|
||||||
if options_.steadystate_flag == 1
|
if options_.steadystate_flag == 1
|
||||||
NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']};
|
NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']};
|
||||||
|
|
|
@ -813,7 +813,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
|
||||||
|
|
||||||
mOutputFile << "M_.orig_eq_nbr = " << mod_file_struct.orig_eq_nbr << ";" << endl
|
mOutputFile << "M_.orig_eq_nbr = " << mod_file_struct.orig_eq_nbr << ";" << endl
|
||||||
<< "M_.eq_nbr = " << dynamic_model.equation_number() << ";" << endl
|
<< "M_.eq_nbr = " << dynamic_model.equation_number() << ";" << endl
|
||||||
<< "M_.ramsey_eq_nbr = " << mod_file_struct.ramsey_eq_nbr << ";" << endl;
|
<< "M_.ramsey_eq_nbr = " << mod_file_struct.ramsey_eq_nbr << ";" << endl
|
||||||
|
<< "M_.set_auxiliary_variables = exist(['./' M_.fname '_set_auxiliary_variables.m'], 'file') == 2;" << endl;
|
||||||
|
|
||||||
if (dynamic_model.equation_number() > 0)
|
if (dynamic_model.equation_number() > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2130,6 +2130,11 @@ StaticModel::writeAuxVarInitval(ostream &output, ExprNodeOutputType output_type)
|
||||||
void
|
void
|
||||||
StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
|
StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
|
||||||
{
|
{
|
||||||
|
ostringstream output_func_body;
|
||||||
|
writeAuxVarRecursiveDefinitions(output_func_body, oMatlabStaticModel);
|
||||||
|
|
||||||
|
if (output_func_body.str().empty())
|
||||||
|
return;
|
||||||
|
|
||||||
string func_name = basename + "_set_auxiliary_variables";
|
string func_name = basename + "_set_auxiliary_variables";
|
||||||
string filename = julia ? func_name + ".jl" : func_name + ".m";
|
string filename = julia ? func_name + ".jl" : func_name + ".m";
|
||||||
|
@ -2148,10 +2153,8 @@ StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia
|
||||||
<< comment << " Status : Computes static model for Dynare" << endl
|
<< comment << " Status : Computes static model for Dynare" << endl
|
||||||
<< comment << endl
|
<< comment << endl
|
||||||
<< comment << " Warning : this file is generated automatically by Dynare" << endl
|
<< comment << " Warning : this file is generated automatically by Dynare" << endl
|
||||||
<< comment << " from model file (.mod)" << endl
|
<< comment << " from model file (.mod)" << endl << endl
|
||||||
<< endl;
|
<< output_func_body.str();
|
||||||
|
|
||||||
writeAuxVarRecursiveDefinitions(output, oMatlabStaticModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue