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

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

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!

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

Anylogic: avoid unwanted execution of process in seize block

I am trying to simulate manufacturing process by using statechart. And i have created agents for particular machines by statecharts and connecting those agents according to manufacturing process with help of resource pool, seize block and release block
My agent is passing through the resource pool and seize block. And I am expecting to run the model one after another seize blocks. However, when I run the model my all three statcharts are active at a same time, which I do not want. can anybody suggest me a possible way to avoid simultaneous process?
I'm assuming your manufacturing processes don't take 0 time. You're missing Delay blocks, causing all your blocks to execute at the same, instantaneous moment.
On a side note, what you're showing us isn't a statechart, but a flowchart.

How to have a condition simulating an error after a rackPick in Anylogic?

I have a problem with anylogic because I am not able to simulate an error happening to the moving resource (I have only one moving resource) of the rackPick block.
I tried to increase the delay (but I think this is not possible to do at runtime, because once the item has been picked from the rack store, I can find no way to restore the old delay)
I tried to reduce the speed of the moving resource (accessing to the correspondent resource pool), but I have the same problem described in point 1.
How can I do that?
I just need the moving resource to pause its job and resume programmatically.
Thanks a lot in advance.
Tricky one, here is one possible way:
make your RackRick/Store use a ResourcePool with custom agents
make the ResourcePool use a Downtime block
Setup the downtime block to resemble your failures. Easiest if you have stochastic failure rates.
Alternatively, you can experiment with priorities: have a very high-prior task that can preempt your RackPick/Store task. Set the RackPick "Task preemption policy" to "Wait for original resource".
(Will need some trial'n'error on your end :) )

How can I create a Scheduled Task that will run every Second in MarkLogic?

MarkLogic Scheduled Tasks cannot be configured to run at an interval less than a minute.
Is there any way I can execute an XQuery module at an interval of 1 second?
NOTE:
Considering the situation where the Task Server is fully loaded and I need to make sure that the secondly scheduled task gets the Task Server thread whenever it needs.
Please let me know if there is anything in MarkLogic that can be used to achieve this.
Wanting rapid-fire scheduled tasks may be a hint that the design needs rethinking.
Even running a task once a minute can be risky, and needs careful thought to manage the possibilities of overlapping tasks and runaway tasks. If the application design calls for a scheduled task to run once a second, I would raise that as a potentially serious problem. Back up a few steps, and if necessary ask a new question about the higher-level problem that led to looking at scheduled tasks.
There was a sub-question about managing queue priority for tasks. Task priorities can handle some of that. There are two priorities: normal and higher. The Task Server empties the higher-priority queue first, then the normal queue. But each queue is still a simple queue, and there's no way to change priorities after a task has been spawned. So if you always queue tasks with priority=higher, then they'll all be in the higher priority queue and they'll all run in order. You can play some games with techniques like using server fields as signals to already-running tasks. But wanting to reorder tasks within a queue could be another hint that the design needs rethinking.
If, after careful thought about all the pitfalls and dangers, I decided I needed a rapid-fire task of some kind.... I would probably do it using external requests. Pick any scripting language and write a simple while loop with an HTTP request to the MarkLogic cluster. Even so, spend some time thinking about overlapping requests and locking. What happens if the request times out on the client side? Will it keep running on the server? Will that lead to overlapping requests and require deadlock resolution? Could it lead to runaway resource consumption?
Avoid any ideas that use xdmp:sleep. That will tie up a Task Server thread during the sleep period, and then you'll have two problems.