I would like the capacity of a resource pool to go from 2 to 1 at a specific point in time. As of now, I am using an event to trigger a reduction in a variable. This variable is what I use to define as the resource pool capacity so logically I would think that the resource pool capacity would drop as well. However, when the event triggers, the variable reduces but the resource pool capacity does not, even if the resources are idle and have no tasks.
Resource Pool capacity is not dynamic, so if you set it as a variable, the variable will only be accessed on model start-up. Changing the variable value during model runtime will not make a difference.
To change the capacity you need to use:
resourcePool.set_capacity(value);
Replace value with the variable name you are using.
For your information, fields preceded by an equal sign are static while those preceded with a circular arrow are dynamic. The example below shows both:
Related
If I add a slider to control a resourcepool capacity, increasing the slider adds the resource to the population. However, how do I delete resources from the population when i decrease the slider? And what will be the delete order be? (From last added agent?)
To destroy them, simply the the property "when capacity decreases" as below:
To test the sequence of destruction, run a few tests by addinga traceln command in the "on destroy unit" code box in the resource pool properties. It probably first destroys idle units but maybe simply destroys the oldest.
I have a resourcePool block. The resource units are Worker type.
However, I cant't access this units calling the resourcePool block from conveyor Stations nor from Service blocks. No matter if I use "agent" or "unit" (in Station -> Resource choice condition), I only can access to resourcePool.agents(), which is a list from which I can't access to Worker agent.
Does anyone knows why, and how could I access to Worker agents considering they are created as Resource Units?
You use agent populations for this. Create an empty population of Worker agents and set the Resource Pool (in its Advanced properties) to add units to a custom population (and select your population).
Now all the resource units are accessible via the population.
I’m working with a AnyLogic simulation on emergency department. The departments leader want to test the benefits of adding, nurses, treatments room etc. It was easy to make it so that they can dynamically change the number of nurses through the GUI, as this is a "Moving" resource type. However, how can I dynamically change a Static resource type like ED-rooms which is tied to specific Network Nodes?
It's not that I want the resource pools to be dynamically created. But it's that I want to control how big of a portion of the existing resource pool that will be used. The current capacity is 13 rooms, and I want this to be varied from 13 to 28
Using get_Capacity(n) works for non-static resources such as Nurses etc. but when I use .set_Capacity(n) for a Static Resource I get the following error:
"(ECRoom is here referring to rooms in the emergency department): java.lang.RuntimeException: root.ECRoom: Capacity definition type should be 'Direct' to support this operation"
The easiest way is to just pre-define several ResourcePool elements with static ED rooms linked to whatever node they would be using.
Then, set their normal capacity to zero and only change it to some non-zero value if the user wants it.
If you simply need to change the capacity at runtime, myResourcePool.set_Capacity(someNumber) is your friend :)
(Dynamically creating resource pools, home nodes, etc. is all possible but a whole different ball-game)
I have a pool of 25 agents (Operators). When an Order is generated, I seize a few Operators and move them to one of many different ProductionSuites as determined by a parameter in the Order.
Within the ProductionSuite, I have a variable of type ResourcePool that I would like to use to have these Operators perform tasks.
In the main window, I put this code in the "On seize unit:" code box:
agent.assignedSuite.suiteOperatorPool.addAgentToContents(unit);
but this triggers a NullPointerException error. Am I using the addAgentToContents method incorrectly?
You have not initialized your suiteOperatorPool variable, it's "initial value" field is empty. Hence, this is just an empty shell of type ResourcePool that cannot do anything, including adding agents to it.
You would need to initialize it properly using the ResourcePool API, but I don't think that is possible.
Also, you cannot have resources be part of 2 resource pools, as you are trying to do. You should think of a different way to solve your problem. Maybe rephrase the issue so we can think of alternatives. You might not need a RP at all but just use pure agent functionality...?
I am using Anylogic where I have just one ResourcePool made by just one Resource Type unit (created through the command "Resource Agent" in the Process Library).
I define the capacity of the ResourcePool, let's say, to 20 and I would like to have each of the single element (or some of them) within the Pool with a different value for the same parameter (e.g 3 units have parameter=1 , other 4 units parameter=2 ...).
First of all how can I set individually each of this parameter? Do I need to use a population of agent? If yes how can I do that? And how can I call the resourcePoolPopulation in other location within the model?
Is there a clevere way to do that?
Hope it is clear, thanks!
That is a weak spot of resource pools, IMO. They are designed to hold a homogeneous "soup" of similar resources and it is hard to pull in a specific element.
However, not impossible, there are various ways. You can create your resource agents manually in an agent population first and add them to the pool manually after creation. Then, in the service object, tick "manual resource unit choice" (or similar) and use a criteria that matches your resource params.