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

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.

Related

logic and actions to my transporters fleet in the flow chart in anylogic

Iam trying to build a model represented as shown but the main problem is how to put my hands on transporters and can do sequence logic on them while been loaded and unloaded along the path among my flowchart sequence.assign queue and delay blocks to my transporter type.
error while doing that.
First, i wanted to make a queue and delay before reaching loading point but when i ran the model i had an error as i tried to cast the delay and the queue to my transporter agent (forklift) and not the material item type(agent) , and when i tried to cast it to my agent (material item type) it didn't respond or see the delay or the queue and the transporter didn't stop.
After loading i want to make a second stop (delay) and queue of transporters out side it but , the model only see the delay and (loaded transporters) ran through the queue and stop in the delay block and i want to investigate the queue but the transports didn't stop in it.
Not quite clear what you need but it sounds like you want to explore preparation flow charts as part of Seize and Release actions, see https://anylogic.help/library-reference-guides/process-modeling-library/resourcetaskstart.html.
With these, you can make your resources (forklifts) follow some flow chart logic before they are actually being seized by your agents. This also works with transporters afaik

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

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

Howto design a clock driven multi-agent simulation

I want to create a multi-agent simulation model for a real word manufacturing process to evaluate some dispatching rules. The simulation needs to produce event logs to evaluate time effect of the dispatching rules compared to the real manufacturing event logs.
How can I incorporate the 'current simulation time' into this kind of multi-agent, message passing intensive simulation?
Background:
The classical discrete event simulation (which handles the time-advancement nicely) cannot be applied here, as the agents in the system represent relatively complex behavior and routing requirements plus the dispatching rules require them to communicate frequently. This and other process complexities rule out a centralized scheduling approach as well.
In the manufacturing science, there are thousands of papers using a multi-agent simulation for their solution of some manufacturing related problem. However, I haven't found a paper yet which describes the inner workings or implementation details of these simulations in the required detail.
Unfortunately, using the shortest process time for discrete time stepping in a system might be infeasible as the range of process time is between 0.1s and 24 hours. There is a possibility my simulation will be used for what-if evaluations in a project later on so the simulation needs to run as fast as possible - no option for overnight simulation runs.
The problem size is about 500 resources and 1000 - 10000 product agents, most of them is finished and not participating in any further communication or resource occupation.
Consequently, in result to the communication new events can trigger an agent to do something before its original 'next time' event would arrive. For example, an agent is currently blocked on a resource lasting an hour. However, another higher priority agent needs that resource right away and asks the fist agent to release that resource.
In some sense, I need a way to create a hybrid of classical message passing agent-simulation and the discrete event simulation.
I considered a mediator agent that is involved in every message - a message router and time enforcer which sends around the messages and the timer tick events. Also the mediator agent keeps a list of next event times for various agents. However, I feel there should be a better way to solve my problem as the concept puts an enormous pressure at the mediator agent.
Update
It took a while, but it seems I managed to create a mini-framework and combined the DES and Agent concept into one. I'm sure its nothing new but at least unique: http://code.google.com/p/tidra-framework/ if you are interested.
This problem sounds as if it should be tackled by using parallel discrete-event simulation - the mediator agent you are planning to implement ('is involved in every message', 'sends around messages and timer tick events') seems to be doing the job of a discrete-event simulator right now. You can make this scale to the desired problem size by using more of such simulators in parallel and then use a synchronization algorithm to maintain causality etc. (see, e.g., this book for details). Of course, this requires some considerable effort, and you might be better off by really trying out the sequential algorithms first.
A nice way of augmenting the classical DES-view of logical processes (= agents) that communicate with each other via events could be to blend in some ideas from other formalisms used to describe discrete-event systems, such as DEVS. In DEVS, each entity can specify the duration it will be in a certain state (e.g., the agent blocking a resource), and will only be interrupted by incoming messages (and then change its state accordingly, e.g. the agent freeing the resource).
BTW In which sense do you think that the agents are too complex to be handled with discrete-event simulation? If you regard each agent as a logical process, it doesn't really matter how complex it is from a simulation point of view - or am I getting something wrong here?