将模型的输出结果导出到不同模型的输入

Exporting output results from a model into the input of a different model

我正在尝试使用 AnyLogic 的个人学习版构建工厂模型。由于此版本每个模型的块数有限,因此在单个模型上构建完整的工厂本身就是一项不可能完成的任务。为了超越这个问题,我想把工厂的主要流程拆分成不同的模型,这意味着我必须将流程A的输出提供给流程B的输入。

我的问题是:如何将模型的时间戳输出导出到不同模型的输入中?

提前致谢。

您有 2 个选择

选项 1:通过 Excel 文件(或 txt 文件)

只需 link 模型中的 Excel 文件,使用连接调色板中的对象

然后你可以使用类似下面的代码获取数据

int excelRow = 2;
String sheetName = "Sheet1!";
String cellName =  sheetName + "A" + excelRow;
while (excelFile.cellExists( cellName )) {
    int x = (int)excelFile.getCellNumericValue( sheetName + "A" +  excelRow);
    int b = (int)excelFile.getCellNumericValue( sheetName + "B" +  excelRow);
    int c = (int)excelFile.getCellNumericValue( sheetName + "C" +  excelRow);
    boolean d = excelFile.getCellBooleanValue( sheetName + "D" +  excelRow);
    
    excelRow ++; // Increase the row that we will lookup in the Excel
}

只需一个 while 循环,只要该行存在,您就可以从 excel 行转到下一行,然后对数据执行任何需要的操作

选项 2:AnyLogic 内部数据库

只需将您的 excel sheet 导入 AnyLogic 数据库,然后使用 for 循环

遍历 table 中的条目
List<Tuple> rows = selectFrom(db_table).list();

for (Tuple row : rows) {
    traceln(
        row.get( db_table.db_column )
    );
}