diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc index 73fc5ca896393c2207bb643f1a3f088d824e32c0..6f9208eaae4316d421f833febe36708341eac0c0 100644 --- a/src/ComputingTasks.cc +++ b/src/ComputingTasks.cc @@ -1373,7 +1373,7 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, b for (const auto &it : estim_params_list) { - int symb_id = symbol_table.getTypeSpecificID(it.name) + 1; + int tsid = symbol_table.getTypeSpecificID(it.name) + 1; SymbolType symb_type = symbol_table.getType(it.name); switch (it.type) @@ -1383,18 +1383,18 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, b output << "estim_params_.var_exo = [estim_params_.var_exo; "; else if (symb_type == SymbolType::endogenous) output << "estim_params_.var_endo = [estim_params_.var_endo; "; - output << symb_id; + output << tsid; break; case 2: output << "estim_params_.param_vals = [estim_params_.param_vals; " - << symb_id; + << tsid; break; case 3: if (symb_type == SymbolType::exogenous) output << "estim_params_.corrx = [estim_params_.corrx; "; else if (symb_type == SymbolType::endogenous) output << "estim_params_.corrn = [estim_params_.corrn; "; - output << symb_id << ", " << symbol_table.getTypeSpecificID(it.name2)+1; + output << tsid << ", " << symbol_table.getTypeSpecificID(it.name2)+1; break; } output << ", "; @@ -1493,77 +1493,78 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam for (const auto &it : estim_params_list) { - int symb_id = symbol_table.getTypeSpecificID(it.name) + 1; + int tsid = symbol_table.getTypeSpecificID(it.name) + 1; SymbolType symb_type = symbol_table.getType(it.name); if (it.type < 3) { if (symb_type == SymbolType::exogenous) { - output << "tmp1 = find(estim_params_.var_exo(:,1)==" << symb_id << ");" << endl; - output << "if isempty(tmp1)" << endl; - output << " disp(sprintf('The standard deviation of %s is not estimated (the value provided in estimated_params_init is not used).', M_.exo_names{" << symb_id << "}))" << endl; + output << "tmp1 = find(estim_params_.var_exo(:,1)==" << tsid << ");" << endl + << "if isempty(tmp1)" << endl + << " disp(sprintf('The standard deviation of %s is not estimated (the value provided in estimated_params_init is not used).', M_.exo_names{" << tsid << "}))" << endl; skipline = true; - output << "else" << endl; - output << " estim_params_.var_exo(tmp1,2) = "; + output << "else" << endl + << " estim_params_.var_exo(tmp1,2) = "; it.init_val->writeOutput(output); - output << ";" << endl; - output << "end" << endl; + output << ";" << endl + << "end" << endl; } else if (symb_type == SymbolType::endogenous) { - output << "tmp1 = find(estim_params_.var_endo(:,1)==" << symb_id << ");" << endl; - output << "if isempty(tmp1)" << endl; - output << " disp(sprintf('The standard deviation of the measurement error on %s is not estimated (the value provided in estimated_params_init is not used).', M_.endo_names{" << symb_id << "}))" << endl; + output << "tmp1 = find(estim_params_.var_endo(:,1)==" << tsid << ");" << endl + << "if isempty(tmp1)" << endl + << " disp(sprintf('The standard deviation of the measurement error on %s is not estimated (the value provided in estimated_params_init is not used).', M_.endo_names{" << tsid << "}))" << endl; skipline = true; - output << "else" << endl; - output << " estim_params_.var_endo(tmp1,2) = "; + output << "else" << endl + << " estim_params_.var_endo(tmp1,2) = "; it.init_val->writeOutput(output); - output << ";" << endl; - output << "end" << endl; + output << ";" << endl + << "end" << endl; } else if (symb_type == SymbolType::parameter) { - output << "tmp1 = find(estim_params_.param_vals(:,1)==" << symb_id << ");" << endl; - output << "if isempty(tmp1)" << endl; - output << " disp(sprintf('Parameter %s is not estimated (the value provided in estimated_params_init is not used).', M_.param_names{" << symb_id << "}))" << endl; + output << "tmp1 = find(estim_params_.param_vals(:,1)==" << tsid << ");" << endl + << "if isempty(tmp1)" << endl + << " disp(sprintf('Parameter %s is not estimated (the value provided in estimated_params_init is not used).', M_.param_names{" << tsid << "}))" << endl; skipline = true; - output << "else" << endl; - output << " estim_params_.param_vals(tmp1,2) = "; + output << "else" << endl + << " estim_params_.param_vals(tmp1,2) = "; it.init_val->writeOutput(output); - output << ";" << endl; - output << "end" << endl; + output << ";" << endl + << "end" << endl; } } else { + int tsid2 = symbol_table.getTypeSpecificID(it.name2) + 1; if (symb_type == SymbolType::exogenous) { - output << "tmp1 = find((estim_params_.corrx(:,1)==" << symb_id << " & estim_params_.corrx(:,2)==" << symbol_table.getTypeSpecificID(it.name2)+1 << ") | " - << "(estim_params_.corrx(:,2)==" << symb_id << " & estim_params_.corrx(:,1)==" << symbol_table.getTypeSpecificID(it.name2)+1 << "));" << endl; - output << "if isempty(tmp1)" << endl; - output << " disp(sprintf('The correlation between %s and %s is not estimated (the value provided in estimated_params_init is not used).', M_.exo_names{" - << symb_id << "}, M_.exo_names{" << symbol_table.getTypeSpecificID(it.name2)+1 << "}))" << endl; + output << "tmp1 = find((estim_params_.corrx(:,1)==" << tsid << " & estim_params_.corrx(:,2)==" << tsid2 << ") | " + << "(estim_params_.corrx(:,2)==" << tsid << " & estim_params_.corrx(:,1)==" << tsid2 << "));" << endl + << "if isempty(tmp1)" << endl + << " disp(sprintf('The correlation between %s and %s is not estimated (the value provided in estimated_params_init is not used).', M_.exo_names{" + << tsid << "}, M_.exo_names{" << tsid2 << "}))" << endl; skipline = true; - output << "else" << endl; - output << " estim_params_.corrx(tmp1,3) = "; + output << "else" << endl + << " estim_params_.corrx(tmp1,3) = "; it.init_val->writeOutput(output); - output << ";" << endl; - output << "end" << endl; + output << ";" << endl + << "end" << endl; } else if (symb_type == SymbolType::endogenous) { - output << "tmp1 = find((estim_params_.corrn(:,1)==" << symb_id << " & estim_params_.corrn(:,2)==" << symbol_table.getTypeSpecificID(it.name2)+1 << ") | " - << "(estim_params_.corrn(:,2)==" << symb_id << " & estim_params_.corrn(:,1)==" << symbol_table.getTypeSpecificID(it.name2)+1 << "));" << endl; - output << "if isempty(tmp1)" << endl; - output << " disp(sprintf('The correlation between measurement errors on %s and %s is not estimated (the value provided in estimated_params_init is not used).', M_.endo_names{" - << symb_id << "}, M_.endo_names{" << symbol_table.getTypeSpecificID(it.name2)+1 << "}))" << endl; + output << "tmp1 = find((estim_params_.corrn(:,1)==" << tsid << " & estim_params_.corrn(:,2)==" << tsid2 << ") | " + << "(estim_params_.corrn(:,2)==" << tsid << " & estim_params_.corrn(:,1)==" << tsid2 << "));" << endl + << "if isempty(tmp1)" << endl + << " disp(sprintf('The correlation between measurement errors on %s and %s is not estimated (the value provided in estimated_params_init is not used).', M_.endo_names{" + << tsid << "}, M_.endo_names{" << tsid2 << "}))" << endl; skipline = true; - output << "else" << endl; - output << " estim_params_.corrn(tmp1,3) = "; + output << "else" << endl + << " estim_params_.corrn(tmp1,3) = "; it.init_val->writeOutput(output); - output << ";" << endl; - output << "end" << endl; + output << ";" << endl + << "end" << endl; } } } @@ -1623,73 +1624,64 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen { for (const auto &it : estim_params_list) { - int symb_id = symbol_table.getTypeSpecificID(it.name) + 1; + int tsid = symbol_table.getTypeSpecificID(it.name) + 1; SymbolType symb_type = symbol_table.getType(it.name); if (it.type < 3) { if (symb_type == SymbolType::exogenous) { - output << "tmp1 = find(estim_params_.var_exo(:,1)==" << symb_id << ");" << endl; - - output << "estim_params_.var_exo(tmp1,3) = "; + output << "tmp1 = find(estim_params_.var_exo(:,1)==" << tsid << ");" << endl + << "estim_params_.var_exo(tmp1,3) = "; it.low_bound->writeOutput(output); - output << ";" << endl; - - output << "estim_params_.var_exo(tmp1,4) = "; + output << ";" << endl + << "estim_params_.var_exo(tmp1,4) = "; it.up_bound->writeOutput(output); output << ";" << endl; } else if (symb_type == SymbolType::endogenous) { - output << "tmp1 = find(estim_params_.var_endo(:,1)==" << symb_id << ");" << endl; - - output << "estim_params_.var_endo(tmp1,3) = "; + output << "tmp1 = find(estim_params_.var_endo(:,1)==" << tsid << ");" << endl + << "estim_params_.var_endo(tmp1,3) = "; it.low_bound->writeOutput(output); - output << ";" << endl; - - output << "estim_params_.var_endo(tmp1,4) = "; + output << ";" << endl + << "estim_params_.var_endo(tmp1,4) = "; it.up_bound->writeOutput(output); output << ";" << endl; } else if (symb_type == SymbolType::parameter) { - output << "tmp1 = find(estim_params_.param_vals(:,1)==" << symb_id << ");" << endl; - - output << "estim_params_.param_vals(tmp1,3) = "; + output << "tmp1 = find(estim_params_.param_vals(:,1)==" << tsid << ");" << endl + << "estim_params_.param_vals(tmp1,3) = "; it.low_bound->writeOutput(output); - output << ";" << endl; - - output << "estim_params_.param_vals(tmp1,4) = "; + output << ";" << endl + << "estim_params_.param_vals(tmp1,4) = "; it.up_bound->writeOutput(output); output << ";" << endl; } } else { + int tsid2 = symbol_table.getTypeSpecificID(it.name2) + 1; if (symb_type == SymbolType::exogenous) { - output << "tmp1 = find((estim_params_.corrx(:,1)==" << symb_id << " & estim_params_.corrx(:,2)==" << symbol_table.getTypeSpecificID(it.name2)+1 << ") | " - << "(estim_params_.corrx(:,2)==" << symb_id << " & estim_params_.corrx(:,1)==" << symbol_table.getTypeSpecificID(it.name2)+1 << "));" << endl; - - output << "estim_params_.corrx(tmp1,4) = "; + output << "tmp1 = find((estim_params_.corrx(:,1)==" << tsid << " & estim_params_.corrx(:,2)==" << tsid2 << ") | " + << "(estim_params_.corrx(:,2)==" << tsid << " & estim_params_.corrx(:,1)==" << tsid2 << "));" << endl + << "estim_params_.corrx(tmp1,4) = "; it.low_bound->writeOutput(output); - output << ";" << endl; - - output << "estim_params_.corrx(tmp1,5) = "; + output << ";" << endl + << "estim_params_.corrx(tmp1,5) = "; it.up_bound->writeOutput(output); output << ";" << endl; } else if (symb_type == SymbolType::endogenous) { - output << "tmp1 = find((estim_params_.corrn(:,1)==" << symb_id << " & estim_params_.corrn(:,2)==" << symbol_table.getTypeSpecificID(it.name2)+1 << ") | " - << "(estim_params_.corrn(:,2)==" << symb_id << " & estim_params_.corrn(:,1)==" << symbol_table.getTypeSpecificID(it.name2)+1 << "));" << endl; - - output << "estim_params_.corrn(tmp1,4) = "; + output << "tmp1 = find((estim_params_.corrn(:,1)==" << tsid << " & estim_params_.corrn(:,2)==" << tsid2 << ") | " + << "(estim_params_.corrn(:,2)==" << tsid << " & estim_params_.corrn(:,1)==" << tsid2 << "));" << endl + << "estim_params_.corrn(tmp1,4) = "; it.low_bound->writeOutput(output); - output << ";" << endl; - - output << "estim_params_.corrn(tmp1,5) = "; + output << ";" << endl + << "estim_params_.corrn(tmp1,5) = "; it.up_bound->writeOutput(output); output << ";" << endl; }