2008-01-11 14:42:14 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003-2008 Dynare Team
|
|
|
|
*
|
|
|
|
* This file is part of Dynare.
|
|
|
|
*
|
|
|
|
* Dynare is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Dynare is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
2006-11-05 00:31:17 +01:00
|
|
|
*/
|
2008-01-11 14:42:14 +01:00
|
|
|
|
2006-11-05 00:31:17 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
using namespace std;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
2006-11-05 00:31:17 +01:00
|
|
|
#include "ComputingTasks.hh"
|
|
|
|
#include "Interface.hh"
|
2006-12-12 12:54:30 +01:00
|
|
|
#include "Statement.hh"
|
|
|
|
|
|
|
|
SteadyStatement::SteadyStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
SteadyStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "steady;\n";
|
|
|
|
}
|
|
|
|
|
2007-11-21 00:24:01 +01:00
|
|
|
SteadySparseStatement::SteadySparseStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SteadySparseStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << basename << "_static;\n";
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
CheckStatement::CheckStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
CheckStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "check;\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-17 15:59:39 +01:00
|
|
|
void
|
|
|
|
CheckStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.check_present = true;
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
SimulStatement::SimulStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-15 12:44:58 +01:00
|
|
|
void
|
|
|
|
SimulStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.simul_present = true;
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
SimulStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "simul(oo_.dr);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2007-03-09 18:27:46 +01:00
|
|
|
SimulSparseStatement::SimulSparseStatement(const OptionsList &options_list_arg,
|
2007-11-21 00:24:01 +01:00
|
|
|
int compiler_arg, int mode_arg) :
|
2007-03-09 18:27:46 +01:00
|
|
|
options_list(options_list_arg),
|
2007-11-21 00:24:01 +01:00
|
|
|
compiler(compiler_arg),
|
|
|
|
mode(mode_arg)
|
2007-02-22 00:28:16 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SimulSparseStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.simul_present = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SimulSparseStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
2007-11-21 00:24:01 +01:00
|
|
|
output << "if (~ options_.initval_file) & (size(oo_.endo_simul,2)<options_.periods)\n";
|
2007-06-01 13:43:49 +02:00
|
|
|
output << " if ~isfield(options_,'datafile')\n";
|
|
|
|
output << " make_y_;\n";
|
|
|
|
output << " make_ex_;\n";
|
|
|
|
output << " else\n";
|
|
|
|
output << " read_data_;\n";
|
|
|
|
output << " end\n";
|
2007-02-22 00:28:16 +01:00
|
|
|
output << "end\n";
|
2007-11-21 00:24:01 +01:00
|
|
|
if(mode==eSparseDLLMode)
|
2007-10-04 00:01:08 +02:00
|
|
|
{
|
2007-11-21 00:24:01 +01:00
|
|
|
if(compiler!=NO_COMPILE)
|
|
|
|
{
|
|
|
|
output << "disp('compiling...');\n";
|
|
|
|
output << "t0=clock;\n";
|
|
|
|
if (compiler == 0)
|
|
|
|
output << "mex " << basename << "_dynamic.c;\n";
|
|
|
|
else
|
|
|
|
output << "mex " << basename << "_dynamic.cc;\n";
|
|
|
|
output << "disp(['compiling time: ' num2str(etime(clock,t0))]);\n";
|
|
|
|
output << "oo_.endo_simul=" << basename << "_dynamic;\n";
|
|
|
|
}
|
2007-10-04 00:01:08 +02:00
|
|
|
else
|
2007-11-21 00:24:01 +01:00
|
|
|
{
|
|
|
|
output << "oo_.endo_simul=simulate;\n";
|
|
|
|
output << "clear simulate.dll;\n";
|
|
|
|
}
|
2007-10-04 00:01:08 +02:00
|
|
|
}
|
2007-02-22 00:28:16 +01:00
|
|
|
else
|
2007-10-04 00:01:08 +02:00
|
|
|
{
|
2007-11-21 00:24:01 +01:00
|
|
|
//output << "oo_.endo_simul=" << basename << "_dynamic();\n";
|
|
|
|
output << basename << "_dynamic;\n";
|
2007-10-04 00:01:08 +02:00
|
|
|
}
|
2007-02-22 00:28:16 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
StochSimulStatement::StochSimulStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg),
|
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-15 12:44:58 +01:00
|
|
|
void
|
|
|
|
StochSimulStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.stoch_simul_or_similar_present = true;
|
2007-02-08 12:56:46 +01:00
|
|
|
|
|
|
|
// Fill in option_order of mod_file_struct
|
|
|
|
OptionsList::num_options_type::const_iterator it = options_list.num_options.find("order");
|
|
|
|
if (it != options_list.num_options.end())
|
|
|
|
mod_file_struct.order_option = atoi(it->second.c_str());
|
2006-12-15 12:44:58 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
StochSimulStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
|
|
|
tmp_symbol_table.writeOutput("var_list_", output);
|
|
|
|
output << "stoch_simul(var_list_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2007-01-04 15:42:27 +01:00
|
|
|
RamseyPolicyStatement::RamseyPolicyStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
2007-02-05 10:55:41 +01:00
|
|
|
const OptionsList &options_list_arg) :
|
2007-01-04 15:42:27 +01:00
|
|
|
tmp_symbol_table(tmp_symbol_table_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RamseyPolicyStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.stoch_simul_or_similar_present = true;
|
2007-02-08 12:56:46 +01:00
|
|
|
|
2007-04-30 14:09:05 +02:00
|
|
|
/* Fill in option_order of mod_file_struct
|
|
|
|
Since ramsey policy needs one further order of derivation (for example, for 1st order
|
|
|
|
approximation, it needs 2nd derivatives), we add 1 to the order declared by user */
|
2007-02-08 12:56:46 +01:00
|
|
|
OptionsList::num_options_type::const_iterator it = options_list.num_options.find("order");
|
|
|
|
if (it != options_list.num_options.end())
|
2007-03-10 21:41:35 +01:00
|
|
|
mod_file_struct.order_option = atoi(it->second.c_str()) + 1;
|
2007-01-04 15:42:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RamseyPolicyStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
tmp_symbol_table.writeOutput("var_list_", output);
|
2007-06-17 15:06:50 +02:00
|
|
|
output << "ramsey_policy(var_list_);\n";
|
2007-01-04 15:42:27 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
EstimationStatement::EstimationStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg),
|
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-15 12:44:58 +01:00
|
|
|
void
|
|
|
|
EstimationStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.stoch_simul_or_similar_present = true;
|
2007-02-08 12:56:46 +01:00
|
|
|
|
|
|
|
// Fill in option_order of mod_file_struct
|
|
|
|
OptionsList::num_options_type::const_iterator it = options_list.num_options.find("order");
|
|
|
|
if (it != options_list.num_options.end())
|
|
|
|
mod_file_struct.order_option = atoi(it->second.c_str());
|
2006-12-15 12:44:58 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
EstimationStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
|
|
|
tmp_symbol_table.writeOutput("var_list_", output);
|
|
|
|
output << "dynare_estimation(var_list_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
PriorAnalysisStatement::PriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
PriorAnalysisStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
tmp_symbol_table.writeOutput("var_list_", output);
|
|
|
|
output << "prior_analysis(var_list_);\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
PosteriorAnalysisStatement::PosteriorAnalysisStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
PosteriorAnalysisStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
tmp_symbol_table.writeOutput("var_list_", output);
|
|
|
|
output << "posterior_analysis(var_list_);\n";
|
|
|
|
}
|
2006-11-05 00:31:17 +01:00
|
|
|
|
2007-10-02 16:05:16 +02:00
|
|
|
DynareSensitivityStatement::DynareSensitivityStatement(const OptionsList &options_list_arg) :
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DynareSensitivityStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "dynare_sensitivity;" << endl;
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
RplotStatement::RplotStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg),
|
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
RplotStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
|
|
|
tmp_symbol_table.writeOutput("var_list_", output);
|
|
|
|
output << "rplot(var_list_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
UnitRootVarsStatement::UnitRootVarsStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
UnitRootVarsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
tmp_symbol_table.writeOutput("options_.unit_root_vars", output);
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
PeriodsStatement::PeriodsStatement(int periods_arg) : periods(periods_arg)
|
2006-11-25 18:55:02 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
PeriodsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-25 18:55:02 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "options_.periods = " << periods << ";" << endl;
|
|
|
|
output << "options_.simul = 1;" << endl;
|
2006-11-25 18:55:02 +01:00
|
|
|
}
|
|
|
|
|
2007-06-01 13:43:49 +02:00
|
|
|
CutoffStatement::CutoffStatement(double cutoff_arg) : cutoff(cutoff_arg)
|
2007-02-22 00:28:16 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CutoffStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
output << "options_.cutoff = " << cutoff << ";" << endl;
|
|
|
|
}
|
|
|
|
|
2007-06-04 00:35:30 +02:00
|
|
|
MarkowitzStatement::MarkowitzStatement(double markowitz_arg) : markowitz(markowitz_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MarkowitzStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
output << "options_.markowitz = " << markowitz << ";" << endl;
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
DsampleStatement::DsampleStatement(int val1_arg) : val1(val1_arg), val2(-1)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
DsampleStatement::DsampleStatement(int val1_arg, int val2_arg) : val1(val1_arg), val2(val2_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
DsampleStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
if (val2 < 0)
|
|
|
|
output << "options_.dsample = " << val1 << ";" << endl;
|
|
|
|
else
|
|
|
|
output << "options_.dsample = [" << val1 << "; " << val2 << "];" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
VarobsStatement::VarobsStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
VarobsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
tmp_symbol_table.writeOutput("options_.varobs", output);
|
|
|
|
}
|
|
|
|
|
|
|
|
EstimatedParamsStatement::EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
estim_params_list(estim_params_list_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
output << "global estim_params_\n";
|
|
|
|
output << "var_list_ = [];\n";
|
|
|
|
output << "estim_params_.var_exo = [];\n";
|
|
|
|
output << "estim_params_.var_endo = [];\n";
|
|
|
|
output << "estim_params_.corrx = [];\n";
|
|
|
|
output << "estim_params_.corrn = [];\n";
|
|
|
|
output << "estim_params_.param_names = [];\n";
|
|
|
|
output << "estim_params_.user_param_names = [];\n";
|
|
|
|
output << "estim_params_.param_vals = [];\n";
|
|
|
|
output << "M_.H = 0;\n";
|
|
|
|
|
|
|
|
vector<EstimationParams>::const_iterator it;
|
|
|
|
|
|
|
|
for(it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
switch(it->type)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
case 1:
|
|
|
|
if (symbol_table.getType(it->name) == eExogenous)
|
|
|
|
output << "estim_params_.var_exo = [estim_params_.var_exo; ";
|
|
|
|
else if (symbol_table.getType(it->name) == eEndogenous)
|
|
|
|
output << "estim_params_.var_endo = [estim_params_.var_endo; ";
|
|
|
|
output << symbol_table.getID(it->name)+1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
output << "estim_params_.param_vals = [estim_params_.param_vals; ";
|
|
|
|
output << symbol_table.getID(it->name)+1;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (symbol_table.getType(it->name) == eExogenous)
|
|
|
|
output << "estim_params_.corrx = [estim_params_.corrx; ";
|
|
|
|
else if (symbol_table.getType(it->name) == eEndogenous)
|
|
|
|
output << "estim_params_.corrn = [estim_params_.corrn; ";
|
|
|
|
output << symbol_table.getID(it->name)+1;
|
|
|
|
output << " " << symbol_table.getID(it->name2)+1;
|
|
|
|
break;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
output << " " << it->init_val << " " << it->low_bound
|
|
|
|
<< " " << it->up_bound << " " << it->prior
|
|
|
|
<< " " << it->mean << " " << it->std
|
|
|
|
<< " " << it->p3 << " " << it->p4 << " " << it->jscale << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
EstimatedParamsInitStatement::EstimatedParamsInitStatement(const vector<EstimationParams> &estim_params_list_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
estim_params_list(estim_params_list_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
vector<EstimationParams>::const_iterator it;
|
|
|
|
|
|
|
|
for(it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
if (it->type < 3)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
if (symbol_table.getType(it->name) == eExogenous)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find(estim_params_.var_exo(:,1)==" << symbol_table.getID(it->name)+1 << ");\n";
|
|
|
|
output << "estim_params_.var_exo(tmp1,2) = " << it->init_val << ";\n";
|
|
|
|
}
|
|
|
|
else if (symbol_table.getType(it->name) == eEndogenous)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find(estim_params_.var_endo(:,1)==" << symbol_table.getID(it->name)+1 << ");\n";
|
|
|
|
output << "estim_params_.var_endo(tmp1,2) = " << it->init_val << ";\n";
|
|
|
|
}
|
|
|
|
else if (symbol_table.getType(it->name) == eParameter)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find(estim_params_.param_vals(:,1)==" << symbol_table.getID(it->name)+1 << ");\n";
|
|
|
|
output << "estim_params_.param_vals(tmp1,2) = " << it->init_val << ";\n";
|
|
|
|
}
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
else
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
if (symbol_table.getType(it->name) == eExogenous)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find((estim_params_.corrx(:,1)==" << symbol_table.getID(it->name)+1 << ")) & (estim_params_.corrx(:,2)==" << symbol_table.getID(it->name2)+1 << ");\n";
|
|
|
|
output << "estim_params_.corrx(tmp1,3) = " << it->init_val << ";\n";
|
|
|
|
}
|
|
|
|
else if (symbol_table.getType(it->name) == eEndogenous)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find((estim_params_.corrn(:,1)==" << symbol_table.getID(it->name)+1 << ")) & (estim_params_.corrn(:,2)==" << symbol_table.getID(it->name2)+1 << ";\n";
|
|
|
|
output << "estim_params_.corrx(tmp1,3) = " << it->init_val << ";\n";
|
|
|
|
}
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
EstimatedParamsBoundsStatement::EstimatedParamsBoundsStatement(const vector<EstimationParams> &estim_params_list_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
estim_params_list(estim_params_list_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
vector<EstimationParams>::const_iterator it;
|
|
|
|
|
|
|
|
for(it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
if (it->type < 3)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
if (symbol_table.getType(it->name) == eExogenous)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find(estim_params_.var_exo(:,1)==" << symbol_table.getID(it->name)+1 << ");\n";
|
|
|
|
output << "estim_params_.var_exo(tmp1,3) = " << it->low_bound << ";\n";
|
|
|
|
output << "estim_params_.var_exo(tmp1,4) = " << it->up_bound << ";\n";
|
|
|
|
}
|
|
|
|
else if (symbol_table.getType(it->name) == eEndogenous)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find(estim_params_.var_endo(:,1)==" << symbol_table.getID(it->name)+1 << ");\n";
|
|
|
|
output << "estim_params_.var_endo(tmp1,3) = " << it->low_bound << ";\n";
|
|
|
|
output << "estim_params_.var_endo(tmp1,4) = " << it->up_bound << ";\n";
|
|
|
|
}
|
|
|
|
else if (symbol_table.getType(it->name) == eParameter)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find(estim_params_.param_vals(:,1)==" << symbol_table.getID(it->name)+1 << ");\n";
|
|
|
|
output << "estim_params_.param_vals(tmp1,3) = " << it->low_bound << ";\n";
|
|
|
|
output << "estim_params_.param_vals(tmp1,4) = " << it->up_bound << ";\n";
|
|
|
|
}
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
else
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
if (symbol_table.getType(it->name) == eExogenous)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find((estim_params_.corrx(:,1)==" << symbol_table.getID(it->name)+1 << ")) & (estim_params_.corrx(:,2)==" << symbol_table.getID(it->name2)+1 << ");\n";
|
|
|
|
output << "estim_params_.corrx(tmp1,4) = " << it->low_bound << ";\n";
|
|
|
|
output << "estim_params_.corrx(tmp1,5) = " << it->up_bound << ";\n";
|
|
|
|
}
|
|
|
|
else if (symbol_table.getType(it->name) == eEndogenous)
|
|
|
|
{
|
|
|
|
output << "tmp1 = find((estim_params_.corrn(:,1)==" << symbol_table.getID(it->name)+1 << ")) & (estim_params_.corrn(:,2)==" << symbol_table.getID(it->name2)+1 << ";\n";
|
|
|
|
output << "estim_params_.corrx(tmp1,4) = " << it->low_bound << ";\n";
|
|
|
|
output << "estim_params_.corrx(tmp1,5) = " << it->up_bound << ";\n";
|
|
|
|
}
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ObservationTrendsStatement::ObservationTrendsStatement(const trend_elements_type &trend_elements_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
trend_elements(trend_elements_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
ObservationTrendsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
output << "options_.trend_coeff_ = {};" << endl;
|
|
|
|
|
|
|
|
trend_elements_type::const_iterator it;
|
|
|
|
|
|
|
|
for(it = trend_elements.begin(); it != trend_elements.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
Type type = symbol_table.getType(it->first);
|
|
|
|
if (type == eEndogenous)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "tmp1 = strmatch('" << it->first << "',options_.varobs,'exact');\n";
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "options_.trend_coeffs{tmp1} = '";
|
|
|
|
it->second->writeOutput(output);
|
|
|
|
output << "';" << endl;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
else
|
|
|
|
cout << "Error : Non-variable symbol used in TREND_COEFF: " << it->first << endl;
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
CalibVarStatement::CalibVarStatement(const calib_var_type &calib_var_arg,
|
|
|
|
const calib_covar_type &calib_covar_arg,
|
|
|
|
const calib_ac_type &calib_ac_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
calib_var(calib_var_arg),
|
|
|
|
calib_covar(calib_covar_arg),
|
|
|
|
calib_ac(calib_ac_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
CalibVarStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
output << interfaces::comment() << "\n" << interfaces::comment() << "CALIB_VAR \n"
|
|
|
|
<< interfaces::comment() << "\n";
|
|
|
|
|
|
|
|
for(int i = 1; i < 4 ; i++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "calib_var_index{" << i << "} = [];\n";
|
|
|
|
output << "calib_targets{" << i << "} = [];\n";
|
|
|
|
output << "calib_weights{" << i << "}=[];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
|
|
|
|
// Print calibration variances
|
|
|
|
for(calib_var_type::const_iterator it = calib_var.begin();
|
|
|
|
it != calib_var.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
const string &name = it->first;
|
|
|
|
const string &weight = it->second.first;
|
2007-03-09 18:27:46 +01:00
|
|
|
const NodeID expression = it->second.second;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
|
|
|
int id = symbol_table.getID(name) + 1;
|
|
|
|
if (symbol_table.getType(name) == eEndogenous)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "calib_var_index{1} = [calib_var_index{1};" << id << "," << id << "];\n";
|
|
|
|
output << "calib_weights{1} = [calib_weights{1}; " << weight << "];\n";
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "calib_targets{1} =[calib_targets{1}; ";
|
|
|
|
expression->writeOutput(output);
|
|
|
|
output << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
else if (symbol_table.getType(name) == eExogenous)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "calib_var_index{3} = [calib_var_index{3};" << id << "," << id << "];\n";
|
|
|
|
output << "calib_weights{3} = [calib_weights{3}; " << weight << "];\n";
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "calib_targets{3} =[calib_targets{3}; ";
|
|
|
|
expression->writeOutput(output);
|
|
|
|
output << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
|
|
|
|
// Print calibration covariances
|
|
|
|
for(calib_covar_type::const_iterator it = calib_covar.begin();
|
|
|
|
it != calib_covar.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
const string &name1 = it->first.first;
|
|
|
|
const string &name2 = it->first.second;
|
|
|
|
const string &weight = it->second.first;
|
2007-03-09 18:27:46 +01:00
|
|
|
const NodeID expression = it->second.second;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
|
|
|
int id1 = symbol_table.getID(name1) + 1;
|
|
|
|
int id2 = symbol_table.getID(name2) + 1;
|
|
|
|
if (symbol_table.getType(name1) == eEndogenous)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "calib_var_index{1} = [calib_var_index{1};" << id1 << "," << id2 << "];\n";
|
|
|
|
output << "calib_weights{1} = [calib_weights{1}; " << weight << "];\n";
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "calib_targets{1} =[calib_targets{1}; ";
|
|
|
|
expression->writeOutput(output);
|
|
|
|
output << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
else if (symbol_table.getType(name1) == eExogenous)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "calib_var_index{3} = [calib_var_index{3};" << id1 << "," << id2 << "];\n";
|
|
|
|
output << "calib_weights{3} = [calib_weights{3}; " << weight << "];\n";
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "calib_targets{3} =[calib_targets{3}; ";
|
|
|
|
expression->writeOutput(output);
|
|
|
|
output << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
// Print calibration autocorrelations
|
|
|
|
int max_iar = 3;
|
|
|
|
|
|
|
|
for(calib_ac_type::const_iterator it = calib_ac.begin();
|
|
|
|
it != calib_ac.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
const string &name = it->first.first;
|
|
|
|
int iar = it->first.second + 3;
|
|
|
|
const string &weight = it->second.first;
|
2007-03-09 18:27:46 +01:00
|
|
|
const NodeID expression = it->second.second;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
|
|
|
int id = symbol_table.getID(name) + 1;
|
|
|
|
|
|
|
|
if (iar > max_iar)
|
|
|
|
{
|
|
|
|
// Create new variables
|
|
|
|
for(int i = max_iar + 1; i <= iar; i++)
|
|
|
|
{
|
|
|
|
output << "calib_var_index{" << i << "} = [];\n";
|
|
|
|
output << "calib_targets{" << i << "} = [];\n";
|
|
|
|
output << "calib_weights{" << i << "}=[];\n";
|
|
|
|
}
|
|
|
|
max_iar = iar;
|
|
|
|
}
|
|
|
|
|
|
|
|
output << "calib_var_index{" << iar << "} = [calib_var_index{" << iar << "};" << id << "];\n";
|
|
|
|
output << "calib_weights{" << iar << "} = [calib_weights{" << iar << "}; " << weight << "];\n";
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "calib_targets{" << iar << "} =[calib_targets{" << iar << "}; ";
|
|
|
|
expression->writeOutput(output);
|
|
|
|
output << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
CalibStatement::CalibStatement(int covar_arg) : covar(covar_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
CalibStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "M_.Sigma_e=calib(calib_var_index,calib_targets,calib_weights," << covar << ",Sigma_e_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
OsrParamsStatement::OsrParamsStatement(const TmpSymbolTable &tmp_symbol_table_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
OsrParamsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
tmp_symbol_table.writeOutput("osr_params_", output);
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
OsrStatement::OsrStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg),
|
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-15 12:44:58 +01:00
|
|
|
void
|
|
|
|
OsrStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
|
|
|
mod_file_struct.stoch_simul_or_similar_present = true;
|
2007-02-08 12:56:46 +01:00
|
|
|
|
|
|
|
// Fill in option_order of mod_file_struct
|
|
|
|
OptionsList::num_options_type::const_iterator it = options_list.num_options.find("order");
|
|
|
|
if (it != options_list.num_options.end())
|
|
|
|
mod_file_struct.order_option = atoi(it->second.c_str());
|
2006-12-15 12:44:58 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
OsrStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
options_list.writeOutput(output);
|
|
|
|
tmp_symbol_table.writeOutput("var_list_", output);
|
|
|
|
output << "osr(var_list_,osr_params_,obj_var_,optim_weights_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
OptimWeightsStatement::OptimWeightsStatement(const var_weights_type &var_weights_arg,
|
|
|
|
const covar_weights_type &covar_weights_arg,
|
|
|
|
const SymbolTable &symbol_table_arg) :
|
|
|
|
var_weights(var_weights_arg),
|
|
|
|
covar_weights(covar_weights_arg),
|
|
|
|
symbol_table(symbol_table_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
OptimWeightsStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
output << interfaces::comment() << "OPTIM_WEIGHTS\n\n";
|
|
|
|
output << "optim_weights_ = sparse(M_.endo_nbr,M_.endo_nbr);\n";
|
|
|
|
output << "obj_var_ = [];\n\n";
|
|
|
|
|
|
|
|
for(var_weights_type::const_iterator it = var_weights.begin();
|
|
|
|
it != var_weights.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
const string &name = it->first;
|
2007-03-09 18:27:46 +01:00
|
|
|
const NodeID value = it->second;
|
2006-12-12 12:54:30 +01:00
|
|
|
int id = symbol_table.getID(name) + 1;
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "optim_weights_(" << id << "," << id << ") = ";
|
|
|
|
value->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "obj_var_ = [obj_var_; " << id << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
2006-12-12 12:54:30 +01:00
|
|
|
|
|
|
|
for(covar_weights_type::const_iterator it = covar_weights.begin();
|
|
|
|
it != covar_weights.end(); it++)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
const string &name1 = it->first.first;
|
|
|
|
const string &name2 = it->first.second;
|
2007-03-09 18:27:46 +01:00
|
|
|
const NodeID value = it->second;
|
2006-12-12 12:54:30 +01:00
|
|
|
int id1 = symbol_table.getID(name1) + 1;
|
|
|
|
int id2 = symbol_table.getID(name2) + 1;
|
2007-03-09 18:27:46 +01:00
|
|
|
output << "optim_weights_(" << id1 << "," << id2 << ") = ";
|
|
|
|
value->writeOutput(output);
|
|
|
|
output << ";" << endl;
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "obj_var_ = [obj_var_; " << id1 << " " << id2 << "];\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
DynaSaveStatement::DynaSaveStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|
|
|
const string &filename_arg, const string &ext_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg),
|
|
|
|
filename(filename_arg),
|
|
|
|
ext(ext_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
DynaSaveStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
tmp_symbol_table.writeOutput("var_list_", output);
|
|
|
|
output << "dynasave(" << filename;
|
2006-11-05 00:31:17 +01:00
|
|
|
if (ext.size() > 0)
|
2006-12-12 12:54:30 +01:00
|
|
|
output << "," << ext;
|
|
|
|
output << ",var_list_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
DynaTypeStatement::DynaTypeStatement(const TmpSymbolTable &tmp_symbol_table_arg,
|
|
|
|
const string &filename_arg, const string &ext_arg) :
|
|
|
|
tmp_symbol_table(tmp_symbol_table_arg),
|
|
|
|
filename(filename_arg),
|
|
|
|
ext(ext_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
DynaTypeStatement::writeOutput(ostream &output, const string &basename) const
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
2006-12-12 12:54:30 +01:00
|
|
|
tmp_symbol_table.writeOutput("var_list_", output);
|
|
|
|
output << "dynatype(" << filename;
|
|
|
|
if (ext.size() > 0)
|
|
|
|
output << "," << ext;
|
|
|
|
output << ",var_list_);\n";
|
2006-11-05 00:31:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
ModelComparisonStatement::ModelComparisonStatement(const filename_list_type &filename_list_arg,
|
|
|
|
const OptionsList &options_list_arg) :
|
|
|
|
filename_list(filename_list_arg),
|
|
|
|
options_list(options_list_arg)
|
2006-11-05 00:31:17 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
void
|
2006-12-19 00:28:52 +01:00
|
|
|
ModelComparisonStatement::writeOutput(ostream &output, const string &basename) const
|
2006-12-12 12:54:30 +01:00
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
|
|
|
|
output << "ModelNames_ = {};\n";
|
|
|
|
output << "ModelPriors_ = {};\n";
|
|
|
|
|
|
|
|
for(filename_list_type::const_iterator it = filename_list.begin();
|
|
|
|
it != filename_list.end(); it++)
|
|
|
|
{
|
|
|
|
output << "ModelNames_ = { ModelNames_{:} '" << it->first << "};\n";
|
|
|
|
output << "ModelPriors_ = { ModelPriors_{:} '" << it->second << "};\n";
|
|
|
|
}
|
|
|
|
output << "model_comparison(ModelNames_,ModelPriors_);\n";
|
|
|
|
}
|
2006-12-19 00:28:52 +01:00
|
|
|
|
|
|
|
PlannerObjectiveStatement::PlannerObjectiveStatement(ModelTree *model_tree_arg) :
|
|
|
|
model_tree(model_tree_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PlannerObjectiveStatement::~PlannerObjectiveStatement()
|
|
|
|
{
|
|
|
|
delete model_tree;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlannerObjectiveStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
|
|
{
|
2007-07-16 18:47:09 +02:00
|
|
|
if (model_tree->equation_number() != 1)
|
|
|
|
{
|
|
|
|
cerr << "Error: planer_objective: should have only one equation!" << endl;
|
|
|
|
exit(-1);
|
|
|
|
}
|
2006-12-19 00:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlannerObjectiveStatement::computingPass()
|
|
|
|
{
|
|
|
|
model_tree->computeStaticHessian = true;
|
2007-03-09 18:27:46 +01:00
|
|
|
model_tree->computingPass(eval_context_type());
|
2006-12-19 00:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
model_tree->writeStaticFile(basename + "_objective");
|
|
|
|
}
|
2007-06-26 00:42:30 +02:00
|
|
|
|
|
|
|
BVARDensityStatement::BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg) :
|
|
|
|
maxnlags(maxnlags_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BVARDensityStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "bvar_density(" << maxnlags << ");" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
BVARForecastStatement::BVARForecastStatement(int nlags_arg, const OptionsList &options_list_arg) :
|
|
|
|
nlags(nlags_arg),
|
|
|
|
options_list(options_list_arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BVARForecastStatement::writeOutput(ostream &output, const string &basename) const
|
|
|
|
{
|
|
|
|
options_list.writeOutput(output);
|
|
|
|
output << "bvar_forecast(" << nlags << ");" << endl;
|
|
|
|
}
|