AnyLogic: Error when different resource pools are used in parallel using Add List Button - simulation

after answers and comments given in my previous question, I encountered new error when using such configuration. before depicting the error, it would be valuable that you consider that I have 5 different resource pools and their capacity is either 1 or zero. number of resource pools with capacity one is determined by user when he declares number of total workers working in this section. In other words I have modeled each worker as one resource pool and according to the fact that number of workers is supposed to be variable; I change the capacity of excess resource pools to zero. first of all is it a right approach?
second when I use such configuration,
(each resource is different and because of their name length last numbers are not visible, i.e. demontage140W1, demontage140W2 and so on)
such an error is encountered:
Internal error: there are reserved units in one-by-one request while pool root.demontage140WorkersPool1 is being discarded: Request P-20-P-NP from root.<population>[19] (at root.seize) for resources [null:0, demontage140WorkersPool1:1, demontage140WorkersPool2:0, demontage140WorkersPool3:0, demontage140WorkersPool4:0] with sets [null, [0, 1, 0, 0, 0], null, null, null]
Does anyone knows what should be done to solve the problem?
NEW DATA-EDIT
This image shows the condition of two first resource pools when the error has occurred. Any new Idea?

Related

Assigning certain agents to a certain resource unit based on source

I currently have 2 different source blocks, 1 that sources agents for one half of the day, the other for the other half. Both converge into the same starting point of the model. I am only using 2 different sources to help simulate 2 different halves of the day.
I also have a resourcePool that increases in capacity from 1 to 2 at time() == 150. How can I ensure that the 1st resource unit that starts the day interacts only with those agents coming from source1, and the 2nd resource unit that arrives at time 150 only interacts with those agents coming from source2? Agents from both sources go through the same seize blocks that seize 1 unit each of 2 different resources at the same time.
There is a short overlap in which both resource units are working, so I want to ensure that one is not interacting with the other's agents.
You need to make use of the resource choice option inside a size block.
To do this start by having a new agent that will represent the resources inside your resource pool and give it a variable that you can use for assigning what source agents it will take. e.g. have an int variable sourceNumber
Now when you increase the number of resources in the resource pool from 1 to 2, you assign the source number of the second resource to 2.
resourcePool.set_capacity(2);
int counter = 0;
for (MyResource r:resourcePool) {
r.sourceNumber = counter;
}
If the agents that need to seize the resource all use the same seize blocks it is perhaps best to make a custom agent and send the seize block from which they came to the agent.
Then inside the source the resource choice field van be used to dictate the correct resource to use

Anylogic resource pool capacity while on linking with slider

I am trying to make my resource pool available/not available as per defined on/off schedule.
Anylogic asks the capacity when on, i have mentioned it as 2.
But i want it to be connected with a slider so that capacity while on can also be made variable while running the model to test the effects.
when i am trying to link the slider, my desired resource pool gets "disabled".
only those resource poolss are shown as enabled whose capacities are defined as "Direct" but not by schedule.
what to do?
You can link the field Capacity when on of a resource pool dynamically with the current value of a slider using the function slider.getIntValue().
Please note however, that the resource pool capacity can't be changed for the current active shift (when the on/off-schedule is currently "on"). So for example, if your shift is currently active with a capacity of 2 and you changed the slider value to let's say 3, the result will be:
Capacity during the current "on" shift: 2
Capacity during the next "on" shift: 3

AnyLogic: two customer classes having different priorities

I know the basics of AnyLogic/Process Modeling Library and am about to teach simulation of basic queues with AnyLogic, transitioning from Simul8 that I 've used for many years.
I have agents of two types, 1 and 2, sent to respective queues 1 and 2, which then feed a single "service" point, so that type 1 takes higher priority (that is, whenever service is ready to pull work, it pulls from queue 1 if it is non-empty, regardless of the size of queue 2). How to capture this as simply as possible?
Having seen the reference pages for a Queue object, my preliminary (unworked) idea is to use a single queue, and control agent priority by the Queue.QUEUING_PRIORITY- Priority-based" option.
For comparison, a solution in the Simul8 software is: set "service" routing-in discipline to "priority"; and assign different priorities to the two queues.
Yes you are right you cant use two queues as the pull from the queues will be done in a round robin fashion. See the screenshot below from the AnyLogic training textbook
You should use queueing in a single queue and you can have either a single parameterised source or two.
See example below
I have 2 sources and at each of them, I set the priority to a local variable inside my agent. Agents from source 1's variable is set to 1 and the from source set to 0.
Then inside the queue, I set the priority so that the agents from source 1 is always in front.

Service block reduce delay time using resource pool workers

I have a resource pool and a service block. The number of the operator in the resource pool is 5 which is linked to the service block. I would like to setup the service in a way that the more workers work on the service the delay time decreases. (ex: if 1 worker works the delay time is 10 min - if 2 workers work the delay time is 5 min. - if 3 workers work the delay time is 3.33 min). I would like up to 5 operators to be working at the same time in the service block based on their availability.
Service Block and Resource Pool
How can I achieve this?
So you're trying to do two things with your Service block:
Seize a dynamic number of units (in the simplest case, seize all available units).
Have the delay time dependent on the number of units seized (in the simplest case, just decreasing multiplicatively according to the number of resources).
For the former, assuming you're seizing from a single pool, just enter a dynamic expression in the "Number of units" property. In the simplest case (seize all available) it would just be pool.idle() (for a resource pool called pool) but that's problematic if the next agent arrives whilst the first is being processed (because it will be treated as needing zero resources) so, depending what you want, you might need to do something like put RestrictedAreaStart / End blocks around your Service block so only one agent can be in the Service block at once.
NB: AnyLogic currently has a bug/limitation that the resource pool's idle/busy counts (from its idle() and busy() functions) are not guaranteed to be correct unless you are at a later simulation time than when seizes/releases occurred. (This is due to how things are resolved in hidden events under-the-covers.) So, if you want to use them in your determination of the number of resources to seize you need to work round this; e.g., by
tracking the number of busy/idle units via your own counts;
using the isIdle() function on individual resources in the pool instead (which typically requires ensuring the resource pool agents are in a custom population, not the hidden default one, so you can explicitly reference/loop through them);
something horrible and hacky like adding a very-small-timeout Delay block before entering a Service block (possibly within RestrictedAreaStart / Ends to ensure that agents don't make it into the Delay, and hence the Service block's seize mechanism, until you want them to).
In general, it makes sense to put the resources-needed calculation in a function (which returns an int and takes the agent as an argument) which you call in the "Number of units" expression. That way you can make the calculation as complex as you like; it would seem you might need a more complex consideration than just "grab everyone" (e.g., perhaps depending on the stream of to-arrive agents if you have knowledge of them, etc.). Maybe, for example, you'd also want to hold your arriving agents in a Wait block beforehand and only release them when the number of resources you want are available. (You'd need to give more precise detail about your requirements to be any more definite here.)
For the variable delay time, have an appropriate dynamic expression for the delay time; you can use the resourceUnits() function to get a list of the resource units seized by your agent. So, in the simplest case (decreases multiplicatively according to the number of resources) it would be something like 10.0 / agent.resourceUnits().size() (for a base delay of 10 time units).

AnyLogic "End of Shift" logic

I have a resource pool that adds units into the population "forklifts". The agents of type Forklift are chosen by other agents and later seized for specific tasks. There is also a schedule for the resource pool.
The problem is that whenever capacity decreases, forklifts units that are moving in the model (but not seized yet) are halted because they are no longer active. Is there a way to customize the choice of resources for the "end of shift". I cannot find anything in Help or online.
Thanks!
I have tried iterating through the resource pool but there is no function I could find to determine whether a unit is active or not. There are boolean functions for idle and busy.
agent.unload_forklift = findFirst(forklifts, f->f.in_use == false);
There are agents that choose resource agents based on internal variables. Maybe I could iterate through the resource pool instead of the population...
I expect forklifts' capacity to decrease based on a customize signal not randomly.