factoring out steady-state computations; steady_state_model now

generates <fname>_steadystate2.m returning parameters as well in case
they have been modified by the user. Added several test cases.
issue#70
Michel Juillard 2011-10-12 21:46:50 +02:00
parent 4befcde035
commit 3b955481cb
2 changed files with 7 additions and 12 deletions

View File

@ -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);

View File

@ -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++)
{