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
parent
4befcde035
commit
3b955481cb
|
@ -584,7 +584,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case eParameter:
|
case eParameter:
|
||||||
if (output_type == oMatlabOutsideModel || output_type == oSteadyStateFile)
|
if (output_type == oMatlabOutsideModel)
|
||||||
output << "M_.params" << "(" << tsid + 1 << ")";
|
output << "M_.params" << "(" << tsid + 1 << ")";
|
||||||
else
|
else
|
||||||
output << "params" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + ARRAY_SUBSCRIPT_OFFSET(output_type) << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
output << "params" << LEFT_ARRAY_SUBSCRIPT(output_type) << tsid + ARRAY_SUBSCRIPT_OFFSET(output_type) << RIGHT_ARRAY_SUBSCRIPT(output_type);
|
||||||
|
|
|
@ -103,7 +103,7 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_polic
|
||||||
if (recursive_order.size() == 0)
|
if (recursive_order.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string filename = basename + "_steadystate.m";
|
string filename = basename + "_steadystate2.m";
|
||||||
|
|
||||||
ofstream output;
|
ofstream output;
|
||||||
output.open(filename.c_str(), ios::out | ios::binary);
|
output.open(filename.c_str(), ios::out | ios::binary);
|
||||||
|
@ -113,16 +113,11 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_polic
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
output << "function [ys_, check_] = " << basename << "_steadystate(";
|
output << "function [ys_, params, info] = " << basename << "_steadystate2("
|
||||||
if (ramsey_policy)
|
<< "ys_, exo_, params)" << endl
|
||||||
output << "ys_";
|
<< "% Steady state generated by Dynare preprocessor" << endl
|
||||||
else
|
<< " info = 0;" << endl
|
||||||
output << "ys_orig_";
|
<< " ys_ = zeros(" << symbol_table.endo_nbr() << ",1);" << endl;
|
||||||
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;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < recursive_order.size(); i++)
|
for (size_t i = 0; i < recursive_order.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue