【问题标题】:Exporting output results from a model into the input of a different model将模型的输出结果导出到不同模型的输入
【发布时间】:2021-11-01 16:36:10
【问题描述】:

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

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

提前谢谢你。

【问题讨论】:

    标签: anylogic


    【解决方案1】:

    你有两个选择

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

    使用连接面板中的对象,只需在模型中链接一个 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 工作表导入 AnyLogic 数据库,然后使用 for 循环遍历表中的条目

    List<Tuple> rows = selectFrom(db_table).list();
    
    for (Tuple row : rows) {
        traceln(
            row.get( db_table.db_column )
        );
    }
    
    

    【讨论】:

    • 嗨,Jabo-Ben!首先感谢您的回答!您提出的导入结果的解决方案工作得很好,但我仍然不明白如何将结果从 anylogic 文件导出到 excel 文件中,您能帮我吗?谢谢!
    • 您好,Francisco,感谢您的反馈,很高兴我的回复回答了您的问题。请提出一个新问题,但请先查看帮助文件,这是从数据库中执行此操作的一个选项 - anylogic.help/anylogic/connectivity/… - 或 anylogic.help/anylogic/connectivity/excel-file.html#excel-file,然后发布您尝试过的内容以及结果。有很多导出选项
    猜你喜欢
    • 2012-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-15
    • 1970-01-01
    • 2018-06-20
    相关资源
    最近更新 更多