Commit 5bbd779b authored by sebastien's avatar sebastien
Browse files

v4 parser:

* added planner_objective statement, which triggers the creation of filename_objective_static.m
* added computing pass
* added the possibility of writing the hessian in static output file



git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1126 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 0f9ed33f
......@@ -18,7 +18,7 @@ SteadyStatement::SteadyStatement(const OptionsList &options_list_arg) :
}
void
SteadyStatement::writeOutput(ostream &output) const
SteadyStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
output << "steady;\n";
......@@ -30,7 +30,7 @@ CheckStatement::CheckStatement(const OptionsList &options_list_arg) :
}
void
CheckStatement::writeOutput(ostream &output) const
CheckStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
output << "check;\n";
......@@ -54,7 +54,7 @@ SimulStatement::checkPass(ModFileStructure &mod_file_struct)
}
void
SimulStatement::writeOutput(ostream &output) const
SimulStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
output << "simul(oo_.dr);\n";
......@@ -74,7 +74,7 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct)
}
void
StochSimulStatement::writeOutput(ostream &output) const
StochSimulStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
tmp_symbol_table.writeOutput("var_list_", output);
......@@ -95,7 +95,7 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct)
}
void
EstimationStatement::writeOutput(ostream &output) const
EstimationStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
tmp_symbol_table.writeOutput("var_list_", output);
......@@ -110,7 +110,7 @@ PriorAnalysisStatement::PriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_
}
void
PriorAnalysisStatement::writeOutput(ostream &output) const
PriorAnalysisStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
tmp_symbol_table.writeOutput("var_list_", output);
......@@ -125,7 +125,7 @@ PosteriorAnalysisStatement::PosteriorAnalysisStatement(const TmpSymbolTable &tmp
}
void
PosteriorAnalysisStatement::writeOutput(ostream &output) const
PosteriorAnalysisStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
tmp_symbol_table.writeOutput("var_list_", output);
......@@ -140,7 +140,7 @@ RplotStatement::RplotStatement(const TmpSymbolTable &tmp_symbol_table_arg,
}
void
RplotStatement::writeOutput(ostream &output) const
RplotStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
tmp_symbol_table.writeOutput("var_list_", output);
......@@ -153,7 +153,7 @@ UnitRootVarsStatement::UnitRootVarsStatement(const TmpSymbolTable &tmp_symbol_ta
}
void
UnitRootVarsStatement::writeOutput(ostream &output) const
UnitRootVarsStatement::writeOutput(ostream &output, const string &basename) const
{
tmp_symbol_table.writeOutput("options_.unit_root_vars", output);
}
......@@ -163,7 +163,7 @@ PeriodsStatement::PeriodsStatement(int periods_arg) : periods(periods_arg)
}
void
PeriodsStatement::writeOutput(ostream &output) const
PeriodsStatement::writeOutput(ostream &output, const string &basename) const
{
output << "options_.periods = " << periods << ";" << endl;
output << "options_.simul = 1;" << endl;
......@@ -178,7 +178,7 @@ DsampleStatement::DsampleStatement(int val1_arg, int val2_arg) : val1(val1_arg),
}
void
DsampleStatement::writeOutput(ostream &output) const
DsampleStatement::writeOutput(ostream &output, const string &basename) const
{
if (val2 < 0)
output << "options_.dsample = " << val1 << ";" << endl;
......@@ -192,7 +192,7 @@ VarobsStatement::VarobsStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
}
void
VarobsStatement::writeOutput(ostream &output) const
VarobsStatement::writeOutput(ostream &output, const string &basename) const
{
tmp_symbol_table.writeOutput("options_.varobs", output);
}
......@@ -205,7 +205,7 @@ EstimatedParamsStatement::EstimatedParamsStatement(const vector<EstimationParams
}
void
EstimatedParamsStatement::writeOutput(ostream &output) const
EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) const
{
output << "global estim_params_\n";
output << "var_list_ = [];\n";
......@@ -262,7 +262,7 @@ EstimatedParamsInitStatement::EstimatedParamsInitStatement(const vector<Estimati
}
void
EstimatedParamsInitStatement::writeOutput(ostream &output) const
EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basename) const
{
vector<EstimationParams>::const_iterator it;
......@@ -312,7 +312,7 @@ EstimatedParamsBoundsStatement::EstimatedParamsBoundsStatement(const vector<Esti
}
void
EstimatedParamsBoundsStatement::writeOutput(ostream &output) const
EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basename) const
{
vector<EstimationParams>::const_iterator it;
......@@ -367,7 +367,7 @@ ObservationTrendsStatement::ObservationTrendsStatement(const trend_elements_type
}
void
ObservationTrendsStatement::writeOutput(ostream &output) const
ObservationTrendsStatement::writeOutput(ostream &output, const string &basename) const
{
output << "options_.trend_coeff_ = {};" << endl;
......@@ -398,7 +398,7 @@ CalibVarStatement::CalibVarStatement(const calib_var_type &calib_var_arg,
}
void
CalibVarStatement::writeOutput(ostream &output) const
CalibVarStatement::writeOutput(ostream &output, const string &basename) const
{
output << interfaces::comment() << "\n" << interfaces::comment() << "CALIB_VAR \n"
......@@ -495,7 +495,7 @@ CalibStatement::CalibStatement(int covar_arg) : covar(covar_arg)
}
void
CalibStatement::writeOutput(ostream &output) const
CalibStatement::writeOutput(ostream &output, const string &basename) const
{
output << "M_.Sigma_e=calib(calib_var_index,calib_targets,calib_weights," << covar << ",Sigma_e_);\n";
}
......@@ -506,7 +506,7 @@ OsrParamsStatement::OsrParamsStatement(const TmpSymbolTable &tmp_symbol_table_ar
}
void
OsrParamsStatement::writeOutput(ostream &output) const
OsrParamsStatement::writeOutput(ostream &output, const string &basename) const
{
tmp_symbol_table.writeOutput("osr_params_", output);
}
......@@ -525,7 +525,7 @@ OsrStatement::checkPass(ModFileStructure &mod_file_struct)
}
void
OsrStatement::writeOutput(ostream &output) const
OsrStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
tmp_symbol_table.writeOutput("var_list_", output);
......@@ -538,7 +538,7 @@ OlrInstStatement::OlrInstStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
}
void
OlrInstStatement::writeOutput(ostream &output) const
OlrInstStatement::writeOutput(ostream &output, const string &basename) const
{
tmp_symbol_table.writeOutput("options_.olr_inst", output);
}
......@@ -558,7 +558,7 @@ OlrStatement::checkPass(ModFileStructure &mod_file_struct)
}
void
OlrStatement::writeOutput(ostream &output) const
OlrStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
tmp_symbol_table.writeOutput("var_list_", output);
......@@ -578,7 +578,7 @@ OptimWeightsStatement::OptimWeightsStatement(const var_weights_type &var_weights
}
void
OptimWeightsStatement::writeOutput(ostream &output) const
OptimWeightsStatement::writeOutput(ostream &output, const string &basename) const
{
output << interfaces::comment() << "OPTIM_WEIGHTS\n\n";
output << "optim_weights_ = sparse(M_.endo_nbr,M_.endo_nbr);\n";
......@@ -616,7 +616,7 @@ DynaSaveStatement::DynaSaveStatement(const TmpSymbolTable &tmp_symbol_table_arg,
}
void
DynaSaveStatement::writeOutput(ostream &output) const
DynaSaveStatement::writeOutput(ostream &output, const string &basename) const
{
tmp_symbol_table.writeOutput("var_list_", output);
output << "dynasave(" << filename;
......@@ -634,7 +634,7 @@ DynaTypeStatement::DynaTypeStatement(const TmpSymbolTable &tmp_symbol_table_arg,
}
void
DynaTypeStatement::writeOutput(ostream &output) const
DynaTypeStatement::writeOutput(ostream &output, const string &basename) const
{
tmp_symbol_table.writeOutput("var_list_", output);
output << "dynatype(" << filename;
......@@ -651,7 +651,7 @@ ModelComparisonStatement::ModelComparisonStatement(const filename_list_type &fil
}
void
ModelComparisonStatement::writeOutput(ostream &output) const
ModelComparisonStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
......@@ -666,3 +666,32 @@ ModelComparisonStatement::writeOutput(ostream &output) const
}
output << "model_comparison(ModelNames_,ModelPriors_);\n";
}
PlannerObjectiveStatement::PlannerObjectiveStatement(ModelTree *model_tree_arg) :
model_tree(model_tree_arg)
{
}
PlannerObjectiveStatement::~PlannerObjectiveStatement()
{
delete model_tree;
}
void
PlannerObjectiveStatement::checkPass(ModFileStructure &mod_file_struct)
{
model_tree->checkPass();
}
void
PlannerObjectiveStatement::computingPass()
{
model_tree->computeStaticHessian = true;
model_tree->computingPass();
}
void
PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename) const
{
model_tree->writeStaticFile(basename + "_objective");
}
......@@ -44,7 +44,7 @@ typedef pair<int, Type> ExpObj;
%token DATAFILE DIAGNOSTIC DIFFUSE_D DOLLAR DR_ALGO DROP DSAMPLE DYN2VEC DYNASAVE DYNATYPE
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT
%token PRIOR_ANALYSIS POSTERIOR_ANALYSIS
%token FILTERED_VARS FIRST_OBS
%token FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS
%token <string_val> FLOAT_NUMBER
%token FORECAST FUNCTIONS
%token GAMMA_PDF GRAPH
......@@ -59,7 +59,7 @@ typedef pair<int, Type> ExpObj;
%token NOBS NOCORR NODIAGNOSTIC NOFUNCTIONS NOGRAPH XLS_SHEET XLS_RANGE
%token NOMOMENTS NOPRINT NORMAL_PDF
%token OBSERVATION_TRENDS OLR OLR_INST OLR_BETA OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS
%token PARAMETERS PERIODS PREFILTER PRESAMPLE PRINT PRIOR_TRUNC FILTER_STEP_AHEAD
%token PARAMETERS PERIODS PLANNER_OBJECTIVE PREFILTER PRESAMPLE PRINT PRIOR_TRUNC
%token QZ_CRITERIUM
%token RELATIVE_IRF REPLIC RESOL RPLOT
%token SHOCKS SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER SOLVE_ALGO STDERR STEADY STOCH_SIMUL
......@@ -129,6 +129,7 @@ typedef pair<int, Type> ExpObj;
| olr
| olr_inst
| model_comparison
| planner_objective
;
......@@ -330,10 +331,10 @@ typedef pair<int, Type> ExpObj;
;
model
: MODEL ';' equation_list END
| MODEL '(' o_linear ')' ';'
: MODEL ';' { driver.begin_model(); } equation_list END
| MODEL '(' o_linear ')' ';' { driver.begin_model(); }
equation_list END
| MODEL '(' USE_DLL ')' ';' {driver.use_dll();}
| MODEL '(' USE_DLL ')' ';' { driver.begin_model(); driver.use_dll(); }
equation_list END
;
......@@ -1037,6 +1038,8 @@ typedef pair<int, Type> ExpObj;
| o_noprint
;
planner_objective : PLANNER_OBJECTIVE { driver.begin_planner_objective(); } hand_side { driver.end_planner_objective($3); } ';'
filename_list : filename {driver.add_mc_filename($1);}
| filename_list COMMA filename {driver.add_mc_filename($3);}
| filename '(' value ')' {driver.add_mc_filename($1, $3);}
......
......@@ -80,6 +80,7 @@ int sigma_e = 0;
<INITIAL>dsample {BEGIN DYNARE_STATEMENT; return token::DSAMPLE;}
<INITIAL>Sigma_e {BEGIN DYNARE_STATEMENT; sigma_e = 1; return token::SIGMA_E;}
<INITIAL>calib {BEGIN DYNARE_STATEMENT; return token::CALIB;}
<INITIAL>planner_objective {BEGIN DYNARE_STATEMENT; return token::PLANNER_OBJECTIVE;}
/* End of a Dynare statement */
<DYNARE_STATEMENT>; {
......
......@@ -56,6 +56,10 @@ ModFile::computingPass()
}
model_tree.computingPass();
for(vector<Statement *>::iterator it = statements.begin();
it != statements.end(); it++)
(*it)->computingPass();
}
void
......@@ -140,7 +144,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all)
// Print statements
for(vector<Statement *>::iterator it = statements.begin();
it != statements.end(); it++)
(*it)->writeOutput(mOutputFile);
(*it)->writeOutput(mOutputFile, basename);
mOutputFile << "save('" << basename << "_results', 'oo_');" << endl;
mOutputFile << "diary off" << endl;
......
......@@ -39,7 +39,8 @@ ModelTree::ModelTree(SymbolTable &symbol_table_arg,
num_constants(num_constants_arg),
computeJacobian(false),
computeJacobianExo(false),
computeHessian(false)
computeHessian(false),
computeStaticHessian(false)
{
}
......@@ -56,7 +57,7 @@ ModelTree::writeStaticMFile(const string &static_basename)
exit(-1);
}
// Writing comments and function definition command
mStaticModelFile << "function [residual, g1] = " << static_basename << "( y, x )\n";
mStaticModelFile << "function [residual, g1, g2] = " << static_basename << "( y, x )\n";
mStaticModelFile << interfaces::comment()+"\n"+interfaces::comment();
mStaticModelFile << "Status : Computes static model for Dynare\n" << interfaces::comment() << "\n";
mStaticModelFile << interfaces::comment();
......@@ -630,13 +631,10 @@ inline NodeID ModelTree::DeriveArgument(NodeID iArg, Type iType, int iVarID)
void
ModelTree::writeStaticModel(ostream &StaticOutput)
{
TreeIterator tree_it;
int lEquationNBR = 0;
ostringstream model_output; // Used for storing model equations
ostringstream model_tmp_output;// Used for storing tmp expressions for model equations
ostringstream jacobian_output; // Used for storing jacobian equations
// Used for storing tmp expressions for jacobian equations
ostringstream jacobian_tmp_output;
ostringstream hessian_output;
ostringstream lsymetric; // For symmetric elements in hessian
int d = current_order; // Minimum number of times a temparary expression apears in equations
// Reference count of token "0=0" is set to 0
......@@ -645,23 +643,24 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
ZeroEqZero->reference_count.end(),0);
// Writing model Equations
current_order = 1;
tree_it = BeginModel;
TreeIterator tree_it = BeginModel;
int lEquationNBR = 0;
for (; tree_it != mModelTree.end(); tree_it++)
{
if ((*tree_it)->op_code == token::EQUAL || (*tree_it)->op_code == token::ASSIGN )
{
if ((*tree_it)->id1->type1 == eLocalParameter)
{
model_output << getExpression((*tree_it)->id1, eStaticEquations, lEquationNBR);
model_output << getExpression((*tree_it)->id1, eStaticEquations);
model_output << " = ";
model_output << getExpression((*tree_it)->id2, eStaticEquations, lEquationNBR) << ";" << endl;
model_output << getExpression((*tree_it)->id2, eStaticEquations) << ";" << endl;
}
else if (lEquationNBR < eq_nbr)
{
model_output << "lhs =";
model_output << getExpression((*tree_it)->id1, eStaticEquations, lEquationNBR) << ";" << endl;
model_output << getExpression((*tree_it)->id1, eStaticEquations) << ";" << endl;
model_output << "rhs =";
model_output << getExpression((*tree_it)->id2, eStaticEquations, lEquationNBR) << ";" << endl;
model_output << getExpression((*tree_it)->id2, eStaticEquations) << ";" << endl;
model_output << "residual" << lpar << lEquationNBR+1 << rpar << "= lhs-rhs;" << endl;
lEquationNBR++;
}
......@@ -672,7 +671,7 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
{
if (optimize(*tree_it))
{
model_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eStaticEquations, lEquationNBR) << ";" << endl;
model_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eStaticEquations) << ";" << endl;
(*tree_it)->tmp_status = 1;
}
else
......@@ -682,7 +681,6 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
}
}
// Writing Jacobian for endogenous variables without lag
for(; tree_it != mModelTree.end(); tree_it++)
{
if ((*tree_it)->op_code != NoOpCode
......@@ -691,7 +689,7 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
{
if (optimize(*tree_it) == 1)
{
jacobian_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eStaticEquations, lEquationNBR) << ";" << endl;
jacobian_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eStaticEquations) << ";" << endl;
(*tree_it)->tmp_status = 1;
}
else
......@@ -701,7 +699,7 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
}
}
lEquationNBR = 0;
// Write Jacobian w.r. to endogenous only
for (unsigned int i = 0; i < mDerivativeIndex[0].size(); i++)
{
if (variable_table.getType(mDerivativeIndex[0][i].derivators) == eEndogenous)
......@@ -718,6 +716,43 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
}
}
// Write Hessian w.r. to endogenous only
if (computeStaticHessian)
{
for (unsigned int i = 0; i < mDerivativeIndex[1].size(); i++)
{
NodeID startHessian = mDerivativeIndex[1][i].token_id;
if (startHessian != ZeroEqZero)
{
string exp = getExpression(startHessian->id1, eStaticDerivatives);
int varID1 = mDerivativeIndex[1][i].derivators / variable_table.size();
int varID2 = mDerivativeIndex[1][i].derivators - varID1 * variable_table.size();
// Keep only derivatives w.r. to endogenous variables
if (variable_table.getType(varID1) != eEndogenous
|| variable_table.getType(varID2) != eEndogenous)
continue;
int id1 = variable_table.getSymbolID(varID1);
int id2 = variable_table.getSymbolID(varID2);
int col_nb = id1*symbol_table.endo_nbr+id2+1;
int col_nb_sym = id2*symbol_table.endo_nbr+id1+1;
hessian_output << " g2" << lpar << mDerivativeIndex[1][i].equation_id+1 << ", " <<
col_nb << rpar << " = " << exp << ";\n";
// Treating symetric elements
if (varID1 != varID2)
lsymetric << " g2" << lpar << mDerivativeIndex[1][i].equation_id+1 << ", " <<
col_nb_sym << rpar << " = " <<
"g2" << lpar << mDerivativeIndex[1][i].equation_id+1 << ", " <<
col_nb << rpar << ";\n";
}
}
}
// Writing ouputs
if (offset == 1)
{
......@@ -744,6 +779,20 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
StaticOutput << " g1 = real(g1)+2*imag(g1);\n";
StaticOutput << " end\n";
StaticOutput << "end\n";
if (computeStaticHessian)
{
StaticOutput << "if nargout >= 3,\n";
// Writing initialization instruction for matrix g2
int ncols = symbol_table.endo_nbr * symbol_table.endo_nbr;
StaticOutput << " g2 = " <<
"sparse([],[],[]," << eq_nbr << ", " << ncols << ", " <<
5*ncols << ");\n";
StaticOutput << "\n\t"+interfaces::comment()+"\n\t"+interfaces::comment();
StaticOutput << "Hessian matrix\n\t";
StaticOutput << interfaces::comment() + "\n\n";
StaticOutput << hessian_output.str() << lsymetric.str();
StaticOutput << "end;\n";
}
}
else
{
......@@ -770,17 +819,10 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
void
ModelTree::writeDynamicModel(ostream &DynamicOutput)
{
TreeIterator tree_it;
int lEquationNBR = 0;
ostringstream lsymetric; // Used when writing symetric elements
ostringstream lsymetric; // Used when writing symetric elements in Hessian
ostringstream model_output; // Used for storing model equations
ostringstream model_tmp_output;// Used for storing tmp expressions for model equations
ostringstream jacobian_output; // Used for storing jacobian equations
// Used for storing tmp expressions for jacobian equations
ostringstream jacobian_tmp_output;
ostringstream hessian_output; // Used for storing Hessian equations
// Used for storing tmp expressions for Hessian equations
ostringstream hessian_tmp_output;
int d = current_order;
......@@ -789,32 +831,29 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
fill(ZeroEqZero->reference_count.begin(),
ZeroEqZero->reference_count.end(),0);
// Clearing output string
model_output.str("");
jacobian_output.str("");
// Getting equations from model tree
// Starting from the end of equation
// Searching for the next '=' operator,
current_order = 1;
lEquationNBR = 0;
int lEquationNBR = 0;
cout << "\tequations .. ";
tree_it = BeginModel;
TreeIterator tree_it = BeginModel;
for (; tree_it != mModelTree.end(); tree_it++)
{
if ((*tree_it)->op_code == token::EQUAL || (*tree_it)->op_code == token::ASSIGN)
{
if ((*tree_it)->id1->type1 == eLocalParameter)
{
model_output << getExpression((*tree_it)->id1, eStaticEquations, lEquationNBR);
model_output << getExpression((*tree_it)->id1, eStaticEquations);
model_output << " = ";
model_output << getExpression((*tree_it)->id2, eStaticEquations, lEquationNBR) << ";" << endl;
model_output << getExpression((*tree_it)->id2, eStaticEquations) << ";" << endl;
}
else if (lEquationNBR < eq_nbr)
{
model_output << "lhs =";
model_output << getExpression(((*tree_it)->id1), eDynamicEquations, lEquationNBR) << ";" << endl;
model_output << getExpression(((*tree_it)->id1), eDynamicEquations) << ";" << endl;
model_output << "rhs =";
model_output << getExpression(((*tree_it)->id2), eDynamicEquations, lEquationNBR) << ";" << endl;
model_output << getExpression(((*tree_it)->id2), eDynamicEquations) << ";" << endl;
model_output << "residual" << lpar << lEquationNBR+1 << rpar << "= lhs-rhs;" << endl;
lEquationNBR++;
}
......@@ -825,7 +864,7 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
{
if (optimize(*tree_it))
{
model_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eDynamicEquations, lEquationNBR) << ";" << endl;
model_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eDynamicEquations) << ";" << endl;
(*tree_it)->tmp_status = 1;
}
else
......@@ -843,7 +882,7 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
{
if (optimize(*tree_it) == 1)
{
jacobian_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eDynamicEquations, lEquationNBR) << ";" << endl;
jacobian_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eDynamicEquations) << ";" << endl;
(*tree_it)->tmp_status = 1;
}
else
......@@ -865,7 +904,7 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
{
if (optimize(*tree_it) == 1)
{
jacobian_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eDynamicEquations, lEquationNBR) << ";" << endl;
jacobian_output << "T" << (*tree_it)->idx << "=" << getExpression(*tree_it, eDynamicEquations) << ";" << endl;
(*tree_it)->tmp_status = 1;
}
else
......@@ -875,7 +914,6 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
}
}
lEquationNBR = 0;
for (unsigned int i = 0; i < mDerivativeIndex[0].size(); i++)
{
if (computeJacobianExo || variable_table.getType(mDerivativeIndex[0][i].derivators) == eEndogenous)
......@@ -899,7 +937,6 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
// Getting Hessian from model tree
// Starting from the end of equation
// Searching for the next '=' operator,
lEquationNBR = 0;
cout << "\tHessian .. ";
for (unsigned int i = 0; i < mDerivativeIndex[1].size(); i++)
{
......@@ -995,8 +1032,8 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
current_order = d;
}
//------------------------------------------------------------------------------
inline string ModelTree::getExpression(NodeID StartID, EquationType iEquationType, int iEquationID)
string
ModelTree::getExpression(NodeID StartID, EquationType iEquationType)
{
// Stack of tokens
......@@ -1342,7 +1379,7 @@ ModelTree::computingPass()
rpar = ']';
}
if (computeHessian)
if (computeHessian || computeStaticHessian)
derive(2);
else
derive(1);
......
......@@ -11,7 +11,7 @@ InitParamStatement::InitParamStatement(const string &param_name_arg,
}