From d668590ff897620cb004c4fd4ff9fd637852f2ab Mon Sep 17 00:00:00 2001 From: Michel Juillard Date: Tue, 17 Mar 2020 09:27:10 +0100 Subject: [PATCH] modify Julia output for mapping eqidx --- src/DynamicModel.cc | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 8a4025a6..c6d35e7e 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -3163,14 +3163,30 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de equation_tags.writeOccbinOutput(output, modstruct, julia); // Write mapping for variables and equations they are present in - for (const auto &variable : variableMapping) + if (!julia) + for (const auto &variable : variableMapping) + { + output << modstruct << "mapping." << symbol_table.getName(variable.first) << ".eqidx = ["; + for (auto equation : variable.second) + output << equation + 1 << " "; + output << "];" << endl; + } + else { - output << modstruct << "mapping." << symbol_table.getName(variable.first) << ".eqidx = ["; - for (auto equation : variable.second) - output << equation + 1 << " "; - output << "];" << endl; + output << modstruct << "mapping.eqidx = Dict(\n"; + for (const auto &variable : variableMapping) + { + output << " \"" + << symbol_table.getName(variable.first) + << "\" => ["; + for (auto equation : variable.second) + output << equation + 1 << ", "; + output << "]," << endl; + } + output << ")" << endl; } + /* Say if static and dynamic models differ (because of [static] and [dynamic] equation tags) */ output << modstruct << "static_and_dynamic_models_differ = "