From 3b955481cb5aa17a36d23eb412e5f482d918f9d0 Mon Sep 17 00:00:00 2001 From: Michel Juillard Date: Wed, 12 Oct 2011 21:46:50 +0200 Subject: [PATCH] factoring out steady-state computations; steady_state_model now generates _steadystate2.m returning parameters as well in case they have been modified by the user. Added several test cases. --- ExprNode.cc | 2 +- SteadyStateModel.cc | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/ExprNode.cc b/ExprNode.cc index c3aa019b..6b94fd7b 100644 --- a/ExprNode.cc +++ b/ExprNode.cc @@ -584,7 +584,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type, switch (type) { case eParameter: - if (output_type == oMatlabOutsideModel || output_type == oSteadyStateFile) + if (output_type == oMatlabOutsideModel) output << "M_.params" << "(" << tsid + 1 << ")"; else output << "params" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + ARRAY_SUBSCRIPT_OFFSET(output_type) << RIGHT_ARRAY_SUBSCRIPT(output_type); diff --git a/SteadyStateModel.cc b/SteadyStateModel.cc index d665428b..c4b2cfd2 100644 --- a/SteadyStateModel.cc +++ b/SteadyStateModel.cc @@ -103,7 +103,7 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_polic if (recursive_order.size() == 0) return; - string filename = basename + "_steadystate.m"; + string filename = basename + "_steadystate2.m"; ofstream output; output.open(filename.c_str(), ios::out | ios::binary); @@ -113,16 +113,11 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_polic exit(EXIT_FAILURE); } - output << "function [ys_, check_] = " << basename << "_steadystate("; - if (ramsey_policy) - output << "ys_"; - else - output << "ys_orig_"; - output << ", exo_)" << endl - << "% Steady state generated by Dynare preprocessor" << endl; - if (!ramsey_policy) - output << " ys_=zeros(" << symbol_table.endo_nbr() << ",1);" << endl; - output << " global M_" << endl; + output << "function [ys_, params, info] = " << basename << "_steadystate2(" + << "ys_, exo_, params)" << endl + << "% Steady state generated by Dynare preprocessor" << endl + << " info = 0;" << endl + << " ys_ = zeros(" << symbol_table.endo_nbr() << ",1);" << endl; for (size_t i = 0; i < recursive_order.size(); i++) {