How do I seize a subset of seized resources? - anylogic

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

Related

Different delay time for different agents in Anylogic

I'd like to know a very simple function of the software Anylogic: I have to set different delay times for different agents in a model, but the software let me see only one boxe and there's no possibilities to specificate what kind of delay time I prefer for every agents. How could I do? Thank you
I tried with some code of Java script but I think that scripture could be available only for the section "Actions" in the different boxes
This is one of the most basic functionalities so check the tutorials as well, but here goes:
Add a parameter 'myParameter' in your agent type of type double.
Give the agents different values for that parameter (cab be dine in the source or where ever you instantiate your agents)
In the delay block code section, use 'agent.myParameter' to access and apply that agent-specific duration.

AnyLogic: Changing ResourcePool based on programmatically created schedule

I refer to a similar problem here.
I implemented a programmatically created schedule same as in the example model from AnyLogic Cloud. Then I added the suggested code in the capacity field.
Still, my problem is the following runtime error: "The parameter capacitySchedule cannot be changed dynamically". Does it just basically does not work with the resource pool compared to the Transporter Fleet presented in the similar problem? Unfortunately it does not work with a fake schedule either.
Here are some screenshots from my model. Thanks in advance.
To work with dynamic capacity of ResourcePool, I use a schedule shift by plan.
in some cases it meets the need.
The implementation of this is simple, in the schedule you give values 1,2,3 etc. They actually point to a position in the array.
Example of the schedule
And inside the ResourcePool you define it as follows:
Example of the ResourcePool by plane
In my example, at times when the schedule value is 4 the capacity of the ResourcePool is 0 and at other times it is as per my parameters.
Change the "Kapaziät definiert" to "By schedule".
Create a fake schedule object fakeSchedule (normally, not programmatically). Make sure it always returns 0 as the value.
Then, use this call for "Kapazität":
' mySchedule == null ? fakeSchedule : mySchedule`
This will tell the pool to use your schedule if it exists, else the fake one

how to custom drop-off block according to agent type

Using previous pick-up blocks, i have an container agent with two different agent types inside (Myagent and Myagent1). I want to insert two different drop-off blocks,the first for Myagent and the second for Myagent1. the problem is which element type i should choose for the drop-off block. For example, if i chose Myagent, it would give me error because of Myagent1:
If i chose Agent then:
Both the agent have a parameter named cc.
(I read other answers on the forum like Drop-off specific custom agents using drop-off block in anylogic, but i still have this error).
thanks for the help.
The best option here is to create a parent agent type that has 'cc' property and have the two types of agents inherit from it as described here. Also as a side note, you should probably take care to name the agents and properties with something meaningful as it will help to understand the model and explain it should you need to ask for help in the future.

My goal is that all resources of a resourcePool perform an action at a specific time. How do I create this iteration?

I am simulating a hospital stay with anylogic, on multiple levels. Each level has its own staff, represented by different ResourcePool (doctor, nurses, OSS) I created the flowchart of the actions concerning the patient. Now I would like, at a specific time (lunch and dinner), the OSS do tour the patients.
How do I set up that all OSS of a ResourcePool go to the rooms?
I would like to create a very small parallel flowchart, with sieze, moveTo, delay and release.
TNX
Easiest way is to use the "Downtime" element to prescribe your resources to do some action, see image below:
Under the "task type" selection, you can send them to a separate flow chart using a "ResourceTaskStart" element and they will do what you put downstream of that (moveto, delay...). Make sure to finish that with a ResourceTaskEnd block.
PS: The "Downtime" block can easily be triggered via a schedule. Make sure to read the help on that block (and the ResourceTaskStart/End blocks) and study the example models that use those.

Anylogic: how to individually address to resources within a Resource Pool

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.