有没有办法在人群中找到特定的代理?

问题描述 投票:0回答:1

我目前正在开发一个项目,其中导入包含来自不同商店的订单的数据集。还有另一个导入的数据集,其中包含每辆卡车在送货时必须执行的商店 ID 序列。每个商店都分配有一个GIS点,目的是卡车按照指定的路线将订单运送到不同的商店。

我创建了一个对象订单,它有 4 个参数:数量、store1、store2、store3。第一个参数表示要运输的货物数量,其余参数明确表示这些货物将交付到哪里(即 store1 表示卡车必须移动到的第一个商店)。 我现在想要创建这些订单,但我需要找到一种方法将路线数据集中出现的 ID 与已从商店数据集创建的代理关联起来。 stores database routes database

我尝试使用 findFirst 函数,如下所示:

for(int i=0; i < excelFile.getLastRowNum("Sheet1");i++){

double amnt=excelFile.getCellNumericValue("Sheet1", i+2, 4)
double a1=excelFile.getCellNumericValue("Sheet1", i+2, 5); ##Cell with the Id of first store
double a2=excelFile.getCellNumericValue("Sheet1", i+2, 6); ##Cell with the Id of second store
double a3=excelFile.getCellNumericValue("Sheet1", i+2, 7); ##Cell with the Id of third store

Store store1=findFirst(stores,Store->Store.storeId==a1);
Store store2=findFirst(stores,Store->Store.storeId==a2);
Store store3=findFirst(stores,Store->Store.storeId==a3);

Order order = new Order(amnt,store1,store2,store3);

我已经尝试了不同的方法来定义条件“Store->Store.storeId==a1”,但它们都不起作用,并且我一直收到以下错误消息: “描述:UtilitiesCollection 类型中的 findFirst(Iterable, Predicate) 方法不适用于参数 (Qstores, ( Store) -> {})。”

anylogic
1个回答
0
投票

您编码不正确,请执行以下操作,用 x 或任何字母替换 Store:

Store store1=findFirst(stores,x->x.storeId==a1);

商店也必须是代理群体,或商店类型代理的集合

在你的情况下,你似乎有一个名为stores的数据库表,你不能使用它,首先你需要用你的stores创建一个集合,然后你可以使用findFirst

并且不要使用与商店数量相同的名称来调用数据库表。使用stores_db或类似的名称作为您的数据库表名称,否则AnyLogic会感到困惑

© www.soinside.com 2019 - 2024. All rights reserved.