From adbeb49b2937c59d0cadfcbd175c5662c1a84abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=28Charybdis=29?= Date: Tue, 14 Aug 2018 16:45:01 +0200 Subject: [PATCH] Do not print non optimizing behaviour field in PAC if empty. --- src/ExprNode.cc | 81 +++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/src/ExprNode.cc b/src/ExprNode.cc index d2c25c62..99f69e5d 100644 --- a/src/ExprNode.cc +++ b/src/ExprNode.cc @@ -8430,47 +8430,50 @@ PacExpectationNode::writeOutput(ostream &output, ExprNodeOutputType output_type, output << " "; output << it->second.second; } - output << "];" << endl - << "M_.pac." << model_name << ".non_optim.params = ["; - for (auto it = params_vars_and_scaling_factor.begin(); - it != params_vars_and_scaling_factor.end(); it++) + output << "];" << endl; + if (!params_vars_and_scaling_factor.empty()) { - if (it != params_vars_and_scaling_factor.begin()) - output << " "; - if (it->first >= 0) - output << datatree.symbol_table.getTypeSpecificID(it->first) + 1; - else - output << "NaN"; + output << "M_.pac." << model_name << ".non_optimizing_behaviour.params = ["; + for (auto it = params_vars_and_scaling_factor.begin(); + it != params_vars_and_scaling_factor.end(); it++) + { + if (it != params_vars_and_scaling_factor.begin()) + output << " "; + if (it->first >= 0) + output << datatree.symbol_table.getTypeSpecificID(it->first) + 1; + else + output << "NaN"; + } + output << "];" + << "M_.pac." << model_name << ".non_optimizing_behaviour.vars = ["; + for (auto it = params_vars_and_scaling_factor.begin(); + it != params_vars_and_scaling_factor.end(); it++) + { + if (it != params_vars_and_scaling_factor.begin()) + output << " "; + output << datatree.symbol_table.getTypeSpecificID(it->second.first.first) + 1; + } + output << "];" << endl + << "M_.pac." << model_name << ".non_optimizing_behaviour.lags = ["; + for (auto it = params_vars_and_scaling_factor.begin(); + it != params_vars_and_scaling_factor.end(); it++) + { + if (it != params_vars_and_scaling_factor.begin()) + output << " "; + output << it->second.first.second; + } + output << "];" << endl + << "M_.pac." << model_name << ".non_optimizing_behaviour.scaling_factor = ["; + for (auto it = params_vars_and_scaling_factor.begin(); + it != params_vars_and_scaling_factor.end(); it++) + { + if (it != params_vars_and_scaling_factor.begin()) + output << " "; + output << it->second.second; + } + output << "];" << endl; } - output << "];" << endl - << "M_.pac." << model_name << ".non_optim.vars = ["; - for (auto it = params_vars_and_scaling_factor.begin(); - it != params_vars_and_scaling_factor.end(); it++) - { - if (it != params_vars_and_scaling_factor.begin()) - output << " "; - output << datatree.symbol_table.getTypeSpecificID(it->second.first.first) + 1; - } - output << "];" << endl - << "M_.pac." << model_name << ".non_optim.lags = ["; - for (auto it = params_vars_and_scaling_factor.begin(); - it != params_vars_and_scaling_factor.end(); it++) - { - if (it != params_vars_and_scaling_factor.begin()) - output << " "; - output << it->second.first.second; - } - output << "];" << endl - << "M_.pac." << model_name << ".non_optim.scaling_factor = ["; - for (auto it = params_vars_and_scaling_factor.begin(); - it != params_vars_and_scaling_factor.end(); it++) - { - if (it != params_vars_and_scaling_factor.begin()) - output << " "; - output << it->second.second; - } - output << "];" << endl - << "M_.pac." << model_name << ".h0_param_indices = ["; + output << "M_.pac." << model_name << ".h0_param_indices = ["; for (auto it = h0_indices.begin(); it != h0_indices.end(); it++) {