Equation-based modelling is a powerful approach to tame the complexity of large-scale simulation problems. Equation-based tools automatically translate models into imperative languages. When confronted with nowadays' problems, however, well assessed model translation techniques exhibit scalability issues, that are particularly severe when models contain very large arrays. In fact, such models can be made very compact by enclosing equations into looping constructs, but reflecting the same compactness into the translated imperative code is not trivial. In this paper, we face this issue by concentrating on a key step of equations-to-code translation, the equation/variable matching. We first show that an efficient translation of models with (large) arrays needs awareness of their presence, by defining a figure of merit to measure how much the looping constructs are preserved along the translation. We then show that the said figure of merit allows to define an optimal array-aware matching, and as our main result, that the so stated optimal array-aware matching problem is NP-complete. As an additional result, we propose a heuristic algorithm capable of performing array-aware matching in polynomial time. The proposed algorithm can be proficiently used by model translator developers in the implementation of efficient tools for large-scale system simulation.
翻译:基于方程的建模是应对大规模仿真问题复杂性的一种强大方法。基于方程的工具会自动将模型翻译成命令式语言。然而,面对当今的问题,经过充分验证的模型翻译技术存在可扩展性问题,当模型包含非常大的数组时,这一问题尤为严重。事实上,通过将方程封装到循环结构中,这类模型可以变得非常紧凑,但将同样的紧凑性反映到翻译后的命令式代码中并非易事。在本文中,我们通过聚焦于方程到代码翻译的关键步骤——方程/变量匹配来应对这一问题。我们首先定义了一个优值来衡量循环结构在翻译过程中的保留程度,从而证明对包含(大型)数组的模型进行高效翻译需要意识到它们的存在。然后,我们表明该优值可以定义最优的数组感知匹配,并且作为我们的主要成果,证明了所提出的最优数组感知匹配问题是NP完全的。作为附加成果,我们提出了一种能够在多项式时间内执行数组感知匹配的启发式算法。模型翻译器开发人员可以在实现大规模系统仿真的高效工具时,有效地使用所提出的算法。