Make pedestrians divert to another queue if QueueTime Exceeds a preselected Value - queue

Edited Version:
I'm actually modelling an airport check-in terminal. It works fine so far, but additional I'm still trying to implement a function, that allows my pedestrians not to enter the service-queue if the queue time exceeds a preselected value (e.g. already 15 Passengers in the queue) and therefore walks to some kind of backup Service that opens during this busy times.
Here is my approach:
Variable QueueSize returns permanently the actual Number of Passengers in the Queue.
Every time a ped enters the pedservice block CheckInEco, the function waitingTime() starts:
QueueSize = CheckInEco.size();
if (QueueSize > 15) CheckInEco.cancel(ped)
So, as soon as there are more than 15 Agents in the queue, number 16 should bypass and move to an alternate ServiceBlock, which I would connect to the ccl Port of the CheckInEco Service. But when building the model, I get this message: ped cannot be resolved to a variable?
According to Anylogic Help, it should be possible to use this cancel - call, but I'm not really experienced with it.. Maybe, someone can help me out?

You can simply use a select output block to prevent pedestrians from going into the service block if there are more than 16 pedestrians already in.
Your original question had to do with waiting time, you should follow the exact same approach. But with waiting time it gets more complicated since you don't want to take the average waiting time from the start of the simulation.... so you need to decide if you want to take the last 10 minutes, 1 hour etc and do you want to include the current waiting time of agents in the queue. Since this is the the questions anymore I am not going to add it here, perhaps ask a new question if this is still the case.

Related

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

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))

How to send agents to sink block if aging higher than threshold

I am building a model where at any point in time if any agent is in system beyond threshold it has to go to Sink block. Is it possible to do it based on Agent time in system ?
If agents spent 180 days and beyond I want to send it to write-off block
what you need to do first is to create an enter block that connects to your sink block
With that done, most of the blocks have a remove method associated, so you can do this, with any agent a:
a.currentBlock().remove(a);
enter.take(a);
Nevertheless, this is not good practice in my opinion, removing an agent from any block at any time will almost certainly mess up your flow logic in some way...

Temporary adjustment of delay time

I have the following problem which I am unable to solve:
I have a situation where a security point (added as delay) holds every half an hour a 15 min break. After the break, the security guards increase their speed till the queue is shorter than 10pp.
I wanted to model this as follows: a state chart with delay.set_capacity(0) after 30 minutes and delay.set_capacity(1) again after the 15 min break. For the increased speed after the break, I added an additional state with condition: queue.size()>10 and now I want to set the action such that the delay function changes the delay time from exponential (1/10) to exponential (1/5) as long as queue.size()>10.
Anyone experience with which function in the action box to use? Or would you suggest a different function?
Since you are using, or at least want to use a statechart I would suggest the following design, where you have composite states inside the working state to indicate if the security agent is working fast or normal and a message transition to let it move from one state to the next.
It is advised to use a message transition and trigger it as needed instead of a conditional state which gets chected for every change inside the agent since this can be a computational expensive exercise.
I assume you already implemented the correct capacity settings for the different on enter actions for working and breaking
Now you simply need to send the message every time an agent enters the queue and every time it exits the delay block, and of course, see the delay time based on the state of the statechart.
Aee screenshot below.

Scheduling Queue for First Come First Server Algorithm

I have the above table, and i have to make a gantt chart for first come first server (FCFS) and Round-Robin (RR) algorithms, also something called a wait queue which i really don't know what it is, after googling a bit i think it's the Queue that has the process that will be executed next? now for FCFS i came up with this charts
yellow means it's executing, green it's waiting for its turn (in READY state), red means it's doing I/O, my question is this correct? if so, what would be the waiting queue be ? i'm thinking it will be P3, P1, P3, P1, P0 (in from right, out from left) which is just the processes sorted based on yellow in reverse. Or should it be the blue stuff ? since the process is in WAIT state there ?
i Also have to make a Wait time and response time table, for:
response time = start time - arrival time
wait time = time where the process is not in RUNNING state, ie it's in WAIT, thus i counted the green blue time since the process started executing
i'm pretty sure that `response time is correct, i'm doubting the latter
Last thing is: at the end of a quantum, the current running process is suspended (interrupted) if and only if the process queue is not empty, since statement has the word quantum i'm assuming it's only valid for Round-Robin scheduling? if so, please elaborate on what this means? i made sense of it like: if quantum time passes, the current running process will be interrupted if and only if there's another process waiting to be executed (ie if we only have one process, and say it runs for 6 units of time, and quantum=3, there's no need to run it for 3 units of time, then make it wait another 3 units of time, then run it again, so the proper answer would be: the process runs from t=0 to t=6 non-stop)

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