简体   繁体   English

相同代理类型的不同延迟时间(AnyLogic)

[英]differen delay times for the same agent type (AnyLogic)

Hope you are all Safe希望你们都平安

Suppose I have the following process: 2 different sources, queue, delay, and sink.假设我有以下过程:2 个不同的源,队列、延迟和接收器。 I have an agent called "patients".我有一个叫“病人”的代理人。

My Goal: to have different service rates (delay time) for patients who are coming from the first source (using percentages).我的目标:为来自第一来源(使用百分比)的患者提供不同的服务费率(延迟时间)。 in other words, I want to have for example;换句话说,我想要例如; 10% of patients (who are coming from source 1) have delay time equal to 5 min and 90% have delay time equal to 10 min. 10% 的患者(来自来源 1)的延迟时间等于 5 分钟,90% 的延迟时间等于 10 分钟。

What I did: is that I assigned a parameter called "percentage" for the agent (patients).我所做的是:我为代理(患者)分配了一个名为“百分比”的参数。 and using "On exit" of the first source I typed并使用我输入的第一个来源的“退出时”

agent.percentage = 1;

and then on the delay time I wrote:然后关于延迟时间我写道:

agent.percentage = 1 ? uniform(0.1);

But it didn`t work, how can I do that?但它不起作用,我该怎么办?

You need to both你需要两者

  • store the source the agent came from;存储代理的来源;
  • randomly determine which delay time you need if they came from a particular source.如果它们来自特定来源,则随机确定您需要的延迟时间。

So your agent parameter should be called sourceNumber or similar (not percentage ), which you set accordingly when you create it (as you did).所以你的代理参数应该被称为sourceNumber或类似的(不是percentage ),你在创建它时相应地设置(就像你所做的那样)。

Then your delay time is something like the below (assuming the 90%/10% split is only for agents from source 1, and other sources have delay time 50 for illustration):那么您的延迟时间如下所示(假设 90%/10% 拆分仅适用于来自源 1 的代理,而其他源的延迟时间为 50 以供说明):

agent.sourceNumber == 1 ? (randomTrue(0.1) ? 5 : 10) : 50

If you need it more complicated (eg, more than two source alternatives), or want it to be more 'legible' with Java if statements and similar, you would write a function called, say, getDelayTime which returns a double and include a call to that function in the delay time expression.如果您需要更复杂的(例如,两个以上的源替代方案),或者希望它在 Java if 语句和类似的情况下更“易读”,您可以编写一个名为getDelayTime的函数,它返回一个double getDelayTime值并包含一个调用到延迟时间表达式中的那个函数。

NB : If you need individual source 1 agents to always have delay time 5 or 10 (if they go through that delay multiple times) then you need to do the sampling when you create them (and store the delay time they will get in, or an indicator of which delay time they will get, in the agent).注意:如果您需要单个源 1 代理始终具有延迟时间 5 或 10(如果它们经过多次延迟),那么您需要在创建它们时进行采样(并存储它们将进入的延迟时间,或他们将在代理中获得的延迟时间的指示器)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM