Use true/false instead of 1/0 for boolean options

This is more elegant, and makes it easier to distinguish them from integer
options.
parent 1793078b
Pipeline #1003 passed with stage
in 1 minute and 49 seconds
......@@ -657,12 +657,12 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
// Fill in mod_file_struct.partial_information
it = options_list.num_options.find("partial_information");
if (it != options_list.num_options.end() && it->second == "1")
if (it != options_list.num_options.end() && it->second == "true")
mod_file_struct.partial_information = true;
// Option k_order_solver (implicit when order >= 3)
it = options_list.num_options.find("k_order_solver");
if ((it != options_list.num_options.end() && it->second == "1")
if ((it != options_list.num_options.end() && it->second == "true")
|| mod_file_struct.order_option >= 3)
mod_file_struct.k_order_solver = true;
......@@ -685,9 +685,9 @@ StochSimulStatement::writeOutput(ostream &output, const string &basename, bool m
// Ensure that order 3 implies k_order (#844)
auto it = options_list.num_options.find("order");
auto it1 = options_list.num_options.find("k_order_solver");
if ((it1 != options_list.num_options.end() && it1->second == "1")
if ((it1 != options_list.num_options.end() && it1->second == "true")
|| (it != options_list.num_options.end() && stoi(it->second) >= 3))
output << "options_.k_order_solver = 1;" << endl;
output << "options_.k_order_solver = true;" << endl;
options_list.writeOutput(output);
symbol_list.writeOutput("var_list_", output);
......@@ -769,13 +769,13 @@ DetCondForecast::writeOutput(ostream &output, const string &basename, bool minim
output << "end;" << endl;
output << "if first_order_solution_to_compute" << endl;
output << " fprintf('%s','Computing the first order solution ...');" << endl;
output << " options_.nograph = 1;" << endl;
output << " options_.nograph = true;" << endl;
output << " options_.order = 1;" << endl;
output << " options_.noprint = 1;" << endl;
output << " options_.nocorr = 1;" << endl;
output << " options_.nomoments = 1;" << endl;
output << " options_.nodecomposition = 1;" << endl;
output << " options_.nofunctions = 1;" << endl;
output << " options_.noprint = true;" << endl;
output << " options_.nocorr = true;" << endl;
output << " options_.nomoments = true;" << endl;
output << " options_.nodecomposition = true;" << endl;
output << " options_.nofunctions = true;" << endl;
output << " options_.irf = 0;" << endl;
output << " tmp_periods = options_.periods;" << endl;
output << " options_.periods = 0;" << endl;
......@@ -822,12 +822,12 @@ RamseyModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsol
// Fill in mod_file_struct.partial_information
it = options_list.num_options.find("partial_information");
if (it != options_list.num_options.end() && it->second == "1")
if (it != options_list.num_options.end() && it->second == "true")
mod_file_struct.partial_information = true;
// Option k_order_solver (implicit when order >= 3)
it = options_list.num_options.find("k_order_solver");
if ((it != options_list.num_options.end() && it->second == "1")
if ((it != options_list.num_options.end() && it->second == "true")
|| mod_file_struct.order_option >= 3)
mod_file_struct.k_order_solver = true;
}
......@@ -842,11 +842,11 @@ RamseyModelStatement::writeOutput(ostream &output, const string &basename, bool
// Ensure that order 3 implies k_order (#844)
auto it = options_list.num_options.find("order");
auto it1 = options_list.num_options.find("k_order_solver");
if ((it1 != options_list.num_options.end() && it1->second == "1")
if ((it1 != options_list.num_options.end() && it1->second == "true")
|| (it != options_list.num_options.end() && stoi(it->second) >= 3))
output << "options_.k_order_solver = 1;" << endl;
output << "options_.k_order_solver = true;" << endl;
output << "options_.ramsey_policy = 1;" << endl;
output << "options_.ramsey_policy = true;" << endl;
options_list.writeOutput(output);
}
......@@ -980,12 +980,12 @@ RamseyPolicyStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
// Fill in mod_file_struct.partial_information
it = options_list.num_options.find("partial_information");
if (it != options_list.num_options.end() && it->second == "1")
if (it != options_list.num_options.end() && it->second == "true")
mod_file_struct.partial_information = true;
// Option k_order_solver (implicit when order >= 3)
it = options_list.num_options.find("k_order_solver");
if ((it != options_list.num_options.end() && it->second == "1")
if ((it != options_list.num_options.end() && it->second == "true")
|| mod_file_struct.order_option >= 3)
mod_file_struct.k_order_solver = true;
}
......@@ -1014,9 +1014,9 @@ RamseyPolicyStatement::writeOutput(ostream &output, const string &basename, bool
// Ensure that order 3 implies k_order (#844)
auto it = options_list.num_options.find("order");
auto it1 = options_list.num_options.find("k_order_solver");
if ((it1 != options_list.num_options.end() && it1->second == "1")
if ((it1 != options_list.num_options.end() && it1->second == "true")
|| (it != options_list.num_options.end() && stoi(it->second) >= 3))
output << "options_.k_order_solver = 1;" << endl;
output << "options_.k_order_solver = true;" << endl;
options_list.writeOutput(output);
output << "var_list_ = {";
......@@ -1087,12 +1087,12 @@ DiscretionaryPolicyStatement::checkPass(ModFileStructure &mod_file_struct, Warni
// Fill in mod_file_struct.partial_information
it = options_list.num_options.find("partial_information");
if (it != options_list.num_options.end() && it->second == "1")
if (it != options_list.num_options.end() && it->second == "true")
mod_file_struct.partial_information = true;
// Option k_order_solver (implicit when order >= 3)
it = options_list.num_options.find("k_order_solver");
if ((it != options_list.num_options.end() && it->second == "1")
if ((it != options_list.num_options.end() && it->second == "true")
|| mod_file_struct.order_option >= 3)
mod_file_struct.k_order_solver = true;
}
......@@ -1103,9 +1103,9 @@ DiscretionaryPolicyStatement::writeOutput(ostream &output, const string &basenam
// Ensure that order 3 implies k_order (#844)
auto it = options_list.num_options.find("order");
auto it1 = options_list.num_options.find("k_order_solver");
if ((it1 != options_list.num_options.end() && it1->second == "1")
if ((it1 != options_list.num_options.end() && it1->second == "true")
|| (it != options_list.num_options.end() && stoi(it->second) >= 3))
output << "options_.k_order_solver = 1;" << endl;
output << "options_.k_order_solver = true;" << endl;
options_list.writeOutput(output);
symbol_list.writeOutput("var_list_", output);
......@@ -1158,7 +1158,7 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
// Fill in mod_file_struct.partial_information
it = options_list.num_options.find("partial_information");
if (it != options_list.num_options.end() && it->second == "1")
if (it != options_list.num_options.end() && it->second == "true")
mod_file_struct.partial_information = true;
// Fill in mod_file_struct.estimation_analytic_derivation
......@@ -1178,7 +1178,7 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
// Fill in mod_file_struct.bayesian_irf_present
it = options_list.num_options.find("bayesian_irf");
if (it != options_list.num_options.end() && it->second == "1")
if (it != options_list.num_options.end() && it->second == "true")
mod_file_struct.bayesian_irf_present = true;
it = options_list.num_options.find("dsge_varlag");
......@@ -1223,12 +1223,12 @@ EstimationStatement::writeOutput(ostream &output, const string &basename, bool m
if (it == options_list.num_options.end())
output << "options_.order = 1;" << endl;
else if (stoi(it->second) == 2)
output << "options_.particle.status = 1;" << endl;
output << "options_.particle.status = true;" << endl;
// Do not check for the steady state in diffuse filter mode (#400)
it = options_list.num_options.find("diffuse_filter");
if (it != options_list.num_options.end() && it->second == "1")
output << "options_.steadystate.nocheck = 1;" << endl;
if (it != options_list.num_options.end() && it->second == "true")
output << "options_.steadystate.nocheck = true;" << endl;
symbol_list.writeOutput("var_list_", output);
output << "oo_recursive_=dynare_estimation(var_list_);" << endl;
......@@ -1971,12 +1971,12 @@ OsrStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation
// Fill in mod_file_struct.partial_information
it = options_list.num_options.find("partial_information");
if (it != options_list.num_options.end() && it->second == "1")
if (it != options_list.num_options.end() && it->second == "true")
mod_file_struct.partial_information = true;
// Option k_order_solver (implicit when order >= 3)
it = options_list.num_options.find("k_order_solver");
if ((it != options_list.num_options.end() && it->second == "1")
if ((it != options_list.num_options.end() && it->second == "true")
|| mod_file_struct.order_option >= 3)
mod_file_struct.k_order_solver = true;
}
......@@ -1987,9 +1987,9 @@ OsrStatement::writeOutput(ostream &output, const string &basename, bool minimal_
// Ensure that order 3 implies k_order (#844)
auto it = options_list.num_options.find("order");
auto it1 = options_list.num_options.find("k_order_solver");
if ((it1 != options_list.num_options.end() && it1->second == "1")
if ((it1 != options_list.num_options.end() && it1->second == "true")
|| (it != options_list.num_options.end() && stoi(it->second) >= 3))
output << "options_.k_order_solver = 1;" << endl;
output << "options_.k_order_solver = true;" << endl;
options_list.writeOutput(output);
symbol_list.writeOutput("var_list_", output);
......@@ -4733,7 +4733,7 @@ CalibSmootherStatement::writeOutput(ostream &output, const string &basename, boo
if (it == options_list.string_options.end())
output << "options_.parameter_set = 'calibration';" << endl;
symbol_list.writeOutput("var_list_", output);
output << "options_.smoother = 1;" << endl
output << "options_.smoother = true;" << endl
<< "options_.order = 1;" << endl
<< "[oo_, M_, options_, bayestopt_] = evaluate_smoother(options_.parameter_set, var_list_, M_, oo_, options_, bayestopt_, estim_params_);" << endl;
}
......
......@@ -3124,9 +3124,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
/* Say if static and dynamic models differ (because of [static] and [dynamic]
equation tags) */
output << modstruct << "static_and_dynamic_models_differ = "
<< (static_only_equations.size() > 0 ?
(julia ? "true" : "1") :
(julia ? "false" : "0"))
<< (static_only_equations.size() > 0 ? "true" :"false")
<< ";" << endl;
vector<int> state_var;
......
This diff is collapsed.
......@@ -889,16 +889,16 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
mOutputFile << "diary('" << basename << ".log');" << endl;
if (minimal_workspace)
mOutputFile << "options_.minimal_workspace = 1;" << endl;
mOutputFile << "options_.minimal_workspace = true;" << endl;
if (console)
mOutputFile << "options_.console_mode = 1;" << endl
<< "options_.nodisplay = 1;" << endl;
mOutputFile << "options_.console_mode = true;" << endl
<< "options_.nodisplay = true;" << endl;
if (nograph)
mOutputFile << "options_.nograph = 1;" << endl;
mOutputFile << "options_.nograph = true;" << endl;
if (nointeractive)
mOutputFile << "options_.nointeractive = 1;" << endl;
mOutputFile << "options_.nointeractive = true;" << endl;
if (param_used_with_lead_lag)
mOutputFile << "M_.parameter_used_with_lead_lag = true;" << endl;
......@@ -926,18 +926,18 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
<< "M_.Correlation_matrix_ME = 1;" << endl;
// May be later modified by a shocks block
mOutputFile << "M_.sigma_e_is_diagonal = 1;" << endl;
mOutputFile << "M_.sigma_e_is_diagonal = true;" << endl;
// Initialize M_.det_shocks
mOutputFile << "M_.det_shocks = [];" << endl;
if (linear == 1)
mOutputFile << "options_.linear = 1;" << endl;
auto to_matlab_logical = [](bool m) { return m ? "true" : "false"; };
mOutputFile << "options_.block=" << block << ";" << endl
<< "options_.bytecode=" << byte_code << ";" << endl
<< "options_.use_dll=" << use_dll << ";" << endl
<< "options_.linear_decomposition=" << linear_decomposition << ";" << endl;
mOutputFile << "options_.linear = " << to_matlab_logical(linear) << ";" << endl
<< "options_.block = " << to_matlab_logical(block) << ";" << endl
<< "options_.bytecode = " << to_matlab_logical(byte_code) << ";" << endl
<< "options_.use_dll = " << to_matlab_logical(use_dll) << ";" << endl
<< "options_.linear_decomposition = " << to_matlab_logical(linear_decomposition) << ";" << endl;
if (parallel_local_files.size() > 0)
{
......
......@@ -225,7 +225,7 @@ InitValStatement::writeOutput(ostream &output, const string &basename, bool mini
<< "% INITVAL instructions" << endl
<< "%" << endl;
// Writing initval block to set initial values for variables
output << "options_.initval_file = 0;" << endl;
output << "options_.initval_file = false;" << endl;
writeInitValues(output);
}
......@@ -420,7 +420,7 @@ InitvalFileStatement::writeOutput(ostream &output, const string &basename, bool
output << "%" << endl
<< "% INITVAL_FILE statement" << endl
<< "%" << endl
<< "options_.initval_file = 1;" << endl
<< "options_.initval_file = true;" << endl
<< "initvalf('" << filename << "');" << endl;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment