Reputation: 61
Basically I have a simple source/sink diagram on anlylogic:
The source will insert into my line the agent "CMproduto" and will get the characteristics of the agent from my DB. My agent will then be sorted by the line that it will be processed by the conditional object to the corresponding queue (of line 1/2/3) and agents will exit my model one by one through a condition. However, my database can be changed (according to the rest of my simulation), so, I need to destroy all current agents in all 3 queues (and also from my CMproduto population) and reinsert them through the "source" but with the new values from my updated database. Thus, my database will always register old models (models that have already gone to my sink), for that i've created a column in my database that is updated with "0" or "1" if the agent has not or has been processed, respectively. So, I should only reinsert into my model agents that have values "0" in this column (I don't want to reprocess models that have already been processed).
This is how my source is configured. Basically agents will enter with the "time between arrival" being 0 (so all of them are inserted at the same time in my model). As said, parameters are being captured from the DB and there is a limited number of arrivals.
My question is: if i delete those agents from my "CMproduto" will they be automatically deleted from my queues? In addition, how can i reinsert agents into my model with the characteristics from my DB (and only models that have not yet been processed)?
Upvotes: 0
Views: 2037
Reputation: 726
I would remove the agents from the queue and then send them back through the flow via an enter block. The code would look something like:
while( queue.size() > 0 ){
// get the agent out of the queue
Agent agent = queue.removeFirst();
// maybe insert some code to adjust the paramters
// then send back to the enter block
enter.take( agent );
}
Your diagram might look something like:
You can use agent.deleteSelf() to remove an agent from a population, but you will get an error if it is still in a flowchart block. Also, when I am cleaning up agents, I always send them to a sink, instead of just removing them from the population. In the past, we have noticed this helps with memory leaks, along with cleaning up our own references.
I notice that you are just sending agents to queues that wait on some conditions (hold blocks). You may want to consider the wait block (see help menu). You may also want to consider a detached queue, where you just pull agents out of the queue when you conditions are met...and really, if you are just keeping agents in a queue, you might not need these blocks at all - you could just store agents in a collection and add/remove/sort, etc as needed.
Upvotes: 2