sroverto
sroverto

Reputation: 61

AnyLogic - Identify seized ResourcePool

I am modeling a service process in AnyLogic thorugh hybrid simulation (DES + Agent based). In this process, I have different resourcePools, one for each employee available in the process. What I would like to knwo, is if I can get, through an AnyLogic function, the ResourcePool currently used by the seize block.The reason why I am needing this information is because then, by using a funcition, I will assign different delays based on the resourcePool seized (e.g., 10 minutes is is rpA, 15 minutes if it is rpB). I attach a shot example to show my problem. Let's suppose this is my process:

Process

I tried to follow the example shown in this post OtherQuestion

Thus, I created a variable myPool

myPool

To be used in the seize and module

seize

and in the resourcePool

rp

But I am constantly receiving errors when compiling the model (e.g., "The method myPool() is undefined for the type Main" in the rpA and rpB, and "The method myPool() is undefined for the type Main" in the seize.

My java skills are really basic so I am not really understading how to write the code I need in this question OtherQuestion to solve my problem.

Upvotes: 0

Views: 539

Answers (1)

Artem P.
Artem P.

Reputation: 816

Before providing an answer, here is an important piece of background knowledge: everything in AnyLogic is an Agent. The thing going through the Delay, the ResourceUnit, the Delay and ResourcePool themselves are all instances of Agent.

Knowing that, here is one way to do get delay time based on which resource pool was used:

double delayTime = (agent.resourceUnitOfPool​(rpA) != null)? 10.0 : 20:0;

The above statement uses a ternary expression in Java. This means that first agent.resourceUnitOfPool(rpA) is evaluated. That method "returns the first occurrence of resource unit of a given pool among the seized resource units, or null if not found.", meaning that:

  • if rpA was used then the value returned will be not null,
  • otherwise if rpB was used then the value returned will be null.

However, this isn't a good approach. It will work with this model but will likely be inadequate should you need to change the model in the future.

A good approach would be to create resource unit type and specify the delay time as unit property. Instructions on how to make custom resource units can be found here.

Upvotes: 1

Related Questions