Anylogic ResourcePoolName.idle() is not update real time? - anylogic

I use the below command to check availability of ResourcePool:
ResourcePoolName.idle()
ResourcePoolName.busy()
I found that the idle unit (or busy unit) is slowly updated.
When the agent leave the Service block, ResourcePoolName.busy() is still busy and ResourcePoolName.idle() is sill not idle. I need to wait for the agent to enter the next 3rd block so that ResourcePoolName.busy() unit and ResourcePoolName.idle() are updated correctly.
How can we have the idle unit (or busy unit) of the ResourcePool update real time????

Someone recommend me this solution and it work well.
Instead of using A Services Block alone, I uses Services Block + Delay (with delay time = 0). Now when the agent leave the Delay Block, ResourcePoolName.idle() status did updated correctly.

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

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

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.

How to stop or suspend and restart “service delay" or the "delay" blocks from the agent based diagram?

By following your advice I’m constructing small models to learn how to use AnyLogic and build my simulation.
I need discrete events diagram interacting with agent based, where the agent based will represent a “service process” based in a previous recommendation it was straight forward to trigger the agent based activity, but I cannot stop or suspend or delay the “delay” block, I tryed to use the “until stopDelay is called” function but I could not make it work, I decided to test with and cyclic event inside the discrete event agent and but was not possible. I am considering that maybe my approach is not correct, and I need to use a different strategy to stop the discrete events process while the agent-based process is running, however since agent based is attempting to simulate some human behaviour, I’m interested in the time variations this could cause to the discrete events process. So my question is how to stop or suspend the “service delay or the delay blocks and restart them from the agent based diagram?
If you just need to store an entity somewhere until Agent process is done then I would recommend using using a 'wait' block instead of a 'delay'. The whole point of a delay is to have a timed exit so suspending it doesn't align with the intended use-case. You can read more about 'wait' block here.
I found the the Job Shop model example, some blocks using stopDelayForAll(), with a "if" code block, so I noticed that it was using a parameter, so I made some changes and the code I'm using and worked is this:
if ( Inqueue >= queCap )
delay.stopDelayForAll();
"Inqueue" is a variable capturing data from the delay block and queCap is a parameter telling the queue block capacity.

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)

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.