Agents not leaving the queue before a transporter is free - queue

in my model I have a queue were multiple agents from different sources come together to seize an transporter ( see picture). But now they leave immediately after they enter the queue to the seize transporter block. But I want to keep them in to queue until a transporter is free and then the first one in the queue should seize a transporter and so should move to the seize transporter block. How should I fix this?

There are several ways:
After the queue, add a RestrictedArea elements to limit the number of agents in the Seize seizeTransporter4 element. In the queue, you can sort the agents.
Instead of a queue element, use a Wait element, in which case you need to write the logic for extracting agents and sending them to seizeTransporter4 element.
The second way is more flexible in terms of writing logic.

seizeTransporter has its own embedded queue. You can access that value with seizeTransporter4.size(). If you insist on having them separately, instead of queue, use delay block, with stopDelay option. Whenever the seizeTransporter4.size() drops below number of available transporters, run the stop delay function. Like
if (seizeTransporter4.size()<=3){
myDelay.stopDelay(myDelay.get(0));
}

Related

How to combine transporter related blocks with Delay, Queues and other blocks from Process Modelling Library?

A source is producing "productA". "productA" is moved by a transporter called "agv" from node1 to node2. On the way between the two nodes I want to put several tasks like for example delay or queue. These tasks can be implemented by Process Modelling Library blocks. When using them you have to set an agent type. Which type do I use now? "productA" or "agv"? When using "agv" an error accurs because that type is not equal to the source agent. When using "productA" tasks from the process Modelling blocks are only executed for this agent, not for "agv". How to deal with that? Is there a way to create a new agent which contains "productA" and "agv" and overwrites the source agent? How will that not contradict with the transporter fleet block?
You need to use ProductA as this is the main agent flowing through the blocks. It just "uses" an AGV to be moved around, similar to a resource.
If you want to stop and do things with the product and the AGV, you use the SeizeTransporter block first, this makes your product seize an AGV.
Then, you can make them do anything by dropping blocks: queues, delays, Move By Transporter. Just make sure to finish up with a Release Transporter block when all is done.

Priority based queue in Anylogic

I am using a priority based queue to pick agents from a pallet rack. Priority of agents can be 0 or 1. If there are 10 agents in palletRack, I want to pick all the agents having priority=1 first. My problem in the current flowchart is: Agents with priority=0 are pickup up before agents with priority=1. May be because the agents enter & leave the Queue block one by one, multiple agents aren't present in the Queue block at the same time so that they can be sorted. How to resolve this?
put a hold block between queueStorage2 and pickFromStorage1 and on the on enter action of queueStorage2, you check if all your agents are there, and if they are (with whatever condition you need to check to be sure everything is there) you unblock the hold with hold.unblock();

Accessing Queue Priorities in a Seize Block

According to the AnyLogic's documentation, a Seize block embeds a Queue block, and "The rich interface of Queue (ability to use priorities, timeouts, remove agents, etc.) is fully exposed by Seize.".
I want to access the queue portion of a seize block in order to make agent prioritization, which can be found under the first "Advanced" tab of the Queue block properties. However, I cannot see this in the properties of a Seize block.
Is there anything I have to do in order for this property to appear in the Seize block? Or do I have to set the queue capacity of the Seize block to 0 and add a separate Queue block in front? I want the model to be as readable as possible for my case organization, thus I want to use as few blocks as possible.
In the seize, the conceptual difference is that instead of "queue priority" you have "task priority"
You can basically do everything related to priority using only that. If you do nothing, you use FIFO, if you want to prioritize based on priority based, well then it's the exact same. If you want to use LIFO, then you can use agent.getBlockEnterTime() as your priority variable, and if you want to compare agents, it's the same as using priority based.
So no, you don't need to add another queue

How to store agents in a block untill a tronsporter can move them?

I'm a new AnyLogic user so hopefully this is a simple problem. I would like to use a block as to represent a storage area for items to be used in an assembly, I am using the delay block with delay time of 0, but maybe the queue block would be more appropriate? I have set up a model in which every X number of seconds a "truck" arrives and if the delay block contains less than a specified capacity of elements, the inject function is called to refill the block. This sort of works, but is seems that the agents are flowing through the delay block's out port and thus do not count toward its capacity (that makes sense to me...) resulting in my source blocks continuing to create agents when the system isn't ready for them. My delay block is followed by a "move by transporter" block which seems to be getting all of the delay blocks outputs immediately. There are only two transporters in my model and I am not sure why more than two agents can be accepted by the transporter block at a time. I set my transporter fleet to have a capacity of 2 but that did not solve the problem.
Any advice would be helpful! Perhaps a different approach is needed. My goal is to have an essentially unlimited pool of parts at the inlet of the factory, but only create agents when the downstream processes are able to pull them in. Thanks in advance!
Welcome to SOF :)
Best use a "Wait" block here:
Let your trucks dump stuff into "Wait" whenever they arrive. Your downstream block can now pull them when they are ready using myWaitBlock.free(someAgent for as many agents as they want to pull from it.
Similarly, you can use a Delay with infinite capacity and set its type to "Until stopDelay() is called". Then similarly as the "Wait" block, you call myDelayBlock.stopDelay(someAgent) when you want.
Another option: Use a hold-block in front of a normal (infinite) queue and unblock it when ready: myHoldBlock.unBlock(numToLetThrough) --> probably the easiest
PS: Please also check how to ask good questions here on SOF, yours is very long, much easier to understand with some screenshots :) --> https://stackoverflow.com/help/how-to-ask

Request entity from Anyogic Process Block and wait until it's available if there is not currently one

I'm trying to emulate what QUEST does when a buffer is queried for a certain Part. In there if the part is not in the buffer the request is left pending and if a Part arrives to the buffer it's released to the machine requesting it. I have also seen this behavior in SimPy which is another DES engine.
I can't seem to find a simple way to do this in AL. The queue block has the following methods:
release(agent): Will return false and forget about the request if there's not an agent as the one specified
remove(agent): Will return null if there's no agent in the queue
So those methods won't do what I want...
It gets a little more complicated as the queue contains agents with parameters and I want to request a specific set of parameters (let's say the agents have a number parameter that can go from 1 to 3 and I'm only interested in agents in the queue if this parameter has the value 2).
Also there's a series of agents pulling this agents from the queue simultaneously and I'd like a priority to be set (let's say FIFO)
so there's a couple things that I've tried and have lead me nowhere:
Using a seize block instead of queue and adding the agents to the embedded queue in the seize block. -> I can't find the proper method to seize from the buffer in a different way from a buffer block (so I moved to option 2) but seize does have a promising customize resource choice that could help with the parameter down-selection
Using a seize block and storing the agents in a pool as resources. issues with dynamic creation of resources, seizing the appropriate one etc...
Creating a queue of requests that have returned null from a queue. This sounds like an overkill but I'll look into it
All of those appear to be a bit complex for such a simple thing in other softwares for simulation so I'm wondering if I'm missing something or if someone has come across this issue before
Suggestion 1: may it helps you to store the agents in the queue in a collection (or different collections, according to the parameter settings). Events: "on enter" and "on exit"
Suggestion 2: may the Wait - block helps you here?