suspend(agent) is not working in AnyLogic - simulation

I have a SERVICE block which i want to stop working for two hours when 10th agent enter the service.
So I used agent suspend and resume function for that. The image of implementation is given below.
MyDynamicEvent Properties section:
Now when i run the model and 10th agent enter the SERVICE, traceln("reparing") gets print on console but MyDynamicEvent does not work which means SERVICE block does not stop working and agents keep passing the SERVICE block. It suppose to stop for 2 hours when 10th agent enters the service.

You understand Dynamic Events wrong. In your code, you are creating the DE when the 10th agent enters, but you schedule it to start 2 hrs later. So it will trigger, but 2 hrs after the 10th agent arrived.
So the problem does not lie with the DE, but with the self.suspend(), imo

Related

Anylogic: Measuring process time without considering waiting time during evening

I have created a discrete simulation model for our production processes in which the capacity, output, etc. should be simulated for the coming year. The model works, but I have a problem with measuring the process time. Our production only works from 7 a.m. to 3 p.m. Is there a way to set the TimeMeasureStart and TimeMeasureEnd block so that the time is only measured during the shift?
As a simplified example with a TimeMeasureStart, a service and a TimeMeasureEnd block:
The agent passes TimeMeasureStart at 2:30 p.m. and immediately enters the service block. The service time is 2 hours. The worker starts the service and goes home at 3:00 p.m. The agent waits in the service block from 3:00 p.m. to 7:00 a.m. At 7 a.m. the worker continues the service (until 8:30 a.m.). As soon as it is finished, the agent passes the TimeMeasureEnd block. The result is currently a process time of 18 hours. However, I only want to measure the time that is worked, so that I get 2 hours as the process time.
Is there a possibility to set / program the TimeMeasureStart / TimeMeasureEnd blocks accordingly so that the waiting time is not included?
My first suggestion would be to ensure that you really need calendar time, why not just run the model in hours and every hour is a working hour... then you don't need to shift schedule.
But often for reporting or having different shift patterns within your model requires you to need calendar time as the basis.
Here is a simple solution: Simply record the time a resource was seized through your own local variables.
You need to add two double variables to your agent 1 for last start and 1 for the cumulative time
previousServiceStart and cummServiceTime
and then save the times in the resource pool using the On seize and On release code
I casted the agent to my custom agent using the (MyAgent)agent code, so that I can access the variables

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.

Anylogic 'service block' one at a time

I'm new with anylogic so I'm not sure how to do this simple thing but is there a way for the service block to only do one agent at a time? I'm making a simulation but it seems that if one agent goes to the service block, it will be serviced even if there is still another agent being serviced? I don't know how to stop the new agent when there is still an agent being serviced. Please help me. Thanks
the problem is probably because you have not set any resources for service block. if you define a resource for your service block, only one agent can be processed at one time and other agents would wait in queue until the delay of first agent is finished.

Anylogic SelectOutput5 Custom Distribution

I am creating a conveyor system, where the source produces 3 agents every 325 seconds. I would like each agent to convey to different specific areas but am having problems evenly distributing them using the SelectOutput5 block.
I am new to the software and have limited knowledge of Java. Is there a custom distribution function that forces the first agent to exit from port 1, second exit port 2 and third exit port 3? I would like the function to be capped at 3 and return back to exiting from port 1 when the 4th agent enters, port 2 for 5th agent, etc...
Try a variable to track last exit and a function to get the next exit.The image below shows an example.

SQL Agent Job runtime alert

I was hoping i could get some help on how i can setup an e-mail alert for a specific agent job, such that it sends an e-mail alert when the run duration exceeds 30 minutes.
Would it be easier to add this step in the job itself? Are there any available methods in the SQL Agent GUI or do i have to create a new job? I figured creating a new job is less likely as i would have to query the sysjobhistory in msdb; The value is only updated once the job finishes so that doesn't help...I need it to check the real time duration of 1 specific agent job as it's running...
Specifically because it happens that the job runs into a deadlock ( That's no longer an issue now), so the job just stays stuck on the table it's locked on, and i only get the notification from the enduser that the report doesn't return results :S
The best method outside of 3rd party monitoring software is to create a high-frequency SQL Agent Job that runs a query on active sessions (returned by something like sp_who) for the duration of spids. This way you can have this monitoring job email you whenever a spid goes over a threshold. Alternatively you could have it compare the current runtime vs a calculated average runtime gleaned from the sys.jobhistory table.