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-bf33cf982152time-shift
parent
0f9ed33f7d
commit
5bbd779bab
|
@ -18,7 +18,7 @@ SteadyStatement::SteadyStatement(const OptionsList &options_list_arg) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SteadyStatement::writeOutput(ostream &output) const
|
SteadyStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
output << "steady;\n";
|
output << "steady;\n";
|
||||||
|
@ -30,7 +30,7 @@ CheckStatement::CheckStatement(const OptionsList &options_list_arg) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CheckStatement::writeOutput(ostream &output) const
|
CheckStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
output << "check;\n";
|
output << "check;\n";
|
||||||
|
@ -54,7 +54,7 @@ SimulStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SimulStatement::writeOutput(ostream &output) const
|
SimulStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
output << "simul(oo_.dr);\n";
|
output << "simul(oo_.dr);\n";
|
||||||
|
@ -74,7 +74,7 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StochSimulStatement::writeOutput(ostream &output) const
|
StochSimulStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
tmp_symbol_table.writeOutput("var_list_", output);
|
tmp_symbol_table.writeOutput("var_list_", output);
|
||||||
|
@ -95,7 +95,7 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EstimationStatement::writeOutput(ostream &output) const
|
EstimationStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
tmp_symbol_table.writeOutput("var_list_", output);
|
tmp_symbol_table.writeOutput("var_list_", output);
|
||||||
|
@ -110,7 +110,7 @@ PriorAnalysisStatement::PriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PriorAnalysisStatement::writeOutput(ostream &output) const
|
PriorAnalysisStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
tmp_symbol_table.writeOutput("var_list_", output);
|
tmp_symbol_table.writeOutput("var_list_", output);
|
||||||
|
@ -125,7 +125,7 @@ PosteriorAnalysisStatement::PosteriorAnalysisStatement(const TmpSymbolTable &tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PosteriorAnalysisStatement::writeOutput(ostream &output) const
|
PosteriorAnalysisStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
tmp_symbol_table.writeOutput("var_list_", output);
|
tmp_symbol_table.writeOutput("var_list_", output);
|
||||||
|
@ -140,7 +140,7 @@ RplotStatement::RplotStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RplotStatement::writeOutput(ostream &output) const
|
RplotStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
tmp_symbol_table.writeOutput("var_list_", output);
|
tmp_symbol_table.writeOutput("var_list_", output);
|
||||||
|
@ -153,7 +153,7 @@ UnitRootVarsStatement::UnitRootVarsStatement(const TmpSymbolTable &tmp_symbol_ta
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UnitRootVarsStatement::writeOutput(ostream &output) const
|
UnitRootVarsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
tmp_symbol_table.writeOutput("options_.unit_root_vars", output);
|
tmp_symbol_table.writeOutput("options_.unit_root_vars", output);
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ PeriodsStatement::PeriodsStatement(int periods_arg) : periods(periods_arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PeriodsStatement::writeOutput(ostream &output) const
|
PeriodsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << "options_.periods = " << periods << ";" << endl;
|
output << "options_.periods = " << periods << ";" << endl;
|
||||||
output << "options_.simul = 1;" << endl;
|
output << "options_.simul = 1;" << endl;
|
||||||
|
@ -178,7 +178,7 @@ DsampleStatement::DsampleStatement(int val1_arg, int val2_arg) : val1(val1_arg),
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DsampleStatement::writeOutput(ostream &output) const
|
DsampleStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
if (val2 < 0)
|
if (val2 < 0)
|
||||||
output << "options_.dsample = " << val1 << ";" << endl;
|
output << "options_.dsample = " << val1 << ";" << endl;
|
||||||
|
@ -192,7 +192,7 @@ VarobsStatement::VarobsStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VarobsStatement::writeOutput(ostream &output) const
|
VarobsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
tmp_symbol_table.writeOutput("options_.varobs", output);
|
tmp_symbol_table.writeOutput("options_.varobs", output);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ EstimatedParamsStatement::EstimatedParamsStatement(const vector<EstimationParams
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EstimatedParamsStatement::writeOutput(ostream &output) const
|
EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << "global estim_params_\n";
|
output << "global estim_params_\n";
|
||||||
output << "var_list_ = [];\n";
|
output << "var_list_ = [];\n";
|
||||||
|
@ -262,7 +262,7 @@ EstimatedParamsInitStatement::EstimatedParamsInitStatement(const vector<Estimati
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EstimatedParamsInitStatement::writeOutput(ostream &output) const
|
EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
vector<EstimationParams>::const_iterator it;
|
vector<EstimationParams>::const_iterator it;
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ EstimatedParamsBoundsStatement::EstimatedParamsBoundsStatement(const vector<Esti
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EstimatedParamsBoundsStatement::writeOutput(ostream &output) const
|
EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
vector<EstimationParams>::const_iterator it;
|
vector<EstimationParams>::const_iterator it;
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ ObservationTrendsStatement::ObservationTrendsStatement(const trend_elements_type
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ObservationTrendsStatement::writeOutput(ostream &output) const
|
ObservationTrendsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << "options_.trend_coeff_ = {};" << endl;
|
output << "options_.trend_coeff_ = {};" << endl;
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ CalibVarStatement::CalibVarStatement(const calib_var_type &calib_var_arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CalibVarStatement::writeOutput(ostream &output) const
|
CalibVarStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
|
|
||||||
output << interfaces::comment() << "\n" << interfaces::comment() << "CALIB_VAR \n"
|
output << interfaces::comment() << "\n" << interfaces::comment() << "CALIB_VAR \n"
|
||||||
|
@ -495,7 +495,7 @@ CalibStatement::CalibStatement(int covar_arg) : covar(covar_arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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";
|
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
|
void
|
||||||
OsrParamsStatement::writeOutput(ostream &output) const
|
OsrParamsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
tmp_symbol_table.writeOutput("osr_params_", output);
|
tmp_symbol_table.writeOutput("osr_params_", output);
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ OsrStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OsrStatement::writeOutput(ostream &output) const
|
OsrStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
tmp_symbol_table.writeOutput("var_list_", output);
|
tmp_symbol_table.writeOutput("var_list_", output);
|
||||||
|
@ -538,7 +538,7 @@ OlrInstStatement::OlrInstStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OlrInstStatement::writeOutput(ostream &output) const
|
OlrInstStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
tmp_symbol_table.writeOutput("options_.olr_inst", output);
|
tmp_symbol_table.writeOutput("options_.olr_inst", output);
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ OlrStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OlrStatement::writeOutput(ostream &output) const
|
OlrStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
tmp_symbol_table.writeOutput("var_list_", output);
|
tmp_symbol_table.writeOutput("var_list_", output);
|
||||||
|
@ -578,7 +578,7 @@ OptimWeightsStatement::OptimWeightsStatement(const var_weights_type &var_weights
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OptimWeightsStatement::writeOutput(ostream &output) const
|
OptimWeightsStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << interfaces::comment() << "OPTIM_WEIGHTS\n\n";
|
output << interfaces::comment() << "OPTIM_WEIGHTS\n\n";
|
||||||
output << "optim_weights_ = sparse(M_.endo_nbr,M_.endo_nbr);\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
|
void
|
||||||
DynaSaveStatement::writeOutput(ostream &output) const
|
DynaSaveStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
tmp_symbol_table.writeOutput("var_list_", output);
|
tmp_symbol_table.writeOutput("var_list_", output);
|
||||||
output << "dynasave(" << filename;
|
output << "dynasave(" << filename;
|
||||||
|
@ -634,7 +634,7 @@ DynaTypeStatement::DynaTypeStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynaTypeStatement::writeOutput(ostream &output) const
|
DynaTypeStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
tmp_symbol_table.writeOutput("var_list_", output);
|
tmp_symbol_table.writeOutput("var_list_", output);
|
||||||
output << "dynatype(" << filename;
|
output << "dynatype(" << filename;
|
||||||
|
@ -651,7 +651,7 @@ ModelComparisonStatement::ModelComparisonStatement(const filename_list_type &fil
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModelComparisonStatement::writeOutput(ostream &output) const
|
ModelComparisonStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
|
|
||||||
|
@ -666,3 +666,32 @@ ModelComparisonStatement::writeOutput(ostream &output) const
|
||||||
}
|
}
|
||||||
output << "model_comparison(ModelNames_,ModelPriors_);\n";
|
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 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 END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT
|
||||||
%token PRIOR_ANALYSIS POSTERIOR_ANALYSIS
|
%token PRIOR_ANALYSIS POSTERIOR_ANALYSIS
|
||||||
%token FILTERED_VARS FIRST_OBS
|
%token FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS
|
||||||
%token <string_val> FLOAT_NUMBER
|
%token <string_val> FLOAT_NUMBER
|
||||||
%token FORECAST FUNCTIONS
|
%token FORECAST FUNCTIONS
|
||||||
%token GAMMA_PDF GRAPH
|
%token GAMMA_PDF GRAPH
|
||||||
|
@ -59,7 +59,7 @@ typedef pair<int, Type> ExpObj;
|
||||||
%token NOBS NOCORR NODIAGNOSTIC NOFUNCTIONS NOGRAPH XLS_SHEET XLS_RANGE
|
%token NOBS NOCORR NODIAGNOSTIC NOFUNCTIONS NOGRAPH XLS_SHEET XLS_RANGE
|
||||||
%token NOMOMENTS NOPRINT NORMAL_PDF
|
%token NOMOMENTS NOPRINT NORMAL_PDF
|
||||||
%token OBSERVATION_TRENDS OLR OLR_INST OLR_BETA OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS
|
%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 QZ_CRITERIUM
|
||||||
%token RELATIVE_IRF REPLIC RESOL RPLOT
|
%token RELATIVE_IRF REPLIC RESOL RPLOT
|
||||||
%token SHOCKS SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER SOLVE_ALGO STDERR STEADY STOCH_SIMUL
|
%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
|
||||||
| olr_inst
|
| olr_inst
|
||||||
| model_comparison
|
| model_comparison
|
||||||
|
| planner_objective
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -330,10 +331,10 @@ typedef pair<int, Type> ExpObj;
|
||||||
;
|
;
|
||||||
|
|
||||||
model
|
model
|
||||||
: MODEL ';' equation_list END
|
: MODEL ';' { driver.begin_model(); } equation_list END
|
||||||
| MODEL '(' o_linear ')' ';'
|
| MODEL '(' o_linear ')' ';' { driver.begin_model(); }
|
||||||
equation_list END
|
equation_list END
|
||||||
| MODEL '(' USE_DLL ')' ';' {driver.use_dll();}
|
| MODEL '(' USE_DLL ')' ';' { driver.begin_model(); driver.use_dll(); }
|
||||||
equation_list END
|
equation_list END
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1037,6 +1038,8 @@ typedef pair<int, Type> ExpObj;
|
||||||
| o_noprint
|
| 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 : filename {driver.add_mc_filename($1);}
|
||||||
| filename_list COMMA filename {driver.add_mc_filename($3);}
|
| filename_list COMMA filename {driver.add_mc_filename($3);}
|
||||||
| filename '(' value ')' {driver.add_mc_filename($1, $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>dsample {BEGIN DYNARE_STATEMENT; return token::DSAMPLE;}
|
||||||
<INITIAL>Sigma_e {BEGIN DYNARE_STATEMENT; sigma_e = 1; return token::SIGMA_E;}
|
<INITIAL>Sigma_e {BEGIN DYNARE_STATEMENT; sigma_e = 1; return token::SIGMA_E;}
|
||||||
<INITIAL>calib {BEGIN DYNARE_STATEMENT; return token::CALIB;}
|
<INITIAL>calib {BEGIN DYNARE_STATEMENT; return token::CALIB;}
|
||||||
|
<INITIAL>planner_objective {BEGIN DYNARE_STATEMENT; return token::PLANNER_OBJECTIVE;}
|
||||||
|
|
||||||
/* End of a Dynare statement */
|
/* End of a Dynare statement */
|
||||||
<DYNARE_STATEMENT>; {
|
<DYNARE_STATEMENT>; {
|
||||||
|
|
|
@ -56,6 +56,10 @@ ModFile::computingPass()
|
||||||
}
|
}
|
||||||
|
|
||||||
model_tree.computingPass();
|
model_tree.computingPass();
|
||||||
|
|
||||||
|
for(vector<Statement *>::iterator it = statements.begin();
|
||||||
|
it != statements.end(); it++)
|
||||||
|
(*it)->computingPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -140,7 +144,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all)
|
||||||
// Print statements
|
// Print statements
|
||||||
for(vector<Statement *>::iterator it = statements.begin();
|
for(vector<Statement *>::iterator it = statements.begin();
|
||||||
it != statements.end(); it++)
|
it != statements.end(); it++)
|
||||||
(*it)->writeOutput(mOutputFile);
|
(*it)->writeOutput(mOutputFile, basename);
|
||||||
|
|
||||||
mOutputFile << "save('" << basename << "_results', 'oo_');" << endl;
|
mOutputFile << "save('" << basename << "_results', 'oo_');" << endl;
|
||||||
mOutputFile << "diary off" << endl;
|
mOutputFile << "diary off" << endl;
|
||||||
|
|
|
@ -39,7 +39,8 @@ ModelTree::ModelTree(SymbolTable &symbol_table_arg,
|
||||||
num_constants(num_constants_arg),
|
num_constants(num_constants_arg),
|
||||||
computeJacobian(false),
|
computeJacobian(false),
|
||||||
computeJacobianExo(false),
|
computeJacobianExo(false),
|
||||||
computeHessian(false)
|
computeHessian(false),
|
||||||
|
computeStaticHessian(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ ModelTree::writeStaticMFile(const string &static_basename)
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
// Writing comments and function definition command
|
// 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 << interfaces::comment()+"\n"+interfaces::comment();
|
||||||
mStaticModelFile << "Status : Computes static model for Dynare\n" << interfaces::comment() << "\n";
|
mStaticModelFile << "Status : Computes static model for Dynare\n" << interfaces::comment() << "\n";
|
||||||
mStaticModelFile << interfaces::comment();
|
mStaticModelFile << interfaces::comment();
|
||||||
|
@ -630,13 +631,10 @@ inline NodeID ModelTree::DeriveArgument(NodeID iArg, Type iType, int iVarID)
|
||||||
void
|
void
|
||||||
ModelTree::writeStaticModel(ostream &StaticOutput)
|
ModelTree::writeStaticModel(ostream &StaticOutput)
|
||||||
{
|
{
|
||||||
TreeIterator tree_it;
|
|
||||||
int lEquationNBR = 0;
|
|
||||||
ostringstream model_output; // Used for storing model equations
|
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
|
ostringstream jacobian_output; // Used for storing jacobian equations
|
||||||
// Used for storing tmp expressions for jacobian equations
|
ostringstream hessian_output;
|
||||||
ostringstream jacobian_tmp_output;
|
ostringstream lsymetric; // For symmetric elements in hessian
|
||||||
|
|
||||||
int d = current_order; // Minimum number of times a temparary expression apears in equations
|
int d = current_order; // Minimum number of times a temparary expression apears in equations
|
||||||
// Reference count of token "0=0" is set to 0
|
// Reference count of token "0=0" is set to 0
|
||||||
|
@ -645,23 +643,24 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
|
||||||
ZeroEqZero->reference_count.end(),0);
|
ZeroEqZero->reference_count.end(),0);
|
||||||
// Writing model Equations
|
// Writing model Equations
|
||||||
current_order = 1;
|
current_order = 1;
|
||||||
tree_it = BeginModel;
|
TreeIterator tree_it = BeginModel;
|
||||||
|
int lEquationNBR = 0;
|
||||||
for (; tree_it != mModelTree.end(); tree_it++)
|
for (; tree_it != mModelTree.end(); tree_it++)
|
||||||
{
|
{
|
||||||
if ((*tree_it)->op_code == token::EQUAL || (*tree_it)->op_code == token::ASSIGN )
|
if ((*tree_it)->op_code == token::EQUAL || (*tree_it)->op_code == token::ASSIGN )
|
||||||
{
|
{
|
||||||
if ((*tree_it)->id1->type1 == eLocalParameter)
|
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 << " = ";
|
||||||
model_output << getExpression((*tree_it)->id2, eStaticEquations, lEquationNBR) << ";" << endl;
|
model_output << getExpression((*tree_it)->id2, eStaticEquations) << ";" << endl;
|
||||||
}
|
}
|
||||||
else if (lEquationNBR < eq_nbr)
|
else if (lEquationNBR < eq_nbr)
|
||||||
{
|
{
|
||||||
model_output << "lhs =";
|
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 << "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;
|
model_output << "residual" << lpar << lEquationNBR+1 << rpar << "= lhs-rhs;" << endl;
|
||||||
lEquationNBR++;
|
lEquationNBR++;
|
||||||
}
|
}
|
||||||
|
@ -672,7 +671,7 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
|
||||||
{
|
{
|
||||||
if (optimize(*tree_it))
|
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;
|
(*tree_it)->tmp_status = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -682,7 +681,6 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writing Jacobian for endogenous variables without lag
|
|
||||||
for(; tree_it != mModelTree.end(); tree_it++)
|
for(; tree_it != mModelTree.end(); tree_it++)
|
||||||
{
|
{
|
||||||
if ((*tree_it)->op_code != NoOpCode
|
if ((*tree_it)->op_code != NoOpCode
|
||||||
|
@ -691,7 +689,7 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
|
||||||
{
|
{
|
||||||
if (optimize(*tree_it) == 1)
|
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;
|
(*tree_it)->tmp_status = 1;
|
||||||
}
|
}
|
||||||
else
|
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++)
|
for (unsigned int i = 0; i < mDerivativeIndex[0].size(); i++)
|
||||||
{
|
{
|
||||||
if (variable_table.getType(mDerivativeIndex[0][i].derivators) == eEndogenous)
|
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
|
// Writing ouputs
|
||||||
if (offset == 1)
|
if (offset == 1)
|
||||||
{
|
{
|
||||||
|
@ -744,6 +779,20 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
|
||||||
StaticOutput << " g1 = real(g1)+2*imag(g1);\n";
|
StaticOutput << " g1 = real(g1)+2*imag(g1);\n";
|
||||||
StaticOutput << " end\n";
|
StaticOutput << " end\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
|
else
|
||||||
{
|
{
|
||||||
|
@ -770,17 +819,10 @@ ModelTree::writeStaticModel(ostream &StaticOutput)
|
||||||
void
|
void
|
||||||
ModelTree::writeDynamicModel(ostream &DynamicOutput)
|
ModelTree::writeDynamicModel(ostream &DynamicOutput)
|
||||||
{
|
{
|
||||||
TreeIterator tree_it;
|
ostringstream lsymetric; // Used when writing symetric elements in Hessian
|
||||||
int lEquationNBR = 0;
|
|
||||||
ostringstream lsymetric; // Used when writing symetric elements
|
|
||||||
ostringstream model_output; // Used for storing model equations
|
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
|
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
|
ostringstream hessian_output; // Used for storing Hessian equations
|
||||||
// Used for storing tmp expressions for Hessian equations
|
|
||||||
ostringstream hessian_tmp_output;
|
|
||||||
|
|
||||||
int d = current_order;
|
int d = current_order;
|
||||||
|
|
||||||
|
@ -789,32 +831,29 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
|
||||||
fill(ZeroEqZero->reference_count.begin(),
|
fill(ZeroEqZero->reference_count.begin(),
|
||||||
ZeroEqZero->reference_count.end(),0);
|
ZeroEqZero->reference_count.end(),0);
|
||||||
|
|
||||||
// Clearing output string
|
|
||||||
model_output.str("");
|
|
||||||
jacobian_output.str("");
|
|
||||||
// Getting equations from model tree
|
// Getting equations from model tree
|
||||||
// Starting from the end of equation
|
// Starting from the end of equation
|
||||||
// Searching for the next '=' operator,
|
// Searching for the next '=' operator,
|
||||||
current_order = 1;
|
current_order = 1;
|
||||||
lEquationNBR = 0;
|
int lEquationNBR = 0;
|
||||||
cout << "\tequations .. ";
|
cout << "\tequations .. ";
|
||||||
tree_it = BeginModel;
|
TreeIterator tree_it = BeginModel;
|
||||||
for (; tree_it != mModelTree.end(); tree_it++)
|
for (; tree_it != mModelTree.end(); tree_it++)
|
||||||
{
|
{
|
||||||
if ((*tree_it)->op_code == token::EQUAL || (*tree_it)->op_code == token::ASSIGN)
|
if ((*tree_it)->op_code == token::EQUAL || (*tree_it)->op_code == token::ASSIGN)
|
||||||
{
|
{
|
||||||
if ((*tree_it)->id1->type1 == eLocalParameter)
|
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 << " = ";
|
||||||
model_output << getExpression((*tree_it)->id2, eStaticEquations, lEquationNBR) << ";" << endl;
|
model_output << getExpression((*tree_it)->id2, eStaticEquations) << ";" << endl;
|
||||||
}
|
}
|
||||||
else if (lEquationNBR < eq_nbr)
|
else if (lEquationNBR < eq_nbr)
|
||||||
{
|
{
|
||||||
model_output << "lhs =";
|
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 << "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;
|
model_output << "residual" << lpar << lEquationNBR+1 << rpar << "= lhs-rhs;" << endl;
|
||||||
lEquationNBR++;
|
lEquationNBR++;
|
||||||
}
|
}
|
||||||
|
@ -825,7 +864,7 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
|
||||||
{
|
{
|
||||||
if (optimize(*tree_it))
|
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;
|
(*tree_it)->tmp_status = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -843,7 +882,7 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
|
||||||
{
|
{
|
||||||
if (optimize(*tree_it) == 1)
|
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;
|
(*tree_it)->tmp_status = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -865,7 +904,7 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
|
||||||
{
|
{
|
||||||
if (optimize(*tree_it) == 1)
|
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;
|
(*tree_it)->tmp_status = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -875,7 +914,6 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lEquationNBR = 0;
|
|
||||||
for (unsigned int i = 0; i < mDerivativeIndex[0].size(); i++)
|
for (unsigned int i = 0; i < mDerivativeIndex[0].size(); i++)
|
||||||
{
|
{
|
||||||
if (computeJacobianExo || variable_table.getType(mDerivativeIndex[0][i].derivators) == eEndogenous)
|
if (computeJacobianExo || variable_table.getType(mDerivativeIndex[0][i].derivators) == eEndogenous)
|
||||||
|
@ -899,7 +937,6 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
|
||||||
// Getting Hessian from model tree
|
// Getting Hessian from model tree
|
||||||
// Starting from the end of equation
|
// Starting from the end of equation
|
||||||
// Searching for the next '=' operator,
|
// Searching for the next '=' operator,
|
||||||
lEquationNBR = 0;
|
|
||||||
cout << "\tHessian .. ";
|
cout << "\tHessian .. ";
|
||||||
for (unsigned int i = 0; i < mDerivativeIndex[1].size(); i++)
|
for (unsigned int i = 0; i < mDerivativeIndex[1].size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -995,8 +1032,8 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput)
|
||||||
current_order = d;
|
current_order = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
string
|
||||||
inline string ModelTree::getExpression(NodeID StartID, EquationType iEquationType, int iEquationID)
|
ModelTree::getExpression(NodeID StartID, EquationType iEquationType)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Stack of tokens
|
// Stack of tokens
|
||||||
|
@ -1342,7 +1379,7 @@ ModelTree::computingPass()
|
||||||
rpar = ']';
|
rpar = ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (computeHessian)
|
if (computeHessian || computeStaticHessian)
|
||||||
derive(2);
|
derive(2);
|
||||||
else
|
else
|
||||||
derive(1);
|
derive(1);
|
||||||
|
|
|
@ -11,7 +11,7 @@ InitParamStatement::InitParamStatement(const string ¶m_name_arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
InitParamStatement::writeOutput(ostream &output) const
|
InitParamStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
int id = symbol_table.getID(param_name) + 1;
|
int id = symbol_table.getID(param_name) + 1;
|
||||||
output << "M_.params( " << id << " ) = " << param_value << ";\n";
|
output << "M_.params( " << id << " ) = " << param_value << ";\n";
|
||||||
|
@ -53,7 +53,7 @@ InitValStatement::InitValStatement(const init_values_type &init_values_arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
InitValStatement::writeOutput(ostream &output) const
|
InitValStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << interfaces::comment() << "\n" << interfaces::comment() << "INITVAL instructions \n"
|
output << interfaces::comment() << "\n" << interfaces::comment() << "INITVAL instructions \n"
|
||||||
<< interfaces::comment() << "\n";
|
<< interfaces::comment() << "\n";
|
||||||
|
@ -83,7 +83,7 @@ EndValStatement::EndValStatement(const init_values_type &init_values_arg,
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EndValStatement::writeOutput(ostream &output) const
|
EndValStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << interfaces::comment() << "\n" << interfaces::comment() << "ENDVAL instructions\n"
|
output << interfaces::comment() << "\n" << interfaces::comment() << "ENDVAL instructions\n"
|
||||||
<< interfaces::comment() << "\n";
|
<< interfaces::comment() << "\n";
|
||||||
|
@ -101,7 +101,7 @@ HistValStatement::HistValStatement(const hist_values_type &hist_values_arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
HistValStatement::writeOutput(ostream &output) const
|
HistValStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << interfaces::comment() << "\n" << interfaces::comment() << "HISTVAL instructions\n"
|
output << interfaces::comment() << "\n" << interfaces::comment() << "HISTVAL instructions\n"
|
||||||
<< interfaces::comment() << "\n";
|
<< interfaces::comment() << "\n";
|
||||||
|
|
|
@ -120,14 +120,14 @@ ParsingDriver::add_model_constant(string *constant)
|
||||||
{
|
{
|
||||||
int id = mod_file->num_constants.AddConstant(*constant);
|
int id = mod_file->num_constants.AddConstant(*constant);
|
||||||
delete constant;
|
delete constant;
|
||||||
return mod_file->model_tree.AddTerminal((NodeID) id, eNumericalConstant);
|
return model_tree->AddTerminal((NodeID) id, eNumericalConstant);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_variable(string *name)
|
ParsingDriver::add_model_variable(string *name)
|
||||||
{
|
{
|
||||||
check_symbol_existence(*name);
|
check_symbol_existence(*name);
|
||||||
NodeID id = mod_file->model_tree.AddTerminal(*name);
|
NodeID id = model_tree->AddTerminal(*name);
|
||||||
delete name;
|
delete name;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ ParsingDriver::add_model_variable(string *name, string *olag)
|
||||||
<< *name
|
<< *name
|
||||||
<< " has lag " << lag << endl;
|
<< " has lag " << lag << endl;
|
||||||
}
|
}
|
||||||
NodeID id = mod_file->model_tree.AddTerminal(*name, lag);
|
NodeID id = model_tree->AddTerminal(*name, lag);
|
||||||
delete name;
|
delete name;
|
||||||
delete olag;
|
delete olag;
|
||||||
return id;
|
return id;
|
||||||
|
@ -296,6 +296,12 @@ ParsingDriver::end_histval()
|
||||||
hist_values.clear();
|
hist_values.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ParsingDriver::begin_model()
|
||||||
|
{
|
||||||
|
model_tree = &mod_file->model_tree;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::end_shocks()
|
ParsingDriver::end_shocks()
|
||||||
{
|
{
|
||||||
|
@ -904,159 +910,175 @@ ParsingDriver::run_model_comparison()
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ParsingDriver::begin_planner_objective()
|
||||||
|
{
|
||||||
|
model_tree = new ModelTree(mod_file->symbol_table, mod_file->num_constants);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ParsingDriver::end_planner_objective(NodeID expr)
|
||||||
|
{
|
||||||
|
// Add equation corresponding to expression
|
||||||
|
model_tree->AddEqual(expr, model_tree->Zero);
|
||||||
|
model_tree->eq_nbr++;
|
||||||
|
|
||||||
|
mod_file->addStatement(new PlannerObjectiveStatement(model_tree));
|
||||||
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_equal(NodeID arg1, NodeID arg2)
|
ParsingDriver::add_model_equal(NodeID arg1, NodeID arg2)
|
||||||
{
|
{
|
||||||
NodeID id = mod_file->model_tree.AddEqual(arg1, arg2);
|
NodeID id = model_tree->AddEqual(arg1, arg2);
|
||||||
mod_file->model_tree.eq_nbr++;
|
model_tree->eq_nbr++;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_equal_with_zero_rhs(NodeID arg)
|
ParsingDriver::add_model_equal_with_zero_rhs(NodeID arg)
|
||||||
{
|
{
|
||||||
return add_model_equal(arg, mod_file->model_tree.Zero);
|
return add_model_equal(arg, model_tree->Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::declare_and_init_local_parameter(string *name, NodeID rhs)
|
ParsingDriver::declare_and_init_local_parameter(string *name, NodeID rhs)
|
||||||
{
|
{
|
||||||
mod_file->symbol_table.AddSymbolDeclar(*name, eLocalParameter, *name);
|
mod_file->symbol_table.AddSymbolDeclar(*name, eLocalParameter, *name);
|
||||||
NodeID id = mod_file->model_tree.AddTerminal(*name);
|
NodeID id = model_tree->AddTerminal(*name);
|
||||||
mod_file->model_tree.AddAssign(id, rhs);
|
model_tree->AddAssign(id, rhs);
|
||||||
delete name;
|
delete name;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_plus(NodeID arg1, NodeID arg2)
|
ParsingDriver::add_model_plus(NodeID arg1, NodeID arg2)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddPlus(arg1, arg2);
|
return model_tree->AddPlus(arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_minus(NodeID arg1, NodeID arg2)
|
ParsingDriver::add_model_minus(NodeID arg1, NodeID arg2)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddMinus(arg1, arg2);
|
return model_tree->AddMinus(arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_uminus(NodeID arg1)
|
ParsingDriver::add_model_uminus(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddUMinus(arg1);
|
return model_tree->AddUMinus(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_times(NodeID arg1, NodeID arg2)
|
ParsingDriver::add_model_times(NodeID arg1, NodeID arg2)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddTimes(arg1, arg2);
|
return model_tree->AddTimes(arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_divide(NodeID arg1, NodeID arg2)
|
ParsingDriver::add_model_divide(NodeID arg1, NodeID arg2)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddDivide(arg1, arg2);
|
return model_tree->AddDivide(arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_power(NodeID arg1, NodeID arg2)
|
ParsingDriver::add_model_power(NodeID arg1, NodeID arg2)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddPower(arg1, arg2);
|
return model_tree->AddPower(arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_exp(NodeID arg1)
|
ParsingDriver::add_model_exp(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddExp(arg1);
|
return model_tree->AddExp(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_log(NodeID arg1)
|
ParsingDriver::add_model_log(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddLog(arg1);
|
return model_tree->AddLog(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_log10(NodeID arg1)
|
ParsingDriver::add_model_log10(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddLog10(arg1);
|
return model_tree->AddLog10(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_cos(NodeID arg1)
|
ParsingDriver::add_model_cos(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddCos(arg1);
|
return model_tree->AddCos(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_sin(NodeID arg1)
|
ParsingDriver::add_model_sin(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddSin(arg1);
|
return model_tree->AddSin(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_tan(NodeID arg1)
|
ParsingDriver::add_model_tan(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddTan(arg1);
|
return model_tree->AddTan(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_acos(NodeID arg1)
|
ParsingDriver::add_model_acos(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddACos(arg1);
|
return model_tree->AddACos(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_asin(NodeID arg1)
|
ParsingDriver::add_model_asin(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddASin(arg1);
|
return model_tree->AddASin(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_atan(NodeID arg1)
|
ParsingDriver::add_model_atan(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddATan(arg1);
|
return model_tree->AddATan(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_cosh(NodeID arg1)
|
ParsingDriver::add_model_cosh(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddCosH(arg1);
|
return model_tree->AddCosH(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_sinh(NodeID arg1)
|
ParsingDriver::add_model_sinh(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddSinH(arg1);
|
return model_tree->AddSinH(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_tanh(NodeID arg1)
|
ParsingDriver::add_model_tanh(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddTanH(arg1);
|
return model_tree->AddTanH(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_acosh(NodeID arg1)
|
ParsingDriver::add_model_acosh(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddACosH(arg1);
|
return model_tree->AddACosH(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_asinh(NodeID arg1)
|
ParsingDriver::add_model_asinh(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddASinH(arg1);
|
return model_tree->AddASinH(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_atanh(NodeID arg1)
|
ParsingDriver::add_model_atanh(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddATanH(arg1);
|
return model_tree->AddATanH(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID
|
NodeID
|
||||||
ParsingDriver::add_model_sqrt(NodeID arg1)
|
ParsingDriver::add_model_sqrt(NodeID arg1)
|
||||||
{
|
{
|
||||||
return mod_file->model_tree.AddSqRt(arg1);
|
return model_tree->AddSqRt(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -120,7 +120,7 @@ ShocksStatement::ShocksStatement(const det_shocks_type &det_shocks_arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShocksStatement::writeOutput(ostream &output) const
|
ShocksStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << interfaces::comment() << endl << interfaces::comment();
|
output << interfaces::comment() << endl << interfaces::comment();
|
||||||
output << "SHOCKS instructions \n";
|
output << "SHOCKS instructions \n";
|
||||||
|
@ -146,7 +146,7 @@ MShocksStatement::MShocksStatement(const det_shocks_type &det_shocks_arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MShocksStatement::writeOutput(ostream &output) const
|
MShocksStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << interfaces::comment() << endl << interfaces::comment();
|
output << interfaces::comment() << endl << interfaces::comment();
|
||||||
output << "SHOCKS instructions \n";
|
output << "SHOCKS instructions \n";
|
||||||
|
|
|
@ -40,7 +40,7 @@ SigmaeStatement::determineMatrixForm(const matrix_type &matrix) throw (MatrixFor
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SigmaeStatement::writeOutput(ostream &output) const
|
SigmaeStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
unsigned int ic, ic1;
|
unsigned int ic, ic1;
|
||||||
unsigned int ir, ir1;
|
unsigned int ir, ir1;
|
||||||
|
|
|
@ -16,13 +16,18 @@ Statement::checkPass(ModFileStructure &mod_file_struct)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Statement::computingPass()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NativeStatement::NativeStatement(const string &native_statement_arg) :
|
NativeStatement::NativeStatement(const string &native_statement_arg) :
|
||||||
native_statement(native_statement_arg)
|
native_statement(native_statement_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NativeStatement::writeOutput(ostream &output) const
|
NativeStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
output << native_statement << endl;
|
output << native_statement << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "TmpSymbolTable.hh"
|
#include "TmpSymbolTable.hh"
|
||||||
#include "SymbolTable.hh"
|
#include "SymbolTable.hh"
|
||||||
#include "Statement.hh"
|
#include "Statement.hh"
|
||||||
|
#include "ModelTree.hh"
|
||||||
|
|
||||||
class SteadyStatement : public Statement
|
class SteadyStatement : public Statement
|
||||||
{
|
{
|
||||||
|
@ -13,7 +14,7 @@ private:
|
||||||
const OptionsList options_list;
|
const OptionsList options_list;
|
||||||
public:
|
public:
|
||||||
SteadyStatement(const OptionsList &options_list_arg);
|
SteadyStatement(const OptionsList &options_list_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CheckStatement : public Statement
|
class CheckStatement : public Statement
|
||||||
|
@ -23,7 +24,7 @@ private:
|
||||||
public:
|
public:
|
||||||
CheckStatement(const OptionsList &options_list_arg);
|
CheckStatement(const OptionsList &options_list_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimulStatement : public Statement
|
class SimulStatement : public Statement
|
||||||
|
@ -33,7 +34,7 @@ private:
|
||||||
public:
|
public:
|
||||||
SimulStatement(const OptionsList &options_list_arg);
|
SimulStatement(const OptionsList &options_list_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StochSimulStatement : public Statement
|
class StochSimulStatement : public Statement
|
||||||
|
@ -45,7 +46,7 @@ public:
|
||||||
StochSimulStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
StochSimulStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RplotStatement : public Statement
|
class RplotStatement : public Statement
|
||||||
|
@ -56,7 +57,7 @@ private:
|
||||||
public:
|
public:
|
||||||
RplotStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
RplotStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnitRootVarsStatement : public Statement
|
class UnitRootVarsStatement : public Statement
|
||||||
|
@ -65,7 +66,7 @@ private:
|
||||||
const TmpSymbolTable tmp_symbol_table;
|
const TmpSymbolTable tmp_symbol_table;
|
||||||
public:
|
public:
|
||||||
UnitRootVarsStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
UnitRootVarsStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PeriodsStatement : public Statement
|
class PeriodsStatement : public Statement
|
||||||
|
@ -74,7 +75,7 @@ private:
|
||||||
const int periods;
|
const int periods;
|
||||||
public:
|
public:
|
||||||
PeriodsStatement(int periods_arg);
|
PeriodsStatement(int periods_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DsampleStatement : public Statement
|
class DsampleStatement : public Statement
|
||||||
|
@ -84,7 +85,7 @@ private:
|
||||||
public:
|
public:
|
||||||
DsampleStatement(int val1_arg);
|
DsampleStatement(int val1_arg);
|
||||||
DsampleStatement(int val1_arg, int val2_arg);
|
DsampleStatement(int val1_arg, int val2_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EstimationStatement : public Statement
|
class EstimationStatement : public Statement
|
||||||
|
@ -96,7 +97,7 @@ public:
|
||||||
EstimationStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
EstimationStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PriorAnalysisStatement : public Statement
|
class PriorAnalysisStatement : public Statement
|
||||||
|
@ -107,7 +108,7 @@ private:
|
||||||
public:
|
public:
|
||||||
PriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
PriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PosteriorAnalysisStatement : public Statement
|
class PosteriorAnalysisStatement : public Statement
|
||||||
|
@ -118,7 +119,7 @@ private:
|
||||||
public:
|
public:
|
||||||
PosteriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
PosteriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VarobsStatement : public Statement
|
class VarobsStatement : public Statement
|
||||||
|
@ -127,7 +128,7 @@ private:
|
||||||
const TmpSymbolTable tmp_symbol_table;
|
const TmpSymbolTable tmp_symbol_table;
|
||||||
public:
|
public:
|
||||||
VarobsStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
VarobsStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObservationTrendsStatement : public Statement
|
class ObservationTrendsStatement : public Statement
|
||||||
|
@ -140,7 +141,7 @@ private:
|
||||||
public:
|
public:
|
||||||
ObservationTrendsStatement(const trend_elements_type &trend_elements_arg,
|
ObservationTrendsStatement(const trend_elements_type &trend_elements_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OsrParamsStatement : public Statement
|
class OsrParamsStatement : public Statement
|
||||||
|
@ -149,7 +150,7 @@ private:
|
||||||
const TmpSymbolTable tmp_symbol_table;
|
const TmpSymbolTable tmp_symbol_table;
|
||||||
public:
|
public:
|
||||||
OsrParamsStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
OsrParamsStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OsrStatement : public Statement
|
class OsrStatement : public Statement
|
||||||
|
@ -161,7 +162,7 @@ public:
|
||||||
OsrStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
OsrStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OlrStatement : public Statement
|
class OlrStatement : public Statement
|
||||||
|
@ -173,7 +174,7 @@ public:
|
||||||
OlrStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
OlrStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OlrInstStatement : public Statement
|
class OlrInstStatement : public Statement
|
||||||
|
@ -182,7 +183,7 @@ private:
|
||||||
const TmpSymbolTable tmp_symbol_table;
|
const TmpSymbolTable tmp_symbol_table;
|
||||||
public:
|
public:
|
||||||
OlrInstStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
OlrInstStatement(const TmpSymbolTable &tmp_symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DynaTypeStatement : public Statement
|
class DynaTypeStatement : public Statement
|
||||||
|
@ -194,7 +195,7 @@ private:
|
||||||
public:
|
public:
|
||||||
DynaTypeStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
DynaTypeStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
const string &filename_arg, const string &ext_arg);
|
const string &filename_arg, const string &ext_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DynaSaveStatement : public Statement
|
class DynaSaveStatement : public Statement
|
||||||
|
@ -206,7 +207,7 @@ private:
|
||||||
public:
|
public:
|
||||||
DynaSaveStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
DynaSaveStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
||||||
const string &filename_arg, const string &ext_arg);
|
const string &filename_arg, const string &ext_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ModelComparisonStatement : public Statement
|
class ModelComparisonStatement : public Statement
|
||||||
|
@ -219,7 +220,7 @@ private:
|
||||||
public:
|
public:
|
||||||
ModelComparisonStatement(const filename_list_type &filename_list_arg,
|
ModelComparisonStatement(const filename_list_type &filename_list_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -270,7 +271,7 @@ private:
|
||||||
public:
|
public:
|
||||||
EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EstimatedParamsInitStatement : public Statement
|
class EstimatedParamsInitStatement : public Statement
|
||||||
|
@ -281,7 +282,7 @@ private:
|
||||||
public:
|
public:
|
||||||
EstimatedParamsInitStatement(const vector<EstimationParams> &estim_params_list_arg,
|
EstimatedParamsInitStatement(const vector<EstimationParams> &estim_params_list_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EstimatedParamsBoundsStatement : public Statement
|
class EstimatedParamsBoundsStatement : public Statement
|
||||||
|
@ -292,7 +293,7 @@ private:
|
||||||
public:
|
public:
|
||||||
EstimatedParamsBoundsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
EstimatedParamsBoundsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptimWeightsStatement : public Statement
|
class OptimWeightsStatement : public Statement
|
||||||
|
@ -308,7 +309,7 @@ public:
|
||||||
OptimWeightsStatement(const var_weights_type &var_weights_arg,
|
OptimWeightsStatement(const var_weights_type &var_weights_arg,
|
||||||
const covar_weights_type &covar_weights_arg,
|
const covar_weights_type &covar_weights_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CalibStatement : public Statement
|
class CalibStatement : public Statement
|
||||||
|
@ -317,7 +318,7 @@ private:
|
||||||
const int covar;
|
const int covar;
|
||||||
public:
|
public:
|
||||||
CalibStatement(int covar_arg);
|
CalibStatement(int covar_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CalibVarStatement : public Statement
|
class CalibVarStatement : public Statement
|
||||||
|
@ -339,7 +340,25 @@ public:
|
||||||
const calib_covar_type &calib_covar_arg,
|
const calib_covar_type &calib_covar_arg,
|
||||||
const calib_ac_type &calib_ac_arg,
|
const calib_ac_type &calib_ac_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \todo Make model_tree a member instead of a pointer */
|
||||||
|
class PlannerObjectiveStatement : public Statement
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
ModelTree *model_tree;
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
/*! \param model_tree_arg the model tree used to store the objective function.
|
||||||
|
It is owned by the PlannerObjectiveStatement, and will be deleted by its destructor */
|
||||||
|
PlannerObjectiveStatement(ModelTree *model_tree_arg);
|
||||||
|
virtual ~PlannerObjectiveStatement();
|
||||||
|
/*! \todo check there are only endogenous variables at the current period in the objective
|
||||||
|
(no exogenous, no lead/lag) */
|
||||||
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
|
virtual void computingPass();
|
||||||
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,11 +45,12 @@ private :
|
||||||
/*! Gets output argument of terminal token */
|
/*! Gets output argument of terminal token */
|
||||||
inline std::string getArgument(NodeID id, Type type, EquationType iEquationType);
|
inline std::string getArgument(NodeID id, Type type, EquationType iEquationType);
|
||||||
/*! Gets expression of part of model tree */
|
/*! Gets expression of part of model tree */
|
||||||
inline std::string getExpression(NodeID StartID, EquationType iEquationType, int iEquationID = -1);
|
std::string getExpression(NodeID StartID, EquationType iEquationType);
|
||||||
inline int optimize(NodeID id);
|
inline int optimize(NodeID id);
|
||||||
/*! Computes derivatives of ModelTree */
|
/*! Computes derivatives of ModelTree */
|
||||||
void derive(int iOrder);
|
void derive(int iOrder);
|
||||||
//! Writes the static model equations and its derivatives
|
//! Writes the static model equations and its derivatives
|
||||||
|
/*! \todo handle hessian in C output */
|
||||||
void writeStaticModel(std::ostream &StaticOutput);
|
void writeStaticModel(std::ostream &StaticOutput);
|
||||||
//! Writes the dynamic model equations and its derivatives
|
//! Writes the dynamic model equations and its derivatives
|
||||||
void writeDynamicModel(std::ostream &DynamicOutput);
|
void writeDynamicModel(std::ostream &DynamicOutput);
|
||||||
|
@ -69,12 +70,14 @@ public:
|
||||||
int eq_nbr;
|
int eq_nbr;
|
||||||
//! Do some checking
|
//! Do some checking
|
||||||
void checkPass() const;
|
void checkPass() const;
|
||||||
//! Whether Jacobian (vs endogenous) should be written
|
//! Whether dynamic Jacobian (w.r. to endogenous) should be written
|
||||||
bool computeJacobian;
|
bool computeJacobian;
|
||||||
//! Whether Jacobian (vs endogenous and exogenous) should be written
|
//! Whether dynamic Jacobian (w.r. to endogenous and exogenous) should be written
|
||||||
bool computeJacobianExo;
|
bool computeJacobianExo;
|
||||||
//! Whether Hessian (vs endogenous and exogenous) should be written
|
//! Whether dynamic Hessian (w.r. to endogenous and exogenous) should be written
|
||||||
bool computeHessian;
|
bool computeHessian;
|
||||||
|
//! Whether static Hessian (w.r. to endogenous only) should be written
|
||||||
|
bool computeStaticHessian;
|
||||||
//! Execute computations (variable sorting + derivation)
|
//! Execute computations (variable sorting + derivation)
|
||||||
/*! You must set computeJacobian, computeJacobianExo and computeHessian to correct values before
|
/*! You must set computeJacobian, computeJacobianExo and computeHessian to correct values before
|
||||||
calling this function */
|
calling this function */
|
||||||
|
|
|
@ -18,7 +18,7 @@ private:
|
||||||
public:
|
public:
|
||||||
InitParamStatement(const string ¶m_name_arg, const string ¶m_value_arg,
|
InitParamStatement(const string ¶m_name_arg, const string ¶m_value_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InitOrEndValStatement : public Statement
|
class InitOrEndValStatement : public Statement
|
||||||
|
@ -44,7 +44,7 @@ class InitValStatement : public InitOrEndValStatement
|
||||||
public:
|
public:
|
||||||
InitValStatement(const init_values_type &init_values_arg,
|
InitValStatement(const init_values_type &init_values_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EndValStatement : public InitOrEndValStatement
|
class EndValStatement : public InitOrEndValStatement
|
||||||
|
@ -52,7 +52,7 @@ class EndValStatement : public InitOrEndValStatement
|
||||||
public:
|
public:
|
||||||
EndValStatement(const init_values_type &init_values_arg,
|
EndValStatement(const init_values_type &init_values_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HistValStatement : public Statement
|
class HistValStatement : public Statement
|
||||||
|
@ -69,7 +69,7 @@ private:
|
||||||
public:
|
public:
|
||||||
HistValStatement(const hist_values_type &hist_values_arg,
|
HistValStatement(const hist_values_type &hist_values_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "Shocks.hh"
|
#include "Shocks.hh"
|
||||||
#include "SigmaeInitialization.hh"
|
#include "SigmaeInitialization.hh"
|
||||||
#include "NumericalInitialization.hh"
|
#include "NumericalInitialization.hh"
|
||||||
|
#include "ModelTree.hh"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -49,6 +50,10 @@ private:
|
||||||
Expression expression;
|
Expression expression;
|
||||||
//! Stores temporary symbol table
|
//! Stores temporary symbol table
|
||||||
TmpSymbolTable *tmp_symbol_table;
|
TmpSymbolTable *tmp_symbol_table;
|
||||||
|
|
||||||
|
//! The model tree in which to add expressions currently parsed
|
||||||
|
ModelTree *model_tree;
|
||||||
|
|
||||||
//! Stores options lists
|
//! Stores options lists
|
||||||
OptionsList options_list;
|
OptionsList options_list;
|
||||||
//! Stores operator table
|
//! Stores operator table
|
||||||
|
@ -185,6 +190,8 @@ public:
|
||||||
void end_endval();
|
void end_endval();
|
||||||
//! Writes end of an histval block
|
//! Writes end of an histval block
|
||||||
void end_histval();
|
void end_histval();
|
||||||
|
//! Begin a model block
|
||||||
|
void begin_model();
|
||||||
//! Writes a shocks statement
|
//! Writes a shocks statement
|
||||||
void end_shocks();
|
void end_shocks();
|
||||||
//! Writes a mshocks statement
|
//! Writes a mshocks statement
|
||||||
|
@ -280,6 +287,10 @@ public:
|
||||||
void run_dynatype(string *arg1, string *arg2 = new string);
|
void run_dynatype(string *arg1, string *arg2 = new string);
|
||||||
void add_mc_filename(string *filename, string *prior = new string("1"));
|
void add_mc_filename(string *filename, string *prior = new string("1"));
|
||||||
void run_model_comparison();
|
void run_model_comparison();
|
||||||
|
//! Begin a planner_objective statement
|
||||||
|
void begin_planner_objective();
|
||||||
|
//! End a planner objective statement
|
||||||
|
void end_planner_objective(NodeID expr);
|
||||||
//! Writes token "arg1=arg2" to model tree
|
//! Writes token "arg1=arg2" to model tree
|
||||||
NodeID add_model_equal(NodeID arg1, NodeID arg2);
|
NodeID add_model_equal(NodeID arg1, NodeID arg2);
|
||||||
//! Writes token "arg=0" to model tree
|
//! Writes token "arg=0" to model tree
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
const covar_and_corr_shocks_type &covar_shocks_arg,
|
const covar_and_corr_shocks_type &covar_shocks_arg,
|
||||||
const covar_and_corr_shocks_type &corr_shocks_arg,
|
const covar_and_corr_shocks_type &corr_shocks_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MShocksStatement : public AbstractShocksStatement
|
class MShocksStatement : public AbstractShocksStatement
|
||||||
|
@ -63,7 +63,7 @@ public:
|
||||||
const covar_and_corr_shocks_type &covar_shocks_arg,
|
const covar_and_corr_shocks_type &covar_shocks_arg,
|
||||||
const covar_and_corr_shocks_type &corr_shocks_arg,
|
const covar_and_corr_shocks_type &corr_shocks_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,7 +39,7 @@ private:
|
||||||
|
|
||||||
public :
|
public :
|
||||||
SigmaeStatement(const matrix_type &matrix_arg) throw (MatrixFormException);
|
SigmaeStatement(const matrix_type &matrix_arg) throw (MatrixFormException);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,7 +25,13 @@ public:
|
||||||
virtual ~Statement();
|
virtual ~Statement();
|
||||||
//! Do some internal check, and fill the ModFileStructure class
|
//! Do some internal check, and fill the ModFileStructure class
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output) const = 0;
|
virtual void computingPass();
|
||||||
|
//! Write Matlab outout code
|
||||||
|
/*!
|
||||||
|
\param output is the output stream of the main matlab file
|
||||||
|
\param basename is the name of the modfile (without extension) which can be used to build auxiliary files
|
||||||
|
*/
|
||||||
|
virtual void writeOutput(ostream &output, const string &basename) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NativeStatement : public Statement
|
class NativeStatement : public Statement
|
||||||
|
@ -34,7 +40,7 @@ private:
|
||||||
const string native_statement;
|
const string native_statement;
|
||||||
public:
|
public:
|
||||||
NativeStatement(const string &native_statement_arg);
|
NativeStatement(const string &native_statement_arg);
|
||||||
virtual void writeOutput(ostream &output) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptionsList
|
class OptionsList
|
||||||
|
|
Loading…
Reference in New Issue