简体   繁体   中英

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. 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.

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).

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):

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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