How agents will wait in the queue for there turn to go to the Delay section? - simulation

I used seize-move-release in order to move the agent with the resource. shown in the figure below.
Problem
Now the only problem is, how agents will wait in the queue (capacity 2) for there turn to go to the Delay section using resource. Explanation is in the image below.
What i am trying to achieve:
I mean agents wait in the queue (capacity 2). Once the delay(machine) gets empty, only then resource transfer the agent from the queue to the delay.
Note:
I try to use service because Service block have queue too but I need the queue before the resource pool.
I hope I explain my problem well let me know if I miss some thing.
I used Wait Block for the agents to Wait but when wait capacity equals to 2 . Agents stop moving forward.

Use a "Wait" object ahead of moveTo.
Whenever the delay capacity decreases to zero ("on exit" code box of delay you can check it using delay.size()==0?), you can tell an agent in the "Wait" object to advance now, using wait.free(agentToFree).
If you want to free the oldest agent, use wait.free(wait.get(wait.size()-1))

Related

How to manually increase the task’s priority by code, using the On task suspended action of the service block

I want to do as written in the title. I'm referring to the part of Anylogic's service block page that says:
“If this order does not suit your needs, manually increase the task’s priority by code, using the On task suspended action of the block.”
I couldn't find how to do it. I did find in the seize block function that recalculates the priorities of the agents in the queue, but this function does not exist for the service block.
Here is a link to the help page:
https://anylogic.help/library-reference-guides/process-modeling-library/service.html
I will add that my goal is to use downtime for service with the policy "seize any unit" but the default of Analogic is to put the suspended agent in the back of the queue. I need it to be the first to seize the next available resource.
Thank you very much!

Implementing a downtime on a resource that waits for the resource to finish its task before delaying it

I'm trying to represent a machine that works for a x amount of time before warning the operator that the oil tank needs to be refilled. Have in mind that the machine doesn't stop as soon as it send the warning message out. That way, the operator will wait until the machine stops any activity it had already started, and once it's done, he'll stop the machine and fill the tank.
In order to represent this process I'm using a Station block from the Material Handling library, that seizes a resource from a resource pool block, to which a downtime block is applied.
Is there a way to make the downtime block wait until the machine stops before performing the maintenance?
I also want to associate a resource pool representative of the operator to the downtime block, so that the operator is busy during the downtime, since he's the responsible for filling the tank. Can I do that?
Thank you in advance!
Is there a way to make the downtime block wait until the machine stops before performing the maintenance?
Yes, explore how Priorities work. Give your machine task a higher priority than the downtime task and ensure that the downtime block does not preempt other tasks:
I also want to associate a resource pool representative of the operator to the downtime block, so that the operator is busy during the downtime, since he's the responsible for filling the tank. Can I do that?
Yes, set the task type to "go to flowchart" and use a custom flow chart to seize from a resource pool (again, check the help on how to set this up in detail):
PS: Please only ask 1 question per issue always. See https://stackoverflow.com/help/how-to-ask and for AnyLogic https://www.benjamin-schumann.com/blog/2021/4/1/how-to-win-at-anylogic-on-stackoverflow

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

Anylogic: How to keep an agent waiting in queue until it changes state? (Discrete Events flowchart)

I'm starting to use Anylogic for a simulation class, and for this I need to model the following behaviour: there's a stream of agents that enter a FIFO queue, and then enter into a server (that I modeled with a delay block), one at a time. The agents have two states (call them A and B), and if an agent reaches the end of the queue in state A, it has to wait until it returns to state B to go into the service.
I think a wait block with capacity for one agent, between the queue and the delay block could potentially solve this situation. But I don't know how to make the wait block to free the agent as soon as it changes state.
Other methods are welcome. I just need the agent to be retained before the delay block as long as it is in the state A, but not any longer. Thanks in advance.
Yes... a wait block with capacity 1 after your queue block is what I would do.
Now when your agent enters the state, on the entry action of that stateB you do the following:
if(currentBlock().equals(main.waitBlock) && main.service.size()==0){
main.waitBlock.free(this);
}
You will also need to do this in the "on enter" of the wait block:
if(agent.inState(agent.stateB) && service.size()==0){
self.free(agent);
}
also, just in case, add a population of 0 of your agent type in main, to be able to use main. in your agent state code.

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?