【问题标题】:AnyLogic: how to get 2nd or 3rd nearest agents?AnyLogic:如何获得第二或第三最近的代理商?
【发布时间】:2022-11-30 04:36:41
【问题描述】:

在基于代理的模型中,假设我有 10 个位置,每个位置都有随机人数(10~20)。另外,我有 5 个设施位置。现在我可以使用 getNearestAgent() 将所有人从每个人员位置发送到最近的设施。但我想将 70% 的人送到最近的设施,20% 的人送到第二最近的设施,10% 的人送到第三最近的设施。我怎样才能做到这一点?

我将所有位置都放在 GIS 地图中。并成功将人员送到最近的设施。

Actual implementation

【问题讨论】:

    标签: anylogic agent


    【解决方案1】:

    创建一个将人作为参数并返回位置的函数:

    Location nearest=person.getNearestAgent(locations);
     if(randomTrue(0.7)){
          return nearest;
     }else{
          
          List <Location> otherLocations=findAll(locations,l->!l.equals(nearest));
          Location secondNearest=person.getNearestAgent(otherLocations);
          if(randomTrue(2.0/3.0){
                return secondNearest;
          }else{
               List <Location> otherLocations2=findAll(otherLocations,l->!l.equals(secondNearest));
               return person.getNearestAgent(otherLocations2);
          }
    
     }
     
    

    【讨论】:

      猜你喜欢
      • 2015-08-13
      • 1970-01-01
      • 2021-11-05
      • 2020-04-12
      • 2014-09-02
      • 2019-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多