Commit 6015b0e5 authored by Houtan Bastani's avatar Houtan Bastani

fixes to trend component model

parent 0d5dd111
......@@ -1315,9 +1315,16 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
output << ", ";
dynamic_model.writeJsonOutput(output);
if (!statements.empty())
if (!statements.empty()
|| !trend_component_model_table.empty())
{
output << ", \"statements\": [";
if (!trend_component_model_table.empty())
{
trend_component_model_table.writeJsonOutput(output);
output << ", ";
}
for (auto it = statements.begin();
it != statements.end(); it++)
{
......
......@@ -1422,22 +1422,20 @@ ParsingDriver::stoch_simul()
void
ParsingDriver::trend_component_model()
{
OptionsList::string_options_t::const_iterator it =
options_list.string_options.find("trend_component.name");
if (it == options_list.string_options.end())
const auto its = options_list.string_options.find("trend_component.name");
if (its == options_list.string_options.end())
error("You must pass the model_name option to the trend_component_model statement.");
auto name = it->second;
auto name = its->second;
OptionsList::vec_str_options_t::const_iterator it1 =
options_list.vector_str_options.find("trend_component.eqtags");
if (it1 == options_list.vector_str_options.end())
const auto itvs = options_list.vector_str_options.find("trend_component.eqtags");
if (itvs == options_list.vector_str_options.end())
error("You must pass the eqtags option to the trend_component_model statement.");
auto eqtags = it1->second;
auto eqtags = itvs->second;
it1 = options_list.vector_str_options.find("trend_component.trends");
if (it1 == options_list.vector_str_options.end())
const auto itvs1 = options_list.vector_str_options.find("trend_component.trends");
if (itvs1 == options_list.vector_str_options.end())
error("You must pass the trends option to the trend_component_model statement.");
auto trends = it1->second;
auto trends = itvs1->second;
mod_file->trend_component_model_table.addTrendComponentModel(name, eqtags, trends);
options_list.clear();
......
......@@ -283,6 +283,21 @@ TrendComponentModelTable::writeJsonOutput(ostream &output) const
if (name != *(names.begin()))
output << ", ";
output << "{\"statementName\": \"trend_component_model\","
<< "\"model_name\": \"" << name << "\"}";
<< "\"model_name\": \"" << name << "\","
<< "\"eqtags\": [";
for (const auto &it : eqtags.at(name))
{
output << "\"" << it << "\"";
if (&it != &eqtags.at(name).back())
output << ", ";
}
output << "], \"trend_eqtags\": [";
for (const auto &it : trend_eqtags.at(name))
{
output << "\"" << it << "\"";
if (&it != &trend_eqtags.at(name).back())
output << ", ";
}
output << "]}";
}
}
......@@ -48,9 +48,11 @@ public:
TrendComponentModelTable(SymbolTable &symbol_table_arg);
//! Add a trend component model
void addTrendComponentModel(string name, vector<string> eqtags, vector<string> trend_eqtags);
void addTrendComponentModel(string name_arg, vector<string> eqtags_arg,
vector<string> trend_eqtags_arg);
inline bool isExistingTrendComponentModelName(const string &name_arg) const;
inline bool empty() const;
map<string, vector<string>> getEqTags() const;
vector<string> getEqTags(const string &name_arg) const;
......@@ -93,4 +95,10 @@ TrendComponentModelTable::isExistingTrendComponentModelName(const string &name_a
return names.find(name_arg) == names.end() ? false : true;
}
inline bool
TrendComponentModelTable::empty() const
{
return names.empty();
}
#endif
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