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

AnyLogic集装箱码头:PrepareLoading块精准入站逻辑实现咨询

AnyLogic集装箱码头加载机制实现方案

步骤1:绑定Wait块触发逻辑

  • 打开Vessel流程中的Wait块,在「On enter」事件中调用自定义函数,传入当前Vessel代理:loadContainersForVessel(agent);

步骤2:编写自定义加载函数

在模型中创建名为loadContainersForVessel的函数,参数设置为Vessel currentVessel,返回类型设为void,代码如下:

// 获取当前船舶剩余装载容量
int remainingCapacity = currentVessel.capacity;
// 从存储系统筛选目标船舶匹配的集装箱
List<Container> targetContainers = containerStorage.select(c -> c.TargetVessel == currentVessel);
// 确定实际可装载数量(取剩余容量与筛选结果的最小值)
int numToLoad = Math.min(remainingCapacity, targetContainers.size());

// 逐个转移符合条件的集装箱至PrepareLoading块
for(int i = 0; i < numToLoad; i++) {
    Container container = targetContainers.get(i);
    PrepareLoading.take(container);
}

关键注意事项

  • 替换containerStorage为你模型中实际存储Container的模块(如Storage、Queue)或自定义集合变量名
  • 确保currentVessel.capacity对应Vessel代理中定义的容量变量,根据实际命名调整
  • Container.TargetVessel需为绑定Vessel实例的变量(而非字符串),保证匹配逻辑准确

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 13:42:38