Merge branch 'master' into json
commit
1b3cccb602
|
@ -470,7 +470,7 @@ RamseyConstraintsStatement::writeOutput(ostream &output, const string &basename,
|
|||
break;
|
||||
default:
|
||||
cerr << "Ramsey constraints: this shouldn't happen." << endl;
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
output << "', '";
|
||||
it->expression->writeOutput(output);
|
||||
|
@ -1094,9 +1094,7 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, b
|
|||
<< "estim_params_.corrn = [];" << endl
|
||||
<< "estim_params_.param_vals = [];" << endl;
|
||||
|
||||
vector<EstimationParams>::const_iterator it;
|
||||
|
||||
for (it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
||||
for (vector<EstimationParams>::const_iterator it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
||||
{
|
||||
int symb_id = symbol_table.getTypeSpecificID(it->name) + 1;
|
||||
SymbolType symb_type = symbol_table.getType(it->name);
|
||||
|
@ -1214,9 +1212,7 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam
|
|||
if (use_calibration)
|
||||
output << "options_.use_calibration_initialization = 1;" << endl;
|
||||
|
||||
vector<EstimationParams>::const_iterator it;
|
||||
|
||||
for (it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
||||
for (vector<EstimationParams>::const_iterator it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
||||
{
|
||||
int symb_id = symbol_table.getTypeSpecificID(it->name) + 1;
|
||||
SymbolType symb_type = symbol_table.getType(it->name);
|
||||
|
@ -1313,9 +1309,7 @@ EstimatedParamsBoundsStatement::EstimatedParamsBoundsStatement(const vector<Esti
|
|||
void
|
||||
EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
vector<EstimationParams>::const_iterator it;
|
||||
|
||||
for (it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
||||
for (vector<EstimationParams>::const_iterator it = estim_params_list.begin(); it != estim_params_list.end(); it++)
|
||||
{
|
||||
int symb_id = symbol_table.getTypeSpecificID(it->name) + 1;
|
||||
SymbolType symb_type = symbol_table.getType(it->name);
|
||||
|
@ -1436,10 +1430,7 @@ void
|
|||
ObservationTrendsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
output << "options_.trend_coeff = {};" << endl;
|
||||
|
||||
trend_elements_t::const_iterator it;
|
||||
|
||||
for (it = trend_elements.begin(); it != trend_elements.end(); it++)
|
||||
for (trend_elements_t::const_iterator it = trend_elements.begin(); it != trend_elements.end(); it++)
|
||||
{
|
||||
SymbolType type = symbol_table.getType(it->first);
|
||||
if (type == eEndogenous)
|
||||
|
@ -1450,7 +1441,7 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename,
|
|||
output << "';" << endl;
|
||||
}
|
||||
else
|
||||
cout << "Error : Non-variable symbol used in TREND_COEFF: " << it->first << endl;
|
||||
cerr << "Warning : Non-variable symbol used in observation_trends: " << it->first << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -800,7 +800,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen
|
|||
code_file.open(main_name.c_str(), ios::out | ios::binary | ios::ate);
|
||||
if (!code_file.is_open())
|
||||
{
|
||||
cout << "Error : Can't open file \"" << main_name << "\" for writing\n";
|
||||
cerr << "Error : Can't open file \"" << main_name << "\" for writing" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -1076,7 +1076,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
|
|||
code_file.open(main_name.c_str(), ios::out | ios::binary | ios::ate);
|
||||
if (!code_file.is_open())
|
||||
{
|
||||
cout << "Error : Can't open file \"" << main_name << "\" for writing\n";
|
||||
cerr << "Error : Can't open file \"" << main_name << "\" for writing" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
//Temporary variables declaration
|
||||
|
@ -1768,7 +1768,7 @@ DynamicModel::Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const
|
|||
SaveCode.open((bin_basename + "_dynamic.bin").c_str(), ios::out | ios::binary);
|
||||
if (!SaveCode.is_open())
|
||||
{
|
||||
cout << "Error : Can't open file \"" << bin_basename << "_dynamic.bin\" for writing\n";
|
||||
cerr << "Error : Can't open file \"" << bin_basename << "_dynamic.bin\" for writing" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
u_count_int = 0;
|
||||
|
@ -3252,8 +3252,8 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
|
|||
if (!no_tmp_terms)
|
||||
computeTemporaryTermsOrdered();
|
||||
int k = 0;
|
||||
equation_block = vector<int>(equation_number());
|
||||
variable_block_lead_lag = vector< pair< int, pair< int, int> > >(equation_number());
|
||||
equation_block = vector<int>(equations.size());
|
||||
variable_block_lead_lag = vector< pair< int, pair< int, int> > >(equations.size());
|
||||
for (unsigned int i = 0; i < getNbBlocks(); i++)
|
||||
{
|
||||
for (unsigned int j = 0; j < getBlockSize(i); j++)
|
||||
|
@ -4210,10 +4210,10 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
|
|||
<< "% from model file (.mod)" << endl << endl
|
||||
<< model_local_vars_output.str()
|
||||
<< model_output.str()
|
||||
<< "rp = zeros(" << equation_number() << ", "
|
||||
<< "rp = zeros(" << equations.size() << ", "
|
||||
<< symbol_table.param_nbr() << ");" << endl
|
||||
<< jacobian_output.str()
|
||||
<< "gp = zeros(" << equation_number() << ", " << dynJacobianColsNbr << ", " << symbol_table.param_nbr() << ");" << endl
|
||||
<< "gp = zeros(" << equations.size() << ", " << dynJacobianColsNbr << ", " << symbol_table.param_nbr() << ");" << endl
|
||||
<< hessian_output.str()
|
||||
<< "if nargout >= 3" << endl
|
||||
<< "rpp = zeros(" << residuals_params_second_derivatives.size() << ",4);" << endl
|
||||
|
@ -4238,10 +4238,10 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
|
|||
<< "ss_param_deriv, ss_param_2nd_deriv)" << endl
|
||||
<< model_local_vars_output.str()
|
||||
<< model_output.str()
|
||||
<< "rp = zeros(" << equation_number() << ", "
|
||||
<< "rp = zeros(" << equations.size() << ", "
|
||||
<< symbol_table.param_nbr() << ");" << endl
|
||||
<< jacobian_output.str()
|
||||
<< "gp = zeros(" << equation_number() << ", " << dynJacobianColsNbr << ", " << symbol_table.param_nbr() << ");" << endl
|
||||
<< "gp = zeros(" << equations.size() << ", " << dynJacobianColsNbr << ", " << symbol_table.param_nbr() << ");" << endl
|
||||
<< hessian_output.str()
|
||||
<< "rpp = zeros(" << residuals_params_second_derivatives.size() << ",4);" << endl
|
||||
<< hessian1_output.str()
|
||||
|
@ -5012,7 +5012,7 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons
|
|||
break;
|
||||
default:
|
||||
std::cerr << "This case shouldn't happen" << std::endl;
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
derivative deriv(col_id + eq*cols_nbr,col_id,eq,it->second);
|
||||
D.push_back(deriv);
|
||||
|
|
|
@ -113,6 +113,7 @@ class ParsingDriver;
|
|||
%token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW
|
||||
%token FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
|
||||
%token <string_val> NAME
|
||||
%token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN
|
||||
%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY
|
||||
%token NOGRAPH POSTERIOR_NOGRAPH POSTERIOR_GRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS
|
||||
%token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS OVERWRITE
|
||||
|
@ -1825,6 +1826,7 @@ estimation_options : o_datafile
|
|||
| o_posterior_sampling_method
|
||||
| o_posterior_sampler_options
|
||||
| o_keep_kalman_algo_if_singularity_is_detected
|
||||
| o_use_penalized_objective_for_hessian
|
||||
;
|
||||
|
||||
list_optim_option : QUOTED_STRING COMMA QUOTED_STRING
|
||||
|
@ -3232,6 +3234,7 @@ o_mcmc_jumping_covariance : MCMC_JUMPING_COVARIANCE EQUAL HESSIAN
|
|||
| MCMC_JUMPING_COVARIANCE EQUAL filename
|
||||
{ driver.option_str("MCMC_jumping_covariance", $3); }
|
||||
;
|
||||
o_use_penalized_objective_for_hessian : USE_PENALIZED_OBJECTIVE_FOR_HESSIAN { driver.option_num("hessian.use_penalized_objective","true"); };
|
||||
o_irf_plot_threshold : IRF_PLOT_THRESHOLD EQUAL non_negative_number { driver.option_num("impulse_responses.plot_threshold", $3); };
|
||||
o_dr_display_tol : DR_DISPLAY_TOL EQUAL non_negative_number { driver.option_num("dr_display_tol", $3); };
|
||||
o_consider_all_endogenous : CONSIDER_ALL_ENDOGENOUS { driver.option_str("endo_vars_for_moment_computations_in_estimation", "all_endogenous_variables"); };
|
||||
|
|
|
@ -400,6 +400,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
|||
<DYNARE_STATEMENT>distribution_approximation {return token::DISTRIBUTION_APPROXIMATION;}
|
||||
<DYNARE_STATEMENT>proposal_distribution {return token::PROPOSAL_DISTRIBUTION;}
|
||||
<DYNARE_STATEMENT>no_posterior_kernel_density {return token::NO_POSTERIOR_KERNEL_DENSITY;}
|
||||
<DYNARE_STATEMENT>use_penalized_objective_for_hessian {return token::USE_PENALIZED_OBJECTIVE_FOR_HESSIAN;}
|
||||
|
||||
<DYNARE_STATEMENT>alpha {
|
||||
yylval->string_val = new string(yytext);
|
||||
|
|
22
ModelTree.cc
22
ModelTree.cc
|
@ -36,7 +36,7 @@ using namespace MFS;
|
|||
bool
|
||||
ModelTree::computeNormalization(const jacob_map_t &contemporaneous_jacobian, bool verbose)
|
||||
{
|
||||
const int n = equation_number();
|
||||
const int n = equations.size();
|
||||
|
||||
assert(n == symbol_table.endo_nbr());
|
||||
|
||||
|
@ -96,7 +96,7 @@ ModelTree::computeNormalization(const jacob_map_t &contemporaneous_jacobian, boo
|
|||
#endif
|
||||
|
||||
// Create the resulting map, by copying the n first elements of mate_map, and substracting n to them
|
||||
endo2eq.resize(equation_number());
|
||||
endo2eq.resize(equations.size());
|
||||
transform(mate_map.begin(), mate_map.begin() + n, endo2eq.begin(), bind2nd(minus<int>(), n));
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -143,7 +143,7 @@ ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian
|
|||
|
||||
cout << "Normalizing the model..." << endl;
|
||||
|
||||
int n = equation_number();
|
||||
int n = equations.size();
|
||||
|
||||
// compute the maximum value of each row of the contemporaneous Jacobian matrix
|
||||
//jacob_map normalized_contemporaneous_jacobian;
|
||||
|
@ -329,7 +329,7 @@ ModelTree::writeRevXrefs(ostream &output, const map<int, set<int> > &xrefmap, co
|
|||
void
|
||||
ModelTree::computeNormalizedEquations(multimap<int, int> &endo2eqs) const
|
||||
{
|
||||
for (int i = 0; i < equation_number(); i++)
|
||||
for (int i = 0; i < equations.size(); i++)
|
||||
{
|
||||
VariableNode *lhs = dynamic_cast<VariableNode *>(equations[i]->get_arg1());
|
||||
if (lhs == NULL)
|
||||
|
@ -417,11 +417,11 @@ ModelTree::evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_m
|
|||
void
|
||||
ModelTree::computePrologueAndEpilogue(const jacob_map_t &static_jacobian_arg, vector<int> &equation_reordered, vector<int> &variable_reordered)
|
||||
{
|
||||
vector<int> eq2endo(equation_number(), 0);
|
||||
equation_reordered.resize(equation_number());
|
||||
variable_reordered.resize(equation_number());
|
||||
vector<int> eq2endo(equations.size(), 0);
|
||||
equation_reordered.resize(equations.size());
|
||||
variable_reordered.resize(equations.size());
|
||||
bool *IM;
|
||||
int n = equation_number();
|
||||
int n = equations.size();
|
||||
IM = (bool *) calloc(n*n, sizeof(bool));
|
||||
int i = 0;
|
||||
for (vector<int>::const_iterator it = endo2eq.begin(); it != endo2eq.end(); it++, i++)
|
||||
|
@ -1696,7 +1696,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &basename,
|
|||
SaveCode.open(bin_basename.c_str(), ios::out | ios::binary);
|
||||
if (!SaveCode.is_open())
|
||||
{
|
||||
cout << "Error : Can't open file \"" << bin_basename << "\" for writing\n";
|
||||
cerr << "Error : Can't open file \"" << bin_basename << "\" for writing" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
u_count_int = 0;
|
||||
|
@ -1799,7 +1799,7 @@ ModelTree::addEquation(expr_t eq, int lineno)
|
|||
void
|
||||
ModelTree::addEquation(expr_t eq, int lineno, vector<pair<string, string> > &eq_tags)
|
||||
{
|
||||
int n = equation_number();
|
||||
int n = equations.size();
|
||||
for (size_t i = 0; i < eq_tags.size(); i++)
|
||||
equation_tags.push_back(make_pair(n, eq_tags[i]));
|
||||
addEquation(eq, lineno);
|
||||
|
@ -1843,7 +1843,7 @@ ModelTree::addNonstationaryVariables(vector<int> nonstationary_vars, bool log_de
|
|||
void
|
||||
ModelTree::initializeVariablesAndEquations()
|
||||
{
|
||||
for (int j = 0; j < equation_number(); j++)
|
||||
for (int j = 0; j < equations.size(); j++)
|
||||
{
|
||||
equation_reordered.push_back(j);
|
||||
variable_reordered.push_back(j);
|
||||
|
|
|
@ -412,7 +412,7 @@ StaticModel::writeModelEquationsCode(const string file_name, const string bin_ba
|
|||
code_file.open(main_name.c_str(), ios::out | ios::binary | ios::ate);
|
||||
if (!code_file.is_open())
|
||||
{
|
||||
cout << "Error : Can't open file \"" << main_name << "\" for writing\n";
|
||||
cerr << "Error : Can't open file \"" << main_name << "\" for writing" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int count_u;
|
||||
|
@ -596,7 +596,7 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string
|
|||
code_file.open(main_name.c_str(), ios::out | ios::binary | ios::ate);
|
||||
if (!code_file.is_open())
|
||||
{
|
||||
cout << "Error : Can't open file \"" << main_name << "\" for writing\n";
|
||||
cerr << "Error : Can't open file \"" << main_name << "\" for writing" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
//Temporary variables declaration
|
||||
|
@ -990,7 +990,7 @@ StaticModel::Write_Inf_To_Bin_File_Block(const string &static_basename, const st
|
|||
SaveCode.open((bin_basename + "_static.bin").c_str(), ios::out | ios::binary);
|
||||
if (!SaveCode.is_open())
|
||||
{
|
||||
cout << "Error : Can't open file \"" << bin_basename << "_static.bin\" for writing\n";
|
||||
cerr << "Error : Can't open file \"" << bin_basename << "_static.bin\" for writing" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
u_count_int = 0;
|
||||
|
@ -2368,10 +2368,10 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
|
|||
<< "% from model file (.mod)" << endl << endl
|
||||
<< model_local_vars_output.str()
|
||||
<< model_output.str()
|
||||
<< "rp = zeros(" << equation_number() << ", "
|
||||
<< "rp = zeros(" << equations.size() << ", "
|
||||
<< symbol_table.param_nbr() << ");" << endl
|
||||
<< jacobian_output.str()
|
||||
<< "gp = zeros(" << equation_number() << ", " << symbol_table.endo_nbr() << ", "
|
||||
<< "gp = zeros(" << equations.size() << ", " << symbol_table.endo_nbr() << ", "
|
||||
<< symbol_table.param_nbr() << ");" << endl
|
||||
<< hessian_output.str()
|
||||
<< "if nargout >= 3" << endl
|
||||
|
@ -2396,10 +2396,10 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
|
|||
<< "function params_derivs(y, x, params)" << endl
|
||||
<< model_local_vars_output.str()
|
||||
<< model_output.str()
|
||||
<< "rp = zeros(" << equation_number() << ", "
|
||||
<< "rp = zeros(" << equations.size() << ", "
|
||||
<< symbol_table.param_nbr() << ");" << endl
|
||||
<< jacobian_output.str()
|
||||
<< "gp = zeros(" << equation_number() << ", " << symbol_table.endo_nbr() << ", "
|
||||
<< "gp = zeros(" << equations.size() << ", " << symbol_table.endo_nbr() << ", "
|
||||
<< symbol_table.param_nbr() << ");" << endl
|
||||
<< hessian_output.str()
|
||||
<< "rpp = zeros(" << residuals_params_second_derivatives.size() << ",4);" << endl
|
||||
|
|
|
@ -30,9 +30,6 @@ using namespace std;
|
|||
class StaticModel : public ModelTree
|
||||
{
|
||||
private:
|
||||
//! Temporary terms for the file containing parameters dervicatives
|
||||
temporary_terms_t params_derivs_temporary_terms;
|
||||
|
||||
//! global temporary terms for block decomposed models
|
||||
vector<vector<temporary_terms_t> > v_temporary_terms;
|
||||
|
||||
|
|
Loading…
Reference in New Issue