fix writing of aux vars, predetermined vars, and observed vars

issue#70
Houtan Bastani 2015-07-29 11:51:27 +02:00
parent 601a52a093
commit ace7278623
1 changed files with 47 additions and 37 deletions

View File

@ -771,9 +771,12 @@ SymbolTable::writeJuliaOutput(ostream &output) const throw (NotYetFrozenExceptio
output << "model.orig_endo_nbr = " << orig_endo_nbr() << endl; output << "model.orig_endo_nbr = " << orig_endo_nbr() << endl;
if (aux_vars.size() > 0) if (aux_vars.size() > 0)
{
output << "# Auxiliary Variables" << endl
<< "model.aux_vars = [" << endl;
for (int i = 0; i < (int) aux_vars.size(); i++) for (int i = 0; i < (int) aux_vars.size(); i++)
{ {
output << "push!(model.aux_vars, " output << " DynareModel.AuxVars("
<< getTypeSpecificID(aux_vars[i].get_symb_id()) + 1 << ", " << getTypeSpecificID(aux_vars[i].get_symb_id()) + 1 << ", "
<< aux_vars[i].get_type() << ", "; << aux_vars[i].get_type() << ", ";
switch (aux_vars[i].get_type()) switch (aux_vars[i].get_type())
@ -784,10 +787,11 @@ SymbolTable::writeJuliaOutput(ostream &output) const throw (NotYetFrozenExceptio
case avEndoLag: case avEndoLag:
case avExoLag: case avExoLag:
output << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) + 1 << ", " output << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) + 1 << ", "
<< aux_vars[i].get_orig_lead_lag() << ", "; << aux_vars[i].get_orig_lead_lag() << ", NaN, NaN";
break; break;
case avMultiplier: case avMultiplier:
output << "NaN, NaN, " << aux_vars[i].get_equation_number_for_multiplier() + 1 << ", " << endl; output << "NaN, NaN, " << aux_vars[i].get_equation_number_for_multiplier() + 1
<< ", NaN";
break; break;
case avDiffForward: case avDiffForward:
output << getTypeSpecificID(aux_vars[i].get_orig_symb_id())+1 << ", NaN, "; output << getTypeSpecificID(aux_vars[i].get_orig_symb_id())+1 << ", NaN, ";
@ -797,27 +801,33 @@ SymbolTable::writeJuliaOutput(ostream &output) const throw (NotYetFrozenExceptio
<< (aux_vars[i].get_information_set() < 0 ? "" : "+") << (aux_vars[i].get_information_set() < 0 ? "" : "+")
<< aux_vars[i].get_information_set() << "}("; << aux_vars[i].get_information_set() << "}(";
aux_vars[i].get_expectation_expr_node()->writeOutput(output, oLatexDynamicModel); aux_vars[i].get_expectation_expr_node()->writeOutput(output, oLatexDynamicModel);
output << ")\"" << endl; output << ")\"";
break; break;
} }
output << ")" << endl;
}
output << "]" << endl;
} }
if (predeterminedNbr() > 0) if (predeterminedNbr() > 0)
{ {
output << "model.pred_vars = [ "; output << "# Predetermined Variables" << endl
<< "model.pred_vars = [ " << endl;
for (set<int>::const_iterator it = predetermined_variables.begin(); for (set<int>::const_iterator it = predetermined_variables.begin();
it != predetermined_variables.end(); it++) it != predetermined_variables.end(); it++)
output << getTypeSpecificID(*it)+1 << "; "; output << " DynareModel.PredVars("
output << "];" << endl; << getTypeSpecificID(*it)+1 << ")" << endl;
output << " ]" << endl;
} }
if (observedVariablesNbr() > 0) if (observedVariablesNbr() > 0)
{ {
output << "options_.obs_vars = [ "; output << "# Observed Variables" << endl
<< "options.obs_vars = [" << endl;
for (vector<int>::const_iterator it = varobs.begin(); for (vector<int>::const_iterator it = varobs.begin();
it != varobs.end(); it++) it != varobs.end(); it++)
output << getTypeSpecificID(*it)+1 << "; "; output << " DynareModel.ObsVars("
output << " ];" << endl; << getTypeSpecificID(*it)+1 << ")" << endl;
output << " ]" << endl;
} }
} }