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

AnyLogic技术问题:统计Agent经ServiceBlock次数并控制SelectOutput分流

AnyLogic中SelectOutput逻辑修正方案

问题根源

当前SelectOutput仅设置了「次数小于10」的判断条件,未实现「次数不足10时按15%/85%概率分流」的核心逻辑,导致不符合预期。

修正步骤

  1. 保留现有正确逻辑:

    • Agent类型中初始值为0的int变量rounds
    • ServiceBlock的On Exit事件中执行((Agent) agent).rounds++;(用于统计经过次数)
  2. 修改SelectOutput的条件表达式:
    将原条件替换为:

    ((Agent) agent).rounds >= 10 || randomTrue(0.15)
    

    逻辑说明:

    • 当rounds >=10:强制触发True端口,Agent进入Sink(满足「达到10次必须离开」的需求)
    • 当rounds <10:通过randomTrue(0.15)生成15%的概率触发True端口,剩余85%概率走False端口回到ServiceBlock(满足概率分流需求)
  3. 验证逻辑:

    • 若Agent第9次离开ServiceBlock,rounds=9,此时15%概率直接去Sink,85%概率回到ServiceBlock,rounds变为10
    • 当rounds=10时,条件必然成立,Agent直接进入Sink,不会再循环

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.30 09:09:56