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

AnyLogic中零件二次加工及优先级调度的仿真建模求助

AnyLogic生产流程仿真最优实现方案

1. 实体类型定义

创建自定义Agent(命名为Part),添加枚举类型属性partType,枚举值包含PART1、PART2、PART3,用于区分不同阶段的工件。

2. 核心组件配置与逻辑实现

步骤1:Source输出Part1

  • 拖拽Source组件到画布,设置实体类型为Part。
  • 在Source的On exit事件中添加代码:
    agent.partType = PartType.PART1;
    
  • 根据需求设置实体生成速率、数量等参数。

步骤2&3:Machine1加工Part1生成Part2并送入Queue1

  • 拖拽Machine组件(命名为Machine1)和Queue组件(命名为Queue1)到画布,连接Source→Machine1→Queue1。
  • 在Machine1的On finish processing事件中添加代码,完成工件类型转换:
    if(agent.partType == PartType.PART1){
        agent.partType = PartType.PART2;
    }
    

步骤4:Queue1中Part2优先送回Machine1加工

  • 拖拽SelectOutput组件到画布,连接Queue1→SelectOutput。
  • 给SelectOutput的第一个分支设置过滤条件:agent.partType == PartType.PART2,将此分支连接到Machine1的输入端。
  • 启用Machine1的优先级调度:
    1. 选中Machine1,在右侧属性面板找到Priority based on agent并勾选。
    2. 设置优先级表达式:agent.partType == PartType.PART2 ? 2 : 1(数值越高优先级越高,确保PART2优先于PART1)。
    3. 将Machine1的内部队列类型改为Priority queue,确保等待加工的工件按优先级排序。

步骤5&6:Part3流向Sink

  • 给SelectOutput的第二个分支设置过滤条件:agent.partType == PartType.PART3,将此分支连接到Sink组件。
  • 在Machine1的On finish processing事件中补充代码,处理PART2到PART3的转换:
    if(agent.partType == PartType.PART2){
        agent.partType = PartType.PART3;
    }
    
  • 加工完成的PART3会流入Queue1,随后被SelectOutput分流到Sink。

3. 关键验证点

  • 运行模型时,观察Queue1中PART2是否优先被Machine1拉取加工。
  • 确认PART3不会进入Machine1,只会流向Sink。
  • 检查Machine1的加工队列,确认PART2始终排在PART1之前。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 06:32:05