You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在AnyLogic供应链模型中动态设置TimeMeasureStart?

解决AnyLogic跨代理TimeMeasure关联问题

方法一:通过Product代理携带起始计时器引用

  • 在Product代理中新增TimeMeasureStart类型的变量,命名为startTimer
  • 当Product进入Vendor页面的TimeMeasureStart模块时,在该模块的On start代码框中添加:product.startTimer = this;(this指代当前的TimeMeasureStart实例)
  • 流程图中的TimeMeasureEnd模块,在End object设置项里直接选择product.startTimer,即可关联对应的起始计时器

方法二:修正代理层级引用(解决getRootAgent失效问题)

  • 若getRootAgent()无法访问,先确认根代理中TimeMeasureStart模块的类型:
    • 若为单个实例:确保根代理类名正确,在流程图中用((你的根代理类名)getRootAgent()).你的TimeMeasureStart模块名引用,比如((SupplyChainRoot)getRootAgent()).vendorStartTimer
    • 若为数组(拖入多个模块自动生成):需指定索引,比如((SupplyChainRoot)getRootAgent()).vendorStartTimer[0],避免TimeMeasureStart[]转TimeMeasureStart的类型不匹配错误

方法三:正确使用set_startObjects方法

  • set_startObjects用于给TimeMeasureEnd批量绑定起始计时器,需传入TimeMeasureStart数组,示例代码如下(可放在TimeMeasureEnd模块的On initialize或流程图初始化代码中):
    timeMeasureEnd.set_startObjects(new TimeMeasureStart[]{ ((SupplyChainRoot)getRootAgent()).vendorStartTimer });
    
  • 注意必须用new TimeMeasureStart[]{ ... }包裹单个实例,解决数组初始化报错问题

内容的提问来源于stack exchange,提问作者Narges Hajloo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 14:25:22