【问题标题】:Anylogic - Automate multiple runs of a simulation model in AnylogicAnylogic - 在 Anylogic 中自动运行多个仿真模型
【发布时间】:2022-01-08 03:45:41
【问题描述】:

我有一个用 Anylogic 编写的仿真模型。模拟的输出会自动导出到 Excel 文件中。对于 10 个场景中的每一个,我需要运行模拟大约 20 次,每次运行大约需要 30 分钟。我怎样才能自动化这个过程?另外,我希望能够在每次运行时向模型传递一些参数

不胜感激!

【问题讨论】:

  • 您想自动化什么?输出写入过程?还是跑了 20 次?
  • 感谢您的回复。我想自动化 20 次运行,并能够为每次运行向模型传递一些参数。

标签: java bash anylogic script


【解决方案1】:

使用Parameters Variation 实验。

您可以使用代码int a=getEngine().getRunCount(); 在主启动时访问任何运行号。您可以预先在 Excel 中准备输入并根据计数传递参数。

您可以为每次运行单独编写输出。使用以下代码作为灵感,我在每次运行结束时将myVariable 写入名为 output0.csv、ouput1.csv 等的 csv 文件。(这发生在 Main -> On Destroy 中。

int a=getEngine().getRunCount();

String filename="output"+a+".csv";

try
{
 FileOutputStream fos = new FileOutputStream(filename);
 PrintStream p = new PrintStream(fos);
 
 for (int i=0; i<100;i++){
    for(int j=0;j<10;j++){
        p.println(myVariable.output[i][j]);}} // outputs tab delimited values
}
catch (Exception e)
{
 traceln("Could not write to file.");
}

【讨论】:

  • 谢谢@Yashar。参数变化解决问题。
猜你喜欢
  • 2023-02-06
  • 2016-10-21
  • 2020-01-10
  • 2022-01-21
  • 2021-04-28
  • 2017-01-12
  • 2020-11-09
  • 2014-08-24
  • 1970-01-01
相关资源
最近更新 更多