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

AnyLogic 8.1订单拣选系统SelectOutput路由触发空指针异常

AnyLogic 8.1 环形传送带拣选系统空指针异常问题

模型背景与架构

使用AnyLogic 8.1完成大学项目(学校许可限制只能用此版本),模型为包含12个订单拣选工位的系统:

  • 每4个工位通过环形传送带组成1个SubArea,共3个SubArea
  • 3个SubArea通过主环形传送带(Area)连接,订单在主环不同点注入/退出,可进入子环访问工位

Order智能体属性

  • stations_to_visit:存储需访问的Station智能体的ArrayList
  • visited_stations:存储已访问Station智能体的ArrayList
  • next_station:下一个需访问的Station智能体实例

Station容量规则

每个Station最多容纳3个订单:1个在Delay块处理,2个在传送带上

路由逻辑(SelectOutput块)

SubArea内路由

  • 前4个SelectOutput调用select_output_branch函数,判断订单是否需进入当前工位且工位有剩余容量:
// select_output_branch
if(!order.stations_to_visit.isEmpty() && order.next_station == station && station.number_of_orders < station.max_number_of_orders) {
    return false;
} else {
    return true;
}
  • 最后1个SelectOutput调用select_output_exit函数,判断订单是否完成所有访问或下一站不在当前SubArea,是则返回主环:
// select_output_exit
if(order.stations_to_visit.isEmpty() || order.next_station.subArea != sub_area) {
    return true;
} else {
    return false;
}

Area主环路由

  • 前3个SelectOutput调用select_output_branch函数,判断订单下一站所属SubArea是否为当前子区域且子区域有剩余容量:
// select_output_branch
if(!order.stations_to_visit.isEmpty() && order.next_station.subArea == sub_area && order.next_station.subArea.number_of_orders < order.next_station.subArea.max_number_of_orders) {
    return false;
} else {
    return true;
}
  • 最后1个SelectOutput调用select_output_exit函数,判断订单是否完成所有访问,是则路由至出口:
// select_output_exit
if(order.stations_to_visit.isEmpty()) {
    return true;
} else {
    return false;
}

主流程(Main中的Flow Controller)

  1. 订单创建:Source按调度生成订单,调用generate_new_stations_to_visit随机分配需访问工位,设置next_station后移入orders_to_inject群体
  2. 订单注入:injection_event触发inject_order函数,检查可用订单及Area容量后,将订单注入Area入口
  3. 工位访问完成:Station的Delay块调用visited_station函数,将当前工位移入visited_stations,从stations_to_visit移除,并调用select_next_station_to_visit更新next_station

所有Enter和Delay块均禁用强制推送

异常情况

运行时触发NullPointerException,报错栈:

Exception during discrete event execution:
NullPointerException
    at com.anylogic.libraries.processmodeling.Conveyor.e(Unknown Source)
    ...

已排查步骤

  • 监控各块订单出口,未发现空订单
  • 发现Area的number_of_agents计数器与传送带总订单数不符,怀疑异常发生在Area的Enter块
  • 简化模型(移除优先级逻辑)、重建模型,问题仍存在
  • 移除SelectOutput的路由逻辑后异常消失;仅移除SubArea的路由逻辑改为random(0.5)也无异常
  • 搭建仅含AnyLogic基础块和默认智能体的模型,仍触发异常,怀疑是版本bug

寻求解决方案

需要解决该NullPointerException问题,确保模型稳定运行

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 06:15:32